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;
|
||||
// If we delete an item, we should initialize the parent panel,
|
||||
// because it could now be invalid.
|
||||
wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
|
||||
if ( panel )
|
||||
wxWindow *parent = GetParent() ;
|
||||
if ( parent )
|
||||
{
|
||||
if (panel->GetDefaultItem() == (wxButton*) this)
|
||||
panel->SetDefaultItem(NULL);
|
||||
if (parent->GetDefaultItem() == (wxButton*) this)
|
||||
parent->SetDefaultItem(NULL);
|
||||
}
|
||||
if ( m_macControl )
|
||||
{
|
||||
|
@@ -225,13 +225,7 @@ void wxTextCtrl::Copy()
|
||||
|
||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TECopy( teH ) ;
|
||||
#if TARGET_CARBON
|
||||
OSStatus err ;
|
||||
err = ClearCurrentScrap( );
|
||||
#else
|
||||
OSErr err ;
|
||||
err = ZeroScrap( );
|
||||
#endif
|
||||
ClearCurrentScrap();
|
||||
TEToScrap() ;
|
||||
}
|
||||
}
|
||||
@@ -245,13 +239,7 @@ void wxTextCtrl::Cut()
|
||||
|
||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TECut( teH ) ;
|
||||
#if TARGET_CARBON
|
||||
OSStatus err ;
|
||||
err = ClearCurrentScrap( );
|
||||
#else
|
||||
OSErr err ;
|
||||
err = ZeroScrap( );
|
||||
#endif
|
||||
ClearCurrentScrap();
|
||||
TEToScrap() ;
|
||||
// MacInvalidateControl() ;
|
||||
}
|
||||
@@ -683,15 +671,12 @@ void wxTextCtrl::OnChar(wxKeyEvent& key_event)
|
||||
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
||||
{
|
||||
wxWindow *parent = GetParent();
|
||||
wxPanel *panel = wxDynamicCast(parent, wxPanel);
|
||||
while ( parent != NULL && panel == NULL )
|
||||
{
|
||||
while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) {
|
||||
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);
|
||||
if ( def && def->IsEnabled() )
|
||||
{
|
||||
@@ -805,19 +790,7 @@ void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
|
||||
|
||||
#else
|
||||
|
||||
#if !TARGET_CARBON
|
||||
#define GetControlOwner( control ) (**control).contrlOwner
|
||||
#endif
|
||||
|
||||
//todo add access to global event record
|
||||
|
||||
EventRecord event ;
|
||||
|
||||
static EventRecord *GetCurrentEventRecord()
|
||||
{
|
||||
return &event ;
|
||||
}
|
||||
|
||||
extern wxApp *wxTheApp ;
|
||||
// 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 */
|
||||
#if TARGET_CARBON
|
||||
static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventUnicodeForKeyEvent } };
|
||||
static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } };
|
||||
#define kMLTEEventCount (sizeof( gMLTEEvents ) / sizeof( EventTypeSpec ))
|
||||
#endif
|
||||
|
||||
@@ -1372,7 +1345,7 @@ bail:
|
||||
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) {
|
||||
OSStatus mUPOpenControl(ControlHandle theControl, bool multiline) {
|
||||
Rect bounds;
|
||||
WindowPtr theWindow;
|
||||
STPTextPaneVars **tpvars, *varsp;
|
||||
@@ -1446,7 +1419,6 @@ OSStatus mUPOpenControl(ControlHandle theControl) {
|
||||
err = InstallWindowEventHandler( varsp->fOwner, varsp->handlerUPP,
|
||||
kMLTEEventCount, gMLTEEvents, tpvars, &varsp->handlerRef );
|
||||
#endif
|
||||
|
||||
/* unlock our storage */
|
||||
HUnlock((Handle) tpvars);
|
||||
/* perform final activations and setup for our text field. Here,
|
||||
@@ -1963,15 +1935,13 @@ void wxTextCtrl::Copy()
|
||||
|
||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TECopy( teH ) ;
|
||||
#if TARGET_CARBON
|
||||
OSStatus err ;
|
||||
err = ClearCurrentScrap( );
|
||||
#else
|
||||
OSErr err ;
|
||||
err = ZeroScrap( );
|
||||
#endif
|
||||
ClearCurrentScrap();
|
||||
TEToScrap() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
mUPDoEditCommand( m_macControl , kmUPCopy ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1986,15 +1956,13 @@ void wxTextCtrl::Cut()
|
||||
|
||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TECut( teH ) ;
|
||||
#if TARGET_CARBON
|
||||
OSStatus err ;
|
||||
err = ClearCurrentScrap( );
|
||||
#else
|
||||
OSErr err ;
|
||||
err = ZeroScrap( );
|
||||
#endif
|
||||
ClearCurrentScrap();
|
||||
TEToScrap() ;
|
||||
// MacInvalidateControl() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
mUPDoEditCommand( m_macControl , kmUPCut ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2027,7 +1995,7 @@ void wxTextCtrl::Paste()
|
||||
{
|
||||
if( parent->MacGetWindowData() )
|
||||
{
|
||||
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
@@ -2042,10 +2010,14 @@ void wxTextCtrl::Paste()
|
||||
}
|
||||
|
||||
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 ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2140,6 +2112,25 @@ long wxTextCtrl::GetLastPosition() const
|
||||
// ::GetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ;
|
||||
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)
|
||||
@@ -2159,6 +2150,10 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
||||
TEDelete( teH ) ;
|
||||
TEInsert( value , value.Length() , teH ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
Refresh() ;
|
||||
}
|
||||
|
||||
@@ -2176,6 +2171,10 @@ void wxTextCtrl::Remove(long from, long to)
|
||||
::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
|
||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TEDelete( teH ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
Refresh() ;
|
||||
}
|
||||
@@ -2258,6 +2257,10 @@ void wxTextCtrl::Clear()
|
||||
{
|
||||
|
||||
::SetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
mUPDoEditCommand( m_macControl , kmUPClear) ;
|
||||
}
|
||||
Refresh() ;
|
||||
}
|
||||
@@ -2342,19 +2345,16 @@ void wxTextCtrl::DiscardEdits()
|
||||
|
||||
int wxTextCtrl::GetNumberOfLines() const
|
||||
{
|
||||
if ( m_windowStyle & wxTE_PASSWORD )
|
||||
{
|
||||
Size actualsize;
|
||||
::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
|
||||
// TODO change this if possible to reflect real lines
|
||||
wxString content = GetValue() ;
|
||||
|
||||
int count = 1;
|
||||
for (int i = 0; i < actualsize; i++)
|
||||
for (int i = 0; i < content.Length() ; i++)
|
||||
{
|
||||
if (wxBuffer[i] == '\r') count++;
|
||||
if (content[i] == '\r') count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
long wxTextCtrl::XYToPosition(long x, long y) const
|
||||
@@ -2375,61 +2375,55 @@ void wxTextCtrl::ShowPosition(long pos)
|
||||
|
||||
int wxTextCtrl::GetLineLength(long lineNo) const
|
||||
{
|
||||
if ( m_windowStyle & wxTE_PASSWORD )
|
||||
{
|
||||
Size actualsize;
|
||||
::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
|
||||
// TODO change this if possible to reflect real lines
|
||||
wxString content = GetValue() ;
|
||||
|
||||
// Find line first
|
||||
int count = 0;
|
||||
for (int i = 0; i < actualsize; i++)
|
||||
for (int i = 0; i < content.Length() ; i++)
|
||||
{
|
||||
if (count == lineNo)
|
||||
{
|
||||
// Count chars in line then
|
||||
count = 0;
|
||||
for (int j = i; j < actualsize; j++)
|
||||
for (int j = i; j < content.Length(); j++)
|
||||
{
|
||||
count++;
|
||||
if (wxBuffer[j] == '\r') return count;
|
||||
if (content[j] == '\r') return count;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
if (wxBuffer[i] == '\r') count++;
|
||||
}
|
||||
if (content[i] == '\r') count++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
wxString wxTextCtrl::GetLineText(long lineNo) const
|
||||
{
|
||||
if ( m_windowStyle & wxTE_PASSWORD )
|
||||
{
|
||||
Size actualsize;
|
||||
::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
|
||||
// TODO change this if possible to reflect real lines
|
||||
wxString content = GetValue() ;
|
||||
|
||||
// Find line first
|
||||
int count = 0;
|
||||
for (int i = 0; i < actualsize; i++)
|
||||
for (int i = 0; i < content.Length() ; i++)
|
||||
{
|
||||
if (count == lineNo)
|
||||
{
|
||||
// Add chars in line then
|
||||
wxString tmp("");
|
||||
|
||||
for (int j = i; j < actualsize; j++)
|
||||
for (int j = i; j < content.Length(); j++)
|
||||
{
|
||||
if (wxBuffer[j] == '\r')
|
||||
if (content[j] == '\r')
|
||||
return tmp;
|
||||
|
||||
tmp += wxBuffer[j];
|
||||
tmp += content[j];
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
if (wxBuffer[i] == '\r') count++;
|
||||
}
|
||||
if (content[i] == '\r') count++;
|
||||
}
|
||||
return wxString("");
|
||||
}
|
||||
@@ -2468,15 +2462,12 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
||||
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
||||
{
|
||||
wxWindow *parent = GetParent();
|
||||
wxPanel *panel = wxDynamicCast(parent, wxPanel);
|
||||
while ( parent != NULL && panel == NULL )
|
||||
{
|
||||
while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) {
|
||||
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);
|
||||
if ( def && def->IsEnabled() )
|
||||
{
|
||||
|
@@ -103,11 +103,11 @@ wxControl::~wxControl()
|
||||
m_isBeingDeleted = TRUE;
|
||||
// If we delete an item, we should initialize the parent panel,
|
||||
// because it could now be invalid.
|
||||
wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
|
||||
if ( panel )
|
||||
wxWindow *parent = GetParent() ;
|
||||
if ( parent )
|
||||
{
|
||||
if (panel->GetDefaultItem() == (wxButton*) this)
|
||||
panel->SetDefaultItem(NULL);
|
||||
if (parent->GetDefaultItem() == (wxButton*) this)
|
||||
parent->SetDefaultItem(NULL);
|
||||
}
|
||||
if ( m_macControl )
|
||||
{
|
||||
|
@@ -225,13 +225,7 @@ void wxTextCtrl::Copy()
|
||||
|
||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TECopy( teH ) ;
|
||||
#if TARGET_CARBON
|
||||
OSStatus err ;
|
||||
err = ClearCurrentScrap( );
|
||||
#else
|
||||
OSErr err ;
|
||||
err = ZeroScrap( );
|
||||
#endif
|
||||
ClearCurrentScrap();
|
||||
TEToScrap() ;
|
||||
}
|
||||
}
|
||||
@@ -245,13 +239,7 @@ void wxTextCtrl::Cut()
|
||||
|
||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TECut( teH ) ;
|
||||
#if TARGET_CARBON
|
||||
OSStatus err ;
|
||||
err = ClearCurrentScrap( );
|
||||
#else
|
||||
OSErr err ;
|
||||
err = ZeroScrap( );
|
||||
#endif
|
||||
ClearCurrentScrap();
|
||||
TEToScrap() ;
|
||||
// MacInvalidateControl() ;
|
||||
}
|
||||
@@ -683,15 +671,12 @@ void wxTextCtrl::OnChar(wxKeyEvent& key_event)
|
||||
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
||||
{
|
||||
wxWindow *parent = GetParent();
|
||||
wxPanel *panel = wxDynamicCast(parent, wxPanel);
|
||||
while ( parent != NULL && panel == NULL )
|
||||
{
|
||||
while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) {
|
||||
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);
|
||||
if ( def && def->IsEnabled() )
|
||||
{
|
||||
@@ -805,19 +790,7 @@ void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
|
||||
|
||||
#else
|
||||
|
||||
#if !TARGET_CARBON
|
||||
#define GetControlOwner( control ) (**control).contrlOwner
|
||||
#endif
|
||||
|
||||
//todo add access to global event record
|
||||
|
||||
EventRecord event ;
|
||||
|
||||
static EventRecord *GetCurrentEventRecord()
|
||||
{
|
||||
return &event ;
|
||||
}
|
||||
|
||||
extern wxApp *wxTheApp ;
|
||||
// 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 */
|
||||
#if TARGET_CARBON
|
||||
static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventUnicodeForKeyEvent } };
|
||||
static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } };
|
||||
#define kMLTEEventCount (sizeof( gMLTEEvents ) / sizeof( EventTypeSpec ))
|
||||
#endif
|
||||
|
||||
@@ -1372,7 +1345,7 @@ bail:
|
||||
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) {
|
||||
OSStatus mUPOpenControl(ControlHandle theControl, bool multiline) {
|
||||
Rect bounds;
|
||||
WindowPtr theWindow;
|
||||
STPTextPaneVars **tpvars, *varsp;
|
||||
@@ -1446,7 +1419,6 @@ OSStatus mUPOpenControl(ControlHandle theControl) {
|
||||
err = InstallWindowEventHandler( varsp->fOwner, varsp->handlerUPP,
|
||||
kMLTEEventCount, gMLTEEvents, tpvars, &varsp->handlerRef );
|
||||
#endif
|
||||
|
||||
/* unlock our storage */
|
||||
HUnlock((Handle) tpvars);
|
||||
/* perform final activations and setup for our text field. Here,
|
||||
@@ -1963,15 +1935,13 @@ void wxTextCtrl::Copy()
|
||||
|
||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TECopy( teH ) ;
|
||||
#if TARGET_CARBON
|
||||
OSStatus err ;
|
||||
err = ClearCurrentScrap( );
|
||||
#else
|
||||
OSErr err ;
|
||||
err = ZeroScrap( );
|
||||
#endif
|
||||
ClearCurrentScrap();
|
||||
TEToScrap() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
mUPDoEditCommand( m_macControl , kmUPCopy ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1986,15 +1956,13 @@ void wxTextCtrl::Cut()
|
||||
|
||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TECut( teH ) ;
|
||||
#if TARGET_CARBON
|
||||
OSStatus err ;
|
||||
err = ClearCurrentScrap( );
|
||||
#else
|
||||
OSErr err ;
|
||||
err = ZeroScrap( );
|
||||
#endif
|
||||
ClearCurrentScrap();
|
||||
TEToScrap() ;
|
||||
// MacInvalidateControl() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
mUPDoEditCommand( m_macControl , kmUPCut ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2027,7 +1995,7 @@ void wxTextCtrl::Paste()
|
||||
{
|
||||
if( parent->MacGetWindowData() )
|
||||
{
|
||||
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
@@ -2042,10 +2010,14 @@ void wxTextCtrl::Paste()
|
||||
}
|
||||
|
||||
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 ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2140,6 +2112,25 @@ long wxTextCtrl::GetLastPosition() const
|
||||
// ::GetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ;
|
||||
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)
|
||||
@@ -2159,6 +2150,10 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
||||
TEDelete( teH ) ;
|
||||
TEInsert( value , value.Length() , teH ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
Refresh() ;
|
||||
}
|
||||
|
||||
@@ -2176,6 +2171,10 @@ void wxTextCtrl::Remove(long from, long to)
|
||||
::SetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
|
||||
::GetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
|
||||
TEDelete( teH ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
Refresh() ;
|
||||
}
|
||||
@@ -2258,6 +2257,10 @@ void wxTextCtrl::Clear()
|
||||
{
|
||||
|
||||
::SetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
mUPDoEditCommand( m_macControl , kmUPClear) ;
|
||||
}
|
||||
Refresh() ;
|
||||
}
|
||||
@@ -2342,19 +2345,16 @@ void wxTextCtrl::DiscardEdits()
|
||||
|
||||
int wxTextCtrl::GetNumberOfLines() const
|
||||
{
|
||||
if ( m_windowStyle & wxTE_PASSWORD )
|
||||
{
|
||||
Size actualsize;
|
||||
::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
|
||||
// TODO change this if possible to reflect real lines
|
||||
wxString content = GetValue() ;
|
||||
|
||||
int count = 1;
|
||||
for (int i = 0; i < actualsize; i++)
|
||||
for (int i = 0; i < content.Length() ; i++)
|
||||
{
|
||||
if (wxBuffer[i] == '\r') count++;
|
||||
if (content[i] == '\r') count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
long wxTextCtrl::XYToPosition(long x, long y) const
|
||||
@@ -2375,61 +2375,55 @@ void wxTextCtrl::ShowPosition(long pos)
|
||||
|
||||
int wxTextCtrl::GetLineLength(long lineNo) const
|
||||
{
|
||||
if ( m_windowStyle & wxTE_PASSWORD )
|
||||
{
|
||||
Size actualsize;
|
||||
::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
|
||||
// TODO change this if possible to reflect real lines
|
||||
wxString content = GetValue() ;
|
||||
|
||||
// Find line first
|
||||
int count = 0;
|
||||
for (int i = 0; i < actualsize; i++)
|
||||
for (int i = 0; i < content.Length() ; i++)
|
||||
{
|
||||
if (count == lineNo)
|
||||
{
|
||||
// Count chars in line then
|
||||
count = 0;
|
||||
for (int j = i; j < actualsize; j++)
|
||||
for (int j = i; j < content.Length(); j++)
|
||||
{
|
||||
count++;
|
||||
if (wxBuffer[j] == '\r') return count;
|
||||
if (content[j] == '\r') return count;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
if (wxBuffer[i] == '\r') count++;
|
||||
}
|
||||
if (content[i] == '\r') count++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
wxString wxTextCtrl::GetLineText(long lineNo) const
|
||||
{
|
||||
if ( m_windowStyle & wxTE_PASSWORD )
|
||||
{
|
||||
Size actualsize;
|
||||
::GetControlData( m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ;
|
||||
// TODO change this if possible to reflect real lines
|
||||
wxString content = GetValue() ;
|
||||
|
||||
// Find line first
|
||||
int count = 0;
|
||||
for (int i = 0; i < actualsize; i++)
|
||||
for (int i = 0; i < content.Length() ; i++)
|
||||
{
|
||||
if (count == lineNo)
|
||||
{
|
||||
// Add chars in line then
|
||||
wxString tmp("");
|
||||
|
||||
for (int j = i; j < actualsize; j++)
|
||||
for (int j = i; j < content.Length(); j++)
|
||||
{
|
||||
if (wxBuffer[j] == '\r')
|
||||
if (content[j] == '\r')
|
||||
return tmp;
|
||||
|
||||
tmp += wxBuffer[j];
|
||||
tmp += content[j];
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
if (wxBuffer[i] == '\r') count++;
|
||||
}
|
||||
if (content[i] == '\r') count++;
|
||||
}
|
||||
return wxString("");
|
||||
}
|
||||
@@ -2468,15 +2462,12 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
||||
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
||||
{
|
||||
wxWindow *parent = GetParent();
|
||||
wxPanel *panel = wxDynamicCast(parent, wxPanel);
|
||||
while ( parent != NULL && panel == NULL )
|
||||
{
|
||||
while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) {
|
||||
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);
|
||||
if ( def && def->IsEnabled() )
|
||||
{
|
||||
|
Reference in New Issue
Block a user