]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/control.cpp
added new files which were generated by bakefile but were not in cvs for some reason
[wxWidgets.git] / src / gtk / control.cpp
index ed8b2147e84540abf8e75c377a131aeae5eecb02..afcd65c371cddc79074d76b6718b2854bfdc17c3 100644 (file)
@@ -7,10 +7,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "control.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -33,7 +29,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow)
 wxControl::wxControl()
 {
     m_needParent = TRUE;
-    m_createComplete = false;
 }
 
 bool wxControl::Create( wxWindow *parent,
@@ -44,7 +39,6 @@ bool wxControl::Create( wxWindow *parent,
                       const wxValidator& validator,
                       const wxString &name )
 {
-    m_createComplete = false;
     bool ret = wxWindow::Create(parent, id, pos, size, style, name);
     
 #if wxUSE_VALIDATORS
@@ -68,14 +62,7 @@ void wxControl::SetLabel( const wxString &label )
         }
         m_label << *pc;
     }
-}
-
-void wxControl::PostSetLabel()
-{
-    // make sure the widget has been created, and that PostCreate has already
-    // been called
-    if (m_widget && m_createComplete && GetAdjustMinSizeFlag())
-        SetBestSize(wxDefaultSize);
+    InvalidateBestSize();    
 }
 
 wxString wxControl::GetLabel() const
@@ -95,7 +82,9 @@ wxSize wxControl::DoGetBestSize() const
     (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
         (m_widget, &req );
 
-    return wxSize(req.width, req.height);
+    wxSize best(req.width, req.height);
+    CacheBestSize(best);
+    return best;
 }
 
 
@@ -110,10 +99,8 @@ void wxControl::PostCreation(const wxSize& size)
     //     GetBestSize is called.
     gtk_widget_ensure_style(m_widget);
     
-    InheritAttributes();
     ApplyWidgetStyle();
     SetInitialBestSize(size);
-    m_createComplete = true;
 }
 
 
@@ -212,7 +199,7 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
     if ( style && style->font_desc )
     {  
         wxNativeFontInfo info;  
-        info.description = style->font_desc;  
+        info.description = pango_font_description_copy(style->font_desc);
         attr.font = wxFont(info);  
     }  
     else  
@@ -240,59 +227,52 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
 
 //static
 wxVisualAttributes
-wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(void),
+wxControl::GetDefaultAttributesFromGTKWidget(wxGtkWidgetNew_t widget_new,
                                              bool useBase,
                                              int state)
 {
     wxVisualAttributes attr;
+    // NB: we need toplevel window so that GTK+ can find the right style
+    GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     GtkWidget* widget = widget_new();
+    gtk_container_add(GTK_CONTAINER(wnd), widget);
     attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state);
-    gtk_widget_destroy(widget);
+    gtk_widget_destroy(wnd);
     return attr;
 }
 
 //static
 wxVisualAttributes
-wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(const gchar*),
+wxControl::GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromStr_t widget_new,
                                              bool useBase,
                                              int state)
 {
     wxVisualAttributes attr;
+    // NB: we need toplevel window so that GTK+ can find the right style
+    GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     GtkWidget* widget = widget_new("");
+    gtk_container_add(GTK_CONTAINER(wnd), widget);
     attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state);
-    gtk_widget_destroy(widget);
+    gtk_widget_destroy(wnd);
     return attr;
 }
 
 
 //static
 wxVisualAttributes
-wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(GtkAdjustment*),
+wxControl::GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromAdj_t widget_new,
                                              bool useBase,
                                              int state)
 {
     wxVisualAttributes attr;
+    // NB: we need toplevel window so that GTK+ can find the right style
+    GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     GtkWidget* widget = widget_new(NULL);
+    gtk_container_add(GTK_CONTAINER(wnd), widget);
     attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state);
-    gtk_widget_destroy(widget);
+    gtk_widget_destroy(wnd);
     return attr;
 }
 
-void wxControl::ApplyWidgetStyle(bool forceStyle)
-{
-    GtkRcStyle *style = CreateWidgetStyle(forceStyle);
-    if ( style )
-    {
-        DoApplyWidgetStyle(style);
-        gtk_rc_style_unref(style);
-    }
-}
-
-void wxControl::DoApplyWidgetStyle(GtkRcStyle *style)
-{
-    gtk_widget_modify_style(m_widget, style);
-}
-
-
 #endif // wxUSE_CONTROLS