/
WinStat.cpp
4451 lines (3593 loc) · 170 KB
/
WinStat.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* @(#)Z 1.77 com/src/ui/WinStat.cpp, odui, od96os2, odos29712d 97/03/21 17:20:33 (97/02/19 15:20:13) */
//====START_GENERATED_PROLOG======================================
//
//
// COMPONENT_NAME: odui
//
// CLASSES: none
//
// ORIGINS: 82,27
//
//
// (C) COPYRIGHT International Business Machines Corp. 1995,1996
// All Rights Reserved
// Licensed Materials - Property of IBM
// US Government Users Restricted Rights - Use, duplication or
// disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//
// IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
// CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
// USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
// OR PERFORMANCE OF THIS SOFTWARE.
//
//====END_GENERATED_PROLOG========================================
//
/********************************************************************/
/* Licensed Materials - Property of IBM */
/* */
/* */
/* Copyright (C) International Business Machines Corp., 1994. */
/* Copyright (C) Apple Computer, Inc., 1994 */
/* */
/* US Government Users Restricted Rights - */
/* Use, duplication, or disclosure restricted */
/* by GSA ADP Schedule Contract with IBM Corp. */
/********************************************************************/
/* IBM Change History (most recent first): */
/* */
/* 21996 05/15/96 brr Added API's for Popup. */
/* CreatePopupMenu */
/* CreatePopupMenu */
/* AcquireBasePopupMenu */
/* Renamed GetCurrentPopupMenu to */
/* AcquireCurrentPopupMenu */
/* 21498 04/29/96 brr Created CreateMenuBarEx */
/* 21467 04/26/96 brr Changed InitMenuBar to InitMenuBarEx */
/* 21316 04/22/96 brr Changed new param to InitMenuBar to be an */
/* address to an array of submenu ID's rather */
/* than the menuID we had tried to do with */
/* defect #21263 */
/* 21263 04/19/96 brr Changed call to InitMenuBar to pass another */
/* parameter that is the menuID. */
/* 21285 04/19/96 brr Removed #include CmdDefs.xh */
/* 2/21/96 jrb Complete Apple DR4 Integration */
/* 145958 12/06/95 pfe Added Set and Get longname methods */
/* 144010 11/27/95 st AdjustPartMenus: allow adjustmenus to go to root part */
/* 142229 11/25/95 st change window list to CUA '89 style */
/* 143654 11/13/95 ced Apple DR4 IDL changes. */
/* 136667 11/6/95 pfe THROW on null platwindow in RegisterWindow */
/* 142504 11/2/95 st move adjust menu items to rlshell */
/* 131165 9/29/95 st changes to window title/window list entry */
/* 135340 9/13/95 BLG Add prompt line text support for popup menus*/
/* 9/08/95 mjk Add Unicode Support */
/* 133968 8/24/95 pfe Port of Apple DR3 code */
/* 129227 8/15/95 pfe infinite loop in AcquireFrontFloatingWindow */
/* 130696 8/07/95 pfe throw in Internalize if no Externalize */
/* 128450 7/17/95 faa window title set to file name w/o path */
/* 124340 6/03/95 st disable VIEW-OPENAS menu item */
/* 122761 6/01/95 BLG returning null instead of valid handle */
/* 123687 6/01/95 BLG OdwindowState::SetDefaultWindowTitles */
/* traped if draft parameter Null put in test */
/* 107897 5/12/95 st exception handling in methods for null draft*/
/* Also put in 2 methods for popup menus */
/* 121993 5/11/95 ced Put back in code in SetDefaultWindowTitles */
/* accidently taken out during B1C16 merge for */
/* switch list entry and fix buffer overflow */
/* bug with long titles. */
/* 119388 4/29/95 st changes for new menus - need currentmenubar */
/* 120604 4/28/95 ced Merge with B1C16 Apple code. */
/* */
/********************************************************************/
/*
File: WinStat.cpp
Contains: Definition of ODWindowState class
Owned by: Richard Rodseth
Copyright: © 1994 - 1995 by Apple Computer, Inc., all rights reserved.
Change History (most recent first):
<82> 11/2/95 RR #1298525, 1298642 Internalize now uses a
SUView on the draftsProperties, and checks
for reference validity
<81> 10/26/95 eeh 1296308: deal with non-persistant frames in
Internalize
<80> 10/24/95 RR #1295596 OpenWindows no longer calls
select() during normal document open.
<79> 10/18/95 RR 1289153: Recover from exceptions creating /
internalizing / registering
windows. Added TRY/CATCH in CATCH block of
::INnternalize
<78> 10/17/95 jpa 1289153: Recover from exceptions creating /
internalizing / registering windows.
<77> 10/16/95 RR #1293067 Pass shouldDispose to
RegisterWindow
<76> 10/8/95 TJ Fixes Recomended by Refball
<75> 10/3/95 eeh 1287095: use ReleaseObject in
RegisterWindow
<74> 10/3/95 TJ Changes done by RefBall Team
<73> 9/21/95 RR # 1285189 AcquireFrontWindow calls
FrontWindow() rather than
GetFrontNonFloatingWindow
<72> 9/13/95 T‚ 1282067 FB3: UI temp var before SOM_TRY
<71> 9/12/95 RR #1274439 Don't activate/deactivate windows
when in background
<70> 9/6/95 RR #(1236387) Deactivate before suspend.
Reactivate after Resume
<69> 9/1/95 RR # 1279100/1280338 Added IsActive test to
SelectODWindow
<68> 8/26/95 T‚ 1274606 FB2: Patching Remarks
<67> 8/25/95 JBS 1263078 FB: fix part editor swapping
<66> 8/15/95 RR # 1233767 Use window iterator in
SuspendResume
<65> 8/12/95 T‚ 1276812 Need to use TempObjs and TempRefs
for exception safety and to avoid TRY
blocks, 1276807 Opt./Bug: use StdTypIO
routines for portable streaming & smaller
footprint, 1276806 Optimization: use
kODFalse instead of kODTrue in comparisons
<64> 8/3/95 RR #1257260: Collapse B classes. Remove
somInit methods. Don't call IsInitialized
or SubclassResponsibility
<63> 8/2/95 VL 1270320: Correct refcounting in
SetCurrentMenuBar and SetBaseMenuBar.
<62> 6/30/95 RR 1242642 BB Ref counting fixes in
HideODWindow.
<61> 6/28/95 RR 1242642 BB Mostly ref counting. AddWindow
and RemoveWindow adjust ref counts. Window
iterator skips items marked for lazy
deletion.
<60> 6/26/95 T‚ 1242642 BB:Fix refcounting bugs
<59> 6/25/95 T‚ 1242642 BB: Turn on ODDebug warning if
refcount is wrong in
ODRefCntObjectsomUninit.
<58> 6/22/95 RR #1245283 Undoable frame deletion
#1209427 Changed private api between
iterator and iteratee. Allow deletion while
iterating
<57> 6/19/95 jpa Added hook to check for path pop-up
(cmd-click title bar) [1259398]
<56> 6/15/95 RR #1256879 Get->AcquireCurrentMenuBar
<55> 6/8/95 RR #1257260 Collapse base classes. #1214898
StdTypes.r -> ODTypes.r
<54> 5/31/95 RR #1251403 Release after AcquirePart #1251980
Missing release in GetFrontRootWindow
<53> 5/26/95 RR #1251403: Multithreading naming support
<52> 5/25/95 jpa List.h --> LinkList.h [1253324]
<51> 5/17/95 RR #1250135/1250137/1250143 Getters increment
refcount
<50> 5/10/95 RR # 1234319. Check for rootFrameList before
internalizing
<49> 5/4/95 eeh 1242889: get drafts string from resource
<48> 5/2/95 RR # 1244133 Fixed SetDefaultWindowTitles to
avoid extra bogus characters
<47> 4/28/95 RR 1211085 Remove 5$ comments
<46> 4/14/95 T‚ With RR & CG: #1194507 DR/BB:title bar of a
draft window doesn't reveal it is a draft
or which draft it is
<45> 4/13/95 RR #1216618 Added ODVolatile
<44> 4/7/95 RR #1216618 Added SOM_TRY etc.
<43> 4/6/95 RR # 1236361 Call Deactivate in HideODWindow.
Remove redundant code to prevent
deadstripping of PlatformFile
<42> 4/4/95 RR # 1220104 Use ODObjectsAreEqual
<41> 3/22/95 RR #1225420, 1227993 Parts internalize
windows. Modified OpenWindow, Externalize,
Internalize. Added RegisterWindowForFrame
<40> 3/10/95 RR # 1225861 Send Suspend/resume to invisible
windows
<39> 3/7/95 RR # 1151165 Cleaned up AdjustPartMenus #
1220929 Added fMenuFocus
<38> 3/3/95 CC # 1205622: Ensure activate event is
delivered after modal dialog is dismissed.
<37> 3/1/95 RR # 1205622 ::OpenWindows now supports
re-opening an open draft by bringing its
windows to the front.
<36> 2/24/95 jpa Use ODNewRgn. [1220810]
<35> 2/22/95 RR # 1213850 Call AdjustMenus for root part of
active window before calling it for menu
focus
<34> 2/20/95 T‚ #1221861 BB: Incomplete AOCE support needs
to be removed from OpenDoc
<33> 1/31/95 RR # 1209165 Rewrote HandleAOCEEvent. #1209552
Call SendBehind in HideODWindow
<31> 1/26/95 VL #???: Use updated Storage Unit Ref API.
<30> 1/25/95 RR #1211853 Removed session parameter from
CreateMenuBar. Pass _fSession to
InitMenuBar
<29> 1/23/95 RR # 1211853 Added CreateMenuBar
<28> 1/4/95 eeh 1209165: added test to
HandleAOCEMailerEvent
<27> 12/20/94 VL 1195012: Make Storage calls be
marshallable.
<26> 12/19/94 eeh 1192626: change ::Internalize not to
duplicate windows already open
<25> 11/28/94 RR Check for AOCE presence
<24> 11/1/94 RR #1196761 Don't exit HandleAOCEMailerEvent
without handling updates in inactive mailer
windows
<23> 10/18/94 RR Used AcquireWindow(id) to validate windows in
CLoseWindows, in case part closed
subsidiary windows
<22> 9/29/94 RA 1189812: Mods for 68K build.
<21> 9/23/94 VL 1155579, 1184272: Use StorUtil to
create/get container and its file.
<20> 9/22/94 eeh #1154961 AddAOCEMailer takes additional
param.
<19> 9/19/94 eeh #1164891: check for userCanceledErr after
SMPMailerEvent call.
<18> 9/1/94 RR #1176805 Release old base menu bar
<17> 9/1/94 CC RADAR #1181971 - missing factory methods
(for JBS)
<16> 8/29/94 RR #1171772 DOn't call SelectWindow
<15> 8/26/94 T‚ #1181761 rename obsolete kOD IDs to correct
kODStrong/WeakStorageUnitRefs
<14> 8/26/94 VL 1183174: Use updated cloning APIs.
<13> 8/25/94 RR Added private AcquireBaseMenuBar. Set
generation of menubar in SetBaseMenuBar
<12> 8/19/94 T‚ #1180922 Need to Stop using obsolete types
(kOD ID)
<11> 8/18/94 jpa Filled in CreateCanvas [1180387]
<10> 8/16/94 JBS 1180387: add CreateCanvas()
<9> 8/15/94 JBS 1181138: add frameType to CreateFrame();
1181156: UI API Cleanup
<8> 8/3/94 VL 1153123: Storage to ODStor.
<7> 7/27/94 eeh fix use of Point and Rect (honesty to SOMÉ)
<6> 7/21/94 eeh fix FixUpMailerWindow
<5> 7/15/94 T‚ make sure PlatformFile code is not
deadstripped
<4> 7/8/94 RR Converted HandleAOCEMailerEvent
<3> 6/27/94 eeh add Environment* parameters to
AOCEHelperObj method calls
<2> 9/27/94 RR Call InitBaseWindowState
<1> 9/26/94 RR first checked in
To Do:
In Progress:
*/
#ifdef DEBUG
// By defining this macro, SOM doesn't define it and I am able to use the
// MyMethodDebug as a break point for IPMD debugging
#define ODWindowStateMethodDebug(c,m) MyMethodDebug(c,m)
static void MyMethodDebug(char *c, char *m);
#endif
#ifdef _PLATFORM_OS2_
#include <ODos2.h>
#endif
#ifdef _PLATFORM_WIN32_
#ifndef _WINDOWS_
#include <windows.h>
#endif
#endif
#ifdef _PLATFORM_UNIX_
#include <Xm/XmAll.h>
#endif
#define ODWindowState_Class_Source
#define VARIABLE_MACROS
#include <WinStat.xih>
#ifndef SOM_ODWindowIterator_xh
#include <WinIter.xh>
#endif
#ifndef _WINUTILM_
#include "WinUtilM.h"
#endif
#ifdef _PLATFORM_MACINTOSH_
#ifndef _UIDEFS_
#include "UIDefs.h"
#endif
#endif
#ifndef _TEMPOBJ_
#include <TempObj.h>
#endif
#ifndef _STDTYPIO_
#include <StdTypIO.h>
#endif
#ifndef SOM_ODSession_xh
#include <ODSessn.xh>
#endif
#ifndef SOM_ODWindow_xh
#include <Window.xh>
#endif
#ifndef SOM_ODMenuBar_xh
#include <MenuBar.xh>
#endif
#if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
#ifndef SOM_ODPopup_xh
#include <Popup.xh>
#endif
// Includes for NLS support for window title
#include <ODMessag.h> // Header file for catalog IDs
#include <stdio.h> // Used for sprintf for window title string
#endif
#if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
#include <odres.h>
#endif
#ifndef SOM_ODArbitrator_xh
#include <Arbitrat.xh>
#endif
#ifndef SOM_Module_Apple_defined
#include <Part.xh>
#endif
#ifndef SOM_ODFrame_xh
#include <Frame.xh>
#endif
#ifndef SOM_ODFacet_xh
#include <Facet.xh>
#endif
#ifndef SOM_ODCanvas_xh
#include <Canvas.xh>
#endif
#ifndef SOM_ODDraft_xh
#include <Draft.xh>
#endif
#ifndef SOM_ODDocument_xh
#include <Document.xh>
#endif
#ifndef SOM_ODContainer_xh
#include <ODCtr.xh>
#endif
#ifndef SOM_ODStorageSystem_xh
#include <ODStor.xh>
#endif
#ifndef SOM_ODStorageUnit_xh
#include <StorageU.xh>
#endif
//#ifndef SOM_Module_OpenDoc_Commands_defined
//#include <CmdDefs.xh>
//#endif
#ifdef _PLATFORM_MACINTOSH_
#ifndef __GESTALTEQU__
#include <GestaltEqu.h>
#endif
#ifndef _DLOGUTIL_
#include <DlogUtil.h>
#endif
#ifndef _USERSRCM_
#include <UseRsrcM.h>
#endif
#endif // _PLATFORM_MACINTOSH_
#ifndef _PLFMFILE_
#include <PlfmFile.h>
#endif
#ifndef _PASCLSTR_
#include "PasclStr.h"
#endif
#ifndef _LINKLIST_
#include <LinkList.h>
#endif
#ifndef _ORDCOLL_
#include "OrdColl.h"
#endif
#ifndef _EXCEPT_
#include "Except.h"
#endif
#ifndef SOM_Module_OpenDoc_StdTypes_defined
#include <StdTypes.xh>
#endif
#ifndef SOM_Module_OpenDoc_StdProps_defined
#include <StdProps.xh>
#endif
#ifndef SOM_Module_OpenDoc_Foci_defined
#include <Foci.xh>
#endif
#ifndef _ODUTILS_
#include <ODUtils.h>
#endif
#ifndef _STORUTIL
#include <StorUtil.h>
#endif
#ifdef _PLATFORM_MACINTOSH_
#ifndef __LOWMEM__
#include <LowMem.h> // For WindowList global
#endif
#ifndef __TOOLUTILS__
#include <ToolUtils.h>
#endif
#endif // _PLATFORM_MACINTOSH_
#ifndef _ODDEBUG_
#include "ODDebug.h" // Adkins -- added
#endif
#ifdef _PLATFORM_MACINTOSH_
#ifndef _WINPOPM_
#include "WinPopM.h"
#endif
// New Window API uses a new "WindowRef" type as an opaque window type. So that we can compile
// with or without the new Windows.h, define WindowRef if it's not already defined: --jpa
#ifndef STRICT_WINDOWS
#define WindowRef WindowPeek
#endif
#endif // _PLATFORM_MACINTOSH_
#ifdef _PLATFORM_WIN32_
#ifndef _OLEWRAP_H_
#include "olewrap.h"
#endif
#ifndef _OLEMGRW_H_
#include "olemgrw.h"
#endif
#ifndef SOM_OpenDocShell_xh
#include "odshell.xh"
#endif
#ifndef SOM_ODSession_xh
#include "odsessn.xh"
#endif
#ifndef SOM_DocumentManager_xh
#include "docmgr.xh"
#endif
#endif
#define ODDebugActivates 0
#ifdef DEBUG
// This method is only used in the debug case as a break point for IPMD
static void MyMethodDebug(char *c, char *m)
{
SOMMethodDebug(c,m);
}
#endif
#ifdef _PLATFORM_MACINTOSH_
#pragma segment ODWindowState
#endif
#include "WinStatB.cpp" // Platform-independent methods, if any
#if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
// Define the constant string for the docshell window class
const char *kODDocumentWindowClass = "ODDocumentWindowClass";
#endif
#ifdef _PLATFORM_OS2_ // CED
#ifdef _UNICODE_
char szMsg1[Str255];
#endif
//----------------------------------------
// Mac style window manipulation functions
inline ODBoolean SendBehind(ODPlatformWindow aWindow, ODPlatformWindow behindWindow)
{
return WinSetWindowPos(aWindow, behindWindow, 0, 0, 0, 0, SWP_ZORDER);
}
inline ODBoolean BringToFront(ODPlatformWindow aWindow)
{
return WinSetWindowPos(aWindow, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
}
inline void SelectWindow(ODPlatformWindow aWindow)
{
WinFocusChange(HWND_DESKTOP, aWindow, FC_NOBRINGTOTOP | FC_NOSETFOCUS);
// If the current focus window is still the window being passed in. It won't
// be if ExcFocus has accomplished its WinSetFocus due to a mouse click or
// a part has changed focus to some other window (embedded PM control perhaps).
if (WinQueryFocus(HWND_DESKTOP) == aWindow)
{
// This means previous attempts to set the focus to the client window
// most likely failed in ExcFocus.cpp. Set focus to the client area
// so keyboard entry will work.
WinSetFocus(HWND_DESKTOP, WinWindowFromID(aWindow, FID_CLIENT));
}
}
inline ODBoolean ShowHide(ODPlatformWindow windowToShow, ODBoolean visibility)
{
return WinShowWindow( windowToShow, visibility );
}
inline ODBoolean HiliteWindow(ODPlatformWindow aWindow, ODBoolean activate)
{
if (activate)
return WinSetActiveWindow(HWND_DESKTOP, aWindow);
else
return WinSetActiveWindow(HWND_DESKTOP, HWND_DESKTOP);
}
#endif // _PLATFORM_OS2_
#ifdef _PLATFORM_WIN32_
//----------------------------------------
// Mac style window manipulation functions
inline ODBoolean SendBehind(ODPlatformWindow aWindow, ODPlatformWindow behindWindow)
{
return SetWindowPos(aWindow, behindWindow, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOMOVE);
}
inline ODBoolean BringToFront(ODPlatformWindow aWindow)
{
return SetWindowPos(aWindow, HWND_TOP, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOMOVE);
// Old Novell code. However, BringWindowToTop also activates the window and
// we don't want this.
// return BringWindowToTop(aWindow);
}
inline void SelectWindow(ODPlatformWindow aWindow)
{
SetActiveWindow(aWindow);
}
inline ODBoolean ShowHide(ODPlatformWindow windowToShow, ODBoolean visibility)
{
return ShowWindow( windowToShow, visibility ? SW_SHOWNA : SW_HIDE);
}
inline ODBoolean HiliteWindow(ODPlatformWindow aWindow, ODBoolean activate)
{
if (activate)
return SetActiveWindow(aWindow) ? kODTrue : kODFalse;
else
return SetActiveWindow(HWND_DESKTOP) ? kODTrue : kODFalse;
}
#endif // _PLATFORM_WIN32_
#ifdef _PLATFORM_UNIX_
//----------------------------------------
// MapNotify eventhandler and atom definitions
extern "C" void MapNotifyEventHandler(Widget widget, XtPointer client_data, XEvent *event, Boolean *cont);
const String ODWinStatMapNotifyPropertyAtom = "OpenDoc:WinStat:MyMapNotifyProperty:String";
Atom MyMapNotifyProperty = 0;
//----------------------------------------
// Mac style window manipulation functions
// The windows passed in must be children of the root window
inline void SendBehind(Display *display,
ODPlatformWindow aWindow,
ODPlatformWindow behindWindow)
{
Window windows[2];
windows[0] = behindWindow;
windows[1] = aWindow;
XRestackWindows(display,
windows,
2);
XSync(display, False);
}
#endif // _PLATFORM_UNIX_
#ifdef _PLATFORM_MACINTOSH_
static ODBoolean IsFrontProcess()
{
ProcessSerialNumber currentPSN;
ProcessSerialNumber frontPSN;
OSErr getFrontProcessResult;
OSErr getCurrentProcessResult;
ODBoolean isSameProcess = kODFalse;
// Compare this process and the front process
getFrontProcessResult = GetFrontProcess(&frontPSN);
getCurrentProcessResult = GetCurrentProcess(¤tPSN);
if ((getFrontProcessResult == noErr) && (getCurrentProcessResult == noErr))
SameProcess(&frontPSN, ¤tPSN, &isSameProcess);
return isSameProcess;
}
SOM_Scope void SOMLINK ODWindowStateDeactivateFrontWindows(ODWindowState *somSelf, Environment *ev)
{
ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
ODWindowStateMethodDebug("ODWindowState","ODWindowStateDeactivateFrontWindows");
SOM_TRY
WindowPtr firstDocWindow;
WindowPtr secondDocWindow;
WindowPtr window;
WindowListIterator iter;
firstDocWindow = somSelf->GetFrontNonFloatingPlatformWindow(ev);
if (firstDocWindow != kODNULL)
secondDocWindow = GetNextWindow(firstDocWindow);
window = iter.First();
while (iter.IsNotComplete() && (window != secondDocWindow))
{
if (GetWindowVisible(window) != kODFalse)
{
somSelf->DeactivateWindow(ev,window);
}
window = iter.Next();
}
SOM_CATCH_ALL
SOM_ENDTRY
}
SOM_Scope void SOMLINK ODWindowStateActivateFrontWindows(ODWindowState *somSelf, Environment *ev)
{
ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
ODWindowStateMethodDebug("ODWindowState","ODWindowStateActivateFrontWindows");
SOM_TRY
WindowPtr firstDocWindow;
WindowPtr secondDocWindow;
WindowPtr window;
WindowListIterator iter;
firstDocWindow = somSelf->GetFrontNonFloatingPlatformWindow(ev);
if (firstDocWindow != kODNULL)
secondDocWindow = GetNextWindow(firstDocWindow);
window = iter.First();
while (iter.IsNotComplete() && (window != secondDocWindow))
{
if (GetWindowVisible(window) != kODFalse)
{
somSelf->ActivateWindow(ev,window);
}
window = iter.Next();
}
SOM_CATCH_ALL
SOM_ENDTRY
}
#endif // _PLATFORM_MACINTOSH_
#if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
//@ST - popup menus
SOM_Scope ODPopup* SOMLINK ODWindowStateCopyBasePopup(ODWindowState *somSelf, Environment *ev)
{
ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
ODWindowStateMethodDebug("ODWindowState","ODWindowStateCopyBasePopup");
// If there is a popup, return a pointer to the copy of the popup,
// otherwise return null
return _fBasePopup ? (ODPopup*) _fBasePopup->Copy(ev) : (ODPopup*) kODNULL;
}
SOM_Scope void SOMLINK ODWindowStateSetBasePopup(ODWindowState *somSelf, Environment *ev,
ODPopup* thePopup)
{
ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
ODWindowStateMethodDebug("ODWindowState","ODWindowStateSetBasePopup");
SOM_TRY
// If the current popup is different than the one passed in
if (!ODObjectsAreEqual(ev, _fBasePopup, thePopup))
{
// Release the currently held popup
ODReleaseObject(ev, _fBasePopup);
// If the new popup is non-null
if (thePopup)
{
// Acquire the new popup
thePopup->Acquire(ev);
}
// Save away the pointer to the new popup
_fBasePopup = thePopup;
}
SOM_CATCH_ALL
SOM_ENDTRY
}
#endif //_PLATFORM_OS2_ || _PLATFORM_WIN32_ || _PLATFORM_UNIX_
#if defined(_PLATFORM_MACINTOSH_) || defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
SOM_Scope ODWindow* SOMLINK ODWindowStateAcquireFrontWindow(ODWindowState *somSelf, Environment *ev)
{
ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
ODWindowStateMethodDebug("ODWindowState","ODWindowStateAcquireFrontWindow");
ODWindow* odWindow = kODNULL;
SOM_TRY
#ifdef _PLATFORM_UNIX_
Window *windows = kODNULL;
unsigned int numWindows;
XSync(_fDisplay, False);
WindowPtr window = FrontWindow(_fScreen,
&windows,
&numWindows);
if (window != kODNULL)
{
somSelf->ResetRootChildren(ev, kODTrue);
if (somSelf->IsODWindowRootChild(ev,window))
odWindow = somSelf->AcquireODWindowRootChild(ev,window);
somSelf->ResetRootChildren(ev, kODFalse);
}
XFree(windows);
#else
WindowPtr window = FrontWindow();
if (window != kODNULL)
{
if (somSelf->IsODWindow(ev,window))
odWindow = somSelf->AcquireODWindow(ev,window);
}
#endif
SOM_CATCH_ALL
SOM_ENDTRY
// AcquireODWindow increments ref count
//if (odWindow)
// odWindow->Acquire(ev);
return odWindow;
}
SOM_Scope ODWindow* SOMLINK ODWindowStateAcquireFrontFloatingWindow(ODWindowState *somSelf, Environment *ev)
{
ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
ODWindowStateMethodDebug("ODWindowState","ODWindowStateAcquireFrontFloatingWindow");
ODWindow* frontFloatingWindow = kODNULL;
SOM_TRY
WindowListIterator iter;
#ifdef _PLATFORM_UNIX_
somSelf->ResetRootChildren(ev, kODTrue);
WindowPtr platformWindow = iter.First(_fScreen);
#else
WindowPtr platformWindow = iter.First();
#endif
while (iter.IsNotComplete() && (frontFloatingWindow == kODNULL))
{
#ifdef _PLATFORM_UNIX_
ODWindow* odWindow = somSelf->AcquireODWindowRootChild(ev,platformWindow);
#else
ODWindow* odWindow = somSelf->AcquireODWindow(ev,platformWindow);
#endif
if (odWindow != kODNULL)
{
if (odWindow->IsFloating(ev) != kODFalse)
{
frontFloatingWindow = odWindow;
}
else
{
ODReleaseObject(ev, odWindow); // -- T‚: released only if we don't want it.
}
}
#if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
// I believe Apple will want this fix to, since without it
// this is a infinite loop :) [pfe] [129227]
// (Unless there is only one window)
platformWindow = iter.Next();
#endif //_PLATFORM_OS2_ || _PLATFORM_WIN32_ || _PLATFORM_UNIX_
}
#ifdef _PLATFORM_UNIX_
somSelf->ResetRootChildren(ev, kODFalse);
#endif
SOM_CATCH_ALL
frontFloatingWindow = kODNULL;
SOM_ENDTRY
// AcquireODWindow increments ref count
//if (frontFloatingWindow)
// frontFloatingWindow->Acquire(ev);
return frontFloatingWindow;
}
SOM_Scope ODWindow* SOMLINK ODWindowStateAcquireFrontRootWindow(ODWindowState *somSelf, Environment *ev)
{
ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
ODWindowStateMethodDebug("ODWindowState","ODWindowStateAcquireFrontRootWindow");
ODWindow* odWindow = kODNULL;
SOM_TRY
#ifdef _PLATFORM_WIN32_
// If running as an OLE Server
if (_fSession->GetOleManager(ev)->IsOleServer()) {
// Get the shell's active document manager
DocumentManager *docMgr;
docMgr = ODOLEManager::GetShell()->GetActiveDocumentManager(ev);
// If the shell has an active document manager
if (docMgr) {
// Get the OLE wrapper
OleWrapper *wrapper;
wrapper = docMgr->GetOleWrapper(ev);
// If there is an OLE wrapper
if (wrapper) {
// Return the root document window from the OLE wrapper. This would have been
// previously set either in SelectODWindow or ShowODWindow
WindowPtr platformWindow;
platformWindow = wrapper->GetRootDocumentWindow();
odWindow = somSelf->AcquireODWindow(ev,platformWindow);
return odWindow;
}
}
}
#endif
WindowListIterator iter;
#ifdef _PLATFORM_UNIX_
somSelf->ResetRootChildren(ev, kODTrue);
for (WindowPtr platformWindow = iter.First(_fScreen);
#else
for (WindowPtr platformWindow = iter.First();
#endif
iter.IsNotComplete();
platformWindow = iter.Next())
{
#ifdef _PLATFORM_UNIX_
odWindow = somSelf->AcquireODWindowRootChild(ev,platformWindow);
#else
odWindow = somSelf->AcquireODWindow(ev,platformWindow);
#endif
if (odWindow && odWindow->IsRootWindow(ev))
break;
else
ODReleaseObject(ev, odWindow);
}
#ifdef _PLATFORM_UNIX_
somSelf->ResetRootChildren(ev, kODFalse);
#endif
SOM_CATCH_ALL
odWindow = kODNULL;
SOM_ENDTRY
// AcquireODWindow increments ref count
//if (odWindow)
// odWindow->Acquire(ev);
return odWindow; // -- T‚: was acquired in the for loop above.
}
#endif //# _PLATFORM_MACINTOSH_ || _PLATFORM_OS2_ || _PLATFORM_WIN32_ || _PLATFORM_UNIX_
SOM_Scope void SOMLINK ODWindowStateInitWindowState(ODWindowState *somSelf, Environment *ev,
ODSession* session)
{
ODWindowStateData *somThis = ODWindowStateGetData(somSelf);
ODWindowStateMethodDebug("ODWindowState","ODWindowStateInitWindowState");
LinkedList* linkedList = kODNULL; ODVolatile(linkedList);
SOM_TRY
/* Moved from somInit. SOM itself sets fields to zero
_fWindowList = kODNULL;
_fSession = kODNULL;
_fBaseMenuBar = kODNULL;
_fCurrentMenuBar = kODNULL;
_fNextID = 0;
_fMenuFocus = 0;
_fIteratorCount = 0;
*/
#if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
/* Moved from somInit. SOM itself sets fields to zero
_fCurrentPopupMenu = kODNULL;
_fBasePopup = kODNULL;
*/
// Allocate storage for the long document name and initialize it to
// an empty string.
_fDocLongName = new char[1]; //145958
_fDocLongName[0] = '\0'; //145958
#endif
somSelf->InitObject(ev);
_fSession = session;
_fMenuFocus = _fSession->Tokenize(ev,kODMenuFocus);
linkedList = new LinkedList;
_fWindowList = linkedList;
#ifdef _PLATFORM_OS2_
// If the document shell window class is not already registered
CLASSINFO classinfo;
if (!WinQueryClassInfo(_fSession->GetWindowSystemData(ev)->hab,
kODDocumentWindowClass,
&classinfo))
{
// Register the document shell window class
if(!WinRegisterClass(_fSession->GetWindowSystemData(ev)->hab,
kODDocumentWindowClass,
_fSession->GetWindowSystemData(ev)->windowProc,
CS_SIZEREDRAW | CS_MOVENOTIFY,
12L))
{
// Throw an error
THROW(kODErrUndefined);
}
}
#endif
#ifdef _PLATFORM_WIN32_
// If the document shell window class is not already registered
WNDCLASS existingWC;
if (!GetClassInfo(_fSession->GetWindowSystemData(ev)->instance,
kODDocumentWindowClass,
&existingWC))
{
// Register the document shell window class
WNDCLASS wc;
wc.style = CS_DBLCLKS;
wc.lpfnWndProc = _fSession->GetWindowSystemData(ev)->windowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 12;
wc.hInstance = _fSession->GetWindowSystemData(ev)->instance;
wc.hIcon = LoadIcon(_fSession->GetWindowSystemData(ev)->resInstance,
MAKEINTRESOURCE(IDR_PRODUCTINFO));
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE + 1);