X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9c641c057ce32ffcb7120eae76d582376d19eede..c2edb18a7dc443fc0902945956a355ed722144fa:/src/mac/carbon/textctrl.cpp diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index 4270eefb1c..0c742d3719 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -28,7 +28,7 @@ #include "wx/app.h" #include "wx/dc.h" #include "wx/button.h" -#include "wx/panel.h" +#include "wx/toplevel.h" #include "wx/textctrl.h" #include "wx/notebook.h" #include "wx/tabctrl.h" @@ -42,6 +42,10 @@ #include #endif +#ifndef __DARWIN__ +#include +#include +#endif #include "wx/mac/uma.h" #define wxUSE_MLTE 0 @@ -124,7 +128,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, } - m_macControl = ::NewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , "\p" , true , 0 , 0 , 1, ( style & wxTE_PASSWORD ) ? kControlEditTextPasswordProc : kControlEditTextProc , (long) this ) ; MacPostControlCreate() ; @@ -134,7 +138,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; (*teH)->lineHeight = -1 ; } @@ -142,7 +146,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, value = wxMacMakeMacStringFromPC( st ) ; else value = st ; - ::SetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; + ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; return TRUE; } @@ -150,7 +154,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, wxString wxTextCtrl::GetValue() const { Size actualsize; - ::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; + ::GetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; wxBuffer[actualsize] = 0 ; if( wxApp::s_macDefaultEncodingIsPC ) return wxMacMakePCStringFromMac( wxBuffer ) ; @@ -164,7 +168,7 @@ void wxTextCtrl::GetSelection(long* from, long* to) const TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; *from = (**teH).selStart; *to = (**teH).selEnd; @@ -178,41 +182,8 @@ void wxTextCtrl::SetValue(const wxString& st) value = wxMacMakeMacStringFromPC( st ) ; else value = st ; - ::SetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; - 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() ) - { - ::SetThemeWindowBackground( 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 ) ; - ::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ; - } - } + ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; + MacRedrawControl() ; } // Clipboard operations @@ -223,7 +194,7 @@ void wxTextCtrl::Copy() TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TECopy( teH ) ; ClearCurrentScrap(); TEToScrap() ; @@ -237,7 +208,7 @@ void wxTextCtrl::Cut() TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TECut( teH ) ; ClearCurrentScrap(); TEToScrap() ; @@ -252,43 +223,10 @@ void wxTextCtrl::Paste() TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TEFromScrap() ; TEPaste( teH ) ; - 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() ) - { - ::SetThemeWindowBackground( 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 ) ; - ::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ; - } - } + MacRedrawControl() ; } } @@ -346,9 +284,9 @@ bool wxTextCtrl::CanPaste() const void wxTextCtrl::SetEditable(bool editable) { if ( editable ) - UMAActivateControl( m_macControl ) ; + UMAActivateControl( (ControlHandle) m_macControl ) ; else - UMADeactivateControl( m_macControl ) ; + UMADeactivateControl( (ControlHandle) m_macControl ) ; } void wxTextCtrl::SetInsertionPoint(long pos) @@ -368,8 +306,8 @@ long wxTextCtrl::GetInsertionPoint() const TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; -// ::GetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; +// ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ; return (**teH).selStart ; } @@ -379,9 +317,9 @@ long wxTextCtrl::GetLastPosition() const TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; -// ::GetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ; +// ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ; return (**teH).teLength ; } @@ -394,8 +332,8 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) selection.selStart = from ; selection.selEnd = to ; - ::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TESetSelect( from , to , teH ) ; TEDelete( teH ) ; TEInsert( value , value.Length() , teH ) ; @@ -411,8 +349,8 @@ void wxTextCtrl::Remove(long from, long to) selection.selStart = from ; selection.selEnd = to ; - ::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TEDelete( teH ) ; Refresh() ; } @@ -423,12 +361,12 @@ void wxTextCtrl::SetSelection(long from, long to) TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; selection.selStart = from ; selection.selEnd = to ; - ::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; TESetSelect( selection.selStart , selection.selEnd , teH ) ; } @@ -451,7 +389,7 @@ void wxTextCtrl::WriteText(const wxString& text) wxBuffer[text.Length() ] = 0 ; // wxMacConvertNewlines( wxBuffer , wxBuffer ) ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TEInsert( wxBuffer , strlen( wxBuffer) , teH ) ; Refresh() ; @@ -465,7 +403,7 @@ void wxTextCtrl::AppendText(const wxString& text) void wxTextCtrl::Clear() { - ::SetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ; + ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ; Refresh() ; } @@ -550,7 +488,7 @@ void wxTextCtrl::DiscardEdits() int wxTextCtrl::GetNumberOfLines() const { Size actualsize; - ::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; + ::GetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; int count = 1; for (int i = 0; i < actualsize; i++) @@ -580,7 +518,7 @@ void wxTextCtrl::ShowPosition(long pos) int wxTextCtrl::GetLineLength(long lineNo) const { Size actualsize; - ::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; + ::GetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; // Find line first int count = 0; @@ -607,7 +545,7 @@ int wxTextCtrl::GetLineLength(long lineNo) const wxString wxTextCtrl::GetLineText(long lineNo) const { Size actualsize; - ::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; + ::GetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; // Find line first int count = 0; @@ -715,12 +653,12 @@ void wxTextCtrl::OnChar(wxKeyEvent& key_event) break; } - EventRecord *ev = wxTheApp->MacGetCurrentEvent(); + EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent(); short keychar = short(ev->message & charCodeMask); if (!eat_key) { short keycode = short(ev->message & keyCodeMask) >> 8 ; - ::HandleControlKey( m_macControl , keycode , keychar , ev->modifiers ); + ::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ); } if ( keychar >= 0x20 || key_event.KeyCode() == WXK_RETURN || @@ -1772,12 +1710,12 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, if ( style & wxTE_PASSWORD ) { - m_macControl = ::NewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , "\p" , true , 0 , 0 , 1, kControlEditTextPasswordProc , (long) this ) ; } else { - if ( mUPCreateControl(parent->GetMacRootWindow(), &bounds, &m_macControl) != noErr ) + if ( mUPCreateControl(parent->MacGetRootWindow(), &bounds, &m_macControl) != noErr ) return FALSE ; } MacPostControlCreate() ; @@ -1791,13 +1729,13 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, if ( style & wxTE_PASSWORD ) { - ::SetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; + ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; } else { STPTextPaneVars **tpvars; /* set up locals */ - tpvars = (STPTextPaneVars **) GetControlReference(m_macControl); + tpvars = (STPTextPaneVars **) GetControlReference( (ControlHandle) m_macControl); /* set the text in the record */ TXNSetData( (**tpvars).fTXNRec, kTXNTextData, (const char*)value, value.Length(), kTXNStartOffset, kTXNEndOffset); @@ -1811,14 +1749,14 @@ wxString wxTextCtrl::GetValue() const Size actualsize; if ( m_windowStyle & wxTE_PASSWORD ) { - ::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; + ::GetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; } else { STPTextPaneVars **tpvars; OSStatus err; /* set up locals */ - tpvars = (STPTextPaneVars **) GetControlReference(m_macControl); + tpvars = (STPTextPaneVars **) GetControlReference( (ControlHandle) m_macControl); /* extract the text from the record */ Handle theText ; err = TXNGetDataEncoded( (**tpvars).fTXNRec, kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); @@ -1849,7 +1787,7 @@ void wxTextCtrl::GetSelection(long* from, long* to) const TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; *from = (**teH).selStart; *to = (**teH).selEnd; @@ -1859,7 +1797,7 @@ void wxTextCtrl::GetSelection(long* from, long* to) const STPTextPaneVars **tpvars; /* set up locals */ - tpvars = (STPTextPaneVars **) GetControlReference(m_macControl); + tpvars = (STPTextPaneVars **) GetControlReference( (ControlHandle) m_macControl); TXNGetSelection( (**tpvars).fTXNRec , (TXNOffset*) from , (TXNOffset*) to ) ; @@ -1876,51 +1814,18 @@ void wxTextCtrl::SetValue(const wxString& st) value = st ; if ( m_windowStyle & wxTE_PASSWORD ) { - ::SetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; + ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; } else { STPTextPaneVars **tpvars; /* set up locals */ - tpvars = (STPTextPaneVars **) GetControlReference(m_macControl); + tpvars = (STPTextPaneVars **) GetControlReference( (ControlHandle) m_macControl); /* set the text in the record */ TXNSetData( (**tpvars).fTXNRec, kTXNTextData, (const char*)value, value.Length(), kTXNStartOffset, kTXNEndOffset); } - 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 ) ; - } - } + MacRedrawControl() ; } // Clipboard operations @@ -1933,14 +1838,14 @@ void wxTextCtrl::Copy() TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TECopy( teH ) ; ClearCurrentScrap(); TEToScrap() ; } else { - mUPDoEditCommand( m_macControl , kmUPCopy ) ; + mUPDoEditCommand( (ControlHandle) m_macControl , kmUPCopy ) ; } } } @@ -1954,7 +1859,7 @@ void wxTextCtrl::Cut() TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TECut( teH ) ; ClearCurrentScrap(); TEToScrap() ; @@ -1962,7 +1867,7 @@ void wxTextCtrl::Cut() } else { - mUPDoEditCommand( m_macControl , kmUPCut ) ; + mUPDoEditCommand( (ControlHandle) m_macControl , kmUPCut ) ; } } } @@ -1976,47 +1881,14 @@ void wxTextCtrl::Paste() TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TEFromScrap() ; TEPaste( teH ) ; - 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() ) - { - ::SetThemeWindowBackground( 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 ) ; - ::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ; - } - } + MacRedrawControl() ; } else { - mUPDoEditCommand( m_macControl , kmUPPaste ) ; + mUPDoEditCommand( (ControlHandle) m_macControl , kmUPPaste ) ; } } } @@ -2075,9 +1947,9 @@ bool wxTextCtrl::CanPaste() const void wxTextCtrl::SetEditable(bool editable) { if ( editable ) - UMAActivateControl( m_macControl ) ; + UMAActivateControl( (ControlHandle) m_macControl ) ; else - UMADeactivateControl( m_macControl ) ; + UMADeactivateControl( (ControlHandle) m_macControl ) ; } void wxTextCtrl::SetInsertionPoint(long pos) @@ -2107,14 +1979,14 @@ long wxTextCtrl::GetLastPosition() const TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; -// ::GetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ; +// ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ; return (**teH).teLength ; } else { - STPTextPaneVars** tpvars = (STPTextPaneVars **) GetControlReference(m_macControl); + STPTextPaneVars** tpvars = (STPTextPaneVars **) GetControlReference( (ControlHandle) m_macControl); int actualsize = 0 ; Handle theText ; @@ -2144,8 +2016,8 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) selection.selStart = from ; selection.selEnd = to ; - ::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TESetSelect( from , to , teH ) ; TEDelete( teH ) ; TEInsert( value , value.Length() , teH ) ; @@ -2168,8 +2040,8 @@ void wxTextCtrl::Remove(long from, long to) selection.selStart = from ; selection.selEnd = to ; - ::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TEDelete( teH ) ; } else @@ -2187,19 +2059,19 @@ void wxTextCtrl::SetSelection(long from, long to) TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; selection.selStart = from ; selection.selEnd = to ; - ::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; TESetSelect( selection.selStart , selection.selEnd , teH ) ; } else { STPTextPaneVars **tpvars; /* set up our locals */ - tpvars = (STPTextPaneVars **) GetControlReference(m_macControl); + tpvars = (STPTextPaneVars **) GetControlReference( (ControlHandle) m_macControl); /* and our drawing environment as the operation may force a redraw in the text area. */ SetPort((**tpvars).fDrawingEnvironment); @@ -2230,14 +2102,14 @@ void wxTextCtrl::WriteText(const wxString& text) TEHandle teH ; long size ; - ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TEInsert( value , value.Length() , teH ) ; } else { STPTextPaneVars **tpvars; /* set up locals */ - tpvars = (STPTextPaneVars **) GetControlReference(m_macControl); + tpvars = (STPTextPaneVars **) GetControlReference( (ControlHandle) m_macControl); /* set the text in the record */ TXNSetData( (**tpvars).fTXNRec, kTXNTextData, (const char*)value, value.Length(), kTXNUseCurrentSelection, kTXNUseCurrentSelection); @@ -2256,11 +2128,11 @@ void wxTextCtrl::Clear() if ( m_windowStyle & wxTE_PASSWORD ) { - ::SetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ; + ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ; } else { - mUPDoEditCommand( m_macControl , kmUPClear) ; + mUPDoEditCommand( (ControlHandle) m_macControl , kmUPClear) ; } Refresh() ; } @@ -2506,7 +2378,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) short keychar ; keychar = short(ev->message & charCodeMask); keycode = short(ev->message & keyCodeMask) >> 8 ; - UMAHandleControlKey( m_macControl , keycode , keychar , ev->modifiers ) ; + UMAHandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ; if ( keychar >= 0x20 || event.KeyCode() == WXK_RETURN || event.KeyCode() == WXK_DELETE || event.KeyCode() == WXK_BACK) { wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);