3 #include "wx/mac/uma.h"
4 #include "wx/mac/aga.h"
7 #include <Carbon/Carbon.h>
9 #include <Navigation.h>
15 #define GetControlOwner( control ) (**control).contrlOwner
16 // since we always call this in the right context we don't have to set and reset the port
17 #define InvalWindowRgn( window , rgn ) InvalRgn( rgn )
20 static bool sUMAHasAppearance
= false ;
21 static long sUMAAppearanceVersion
= 0 ;
22 extern int gAGABackgroundColor
;
23 bool UMAHasAppearance() { return sUMAHasAppearance
; }
24 long UMAGetAppearanceVersion() { return sUMAAppearanceVersion
; }
26 static bool sUMAHasWindowManager
= false ;
27 static long sUMAWindowManagerAttr
= 0 ;
29 bool UMAHasWindowManager() { return sUMAHasWindowManager
; }
30 long UMAGetWindowManagerAttr() { return sUMAWindowManagerAttr
; }
31 void UMACleanupToolbox()
33 #if UMA_USE_APPEARANCE
34 if ( sUMAHasAppearance
)
36 UnregisterAppearanceClient() ;
39 if ( NavServicesAvailable() )
44 void UMAInitToolbox( UInt16 inMoreMastersCalls
)
48 for (long i
= 1; i
<= inMoreMastersCalls
; i
++)
51 ::InitGraf(&qd
.thePort
);
56 ::FlushEvents(everyEvent
, 0);
59 PurgeSpace(&total
, &contig
);
64 #if UMA_USE_APPEARANCE
66 if ( Gestalt( gestaltAppearanceAttr
, &theAppearance
) == noErr
)
68 sUMAHasAppearance
= true ;
69 RegisterAppearanceClient();
70 if ( Gestalt( gestaltAppearanceVersion
, &theAppearance
) == noErr
)
72 sUMAAppearanceVersion
= theAppearance
;
76 sUMAAppearanceVersion
= 0x0100 ;
79 #endif // UMA_USE_APPEARANCE
82 if ( Gestalt( gestaltWindowMgrAttr
, &sUMAWindowManagerAttr
) == noErr
)
84 sUMAHasWindowManager
= sUMAWindowManagerAttr
& gestaltWindowMgrPresent
;
86 #endif // UMA_USE_WINDOWMGR
91 // Call currently implicitely done : InitFloatingWindows() ;
93 if ( sUMAHasWindowManager
)
94 InitFloatingWindows() ;
100 if ( NavServicesAvailable() )
107 long UMAGetProcessMode()
110 ProcessInfoRec processinfo
;
111 ProcessSerialNumber procno
;
113 procno
.highLongOfPSN
= NULL
;
114 procno
.lowLongOfPSN
= kCurrentProcess
;
115 processinfo
.processInfoLength
= sizeof(ProcessInfoRec
);
116 processinfo
.processName
= NULL
;
117 processinfo
.processAppSpec
= NULL
;
119 err
= ::GetProcessInformation( &procno
, &processinfo
) ;
120 wxASSERT( err
== noErr
) ;
121 return processinfo
.processMode
;
124 bool UMAGetProcessModeDoesActivateOnFGSwitch()
126 return UMAGetProcessMode() & modeDoesActivateOnFGSwitch
;
131 void UMASetMenuTitle( MenuRef menu
, StringPtr title
)
134 long size
= GetHandleSize( (Handle
) menu
) ;
135 const long headersize
= 14 ;
136 int oldlen
= (**menu
).menuData
[0] + 1;
137 int newlen
= title
[0] + 1 ;
139 if ( oldlen
< newlen
)
141 // enlarge before adjusting
142 SetHandleSize( (Handle
) menu
, size
+ (newlen
- oldlen
) );
145 if ( oldlen
!= newlen
)
146 memmove( (char*) (**menu
).menuData
+ newlen
, (char*) (**menu
).menuData
+ oldlen
, size
- headersize
- oldlen
) ;
148 memcpy( (char*) (**menu
).menuData
, title
, newlen
) ;
149 if ( oldlen
> newlen
)
152 SetHandleSize( (Handle
) menu
, size
+ (newlen
- oldlen
) ) ;
155 SetMenuTitle( menu
, title
) ;
159 UInt32
UMAMenuEvent( EventRecord
*inEvent
)
161 #if UMA_USE_APPEARANCE
162 if ( UMAHasAppearance() )
164 return MenuEvent( inEvent
) ;
169 if ( inEvent
->what
== keyDown
&& inEvent
->modifiers
& cmdKey
)
171 return MenuKey( inEvent
->message
& charCodeMask
) ;
177 void UMAEnableMenuItem( MenuRef inMenu
, MenuItemIndex inItem
)
179 #if UMA_USE_8_6 || TARGET_CARBON
180 EnableMenuItem( inMenu
, inItem
) ;
182 EnableItem( inMenu
, inItem
) ;
186 void UMADisableMenuItem( MenuRef inMenu
, MenuItemIndex inItem
)
188 #if UMA_USE_8_6 || TARGET_CARBON
189 DisableMenuItem( inMenu
, inItem
) ;
191 DisableItem( inMenu
, inItem
) ;
195 void UMAAppendSubMenuItem( MenuRef menu
, StringPtr l
, SInt16 id
)
198 memcpy( label
, l
, l
[0]+1 ) ;
199 // hardcoded adding of the submenu combination for mac
201 int theEnd
= label
[0] + 1;
203 theEnd
= 251; // mac allows only 255 characters
204 label
[theEnd
++] = '/';
205 label
[theEnd
++] = hMenuCmd
;
206 label
[theEnd
++] = '!';
207 label
[theEnd
++] = id
;
208 label
[theEnd
] = 0x00;
210 MacAppendMenu(menu
, label
);
213 void UMAInsertSubMenuItem( MenuRef menu
, StringPtr l
, MenuItemIndex item
, SInt16 id
)
216 memcpy( label
, l
, l
[0]+1 ) ;
217 // hardcoded adding of the submenu combination for mac
219 int theEnd
= label
[0] + 1;
221 theEnd
= 251; // mac allows only 255 characters
222 label
[theEnd
++] = '/';
223 label
[theEnd
++] = hMenuCmd
;
224 label
[theEnd
++] = '!';
225 label
[theEnd
++] = id
;
226 label
[theEnd
] = 0x00;
228 MacInsertMenuItem(menu
, label
, item
);
231 void UMAAppendMenuItem( MenuRef menu
, StringPtr l
, SInt16 key
, UInt8 modifiers
)
234 memcpy( label
, l
, l
[0]+1 ) ;
239 label
[++pos
] = toupper( key
);
242 MacAppendMenu( menu
, label
) ;
245 void UMAInsertMenuItem( MenuRef menu
, StringPtr l
, MenuItemIndex item
, SInt16 key
, UInt8 modifiers
)
248 memcpy( label
, l
, l
[0]+1 ) ;
253 label
[++pos
] = toupper( key
);
256 MacInsertMenuItem( menu
, label
, item
) ;
259 void UMADrawMenuBar()
265 void UMASetMenuItemText( MenuRef menu
, MenuItemIndex item
, StringPtr label
)
267 ::SetMenuItemText( menu
, item
, label
) ;
270 MenuRef
UMANewMenu( SInt16 menuid
, StringPtr label
)
272 return ::NewMenu(menuid
, label
);
275 void UMADisposeMenu( MenuRef menu
)
277 DisposeMenu( menu
) ;
279 void UMADeleteMenu( SInt16 menuId
)
281 ::DeleteMenu( menuId
) ;
284 void UMAInsertMenu( MenuRef insertMenu
, SInt16 afterId
)
286 ::InsertMenu( insertMenu
, afterId
) ;
292 int gPrOpenCounter
= 0 ;
299 if ( gPrOpenCounter
== 1 )
303 wxASSERT( err
== noErr
) ;
307 OSStatus err
= noErr
;
309 if ( gPrOpenCounter
== 1 )
312 wxASSERT( err
== noErr
) ;
318 OSStatus
UMAPrClose()
322 wxASSERT( gPrOpenCounter
>= 1 ) ;
323 if ( gPrOpenCounter
== 1 )
327 wxASSERT( err
== noErr
) ;
332 OSStatus err
= noErr
;
333 wxASSERT( gPrOpenCounter
>= 1 ) ;
334 if ( gPrOpenCounter
== 1 )
345 pascal QDGlobalsPtr
GetQDGlobalsPtr (void)
347 return QDGlobalsPtr (* (Ptr
*) LMGetCurrentA5 ( ) - 0xCA);
352 void UMAShowWatchCursor()
356 CursHandle watchFob
= GetCursor (watchCursor
);
363 Cursor preservedArrow
;
364 GetQDGlobalsArrow (&preservedArrow
);
365 SetQDGlobalsArrow (*watchFob
);
367 SetQDGlobalsArrow (&preservedArrow
);
369 SetCursor (*watchFob
);
374 void UMAShowArrowCursor()
378 SetCursor (GetQDGlobalsArrow (&arrow
));
380 SetCursor (&(qd
.arrow
));
386 GrafPtr
UMAGetWindowPort( WindowRef inWindowRef
)
388 wxASSERT( inWindowRef
!= NULL
) ;
390 return GetWindowPort( inWindowRef
) ;
392 return (GrafPtr
) inWindowRef
;
396 void UMADisposeWindow( WindowRef inWindowRef
)
398 wxASSERT( inWindowRef
!= NULL
) ;
399 DisposeWindow( inWindowRef
) ;
402 void UMASetWTitleC( WindowRef inWindowRef
, const char *title
)
405 strncpy( (char*)ptitle
, title
, 96 ) ;
408 c2pstrcpy( ptitle
, (char *)ptitle
) ;
410 c2pstr( (char*)ptitle
) ;
412 SetWTitle( inWindowRef
, ptitle
) ;
415 void UMAGetWTitleC( WindowRef inWindowRef
, char *title
)
417 GetWTitle( inWindowRef
, (unsigned char*)title
) ;
419 p2cstrcpy( title
, (unsigned char *)title
) ;
421 p2cstr( (unsigned char*)title
) ;
425 void UMAShowWindow( WindowRef inWindowRef
)
427 ShowWindow( inWindowRef
) ;
431 void UMAHideWindow( WindowRef inWindowRef
)
433 HideWindow( inWindowRef
) ;
436 void UMASelectWindow( WindowRef inWindowRef
)
438 SelectWindow( inWindowRef
) ;
441 void UMABringToFront( WindowRef inWindowRef
)
443 BringToFront( inWindowRef
) ;
446 void UMASendBehind( WindowRef inWindowRef
, WindowRef behindWindow
)
448 SendBehind( inWindowRef
, behindWindow
) ;
451 void UMACloseWindow(WindowRef inWindowRef
)
455 CloseWindow( inWindowRef
) ;
459 // appearance additions
461 void UMAActivateControl( ControlHandle inControl
)
463 #if UMA_USE_APPEARANCE
464 if ( UMAHasAppearance() )
466 if ( !UMAIsControlActive( inControl
) )
468 bool visible
= IsControlVisible( inControl
) ;
470 SetControlVisibility( inControl
, false , false ) ;
471 ::ActivateControl( inControl
) ;
473 SetControlVisibility( inControl
, true , false ) ;
474 InvalWindowRect(GetControlOwner(inControl
),&(**inControl
).contrlRect
) ;
482 AGAActivateControl( inControl
) ;
490 void UMADrawControl( ControlHandle inControl
)
492 WindowRef theWindow
= GetControlOwner(inControl
) ;
493 RgnHandle updateRgn
= NewRgn() ;
495 GetWindowRegion( theWindow
, kWindowUpdateRgn
, updateRgn
) ;
497 GetWindowUpdateRgn( theWindow
, updateRgn
) ;
499 Point zero
= { 0 , 0 } ;
500 LocalToGlobal( &zero
) ;
501 OffsetRgn( updateRgn
, -zero
.h
, -zero
.v
) ;
502 #if UMA_USE_APPEARANCE
503 if ( UMAHasAppearance() )
505 ::DrawControlInCurrentPort( inControl
) ;
511 AGADrawControl( inControl
) ;
517 #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
518 InvalWindowRgn( theWindow
, updateRgn
) ;
520 InvalRgn( updateRgn
) ;
522 DisposeRgn( updateRgn
) ;
526 void UMAMoveControl( ControlHandle inControl
, short x
, short y
)
528 if ( UMAHasAppearance() )
530 bool visible
= UMAIsControlVisible( inControl
) ;
532 SetControlVisibility( inControl
, false , false ) ;
533 InvalWindowRect(GetControlOwner(inControl
),&(**inControl
).contrlRect
) ;
535 ::MoveControl( inControl
, x
, y
) ;
537 SetControlVisibility( inControl
, true , false ) ;
538 InvalWindowRect(GetControlOwner(inControl
),&(**inControl
).contrlRect
) ;
543 void UMASizeControl( ControlHandle inControl
, short x
, short y
)
545 if ( UMAHasAppearance() )
547 bool visible
= UMAIsControlVisible( inControl
) ;
549 SetControlVisibility( inControl
, false , false ) ;
550 InvalWindowRect(GetControlOwner(inControl
),&(**inControl
).contrlRect
) ;
552 ::SizeControl( inControl
, x
, y
) ;
554 SetControlVisibility( inControl
, true , false ) ;
555 InvalWindowRect(GetControlOwner(inControl
),&(**inControl
).contrlRect
) ;
560 void UMADeactivateControl( ControlHandle inControl
)
562 if ( UMAHasAppearance() )
564 if ( UMAIsControlActive( inControl
) )
566 bool visible
= IsControlVisible( inControl
) ;
568 SetControlVisibility( inControl
, false , false ) ;
569 ::DeactivateControl( inControl
) ;
571 SetControlVisibility( inControl
, true , false ) ;
572 InvalWindowRect(GetControlOwner(inControl
),&(**inControl
).contrlRect
) ;
578 void UMASetThemeWindowBackground (WindowRef inWindow
,
582 #if UMA_USE_APPEARANCE
583 if ( UMAHasAppearance() )
585 ::SetThemeWindowBackground( inWindow
,inBrush
, inUpdate
) ;
591 AGASetThemeWindowBackground( inWindow
, inBrush
, inUpdate
) ;
599 void UMAApplyThemeBackground (ThemeBackgroundKind inKind
,
601 ThemeDrawState inState
,
605 #if UMA_USE_APPEARANCE
606 if ( UMAHasAppearance() )
609 if ( sUMAAppearanceVersion >= 0x0110 )
610 ::ApplyThemeBackground( inKind ,bounds , inState , inDepth , inColorDev ) ;
617 AGAApplyThemeBackground( inKind
,bounds
, inState
, inDepth
, inColorDev
) ;
625 ControlHandle
UMANewControl(WindowPtr owningWindow
,
626 const Rect
* boundsRect
,
627 ConstStr255Param controlTitle
,
628 Boolean initiallyVisible
,
633 SInt32 controlReference
)
635 ControlHandle theControl
= NULL
;
636 #if UMA_USE_APPEARANCE
637 if ( UMAHasAppearance() )
639 theControl
= NewControl( owningWindow
, boundsRect
, controlTitle
, initiallyVisible
,
640 initialValue
, minimumValue
, maximumValue
, procID
, controlReference
) ;
646 theControl
= AGANewControl( owningWindow
, boundsRect
, controlTitle
, initiallyVisible
,
647 initialValue
, minimumValue
, maximumValue
, procID
, controlReference
) ;
656 void UMADisposeControl (ControlHandle theControl
)
658 if ( UMAHasAppearance() )
660 ::DisposeControl( theControl
) ;
664 ::DisposeControl( theControl
) ;
668 void UMAHiliteControl (ControlHandle inControl
,
669 ControlPartCode hiliteState
)
671 if ( UMAHasAppearance() )
673 ::HiliteControl( inControl
, hiliteState
) ;
677 ::HiliteControl( inControl
, hiliteState
) ;
681 // shows the control and adds the region to the update region
682 void UMAShowControl (ControlHandle inControl
)
684 if ( UMAHasAppearance() )
686 SetControlVisibility( inControl
, true , false ) ;
687 InvalWindowRect(GetControlOwner(inControl
),&(**inControl
).contrlRect
) ;
691 (**inControl
).contrlVis
= 255 ;
695 // Hides the control and adds the region to the update region
696 void UMAHideControl (ControlHandle inControl
)
698 if ( UMAHasAppearance() )
700 ::HideControl( inControl
) ;
704 ::HideControl( inControl
) ;
709 void UMASetControlVisibility (ControlHandle inControl
,
713 if ( UMAHasAppearance() )
715 #if UMA_USE_APPEARANCE
716 ::SetControlVisibility( inControl
, inIsVisible
, inDoDraw
) ;
723 bool UMAIsControlActive (ControlHandle inControl
)
726 return IsControlActive( inControl
) ;
728 #if UMA_USE_APPEARANCE
729 if ( UMAHasAppearance() )
731 return IsControlActive( inControl
) ;
735 return (**inControl
).contrlHilite
== 0 ;
740 bool UMAIsControlVisible (ControlHandle inControl
)
742 #if UMA_USE_APPEARANCE
743 if ( UMAHasAppearance() )
745 return IsControlVisible( inControl
) ;
751 return (**inControl
).contrlVis
== 255 ;
757 OSErr
UMAGetBestControlRect (ControlHandle inControl
,
759 SInt16
* outBaseLineOffset
)
761 #if UMA_USE_APPEARANCE
762 if ( UMAHasAppearance() )
764 return GetBestControlRect( inControl
, outRect
, outBaseLineOffset
) ;
770 return AGAGetBestControlRect( inControl
, outRect
, outBaseLineOffset
) ;
780 OSErr
UMASetControlFontStyle (ControlHandle inControl
,
781 const ControlFontStyleRec
* inStyle
)
783 #if UMA_USE_APPEARANCE
784 if ( UMAHasAppearance() )
786 return ::SetControlFontStyle( inControl
, inStyle
) ;
791 return AGASetControlFontStyle( inControl
, inStyle
) ;
803 OSErr
UMACreateRootControl (WindowPtr inWindow
,
804 ControlHandle
* outControl
)
806 #if UMA_USE_APPEARANCE
807 if ( UMAHasAppearance() )
809 return CreateRootControl( inWindow
, outControl
) ;
814 return AGACreateRootControl( inWindow
, outControl
) ;
824 OSErr
UMAEmbedControl (ControlHandle inControl
,
825 ControlHandle inContainer
)
827 #if UMA_USE_APPEARANCE
828 if ( UMAHasAppearance() )
830 return EmbedControl( inControl
, inContainer
) ;
835 return AGAEmbedControl( inControl
, inContainer
) ; ;
846 OSErr
UMASetKeyboardFocus (WindowPtr inWindow
,
847 ControlHandle inControl
,
848 ControlFocusPart inPart
)
854 SetPort( GetWindowPort( inWindow
) ) ;
856 SetPort( inWindow
) ;
859 #if UMA_USE_APPEARANCE
860 if ( UMAHasAppearance() )
862 err
= SetKeyboardFocus( inWindow
, inControl
, inPart
) ;
867 err
= AGASetKeyboardFocus( inWindow
, inControl
, inPart
) ;
881 ControlPartCode
UMAHandleControlClick (ControlHandle inControl
,
884 ControlActionUPP inAction
)
886 #if UMA_USE_APPEARANCE
887 if ( UMAHasAppearance() )
889 return HandleControlClick( inControl
, inWhere
, inModifiers
, inAction
) ;
895 return AGAHandleControlClick( inControl
, inWhere
, inModifiers
, inAction
) ;
905 SInt16
UMAHandleControlKey (ControlHandle inControl
,
910 #if UMA_USE_APPEARANCE
911 if ( UMAHasAppearance() )
913 return HandleControlKey( inControl
, inKeyCode
, inCharCode
, inModifiers
) ;
919 return AGAHandleControlKey(inControl
, inKeyCode
, inCharCode
, inModifiers
) ;
930 void UMAIdleControls (WindowPtr inWindow
)
932 #if UMA_USE_APPEARANCE
933 if ( UMAHasAppearance() )
935 IdleControls( inWindow
) ;
941 AGAIdleControls( inWindow
) ;
949 void UMAUpdateControls( WindowPtr inWindow
, RgnHandle inRgn
)
951 RgnHandle updateRgn
= NewRgn() ;
953 GetWindowRegion( inWindow
, kWindowUpdateRgn
, updateRgn
) ;
955 GetWindowUpdateRgn( inWindow
, updateRgn
) ;
957 Point zero
= { 0 , 0 } ;
958 LocalToGlobal( &zero
) ;
959 OffsetRgn( updateRgn
, -zero
.h
, -zero
.v
) ;
960 #if UMA_USE_APPEARANCE
961 if ( UMAHasAppearance() )
963 UpdateControls( inWindow
, inRgn
) ;
969 AGAUpdateControls( inWindow
, inRgn
) ;
975 #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
976 InvalWindowRgn( inWindow
, updateRgn
) ;
978 InvalRgn( updateRgn
) ;
980 DisposeRgn( updateRgn
) ;
984 OSErr
UMAGetRootControl( WindowPtr inWindow
, ControlHandle
*outControl
)
986 #if UMA_USE_APPEARANCE
987 if ( UMAHasAppearance() )
989 return GetRootControl( inWindow
, outControl
) ;
995 return AGAGetRootControl( inWindow
, outControl
) ;
1005 // handling control data
1007 OSErr
UMASetControlData (ControlHandle inControl
,
1008 ControlPartCode inPart
,
1013 #if UMA_USE_APPEARANCE
1014 if ( UMAHasAppearance() )
1016 return SetControlData( inControl
, inPart
, inTagName
, inSize
, inData
) ;
1021 return AGASetControlData( inControl
, inPart
, inTagName
, inSize
, inData
) ;
1031 OSErr
UMAGetControlData (ControlHandle inControl
,
1032 ControlPartCode inPart
,
1036 Size
* outActualSize
)
1038 #if UMA_USE_APPEARANCE
1039 if ( UMAHasAppearance() )
1041 return ::GetControlData( inControl
, inPart
, inTagName
, inBufferSize
, outBuffer
, outActualSize
) ;
1047 return AGAGetControlData( inControl
, inPart
, inTagName
, inBufferSize
, outBuffer
, outActualSize
) ;
1057 OSErr
UMAGetControlDataSize (ControlHandle inControl
,
1058 ControlPartCode inPart
,
1062 #if UMA_USE_APPEARANCE
1063 if ( UMAHasAppearance() )
1065 return GetControlDataSize( inControl
, inPart
, inTagName
, outMaxSize
) ;
1071 return AGAGetControlDataSize( inControl
, inPart
, inTagName
, outMaxSize
) ;
1084 // system 8.0 changes
1086 short UMAFindWindow( Point inPoint
, WindowRef
*outWindow
)
1088 // todo add the additional area codes
1089 return FindWindow( inPoint
, outWindow
) ;
1092 OSStatus
UMAGetWindowFeatures( WindowRef inWindowRef
, UInt32
*outFeatures
)
1094 #if UMA_USE_WINDOWMGR
1095 return GetWindowFeatures( inWindowRef
, outFeatures
) ;
1101 OSStatus
UMAGetWindowRegion( WindowRef inWindowRef
, WindowRegionCode inRegionCode
, RgnHandle ioWinRgn
)
1103 #if UMA_USE_WINDOWMGR
1104 return GetWindowRegion( inWindowRef
, inRegionCode
, ioWinRgn
) ;
1110 void UMADrawGrowIcon( WindowRef inWindowRef
)
1112 DrawGrowIcon( inWindowRef
) ;
1115 OSStatus
UMACollapseWindow( WindowRef inWindowRef
, Boolean inCollapseIt
)
1117 return CollapseWindow( inWindowRef
, inCollapseIt
) ;
1120 OSStatus
UMACollapseAllWindows( Boolean inCollapseEm
)
1122 return CollapseAllWindows( inCollapseEm
) ;
1125 Boolean
UMAIsWindowCollapsed( WindowRef inWindowRef
)
1127 return IsWindowCollapsed( inWindowRef
) ;
1130 Boolean
UMAIsWindowCollapsable( WindowRef inWindowRef
)
1132 return IsWindowCollapsable( inWindowRef
) ;
1135 // system 8.5 changes<MacWindows.h>
1136 OSStatus
UMACreateNewWindow( WindowClass windowClass
, WindowAttributes attributes
, const Rect
*bounds
, WindowRef
*outWindow
)
1138 #if UMA_USE_WINDOWMGR
1139 if ( UMAHasWindowManager() )
1141 return CreateNewWindow( windowClass
, attributes
, bounds
, outWindow
) ;
1147 if ( UMAHasAppearance() )
1149 switch( windowClass
)
1151 case kMovableModalWindowClass
:
1152 procID
= kWindowMovableModalDialogProc
;
1154 case kModalWindowClass
:
1155 procID
= kWindowShadowDialogProc
;
1157 case kFloatingWindowClass
:
1158 if ( attributes
& kWindowSideTitlebarAttribute
)
1160 if( ( attributes
& kWindowResizableAttribute
) &&
1161 ( attributes
& kWindowFullZoomAttribute
) )
1163 procID
= kWindowFloatSideFullZoomGrowProc
;
1165 else if( attributes
& kWindowFullZoomAttribute
)
1167 procID
= kWindowFloatSideFullZoomProc
;
1169 else if ( attributes
& kWindowResizableAttribute
)
1171 procID
= kWindowFloatSideGrowProc
;
1175 procID
= kWindowFloatSideProc
;
1180 if( ( attributes
& kWindowResizableAttribute
) &&
1181 ( attributes
& kWindowFullZoomAttribute
) )
1183 procID
= kWindowFloatFullZoomGrowProc
;
1185 else if( attributes
& kWindowFullZoomAttribute
)
1187 procID
= kWindowFloatFullZoomProc
;
1189 else if ( attributes
& kWindowResizableAttribute
)
1191 procID
= kWindowFloatGrowProc
;
1195 procID
= kWindowFloatProc
;
1199 case kDocumentWindowClass
:
1201 if( ( attributes
& kWindowResizableAttribute
) &&
1202 ( attributes
& kWindowFullZoomAttribute
) )
1204 procID
= kWindowFullZoomGrowDocumentProc
;
1206 else if( attributes
& kWindowFullZoomAttribute
)
1208 procID
= kWindowFullZoomDocumentProc
;
1210 else if ( attributes
& kWindowResizableAttribute
)
1212 procID
= kWindowGrowDocumentProc
;
1216 procID
= kWindowDocumentProc
;
1223 switch( windowClass
)
1225 case kMovableModalWindowClass
:
1226 procID
= movableDBoxProc
;
1228 case kModalWindowClass
:
1229 procID
= altDBoxProc
;
1231 case kFloatingWindowClass
:
1232 if ( attributes
& kWindowSideTitlebarAttribute
)
1234 if( ( attributes
& kWindowResizableAttribute
) &&
1235 ( attributes
& kWindowFullZoomAttribute
) )
1237 procID
= floatSideZoomGrowProc
;
1239 else if( attributes
& kWindowFullZoomAttribute
)
1241 procID
= floatSideZoomProc
;
1243 else if ( attributes
& kWindowResizableAttribute
)
1245 procID
= floatSideGrowProc
;
1249 procID
= floatSideProc
;
1254 if( ( attributes
& kWindowResizableAttribute
) &&
1255 ( attributes
& kWindowFullZoomAttribute
) )
1257 procID
= floatZoomGrowProc
;
1259 else if( attributes
& kWindowFullZoomAttribute
)
1261 procID
= floatZoomProc
;
1263 else if ( attributes
& kWindowResizableAttribute
)
1265 procID
= floatGrowProc
;
1273 case kDocumentWindowClass
:
1275 if( ( attributes
& kWindowResizableAttribute
) &&
1276 ( attributes
& kWindowFullZoomAttribute
) )
1278 procID
= zoomDocProc
;
1280 else if( attributes
& kWindowFullZoomAttribute
)
1282 procID
= zoomNoGrow
;
1284 else if ( attributes
& kWindowResizableAttribute
)
1286 procID
= documentProc
;
1290 procID
= noGrowDocProc
;
1296 *outWindow
= NewCWindow(nil
, bounds
, "\p", false, procID
, (WindowRef
) -1 /*behind*/,
1297 attributes
& kWindowCloseBoxAttribute
, (long)NULL
);
1302 OSStatus
UMAGetWindowClass( WindowRef inWindowRef
, WindowClass
*outWindowClass
)
1304 #if UMA_USE_WINDOWMGR
1305 if ( UMAHasWindowManager() )
1307 return GetWindowClass( inWindowRef
, outWindowClass
) ;
1311 return kDocumentWindowClass
;
1314 OSStatus
UMAGetWindowAttributes( WindowRef inWindowRef
, WindowAttributes
*outAttributes
)
1316 #if UMA_USE_WINDOWMGR
1317 if ( UMAHasWindowManager() )
1319 return GetWindowAttributes( inWindowRef
, outAttributes
) ;
1322 return kWindowNoAttributes
;
1325 void UMAShowFloatingWindows()
1327 #if UMA_USE_WINDOWMGR
1328 if ( UMAHasWindowManager() )
1330 ShowFloatingWindows() ;
1335 void UMAHideFloatingWindows()
1337 #if UMA_USE_WINDOWMGR
1338 if ( UMAHasWindowManager() )
1340 HideFloatingWindows() ;
1345 Boolean
UMAAreFloatingWindowsVisible()
1347 #if UMA_USE_WINDOWMGR
1348 if ( UMAHasWindowManager() )
1350 return AreFloatingWindowsVisible() ;
1356 WindowRef
UMAFrontNonFloatingWindow()
1358 #if UMA_USE_WINDOWMGR
1359 if ( UMAHasWindowManager() )
1361 return FrontNonFloatingWindow() ;
1366 return FrontWindow() ;
1370 WindowRef
UMAFrontWindow()
1372 #if UMA_USE_WINDOWMGR
1373 if ( UMAHasWindowManager() )
1375 return FrontWindow() ;
1380 return FrontWindow() ;
1384 WindowRef
UMAGetActiveNonFloatingWindow()
1389 bool UMAIsWindowFloating( WindowRef inWindow
)
1393 UMAGetWindowClass( inWindow
, &cl
) ;
1394 return cl
== kFloatingWindowClass
;
1397 bool UMAIsWindowModal( WindowRef inWindow
)
1401 UMAGetWindowClass( inWindow
, &cl
) ;
1402 return cl
< kFloatingWindowClass
;
1407 void UMAHighlightAndActivateWindow( WindowRef inWindowRef
, bool inActivate
)
1411 // bool isHighlighted = IsWindowHighlited( inWindowRef ) ;
1412 // if ( inActivate != isHightlited )
1416 SetPort( GetWindowPort( inWindowRef
) ) ;
1418 SetPort( inWindowRef
) ;
1420 SetOrigin( 0 , 0 ) ;
1421 HiliteWindow( inWindowRef
, inActivate
) ;
1422 ControlHandle control
= NULL
;
1423 UMAGetRootControl( inWindowRef
, & control
) ;
1427 UMAActivateControl( control
) ;
1429 UMADeactivateControl( control
) ;
1434 OSStatus
UMADrawThemePlacard( const Rect
*inRect
, ThemeDrawState inState
)
1436 #if UMA_USE_APPEARANCE
1437 if ( UMAHasAppearance() )
1439 ::DrawThemePlacard( inRect
, inState
) ;