X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f68586e51b20dccee3fd5645aeaca7cc8ff298c2..4ee1741f75d443ac816cd90d5d0941d33fdd0698:/src/gtk1/textctrl.cpp diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index 3fc3e5386c..ddd7432d18 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -100,17 +100,27 @@ wxTextCtrl::wxTextCtrl() m_modified = FALSE; } -wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value, - const wxPoint &pos, const wxSize &size, - int style, const wxValidator& validator, const wxString &name ) +wxTextCtrl::wxTextCtrl( wxWindow *parent, + wxWindowID id, + const wxString &value, + const wxPoint &pos, + const wxSize &size, + long style, + const wxValidator& validator, + const wxString &name ) { m_modified = FALSE; Create( parent, id, value, pos, size, style, validator, name ); } -bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, - const wxPoint &pos, const wxSize &size, - int style, const wxValidator& validator, const wxString &name ) +bool wxTextCtrl::Create( wxWindow *parent, + wxWindowID id, + const wxString &value, + const wxPoint &pos, + const wxSize &size, + long style, + const wxValidator& validator, + const wxString &name ) { m_needParent = TRUE; m_acceptsFocus = TRUE; @@ -119,7 +129,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxTextCtrl creation failed") ); - return FALSE; + return FALSE; } @@ -182,12 +192,21 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, m_text = gtk_entry_new(); } - SetSizeOrDefault( size ); - m_parent->DoAddChild( this ); PostCreation(); + SetFont( parent->GetFont() ); + + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = size_best.x; + if (new_size.y == -1) + new_size.y = size_best.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + if (multi_line) gtk_widget_show(m_text); @@ -247,7 +266,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, SetForegroundColour( parent->GetForegroundColour() ); m_cursor = wxCursor( wxCURSOR_IBEAM ); - + Show( TRUE ); return TRUE; @@ -781,13 +800,13 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) wxWindow *top_frame = m_parent; while (top_frame->GetParent() && !(top_frame->IsTopLevel())) top_frame = top_frame->GetParent(); - GtkWindow *window = GTK_WINDOW(top_frame->m_widget); - - if (window->default_widget) + GtkWindow *window = GTK_WINDOW(top_frame->m_widget); + + if (window->default_widget) { gtk_widget_activate (window->default_widget); - return; - } + return; + } } key_event.Skip(); @@ -945,11 +964,11 @@ void wxTextCtrl::OnInternalIdle() if (cursor.Ok()) { GdkWindow *window = (GdkWindow*) NULL; - if (HasFlag(wxTE_MULTILINE)) + if (HasFlag(wxTE_MULTILINE)) window = GTK_TEXT(m_text)->text_area; else window = GTK_ENTRY(m_text)->text_area; - + if (window) gdk_window_set_cursor( window, cursor.GetCursor() ); @@ -967,5 +986,6 @@ void wxTextCtrl::OnInternalIdle() wxSize wxTextCtrl::DoGetBestSize() const { // FIXME should be different for multi-line controls... - return wxSize(80, 26); + wxSize ret( wxControl::DoGetBestSize() ); + return wxSize(80, ret.y); }