]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/control.cpp
renamed port to session for Carbon printing
[wxWidgets.git] / src / mac / control.cpp
index 15bc46b48e4a0f402107e7eb493af79085a69195..f0714b067a99305774f138b94d0860d40b1c77a8 100644 (file)
 #pragma implementation "control.h"
 #endif
 
 #pragma implementation "control.h"
 #endif
 
+#include "wx/defs.h"
+
 #include "wx/control.h"
 #include "wx/panel.h"
 #include "wx/app.h"
 #include "wx/control.h"
 #include "wx/panel.h"
 #include "wx/app.h"
+#include "wx/dc.h"
 #include "wx/notebook.h"
 #include "wx/tabctrl.h"
 #include "wx/radiobox.h"
 #include "wx/notebook.h"
 #include "wx/tabctrl.h"
 #include "wx/radiobox.h"
@@ -69,7 +72,7 @@ wxControl::wxControl()
 
        if ( wxMacLiveScrollbarActionUPP == NULL )
        {
 
        if ( wxMacLiveScrollbarActionUPP == NULL )
        {
-#ifdef __UNIX__
+#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
         wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc );
 #else
                wxMacLiveScrollbarActionUPP = NewControlActionProc( wxMacLiveScrollbarActionProc ) ;
         wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc );
 #else
                wxMacLiveScrollbarActionUPP = NewControlActionProc( wxMacLiveScrollbarActionProc ) ;
@@ -135,6 +138,7 @@ void wxControl::SetLabel(const wxString& title)
 #endif
                ::SetControlTitle( m_macControl , maclabel ) ;
        }
 #endif
                ::SetControlTitle( m_macControl , maclabel ) ;
        }
+       Refresh() ;
 }
 
 wxSize wxControl::DoGetBestSize() const
 }
 
 wxSize wxControl::DoGetBestSize() const
@@ -269,6 +273,7 @@ void wxControl::MacPostControlCreate()
        m_macControlIsShown  = true ;
        MacAdjustControlRect() ;
        wxAssociateControlWithMacControl( m_macControl , this ) ;
        m_macControlIsShown  = true ;
        MacAdjustControlRect() ;
        wxAssociateControlWithMacControl( m_macControl , this ) ;
+       UMAShowControl( m_macControl ) ;
 }
 
 void wxControl::MacAdjustControlRect() 
 }
 
 void wxControl::MacAdjustControlRect() 
