]>
Commit | Line | Data |
---|---|---|
84969af7 | 1 | ///////////////////////////////////////////////////////////////////////////// |
faa94f3e | 2 | // Name: src/mac/carbon/uma.cpp |
84969af7 JS |
3 | // Purpose: UMA support |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Stefan Csomor | |
65571936 | 9 | // Licence: The wxWindows licence |
84969af7 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
3d1a4878 | 12 | #include "wx/wxprec.h" |
2dbc444a | 13 | |
e17206f7 VS |
14 | #include "wx/mac/uma.h" |
15 | ||
2dbc444a RD |
16 | #if wxUSE_GUI |
17 | ||
0db43f1a | 18 | #include "wx/toplevel.h" |
5fde6fcc | 19 | #include "wx/dc.h" |
72e7876b | 20 | |
6239ee05 | 21 | #include "wx/mac/uma.h" |
9c3c5849 | 22 | |
72055702 SC |
23 | // since we have decided that we only support 8.6 upwards we are |
24 | // checking for these minimum requirements in the startup code of | |
77ffb593 | 25 | // the application so all wxWidgets code can safely assume that appearance 1.1 |
58751a86 | 26 | // windows manager, control manager, navigation services etc. are |
72055702 | 27 | // present |
e7b596fb | 28 | |
e6c3d3e6 | 29 | static SInt32 sUMASystemVersion = 0 ; |
0e5a4d20 | 30 | |
2b5f62a0 | 31 | long UMAGetSystemVersion() { return sUMASystemVersion ; } |
72e7876b | 32 | |
5b781a67 SC |
33 | void UMACleanupToolbox() |
34 | { | |
5b781a67 | 35 | } |
98af9c73 | 36 | |
89954433 VZ |
37 | void UMAInitToolbox( UInt16 WXUNUSED(inMoreMastersCalls), |
38 | bool WXUNUSED(isEmbedded) ) | |
72e7876b | 39 | { |
2b5f62a0 | 40 | if ( Gestalt(gestaltSystemVersion, &sUMASystemVersion) != noErr) |
e40298d5 | 41 | sUMASystemVersion = 0x0000 ; |
58751a86 | 42 | |
e6c3d3e6 | 43 | #ifndef __LP64__ |
564bf1ea | 44 | { |
98af9c73 DS |
45 | FontFamilyID fontId ; |
46 | Str255 fontName ; | |
47 | SInt16 fontSize ; | |
48 | Style fontStyle ; | |
4a6a2972 | 49 | |
98af9c73 DS |
50 | GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; |
51 | GetFNum( fontName, &fontId ); | |
4a6a2972 | 52 | |
98af9c73 DS |
53 | TXNMacOSPreferredFontDescription fontDescriptions[] = |
54 | { | |
55 | { fontId , (fontSize << 16) , kTXNDefaultFontStyle, kTXNSystemDefaultEncoding } | |
56 | } ; | |
57 | int noOfFontDescriptions = sizeof( fontDescriptions ) / sizeof(TXNMacOSPreferredFontDescription) ; | |
58 | ||
59 | OptionBits options = 0 ; | |
f8eebb95 | 60 | |
98af9c73 DS |
61 | if ( UMAGetSystemVersion() < 0x1000 ) |
62 | options |= kTXNAlwaysUseQuickDrawTextMask ; | |
ded4fa5b | 63 | |
98af9c73 DS |
64 | TXNInitTextension( fontDescriptions, noOfFontDescriptions, options ); |
65 | } | |
e6c3d3e6 | 66 | #endif |
66a09d47 | 67 | |
98af9c73 | 68 | UMASetSystemIsInitialized( true ); |
72e7876b SC |
69 | } |
70 | ||
71 | // process manager | |
58751a86 | 72 | long UMAGetProcessMode() |
72e7876b | 73 | { |
58751a86 | 74 | OSErr err ; |
e40298d5 JS |
75 | ProcessInfoRec processinfo; |
76 | ProcessSerialNumber procno ; | |
58751a86 | 77 | |
77eddfb7 | 78 | procno.highLongOfPSN = 0 ; |
e40298d5 JS |
79 | procno.lowLongOfPSN = kCurrentProcess ; |
80 | processinfo.processInfoLength = sizeof(ProcessInfoRec); | |
81 | processinfo.processName = NULL; | |
e6c3d3e6 | 82 | #ifndef __LP64__ |
e40298d5 | 83 | processinfo.processAppSpec = NULL; |
e6c3d3e6 | 84 | #endif |
72e7876b | 85 | |
e40298d5 JS |
86 | err = ::GetProcessInformation( &procno , &processinfo ) ; |
87 | wxASSERT( err == noErr ) ; | |
98af9c73 | 88 | |
e40298d5 | 89 | return processinfo.processMode ; |
72e7876b SC |
90 | } |
91 | ||
58751a86 | 92 | bool UMAGetProcessModeDoesActivateOnFGSwitch() |
72e7876b | 93 | { |
e40298d5 | 94 | return UMAGetProcessMode() & modeDoesActivateOnFGSwitch ; |
72e7876b SC |
95 | } |
96 | ||
97 | // menu manager | |
98 | ||
cd66beb3 SC |
99 | #if wxMAC_USE_COCOA == 0 |
100 | ||
908d407c | 101 | MenuRef UMANewMenu( SInt16 id , const wxString& title , wxFontEncoding encoding ) |
72e7876b | 102 | { |
e40298d5 JS |
103 | wxString str = wxStripMenuCodes( title ) ; |
104 | MenuRef menu ; | |
98af9c73 | 105 | |
e40298d5 | 106 | CreateNewMenu( id , 0 , &menu ) ; |
908d407c | 107 | SetMenuTitleWithCFString( menu , wxMacCFStringHolder(str , encoding ) ) ; |
98af9c73 | 108 | |
e40298d5 | 109 | return menu ; |
bf918b97 | 110 | } |
72e7876b | 111 | |
98af9c73 | 112 | void UMASetMenuTitle( MenuRef menu , const wxString& title , wxFontEncoding encoding ) |
bf918b97 | 113 | { |
e40298d5 | 114 | wxString str = wxStripMenuCodes( title ) ; |
98af9c73 | 115 | |
908d407c | 116 | SetMenuTitleWithCFString( menu , wxMacCFStringHolder(str , encoding) ) ; |
72e7876b SC |
117 | } |
118 | ||
98af9c73 | 119 | void UMASetMenuItemText( MenuRef menu, MenuItemIndex item, const wxString& title, wxFontEncoding encoding ) |
72e7876b | 120 | { |
43524b15 DS |
121 | // we don't strip the accels here anymore, must be done before |
122 | wxString str = title ; | |
98af9c73 | 123 | |
908d407c | 124 | SetMenuItemTextWithCFString( menu , item , wxMacCFStringHolder(str , encoding) ) ; |
72e7876b SC |
125 | } |
126 | ||
bf918b97 | 127 | UInt32 UMAMenuEvent( EventRecord *inEvent ) |
72e7876b | 128 | { |
98af9c73 | 129 | return MenuEvent( inEvent ) ; |
72e7876b SC |
130 | } |
131 | ||
58751a86 | 132 | void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex inItem , bool enable) |
72e7876b | 133 | { |
e40298d5 JS |
134 | if ( enable ) |
135 | EnableMenuItem( inMenu , inItem ) ; | |
136 | else | |
137 | DisableMenuItem( inMenu , inItem ) ; | |
72e7876b | 138 | } |
2f1ae414 | 139 | |
908d407c | 140 | void UMAAppendSubMenuItem( MenuRef menu , const wxString& title, wxFontEncoding encoding , SInt16 id ) |
2f1ae414 | 141 | { |
e6c3d3e6 | 142 | AppendMenuItemTextWithCFString( menu, |
31c1cbc7 | 143 | CFSTR("A"), 0, 0,NULL); |
98af9c73 | 144 | UMASetMenuItemText( menu, (SInt16) ::CountMenuItems(menu), title , encoding ); |
e40298d5 | 145 | SetMenuItemHierarchicalID( menu , CountMenuItems( menu ) , id ) ; |
2f1ae414 SC |
146 | } |
147 | ||
908d407c | 148 | void UMAInsertSubMenuItem( MenuRef menu , const wxString& title, wxFontEncoding encoding , MenuItemIndex item , SInt16 id ) |
2f1ae414 | 149 | { |
e6c3d3e6 | 150 | InsertMenuItemTextWithCFString( menu, |
31c1cbc7 VZ |
151 | CFSTR("A"), item, 0, 0); |
152 | ||
98af9c73 | 153 | UMASetMenuItemText( menu, item+1, title , encoding ); |
4da39c96 | 154 | SetMenuItemHierarchicalID( menu , item+1 , id ) ; |
2f1ae414 SC |
155 | } |
156 | ||
bf918b97 | 157 | void UMASetMenuItemShortcut( MenuRef menu , MenuItemIndex item , wxAcceleratorEntry *entry ) |
2f1ae414 | 158 | { |
e40298d5 JS |
159 | if ( !entry ) |
160 | return ; | |
58751a86 | 161 | |
e40298d5 JS |
162 | UInt8 modifiers = 0 ; |
163 | SInt16 key = entry->GetKeyCode() ; | |
164 | if ( key ) | |
165 | { | |
98af9c73 | 166 | bool explicitCommandKey = (entry->GetFlags() & wxACCEL_CTRL); |
e40298d5 | 167 | |
98af9c73 | 168 | if (entry->GetFlags() & wxACCEL_ALT) |
e40298d5 | 169 | modifiers |= kMenuOptionModifier ; |
e40298d5 | 170 | |
58751a86 | 171 | if (entry->GetFlags() & wxACCEL_SHIFT) |
e40298d5 | 172 | modifiers |= kMenuShiftModifier ; |
e40298d5 JS |
173 | |
174 | SInt16 glyph = 0 ; | |
175 | SInt16 macKey = key ; | |
176 | if ( key >= WXK_F1 && key <= WXK_F15 ) | |
177 | { | |
98af9c73 DS |
178 | if ( !explicitCommandKey ) |
179 | modifiers |= kMenuNoCommandModifier ; | |
180 | ||
a5c1f8ca SC |
181 | // for some reasons this must be 0 right now |
182 | // everything else leads to just the first function key item | |
183 | // to be selected. Thanks to Ryan Wilcox for finding out. | |
2dbc444a | 184 | macKey = 0 ; |
e40298d5 JS |
185 | glyph = kMenuF1Glyph + ( key - WXK_F1 ) ; |
186 | if ( key >= WXK_F13 ) | |
6239ee05 | 187 | glyph += 12 ; |
1bec2ee4 | 188 | } |
e40298d5 JS |
189 | else |
190 | { | |
98af9c73 | 191 | switch ( key ) |
e40298d5 JS |
192 | { |
193 | case WXK_BACK : | |
194 | macKey = kBackspaceCharCode ; | |
195 | glyph = kMenuDeleteLeftGlyph ; | |
196 | break ; | |
98af9c73 | 197 | |
e40298d5 JS |
198 | case WXK_TAB : |
199 | macKey = kTabCharCode ; | |
200 | glyph = kMenuTabRightGlyph ; | |
201 | break ; | |
98af9c73 | 202 | |
e40298d5 JS |
203 | case kEnterCharCode : |
204 | macKey = kEnterCharCode ; | |
205 | glyph = kMenuEnterGlyph ; | |
206 | break ; | |
98af9c73 | 207 | |
e40298d5 JS |
208 | case WXK_RETURN : |
209 | macKey = kReturnCharCode ; | |
210 | glyph = kMenuReturnGlyph ; | |
211 | break ; | |
98af9c73 | 212 | |
e40298d5 JS |
213 | case WXK_ESCAPE : |
214 | macKey = kEscapeCharCode ; | |
215 | glyph = kMenuEscapeGlyph ; | |
216 | break ; | |
98af9c73 | 217 | |
e40298d5 JS |
218 | case WXK_SPACE : |
219 | macKey = ' ' ; | |
220 | glyph = kMenuSpaceGlyph ; | |
221 | break ; | |
98af9c73 | 222 | |
e40298d5 JS |
223 | case WXK_DELETE : |
224 | macKey = kDeleteCharCode ; | |
225 | glyph = kMenuDeleteRightGlyph ; | |
226 | break ; | |
98af9c73 | 227 | |
e40298d5 JS |
228 | case WXK_CLEAR : |
229 | macKey = kClearCharCode ; | |
230 | glyph = kMenuClearGlyph ; | |
231 | break ; | |
98af9c73 | 232 | |
faa94f3e | 233 | case WXK_PAGEUP : |
e40298d5 JS |
234 | macKey = kPageUpCharCode ; |
235 | glyph = kMenuPageUpGlyph ; | |
236 | break ; | |
98af9c73 | 237 | |
faa94f3e | 238 | case WXK_PAGEDOWN : |
e40298d5 JS |
239 | macKey = kPageDownCharCode ; |
240 | glyph = kMenuPageDownGlyph ; | |
241 | break ; | |
98af9c73 | 242 | |
e40298d5 JS |
243 | case WXK_LEFT : |
244 | macKey = kLeftArrowCharCode ; | |
245 | glyph = kMenuLeftArrowGlyph ; | |
246 | break ; | |
98af9c73 | 247 | |
e40298d5 JS |
248 | case WXK_UP : |
249 | macKey = kUpArrowCharCode ; | |
250 | glyph = kMenuUpArrowGlyph ; | |
251 | break ; | |
98af9c73 | 252 | |
e40298d5 JS |
253 | case WXK_RIGHT : |
254 | macKey = kRightArrowCharCode ; | |
255 | glyph = kMenuRightArrowGlyph ; | |
256 | break ; | |
98af9c73 | 257 | |
e40298d5 JS |
258 | case WXK_DOWN : |
259 | macKey = kDownArrowCharCode ; | |
260 | glyph = kMenuDownArrowGlyph ; | |
261 | break ; | |
98af9c73 | 262 | |
4952771d JS |
263 | case WXK_HOME : |
264 | macKey = kHomeCharCode ; | |
265 | glyph = kMenuNorthwestArrowGlyph ; | |
266 | break ; | |
267 | ||
268 | case WXK_END : | |
269 | macKey = kEndCharCode ; | |
270 | glyph = kMenuSoutheastArrowGlyph ; | |
271 | break ; | |
1bec2ee4 SC |
272 | default : |
273 | macKey = toupper( key ) ; | |
274 | break ; | |
2b5f62a0 | 275 | } |
98af9c73 | 276 | |
1bec2ee4 SC |
277 | // we now allow non command key shortcuts |
278 | // remove in case this gives problems | |
279 | if ( !explicitCommandKey ) | |
280 | modifiers |= kMenuNoCommandModifier ; | |
2b5f62a0 | 281 | } |
bf918b97 | 282 | |
1a03b3e2 JS |
283 | // 1d and 1e have special meaning to SetItemCmd, so |
284 | // do not use for these character codes. | |
40cc34ec | 285 | if (key != WXK_UP && key != WXK_RIGHT && key != WXK_DOWN && key != WXK_LEFT) |
1a03b3e2 JS |
286 | SetItemCmd( menu, item , macKey ); |
287 | ||
98af9c73 | 288 | SetMenuItemModifiers( menu, item , modifiers ) ; |
2b5f62a0 VZ |
289 | |
290 | if ( glyph ) | |
98af9c73 | 291 | SetMenuItemKeyGlyph( menu, item , glyph ) ; |
e40298d5 | 292 | } |
2b5f62a0 VZ |
293 | } |
294 | ||
908d407c | 295 | void UMAAppendMenuItem( MenuRef menu , const wxString& title, wxFontEncoding encoding , wxAcceleratorEntry *entry ) |
2b5f62a0 | 296 | { |
e6c3d3e6 | 297 | AppendMenuItemTextWithCFString( menu, |
31c1cbc7 | 298 | CFSTR("A"), 0, 0,NULL); |
faa94f3e | 299 | // don't attempt to interpret metacharacters like a '-' at the beginning (would become a separator otherwise) |
a76342da | 300 | ChangeMenuItemAttributes( menu , ::CountMenuItems(menu), kMenuItemAttrIgnoreMeta , 0 ) ; |
908d407c | 301 | UMASetMenuItemText(menu, (SInt16) ::CountMenuItems(menu), title , encoding ); |
98af9c73 | 302 | UMASetMenuItemShortcut( menu , (SInt16) ::CountMenuItems(menu), entry ) ; |
2f1ae414 SC |
303 | } |
304 | ||
908d407c | 305 | void UMAInsertMenuItem( MenuRef menu , const wxString& title, wxFontEncoding encoding , MenuItemIndex item , wxAcceleratorEntry *entry ) |
2f1ae414 | 306 | { |
e6c3d3e6 | 307 | InsertMenuItemTextWithCFString( menu, |
31c1cbc7 | 308 | CFSTR("A"), item, 0, 0); |
98af9c73 | 309 | |
faa94f3e | 310 | // don't attempt to interpret metacharacters like a '-' at the beginning (would become a separator otherwise) |
a76342da | 311 | ChangeMenuItemAttributes( menu , item+1, kMenuItemAttrIgnoreMeta , 0 ) ; |
908d407c | 312 | UMASetMenuItemText(menu, item+1 , title , encoding ); |
58751a86 | 313 | UMASetMenuItemShortcut( menu , item+1 , entry ) ; |
2f1ae414 SC |
314 | } |
315 | ||
cd66beb3 SC |
316 | #endif |
317 | ||
318 | #if wxMAC_USE_COCOA == 0 | |
319 | ||
58751a86 | 320 | void UMAShowWatchCursor() |
72e7876b | 321 | { |
e6c3d3e6 | 322 | SetThemeCursor(kThemeWatchCursor); |
72e7876b SC |
323 | } |
324 | ||
98af9c73 | 325 | void UMAShowArrowCursor() |
72e7876b | 326 | { |
e6c3d3e6 | 327 | SetThemeCursor(kThemeArrowCursor); |
72e7876b SC |
328 | } |
329 | ||
cd66beb3 SC |
330 | static OSStatus UMAGetHelpMenu( |
331 | MenuRef * outHelpMenu, | |
332 | MenuItemIndex * outFirstCustomItemIndex, | |
333 | bool allowHelpMenuCreation); | |
334 | ||
335 | static OSStatus UMAGetHelpMenu( | |
336 | MenuRef * outHelpMenu, | |
337 | MenuItemIndex * outFirstCustomItemIndex, | |
338 | bool allowHelpMenuCreation) | |
339 | { | |
340 | static bool s_createdHelpMenu = false ; | |
341 | ||
342 | if ( !s_createdHelpMenu && !allowHelpMenuCreation ) | |
343 | { | |
344 | return paramErr ; | |
345 | } | |
346 | ||
347 | OSStatus status = HMGetHelpMenu( outHelpMenu , outFirstCustomItemIndex ) ; | |
348 | s_createdHelpMenu = ( status == noErr ) ; | |
349 | return status ; | |
350 | } | |
351 | ||
352 | OSStatus UMAGetHelpMenu( | |
353 | MenuRef * outHelpMenu, | |
354 | MenuItemIndex * outFirstCustomItemIndex) | |
355 | { | |
356 | return UMAGetHelpMenu( outHelpMenu , outFirstCustomItemIndex , true ); | |
357 | } | |
358 | ||
359 | OSStatus UMAGetHelpMenuDontCreate( | |
360 | MenuRef * outHelpMenu, | |
361 | MenuItemIndex * outFirstCustomItemIndex) | |
362 | { | |
363 | return UMAGetHelpMenu( outHelpMenu , outFirstCustomItemIndex , false ); | |
364 | } | |
365 | ||
366 | #endif | |
367 | ||
72e7876b SC |
368 | // window manager |
369 | ||
cd66beb3 SC |
370 | #if wxMAC_USE_QUICKDRAW |
371 | ||
98af9c73 | 372 | GrafPtr UMAGetWindowPort( WindowRef inWindowRef ) |
72e7876b | 373 | { |
e40298d5 | 374 | wxASSERT( inWindowRef != NULL ) ; |
98af9c73 | 375 | |
58751a86 | 376 | return (GrafPtr) GetWindowPort( inWindowRef ) ; |
72e7876b SC |
377 | } |
378 | ||
98af9c73 | 379 | void UMADisposeWindow( WindowRef inWindowRef ) |
72e7876b | 380 | { |
e40298d5 | 381 | wxASSERT( inWindowRef != NULL ) ; |
98af9c73 | 382 | |
e40298d5 | 383 | DisposeWindow( inWindowRef ) ; |
72e7876b SC |
384 | } |
385 | ||
98af9c73 | 386 | void UMASetWTitle( WindowRef inWindowRef , const wxString& title , wxFontEncoding encoding ) |
72e7876b | 387 | { |
908d407c | 388 | SetWindowTitleWithCFString( inWindowRef , wxMacCFStringHolder(title , encoding) ) ; |
72e7876b | 389 | } |
03e11df5 | 390 | |
72e7876b SC |
391 | // appearance additions |
392 | ||
98af9c73 | 393 | void UMASetControlTitle( ControlRef inControl , const wxString& title , wxFontEncoding encoding ) |
427ff662 | 394 | { |
908d407c | 395 | SetControlTitleWithCFString( inControl , wxMacCFStringHolder(title , encoding) ) ; |
427ff662 SC |
396 | } |
397 | ||
facd6764 | 398 | void UMAActivateControl( ControlRef inControl ) |
72e7876b | 399 | { |
98af9c73 | 400 | ::ActivateControl( inControl ) ; |
72e7876b SC |
401 | } |
402 | ||
facd6764 | 403 | void UMAMoveControl( ControlRef inControl , short x , short y ) |
72e7876b | 404 | { |
98af9c73 | 405 | ::MoveControl( inControl , x , y ) ; |
72e7876b SC |
406 | } |
407 | ||
facd6764 | 408 | void UMASizeControl( ControlRef inControl , short x , short y ) |
72e7876b | 409 | { |
98af9c73 | 410 | ::SizeControl( inControl , x , y ) ; |
72e7876b SC |
411 | } |
412 | ||
facd6764 | 413 | void UMADeactivateControl( ControlRef inControl ) |
72e7876b | 414 | { |
98af9c73 | 415 | ::DeactivateControl( inControl ) ; |
e40298d5 | 416 | } |
98af9c73 | 417 | |
e40298d5 | 418 | // shows the control and adds the region to the update region |
98af9c73 | 419 | void UMAShowControl( ControlRef inControl ) |
e40298d5 JS |
420 | { |
421 | SetControlVisibility( inControl , true , false ) ; | |
e6c3d3e6 | 422 | HIViewSetNeedsDisplay( inControl, true ); |
72e7876b SC |
423 | } |
424 | ||
facd6764 | 425 | // hides the control and adds the region to the update region |
98af9c73 | 426 | void UMAHideControl( ControlRef inControl ) |
22e751a5 | 427 | { |
e40298d5 | 428 | SetControlVisibility( inControl , false , false ) ; |
e6c3d3e6 | 429 | HIViewSetNeedsDisplay( inControl, true ); |
22e751a5 | 430 | } |
98af9c73 | 431 | |
58751a86 | 432 | bool UMAIsWindowFloating( WindowRef inWindow ) |
72e7876b | 433 | { |
e40298d5 | 434 | WindowClass cl ; |
58751a86 | 435 | |
e40298d5 JS |
436 | GetWindowClass( inWindow , &cl ) ; |
437 | return cl == kFloatingWindowClass ; | |
72e7876b SC |
438 | } |
439 | ||
58751a86 | 440 | bool UMAIsWindowModal( WindowRef inWindow ) |
72e7876b | 441 | { |
e40298d5 | 442 | WindowClass cl ; |
58751a86 | 443 | |
e40298d5 JS |
444 | GetWindowClass( inWindow , &cl ) ; |
445 | return cl < kFloatingWindowClass ; | |
72e7876b SC |
446 | } |
447 | ||
448 | // others | |
449 | ||
450 | void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate ) | |
451 | { | |
e40298d5 JS |
452 | if ( inWindowRef ) |
453 | { | |
454 | // bool isHighlighted = IsWindowHighlited( inWindowRef ) ; | |
3103e8a9 | 455 | // if ( inActivate != isHighlighted ) |
e6c3d3e6 | 456 | #ifndef __LP64__ |
e40298d5 JS |
457 | GrafPtr port ; |
458 | GetPort( &port ) ; | |
459 | SetPortWindowPort( inWindowRef ) ; | |
e6c3d3e6 | 460 | #endif |
e40298d5 | 461 | HiliteWindow( inWindowRef , inActivate ) ; |
facd6764 | 462 | ControlRef control = NULL ; |
98af9c73 | 463 | ::GetRootControl( inWindowRef , &control ) ; |
e40298d5 JS |
464 | if ( control ) |
465 | { | |
466 | if ( inActivate ) | |
467 | UMAActivateControl( control ) ; | |
468 | else | |
469 | UMADeactivateControl( control ) ; | |
58751a86 | 470 | } |
e6c3d3e6 | 471 | #ifndef __LP64__ |
e40298d5 | 472 | SetPort( port ) ; |
e6c3d3e6 | 473 | #endif |
e40298d5 | 474 | } |
72e7876b | 475 | } |
e40298d5 | 476 | |
58751a86 | 477 | OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) |
2f1ae414 | 478 | { |
e6c3d3e6 | 479 | #ifndef __LP64__ |
e40298d5 | 480 | return ::DrawThemePlacard( inRect , inState ) ; |
e6c3d3e6 SC |
481 | #else |
482 | return noErr; | |
483 | #endif | |
2f1ae414 | 484 | } |
72e7876b | 485 | |
cd66beb3 | 486 | Rect * UMAGetControlBoundsInWindowCoords( ControlRef theControl, Rect *bounds ) |
b03e4fcd | 487 | { |
cd66beb3 SC |
488 | GetControlBounds( theControl , bounds ) ; |
489 | ||
490 | WindowRef tlwref = GetControlOwner( theControl ) ; | |
491 | ||
492 | wxTopLevelWindowMac* tlwwx = wxFindWinFromMacWindow( tlwref ) ; | |
493 | if ( tlwwx != NULL ) | |
4dd25308 | 494 | { |
cd66beb3 SC |
495 | ControlRef rootControl = tlwwx->GetPeer()->GetControlRef() ; |
496 | HIPoint hiPoint = CGPointMake( 0 , 0 ) ; | |
497 | HIViewConvertPoint( &hiPoint , HIViewGetSuperview(theControl) , rootControl ) ; | |
498 | OffsetRect( bounds , (short) hiPoint.x , (short) hiPoint.y ) ; | |
4dd25308 | 499 | } |
cd66beb3 SC |
500 | |
501 | return bounds ; | |
4dd25308 VZ |
502 | } |
503 | ||
cd66beb3 | 504 | #endif |
4dd25308 | 505 | |
e6c3d3e6 SC |
506 | #ifndef __LP64__ |
507 | ||
98af9c73 | 508 | wxMacPortStateHelper::wxMacPortStateHelper( GrafPtr newport ) |
76a5e5d2 | 509 | { |
e40298d5 JS |
510 | m_clip = NULL ; |
511 | Setup( newport ) ; | |
76a5e5d2 SC |
512 | } |
513 | ||
514 | wxMacPortStateHelper::wxMacPortStateHelper() | |
515 | { | |
e40298d5 | 516 | m_clip = NULL ; |
76a5e5d2 SC |
517 | } |
518 | ||
519 | void wxMacPortStateHelper::Setup( GrafPtr newport ) | |
520 | { | |
e40298d5 JS |
521 | GetPort( &m_oldPort ) ; |
522 | SetPort( newport ) ; | |
98af9c73 DS |
523 | SetOrigin(0, 0); |
524 | ||
427ff662 | 525 | wxASSERT_MSG( m_clip == NULL , wxT("Cannot call setup twice") ) ; |
e40298d5 JS |
526 | m_clip = NewRgn() ; |
527 | GetClip( m_clip ); | |
98af9c73 DS |
528 | m_textFont = GetPortTextFont( (CGrafPtr) newport ); |
529 | m_textSize = GetPortTextSize( (CGrafPtr) newport ); | |
530 | m_textStyle = GetPortTextFace( (CGrafPtr) newport ); | |
531 | m_textMode = GetPortTextMode( (CGrafPtr) newport ); | |
e40298d5 JS |
532 | GetThemeDrawingState( &m_drawingState ) ; |
533 | m_currentPort = newport ; | |
76a5e5d2 | 534 | } |
98af9c73 | 535 | |
76a5e5d2 SC |
536 | void wxMacPortStateHelper::Clear() |
537 | { | |
e40298d5 JS |
538 | if ( m_clip ) |
539 | { | |
540 | DisposeRgn( m_clip ) ; | |
541 | DisposeThemeDrawingState( m_drawingState ) ; | |
542 | m_clip = NULL ; | |
543 | } | |
76a5e5d2 SC |
544 | } |
545 | ||
546 | wxMacPortStateHelper::~wxMacPortStateHelper() | |
547 | { | |
e40298d5 JS |
548 | if ( m_clip ) |
549 | { | |
550 | SetPort( m_currentPort ) ; | |
551 | SetClip( m_clip ) ; | |
552 | DisposeRgn( m_clip ) ; | |
553 | TextFont( m_textFont ); | |
554 | TextSize( m_textSize ); | |
555 | TextFace( m_textStyle ); | |
556 | TextMode( m_textMode ); | |
557 | SetThemeDrawingState( m_drawingState , true ) ; | |
558 | SetPort( m_oldPort ) ; | |
559 | } | |
76a5e5d2 SC |
560 | } |
561 | ||
e6c3d3e6 SC |
562 | #endif |
563 | ||
6239ee05 SC |
564 | size_t UMAPutBytesCFRefCallback( void *info, const void *bytes, size_t count ) |
565 | { | |
566 | CFMutableDataRef data = (CFMutableDataRef) info; | |
567 | if ( data ) | |
568 | { | |
569 | CFDataAppendBytes( data, (const UInt8*) bytes, count ); | |
570 | } | |
571 | return count; | |
572 | } | |
573 | ||
31c1cbc7 VZ |
574 | void UMAReleaseCFDataProviderCallback(void *info, |
575 | const void *WXUNUSED(data), | |
576 | size_t WXUNUSED(count)) | |
6239ee05 SC |
577 | { |
578 | if ( info ) | |
579 | CFRelease( (CFDataRef) info ); | |
580 | } | |
581 | ||
582 | void UMAReleaseCFDataConsumerCallback( void *info ) | |
583 | { | |
584 | if ( info ) | |
585 | CFRelease( (CFDataRef) info ); | |
586 | } | |
587 | ||
588 | CGDataProviderRef UMACGDataProviderCreateWithCFData( CFDataRef data ) | |
589 | { | |
590 | if ( data == NULL ) | |
591 | return NULL; | |
31c1cbc7 | 592 | |
e1673e52 | 593 | return CGDataProviderCreateWithCFData( data ); |
6239ee05 SC |
594 | } |
595 | ||
596 | CGDataConsumerRef UMACGDataConsumerCreateWithCFData( CFMutableDataRef data ) | |
597 | { | |
598 | if ( data == NULL ) | |
599 | return NULL; | |
31c1cbc7 | 600 | |
e1673e52 | 601 | return CGDataConsumerCreateWithCFData( data ); |
6239ee05 | 602 | } |
2dbc444a RD |
603 | #endif // wxUSE_GUI |
604 | ||
605 | #if wxUSE_BASE | |
606 | ||
607 | static bool sUMASystemInitialized = false ; | |
608 | ||
609 | bool UMASystemIsInitialized() | |
610 | { | |
611 | return sUMASystemInitialized ; | |
612 | } | |
613 | ||
614 | void UMASetSystemIsInitialized(bool val) | |
615 | { | |
616 | sUMASystemInitialized = val; | |
617 | } | |
618 | ||
2dbc444a | 619 | #endif // wxUSE_BASE |