X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/17808a759627b03c2acbe7333dd2386557e1b804..f363cee882672e147340240cf0bb194a68e37833:/src/gtk1/textctrl.cpp diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index ea289a657e..0188681154 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -2,7 +2,6 @@ // Name: src/gtk1/textctrl.cpp // Purpose: // Author: Robert Roebling -// Id: $Id$ // Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -13,6 +12,7 @@ #include "wx/textctrl.h" #ifndef WX_PRECOMP + #include "wx/app.h" #include "wx/intl.h" #include "wx/log.h" #include "wx/utils.h" @@ -23,6 +23,7 @@ #include "wx/strconv.h" #include "wx/fontutil.h" // for wxNativeFontInfo (GetNativeFontInfo()) +#include "wx/evtloop.h" #include #include @@ -100,7 +101,7 @@ gtk_insert_text_callback(GtkEditable *editable, // we should only be called if we have a max len limit at all GtkEntry *entry = GTK_ENTRY (editable); - wxCHECK_RET( entry->text_max_length, _T("shouldn't be called") ); + wxCHECK_RET( entry->text_max_length, wxT("shouldn't be called") ); // check that we don't overflow the max length limit // @@ -112,11 +113,11 @@ gtk_insert_text_callback(GtkEditable *editable, gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text"); // remember that the next changed signal is to be ignored to avoid - // generating a dummy wxEVT_COMMAND_TEXT_UPDATED event + // generating a dummy wxEVT_TEXT event win->IgnoreNextTextUpdate(); // and generate the correct one ourselves - wxCommandEvent event(wxEVT_COMMAND_TEXT_MAXLEN, win->GetId()); + wxCommandEvent event(wxEVT_TEXT_MAXLEN, win->GetId()); event.SetEventObject(win); event.SetString(win->GetValue()); win->HandleWindowEvent( event ); @@ -143,7 +144,7 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) win->SetModified(); win->UpdateFontIfNeeded(); - wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() ); + wxCommandEvent event( wxEVT_TEXT, win->GetId() ); event.SetEventObject( win ); win->HandleWindowEvent( event ); } @@ -175,8 +176,6 @@ gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) // which implicitly calls wxYield()) so we override GtkText::draw() and simply // don't do anything if we're inside wxYield() -extern bool wxIsInsideYield; - extern "C" { typedef void (*GtkDrawCallback)(GtkWidget *widget, GdkRectangle *rect); } @@ -186,10 +185,11 @@ static GtkDrawCallback gs_gtk_text_draw = NULL; extern "C" { static void wxgtk_text_draw( GtkWidget *widget, GdkRectangle *rect) { - if ( !wxIsInsideYield ) + wxEventLoopBase* loop = wxEventLoopBase::GetActive(); + if ( loop && !loop->IsYielding() ) { wxCHECK_RET( gs_gtk_text_draw != wxgtk_text_draw, - _T("infinite recursion in wxgtk_text_draw aborted") ); + wxT("infinite recursion in wxgtk_text_draw aborted") ); gs_gtk_text_draw(widget, rect); } @@ -200,8 +200,6 @@ static void wxgtk_text_draw( GtkWidget *widget, GdkRectangle *rect) // wxTextCtrl //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase) - BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase) EVT_CHAR(wxTextCtrl::OnChar) @@ -224,7 +222,7 @@ void wxTextCtrl::Init() m_modified = false; SetUpdateFont(false); m_text = - m_vScrollbar = (GtkWidget *)NULL; + m_vScrollbar = NULL; } wxTextCtrl::~wxTextCtrl() @@ -272,7 +270,7 @@ bool wxTextCtrl::Create( wxWindow *parent, if (multi_line) { // create our control ... - m_text = gtk_text_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); + m_text = gtk_text_new( NULL, NULL ); // ... and put into the upper left hand corner of the table bool bHasHScrollbar = false; @@ -405,7 +403,7 @@ void wxTextCtrl::CalculateScrollbar() } } -wxString wxTextCtrl::GetValue() const +wxString wxTextCtrl::DoGetValue() const { wxCHECK_MSG( m_text != NULL, wxEmptyString, wxT("invalid text ctrl") ); @@ -715,29 +713,6 @@ void wxTextCtrl::DoEnable( bool enable ) } } -// wxGTK-specific: called recursively by Enable, -// to give widgets an oppprtunity to correct their colours after they -// have been changed by Enable -void wxTextCtrl::OnEnabled( bool WXUNUSED(enable) ) -{ - if ( IsSingleLine() ) - return; - - // If we have a custom background colour, we use this colour in both - // disabled and enabled mode, or we end up with a different colour under the - // text. - wxColour oldColour = GetBackgroundColour(); - if (oldColour.Ok()) - { - // Need to set twice or it'll optimize the useful stuff out - if (oldColour == * wxWHITE) - SetBackgroundColour(*wxBLACK); - else - SetBackgroundColour(*wxWHITE); - SetBackgroundColour(oldColour); - } -} - void wxTextCtrl::MarkDirty() { m_modified = true; @@ -817,7 +792,7 @@ void wxTextCtrl::SetSelection( long from, long to ) !GTK_TEXT(m_text)->line_start_cache ) { // tell the programmer that it didn't work - wxLogDebug(_T("Can't call SetSelection() before realizing the control")); + wxLogDebug(wxT("Can't call SetSelection() before realizing the control")); return; } @@ -996,7 +971,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) if ((key_event.GetKeyCode() == WXK_RETURN) && (m_windowStyle & wxTE_PROCESS_ENTER)) { - wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); + wxCommandEvent event(wxEVT_TEXT_ENTER, m_windowId); event.SetEventObject(this); event.SetString(GetValue()); if (HandleWindowEvent(event)) return; @@ -1072,7 +1047,7 @@ void wxTextCtrl::ChangeFontGlobally() // possible! wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE) && m_updateFont, - _T("shouldn't be called for single line controls") ); + wxT("shouldn't be called for single line controls") ); wxString value = GetValue(); if ( !value.empty() ) @@ -1111,7 +1086,7 @@ bool wxTextCtrl::SetBackgroundColour( const wxColour &colour ) if (!m_widget->window) return false; - if (!m_backgroundColour.Ok()) + if (!m_backgroundColour.IsOk()) return false; if (m_windowStyle & wxTE_MULTILINE) @@ -1146,7 +1121,7 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style ) gint l = gtk_text_get_length( GTK_TEXT(m_text) ); wxCHECK_MSG( start >= 0 && end <= l, false, - _T("invalid range in wxTextCtrl::SetStyle") ); + wxT("invalid range in wxTextCtrl::SetStyle") ); gint old_pos = gtk_editable_get_position( GTK_EDITABLE(m_text) ); char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), start, end ); @@ -1243,11 +1218,11 @@ void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event) void wxTextCtrl::OnInternalIdle() { wxCursor cursor = m_cursor; - if (g_globalCursor.Ok()) cursor = g_globalCursor; + if (g_globalCursor.IsOk()) cursor = g_globalCursor; - if (cursor.Ok()) + if (cursor.IsOk()) { - GdkWindow *window = (GdkWindow*) NULL; + GdkWindow *window = NULL; if (HasFlag(wxTE_MULTILINE)) window = GTK_TEXT(m_text)->text_area; else @@ -1256,7 +1231,7 @@ void wxTextCtrl::OnInternalIdle() if (window) gdk_window_set_cursor( window, cursor.GetCursor() ); - if (!g_globalCursor.Ok()) + if (!g_globalCursor.IsOk()) cursor = *wxSTANDARD_CURSOR; window = m_widget->window;