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;
!CreateBase( parent, id, pos, size, style, validator, name ))
{
wxFAIL_MSG( wxT("wxTextCtrl creation failed") );
- return FALSE;
+ return FALSE;
}
m_text = gtk_entry_new();
}
- wxSize newSize = size;
- if (newSize.x == -1) newSize.x = 80;
- if (newSize.y == -1) newSize.y = 26;
- SetSize( newSize.x, newSize.y );
+ wxSize new_size = size,
+ sizeBest = DoGetBestSize();
+ if (new_size.x == -1)
+ new_size.x = sizeBest.x;
+ if (new_size.y == -1)
+ new_size.y = sizeBest.y;
+
+ if ((new_size.x != size.x) || (new_size.y != size.y))
+ SetSize( new_size.x, new_size.y );
m_parent->DoAddChild( this );
SetForegroundColour( parent->GetForegroundColour() );
m_cursor = wxCursor( wxCURSOR_IBEAM );
-
+
Show( TRUE );
return TRUE;
/* bring editable's cursor uptodate. bug in GTK. */
- GTK_EDITABLE(m_text)->current_pos = pos;
+ GTK_EDITABLE(m_text)->current_pos = (guint32)pos;
}
}
if (GetEventHandler()->ProcessEvent(event)) return;
}
+ if ((key_event.KeyCode() == WXK_RETURN) && !(m_windowStyle & wxTE_MULTILINE))
+ {
+ 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)
+ {
+ gtk_widget_activate (window->default_widget);
+ return;
+ }
+ }
+
key_event.Skip();
}
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() );
if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget)))
gdk_window_set_cursor( window, cursor.GetCursor() );
}
+
+ UpdateWindowUI();
+}
+
+wxSize wxTextCtrl::DoGetBestSize() const
+{
+ // FIXME should be different for multi-line controls...
+ wxSize ret( wxControl::DoGetBestSize() );
+ return wxSize(80, ret.y);
}