]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/aga.cpp
don't crash in UnselectAll() if the tree has no root
[wxWidgets.git] / src / mac / aga.cpp
index d356a5ac1d93380f407fe47664a746939a78bc69..66da32984c52987a2386a5ae35fecdba326d63e7 100644 (file)
@@ -1,9 +1,10 @@
-#include <wx/mac/uma.h>
-#include <wx/mac/aga.h>
+#include "wx/dc.h"
+#include "wx/mac/uma.h"
+#include "wx/mac/aga.h"
 
-#if !TARGET_CARBON
+#if 0 // TO BE REMOVED SOON
 
-#include <extcdef.h>
+//#include <extcdef.h>
 #include <PictUtils.h>
 
 pascal SInt32 AGAProgressBarDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param);
@@ -13,26 +14,27 @@ pascal SInt32 AGAListControlDefProc (SInt16 procID, ControlHandle theControl, Co
 pascal SInt32 AGAEditTextDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) ;
 pascal SInt32 AGAStaticGroupBoxTextDefProc (SInt16 procID, ControlHandle theControl, ControlDefProcMessage message, SInt32 param) ;
 
-#define B                                                                                                              13
-#define        W                                                                                                               0
+#define B   13
+#define        W   0
 
 SInt16 kAGARootControlProcID ;
 int gAGABackgroundColor = 0 ;
 
-const RGBColor gAGAColorArray[] = {    {0xFFFF, 0xFFFF, 0xFFFF},               //      W
-                                       {0xEEEE, 0xEEEE, 0xEEEE},       //      1
-                                       {0xDDDD, 0xDDDD, 0xDDDD},       //      2
-                                       {0xCCCC, 0xCCCC, 0xCCCC},       //      3
-                                       {0xBBBB, 0xBBBB, 0xBBBB},       //      4
-                                       {0xAAAA, 0xAAAA, 0xAAAA},       //      5
-                                       {0x9999, 0x9999, 0x9999},       //      6
-                                       {0x8888, 0x8888, 0x8888},               //      7
-                                       {0x7777, 0x7777, 0x7777},               //      8
-                                       {0x6666, 0x6666, 0x6666},               //      9
-                                       {0x5555, 0x5555, 0x5555},               //      10
-                                       {0x4444, 0x4444, 0x4444},               //      11
-                                       {0x2222, 0x2222, 0x2222},               //      12
-                                       {0x0000, 0x0000, 0x0000}                //      B
+const RGBColor gAGAColorArray[] = {
+  {0xFFFF, 0xFFFF, 0xFFFF},    //      W
+  {0xEEEE, 0xEEEE, 0xEEEE},    //      1
+  {0xDDDD, 0xDDDD, 0xDDDD},    //      2
+  {0xCCCC, 0xCCCC, 0xCCCC},    //      3
+  {0xBBBB, 0xBBBB, 0xBBBB},    //      4
+  {0xAAAA, 0xAAAA, 0xAAAA},    //      5
+  {0x9999, 0x9999, 0x9999},    //      6
+  {0x8888, 0x8888, 0x8888},    //      7
+  {0x7777, 0x7777, 0x7777},    //      8
+  {0x6666, 0x6666, 0x6666},    //      9
+  {0x5555, 0x5555, 0x5555},    //      10
+  {0x4444, 0x4444, 0x4444},    //      11
+  {0x2222, 0x2222, 0x2222},    //      12
+  {0x0000, 0x0000, 0x0000}     //      B
 };
 
 char LAGADefaultOutline_mCorners[4][5][5] =    {
@@ -2552,70 +2554,58 @@ void AGAApplyThemeBackground(ThemeBackgroundKind        inKind,
 {
 }
 
-#endif
+#endif // !TARGET_CARBON
+
+// this helper class stores and restores the current grafport
+// status in a theme savvy manner, pen mode, patterns and fonts
+// attributes
+
 AGAPortHelper::AGAPortHelper( GrafPtr newport) 
 {
-       GetPort( &port ) ;
-       SetPort( newport ) ;
-//     wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ; 
-       GetPenState( &oldPenState ) ;
-       GetBackColor( &oldBackColor ) ;
-       GetForeColor( &oldForeColor ) ;
-
-       clip = NewRgn() ;
-       GetClip( clip );
-       font = GetPortTextFont( newport);
-       size = GetPortTextSize( newport);
-       style = GetPortTextFace( newport);
-       mode = GetPortTextMode( newport);       
-       nport = newport ;
-
+  m_clip = NULL ;
+  Setup( newport ) ;
 }
 AGAPortHelper::AGAPortHelper()
 {
-       clip = NULL ;
+       m_clip = NULL ;
 }
+
 void AGAPortHelper::Setup( GrafPtr newport )
 {
-       GetPort( &port ) ;
+       GetPort( &m_oldPort ) ;
        SetPort( newport ) ;
-//     wxASSERT( newport->portRect.left == 0 && newport->portRect.top == 0 ) ; 
-       GetPenState( &oldPenState ) ;
-       GetBackColor( &oldBackColor ) ;
-       GetForeColor( &oldForeColor ) ;
-
-       clip = NewRgn() ;
-       GetClip( clip );
-       font = GetPortTextFont( newport);
-       size = GetPortTextSize( newport);
-       style = GetPortTextFace( newport);
-       mode = GetPortTextMode( newport);       
-       nport = newport ;
+       wxASSERT_MSG( m_clip == NULL , "Cannot call setup twice" ) ;
+       m_clip = NewRgn() ;
+       GetClip( m_clip );
+       m_textFont = GetPortTextFont( newport);
+       m_textSize = GetPortTextSize( newport);
+       m_textStyle = GetPortTextFace( newport);
+       m_textMode = GetPortTextMode( newport); 
+       GetThemeDrawingState( &m_drawingState ) ;
+       m_currentPort = newport ;
 }
 void AGAPortHelper::Clear()
 {
-       if ( clip )
+       if ( m_clip )
        {
-               DisposeRgn( clip ) ;
-               clip = NULL ;
+               DisposeRgn( m_clip ) ;
+               DisposeThemeDrawingState( m_drawingState ) ;
+               m_clip = NULL ;
        }
 }
 AGAPortHelper::~AGAPortHelper()
 {
-       if ( clip )
+       if ( m_clip )
        {
-               SetPort( nport ) ;
-               SetClip( clip ) ;
-               DisposeRgn( clip ) ;
-               RGBForeColor(&oldForeColor);
-               RGBBackColor(&oldBackColor);
-               SetPenState(&oldPenState);                              
-
-               TextFont( font );
-               TextSize( size );
-               TextFace( style );
-               TextMode( mode );
-               SetPort( port ) ;
+               SetPort( m_currentPort ) ;
+               SetClip( m_clip ) ;
+               DisposeRgn( m_clip ) ;
+               TextFont( m_textFont );
+               TextSize( m_textSize );
+               TextFace( m_textStyle );
+               TextMode( m_textMode );
+               SetThemeDrawingState( m_drawingState , true ) ;
+               SetPort( m_oldPort ) ;
        }
 }