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