X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/69e15b78afa1f5052457456a8849e65ba3d1a0f4..08fc17448ab46b588435887cf6418565d40b5298:/src/gtk/textctrl.cpp diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index d300952a7f..b8bba6c69b 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -24,6 +24,13 @@ #include "gtk/gtk.h" #include "gdk/gdkkeysyms.h" +//----------------------------------------------------------------------------- +// idle system +//----------------------------------------------------------------------------- + +extern void wxapp_install_idle_handler(); +extern bool g_isIdle; + //----------------------------------------------------------------------------- // data //----------------------------------------------------------------------------- @@ -37,6 +44,8 @@ extern bool g_blockEventsOnDrag; static void gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) { + if (g_isIdle) wxapp_install_idle_handler(); + if (!win->m_hasVMT) return; win->SetModified(); @@ -54,9 +63,11 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) static void gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) { - if (!win->m_hasVMT) return; - + if (g_isIdle) wxapp_install_idle_handler(); + win->CalculateScrollbar(); + + if (!win->m_hasVMT) return; } //----------------------------------------------------------------------------- @@ -129,7 +140,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, m_vScrollbarVisible = FALSE; bool multi_line = (style & wxTE_MULTILINE) != 0; - if ( multi_line ) + if (multi_line) { /* a multi-line edit control: create a vertical scrollbar by default and horizontal if requested */ @@ -147,6 +158,9 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, (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) { @@ -158,11 +172,21 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, GTK_FILL, 0, 0); gtk_widget_show(hscrollbar); - } - - /* we create the vertical scrollbar on demand */ - m_vScrollbar = (GtkWidget*) NULL; +#if (GTK_MINOR_VERSION > 0) + /* don't wrap lines, otherwise we wouldn't need the scrollbar */ + 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 ); + + gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1, + GTK_FILL, + (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), + 0, 0); } else { @@ -183,15 +207,18 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, PostCreation(); if (multi_line) - { - gtk_widget_realize(m_text); gtk_widget_show(m_text); - } /* we want to be notified about text changes */ gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); + if (multi_line) + { + gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed", + (GtkSignalFunc) gtk_scrollbar_changed_callback, (gpointer) this ); + } + if (!value.IsEmpty()) { gint tmp = 0; @@ -232,12 +259,6 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, Show( TRUE ); - if (multi_line) - { - gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed", - (GtkSignalFunc) gtk_scrollbar_changed_callback, (gpointer) this ); - } - return TRUE; } @@ -260,18 +281,6 @@ void wxTextCtrl::CalculateScrollbar() { if (!m_vScrollbarVisible) { - if (!m_vScrollbar) - { - /* 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 ); - - gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1, - GTK_FILL, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), - 0, 0); - } - gtk_widget_show( m_vScrollbar ); m_vScrollbarVisible = TRUE; @@ -293,7 +302,7 @@ wxString wxTextCtrl::GetValue() const } else { - tmp = gtk_entry_get_text( GTK_ENTRY(m_text) ); + tmp = wxString(gtk_entry_get_text( GTK_ENTRY(m_text) ),*wxConv_current); } return tmp; } @@ -951,6 +960,8 @@ void wxTextCtrl::SetBackgroundColour( const wxColour &colour ) wxCHECK_RET( m_text != NULL, _T("invalid text ctrl") ); wxControl::SetBackgroundColour( colour ); + + if (!m_widget->window) return; wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); if (sysbg.Red() == colour.Red() && @@ -965,6 +976,7 @@ void wxTextCtrl::SetBackgroundColour( const wxColour &colour ) if (m_windowStyle & wxTE_MULTILINE) { GdkWindow *window = GTK_TEXT(m_text)->text_area; + if (!window) return; m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); gdk_window_set_background( window, m_backgroundColour.GetColor() ); gdk_window_clear( window );