changed defaultitem method from belonging to a panel to any window
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12872 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -103,11 +103,11 @@ wxControl::~wxControl()
|
|||||||
m_isBeingDeleted = TRUE;
|
m_isBeingDeleted = TRUE;
|
||||||
// If we delete an item, we should initialize the parent panel,
|
// If we delete an item, we should initialize the parent panel,
|
||||||
// because it could now be invalid.
|
// because it could now be invalid.
|
||||||
wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
|
wxWindow *parent = GetParent() ;
|
||||||
if ( panel )
|
if ( parent )
|
||||||
{
|
{
|
||||||
if (panel->GetDefaultItem() == (wxButton*) this)
|
if (parent->GetDefaultItem() == (wxButton*) this)
|
||||||
panel->SetDefaultItem(NULL);
|
parent->SetDefaultItem(NULL);
|
||||||
}
|
}
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
|
@@ -223,16 +223,10 @@ void wxTextCtrl::Copy()
|
|||||||
TEHandle teH ;
|
TEHandle teH ;
|
||||||
long size ;
|
long size ;
|
||||||
|
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TECopy( teH ) ;
|
TECopy( teH ) ;
|
||||||
#if TARGET_CARBON
|
ClearCurrentScrap();
|
||||||
OSStatus err ;
|
TEToScrap() ;
|
||||||
err = ClearCurrentScrap( );
|
|
||||||
#else
|
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,18 +237,12 @@ void wxTextCtrl::Cut()
|
|||||||
TEHandle teH ;
|
TEHandle teH ;
|
||||||
long size ;
|
long size ;
|
||||||
|
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TECut( teH ) ;
|
TECut( teH ) ;
|
||||||
#if TARGET_CARBON
|
ClearCurrentScrap();
|
||||||
OSStatus err ;
|
TEToScrap() ;
|
||||||
err = ClearCurrentScrap( );
|
// MacInvalidateControl() ;
|
||||||
#else
|
}
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
|
||||||
// MacInvalidateControl() ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Paste()
|
void wxTextCtrl::Paste()
|
||||||
@@ -683,15 +671,12 @@ void wxTextCtrl::OnChar(wxKeyEvent& key_event)
|
|||||||
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
||||||
{
|
{
|
||||||
wxWindow *parent = GetParent();
|
wxWindow *parent = GetParent();
|
||||||
wxPanel *panel = wxDynamicCast(parent, wxPanel);
|
while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) {
|
||||||
while ( parent != NULL && panel == NULL )
|
parent = parent->GetParent() ;
|
||||||
{
|
|
||||||
parent = parent->GetParent() ;
|
|
||||||
panel = wxDynamicCast(parent, wxPanel);
|
|
||||||
}
|
}
|
||||||
if ( panel && panel->GetDefaultItem() )
|
if ( parent && parent->GetDefaultItem() )
|
||||||
{
|
{
|
||||||
wxButton *def = wxDynamicCast(panel->GetDefaultItem(),
|
wxButton *def = wxDynamicCast(parent->GetDefaultItem(),
|
||||||
wxButton);
|
wxButton);
|
||||||
if ( def && def->IsEnabled() )
|
if ( def && def->IsEnabled() )
|
||||||
{
|
{
|
||||||
@@ -699,9 +684,9 @@ void wxTextCtrl::OnChar(wxKeyEvent& key_event)
|
|||||||
event.SetEventObject(def);
|
event.SetEventObject(def);
|
||||||
def->Command(event);
|
def->Command(event);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this will make wxWindows eat the ENTER key so that
|
// this will make wxWindows eat the ENTER key so that
|
||||||
// we actually prevent line wrapping in a single line
|
// we actually prevent line wrapping in a single line
|
||||||
// text control
|
// text control
|
||||||
@@ -805,19 +790,7 @@ void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#if !TARGET_CARBON
|
extern wxApp *wxTheApp ;
|
||||||
#define GetControlOwner( control ) (**control).contrlOwner
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//todo add access to global event record
|
|
||||||
|
|
||||||
EventRecord event ;
|
|
||||||
|
|
||||||
static EventRecord *GetCurrentEventRecord()
|
|
||||||
{
|
|
||||||
return &event ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// CS:We will replace the TextEdit by using the MultiLanguageTextEngine based on the following code written by apple
|
// CS:We will replace the TextEdit by using the MultiLanguageTextEngine based on the following code written by apple
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1025,7 +998,7 @@ ControlUserPaneFocusUPP gTPFocusProc = NULL;
|
|||||||
|
|
||||||
/* events handled by our focus advance override routine */
|
/* events handled by our focus advance override routine */
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventUnicodeForKeyEvent } };
|
static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } };
|
||||||
#define kMLTEEventCount (sizeof( gMLTEEvents ) / sizeof( EventTypeSpec ))
|
#define kMLTEEventCount (sizeof( gMLTEEvents ) / sizeof( EventTypeSpec ))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1366,40 +1339,40 @@ bail:
|
|||||||
|
|
||||||
|
|
||||||
/* mUPOpenControl initializes a user pane control so it will be drawn
|
/* mUPOpenControl initializes a user pane control so it will be drawn
|
||||||
and will behave as a scrolling text edit field inside of a window.
|
and will behave as a scrolling text edit field inside of a window.
|
||||||
This routine performs all of the initialization steps necessary,
|
This routine performs all of the initialization steps necessary,
|
||||||
except it does not create the user pane control itself. theControl
|
except it does not create the user pane control itself. theControl
|
||||||
should refer to a user pane control that you have either created
|
should refer to a user pane control that you have either created
|
||||||
yourself or extracted from a dialog's control heirarchy using
|
yourself or extracted from a dialog's control heirarchy using
|
||||||
the GetDialogItemAsControl routine. */
|
the GetDialogItemAsControl routine. */
|
||||||
OSStatus mUPOpenControl(ControlHandle theControl) {
|
OSStatus mUPOpenControl(ControlHandle theControl, bool multiline) {
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
WindowPtr theWindow;
|
WindowPtr theWindow;
|
||||||
STPTextPaneVars **tpvars, *varsp;
|
STPTextPaneVars **tpvars, *varsp;
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
RGBColor rgbWhite = {0xFFFF, 0xFFFF, 0xFFFF};
|
RGBColor rgbWhite = {0xFFFF, 0xFFFF, 0xFFFF};
|
||||||
TXNBackground tback;
|
TXNBackground tback;
|
||||||
|
|
||||||
/* set up our globals */
|
/* set up our globals */
|
||||||
if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(TPPaneDrawProc);
|
if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(TPPaneDrawProc);
|
||||||
if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(TPPaneHitTestProc);
|
if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(TPPaneHitTestProc);
|
||||||
if (gTPTrackProc == NULL) gTPTrackProc = NewControlUserPaneTrackingUPP(TPPaneTrackingProc);
|
if (gTPTrackProc == NULL) gTPTrackProc = NewControlUserPaneTrackingUPP(TPPaneTrackingProc);
|
||||||
if (gTPIdleProc == NULL) gTPIdleProc = NewControlUserPaneIdleUPP(TPPaneIdleProc);
|
if (gTPIdleProc == NULL) gTPIdleProc = NewControlUserPaneIdleUPP(TPPaneIdleProc);
|
||||||
if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(TPPaneKeyDownProc);
|
if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(TPPaneKeyDownProc);
|
||||||
if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(TPPaneActivateProc);
|
if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(TPPaneActivateProc);
|
||||||
if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(TPPaneFocusProc);
|
if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(TPPaneFocusProc);
|
||||||
|
|
||||||
/* allocate our private storage */
|
/* allocate our private storage */
|
||||||
tpvars = (STPTextPaneVars **) NewHandleClear(sizeof(STPTextPaneVars));
|
tpvars = (STPTextPaneVars **) NewHandleClear(sizeof(STPTextPaneVars));
|
||||||
SetControlReference(theControl, (long) tpvars);
|
SetControlReference(theControl, (long) tpvars);
|
||||||
HLock((Handle) tpvars);
|
HLock((Handle) tpvars);
|
||||||
varsp = *tpvars;
|
varsp = *tpvars;
|
||||||
/* set the initial settings for our private data */
|
/* set the initial settings for our private data */
|
||||||
varsp->fInFocus = false;
|
varsp->fInFocus = false;
|
||||||
varsp->fIsActive = true;
|
varsp->fIsActive = true;
|
||||||
varsp->fTEActive = false;
|
varsp->fTEActive = false;
|
||||||
varsp->fUserPaneRec = theControl;
|
varsp->fUserPaneRec = theControl;
|
||||||
theWindow = varsp->fOwner = GetControlOwner(theControl);
|
theWindow = varsp->fOwner = GetControlOwner(theControl);
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
varsp->fDrawingEnvironment = GetWindowPort(varsp->fOwner);
|
varsp->fDrawingEnvironment = GetWindowPort(varsp->fOwner);
|
||||||
#else
|
#else
|
||||||
@@ -1446,7 +1419,6 @@ OSStatus mUPOpenControl(ControlHandle theControl) {
|
|||||||
err = InstallWindowEventHandler( varsp->fOwner, varsp->handlerUPP,
|
err = InstallWindowEventHandler( varsp->fOwner, varsp->handlerUPP,
|
||||||
kMLTEEventCount, gMLTEEvents, tpvars, &varsp->handlerRef );
|
kMLTEEventCount, gMLTEEvents, tpvars, &varsp->handlerRef );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* unlock our storage */
|
/* unlock our storage */
|
||||||
HUnlock((Handle) tpvars);
|
HUnlock((Handle) tpvars);
|
||||||
/* perform final activations and setup for our text field. Here,
|
/* perform final activations and setup for our text field. Here,
|
||||||
@@ -1798,8 +1770,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( style & wxTE_PASSWORD )
|
if ( style & wxTE_PASSWORD )
|
||||||
{
|
{
|
||||||
m_macControl = ::NewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1,
|
m_macControl = ::NewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1,
|
||||||
kControlEditTextPasswordProc , (long) this ) ;
|
kControlEditTextPasswordProc , (long) this ) ;
|
||||||
}
|
}
|
||||||
@@ -1961,18 +1933,16 @@ void wxTextCtrl::Copy()
|
|||||||
TEHandle teH ;
|
TEHandle teH ;
|
||||||
long size ;
|
long size ;
|
||||||
|
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TECopy( teH ) ;
|
TECopy( teH ) ;
|
||||||
#if TARGET_CARBON
|
ClearCurrentScrap();
|
||||||
OSStatus err ;
|
TEToScrap() ;
|
||||||
err = ClearCurrentScrap( );
|
}
|
||||||
#else
|
else
|
||||||
OSErr err ;
|
{
|
||||||
err = ZeroScrap( );
|
mUPDoEditCommand( m_macControl , kmUPCopy ) ;
|
||||||
#endif
|
}
|
||||||
TEToScrap() ;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Cut()
|
void wxTextCtrl::Cut()
|
||||||
@@ -1984,19 +1954,17 @@ void wxTextCtrl::Cut()
|
|||||||
TEHandle teH ;
|
TEHandle teH ;
|
||||||
long size ;
|
long size ;
|
||||||
|
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TECut( teH ) ;
|
TECut( teH ) ;
|
||||||
#if TARGET_CARBON
|
ClearCurrentScrap();
|
||||||
OSStatus err ;
|
TEToScrap() ;
|
||||||
err = ClearCurrentScrap( );
|
// MacInvalidateControl() ;
|
||||||
#else
|
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
|
||||||
// MacInvalidateControl() ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mUPDoEditCommand( m_macControl , kmUPCut ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Paste()
|
void wxTextCtrl::Paste()
|
||||||
@@ -2008,45 +1976,49 @@ void wxTextCtrl::Paste()
|
|||||||
TEHandle teH ;
|
TEHandle teH ;
|
||||||
long size ;
|
long size ;
|
||||||
|
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TEFromScrap() ;
|
TEFromScrap() ;
|
||||||
TEPaste( teH ) ;
|
TEPaste( teH ) ;
|
||||||
WindowRef window = GetMacRootWindow() ;
|
WindowRef window = GetMacRootWindow() ;
|
||||||
if ( window )
|
if ( window )
|
||||||
{
|
{
|
||||||
wxWindow* win = wxFindWinFromMacWindow( window ) ;
|
wxWindow* win = wxFindWinFromMacWindow( window ) ;
|
||||||
if ( win )
|
if ( win )
|
||||||
{
|
{
|
||||||
wxMacDrawingHelper help( win ) ;
|
wxMacDrawingHelper help( win ) ;
|
||||||
// the mac control manager always assumes to have the origin at 0,0
|
// the mac control manager always assumes to have the origin at 0,0
|
||||||
SetOrigin( 0 , 0 ) ;
|
SetOrigin( 0 , 0 ) ;
|
||||||
|
|
||||||
bool hasTabBehind = false ;
|
bool hasTabBehind = false ;
|
||||||
wxWindow* parent = GetParent() ;
|
wxWindow* parent = GetParent() ;
|
||||||
while ( parent )
|
while ( parent )
|
||||||
{
|
{
|
||||||
if( parent->MacGetWindowData() )
|
if( parent->MacGetWindowData() )
|
||||||
{
|
{
|
||||||
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
|
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
|
||||||
{
|
{
|
||||||
if ( ((wxControl*)parent)->GetMacControl() )
|
if ( ((wxControl*)parent)->GetMacControl() )
|
||||||
SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
|
SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent = parent->GetParent() ;
|
parent = parent->GetParent() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
UMADrawControl( m_macControl ) ;
|
UMADrawControl( m_macControl ) ;
|
||||||
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
|
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
mUPDoEditCommand( m_macControl , kmUPPaste ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::CanCopy() const
|
bool wxTextCtrl::CanCopy() const
|
||||||
@@ -2140,6 +2112,25 @@ long wxTextCtrl::GetLastPosition() const
|
|||||||
// ::GetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ;
|
// ::GetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ;
|
||||||
return (**teH).teLength ;
|
return (**teH).teLength ;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
STPTextPaneVars** tpvars = (STPTextPaneVars **) GetControlReference(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 ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
||||||
@@ -2151,15 +2142,19 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
|||||||
|
|
||||||
ControlEditTextSelectionRec selection ;
|
ControlEditTextSelectionRec selection ;
|
||||||
|
|
||||||
selection.selStart = from ;
|
selection.selStart = from ;
|
||||||
selection.selEnd = to ;
|
selection.selEnd = to ;
|
||||||
::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
|
::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TESetSelect( from , to , teH ) ;
|
TESetSelect( from , to , teH ) ;
|
||||||
TEDelete( teH ) ;
|
TEDelete( teH ) ;
|
||||||
TEInsert( value , value.Length() , teH ) ;
|
TEInsert( value , value.Length() , teH ) ;
|
||||||
}
|
}
|
||||||
Refresh() ;
|
else
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
Refresh() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Remove(long from, long to)
|
void wxTextCtrl::Remove(long from, long to)
|
||||||
@@ -2171,11 +2166,15 @@ void wxTextCtrl::Remove(long from, long to)
|
|||||||
|
|
||||||
ControlEditTextSelectionRec selection ;
|
ControlEditTextSelectionRec selection ;
|
||||||
|
|
||||||
selection.selStart = from ;
|
selection.selStart = from ;
|
||||||
selection.selEnd = to ;
|
selection.selEnd = to ;
|
||||||
::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
|
::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TEDelete( teH ) ;
|
TEDelete( teH ) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
}
|
}
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
@@ -2259,7 +2258,11 @@ void wxTextCtrl::Clear()
|
|||||||
|
|
||||||
::SetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ;
|
::SetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ;
|
||||||
}
|
}
|
||||||
Refresh() ;
|
else
|
||||||
|
{
|
||||||
|
mUPDoEditCommand( m_macControl , kmUPClear) ;
|
||||||
|
}
|
||||||
|
Refresh() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::IsModified() const
|
bool wxTextCtrl::IsModified() const
|
||||||
@@ -2342,19 +2345,16 @@ void wxTextCtrl::DiscardEdits()
|
|||||||
|
|
||||||
int wxTextCtrl::GetNumberOfLines() const
|
int wxTextCtrl::GetNumberOfLines() const
|
||||||
{
|
{
|
||||||
if ( m_windowStyle & wxTE_PASSWORD )
|
// TODO change this if possible to reflect real lines
|
||||||
{
|
wxString content = GetValue() ;
|
||||||
Size actualsize;
|
|
||||||
::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
|
int count = 1;
|
||||||
|
for (int i = 0; i < content.Length() ; i++)
|
||||||
int count = 1;
|
{
|
||||||
for (int i = 0; i < actualsize; i++)
|
if (content[i] == '\r') count++;
|
||||||
{
|
}
|
||||||
if (wxBuffer[i] == '\r') count++;
|
|
||||||
}
|
return count;
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxTextCtrl::XYToPosition(long x, long y) const
|
long wxTextCtrl::XYToPosition(long x, long y) const
|
||||||
@@ -2375,62 +2375,56 @@ void wxTextCtrl::ShowPosition(long pos)
|
|||||||
|
|
||||||
int wxTextCtrl::GetLineLength(long lineNo) const
|
int wxTextCtrl::GetLineLength(long lineNo) const
|
||||||
{
|
{
|
||||||
if ( m_windowStyle & wxTE_PASSWORD )
|
// TODO change this if possible to reflect real lines
|
||||||
{
|
wxString content = GetValue() ;
|
||||||
Size actualsize;
|
|
||||||
::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
|
// Find line first
|
||||||
|
int count = 0;
|
||||||
// Find line first
|
for (int i = 0; i < content.Length() ; i++)
|
||||||
int count = 0;
|
{
|
||||||
for (int i = 0; i < actualsize; i++)
|
if (count == lineNo)
|
||||||
{
|
{
|
||||||
if (count == lineNo)
|
// Count chars in line then
|
||||||
{
|
count = 0;
|
||||||
// Count chars in line then
|
for (int j = i; j < content.Length(); j++)
|
||||||
count = 0;
|
{
|
||||||
for (int j = i; j < actualsize; j++)
|
count++;
|
||||||
{
|
if (content[j] == '\r') return count;
|
||||||
count++;
|
}
|
||||||
if (wxBuffer[j] == '\r') return count;
|
|
||||||
}
|
return count;
|
||||||
|
}
|
||||||
return count;
|
if (content[i] == '\r') count++;
|
||||||
}
|
}
|
||||||
if (wxBuffer[i] == '\r') count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxTextCtrl::GetLineText(long lineNo) const
|
wxString wxTextCtrl::GetLineText(long lineNo) const
|
||||||
{
|
{
|
||||||
if ( m_windowStyle & wxTE_PASSWORD )
|
// TODO change this if possible to reflect real lines
|
||||||
{
|
wxString content = GetValue() ;
|
||||||
Size actualsize;
|
|
||||||
::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
|
// Find line first
|
||||||
|
int count = 0;
|
||||||
// Find line first
|
for (int i = 0; i < content.Length() ; i++)
|
||||||
int count = 0;
|
{
|
||||||
for (int i = 0; i < actualsize; i++)
|
if (count == lineNo)
|
||||||
{
|
{
|
||||||
if (count == lineNo)
|
// Add chars in line then
|
||||||
{
|
wxString tmp("");
|
||||||
// Add chars in line then
|
|
||||||
wxString tmp("");
|
for (int j = i; j < content.Length(); j++)
|
||||||
|
{
|
||||||
for (int j = i; j < actualsize; j++)
|
if (content[j] == '\r')
|
||||||
{
|
return tmp;
|
||||||
if (wxBuffer[j] == '\r')
|
|
||||||
return tmp;
|
tmp += content[j];
|
||||||
|
}
|
||||||
tmp += wxBuffer[j];
|
|
||||||
}
|
return tmp;
|
||||||
|
}
|
||||||
return tmp;
|
if (content[i] == '\r') count++;
|
||||||
}
|
}
|
||||||
if (wxBuffer[i] == '\r') count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return wxString("");
|
return wxString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2468,15 +2462,12 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
||||||
{
|
{
|
||||||
wxWindow *parent = GetParent();
|
wxWindow *parent = GetParent();
|
||||||
wxPanel *panel = wxDynamicCast(parent, wxPanel);
|
while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) {
|
||||||
while ( parent != NULL && panel == NULL )
|
parent = parent->GetParent() ;
|
||||||
{
|
|
||||||
parent = parent->GetParent() ;
|
|
||||||
panel = wxDynamicCast(parent, wxPanel);
|
|
||||||
}
|
}
|
||||||
if ( panel && panel->GetDefaultItem() )
|
if ( parent && parent->GetDefaultItem() )
|
||||||
{
|
{
|
||||||
wxButton *def = wxDynamicCast(panel->GetDefaultItem(),
|
wxButton *def = wxDynamicCast(parent->GetDefaultItem(),
|
||||||
wxButton);
|
wxButton);
|
||||||
if ( def && def->IsEnabled() )
|
if ( def && def->IsEnabled() )
|
||||||
{
|
{
|
||||||
|
@@ -103,11 +103,11 @@ wxControl::~wxControl()
|
|||||||
m_isBeingDeleted = TRUE;
|
m_isBeingDeleted = TRUE;
|
||||||
// If we delete an item, we should initialize the parent panel,
|
// If we delete an item, we should initialize the parent panel,
|
||||||
// because it could now be invalid.
|
// because it could now be invalid.
|
||||||
wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
|
wxWindow *parent = GetParent() ;
|
||||||
if ( panel )
|
if ( parent )
|
||||||
{
|
{
|
||||||
if (panel->GetDefaultItem() == (wxButton*) this)
|
if (parent->GetDefaultItem() == (wxButton*) this)
|
||||||
panel->SetDefaultItem(NULL);
|
parent->SetDefaultItem(NULL);
|
||||||
}
|
}
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
|
@@ -223,16 +223,10 @@ void wxTextCtrl::Copy()
|
|||||||
TEHandle teH ;
|
TEHandle teH ;
|
||||||
long size ;
|
long size ;
|
||||||
|
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TECopy( teH ) ;
|
TECopy( teH ) ;
|
||||||
#if TARGET_CARBON
|
ClearCurrentScrap();
|
||||||
OSStatus err ;
|
TEToScrap() ;
|
||||||
err = ClearCurrentScrap( );
|
|
||||||
#else
|
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,18 +237,12 @@ void wxTextCtrl::Cut()
|
|||||||
TEHandle teH ;
|
TEHandle teH ;
|
||||||
long size ;
|
long size ;
|
||||||
|
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TECut( teH ) ;
|
TECut( teH ) ;
|
||||||
#if TARGET_CARBON
|
ClearCurrentScrap();
|
||||||
OSStatus err ;
|
TEToScrap() ;
|
||||||
err = ClearCurrentScrap( );
|
// MacInvalidateControl() ;
|
||||||
#else
|
}
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
|
||||||
// MacInvalidateControl() ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Paste()
|
void wxTextCtrl::Paste()
|
||||||
@@ -683,15 +671,12 @@ void wxTextCtrl::OnChar(wxKeyEvent& key_event)
|
|||||||
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
||||||
{
|
{
|
||||||
wxWindow *parent = GetParent();
|
wxWindow *parent = GetParent();
|
||||||
wxPanel *panel = wxDynamicCast(parent, wxPanel);
|
while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) {
|
||||||
while ( parent != NULL && panel == NULL )
|
parent = parent->GetParent() ;
|
||||||
{
|
|
||||||
parent = parent->GetParent() ;
|
|
||||||
panel = wxDynamicCast(parent, wxPanel);
|
|
||||||
}
|
}
|
||||||
if ( panel && panel->GetDefaultItem() )
|
if ( parent && parent->GetDefaultItem() )
|
||||||
{
|
{
|
||||||
wxButton *def = wxDynamicCast(panel->GetDefaultItem(),
|
wxButton *def = wxDynamicCast(parent->GetDefaultItem(),
|
||||||
wxButton);
|
wxButton);
|
||||||
if ( def && def->IsEnabled() )
|
if ( def && def->IsEnabled() )
|
||||||
{
|
{
|
||||||
@@ -699,9 +684,9 @@ void wxTextCtrl::OnChar(wxKeyEvent& key_event)
|
|||||||
event.SetEventObject(def);
|
event.SetEventObject(def);
|
||||||
def->Command(event);
|
def->Command(event);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this will make wxWindows eat the ENTER key so that
|
// this will make wxWindows eat the ENTER key so that
|
||||||
// we actually prevent line wrapping in a single line
|
// we actually prevent line wrapping in a single line
|
||||||
// text control
|
// text control
|
||||||
@@ -805,19 +790,7 @@ void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#if !TARGET_CARBON
|
extern wxApp *wxTheApp ;
|
||||||
#define GetControlOwner( control ) (**control).contrlOwner
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//todo add access to global event record
|
|
||||||
|
|
||||||
EventRecord event ;
|
|
||||||
|
|
||||||
static EventRecord *GetCurrentEventRecord()
|
|
||||||
{
|
|
||||||
return &event ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// CS:We will replace the TextEdit by using the MultiLanguageTextEngine based on the following code written by apple
|
// CS:We will replace the TextEdit by using the MultiLanguageTextEngine based on the following code written by apple
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1025,7 +998,7 @@ ControlUserPaneFocusUPP gTPFocusProc = NULL;
|
|||||||
|
|
||||||
/* events handled by our focus advance override routine */
|
/* events handled by our focus advance override routine */
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventUnicodeForKeyEvent } };
|
static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } };
|
||||||
#define kMLTEEventCount (sizeof( gMLTEEvents ) / sizeof( EventTypeSpec ))
|
#define kMLTEEventCount (sizeof( gMLTEEvents ) / sizeof( EventTypeSpec ))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1366,40 +1339,40 @@ bail:
|
|||||||
|
|
||||||
|
|
||||||
/* mUPOpenControl initializes a user pane control so it will be drawn
|
/* mUPOpenControl initializes a user pane control so it will be drawn
|
||||||
and will behave as a scrolling text edit field inside of a window.
|
and will behave as a scrolling text edit field inside of a window.
|
||||||
This routine performs all of the initialization steps necessary,
|
This routine performs all of the initialization steps necessary,
|
||||||
except it does not create the user pane control itself. theControl
|
except it does not create the user pane control itself. theControl
|
||||||
should refer to a user pane control that you have either created
|
should refer to a user pane control that you have either created
|
||||||
yourself or extracted from a dialog's control heirarchy using
|
yourself or extracted from a dialog's control heirarchy using
|
||||||
the GetDialogItemAsControl routine. */
|
the GetDialogItemAsControl routine. */
|
||||||
OSStatus mUPOpenControl(ControlHandle theControl) {
|
OSStatus mUPOpenControl(ControlHandle theControl, bool multiline) {
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
WindowPtr theWindow;
|
WindowPtr theWindow;
|
||||||
STPTextPaneVars **tpvars, *varsp;
|
STPTextPaneVars **tpvars, *varsp;
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
RGBColor rgbWhite = {0xFFFF, 0xFFFF, 0xFFFF};
|
RGBColor rgbWhite = {0xFFFF, 0xFFFF, 0xFFFF};
|
||||||
TXNBackground tback;
|
TXNBackground tback;
|
||||||
|
|
||||||
/* set up our globals */
|
/* set up our globals */
|
||||||
if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(TPPaneDrawProc);
|
if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(TPPaneDrawProc);
|
||||||
if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(TPPaneHitTestProc);
|
if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(TPPaneHitTestProc);
|
||||||
if (gTPTrackProc == NULL) gTPTrackProc = NewControlUserPaneTrackingUPP(TPPaneTrackingProc);
|
if (gTPTrackProc == NULL) gTPTrackProc = NewControlUserPaneTrackingUPP(TPPaneTrackingProc);
|
||||||
if (gTPIdleProc == NULL) gTPIdleProc = NewControlUserPaneIdleUPP(TPPaneIdleProc);
|
if (gTPIdleProc == NULL) gTPIdleProc = NewControlUserPaneIdleUPP(TPPaneIdleProc);
|
||||||
if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(TPPaneKeyDownProc);
|
if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(TPPaneKeyDownProc);
|
||||||
if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(TPPaneActivateProc);
|
if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(TPPaneActivateProc);
|
||||||
if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(TPPaneFocusProc);
|
if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(TPPaneFocusProc);
|
||||||
|
|
||||||
/* allocate our private storage */
|
/* allocate our private storage */
|
||||||
tpvars = (STPTextPaneVars **) NewHandleClear(sizeof(STPTextPaneVars));
|
tpvars = (STPTextPaneVars **) NewHandleClear(sizeof(STPTextPaneVars));
|
||||||
SetControlReference(theControl, (long) tpvars);
|
SetControlReference(theControl, (long) tpvars);
|
||||||
HLock((Handle) tpvars);
|
HLock((Handle) tpvars);
|
||||||
varsp = *tpvars;
|
varsp = *tpvars;
|
||||||
/* set the initial settings for our private data */
|
/* set the initial settings for our private data */
|
||||||
varsp->fInFocus = false;
|
varsp->fInFocus = false;
|
||||||
varsp->fIsActive = true;
|
varsp->fIsActive = true;
|
||||||
varsp->fTEActive = false;
|
varsp->fTEActive = false;
|
||||||
varsp->fUserPaneRec = theControl;
|
varsp->fUserPaneRec = theControl;
|
||||||
theWindow = varsp->fOwner = GetControlOwner(theControl);
|
theWindow = varsp->fOwner = GetControlOwner(theControl);
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
varsp->fDrawingEnvironment = GetWindowPort(varsp->fOwner);
|
varsp->fDrawingEnvironment = GetWindowPort(varsp->fOwner);
|
||||||
#else
|
#else
|
||||||
@@ -1446,7 +1419,6 @@ OSStatus mUPOpenControl(ControlHandle theControl) {
|
|||||||
err = InstallWindowEventHandler( varsp->fOwner, varsp->handlerUPP,
|
err = InstallWindowEventHandler( varsp->fOwner, varsp->handlerUPP,
|
||||||
kMLTEEventCount, gMLTEEvents, tpvars, &varsp->handlerRef );
|
kMLTEEventCount, gMLTEEvents, tpvars, &varsp->handlerRef );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* unlock our storage */
|
/* unlock our storage */
|
||||||
HUnlock((Handle) tpvars);
|
HUnlock((Handle) tpvars);
|
||||||
/* perform final activations and setup for our text field. Here,
|
/* perform final activations and setup for our text field. Here,
|
||||||
@@ -1798,8 +1770,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( style & wxTE_PASSWORD )
|
if ( style & wxTE_PASSWORD )
|
||||||
{
|
{
|
||||||
m_macControl = ::NewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1,
|
m_macControl = ::NewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1,
|
||||||
kControlEditTextPasswordProc , (long) this ) ;
|
kControlEditTextPasswordProc , (long) this ) ;
|
||||||
}
|
}
|
||||||
@@ -1961,18 +1933,16 @@ void wxTextCtrl::Copy()
|
|||||||
TEHandle teH ;
|
TEHandle teH ;
|
||||||
long size ;
|
long size ;
|
||||||
|
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TECopy( teH ) ;
|
TECopy( teH ) ;
|
||||||
#if TARGET_CARBON
|
ClearCurrentScrap();
|
||||||
OSStatus err ;
|
TEToScrap() ;
|
||||||
err = ClearCurrentScrap( );
|
}
|
||||||
#else
|
else
|
||||||
OSErr err ;
|
{
|
||||||
err = ZeroScrap( );
|
mUPDoEditCommand( m_macControl , kmUPCopy ) ;
|
||||||
#endif
|
}
|
||||||
TEToScrap() ;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Cut()
|
void wxTextCtrl::Cut()
|
||||||
@@ -1984,19 +1954,17 @@ void wxTextCtrl::Cut()
|
|||||||
TEHandle teH ;
|
TEHandle teH ;
|
||||||
long size ;
|
long size ;
|
||||||
|
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TECut( teH ) ;
|
TECut( teH ) ;
|
||||||
#if TARGET_CARBON
|
ClearCurrentScrap();
|
||||||
OSStatus err ;
|
TEToScrap() ;
|
||||||
err = ClearCurrentScrap( );
|
// MacInvalidateControl() ;
|
||||||
#else
|
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
|
||||||
// MacInvalidateControl() ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mUPDoEditCommand( m_macControl , kmUPCut ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Paste()
|
void wxTextCtrl::Paste()
|
||||||
@@ -2008,45 +1976,49 @@ void wxTextCtrl::Paste()
|
|||||||
TEHandle teH ;
|
TEHandle teH ;
|
||||||
long size ;
|
long size ;
|
||||||
|
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TEFromScrap() ;
|
TEFromScrap() ;
|
||||||
TEPaste( teH ) ;
|
TEPaste( teH ) ;
|
||||||
WindowRef window = GetMacRootWindow() ;
|
WindowRef window = GetMacRootWindow() ;
|
||||||
if ( window )
|
if ( window )
|
||||||
{
|
{
|
||||||
wxWindow* win = wxFindWinFromMacWindow( window ) ;
|
wxWindow* win = wxFindWinFromMacWindow( window ) ;
|
||||||
if ( win )
|
if ( win )
|
||||||
{
|
{
|
||||||
wxMacDrawingHelper help( win ) ;
|
wxMacDrawingHelper help( win ) ;
|
||||||
// the mac control manager always assumes to have the origin at 0,0
|
// the mac control manager always assumes to have the origin at 0,0
|
||||||
SetOrigin( 0 , 0 ) ;
|
SetOrigin( 0 , 0 ) ;
|
||||||
|
|
||||||
bool hasTabBehind = false ;
|
bool hasTabBehind = false ;
|
||||||
wxWindow* parent = GetParent() ;
|
wxWindow* parent = GetParent() ;
|
||||||
while ( parent )
|
while ( parent )
|
||||||
{
|
{
|
||||||
if( parent->MacGetWindowData() )
|
if( parent->MacGetWindowData() )
|
||||||
{
|
{
|
||||||
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
|
if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
|
||||||
{
|
{
|
||||||
if ( ((wxControl*)parent)->GetMacControl() )
|
if ( ((wxControl*)parent)->GetMacControl() )
|
||||||
SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
|
SetUpControlBackground( ((wxControl*)parent)->GetMacControl() , -1 , true ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent = parent->GetParent() ;
|
parent = parent->GetParent() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
UMADrawControl( m_macControl ) ;
|
UMADrawControl( m_macControl ) ;
|
||||||
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
|
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
mUPDoEditCommand( m_macControl , kmUPPaste ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::CanCopy() const
|
bool wxTextCtrl::CanCopy() const
|
||||||
@@ -2140,6 +2112,25 @@ long wxTextCtrl::GetLastPosition() const
|
|||||||
// ::GetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ;
|
// ::GetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ;
|
||||||
return (**teH).teLength ;
|
return (**teH).teLength ;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
STPTextPaneVars** tpvars = (STPTextPaneVars **) GetControlReference(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 ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
||||||
@@ -2151,15 +2142,19 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
|||||||
|
|
||||||
ControlEditTextSelectionRec selection ;
|
ControlEditTextSelectionRec selection ;
|
||||||
|
|
||||||
selection.selStart = from ;
|
selection.selStart = from ;
|
||||||
selection.selEnd = to ;
|
selection.selEnd = to ;
|
||||||
::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
|
::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TESetSelect( from , to , teH ) ;
|
TESetSelect( from , to , teH ) ;
|
||||||
TEDelete( teH ) ;
|
TEDelete( teH ) ;
|
||||||
TEInsert( value , value.Length() , teH ) ;
|
TEInsert( value , value.Length() , teH ) ;
|
||||||
}
|
}
|
||||||
Refresh() ;
|
else
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
Refresh() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Remove(long from, long to)
|
void wxTextCtrl::Remove(long from, long to)
|
||||||
@@ -2171,11 +2166,15 @@ void wxTextCtrl::Remove(long from, long to)
|
|||||||
|
|
||||||
ControlEditTextSelectionRec selection ;
|
ControlEditTextSelectionRec selection ;
|
||||||
|
|
||||||
selection.selStart = from ;
|
selection.selStart = from ;
|
||||||
selection.selEnd = to ;
|
selection.selEnd = to ;
|
||||||
::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
|
::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
|
||||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||||
TEDelete( teH ) ;
|
TEDelete( teH ) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
}
|
}
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
@@ -2259,7 +2258,11 @@ void wxTextCtrl::Clear()
|
|||||||
|
|
||||||
::SetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ;
|
::SetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ;
|
||||||
}
|
}
|
||||||
Refresh() ;
|
else
|
||||||
|
{
|
||||||
|
mUPDoEditCommand( m_macControl , kmUPClear) ;
|
||||||
|
}
|
||||||
|
Refresh() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::IsModified() const
|
bool wxTextCtrl::IsModified() const
|
||||||
@@ -2342,19 +2345,16 @@ void wxTextCtrl::DiscardEdits()
|
|||||||
|
|
||||||
int wxTextCtrl::GetNumberOfLines() const
|
int wxTextCtrl::GetNumberOfLines() const
|
||||||
{
|
{
|
||||||
if ( m_windowStyle & wxTE_PASSWORD )
|
// TODO change this if possible to reflect real lines
|
||||||
{
|
wxString content = GetValue() ;
|
||||||
Size actualsize;
|
|
||||||
::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
|
int count = 1;
|
||||||
|
for (int i = 0; i < content.Length() ; i++)
|
||||||
int count = 1;
|
{
|
||||||
for (int i = 0; i < actualsize; i++)
|
if (content[i] == '\r') count++;
|
||||||
{
|
}
|
||||||
if (wxBuffer[i] == '\r') count++;
|
|
||||||
}
|
return count;
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxTextCtrl::XYToPosition(long x, long y) const
|
long wxTextCtrl::XYToPosition(long x, long y) const
|
||||||
@@ -2375,62 +2375,56 @@ void wxTextCtrl::ShowPosition(long pos)
|
|||||||
|
|
||||||
int wxTextCtrl::GetLineLength(long lineNo) const
|
int wxTextCtrl::GetLineLength(long lineNo) const
|
||||||
{
|
{
|
||||||
if ( m_windowStyle & wxTE_PASSWORD )
|
// TODO change this if possible to reflect real lines
|
||||||
{
|
wxString content = GetValue() ;
|
||||||
Size actualsize;
|
|
||||||
::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
|
// Find line first
|
||||||
|
int count = 0;
|
||||||
// Find line first
|
for (int i = 0; i < content.Length() ; i++)
|
||||||
int count = 0;
|
{
|
||||||
for (int i = 0; i < actualsize; i++)
|
if (count == lineNo)
|
||||||
{
|
{
|
||||||
if (count == lineNo)
|
// Count chars in line then
|
||||||
{
|
count = 0;
|
||||||
// Count chars in line then
|
for (int j = i; j < content.Length(); j++)
|
||||||
count = 0;
|
{
|
||||||
for (int j = i; j < actualsize; j++)
|
count++;
|
||||||
{
|
if (content[j] == '\r') return count;
|
||||||
count++;
|
}
|
||||||
if (wxBuffer[j] == '\r') return count;
|
|
||||||
}
|
return count;
|
||||||
|
}
|
||||||
return count;
|
if (content[i] == '\r') count++;
|
||||||
}
|
}
|
||||||
if (wxBuffer[i] == '\r') count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxTextCtrl::GetLineText(long lineNo) const
|
wxString wxTextCtrl::GetLineText(long lineNo) const
|
||||||
{
|
{
|
||||||
if ( m_windowStyle & wxTE_PASSWORD )
|
// TODO change this if possible to reflect real lines
|
||||||
{
|
wxString content = GetValue() ;
|
||||||
Size actualsize;
|
|
||||||
::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
|
// Find line first
|
||||||
|
int count = 0;
|
||||||
// Find line first
|
for (int i = 0; i < content.Length() ; i++)
|
||||||
int count = 0;
|
{
|
||||||
for (int i = 0; i < actualsize; i++)
|
if (count == lineNo)
|
||||||
{
|
{
|
||||||
if (count == lineNo)
|
// Add chars in line then
|
||||||
{
|
wxString tmp("");
|
||||||
// Add chars in line then
|
|
||||||
wxString tmp("");
|
for (int j = i; j < content.Length(); j++)
|
||||||
|
{
|
||||||
for (int j = i; j < actualsize; j++)
|
if (content[j] == '\r')
|
||||||
{
|
return tmp;
|
||||||
if (wxBuffer[j] == '\r')
|
|
||||||
return tmp;
|
tmp += content[j];
|
||||||
|
}
|
||||||
tmp += wxBuffer[j];
|
|
||||||
}
|
return tmp;
|
||||||
|
}
|
||||||
return tmp;
|
if (content[i] == '\r') count++;
|
||||||
}
|
}
|
||||||
if (wxBuffer[i] == '\r') count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return wxString("");
|
return wxString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2468,15 +2462,12 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
||||||
{
|
{
|
||||||
wxWindow *parent = GetParent();
|
wxWindow *parent = GetParent();
|
||||||
wxPanel *panel = wxDynamicCast(parent, wxPanel);
|
while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) {
|
||||||
while ( parent != NULL && panel == NULL )
|
parent = parent->GetParent() ;
|
||||||
{
|
|
||||||
parent = parent->GetParent() ;
|
|
||||||
panel = wxDynamicCast(parent, wxPanel);
|
|
||||||
}
|
}
|
||||||
if ( panel && panel->GetDefaultItem() )
|
if ( parent && parent->GetDefaultItem() )
|
||||||
{
|
{
|
||||||
wxButton *def = wxDynamicCast(panel->GetDefaultItem(),
|
wxButton *def = wxDynamicCast(parent->GetDefaultItem(),
|
||||||
wxButton);
|
wxButton);
|
||||||
if ( def && def->IsEnabled() )
|
if ( def && def->IsEnabled() )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user