@@ -302,6 +307,8 @@ void wxControl::MacAdjustControlRect()
                        if ( IsKindOf( CLASSINFO( wxButton ) ) )
                        {
                                m_width = m_label.Length() * 8 + 12 ;
                        if ( IsKindOf( CLASSINFO( wxButton ) ) )
                        {
                                m_width = m_label.Length() * 8 + 12 ;
+                               if ( m_width < 70 )
+                                 m_width = 70 ;
                        }
                        else if ( IsKindOf( CLASSINFO( wxStaticText ) ) )
                        {
                        }
                        else if ( IsKindOf( CLASSINFO( wxStaticText ) ) )
                        {
@@ -355,15 +362,15 @@ void wxControl::MacSuperChangedPosition()
        
                if ( mac_x != former_mac_x || mac_y != former_mac_y )
                {
        
                if ( mac_x != former_mac_x || mac_y != former_mac_y )
                {
-                       {
-                               Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ;
-                               InvalWindowRect( rootwindow , &inval ) ;
-                       }
+                       {
+                               Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ;
+                               InvalWindowRect( rootwindow , &inval ) ;
+                       }
                        UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ;
                        UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ;
-                       {
-                               Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
-                               InvalWindowRect( rootwindow , &inval ) ;
-                       }
+                       {
+                               Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
+                               InvalWindowRect( rootwindow , &inval ) ;
+                       }
                }
                if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
                {
                }
                if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
                {
@@ -491,15 +498,15 @@ void  wxControl::DoSetSize(int x, int y,
        
        if ( mac_x != former_mac_x || mac_y != former_mac_y )
        {
        
        if ( mac_x != former_mac_x || mac_y != former_mac_y )
        {
-               {
-                       Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ;
-                       InvalWindowRect( macrootwindow, &inval ) ;
-               }
+               {
+                       Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ;
+                       InvalWindowRect( macrootwindow, &inval ) ;
+               }
                UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y  + m_macVerticalBorder ) ;
                UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y  + m_macVerticalBorder ) ;
-               {
-                       Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
-                       InvalWindowRect(macrootwindow, &inval ) ;
-               }
+               {
+                       Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ;
+                       InvalWindowRect(macrootwindow, &inval ) ;
+               }
        }
 
        if ( actualX != former_x || actualY != former_y )
        }
 
        if ( actualX != former_x || actualY != former_y )
@@ -509,9 +516,10 @@ void  wxControl::DoSetSize(int x, int y,
 
                MacRepositionScrollBars() ;
                // To consider -> should the parameters be the effective or the virtual coordinates (AdjustForParent..)
 
                MacRepositionScrollBars() ;
                // To consider -> should the parameters be the effective or the virtual coordinates (AdjustForParent..)
-    wxMoveEvent event(wxPoint(m_x, m_y), m_windowId);
-    event.SetEventObject(this);
-    GetEventHandler()->ProcessEvent(event);
+       wxPoint point(m_x, m_y);
+        wxMoveEvent event(point, m_windowId);
+        event.SetEventObject(this);
+        GetEventHandler()->ProcessEvent(event);
        }               
        if ( actualWidth != former_w || actualHeight != former_h )
        {
        }               
        if ( actualWidth != former_w || actualHeight != former_h )
        {
@@ -529,9 +537,10 @@ void  wxControl::DoSetSize(int x, int y,
                }
 
                MacRepositionScrollBars() ;
                }
 
                MacRepositionScrollBars() ;
-    wxSizeEvent event(wxSize(m_width, m_height), m_windowId);
-    event.SetEventObject(this);
-    GetEventHandler()->ProcessEvent(event);
+       wxSize size(m_width, m_height);
+        wxSizeEvent event(size, m_windowId);
+        event.SetEventObject(this);
+        GetEventHandler()->ProcessEvent(event);
        }
        if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
        {
        }
        if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) )
        {
@@ -576,21 +585,10 @@ bool  wxControl::Enable(bool enable)
 
        if ( m_macControl )
        {
 
        if ( m_macControl )
        {
-               
-               if ( UMAHasAppearance() )
-               {
-                       if ( enable )
-                               ::ActivateControl( m_macControl ) ;
-                       else
-                               ::DeactivateControl( m_macControl ) ;
-               }
+               if ( enable )
+                   UMAActivateControl( m_macControl ) ;
                else
                else
-               {
-                       if ( enable )
-                               ::HiliteControl( m_macControl , 0 ) ;
-                       else
-                               ::HiliteControl( m_macControl , 255 ) ;
-               }
+                   UMADeactivateControl( m_macControl ) ;
        }
        return TRUE ;
 }
        }
        return TRUE ;
 }
@@ -643,7 +641,6 @@ void wxControl::MacRedrawControl()
                                
                                UMADrawControl( m_macControl ) ;
                                UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
                                
                                UMADrawControl( m_macControl ) ;
                                UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
-                               wxDC::MacInvalidateSetup() ;
                        }
                }
        }
                        }
                }
        }
@@ -662,8 +659,9 @@ void wxControl::OnPaint(wxPaintEvent& event)
                                wxMacDrawingHelper help( win ) ;
                                // the mac control manager always assumes to have the origin at 0,0
                                SetOrigin( 0 , 0 ) ;
                                wxMacDrawingHelper help( win ) ;
                                // the mac control manager always assumes to have the origin at 0,0
                                SetOrigin( 0 , 0 ) ;
+
                                
                                
-                               bool                    hasTabBehind = false ;
+                               bool hasTabBehind = false ;
                                wxWindow* parent = GetParent() ;
                                while ( parent )
                                {
                                wxWindow* parent = GetParent() ;
                                while ( parent )
                                {
@@ -682,10 +680,9 @@ void wxControl::OnPaint(wxPaintEvent& event)
                                        
                                        parent = parent->GetParent() ;
                                } 
                                        
                                        parent = parent->GetParent() ;
                                } 
-                               
+
                                UMADrawControl( m_macControl ) ;
                                UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
                                UMADrawControl( m_macControl ) ;
                                UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
-                               wxDC::MacInvalidateSetup() ;
                        }
                }
        }
                        }
                }
        }
@@ -761,10 +758,12 @@ void  wxControl::OnMouseEvent( wxMouseEvent &event )
        
                controlpart = FindControl( localwhere , window , &control ) ;
                {
        
                controlpart = FindControl( localwhere , window , &control ) ;
                {
+               /*
                        if ( AcceptsFocus() && FindFocus() != this )
                        {
                                SetFocus() ;
                        }
                        if ( AcceptsFocus() && FindFocus() != this )
                        {
                                SetFocus() ;
                        }
+               */
                        if ( control && UMAIsControlActive( control ) )
                        {
                                {
                        if ( control && UMAIsControlActive( control ) )
                        {
                                {