adapting TextUpdateEvents, using wxTextEntry API
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60154 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -158,6 +158,8 @@ protected:
|
|||||||
|
|
||||||
virtual void SetClientDataType(wxClientDataType clientDataItemsType);
|
virtual void SetClientDataType(wxClientDataType clientDataItemsType);
|
||||||
|
|
||||||
|
virtual void EnableTextChangedEvents(bool enable);
|
||||||
|
|
||||||
// the subcontrols
|
// the subcontrols
|
||||||
wxComboBoxText* m_text;
|
wxComboBoxText* m_text;
|
||||||
wxComboBoxChoice* m_choice;
|
wxComboBoxChoice* m_choice;
|
||||||
|
@@ -79,7 +79,6 @@ public:
|
|||||||
|
|
||||||
// editing
|
// editing
|
||||||
virtual void Clear();
|
virtual void Clear();
|
||||||
virtual void Replace(long from, long to, const wxString& value);
|
|
||||||
virtual void Remove(long from, long to);
|
virtual void Remove(long from, long to);
|
||||||
|
|
||||||
// sets/clears the dirty flag
|
// sets/clears the dirty flag
|
||||||
@@ -100,7 +99,6 @@ public:
|
|||||||
// writing text inserts it at the current position;
|
// writing text inserts it at the current position;
|
||||||
// appending always inserts it at the end
|
// appending always inserts it at the end
|
||||||
virtual void WriteText(const wxString& text);
|
virtual void WriteText(const wxString& text);
|
||||||
virtual void AppendText(const wxString& text);
|
|
||||||
|
|
||||||
// translate between the position (which is just an index into the textctrl
|
// translate between the position (which is just an index into the textctrl
|
||||||
// considering all its contents as a single strings) and (x, y) coordinates
|
// considering all its contents as a single strings) and (x, y) coordinates
|
||||||
@@ -176,7 +174,6 @@ protected:
|
|||||||
|
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
virtual void DoSetValue(const wxString& value, int flags = 0);
|
|
||||||
virtual wxString DoGetValue() const;
|
virtual wxString DoGetValue() const;
|
||||||
|
|
||||||
bool m_editable;
|
bool m_editable;
|
||||||
@@ -187,17 +184,12 @@ protected:
|
|||||||
// need to make this public because of the current implementation via callbacks
|
// need to make this public because of the current implementation via callbacks
|
||||||
unsigned long m_maxLength;
|
unsigned long m_maxLength;
|
||||||
|
|
||||||
bool GetTriggerOnSetValue() const
|
virtual void EnableTextChangedEvents(bool enable)
|
||||||
{
|
{
|
||||||
return m_triggerOnSetValue;
|
m_triggerUpdateEvents = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetTriggerOnSetValue(bool trigger)
|
bool m_triggerUpdateEvents ;
|
||||||
{
|
|
||||||
m_triggerOnSetValue = trigger;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool m_triggerOnSetValue ;
|
|
||||||
|
|
||||||
private :
|
private :
|
||||||
wxMenu *m_privateContextMenu;
|
wxMenu *m_privateContextMenu;
|
||||||
|
@@ -57,9 +57,12 @@ public:
|
|||||||
: wxTextCtrl( cb , 1 )
|
: wxTextCtrl( cb , 1 )
|
||||||
{
|
{
|
||||||
m_cb = cb;
|
m_cb = cb;
|
||||||
SetTriggerOnSetValue( false );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ForwardEnableTextChangedEvents(bool enable)
|
||||||
|
{
|
||||||
|
EnableTextChangedEvents(enable);
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
void OnChar( wxKeyEvent& event )
|
void OnChar( wxKeyEvent& event )
|
||||||
{
|
{
|
||||||
@@ -147,6 +150,7 @@ protected:
|
|||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxComboBox *m_cb;
|
wxComboBox *m_cb;
|
||||||
|
|
||||||
@@ -394,6 +398,12 @@ bool wxComboBox::Create(wxWindow *parent,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxComboBox::EnableTextChangedEvents(bool enable)
|
||||||
|
{
|
||||||
|
if ( m_text )
|
||||||
|
m_text->ForwardEnableTextChangedEvents(enable);
|
||||||
|
}
|
||||||
|
|
||||||
wxString wxComboBox::DoGetValue() const
|
wxString wxComboBox::DoGetValue() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_text, wxString(), "can't be called for read-only combobox" );
|
wxCHECK_MSG( m_text, wxString(), "can't be called for read-only combobox" );
|
||||||
|
@@ -80,7 +80,7 @@ void wxTextCtrl::Init()
|
|||||||
|
|
||||||
m_maxLength = 0;
|
m_maxLength = 0;
|
||||||
m_privateContextMenu = NULL;
|
m_privateContextMenu = NULL;
|
||||||
m_triggerOnSetValue = true ;
|
m_triggerUpdateEvents = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxTextCtrl::~wxTextCtrl()
|
wxTextCtrl::~wxTextCtrl()
|
||||||
@@ -167,20 +167,6 @@ void wxTextCtrl::GetSelection(long* from, long* to) const
|
|||||||
GetTextPeer()->GetSelection( from , to ) ;
|
GetTextPeer()->GetSelection( from , to ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::DoSetValue(const wxString& str, int flags)
|
|
||||||
{
|
|
||||||
// optimize redraws
|
|
||||||
if ( GetValue() == str )
|
|
||||||
return;
|
|
||||||
|
|
||||||
GetTextPeer()->SetStringValue( str ) ;
|
|
||||||
|
|
||||||
if ( (flags & SetValue_SendEvent) && m_triggerOnSetValue )
|
|
||||||
{
|
|
||||||
SendTextUpdatedEvent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxTextCtrl::SetMaxLength(unsigned long len)
|
void wxTextCtrl::SetMaxLength(unsigned long len)
|
||||||
{
|
{
|
||||||
m_maxLength = len ;
|
m_maxLength = len ;
|
||||||
@@ -225,9 +211,7 @@ void wxTextCtrl::Cut()
|
|||||||
{
|
{
|
||||||
GetTextPeer()->Cut() ;
|
GetTextPeer()->Cut() ;
|
||||||
|
|
||||||
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
|
SendTextUpdatedEvent();
|
||||||
event.SetEventObject( this );
|
|
||||||
HandleWindowEvent( event );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,10 +222,7 @@ void wxTextCtrl::Paste()
|
|||||||
GetTextPeer()->Paste() ;
|
GetTextPeer()->Paste() ;
|
||||||
|
|
||||||
// TODO: eventually we should add setting the default style again
|
// TODO: eventually we should add setting the default style again
|
||||||
|
SendTextUpdatedEvent();
|
||||||
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
|
|
||||||
event.SetEventObject( this );
|
|
||||||
HandleWindowEvent( event );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,14 +288,11 @@ wxTextPos wxTextCtrl::GetLastPosition() const
|
|||||||
return GetTextPeer()->GetLastPosition() ;
|
return GetTextPeer()->GetLastPosition() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Replace(long from, long to, const wxString& str)
|
|
||||||
{
|
|
||||||
GetTextPeer()->Replace( from , to , str ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxTextCtrl::Remove(long from, long to)
|
void wxTextCtrl::Remove(long from, long to)
|
||||||
{
|
{
|
||||||
GetTextPeer()->Remove( from , to ) ;
|
GetTextPeer()->Remove( from , to ) ;
|
||||||
|
if ( m_triggerUpdateEvents )
|
||||||
|
SendTextUpdatedEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::SetSelection(long from, long to)
|
void wxTextCtrl::SetSelection(long from, long to)
|
||||||
@@ -325,17 +303,14 @@ void wxTextCtrl::SetSelection(long from, long to)
|
|||||||
void wxTextCtrl::WriteText(const wxString& str)
|
void wxTextCtrl::WriteText(const wxString& str)
|
||||||
{
|
{
|
||||||
GetTextPeer()->WriteText( str ) ;
|
GetTextPeer()->WriteText( str ) ;
|
||||||
}
|
if ( m_triggerUpdateEvents )
|
||||||
|
SendTextUpdatedEvent();
|
||||||
void wxTextCtrl::AppendText(const wxString& text)
|
|
||||||
{
|
|
||||||
SetInsertionPointEnd();
|
|
||||||
WriteText( text );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Clear()
|
void wxTextCtrl::Clear()
|
||||||
{
|
{
|
||||||
GetTextPeer()->Clear() ;
|
GetTextPeer()->Clear() ;
|
||||||
|
SendTextUpdatedEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::IsModified() const
|
bool wxTextCtrl::IsModified() const
|
||||||
|
Reference in New Issue
Block a user