#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"
#include <malloc.h>
#endif
+#ifndef __DARWIN__
+#include <Scrap.h>
+#include <MacTextEditor.h>
+#endif
#include "wx/mac/uma.h"
#define wxUSE_MLTE 0
}
- m_macControl = ::NewControl( parent->MacGetRootWindow() , &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() ;
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 ;
}
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;
}
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 ) ;
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;
value = wxMacMakeMacStringFromPC( st ) ;
else
value = st ;
- ::SetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ;
- WindowRef window = MacGetRootWindow() ;
- 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->IsTopLevel() )
- {
-// ::SetThemeWindowBackground( win->MacGetRootWindow() , 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() ;
+ Update();
}
// Clipboard operations
TEHandle teH ;
long size ;
- ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
- TECopy( teH ) ;
+ ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
+ TECopy( teH ) ;
ClearCurrentScrap();
- TEToScrap() ;
+ TEToScrap() ;
}
}
TEHandle teH ;
long size ;
- ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
- TECut( teH ) ;
+ ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
+ TECut( teH ) ;
ClearCurrentScrap();
- TEToScrap() ;
- // MacInvalidateControl() ;
- }
+ TEToScrap() ;
+ // MacInvalidateControl() ;
+ }
}
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 = MacGetRootWindow() ;
- 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->IsTopLevel() )
- {
-// ::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() ;
}
}
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)
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 ;
}
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 ;
}
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 ) ;
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() ;
}
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 ) ;
}
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() ;
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() ;
}
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++)
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;
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;
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 ||
/* mUPOpenControl initializes a user pane control so it will be drawn
- and will behave as a scrolling text edit field inside of a window.
- This routine performs all of the initialization steps necessary,
- except it does not create the user pane control itself. theControl
- should refer to a user pane control that you have either created
- yourself or extracted from a dialog's control heirarchy using
- the GetDialogItemAsControl routine. */
+ and will behave as a scrolling text edit field inside of a window.
+ This routine performs all of the initialization steps necessary,
+ except it does not create the user pane control itself. theControl
+ should refer to a user pane control that you have either created
+ yourself or extracted from a dialog's control heirarchy using
+ the GetDialogItemAsControl routine. */
OSStatus mUPOpenControl(ControlHandle theControl, bool multiline) {
- Rect bounds;
- WindowPtr theWindow;
- STPTextPaneVars **tpvars, *varsp;
- OSStatus err;
- RGBColor rgbWhite = {0xFFFF, 0xFFFF, 0xFFFF};
- TXNBackground tback;
-
- /* set up our globals */
- if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(TPPaneDrawProc);
- if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(TPPaneHitTestProc);
- if (gTPTrackProc == NULL) gTPTrackProc = NewControlUserPaneTrackingUPP(TPPaneTrackingProc);
- if (gTPIdleProc == NULL) gTPIdleProc = NewControlUserPaneIdleUPP(TPPaneIdleProc);
- if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(TPPaneKeyDownProc);
- if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(TPPaneActivateProc);
- if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(TPPaneFocusProc);
-
- /* allocate our private storage */
- tpvars = (STPTextPaneVars **) NewHandleClear(sizeof(STPTextPaneVars));
- SetControlReference(theControl, (long) tpvars);
- HLock((Handle) tpvars);
- varsp = *tpvars;
- /* set the initial settings for our private data */
- varsp->fInFocus = false;
- varsp->fIsActive = true;
- varsp->fTEActive = false;
- varsp->fUserPaneRec = theControl;
- theWindow = varsp->fOwner = GetControlOwner(theControl);
+ Rect bounds;
+ WindowPtr theWindow;
+ STPTextPaneVars **tpvars, *varsp;
+ OSStatus err;
+ RGBColor rgbWhite = {0xFFFF, 0xFFFF, 0xFFFF};
+ TXNBackground tback;
+
+ /* set up our globals */
+ if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(TPPaneDrawProc);
+ if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(TPPaneHitTestProc);
+ if (gTPTrackProc == NULL) gTPTrackProc = NewControlUserPaneTrackingUPP(TPPaneTrackingProc);
+ if (gTPIdleProc == NULL) gTPIdleProc = NewControlUserPaneIdleUPP(TPPaneIdleProc);
+ if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(TPPaneKeyDownProc);
+ if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(TPPaneActivateProc);
+ if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(TPPaneFocusProc);
+
+ /* allocate our private storage */
+ tpvars = (STPTextPaneVars **) NewHandleClear(sizeof(STPTextPaneVars));
+ SetControlReference(theControl, (long) tpvars);
+ HLock((Handle) tpvars);
+ varsp = *tpvars;
+ /* set the initial settings for our private data */
+ varsp->fInFocus = false;
+ varsp->fIsActive = true;
+ varsp->fTEActive = false;
+ varsp->fUserPaneRec = theControl;
+ theWindow = varsp->fOwner = GetControlOwner(theControl);
#if TARGET_CARBON
varsp->fDrawingEnvironment = GetWindowPort(varsp->fOwner);
#else
if ( style & wxTE_PASSWORD )
{
- m_macControl = ::NewControl( parent->MacGetRootWindow() , &bounds , "\p" , true , 0 , 0 , 1,
+ m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , "\p" , true , 0 , 0 , 1,
kControlEditTextPasswordProc , (long) this ) ;
}
else
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);
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 );
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;
STPTextPaneVars **tpvars;
/* set up locals */
- tpvars = (STPTextPaneVars **) GetControlReference(m_macControl);
+ tpvars = (STPTextPaneVars **) GetControlReference( (ControlHandle) m_macControl);
TXNGetSelection( (**tpvars).fTXNRec , (TXNOffset*) from , (TXNOffset*) to ) ;
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 = MacGetRootWindow() ;
- 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
TEHandle teH ;
long size ;
- ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
- TECopy( teH ) ;
- ClearCurrentScrap();
- TEToScrap() ;
- }
- else
- {
- mUPDoEditCommand( m_macControl , kmUPCopy ) ;
- }
- }
+ ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
+ TECopy( teH ) ;
+ ClearCurrentScrap();
+ TEToScrap() ;
+ }
+ else
+ {
+ mUPDoEditCommand( (ControlHandle) m_macControl , kmUPCopy ) ;
+ }
+ }
}
void wxTextCtrl::Cut()
TEHandle teH ;
long size ;
- ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
- TECut( teH ) ;
- ClearCurrentScrap();
- TEToScrap() ;
- // MacInvalidateControl() ;
+ ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
+ TECut( teH ) ;
+ ClearCurrentScrap();
+ TEToScrap() ;
+ // MacInvalidateControl() ;
+ }
+ else
+ {
+ mUPDoEditCommand( (ControlHandle) m_macControl , kmUPCut ) ;
+ }
}
- else
- {
- mUPDoEditCommand( m_macControl , kmUPCut ) ;
- }
- }
}
void wxTextCtrl::Paste()
TEHandle teH ;
long size ;
- ::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
- TEFromScrap() ;
- TEPaste( teH ) ;
- WindowRef window = MacGetRootWindow() ;
- 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 ) ;
- }
- }
- }
- else
- {
- mUPDoEditCommand( m_macControl , kmUPPaste ) ;
- }
- }
+ ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
+ TEFromScrap() ;
+ TEPaste( teH ) ;
+ MacRedrawControl() ;
+ }
+ else
+ {
+ mUPDoEditCommand( (ControlHandle) m_macControl , kmUPPaste ) ;
+ }
+ }
}
bool wxTextCtrl::CanCopy() 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)
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 ;
- OSErr err = TXNGetDataEncoded( (**tpvars).fTXNRec, kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData );
- /* all done */
- if ( err )
- {
- actualsize = 0 ;
- }
- else
- {
- actualsize = GetHandleSize( theText ) ;
- DisposeHandle( theText ) ;
- }
- return actualsize ;
+ Handle theText ;
+ OSErr err = TXNGetDataEncoded( (**tpvars).fTXNRec, kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData );
+ /* all done */
+ if ( err )
+ {
+ actualsize = 0 ;
+ }
+ else
+ {
+ actualsize = GetHandleSize( theText ) ;
+ DisposeHandle( theText ) ;
+ }
+ return actualsize ;
}
}
ControlEditTextSelectionRec selection ;
- 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 ) ;
- TESetSelect( from , to , teH ) ;
- TEDelete( teH ) ;
- TEInsert( value , value.Length() , teH ) ;
- }
- else
- {
- // TODO
- }
- Refresh() ;
+ selection.selStart = from ;
+ selection.selEnd = to ;
+ ::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 ) ;
+ }
+ else
+ {
+ // TODO
+ }
+ Refresh() ;
}
void wxTextCtrl::Remove(long from, long to)
ControlEditTextSelectionRec selection ;
- 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 ) ;
- TEDelete( teH ) ;
+ selection.selStart = from ;
+ selection.selEnd = to ;
+ ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
+ ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
+ TEDelete( teH ) ;
}
else
{
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);
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);
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() ;
+ Refresh() ;
}
bool wxTextCtrl::IsModified() const
{
// TODO change this if possible to reflect real lines
wxString content = GetValue() ;
-
- int count = 1;
- for (int i = 0; i < content.Length() ; i++)
- {
- if (content[i] == '\r') count++;
- }
-
+
+ int count = 1;
+ for (int i = 0; i < content.Length() ; i++)
+ {
+ if (content[i] == '\r') count++;
+ }
+
return count;
}
{
// TODO change this if possible to reflect real lines
wxString content = GetValue() ;
-
- // Find line first
- int count = 0;
- for (int i = 0; i < content.Length() ; i++)
- {
- if (count == lineNo)
- {
- // Count chars in line then
- count = 0;
- for (int j = i; j < content.Length(); j++)
- {
- count++;
- if (content[j] == '\r') return count;
- }
-
- return count;
- }
- if (content[i] == '\r') count++;
- }
+
+ // Find line first
+ int count = 0;
+ for (int i = 0; i < content.Length() ; i++)
+ {
+ if (count == lineNo)
+ {
+ // Count chars in line then
+ count = 0;
+ for (int j = i; j < content.Length(); j++)
+ {
+ count++;
+ if (content[j] == '\r') return count;
+ }
+
+ return count;
+ }
+ if (content[i] == '\r') count++;
+ }
return 0;
}
// TODO change this if possible to reflect real lines
wxString content = GetValue() ;
- // Find line first
- int count = 0;
- for (int i = 0; i < content.Length() ; i++)
- {
- if (count == lineNo)
- {
- // Add chars in line then
- wxString tmp("");
-
- for (int j = i; j < content.Length(); j++)
- {
- if (content[j] == '\r')
- return tmp;
-
- tmp += content[j];
- }
-
- return tmp;
- }
- if (content[i] == '\r') count++;
- }
+ // Find line first
+ int count = 0;
+ for (int i = 0; i < content.Length() ; i++)
+ {
+ if (count == lineNo)
+ {
+ // Add chars in line then
+ wxString tmp("");
+
+ for (int j = i; j < content.Length(); j++)
+ {
+ if (content[j] == '\r')
+ return tmp;
+
+ tmp += content[j];
+ }
+
+ return tmp;
+ }
+ if (content[i] == '\r') count++;
+ }
return wxString("");
}
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);