]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/textctrl.cpp
no message
[wxWidgets.git] / src / mac / carbon / textctrl.cpp
index dd35860824a55510f3cc0305215f0b3f5f7f4f09..0724fe9da9a8cc4d921d0ad7c8fd010de92b8378 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"
@@ -105,6 +107,15 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
 
        MacPreControlCreate( parent , id ,  "" , pos , mySize ,style, validator , name , &bounds , title ) ;
 
+    if ( m_windowStyle & wxTE_MULTILINE )
+    {
+        wxASSERT_MSG( !(m_windowStyle & wxTE_PROCESS_ENTER),
+                      wxT("wxTE_PROCESS_ENTER style is ignored for multiline text controls (they always process it)") );
+
+        m_windowStyle |= wxTE_PROCESS_ENTER;
+    }
+
+
        m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, 
                ( style & wxTE_PASSWORD ) ? kControlEditTextPasswordProc : kControlEditTextProc , (long) this ) ;
        MacPostControlCreate() ;
@@ -160,7 +171,40 @@ 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) ) ;
-       UMADrawControl( m_macControl ) ;
+       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 ) ;
+               }
+       }
 }
 
 // Clipboard operations
@@ -215,7 +259,40 @@ void wxTextCtrl::Paste()
                UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
                TEFromScrap() ;
                TEPaste( teH ) ;
-               UMADrawControl( m_macControl ) ;
+               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 ) ;
+                       }
+               }
        }
 }
 
@@ -326,7 +403,7 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value)
        TESetSelect( from , to  , teH ) ;
        TEDelete( teH ) ;
                TEInsert( value , value.Length() , teH ) ;
-//     MacInvalidateControl() ;
+       Refresh() ;
 }
 
 void wxTextCtrl::Remove(long from, long to)
@@ -341,7 +418,7 @@ void wxTextCtrl::Remove(long from, long to)
        UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
        UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
        TEDelete( teH ) ;
-//     MacInvalidateControl() ;
+       Refresh() ;
 }
 
 void wxTextCtrl::SetSelection(long from, long to)
@@ -585,7 +662,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
        keychar = short(ev->message & charCodeMask);
        keycode = short(ev->message & keyCodeMask) >> 8 ;
        UMAHandleControlKey( m_macControl , keycode , keychar , ev->modifiers ) ;
-       if ( keychar >= 0x20 || event.KeyCode() == WXK_RETURN)
+       if ( keychar >= 0x20 || event.KeyCode() == WXK_RETURN || event.KeyCode() == WXK_DELETE || event.KeyCode() == WXK_BACK)
        {
         wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
         event.SetString( GetValue() ) ;