From bb69661b050ad2c774985e225cce0e497a875143 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 12 Jul 1999 14:02:01 +0000 Subject: [PATCH] 1. wxTextControl::SetFont() does something (good or bad - for you to judge) 2. tip dialog modified slightly to look a bit prettier under GTK 3. notebook test demonstrates the wxGTK radiobox-in-notebook-pages-constraints bug git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/notebook/test.cpp | 22 ++++---- samples/text/controls.cpp | 47 ++++++++--------- src/gtk/textctrl.cpp | 106 +++++++++++++++++++++++++------------- src/gtk1/textctrl.cpp | 106 +++++++++++++++++++++++++------------- 4 files changed, 177 insertions(+), 104 deletions(-) diff --git a/samples/notebook/test.cpp b/samples/notebook/test.cpp index e9d6088176..37306e8e3a 100644 --- a/samples/notebook/test.cpp +++ b/samples/notebook/test.cpp @@ -96,22 +96,26 @@ void MyApp::InitTabView(wxNotebook* notebook, wxWindow* window) panel2->SetBackgroundColour(wxColour("BLUE")); wxString animals[] = { "Fox", "Hare", "Rabbit", "Sabre-toothed tiger", "T Rex" }; - wxListBox *listbox = new wxListBox(panel2, -1, wxPoint(5, 5), wxSize(170, 80), 5, animals); + wxRadioBox *radiobox = new wxRadioBox(panel2, -1, "Choose one", + wxDefaultPosition, wxDefaultSize, 5, animals); c = new wxLayoutConstraints; c->left.SameAs(panel2, wxLeft, 4); c->top.SameAs(panel2, wxTop, 4); c->height.PercentOf(panel2, wxHeight, 50); c->right.SameAs(panel2, wxRight, 4); - listbox->SetConstraints(c); + radiobox->SetConstraints(c); - wxTextCtrl *text = new wxTextCtrl(panel2, -1, "Some notes about the animals in this house", wxPoint(5, 100), wxSize(170, 100), wxTE_MULTILINE); + wxRadioBox *radiobox2 = new wxRadioBox(panel2, -1, "Choose one", + wxDefaultPosition, wxDefaultSize, + 5, animals, + 2, wxRA_SPECIFY_ROWS); c = new wxLayoutConstraints; - c->left.SameAs(panel2, wxLeft, 4); - c->bottom.SameAs(panel2, wxBottom, 4); - c->top.Below(listbox, 4); - c->right.SameAs(panel2, wxRight, 4); - text->SetConstraints(c); + c->left.SameAs(radiobox, wxLeft); + c->height.AsIs(); + c->top.Below(radiobox, 4); + c->right.SameAs(radiobox, wxRight); + radiobox2->SetConstraints(c); notebook->AddPage(panel2, "Dog"); @@ -170,7 +174,7 @@ void MyDialog::Init(void) SetAutoLayout(TRUE); Layout(); - this->Centre(wxBOTH); + Centre(wxBOTH); } BEGIN_EVENT_TABLE(MyFrame, wxFrame) diff --git a/samples/text/controls.cpp b/samples/text/controls.cpp index b9e3bf4777..a27af06ebb 100644 --- a/samples/text/controls.cpp +++ b/samples/text/controls.cpp @@ -82,7 +82,7 @@ public: MyTextCtrl *m_tab; MyTextCtrl *m_entertab; MyTextCtrl *m_readonly; - + MyTextCtrl *m_multitext; MyTextCtrl *m_horizontal; MyTextCtrl *m_multitab; @@ -387,37 +387,38 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) // single line text controls - m_text = new MyTextCtrl( this, -1, "Single line.", + m_text = new MyTextCtrl( this, -1, "Single line.", wxPoint(10,10), wxSize(140,-1), 0); (*m_text) << " Appended."; m_text->SetInsertionPoint(0); m_text->WriteText( "Prepended. " ); - - m_password = new MyTextCtrl( this, -1, "", + + m_password = new MyTextCtrl( this, -1, "", wxPoint(10,50), wxSize(140,-1), wxTE_PASSWORD ); - - m_readonly = new MyTextCtrl( this, -1, "Read only", + + m_readonly = new MyTextCtrl( this, -1, "Read only", wxPoint(10,90), wxSize(140,-1), wxTE_READONLY ); - + // multi line text controls - m_horizontal = new MyTextCtrl( this, -1, "Multiline text control with a horizontal scrollbar.", - wxPoint(10,170), wxSize(140,70), wxTE_MULTILINE | wxHSCROLL ); - - m_multitext = new MyTextCtrl( this, ID_TEXT, "Multi line.", + m_horizontal = new MyTextCtrl( this, -1, "Multiline text control with a horizontal scrollbar.", + wxPoint(10,170), wxSize(140,70), wxTE_MULTILINE | wxHSCROLL ); + m_horizontal->SetFont(wxFont(18, wxSWISS, wxNORMAL, wxBOLD)); + + m_multitext = new MyTextCtrl( this, ID_TEXT, "Multi line.", wxPoint(180,10), wxSize(240,70), wxTE_MULTILINE ); (*m_multitext) << " Appended."; m_multitext->SetInsertionPoint(0); m_multitext->WriteText( "Prepended. " ); - + #if wxUSE_TOOLTIPS m_multitext->SetToolTip("Press F1 here."); #endif - m_tab = new MyTextCtrl( this, -1, "Multiline, allow processing.", + m_tab = new MyTextCtrl( this, -1, "Multiline, allow processing.", wxPoint(180,90), wxSize(240,70), wxTE_MULTILINE | wxTE_PROCESS_TAB ); - m_enter = new MyTextCtrl( this, -1, "Multiline, allow processing.", + m_enter = new MyTextCtrl( this, -1, "Multiline, allow processing.", wxPoint(180,170), wxSize(240,70), wxTE_MULTILINE | wxTE_PROCESS_ENTER ); wxButton *button; @@ -431,7 +432,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) #if wxUSE_TOOLTIPS button->SetToolTip("Move cursor in multi-line text control to end of first line."); #endif - + (void)new wxStaticBox( this, -1, "wx&Clipboard", wxPoint(445,130), wxSize(160,100) ); button = new wxButton( this, ID_COPY_TEXT, "C&opy line 1", wxPoint(470,150), wxSize(110,30) ); #if wxUSE_TOOLTIPS @@ -581,11 +582,11 @@ void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) wxBeginBusyCursor(); wxMessageDialog dialog(this, "This is a text control sample. It demonstrates the many different text control\n" - "styles, the use of the clipboard, setting and handling tooltips and intercepting\n" - "key and char events.\n" - "\n" - "Copyright (c) 1999, Robert Roebling, Julian Smart, Vadim Zeitlin", - "About Text Controls", wxOK ); + "styles, the use of the clipboard, setting and handling tooltips and intercepting\n" + "key and char events.\n" + "\n" + "Copyright (c) 1999, Robert Roebling, Julian Smart, Vadim Zeitlin", + "About Text Controls", wxOK ); dialog.ShowModal(); wxEndBusyCursor(); @@ -600,9 +601,9 @@ void MyFrame::OnSetTooltipDelay(wxCommandEvent& event) delay.Printf( _T("%ld"), s_delay); delay = wxGetTextFromUser("Enter delay (in milliseconds)", - "Set tooltip delay", - delay, - this); + "Set tooltip delay", + delay, + this); if ( !delay ) return; // cancelled diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 7e283a82d9..3d426e1668 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -46,7 +46,7 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) { if (!win->m_hasVMT) return; - if (g_isIdle) + if (g_isIdle) wxapp_install_idle_handler(); win->SetModified(); @@ -65,8 +65,8 @@ static void gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) { if (!win->m_hasVMT) return; - - if (g_isIdle) + + if (g_isIdle) wxapp_install_idle_handler(); win->CalculateScrollbar(); @@ -160,10 +160,10 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK), 0, 0); - + /* always wrap words */ gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE ); - + /* put the horizontal scrollbar in the lower left hand corner */ if (bHasHScrollbar) { @@ -180,7 +180,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, gtk_text_set_line_wrap( GTK_TEXT(m_text), FALSE ); #endif } - + /* finally, put the vertical scrollbar in the upper right corner */ m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj ); GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS ); @@ -317,7 +317,7 @@ void wxTextCtrl::SetValue( const wxString &value ) gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + wxString tmp = _T(""); if (!value.IsNull()) tmp = value; if (m_windowStyle & wxTE_MULTILINE) @@ -336,7 +336,7 @@ void wxTextCtrl::SetValue( const wxString &value ) { gtk_entry_set_text( GTK_ENTRY(m_text), tmp.mbc_str() ); } - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -349,7 +349,7 @@ void wxTextCtrl::WriteText( const wxString &text ) gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + if (m_windowStyle & wxTE_MULTILINE) { /* this moves the cursor pos to behind the inserted text */ @@ -382,7 +382,7 @@ void wxTextCtrl::WriteText( const wxString &text ) /* bring entry's cursor uptodate. bug in GTK. */ gtk_entry_set_position( GTK_ENTRY(m_text), GTK_EDITABLE(m_text)->current_pos ); } - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -395,17 +395,32 @@ void wxTextCtrl::AppendText( const wxString &text ) gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + if (m_windowStyle & wxTE_MULTILINE) { - /* we'll insert at the last position */ - gint len = gtk_text_get_length( GTK_TEXT(m_text) ); + bool hasSpecialAttributes = m_font.Ok() || + m_foregroundColour.Ok() || + m_backgroundColour.Ok(); + if ( hasSpecialAttributes ) + { + gtk_text_insert( GTK_TEXT(m_text), + m_font.GetInternalFont(), + m_foregroundColour.GetColor(), + m_backgroundColour.GetColor(), + text, text.length()); + + } + else + { + /* we'll insert at the last position */ + gint len = gtk_text_get_length( GTK_TEXT(m_text) ); #if wxUSE_UNICODE - wxWX2MBbuf buf = text.mbc_str(); - gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &len ); + wxWX2MBbuf buf = text.mbc_str(); + gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &len ); #else - gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len ); + gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len ); #endif + } /* bring editable's cursor uptodate. bug in GTK. */ GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) ); @@ -414,7 +429,7 @@ void wxTextCtrl::AppendText( const wxString &text ) { gtk_entry_append_text( GTK_ENTRY(m_text), text.mbc_str() ); } - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -453,7 +468,7 @@ bool wxTextCtrl::LoadFile( const wxString &file ) gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + if (m_windowStyle & wxTE_MULTILINE) { gint pos = 0; @@ -463,10 +478,10 @@ bool wxTextCtrl::LoadFile( const wxString &file ) { gtk_entry_set_text( GTK_ENTRY(m_text), text ); } - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + free (text); m_modified = FALSE; return TRUE; @@ -746,9 +761,9 @@ void wxTextCtrl::Remove( long from, long to ) gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to ); - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -759,9 +774,9 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value ) gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to ); - + if (!value.IsEmpty()) { gint pos = (gint)from; @@ -772,7 +787,7 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value ) gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos ); #endif } - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -783,13 +798,13 @@ void wxTextCtrl::Cut() gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + #if (GTK_MINOR_VERSION > 0) gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) ); #else gtk_editable_cut_clipboard( GTK_EDITABLE(m_text), 0 ); #endif - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -811,13 +826,13 @@ void wxTextCtrl::Paste() gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + #if (GTK_MINOR_VERSION > 0) gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) ); #else gtk_editable_paste_clipboard( GTK_EDITABLE(m_text), 0 ); #endif - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -875,14 +890,14 @@ bool wxTextCtrl::CanRedo() const void wxTextCtrl::GetSelection(long* from, long* to) const { wxCHECK_RET( m_text != NULL, _T("invalid text ctrl") ); - + if (!(GTK_EDITABLE(m_text)->has_selection)) { if (from) *from = 0; - if (to) *to = 0; - return; + if (to) *to = 0; + return; } - + if (from) *from = (long) GTK_EDITABLE(m_text)->selection_start_pos; if (to) *to = (long) GTK_EDITABLE(m_text)->selection_end_pos; } @@ -1005,12 +1020,31 @@ bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) return (window == GTK_ENTRY(m_text)->text_area); } -bool wxTextCtrl::SetFont( const wxFont &WXUNUSED(font) ) +// the font will change for subsequent text insertiongs +bool wxTextCtrl::SetFont( const wxFont &font ) { wxCHECK_MSG( m_text != NULL, FALSE, _T("invalid text ctrl") ); - // doesn't work - return FALSE; + if ( !wxWindowBase::SetFont(font) ) + { + // font didn't change, nothing to do + return FALSE; + } + + if ( m_windowStyle & wxTE_MULTILINE ) + { + // for compatibility with other ports: the font is a global controls + // characteristic, so change the font globally + wxString value = GetValue(); + if ( !value.IsEmpty() ) + { + Clear(); + + AppendText(value); + } + } + + return TRUE; } bool wxTextCtrl::SetForegroundColour( const wxColour &WXUNUSED(colour) ) diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index 7e283a82d9..3d426e1668 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -46,7 +46,7 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) { if (!win->m_hasVMT) return; - if (g_isIdle) + if (g_isIdle) wxapp_install_idle_handler(); win->SetModified(); @@ -65,8 +65,8 @@ static void gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) { if (!win->m_hasVMT) return; - - if (g_isIdle) + + if (g_isIdle) wxapp_install_idle_handler(); win->CalculateScrollbar(); @@ -160,10 +160,10 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK), 0, 0); - + /* always wrap words */ gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE ); - + /* put the horizontal scrollbar in the lower left hand corner */ if (bHasHScrollbar) { @@ -180,7 +180,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, gtk_text_set_line_wrap( GTK_TEXT(m_text), FALSE ); #endif } - + /* finally, put the vertical scrollbar in the upper right corner */ m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj ); GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS ); @@ -317,7 +317,7 @@ void wxTextCtrl::SetValue( const wxString &value ) gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + wxString tmp = _T(""); if (!value.IsNull()) tmp = value; if (m_windowStyle & wxTE_MULTILINE) @@ -336,7 +336,7 @@ void wxTextCtrl::SetValue( const wxString &value ) { gtk_entry_set_text( GTK_ENTRY(m_text), tmp.mbc_str() ); } - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -349,7 +349,7 @@ void wxTextCtrl::WriteText( const wxString &text ) gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + if (m_windowStyle & wxTE_MULTILINE) { /* this moves the cursor pos to behind the inserted text */ @@ -382,7 +382,7 @@ void wxTextCtrl::WriteText( const wxString &text ) /* bring entry's cursor uptodate. bug in GTK. */ gtk_entry_set_position( GTK_ENTRY(m_text), GTK_EDITABLE(m_text)->current_pos ); } - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -395,17 +395,32 @@ void wxTextCtrl::AppendText( const wxString &text ) gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + if (m_windowStyle & wxTE_MULTILINE) { - /* we'll insert at the last position */ - gint len = gtk_text_get_length( GTK_TEXT(m_text) ); + bool hasSpecialAttributes = m_font.Ok() || + m_foregroundColour.Ok() || + m_backgroundColour.Ok(); + if ( hasSpecialAttributes ) + { + gtk_text_insert( GTK_TEXT(m_text), + m_font.GetInternalFont(), + m_foregroundColour.GetColor(), + m_backgroundColour.GetColor(), + text, text.length()); + + } + else + { + /* we'll insert at the last position */ + gint len = gtk_text_get_length( GTK_TEXT(m_text) ); #if wxUSE_UNICODE - wxWX2MBbuf buf = text.mbc_str(); - gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &len ); + wxWX2MBbuf buf = text.mbc_str(); + gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &len ); #else - gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len ); + gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len ); #endif + } /* bring editable's cursor uptodate. bug in GTK. */ GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) ); @@ -414,7 +429,7 @@ void wxTextCtrl::AppendText( const wxString &text ) { gtk_entry_append_text( GTK_ENTRY(m_text), text.mbc_str() ); } - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -453,7 +468,7 @@ bool wxTextCtrl::LoadFile( const wxString &file ) gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + if (m_windowStyle & wxTE_MULTILINE) { gint pos = 0; @@ -463,10 +478,10 @@ bool wxTextCtrl::LoadFile( const wxString &file ) { gtk_entry_set_text( GTK_ENTRY(m_text), text ); } - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + free (text); m_modified = FALSE; return TRUE; @@ -746,9 +761,9 @@ void wxTextCtrl::Remove( long from, long to ) gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to ); - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -759,9 +774,9 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value ) gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to ); - + if (!value.IsEmpty()) { gint pos = (gint)from; @@ -772,7 +787,7 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value ) gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos ); #endif } - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -783,13 +798,13 @@ void wxTextCtrl::Cut() gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + #if (GTK_MINOR_VERSION > 0) gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) ); #else gtk_editable_cut_clipboard( GTK_EDITABLE(m_text), 0 ); #endif - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -811,13 +826,13 @@ void wxTextCtrl::Paste() gtk_signal_disconnect_by_func( GTK_OBJECT(m_text), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - + #if (GTK_MINOR_VERSION > 0) gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) ); #else gtk_editable_paste_clipboard( GTK_EDITABLE(m_text), 0 ); #endif - + gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); } @@ -875,14 +890,14 @@ bool wxTextCtrl::CanRedo() const void wxTextCtrl::GetSelection(long* from, long* to) const { wxCHECK_RET( m_text != NULL, _T("invalid text ctrl") ); - + if (!(GTK_EDITABLE(m_text)->has_selection)) { if (from) *from = 0; - if (to) *to = 0; - return; + if (to) *to = 0; + return; } - + if (from) *from = (long) GTK_EDITABLE(m_text)->selection_start_pos; if (to) *to = (long) GTK_EDITABLE(m_text)->selection_end_pos; } @@ -1005,12 +1020,31 @@ bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) return (window == GTK_ENTRY(m_text)->text_area); } -bool wxTextCtrl::SetFont( const wxFont &WXUNUSED(font) ) +// the font will change for subsequent text insertiongs +bool wxTextCtrl::SetFont( const wxFont &font ) { wxCHECK_MSG( m_text != NULL, FALSE, _T("invalid text ctrl") ); - // doesn't work - return FALSE; + if ( !wxWindowBase::SetFont(font) ) + { + // font didn't change, nothing to do + return FALSE; + } + + if ( m_windowStyle & wxTE_MULTILINE ) + { + // for compatibility with other ports: the font is a global controls + // characteristic, so change the font globally + wxString value = GetValue(); + if ( !value.IsEmpty() ) + { + Clear(); + + AppendText(value); + } + } + + return TRUE; } bool wxTextCtrl::SetForegroundColour( const wxColour &WXUNUSED(colour) ) -- 2.45.2