X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/db434467a143a2c847c4bcfe987f0202c2d02bf2..2bc6945a258b355f579d8533b7174f02ff8dc9e3:/src/gtk1/textctrl.cpp diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index ddd7432d18..4cef1e8168 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -98,6 +98,8 @@ END_EVENT_TABLE() wxTextCtrl::wxTextCtrl() { m_modified = FALSE; + m_text = + m_vScrollbar = (GtkWidget *)NULL; } wxTextCtrl::wxTextCtrl( wxWindow *parent, @@ -337,6 +339,13 @@ void wxTextCtrl::SetValue( const wxString &value ) { gtk_entry_set_text( GTK_ENTRY(m_text), tmp.mbc_str() ); } + + // GRG, Jun/2000: Changed this after a lot of discussion in + // the lists. wxWindows 2.2 will have a set of flags to + // customize this behaviour. + SetInsertionPoint(0); + + m_modified = FALSE; } void wxTextCtrl::WriteText( const wxString &text ) @@ -607,6 +616,26 @@ void wxTextCtrl::SetEditable( bool editable ) gtk_entry_set_editable( GTK_ENTRY(m_text), editable ); } +bool wxTextCtrl::Enable( bool enable ) +{ + if (!wxWindowBase::Enable(enable)) + { + // nothing to do + return FALSE; + } + + if (m_windowStyle & wxTE_MULTILINE) + { + gtk_text_set_editable( GTK_TEXT(m_text), enable ); + } + else + { + gtk_widget_set_sensitive( m_text, enable ); + } + + return TRUE; +} + void wxTextCtrl::DiscardEdits() { m_modified = FALSE; @@ -715,7 +744,7 @@ bool wxTextCtrl::CanCut() const // Can cut if there's a selection long from, to; GetSelection(& from, & to); - return (from != to) ; + return (from != to) && (IsEditable()); } bool wxTextCtrl::CanPaste() const @@ -758,8 +787,9 @@ void wxTextCtrl::GetSelection(long* from, long* to) const if (!(GTK_EDITABLE(m_text)->has_selection)) { - if (from) *from = 0; - if (to) *to = 0; + long i = GetInsertionPoint(); + if (from) *from = i; + if (to) *to = i; return; } @@ -792,6 +822,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) { wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); event.SetEventObject(this); + event.SetString(GetValue()); if (GetEventHandler()->ProcessEvent(event)) return; }