]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/control.cpp
added new focus behaviour (like MSW) and toolbar fixes
[wxWidgets.git] / src / mac / control.cpp
index ab62f4034d6009dfa6419556c2e52cbfc24cc795..cbbd8e34297699b9c6876a35dba98028cbce2c58 100644 (file)
 #endif
 
 #include "wx/control.h"
+#include "wx/panel.h"
+#include "wx/app.h"
 #include "wx/notebook.h"
 #include "wx/tabctrl.h"
 #include "wx/radiobox.h"
 #include "wx/spinbutt.h"
+#include "wx/scrolbar.h"
+#include "wx/button.h"
+#include "wx/dialog.h"
+#include "wx/statbox.h"
+#include "wx/sizer.h"
+#include "wx/stattext.h"
 
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
@@ -61,7 +69,11 @@ wxControl::wxControl()
 
        if ( wxMacLiveScrollbarActionUPP == NULL )
        {
+#ifdef __UNIX__
+        wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc );
+#else
                wxMacLiveScrollbarActionUPP = NewControlActionProc( wxMacLiveScrollbarActionProc ) ;
+#endif
        }
 }
 
@@ -115,9 +127,12 @@ void wxControl::SetLabel(const wxString& title)
                else
                        label = title ;
                
-               strcpy( (char*) maclabel , label ) ;
-               c2pstr( (char*) maclabel ) ;
-       
+#if TARGET_CARBON
+               c2pstrcpy( (StringPtr) maclabel , label ) ;
+#else
+               strcpy( (char *) maclabel , label ) ;
+               c2pstr( (char *) maclabel ) ;
+#endif
                ::SetControlTitle( m_macControl , maclabel ) ;
        }
 }
@@ -209,13 +224,19 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l
        outBounds->bottom = outBounds->top + m_height - 2 * m_macVerticalBorder;
        outBounds->right = outBounds->left + m_width - 2 * m_macHorizontalBorder ;
 
-       strcpy( (char*) maclabel , label ) ;
+       char c_text[255];
+       strcpy( c_text , label ) ;
        if( wxApp::s_macDefaultEncodingIsPC )
        {
-               wxMacConvertFromPCForControls( (char*) maclabel ) ;
+               wxMacConvertFromPCForControls( c_text ) ;
        }
 
-       c2pstr( (char*) maclabel ) ;
+#if TARGET_CARBON
+       c2pstrcpy( (StringPtr) maclabel , c_text ) ;
+#else
+       strcpy( (char *) maclabel , c_text ) ;
+       c2pstr( (char *) maclabel ) ;
+#endif
 }
 
 void wxControl::MacPostControlCreate()
@@ -245,6 +266,7 @@ void wxControl::MacPostControlCreate()
        ControlHandle container = GetParent()->MacGetContainerForEmbedding() ;
        wxASSERT_MSG( container != NULL , "No valid mac container control" ) ;
        ::UMAEmbedControl( m_macControl , container ) ;
+       m_macControlIsShown  = true ;
        MacAdjustControlRect() ;
        wxAssociateControlWithMacControl( m_macControl , this ) ;
 }
@@ -395,12 +417,19 @@ void  wxControl::MacSuperShown( bool show )
        {
                if ( !show )
                {
-                       ::UMAHideControl( m_macControl ) ;
+                       if ( m_macControlIsShown )
+                       {
+                               ::UMAHideControl( m_macControl ) ;
+                               m_macControlIsShown = false ;
+                       }
                }
                else
                {
-                       if ( m_isShown )
+                       if ( MacIsReallyShown() && !m_macControlIsShown )
+                       {
                                ::UMAShowControl( m_macControl ) ;
+                               m_macControlIsShown = true ;
+                       }
                }
        }
                
@@ -520,10 +549,22 @@ bool  wxControl::Show(bool show)
                
        if ( m_macControl )
        {
-               if ( show )
-                       ::UMAShowControl( m_macControl ) ;
+               if ( !show )
+               {
+                       if ( m_macControlIsShown )
+                       {
+                               ::UMAHideControl( m_macControl ) ;
+                               m_macControlIsShown = false ;
+                       }
+               }
                else
-                       ::UMAHideControl( m_macControl ) ;
+               {
+                       if ( MacIsReallyShown() && !m_macControlIsShown )
+                       {
+                               ::UMAShowControl( m_macControl ) ;
+                               m_macControlIsShown = true ;
+                       }
+               }
        }
        return TRUE ;
 }
@@ -602,6 +643,7 @@ void wxControl::MacRedrawControl()
                                
                                UMADrawControl( m_macControl ) ;
                                UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
+                               wxDC::MacInvalidateSetup() ;
                        }
                }
        }
@@ -643,6 +685,7 @@ void wxControl::OnPaint(wxPaintEvent& event)
                                
                                UMADrawControl( m_macControl ) ;
                                UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
+                               wxDC::MacInvalidateSetup() ;
                        }
                }
        }
@@ -718,10 +761,12 @@ void  wxControl::OnMouseEvent( wxMouseEvent &event )
        
                controlpart = FindControl( localwhere , window , &control ) ;
                {
+               /*
                        if ( AcceptsFocus() && FindFocus() != this )
                        {
                                SetFocus() ;
                        }
+               */
                        if ( control && UMAIsControlActive( control ) )
                        {
                                {