]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/textctrl.cpp
BC++ 5.x also supports _beginthreadex and _endthreadex
[wxWidgets.git] / src / gtk1 / textctrl.cpp
index 8811350e7c8b36dd7fc1a2907263f973a204207b..e832dcdf05704efc246545ba426a6e515d07878c 100644 (file)
@@ -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,7 +192,15 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
           m_text = gtk_entry_new();
     }
 
-    SetSizeOrDefault( size );
+    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 );
 
@@ -247,7 +265,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
     SetForegroundColour( parent->GetForegroundColour() );
 
     m_cursor = wxCursor( wxCURSOR_IBEAM );
-    
+
     Show( TRUE );
 
     return TRUE;
@@ -330,7 +348,7 @@ void wxTextCtrl::WriteText( const wxString &text )
     {
         /* this moves the cursor pos to behind the inserted text */
         gint len = GTK_EDITABLE(m_text)->current_pos;
-        
+
 #if wxUSE_UNICODE
         wxWX2MBbuf buf = text.mbc_str();
         gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &len );
@@ -781,13 +799,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 +963,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 +985,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);
 }