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 )
|
||||||
{
|
{
|
||||||
|
@@ -225,13 +225,7 @@ void wxTextCtrl::Copy()
|
|||||||
|
|
||||||
::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 ;
|
|
||||||
err = ClearCurrentScrap( );
|
|
||||||
#else
|
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
TEToScrap() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,13 +239,7 @@ void wxTextCtrl::Cut()
|
|||||||
|
|
||||||
::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 ;
|
|
||||||
err = ClearCurrentScrap( );
|
|
||||||
#else
|
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
TEToScrap() ;
|
||||||
// MacInvalidateControl() ;
|
// MacInvalidateControl() ;
|
||||||
}
|
}
|
||||||
@@ -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() )
|
||||||
{
|
{
|
||||||
@@ -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
|
||||||
|
|
||||||
@@ -1372,7 +1345,7 @@ bail:
|
|||||||
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;
|
||||||
@@ -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,
|
||||||
@@ -1963,15 +1935,13 @@ void wxTextCtrl::Copy()
|
|||||||
|
|
||||||
::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 ;
|
|
||||||
err = ClearCurrentScrap( );
|
|
||||||
#else
|
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
TEToScrap() ;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mUPDoEditCommand( m_macControl , kmUPCopy ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1986,15 +1956,13 @@ void wxTextCtrl::Cut()
|
|||||||
|
|
||||||
::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 ;
|
|
||||||
err = ClearCurrentScrap( );
|
|
||||||
#else
|
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
TEToScrap() ;
|
||||||
// MacInvalidateControl() ;
|
// MacInvalidateControl() ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mUPDoEditCommand( m_macControl , kmUPCut ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2027,7 +1995,7 @@ void wxTextCtrl::Paste()
|
|||||||
{
|
{
|
||||||
if( parent->MacGetWindowData() )
|
if( parent->MacGetWindowData() )
|
||||||
{
|
{
|
||||||
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2042,10 +2010,14 @@ void wxTextCtrl::Paste()
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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)
|
||||||
@@ -2159,6 +2150,10 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
|||||||
TEDelete( teH ) ;
|
TEDelete( teH ) ;
|
||||||
TEInsert( value , value.Length() , teH ) ;
|
TEInsert( value , value.Length() , teH ) ;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2176,6 +2171,10 @@ void wxTextCtrl::Remove(long from, long 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() ;
|
||||||
}
|
}
|
||||||
@@ -2258,6 +2257,10 @@ 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) ) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mUPDoEditCommand( m_macControl , kmUPClear) ;
|
||||||
}
|
}
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
@@ -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;
|
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;
|
return count;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxTextCtrl::XYToPosition(long x, long y) const
|
long wxTextCtrl::XYToPosition(long x, long y) const
|
||||||
@@ -2375,61 +2375,55 @@ 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
|
// Find line first
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < actualsize; i++)
|
for (int i = 0; i < content.Length() ; i++)
|
||||||
{
|
{
|
||||||
if (count == lineNo)
|
if (count == lineNo)
|
||||||
{
|
{
|
||||||
// Count chars in line then
|
// Count chars in line then
|
||||||
count = 0;
|
count = 0;
|
||||||
for (int j = i; j < actualsize; j++)
|
for (int j = i; j < content.Length(); j++)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
if (wxBuffer[j] == '\r') return count;
|
if (content[j] == '\r') return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
if (wxBuffer[i] == '\r') count++;
|
if (content[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
|
// Find line first
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < actualsize; i++)
|
for (int i = 0; i < content.Length() ; i++)
|
||||||
{
|
{
|
||||||
if (count == lineNo)
|
if (count == lineNo)
|
||||||
{
|
{
|
||||||
// Add chars in line then
|
// Add chars in line then
|
||||||
wxString tmp("");
|
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;
|
return tmp;
|
||||||
|
|
||||||
tmp += wxBuffer[j];
|
tmp += content[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
if (wxBuffer[i] == '\r') count++;
|
if (content[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 )
|
||||||
{
|
{
|
||||||
|
@@ -225,13 +225,7 @@ void wxTextCtrl::Copy()
|
|||||||
|
|
||||||
::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 ;
|
|
||||||
err = ClearCurrentScrap( );
|
|
||||||
#else
|
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
TEToScrap() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,13 +239,7 @@ void wxTextCtrl::Cut()
|
|||||||
|
|
||||||
::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 ;
|
|
||||||
err = ClearCurrentScrap( );
|
|
||||||
#else
|
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
TEToScrap() ;
|
||||||
// MacInvalidateControl() ;
|
// MacInvalidateControl() ;
|
||||||
}
|
}
|
||||||
@@ -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() )
|
||||||
{
|
{
|
||||||
@@ -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
|
||||||
|
|
||||||
@@ -1372,7 +1345,7 @@ bail:
|
|||||||
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;
|
||||||
@@ -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,
|
||||||
@@ -1963,15 +1935,13 @@ void wxTextCtrl::Copy()
|
|||||||
|
|
||||||
::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 ;
|
|
||||||
err = ClearCurrentScrap( );
|
|
||||||
#else
|
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
TEToScrap() ;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mUPDoEditCommand( m_macControl , kmUPCopy ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1986,15 +1956,13 @@ void wxTextCtrl::Cut()
|
|||||||
|
|
||||||
::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 ;
|
|
||||||
err = ClearCurrentScrap( );
|
|
||||||
#else
|
|
||||||
OSErr err ;
|
|
||||||
err = ZeroScrap( );
|
|
||||||
#endif
|
|
||||||
TEToScrap() ;
|
TEToScrap() ;
|
||||||
// MacInvalidateControl() ;
|
// MacInvalidateControl() ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mUPDoEditCommand( m_macControl , kmUPCut ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2027,7 +1995,7 @@ void wxTextCtrl::Paste()
|
|||||||
{
|
{
|
||||||
if( parent->MacGetWindowData() )
|
if( parent->MacGetWindowData() )
|
||||||
{
|
{
|
||||||
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
::SetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2042,10 +2010,14 @@ void wxTextCtrl::Paste()
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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)
|
||||||
@@ -2159,6 +2150,10 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
|||||||
TEDelete( teH ) ;
|
TEDelete( teH ) ;
|
||||||
TEInsert( value , value.Length() , teH ) ;
|
TEInsert( value , value.Length() , teH ) ;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2176,6 +2171,10 @@ void wxTextCtrl::Remove(long from, long 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() ;
|
||||||
}
|
}
|
||||||
@@ -2258,6 +2257,10 @@ 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) ) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mUPDoEditCommand( m_macControl , kmUPClear) ;
|
||||||
}
|
}
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
@@ -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;
|
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;
|
return count;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxTextCtrl::XYToPosition(long x, long y) const
|
long wxTextCtrl::XYToPosition(long x, long y) const
|
||||||
@@ -2375,61 +2375,55 @@ 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
|
// Find line first
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < actualsize; i++)
|
for (int i = 0; i < content.Length() ; i++)
|
||||||
{
|
{
|
||||||
if (count == lineNo)
|
if (count == lineNo)
|
||||||
{
|
{
|
||||||
// Count chars in line then
|
// Count chars in line then
|
||||||
count = 0;
|
count = 0;
|
||||||
for (int j = i; j < actualsize; j++)
|
for (int j = i; j < content.Length(); j++)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
if (wxBuffer[j] == '\r') return count;
|
if (content[j] == '\r') return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
if (wxBuffer[i] == '\r') count++;
|
if (content[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
|
// Find line first
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < actualsize; i++)
|
for (int i = 0; i < content.Length() ; i++)
|
||||||
{
|
{
|
||||||
if (count == lineNo)
|
if (count == lineNo)
|
||||||
{
|
{
|
||||||
// Add chars in line then
|
// Add chars in line then
|
||||||
wxString tmp("");
|
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;
|
return tmp;
|
||||||
|
|
||||||
tmp += wxBuffer[j];
|
tmp += content[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
if (wxBuffer[i] == '\r') count++;
|
if (content[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