]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/uma.cpp
added spinctrl to be ignored when clicked (otherwise its siblings on the same window...
[wxWidgets.git] / src / mac / carbon / uma.cpp
CommitLineData
03e11df5 1#include "wx/defs.h"
5fde6fcc 2#include "wx/dc.h"
03e11df5 3#include "wx/mac/uma.h"
b03e4fcd 4#include <MacTextEditor.h>
72e7876b 5
f5c6eb5c 6#ifndef __DARWIN__
a3d3d3bf
GD
7# include <Navigation.h>
8# if defined(TARGET_CARBON)
9# if PM_USE_SESSION_APIS
10# include <PMCore.h>
11# endif
12# include <PMApplication.h>
66a09d47
SC
13# else
14# include <Printing.h>
a3d3d3bf 15# endif
03e11df5 16#endif
5b781a67 17
72055702
SC
18// since we have decided that we only support 8.6 upwards we are
19// checking for these minimum requirements in the startup code of
20// the application so all wxWindows code can safely assume that appearance 1.1
21// windows manager, control manager, navigation services etc. are
22// present
e7b596fb 23
72e7876b
SC
24static bool sUMAHasAppearance = false ;
25static long sUMAAppearanceVersion = 0 ;
0888ccc7 26static bool sUMAHasAquaLayout = false ;
0e5a4d20
SC
27static bool sUMASystemInitialized = false ;
28
72e7876b
SC
29extern int gAGABackgroundColor ;
30bool UMAHasAppearance() { return sUMAHasAppearance ; }
31long UMAGetAppearanceVersion() { return sUMAAppearanceVersion ; }
32
33static bool sUMAHasWindowManager = false ;
34static long sUMAWindowManagerAttr = 0 ;
35
36bool UMAHasWindowManager() { return sUMAHasWindowManager ; }
37long UMAGetWindowManagerAttr() { return sUMAWindowManagerAttr ; }
0888ccc7 38bool UMAHasAquaLayout() { return sUMAHasAquaLayout ; }
0e5a4d20 39bool UMASystemIsInitialized() { return sUMASystemInitialized ; }
72055702 40
5b781a67
SC
41void UMACleanupToolbox()
42{
5b781a67
SC
43 if ( sUMAHasAppearance )
44 {
45 UnregisterAppearanceClient() ;
46 }
5b781a67
SC
47 if ( NavServicesAvailable() )
48 {
49 NavUnload() ;
50 }
f8eebb95
SC
51 if ( TXNTerminateTextension != (void*) kUnresolvedCFragSymbolAddress )
52 TXNTerminateTextension( ) ;
5b781a67 53}
72e7876b
SC
54void UMAInitToolbox( UInt16 inMoreMastersCalls )
55{
56#if !TARGET_CARBON
57 ::MaxApplZone();
58 for (long i = 1; i <= inMoreMastersCalls; i++)
59 ::MoreMasters();
60
61 ::InitGraf(&qd.thePort);
62 ::InitFonts();
72e7876b
SC
63 ::InitMenus();
64 ::TEInit();
65 ::InitDialogs(0L);
66 ::FlushEvents(everyEvent, 0);
67 ::InitCursor();
68 long total,contig;
69 PurgeSpace(&total, &contig);
70#else
2f1ae414 71 InitCursor();
72e7876b
SC
72#endif
73
72e7876b
SC
74 long theAppearance ;
75 if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr )
76 {
77 sUMAHasAppearance = true ;
78 RegisterAppearanceClient();
79 if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr )
80 {
81 sUMAAppearanceVersion = theAppearance ;
82 }
83 else
84 {
85 sUMAAppearanceVersion = 0x0100 ;
86 }
87 }
72e7876b
SC
88 if ( Gestalt( gestaltWindowMgrAttr, &sUMAWindowManagerAttr ) == noErr )
89 {
90 sUMAHasWindowManager = sUMAWindowManagerAttr & gestaltWindowMgrPresent ;
91 }
5b781a67 92
8e8d3ba8
SC
93#if TARGET_CARBON
94// Call currently implicitely done : InitFloatingWindows() ;
95#else
5b781a67
SC
96 if ( sUMAHasWindowManager )
97 InitFloatingWindows() ;
98 else
99 InitWindows();
03e11df5 100#endif
5b781a67
SC
101
102 if ( NavServicesAvailable() )
103 {
104 NavLoad() ;
105 }
b03e4fcd 106
f8eebb95
SC
107 if ( TXNInitTextension != (void*) kUnresolvedCFragSymbolAddress )
108 {
109 TXNMacOSPreferredFontDescription defaults;
110 defaults.fontID = kFontIDGeneva ;
111 defaults.pointSize = (10 << 16) ;
112 defaults.fontStyle = kTXNDefaultFontStyle;
113 defaults.encoding = kTXNSystemDefaultEncoding;
114 TXNInitTextension(&defaults, 1, (kTXNAlwaysUseQuickDrawTextMask | kTXNWantMoviesMask | kTXNWantSoundMask | kTXNWantGraphicsMask));
115 }
116
0888ccc7
SC
117 long menuMgrAttr ;
118 Gestalt( gestaltMenuMgrAttr , &menuMgrAttr ) ;
119 if ( menuMgrAttr & gestaltMenuMgrAquaLayoutMask )
120 sUMAHasAquaLayout = true ;
0e5a4d20 121 sUMASystemInitialized = true ;
66a09d47 122
72e7876b
SC
123}
124
66a09d47
SC
125/*
126Boolean CanUseATSUI()
127 {
128 long result;
129 OSErr err = Gestalt(gestaltATSUVersion, &result);
130 return (err == noErr);
131 }
132*/
72e7876b
SC
133// process manager
134long UMAGetProcessMode()
135{
136 OSErr err ;
137 ProcessInfoRec processinfo;
138 ProcessSerialNumber procno ;
139
140 procno.highLongOfPSN = NULL ;
141 procno.lowLongOfPSN = kCurrentProcess ;
142 processinfo.processInfoLength = sizeof(ProcessInfoRec);
143 processinfo.processName = NULL;
144 processinfo.processAppSpec = NULL;
145
146 err = ::GetProcessInformation( &procno , &processinfo ) ;
147 wxASSERT( err == noErr ) ;
148 return processinfo.processMode ;
149}
150
151bool UMAGetProcessModeDoesActivateOnFGSwitch()
152{
153 return UMAGetProcessMode() & modeDoesActivateOnFGSwitch ;
154}
155
156// menu manager
157
2f1ae414 158void UMASetMenuTitle( MenuRef menu , StringPtr title )
72e7876b 159{
76a5e5d2 160/*
72e7876b
SC
161#if !TARGET_CARBON
162 long size = GetHandleSize( (Handle) menu ) ;
163 const long headersize = 14 ;
164 int oldlen = (**menu).menuData[0] + 1;
165 int newlen = title[0] + 1 ;
166
167 if ( oldlen < newlen )
168 {
169 // enlarge before adjusting
170 SetHandleSize( (Handle) menu , size + (newlen - oldlen ) );
171 }
172
173 if ( oldlen != newlen )
174 memmove( (char*) (**menu).menuData + newlen , (char*) (**menu).menuData + oldlen , size - headersize - oldlen ) ;
175
176 memcpy( (char*) (**menu).menuData , title , newlen ) ;
177 if ( oldlen > newlen )
178 {
179 // shrink after
180 SetHandleSize( (Handle) menu , size + (newlen - oldlen ) ) ;
181 }
182#else
76a5e5d2 183*/
72e7876b 184 SetMenuTitle( menu , title ) ;
76a5e5d2 185//#endif
72e7876b
SC
186}
187
188UInt32 UMAMenuEvent( EventRecord *inEvent )
189{
72e7876b 190 return MenuEvent( inEvent ) ;
72e7876b
SC
191}
192
193void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex inItem )
194{
72e7876b 195 EnableMenuItem( inMenu , inItem ) ;
72e7876b
SC
196}
197
198void UMADisableMenuItem( MenuRef inMenu , MenuItemIndex inItem )
199{
72e7876b 200 DisableMenuItem( inMenu , inItem ) ;
72e7876b 201}
2f1ae414
SC
202
203void UMAAppendSubMenuItem( MenuRef menu , StringPtr l , SInt16 id )
204{
205 Str255 label ;
206 memcpy( label , l , l[0]+1 ) ;
207 // hardcoded adding of the submenu combination for mac
208
209 int theEnd = label[0] + 1;
210 if (theEnd > 251)
211 theEnd = 251; // mac allows only 255 characters
212 label[theEnd++] = '/';
213 label[theEnd++] = hMenuCmd;
214 label[theEnd++] = '!';
215 label[theEnd++] = id ;
216 label[theEnd] = 0x00;
217 label[0] = theEnd;
218 MacAppendMenu(menu, label);
219}
220
221void UMAInsertSubMenuItem( MenuRef menu , StringPtr l , MenuItemIndex item , SInt16 id )
222{
223 Str255 label ;
224 memcpy( label , l , l[0]+1 ) ;
225 // hardcoded adding of the submenu combination for mac
226
227 int theEnd = label[0] + 1;
228 if (theEnd > 251)
229 theEnd = 251; // mac allows only 255 characters
230 label[theEnd++] = '/';
231 label[theEnd++] = hMenuCmd;
232 label[theEnd++] = '!';
233 label[theEnd++] = id;
234 label[theEnd] = 0x00;
235 label[0] = theEnd;
236 MacInsertMenuItem(menu, label , item);
237}
238
239void UMAAppendMenuItem( MenuRef menu , StringPtr l , SInt16 key, UInt8 modifiers )
240{
241 Str255 label ;
242 memcpy( label , l , l[0]+1 ) ;
243 if ( key )
244 {
245 int pos = label[0] ;
246 label[++pos] = '/';
247 label[++pos] = toupper( key );
248 label[0] = pos ;
249 }
250 MacAppendMenu( menu , label ) ;
251}
252
253void UMAInsertMenuItem( MenuRef menu , StringPtr l , MenuItemIndex item , SInt16 key, UInt8 modifiers )
254{
255 Str255 label ;
256 memcpy( label , l , l[0]+1 ) ;
257 if ( key )
258 {
259 int pos = label[0] ;
260 label[++pos] = '/';
261 label[++pos] = toupper( key );
262 label[0] = pos ;
263 }
264 MacInsertMenuItem( menu , label , item) ;
265}
266
72e7876b
SC
267// quickdraw
268
2f1ae414
SC
269int gPrOpenCounter = 0 ;
270
a3d3d3bf 271OSStatus UMAPrOpen(void *macPrintSession)
2f1ae414
SC
272{
273#if !TARGET_CARBON
274 OSErr err = noErr ;
275 ++gPrOpenCounter ;
276 if ( gPrOpenCounter == 1 )
277 {
278 PrOpen() ;
279 err = PrError() ;
280 wxASSERT( err == noErr ) ;
281 }
5b781a67 282 return err ;
2f1ae414 283#else
5b781a67
SC
284 OSStatus err = noErr ;
285 ++gPrOpenCounter ;
286 if ( gPrOpenCounter == 1 )
287 {
a689a4d0 288 #if PM_USE_SESSION_APIS
a3d3d3bf 289 err = PMCreateSession((PMPrintSession *)macPrintSession) ;
a689a4d0
GD
290 #else
291 err = PMBegin() ;
292 #endif
5b781a67
SC
293 wxASSERT( err == noErr ) ;
294 }
295 return err ;
2f1ae414
SC
296#endif
297}
298
a3d3d3bf 299OSStatus UMAPrClose(void *macPrintSession)
2f1ae414
SC
300{
301#if !TARGET_CARBON
302 OSErr err = noErr ;
303 wxASSERT( gPrOpenCounter >= 1 ) ;
304 if ( gPrOpenCounter == 1 )
305 {
306 PrClose() ;
307 err = PrError() ;
308 wxASSERT( err == noErr ) ;
309 }
310 --gPrOpenCounter ;
5b781a67 311 return err ;
2f1ae414 312#else
5b781a67
SC
313 OSStatus err = noErr ;
314 wxASSERT( gPrOpenCounter >= 1 ) ;
315 if ( gPrOpenCounter == 1 )
316 {
a689a4d0 317 #if PM_USE_SESSION_APIS
a3d3d3bf
GD
318 err = PMRelease(*(PMPrintSession *)macPrintSession) ;
319 *(PMPrintSession *)macPrintSession = kPMNoReference;
a689a4d0
GD
320 #else
321 err = PMEnd() ;
322 #endif
5b781a67
SC
323 }
324 --gPrOpenCounter ;
325 return err ;
2f1ae414
SC
326#endif
327}
328
72e7876b
SC
329#if !TARGET_CARBON
330
72055702 331pascal QDGlobalsPtr GetQDGlobalsPtr (void) ;
72e7876b
SC
332pascal QDGlobalsPtr GetQDGlobalsPtr (void)
333{
334 return QDGlobalsPtr (* (Ptr*) LMGetCurrentA5 ( ) - 0xCA);
335}
336
337#endif
338
339void UMAShowWatchCursor()
340{
341 OSErr err = noErr;
342
343 CursHandle watchFob = GetCursor (watchCursor);
344
345 if (!watchFob)
346 err = nilHandleErr;
347 else
348 {
349 #if TARGET_CARBON
72055702
SC
350// Cursor preservedArrow;
351// GetQDGlobalsArrow (&preservedArrow);
352// SetQDGlobalsArrow (*watchFob);
353// InitCursor ( );
354// SetQDGlobalsArrow (&preservedArrow);
355 SetCursor (*watchFob);
72e7876b
SC
356 #else
357 SetCursor (*watchFob);
358 #endif
359 }
360}
361
362void UMAShowArrowCursor()
363{
364#if TARGET_CARBON
365 Cursor arrow;
366 SetCursor (GetQDGlobalsArrow (&arrow));
367#else
368 SetCursor (&(qd.arrow));
369#endif
370}
371
372// window manager
373
374GrafPtr UMAGetWindowPort( WindowRef inWindowRef )
375{
376 wxASSERT( inWindowRef != NULL ) ;
377#if TARGET_CARBON
cf6674a4 378 return (GrafPtr) GetWindowPort( inWindowRef ) ;
72e7876b
SC
379#else
380 return (GrafPtr) inWindowRef ;
381#endif
382}
383
384void UMADisposeWindow( WindowRef inWindowRef )
385{
386 wxASSERT( inWindowRef != NULL ) ;
387 DisposeWindow( inWindowRef ) ;
388}
389
390void UMASetWTitleC( WindowRef inWindowRef , const char *title )
391{
392 Str255 ptitle ;
393 strncpy( (char*)ptitle , title , 96 ) ;
394 ptitle[96] = 0 ;
03e11df5
GD
395#if TARGET_CARBON
396 c2pstrcpy( ptitle, (char *)ptitle ) ;
397#else
72e7876b 398 c2pstr( (char*)ptitle ) ;
03e11df5 399#endif
72e7876b
SC
400 SetWTitle( inWindowRef , ptitle ) ;
401}
03e11df5 402
72e7876b
SC
403void UMAGetWTitleC( WindowRef inWindowRef , char *title )
404{
405 GetWTitle( inWindowRef , (unsigned char*)title ) ;
03e11df5
GD
406#if TARGET_CARBON
407 p2cstrcpy( title, (unsigned char *)title ) ;
408#else
72e7876b 409 p2cstr( (unsigned char*)title ) ;
03e11df5 410#endif
72e7876b
SC
411}
412
72e7876b
SC
413// appearance additions
414
415void UMAActivateControl( ControlHandle inControl )
416{
22e751a5
SC
417 // we have to add the control after again to the update rgn
418 // otherwise updates get lost
419 if ( !IsControlActive( inControl ) )
420 {
fdaf613a
SC
421 bool visible = IsControlVisible( inControl ) ;
422 if ( visible )
423 SetControlVisibility( inControl , false , false ) ;
3f4902f5 424 ::ActivateControl( inControl ) ;
fdaf613a
SC
425 if ( visible ) {
426 SetControlVisibility( inControl , true , false ) ;
c36f0244
SC
427 Rect ctrlBounds ;
428 InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
fdaf613a 429 }
22e751a5 430 }
72e7876b
SC
431}
432
433void UMADrawControl( ControlHandle inControl )
434{
3f4902f5
GD
435 WindowRef theWindow = GetControlOwner(inControl) ;
436 RgnHandle updateRgn = NewRgn() ;
3f4902f5 437 GetWindowUpdateRgn( theWindow , updateRgn ) ;
22e751a5
SC
438 Point zero = { 0 , 0 } ;
439 LocalToGlobal( &zero ) ;
440 OffsetRgn( updateRgn , -zero.h , -zero.v ) ;
441 ::DrawControlInCurrentPort( inControl ) ;
442 InvalWindowRgn( theWindow, updateRgn) ;
443 DisposeRgn( updateRgn ) ;
72e7876b
SC
444}
445
446void UMAMoveControl( ControlHandle inControl , short x , short y )
447{
72055702
SC
448 bool visible = IsControlVisible( inControl ) ;
449 if ( visible ) {
450 SetControlVisibility( inControl , false , false ) ;
451 Rect ctrlBounds ;
452 InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
453 }
454 ::MoveControl( inControl , x , y ) ;
455 if ( visible ) {
456 SetControlVisibility( inControl , true , false ) ;
457 Rect ctrlBounds ;
458 InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
459 }
72e7876b
SC
460}
461
462void UMASizeControl( ControlHandle inControl , short x , short y )
463{
72055702
SC
464 bool visible = IsControlVisible( inControl ) ;
465 if ( visible ) {
466 SetControlVisibility( inControl , false , false ) ;
467 Rect ctrlBounds ;
468 InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
b03e4fcd 469 }
72055702
SC
470 ::SizeControl( inControl , x , y ) ;
471 if ( visible ) {
472 SetControlVisibility( inControl , true , false ) ;
473 Rect ctrlBounds ;
474 InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
475 }
72e7876b
SC
476}
477
478void UMADeactivateControl( ControlHandle inControl )
479{
22e751a5
SC
480 // we have to add the control after again to the update rgn
481 // otherwise updates get lost
72055702
SC
482 bool visible = IsControlVisible( inControl ) ;
483 if ( visible )
484 SetControlVisibility( inControl , false , false ) ;
485 ::DeactivateControl( inControl ) ;
486 if ( visible ) {
487 SetControlVisibility( inControl , true , false ) ;
488 Rect ctrlBounds ;
489 InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
490 }
72e7876b 491}
fdaf613a 492// shows the control and adds the region to the update region
3f4902f5 493void UMAShowControl (ControlHandle inControl)
72e7876b 494{
fdaf613a 495 SetControlVisibility( inControl , true , false ) ;
c36f0244
SC
496 Rect ctrlBounds ;
497 InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
72e7876b
SC
498}
499
22e751a5
SC
500// shows the control and adds the region to the update region
501void UMAHideControl (ControlHandle inControl)
502{
503 SetControlVisibility( inControl , false , false ) ;
504 Rect ctrlBounds ;
505 InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
506}
72e7876b
SC
507// keyboard focus
508OSErr UMASetKeyboardFocus (WindowPtr inWindow,
509 ControlHandle inControl,
510 ControlFocusPart inPart)
511{
2f1ae414
SC
512 OSErr err = noErr;
513 GrafPtr port ;
514 GetPort( &port ) ;
72055702
SC
515
516 SetPortWindowPort( inWindow ) ;
517
72055702 518 err = SetKeyboardFocus( inWindow , inControl , inPart ) ;
2f1ae414
SC
519 SetPort( port ) ;
520 return err ;
72e7876b
SC
521}
522
523
524
525
526// events
72e7876b
SC
527void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn )
528{
72055702
SC
529 RgnHandle updateRgn = NewRgn() ;
530 GetWindowUpdateRgn( inWindow , updateRgn ) ;
531
be57fda6
SC
532 Point zero = { 0 , 0 } ;
533 LocalToGlobal( &zero ) ;
534 OffsetRgn( updateRgn , -zero.h , -zero.v ) ;
72e7876b 535
72055702
SC
536 UpdateControls( inWindow , inRgn ) ;
537 InvalWindowRgn( inWindow, updateRgn) ;
538 DisposeRgn( updateRgn ) ;
72e7876b 539
72e7876b
SC
540}
541
542bool UMAIsWindowFloating( WindowRef inWindow )
543{
544 WindowClass cl ;
545
72055702 546 GetWindowClass( inWindow , &cl ) ;
72e7876b
SC
547 return cl == kFloatingWindowClass ;
548}
549
550bool UMAIsWindowModal( WindowRef inWindow )
551{
552 WindowClass cl ;
553
72055702 554 GetWindowClass( inWindow , &cl ) ;
72e7876b
SC
555 return cl < kFloatingWindowClass ;
556}
557
558// others
559
560void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate )
561{
562 if ( inWindowRef )
563 {
564// bool isHighlighted = IsWindowHighlited( inWindowRef ) ;
565// if ( inActivate != isHightlited )
c809f3be
SC
566 GrafPtr port ;
567 GetPort( &port ) ;
72055702 568 SetPortWindowPort( inWindowRef ) ;
c809f3be
SC
569 HiliteWindow( inWindowRef , inActivate ) ;
570 ControlHandle control = NULL ;
72055702 571 ::GetRootControl( inWindowRef , & control ) ;
c809f3be
SC
572 if ( control )
573 {
574 if ( inActivate )
575 UMAActivateControl( control ) ;
576 else
577 UMADeactivateControl( control ) ;
578 }
579 SetPort( port ) ;
72e7876b
SC
580 }
581}
2f1ae414
SC
582OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState )
583{
72055702 584 return ::DrawThemePlacard( inRect , inState ) ;
2f1ae414 585}
72e7876b 586
2f056c85 587#if !TARGET_CARBON
b03e4fcd 588static OSStatus helpMenuStatus = noErr ;
b03e4fcd 589static MenuItemIndex firstCustomItemIndex = 0 ;
2f056c85 590#endif
b03e4fcd
SC
591
592OSStatus UMAGetHelpMenu(
593 MenuRef * outHelpMenu,
594 MenuItemIndex * outFirstCustomItemIndex)
595{
596#if TARGET_CARBON
597 return HMGetHelpMenu( outHelpMenu , outFirstCustomItemIndex ) ;
598#else
ca5e5bad
SC
599 MenuRef helpMenuHandle ;
600 helpMenuStatus = HMGetHelpMenuHandle( &helpMenuHandle ) ;
601 if ( firstCustomItemIndex == 0 && helpMenuStatus == noErr )
b03e4fcd 602 {
ca5e5bad 603 firstCustomItemIndex = CountMenuItems( helpMenuHandle ) + 1 ;
b03e4fcd
SC
604 }
605 if ( outFirstCustomItemIndex )
606 {
607 *outFirstCustomItemIndex = firstCustomItemIndex ;
608 }
609 *outHelpMenu = helpMenuHandle ;
610 return helpMenuStatus ;
611#endif
612}
76a5e5d2
SC
613
614wxMacPortStateHelper::wxMacPortStateHelper( GrafPtr newport)
615{
616 m_clip = NULL ;
617 Setup( newport ) ;
618}
619
620wxMacPortStateHelper::wxMacPortStateHelper()
621{
622 m_clip = NULL ;
623}
624
625void wxMacPortStateHelper::Setup( GrafPtr newport )
626{
627 GetPort( &m_oldPort ) ;
628 SetPort( newport ) ;
629 wxASSERT_MSG( m_clip == NULL , "Cannot call setup twice" ) ;
630 m_clip = NewRgn() ;
631 GetClip( m_clip );
632 m_textFont = GetPortTextFont( (CGrafPtr) newport);
633 m_textSize = GetPortTextSize( (CGrafPtr) newport);
634 m_textStyle = GetPortTextFace( (CGrafPtr) newport);
635 m_textMode = GetPortTextMode( (CGrafPtr) newport);
636 GetThemeDrawingState( &m_drawingState ) ;
637 m_currentPort = newport ;
638}
639void wxMacPortStateHelper::Clear()
640{
641 if ( m_clip )
642 {
643 DisposeRgn( m_clip ) ;
644 DisposeThemeDrawingState( m_drawingState ) ;
645 m_clip = NULL ;
646 }
647}
648
649wxMacPortStateHelper::~wxMacPortStateHelper()
650{
651 if ( m_clip )
652 {
653 SetPort( m_currentPort ) ;
654 SetClip( m_clip ) ;
655 DisposeRgn( m_clip ) ;
656 TextFont( m_textFont );
657 TextSize( m_textSize );
658 TextFace( m_textStyle );
659 TextMode( m_textMode );
660 SetThemeDrawingState( m_drawingState , true ) ;
661 SetPort( m_oldPort ) ;
662 }
663}
664