1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Universal MacOS API
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__POWERPC__)
16 #if defined(__DARWIN__)
17 #include <Carbon/Carbon.h>
22 // this is now defined in the latest headers
23 // typedef short MenuItemIndex ;
26 void UMAInitToolbox( UInt16 inMoreMastersCalls
) ;
27 void UMACleanupToolbox() ;
28 bool UMAHasAppearance() ;
29 long UMAGetAppearanceVersion() ;
30 bool UMAHasWindowManager() ;
31 long UMAGetWindowManagerAttr() ;
32 bool UMAHasAquaLayout() ;
36 long UMAGetProcessMode() ;
37 bool UMAGetProcessModeDoesActivateOnFGSwitch() ;
41 void UMASetMenuTitle( MenuRef menu
, StringPtr title
) ;
42 UInt32
UMAMenuEvent( EventRecord
*inEvent
) ;
43 void UMAEnableMenuItem( MenuRef inMenu
, MenuItemIndex item
) ;
44 void UMADisableMenuItem( MenuRef inMenu
, MenuItemIndex item
) ;
45 void UMAAppendSubMenuItem( MenuRef menu
, StringPtr label
, SInt16 submenuid
) ;
46 void UMAInsertSubMenuItem( MenuRef menu
, StringPtr label
, MenuItemIndex item
, SInt16 submenuid
) ;
47 void UMAAppendMenuItem( MenuRef menu
, StringPtr label
, SInt16 key
= 0, UInt8 modifiers
= 0 ) ;
48 void UMAInsertMenuItem( MenuRef menu
, StringPtr label
, MenuItemIndex item
, SInt16 key
= 0 , UInt8 modifiers
= 0 ) ;
49 // void UMASetMenuItemText( MenuRef menu , MenuItemIndex item , StringPtr label ) ;
51 // MenuRef ::NewMenu( SInt16 menuid , StringPtr label ) ;
52 // void UMADisposeMenu( MenuRef menu ) ;
54 // handling the menubar
56 // void UMADeleteMenu( SInt16 menuId ) ;
57 // void UMAInsertMenu( MenuRef insertMenu , SInt16 afterId ) ;
58 // void UMADrawMenuBar() ;
62 void UMAShowWatchCursor() ;
63 void UMAShowArrowCursor() ;
65 #if TARGET_CARBON && PM_USE_SESSION_APIS
66 OSStatus
UMAPrOpen(PMPrintSession
*macPrintSession
) ;
67 OSStatus
UMAPrClose(PMPrintSession
*macPrintSession
) ;
69 OSStatus
UMAPrOpen() ;
70 OSStatus
UMAPrClose() ;
75 GrafPtr
UMAGetWindowPort( WindowRef inWindowRef
) ;
76 void UMADisposeWindow( WindowRef inWindowRef
) ;
77 void UMASetWTitleC( WindowRef inWindowRef
, const char *title
) ;
78 void UMAGetWTitleC( WindowRef inWindowRef
, char *title
) ;
80 void UMADrawGrowIcon( WindowRef inWindowRef
) ;
81 //void UMAShowWindow( WindowRef inWindowRef ) ;
82 //void UMAHideWindow( WindowRef inWindowRef ) ;
83 void UMAShowHide( WindowRef inWindowRef
, Boolean show
) ;
84 //void UMASelectWindow( WindowRef inWindowRef ) ;
85 //void UMABringToFront( WindowRef inWindowRef ) ;
86 //void UMASendBehind( WindowRef inWindowRef , WindowRef behindWindow ) ;
87 // void UMACloseWindow(WindowRef inWindowRef) ;
91 void UMADrawControl( ControlHandle inControl
) ;
93 void UMAEnableControl( ControlHandle inControl
) ;
94 void UMADisableControl( ControlHandle inControl
) ;
95 void UMAActivateControl( ControlHandle inControl
) ;
96 void UMADeactivateControl( ControlHandle inControl
) ;
97 //void UMAApplyThemeBackground (ThemeBackgroundKind inKind,
98 // const Rect * bounds,
99 // ThemeDrawState inState,
101 // Boolean inColorDev);
102 //void UMASetThemeWindowBackground (WindowRef inWindow,
103 // ThemeBrush inBrush,
104 // Boolean inUpdate) ;
106 ControlHandle ::NewControl(WindowPtr owningWindow,
107 const Rect * boundsRect,
108 ConstStr255Param controlTitle,
109 Boolean initiallyVisible,
114 SInt32 controlReference) ;
116 //void UMADisposeControl (ControlHandle theControl) ;
117 //void UMAHiliteControl (ControlHandle theControl,
118 // ControlPartCode hiliteState) ;
119 void UMAShowControl (ControlHandle theControl
) ;
120 void UMAHideControl (ControlHandle theControl
);
121 //void UMASetControlVisibility (ControlHandle inControl,
122 // Boolean inIsVisible,
123 // Boolean inDoDraw);
125 //bool UMAIsControlActive (ControlHandle inControl);
126 //bool UMAIsControlVisible (ControlHandle inControl);
127 void UMAActivateControl (ControlHandle inControl
);
128 void UMADeactivateControl (ControlHandle inControl
);
130 //OSErr UMAGetBestControlRect (ControlHandle inControl,
132 // SInt16 * outBaseLineOffset);
133 //OSErr UMASetControlFontStyle (ControlHandle inControl,
134 // const ControlFontStyleRec * inStyle) ;
137 void UMAMoveControl( ControlHandle inControl
, short x
, short y
) ;
138 void UMASizeControl( ControlHandle inControl
, short x
, short y
) ;
141 //OSErr UMACreateRootControl (WindowPtr inWindow,
142 // ControlHandle * outControl) ;
144 //OSErr UMAEmbedControl (ControlHandle inControl,
145 // ControlHandle inContainer);
148 OSErr
UMASetKeyboardFocus (WindowPtr inWindow
,
149 ControlHandle inControl
,
150 ControlFocusPart inPart
) ;
155 //ControlPartCode UMAHandleControlClick (ControlHandle inControl,
157 // SInt16 inModifiers,
158 // ControlActionUPP inAction) ;
159 //SInt16 UMAHandleControlKey (ControlHandle inControl,
161 // SInt16 inCharCode,
162 // SInt16 inModifiers);
164 //void UMAIdleControls (WindowPtr inWindow) ;
166 void UMAUpdateControls( WindowPtr inWindow
, RgnHandle inRgn
) ;
167 OSErr
UMAGetRootControl( WindowPtr inWindow
, ControlHandle
*outControl
) ;
169 // handling control data
171 OSErr ::SetControlData (ControlHandle inControl,
172 ControlPartCode inPart,
177 OSErr ::GetControlData (ControlHandle inControl,
178 ControlPartCode inPart,
182 Size * outActualSize) ;
183 OSErr ::GetControlDataSize (ControlHandle inControl,
184 ControlPartCode inPart,
191 short UMAFindWindow( Point inPoint , WindowRef *outWindow ) ;
192 OSStatus UMAGetWindowFeatures( WindowRef inWindowRef , UInt32 *outFeatures ) ;
193 OSStatus UMAGetWindowRegion( WindowRef inWindowRef , WindowRegionCode inRegionCode , RgnHandle ioWinRgn ) ;
194 OSStatus UMACollapseWindow( WindowRef inWindowRef , Boolean inCollapseIt ) ;
195 OSStatus UMACollapseAllWindows( Boolean inCollapseEm ) ;
196 Boolean UMAIsWindowCollapsed( WindowRef inWindowRef ) ;
197 Boolean UMAIsWindowCollapsable( WindowRef inWindowRef ) ;
201 OSStatus UMACreateNewWindow( WindowClass windowClass , WindowAttributes attributes , const Rect *bounds, WindowRef *outWindow ) ;
202 OSStatus UMAGetWindowClass( WindowRef inWindowRef , WindowClass *outWindowClass ) ;
203 OSStatus UMAGetWindowAttributes( WindowRef inWindowRef , WindowAttributes *outAttributes ) ;
205 void UMAShowFloatingWindows() ;
206 void UMAHideFloatingWindows() ;
207 Boolean UMAAreFloatingWindowsVisible() ;
208 WindowRef UMAFrontWindow() ;
209 WindowRef UMAFrontNonFloatingWindow() ;
213 bool UMAIsWindowFloating( WindowRef inWindow
) ;
214 bool UMAIsWindowModal( WindowRef inWindow
) ;
216 WindowRef UMAGetActiveWindow() ;
217 WindowRef UMAGetActiveNonFloatingWindow() ;
219 void UMAHighlightAndActivateWindow( WindowRef inWindowRef
, bool inActivate
) ;
221 OSStatus
UMAGetHelpMenu(
222 MenuRef
* outHelpMenu
,
223 MenuItemIndex
* outFirstCustomItemIndex
); /* can be NULL */
226 #define GetPortTextFont( p) ((p)->txFont )
227 #define GetPortTextSize( p) ((p)->txSize )
228 #define GetPortTextFace( p) ((p)->txFace )
229 #define GetPortTextMode( p) ((p)->txMode )
230 #define GetRegionBounds( r , b) ((*b) = (**r).rgnBBox)
231 #define GetPortBounds( p , b) ((*b) = p->portRect )
232 #define GetWindowPortBounds( p , b) ((*b) = p->portRect )
233 #define GetPortVisibleRegion( p, r ) CopyRgn( p->visRgn , r )
234 #define GetQDGlobalsWhite( a ) (&((*a) = qd.white))
235 #define GetQDGlobalsBlack( a ) (&((*a) = qd.black))
236 #define GetQDGlobalsScreenBits( a ) ((*a) = qd.screenBits)
237 #define GetQDGlobalsArrow( a ) (&((*a) = qd.arrow))
238 #define GetControlBounds( c , b ) &((*b) = (**c).contrlRect )
239 #define GetPortBitMapForCopyBits( p ) ((BitMap*) &(((CGrafPtr)p)->portPixMap ))
240 #define GetControlOwner( control ) ((**control).contrlOwner)
241 #define InvalWindowRgn( window , rgn ) InvalRgn( rgn )
242 #define GetPortPenMode( p ) (p->pnMode)
243 #define SetPortPenMode( p , mode ) (p->pnMode = mode )
244 #define ClearCurrentScrap() ZeroScrap() ;
247 #define GetControlReference( control ) ((**control).contrlRfCon)
251 #define SetListSelectionFlags( list , options ) (**list).selFlags = options
252 #define GetListRefCon( list ) (**list).refCon
256 #define GetWindowUpdateRgn( inWindow , updateRgn ) GetWindowRegion( inWindow , kWindowUpdateRgn, updateRgn )
258 // Appearance Drawing
260 OSStatus
UMADrawThemePlacard( const Rect
*inRect
, ThemeDrawState inState
) ;