]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/uma.cpp
64 bit fixes
[wxWidgets.git] / src / mac / carbon / uma.cpp
CommitLineData
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 29static SInt32 sUMASystemVersion = 0 ;
0e5a4d20 30
2b5f62a0 31long UMAGetSystemVersion() { return sUMASystemVersion ; }
72e7876b 32
5b781a67
SC
33void UMACleanupToolbox()
34{
5b781a67 35}
98af9c73 36
89954433
VZ
37void UMAInitToolbox( UInt16 WXUNUSED(inMoreMastersCalls),
38 bool WXUNUSED(isEmbedded) )
72e7876b 39{
e128397f
DS
40 ::InitCursor();
41
2b5f62a0 42 if ( Gestalt(gestaltSystemVersion, &sUMASystemVersion) != noErr)
e40298d5 43 sUMASystemVersion = 0x0000 ;
58751a86 44
e6c3d3e6 45#ifndef __LP64__
564bf1ea 46 {
98af9c73
DS
47 FontFamilyID fontId ;
48 Str255 fontName ;
49 SInt16 fontSize ;
50 Style fontStyle ;
4a6a2972 51
98af9c73
DS
52 GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
53 GetFNum( fontName, &fontId );
4a6a2972 54
98af9c73
DS
55 TXNMacOSPreferredFontDescription fontDescriptions[] =
56 {
57 { fontId , (fontSize << 16) , kTXNDefaultFontStyle, kTXNSystemDefaultEncoding }
58 } ;
59 int noOfFontDescriptions = sizeof( fontDescriptions ) / sizeof(TXNMacOSPreferredFontDescription) ;
60
61 OptionBits options = 0 ;
f8eebb95 62
98af9c73
DS
63 if ( UMAGetSystemVersion() < 0x1000 )
64 options |= kTXNAlwaysUseQuickDrawTextMask ;
ded4fa5b 65
98af9c73
DS
66 TXNInitTextension( fontDescriptions, noOfFontDescriptions, options );
67 }
e6c3d3e6 68#endif
66a09d47 69
98af9c73 70 UMASetSystemIsInitialized( true );
72e7876b
SC
71}
72
73// process manager
58751a86 74long UMAGetProcessMode()
72e7876b 75{
58751a86 76 OSErr err ;
e40298d5
JS
77 ProcessInfoRec processinfo;
78 ProcessSerialNumber procno ;
58751a86 79
77eddfb7 80 procno.highLongOfPSN = 0 ;
e40298d5
JS
81 procno.lowLongOfPSN = kCurrentProcess ;
82 processinfo.processInfoLength = sizeof(ProcessInfoRec);
83 processinfo.processName = NULL;
e6c3d3e6 84#ifndef __LP64__
e40298d5 85 processinfo.processAppSpec = NULL;
e6c3d3e6 86#endif
72e7876b 87
e40298d5
JS
88 err = ::GetProcessInformation( &procno , &processinfo ) ;
89 wxASSERT( err == noErr ) ;
98af9c73 90
e40298d5 91 return processinfo.processMode ;
72e7876b
SC
92}
93
58751a86 94bool UMAGetProcessModeDoesActivateOnFGSwitch()
72e7876b 95{
e40298d5 96 return UMAGetProcessMode() & modeDoesActivateOnFGSwitch ;
72e7876b
SC
97}
98
99// menu manager
100
908d407c 101MenuRef 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 112void 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 119void 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 127UInt32 UMAMenuEvent( EventRecord *inEvent )
72e7876b 128{
98af9c73 129 return MenuEvent( inEvent ) ;
72e7876b
SC
130}
131
58751a86 132void 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 140void 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 148void 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 157void 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 295void 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 305void 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
58751a86 316void UMAShowWatchCursor()
72e7876b 317{
e6c3d3e6 318 SetThemeCursor(kThemeWatchCursor);
72e7876b
SC
319}
320
98af9c73 321void UMAShowArrowCursor()
72e7876b 322{
e6c3d3e6 323 SetThemeCursor(kThemeArrowCursor);
72e7876b
SC
324}
325
326// window manager
327
98af9c73 328GrafPtr UMAGetWindowPort( WindowRef inWindowRef )
72e7876b 329{
e40298d5 330 wxASSERT( inWindowRef != NULL ) ;
98af9c73 331
58751a86 332 return (GrafPtr) GetWindowPort( inWindowRef ) ;
72e7876b
SC
333}
334
98af9c73 335void UMADisposeWindow( WindowRef inWindowRef )
72e7876b 336{
e40298d5 337 wxASSERT( inWindowRef != NULL ) ;
98af9c73 338
e40298d5 339 DisposeWindow( inWindowRef ) ;
72e7876b
SC
340}
341
98af9c73 342void UMASetWTitle( WindowRef inWindowRef , const wxString& title , wxFontEncoding encoding )
72e7876b 343{
908d407c 344 SetWindowTitleWithCFString( inWindowRef , wxMacCFStringHolder(title , encoding) ) ;
72e7876b 345}
03e11df5 346
72e7876b
SC
347// appearance additions
348
98af9c73 349void UMASetControlTitle( ControlRef inControl , const wxString& title , wxFontEncoding encoding )
427ff662 350{
908d407c 351 SetControlTitleWithCFString( inControl , wxMacCFStringHolder(title , encoding) ) ;
427ff662
SC
352}
353
facd6764 354void UMAActivateControl( ControlRef inControl )
72e7876b 355{
98af9c73 356 ::ActivateControl( inControl ) ;
72e7876b
SC
357}
358
facd6764 359void UMAMoveControl( ControlRef inControl , short x , short y )
72e7876b 360{
98af9c73 361 ::MoveControl( inControl , x , y ) ;
72e7876b
SC
362}
363
facd6764 364void UMASizeControl( ControlRef inControl , short x , short y )
72e7876b 365{
98af9c73 366 ::SizeControl( inControl , x , y ) ;
72e7876b
SC
367}
368
facd6764 369void UMADeactivateControl( ControlRef inControl )
72e7876b 370{
98af9c73 371 ::DeactivateControl( inControl ) ;
e40298d5 372}
98af9c73 373
e40298d5 374// shows the control and adds the region to the update region
98af9c73 375void UMAShowControl( ControlRef inControl )
e40298d5
JS
376{
377 SetControlVisibility( inControl , true , false ) ;
e6c3d3e6 378 HIViewSetNeedsDisplay( inControl, true );
72e7876b
SC
379}
380
facd6764 381// hides the control and adds the region to the update region
98af9c73 382void UMAHideControl( ControlRef inControl )
22e751a5 383{
e40298d5 384 SetControlVisibility( inControl , false , false ) ;
e6c3d3e6 385 HIViewSetNeedsDisplay( inControl, true );
22e751a5 386}
98af9c73 387
72e7876b 388// keyboard focus
98af9c73
DS
389OSErr UMASetKeyboardFocus( WindowPtr inWindow,
390 ControlRef inControl,
391 ControlFocusPart inPart )
72e7876b 392{
e40298d5 393 OSErr err = noErr;
e6c3d3e6 394#ifndef __LP64__
e40298d5 395 GrafPtr port ;
72055702 396
98af9c73 397 GetPort( &port ) ;
e40298d5 398 SetPortWindowPort( inWindow ) ;
e6c3d3e6 399#endif
72055702 400
e40298d5 401 err = SetKeyboardFocus( inWindow , inControl , inPart ) ;
e6c3d3e6 402#ifndef __LP64__
e40298d5 403 SetPort( port ) ;
e6c3d3e6 404#endif
98af9c73 405
e40298d5 406 return err ;
72e7876b
SC
407}
408
58751a86 409bool UMAIsWindowFloating( WindowRef inWindow )
72e7876b 410{
e40298d5 411 WindowClass cl ;
58751a86 412
e40298d5
JS
413 GetWindowClass( inWindow , &cl ) ;
414 return cl == kFloatingWindowClass ;
72e7876b
SC
415}
416
58751a86 417bool UMAIsWindowModal( WindowRef inWindow )
72e7876b 418{
e40298d5 419 WindowClass cl ;
58751a86 420
e40298d5
JS
421 GetWindowClass( inWindow , &cl ) ;
422 return cl < kFloatingWindowClass ;
72e7876b
SC
423}
424
425// others
426
427void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate )
428{
e40298d5
JS
429 if ( inWindowRef )
430 {
431// bool isHighlighted = IsWindowHighlited( inWindowRef ) ;
3103e8a9 432// if ( inActivate != isHighlighted )
e6c3d3e6 433#ifndef __LP64__
e40298d5
JS
434 GrafPtr port ;
435 GetPort( &port ) ;
436 SetPortWindowPort( inWindowRef ) ;
e6c3d3e6 437#endif
e40298d5 438 HiliteWindow( inWindowRef , inActivate ) ;
facd6764 439 ControlRef control = NULL ;
98af9c73 440 ::GetRootControl( inWindowRef , &control ) ;
e40298d5
JS
441 if ( control )
442 {
443 if ( inActivate )
444 UMAActivateControl( control ) ;
445 else
446 UMADeactivateControl( control ) ;
58751a86 447 }
e6c3d3e6 448#ifndef __LP64__
e40298d5 449 SetPort( port ) ;
e6c3d3e6 450#endif
e40298d5 451 }
72e7876b 452}
e40298d5 453
58751a86 454OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState )
2f1ae414 455{
e6c3d3e6 456#ifndef __LP64__
e40298d5 457 return ::DrawThemePlacard( inRect , inState ) ;
e6c3d3e6
SC
458#else
459 return noErr;
460#endif
2f1ae414 461}
72e7876b 462
4dd25308 463static OSStatus UMAGetHelpMenu(
98af9c73 464 MenuRef * outHelpMenu,
4dd25308
VZ
465 MenuItemIndex * outFirstCustomItemIndex,
466 bool allowHelpMenuCreation);
467
468static OSStatus UMAGetHelpMenu(
469 MenuRef * outHelpMenu,
470 MenuItemIndex * outFirstCustomItemIndex,
471 bool allowHelpMenuCreation)
b03e4fcd 472{
4dd25308 473 static bool s_createdHelpMenu = false ;
98af9c73 474
4dd25308
VZ
475 if ( !s_createdHelpMenu && !allowHelpMenuCreation )
476 {
477 return paramErr ;
478 }
479
480 OSStatus status = HMGetHelpMenu( outHelpMenu , outFirstCustomItemIndex ) ;
481 s_createdHelpMenu = ( status == noErr ) ;
482 return status ;
b03e4fcd 483}
76a5e5d2 484
4dd25308
VZ
485OSStatus UMAGetHelpMenu(
486 MenuRef * outHelpMenu,
487 MenuItemIndex * outFirstCustomItemIndex)
488{
489 return UMAGetHelpMenu( outHelpMenu , outFirstCustomItemIndex , true );
490}
491
492OSStatus UMAGetHelpMenuDontCreate(
493 MenuRef * outHelpMenu,
494 MenuItemIndex * outFirstCustomItemIndex)
495{
496 return UMAGetHelpMenu( outHelpMenu , outFirstCustomItemIndex , false );
497}
498
e6c3d3e6
SC
499#ifndef __LP64__
500
98af9c73 501wxMacPortStateHelper::wxMacPortStateHelper( GrafPtr newport )
76a5e5d2 502{
e40298d5
JS
503 m_clip = NULL ;
504 Setup( newport ) ;
76a5e5d2
SC
505}
506
507wxMacPortStateHelper::wxMacPortStateHelper()
508{
e40298d5 509 m_clip = NULL ;
76a5e5d2
SC
510}
511
512void wxMacPortStateHelper::Setup( GrafPtr newport )
513{
e40298d5
JS
514 GetPort( &m_oldPort ) ;
515 SetPort( newport ) ;
98af9c73
DS
516 SetOrigin(0, 0);
517
427ff662 518 wxASSERT_MSG( m_clip == NULL , wxT("Cannot call setup twice") ) ;
e40298d5
JS
519 m_clip = NewRgn() ;
520 GetClip( m_clip );
98af9c73
DS
521 m_textFont = GetPortTextFont( (CGrafPtr) newport );
522 m_textSize = GetPortTextSize( (CGrafPtr) newport );
523 m_textStyle = GetPortTextFace( (CGrafPtr) newport );
524 m_textMode = GetPortTextMode( (CGrafPtr) newport );
e40298d5
JS
525 GetThemeDrawingState( &m_drawingState ) ;
526 m_currentPort = newport ;
76a5e5d2 527}
98af9c73 528
76a5e5d2
SC
529void wxMacPortStateHelper::Clear()
530{
e40298d5
JS
531 if ( m_clip )
532 {
533 DisposeRgn( m_clip ) ;
534 DisposeThemeDrawingState( m_drawingState ) ;
535 m_clip = NULL ;
536 }
76a5e5d2
SC
537}
538
539wxMacPortStateHelper::~wxMacPortStateHelper()
540{
e40298d5
JS
541 if ( m_clip )
542 {
543 SetPort( m_currentPort ) ;
544 SetClip( m_clip ) ;
545 DisposeRgn( m_clip ) ;
546 TextFont( m_textFont );
547 TextSize( m_textSize );
548 TextFace( m_textStyle );
549 TextMode( m_textMode );
550 SetThemeDrawingState( m_drawingState , true ) ;
551 SetPort( m_oldPort ) ;
552 }
76a5e5d2
SC
553}
554
e6c3d3e6
SC
555#endif
556
98af9c73 557Rect * UMAGetControlBoundsInWindowCoords( ControlRef theControl, Rect *bounds )
facd6764 558{
facd6764 559 GetControlBounds( theControl , bounds ) ;
98af9c73 560
37d0bfa8 561 WindowRef tlwref = GetControlOwner( theControl ) ;
37d0bfa8 562
789ae0cf 563 wxTopLevelWindowMac* tlwwx = wxFindWinFromMacWindow( tlwref ) ;
e779b609 564 if ( tlwwx != NULL )
789ae0cf
SC
565 {
566 ControlRef rootControl = tlwwx->GetPeer()->GetControlRef() ;
98af9c73
DS
567 HIPoint hiPoint = CGPointMake( 0 , 0 ) ;
568 HIViewConvertPoint( &hiPoint , HIViewGetSuperview(theControl) , rootControl ) ;
789ae0cf
SC
569 OffsetRect( bounds , (short) hiPoint.x , (short) hiPoint.y ) ;
570 }
98af9c73 571
facd6764
SC
572 return bounds ;
573}
574
6239ee05
SC
575size_t UMAPutBytesCFRefCallback( void *info, const void *bytes, size_t count )
576{
577 CFMutableDataRef data = (CFMutableDataRef) info;
578 if ( data )
579 {
580 CFDataAppendBytes( data, (const UInt8*) bytes, count );
581 }
582 return count;
583}
584
31c1cbc7
VZ
585void UMAReleaseCFDataProviderCallback(void *info,
586 const void *WXUNUSED(data),
587 size_t WXUNUSED(count))
6239ee05
SC
588{
589 if ( info )
590 CFRelease( (CFDataRef) info );
591}
592
593void UMAReleaseCFDataConsumerCallback( void *info )
594{
595 if ( info )
596 CFRelease( (CFDataRef) info );
597}
598
599CGDataProviderRef UMACGDataProviderCreateWithCFData( CFDataRef data )
600{
601 if ( data == NULL )
602 return NULL;
31c1cbc7 603
e1673e52 604 return CGDataProviderCreateWithCFData( data );
6239ee05
SC
605}
606
607CGDataConsumerRef UMACGDataConsumerCreateWithCFData( CFMutableDataRef data )
608{
609 if ( data == NULL )
610 return NULL;
31c1cbc7 611
e1673e52 612 return CGDataConsumerCreateWithCFData( data );
6239ee05 613}
2dbc444a
RD
614#endif // wxUSE_GUI
615
616#if wxUSE_BASE
617
618static bool sUMASystemInitialized = false ;
619
620bool UMASystemIsInitialized()
621{
622 return sUMASystemInitialized ;
623}
624
625void UMASetSystemIsInitialized(bool val)
626{
627 sUMASystemInitialized = val;
628}
629
2dbc444a 630#endif // wxUSE_BASE