]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/textctrl.cpp
Got rid of some wierd VisualAge debug nonsense that had appeared in this after the...
[wxWidgets.git] / src / mac / carbon / textctrl.cpp
index af3919bb7bd4ca122df4e2cf3dbfcc9c3a4fd069..0a51bb757e8f4a10eaefbb61390dd3f28283061b 100644 (file)
 #pragma implementation "textctrl.h"
 #endif
 
-#ifndef __WXMAC__
-#include <sys/types.h>
-#include <sys/stat.h>
+#ifdef __UNIX__
+  #include <sys/types.h>
+  #include <sys/stat.h>
 #else
-#include <stat.h>
+  #include <stat.h>
 #endif
 #include <fstream.h>
 
+#include "wx/app.h"
+#include "wx/dc.h"
+#include "wx/button.h"
+#include "wx/panel.h"
 #include "wx/textctrl.h"
+#include "wx/notebook.h"
+#include "wx/tabctrl.h"
 #include "wx/settings.h"
 #include "wx/filefn.h"
 #include "wx/utils.h"
 
 #if defined(__BORLANDC__) && !defined(__WIN32__)
-#include <alloc.h>
-#else
-#ifndef __MWERKS__
-#ifndef __GNUWIN32__
-#include <malloc.h>
-#endif
-#endif
+  #include <alloc.h>
+#elif !defined(__MWERKS__) && !defined(__GNUWIN32) && !defined(__WXMAC_X__)
+  #include <malloc.h>
 #endif
 
 #include "wx/mac/uma.h"
@@ -111,6 +113,14 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
 
        wxString value ;
        
+       {
+               TEHandle teH ;
+               long size ;
+   
+               UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
+               (*teH)->lineHeight = -1 ;
+       }
+       
        if( wxApp::s_macDefaultEncodingIsPC )
                value = wxMacMakeMacStringFromPC( st ) ;
        else
@@ -152,8 +162,41 @@ void wxTextCtrl::SetValue(const wxString& st)
        else
                value = st ;
        UMASetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ;
-       Refresh() ;
-//     MacInvalidateControl() ;
+       WindowRef window = GetMacRootWindow() ;
+       if ( window )
+       {
+               wxWindow* win = wxFindWinFromMacWindow( window ) ;
+               if ( win )
+               {
+                       wxMacDrawingHelper help( win ) ;
+                       // the mac control manager always assumes to have the origin at 0,0
+                       SetOrigin( 0 , 0 ) ;
+                       
+                       bool                    hasTabBehind = false ;
+                       wxWindow* parent = GetParent() ;
+                       while ( parent )
+                       {
+                               if( parent->MacGetWindowData() )
+                               {
+                                       UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
+                                       break ;
+                               }
+                               
+                               if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) ||  parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
+                               {
+                                       if ( ((wxControl*)parent)->GetMacControl() )
+                                               SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
+                                       break ;
+                               }
+                               
+                               parent = parent->GetParent() ;
+                       } 
+                       
+                       UMADrawControl( m_macControl ) ;
+                       UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
+                       wxDC::MacInvalidateSetup() ;
+               }
+       }
 }
 
 // Clipboard operations
@@ -208,7 +251,41 @@ void wxTextCtrl::Paste()
                UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
                TEFromScrap() ;
                TEPaste( teH ) ;
-//     MacInvalidateControl() ;
+               WindowRef window = GetMacRootWindow() ;
+               if ( window )
+               {
+                       wxWindow* win = wxFindWinFromMacWindow( window ) ;
+                       if ( win )
+                       {
+                               wxMacDrawingHelper help( win ) ;
+                               // the mac control manager always assumes to have the origin at 0,0
+                               SetOrigin( 0 , 0 ) ;
+                               
+                               bool                    hasTabBehind = false ;
+                               wxWindow* parent = GetParent() ;
+                               while ( parent )
+                               {
+                                       if( parent->MacGetWindowData() )
+                                       {
+                                               UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
+                                               break ;
+                                       }
+                                       
+                                       if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) ||  parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
+                                       {
+                                               if ( ((wxControl*)parent)->GetMacControl() )
+                                                       SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
+                                               break ;
+                                       }
+                                       
+                                       parent = parent->GetParent() ;
+                               } 
+                               
+                               UMADrawControl( m_macControl ) ;
+                               UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
+                               wxDC::MacInvalidateSetup() ;
+                       }
+               }
        }
 }