fixed GTK styles handling:
authorVáclav Slavík <vslavik@fastmail.fm>
Mon, 14 Jun 2004 17:34:00 +0000 (17:34 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Mon, 14 Jun 2004 17:34:00 +0000 (17:34 +0000)
1. don't modify the style unless something changed
2. use gtk_widget_modify_style instead of gtk_widget_set_style, the latter is not recommended by GTK+ developers

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27784 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

82 files changed:
docs/changes.txt
include/wx/defs.h
include/wx/gtk/bmpbuttn.h
include/wx/gtk/button.h
include/wx/gtk/checkbox.h
include/wx/gtk/choice.h
include/wx/gtk/combobox.h
include/wx/gtk/control.h
include/wx/gtk/gauge.h
include/wx/gtk/listbox.h
include/wx/gtk/notebook.h
include/wx/gtk/radiobox.h
include/wx/gtk/radiobut.h
include/wx/gtk/scrolbar.h
include/wx/gtk/slider.h
include/wx/gtk/spinbutt.h
include/wx/gtk/spinctrl.h
include/wx/gtk/statbox.h
include/wx/gtk/stattext.h
include/wx/gtk/textctrl.h
include/wx/gtk/tglbtn.h
include/wx/gtk/window.h
include/wx/gtk1/bmpbuttn.h
include/wx/gtk1/button.h
include/wx/gtk1/checkbox.h
include/wx/gtk1/choice.h
include/wx/gtk1/combobox.h
include/wx/gtk1/control.h
include/wx/gtk1/gauge.h
include/wx/gtk1/listbox.h
include/wx/gtk1/notebook.h
include/wx/gtk1/radiobox.h
include/wx/gtk1/radiobut.h
include/wx/gtk1/scrolbar.h
include/wx/gtk1/slider.h
include/wx/gtk1/spinbutt.h
include/wx/gtk1/spinctrl.h
include/wx/gtk1/statbox.h
include/wx/gtk1/stattext.h
include/wx/gtk1/textctrl.h
include/wx/gtk1/tglbtn.h
include/wx/gtk1/window.h
src/gtk/bmpbuttn.cpp
src/gtk/button.cpp
src/gtk/checkbox.cpp
src/gtk/choice.cpp
src/gtk/combobox.cpp
src/gtk/control.cpp
src/gtk/gauge.cpp
src/gtk/listbox.cpp
src/gtk/notebook.cpp
src/gtk/radiobox.cpp
src/gtk/radiobut.cpp
src/gtk/scrolbar.cpp
src/gtk/slider.cpp
src/gtk/spinbutt.cpp
src/gtk/spinctrl.cpp
src/gtk/statbox.cpp
src/gtk/stattext.cpp
src/gtk/textctrl.cpp
src/gtk/tglbtn.cpp
src/gtk/window.cpp
src/gtk1/bmpbuttn.cpp
src/gtk1/button.cpp
src/gtk1/checkbox.cpp
src/gtk1/choice.cpp
src/gtk1/combobox.cpp
src/gtk1/control.cpp
src/gtk1/gauge.cpp
src/gtk1/listbox.cpp
src/gtk1/notebook.cpp
src/gtk1/radiobox.cpp
src/gtk1/radiobut.cpp
src/gtk1/scrolbar.cpp
src/gtk1/slider.cpp
src/gtk1/spinbutt.cpp
src/gtk1/spinctrl.cpp
src/gtk1/statbox.cpp
src/gtk1/stattext.cpp
src/gtk1/textctrl.cpp
src/gtk1/tglbtn.cpp
src/gtk1/window.cpp

index f8978bcd3d3f429a884e79db1747c9ae608849b6..6a0e2c0e397a9b0241b0159e81eaccb8c736d15e 100644 (file)
@@ -119,7 +119,7 @@ Unix:
 
 wxGTK:
 
-- fixed wrong colour of tooltips under some themes
+- fixed many rendering artifacts and wrong colours with lots of GTK+ themes
 - implemented wxColourDialog as native dialog
 - wxTreeCtrl::GetCount() counts root as well now (compatible with MSW)
 
index 74eb5b8e9153035198909e6ac08dcad8e264f1a8..56044c1f81d70725eddcbc2e95008511371d4fc2 100644 (file)
@@ -2342,7 +2342,7 @@ typedef struct _GdkICAttr       GdkICAttr;
 
 /* Stand-ins for GTK types */
 typedef struct _GtkWidget         GtkWidget;
-typedef struct _GtkStyle          GtkStyle;
+typedef struct _GtkRcStyle        GtkRcStyle;
 typedef struct _GtkAdjustment     GtkAdjustment;
 typedef struct _GtkList           GtkList;
 typedef struct _GtkToolbar        GtkToolbar;
index c71501e59a7c8e57e57f2f044336f6d716058541..f4d71460df7ae126d2d614ae116f73ebcb7e62fc 100644 (file)
@@ -61,7 +61,7 @@ public:
     void NotFocus();
     void StartSelect();
     void EndSelect();
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
 
     bool         m_hasFocus:1;
     bool         m_isSelected:1;
index 3a55ddec52e9ae6d5e996178d0f456b172529934..59d8bb74c3e255426f3f13791d53060805bc251c 100644 (file)
@@ -64,7 +64,7 @@ public:
     // implementation
     // --------------
 
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     bool IsOwnGtkWindow( GdkWindow *window );
 
     // Since this wxButton doesn't derive from wxButtonBase (why?) we need
index 0fefb3c67cf9eb397ce089d95a20c8aee2145d25..aa2c495d445bd5a4eab7dfef13a51c4a96c043ea 100644 (file)
@@ -51,7 +51,7 @@ public:
     // implementation
     // --------------
 
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     bool IsOwnGtkWindow( GdkWindow *window );
     void OnInternalIdle();
 
index 17ae9edeb229e2e666aa8fdddb7a96d6014656d4..8732297d191c78eaee4d0431f9ac841f75806e73 100644 (file)
@@ -83,7 +83,7 @@ public:
 protected:
     wxList m_clientList;    // contains the client data for the items
 
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     virtual int DoAppend(const wxString& item);
     virtual int DoInsert(const wxString& item, int pos);
 
index 39bbb7ed548b924cb552ed31413a30e1690cb4cc..c4c7bf3d891bf523729f06389ab778a958419492 100644 (file)
@@ -130,7 +130,7 @@ public:
     void EnableEvents();
     GtkWidget* GetConnectWidget();
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
 
     wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
 
index be6f36bc1c395a6cc4c69d1c940cc381b08e44ab..417ad2083f54ef161c48afb9f43f50b617047746 100644 (file)
@@ -56,6 +56,11 @@ public:
     virtual wxVisualAttributes GetDefaultAttributes() const;
 
 protected:
+    virtual void ApplyWidgetStyle();
+    // helper function to ease native widgets wrapping, called by 
+    // ApplyWidgetStyle -- override this, not ApplyWidgetStyle
+    virtual void DoApplyWidgetStyle(GtkRcStyle *style);
+
     virtual wxSize DoGetBestSize() const;
     void PostCreation(const wxSize& size);
 
index 5652b6b5cbc0c31798aac0e982ab2ae694d76c13..e00e65d934a7c605f57b6bd3cf3de584390bf44e 100644 (file)
@@ -83,8 +83,6 @@ public:
     // implementation
     // -------------
 
-    void ApplyWidgetStyle();
-
     // the max and current gauge values
     int m_rangeMax,
         m_gaugePos;
index ff8d595c6c57e0fdd6e2318cd6fe2ead189a6a60..b8c980241fdaedea336957b84596ff641d33b7d9 100644 (file)
@@ -105,7 +105,7 @@ public:
     int GtkGetIndex( GtkWidget *item ) const;
     GtkWidget *GetConnectWidget();
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     void OnInternalIdle();
 
 #if wxUSE_TOOLTIPS
index 664eb5f1993558a22326b82dff7ea10ea75369c7..1830da0e9ef3cf0b1e4eb516e0fc5ddc5372b57f 100644 (file)
@@ -113,7 +113,7 @@ public:
     // set all page's font
     bool SetFont(const wxFont& font);
     
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
 
     // report if window belongs to notebook
     bool IsOwnGtkWindow( GdkWindow *window );
index 882bda03579e3298fac5f5971faf3508a4561685..e426de643fd08eff2a1befa0b5d1e4e208fa136b 100644 (file)
@@ -121,7 +121,7 @@ public:
     void GtkDisableEvents();
     void GtkEnableEvents();
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
 #if wxUSE_TOOLTIPS
     void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
 #endif // wxUSE_TOOLTIPS
index 39c442216f2d6ae3e67651973614e0d1bd26eb7d..552286e179b91e4f1a0dca57af4944b4f5e08d90 100644 (file)
@@ -57,7 +57,7 @@ public:
     virtual bool IsRadioButton() const { return TRUE; }
 
     GSList *m_radioButtonGroup;
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     bool IsOwnGtkWindow( GdkWindow *window );
     void OnInternalIdle();
 
index 8ce5e82897110387af9b9f44f09f3a9bd632a37a..5a8dd5cbc23ce6b1b8f042f6cc4b8a3e0ea0247f 100644 (file)
@@ -75,7 +75,6 @@ public:
     // --------------
 
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
 
     GtkAdjustment  *m_adjust;
     float           m_oldPos;
index bd4af3fcad80204c6f66b406197cf43a8518b036..3ff3ad6ea2f2e61692ff30c5a07a61a4a77f887c 100644 (file)
@@ -65,7 +65,6 @@ public:
     
     // implementation
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
     void GtkDisableEvents();
     void GtkEnableEvents();
 
index dfe3c40c056a4a7869fd71cda82d95775ebbb7bc..bbf998067d705e5b07170fce934707eebb489c5f 100644 (file)
@@ -53,7 +53,6 @@ public:
     void OnSize( wxSizeEvent &event );
 
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
 
     GtkAdjustment  *m_adjust;
     float           m_oldPos;
index 425f31f3353837d33e85d5260ffbf4f75dd8e90a..7ca72d8262dd6b9ae5d380e1b7b978ebc29db4b2 100644 (file)
@@ -66,7 +66,6 @@ public:
     void OnChar( wxKeyEvent &event );
     
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
     void GtkDisableEvents();
     void GtkEnableEvents();
 
index f0f1b2ff0efa759927040514fed86b3a701bf608..2bedf27d46e760b227bc5b68ae3ee441e4bc31e8 100644 (file)
@@ -45,8 +45,6 @@ public:
 
     // implementation
 
-    virtual void ApplyWidgetStyle();
-
     virtual bool IsTransparentForMouse() const { return TRUE; }
 
 private:
index eb9ee2a86ed5d47082c96a3ff89c2896b8db6b06..6686c96982fd80da969685882386aaf5925a2a6f 100644 (file)
@@ -65,8 +65,6 @@ public:
     
     // implementation
     // --------------
-    
-    void ApplyWidgetStyle();
 
 protected:
     virtual wxSize DoGetBestSize() const;
index 7ca89491e652dc9699a68f0f6f0232315c2caed9..3832c956dcabc58eb6e1f35631b0ecc3bf1f8b18 100644 (file)
@@ -133,7 +133,7 @@ public:
 
     GtkWidget* GetConnectWidget();
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     void CalculateScrollbar();
     void OnInternalIdle();
     void UpdateFontIfNeeded();
index 7da1777c18c496d03892a01b5f270380ef10a5c1..06f317f52beaf1d44314aef236953b367f005195 100644 (file)
@@ -74,7 +74,7 @@ public:
     wxBitmap  m_bitmap;
 
     void OnSetBitmap();
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     bool IsOwnGtkWindow(GdkWindow *window);
 
     virtual void OnInternalIdle();
@@ -128,7 +128,7 @@ public:
     // implementation
     bool m_blockEvent;
 
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     bool IsOwnGtkWindow(GdkWindow *window);
 
     virtual void OnInternalIdle();
index de520358355762827401503c0e43d25edfe69a5a..a0496b7fb9e12cc86dfa7767a49284fb8368de98 100644 (file)
@@ -153,10 +153,6 @@ public:
     virtual bool IsOwnGtkWindow( GdkWindow *window );
     void ConnectWidget( GtkWidget *widget );
 
-    // Creates a new widget style if none is there
-    // and sets m_widgetStyle to this value.
-    GtkStyle *GetWidgetStyle();
-
 #ifdef __WXGTK20__
     // Returns the default context which usually is anti-aliased
     PangoContext   *GtkGetPangoDefaultContext();
@@ -168,12 +164,6 @@ public:
     PangoContext   *m_x11Context;
 #endif
 
-    // Called by SetFont() and SetXXXColour etc
-    void SetWidgetStyle();
-
-    // Overridden in many GTK widgets who have to handle subwidgets
-    virtual void ApplyWidgetStyle();
-
 #if wxUSE_TOOLTIPS
     virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
 #endif // wxUSE_TOOLTIPS
@@ -247,12 +237,6 @@ public:
     bool                 m_delayedForegroundColour:1;
     bool                 m_delayedBackgroundColour:1;
 
-    // Contains GTK's widgets internal information about non-default widget
-    // font and colours. we create one for each widget that gets any
-    // non-default attribute set via SetFont() or SetForegroundColour() /
-    // SetBackgroundColour().
-    GtkStyle            *m_widgetStyle;
-
     // C++ has no virtual methods in the constrcutor of any class but we need
     // different methods of inserting a child window into a wxFrame,
     // wxMDIFrame, wxNotebook etc. this is the callback that will get used.
@@ -280,6 +264,14 @@ public:
 protected:
     // common part of all ctors (not virtual because called from ctor)
     void Init();
+    
+    // Called by ApplyWidgetStyle (which is called by SetFont() and
+    // SetXXXColour etc to apply style changed to native widgets) to create
+    // modified GTK style with non-standard attributes. 
+    GtkRcStyle *CreateWidgetStyle();
+
+    // Overridden in many GTK widgets who have to handle subwidgets
+    virtual void ApplyWidgetStyle();
 
 private:
     DECLARE_DYNAMIC_CLASS(wxWindowGTK)
index c71501e59a7c8e57e57f2f044336f6d716058541..f4d71460df7ae126d2d614ae116f73ebcb7e62fc 100644 (file)
@@ -61,7 +61,7 @@ public:
     void NotFocus();
     void StartSelect();
     void EndSelect();
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
 
     bool         m_hasFocus:1;
     bool         m_isSelected:1;
index 3a55ddec52e9ae6d5e996178d0f456b172529934..59d8bb74c3e255426f3f13791d53060805bc251c 100644 (file)
@@ -64,7 +64,7 @@ public:
     // implementation
     // --------------
 
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     bool IsOwnGtkWindow( GdkWindow *window );
 
     // Since this wxButton doesn't derive from wxButtonBase (why?) we need
index 0fefb3c67cf9eb397ce089d95a20c8aee2145d25..aa2c495d445bd5a4eab7dfef13a51c4a96c043ea 100644 (file)
@@ -51,7 +51,7 @@ public:
     // implementation
     // --------------
 
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     bool IsOwnGtkWindow( GdkWindow *window );
     void OnInternalIdle();
 
index 17ae9edeb229e2e666aa8fdddb7a96d6014656d4..8732297d191c78eaee4d0431f9ac841f75806e73 100644 (file)
@@ -83,7 +83,7 @@ public:
 protected:
     wxList m_clientList;    // contains the client data for the items
 
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     virtual int DoAppend(const wxString& item);
     virtual int DoInsert(const wxString& item, int pos);
 
index 39bbb7ed548b924cb552ed31413a30e1690cb4cc..c4c7bf3d891bf523729f06389ab778a958419492 100644 (file)
@@ -130,7 +130,7 @@ public:
     void EnableEvents();
     GtkWidget* GetConnectWidget();
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
 
     wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
 
index be6f36bc1c395a6cc4c69d1c940cc381b08e44ab..417ad2083f54ef161c48afb9f43f50b617047746 100644 (file)
@@ -56,6 +56,11 @@ public:
     virtual wxVisualAttributes GetDefaultAttributes() const;
 
 protected:
+    virtual void ApplyWidgetStyle();
+    // helper function to ease native widgets wrapping, called by 
+    // ApplyWidgetStyle -- override this, not ApplyWidgetStyle
+    virtual void DoApplyWidgetStyle(GtkRcStyle *style);
+
     virtual wxSize DoGetBestSize() const;
     void PostCreation(const wxSize& size);
 
index 5652b6b5cbc0c31798aac0e982ab2ae694d76c13..e00e65d934a7c605f57b6bd3cf3de584390bf44e 100644 (file)
@@ -83,8 +83,6 @@ public:
     // implementation
     // -------------
 
-    void ApplyWidgetStyle();
-
     // the max and current gauge values
     int m_rangeMax,
         m_gaugePos;
index ff8d595c6c57e0fdd6e2318cd6fe2ead189a6a60..b8c980241fdaedea336957b84596ff641d33b7d9 100644 (file)
@@ -105,7 +105,7 @@ public:
     int GtkGetIndex( GtkWidget *item ) const;
     GtkWidget *GetConnectWidget();
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     void OnInternalIdle();
 
 #if wxUSE_TOOLTIPS
index 664eb5f1993558a22326b82dff7ea10ea75369c7..1830da0e9ef3cf0b1e4eb516e0fc5ddc5372b57f 100644 (file)
@@ -113,7 +113,7 @@ public:
     // set all page's font
     bool SetFont(const wxFont& font);
     
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
 
     // report if window belongs to notebook
     bool IsOwnGtkWindow( GdkWindow *window );
index 882bda03579e3298fac5f5971faf3508a4561685..e426de643fd08eff2a1befa0b5d1e4e208fa136b 100644 (file)
@@ -121,7 +121,7 @@ public:
     void GtkDisableEvents();
     void GtkEnableEvents();
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
 #if wxUSE_TOOLTIPS
     void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
 #endif // wxUSE_TOOLTIPS
index 39c442216f2d6ae3e67651973614e0d1bd26eb7d..552286e179b91e4f1a0dca57af4944b4f5e08d90 100644 (file)
@@ -57,7 +57,7 @@ public:
     virtual bool IsRadioButton() const { return TRUE; }
 
     GSList *m_radioButtonGroup;
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     bool IsOwnGtkWindow( GdkWindow *window );
     void OnInternalIdle();
 
index 8ce5e82897110387af9b9f44f09f3a9bd632a37a..5a8dd5cbc23ce6b1b8f042f6cc4b8a3e0ea0247f 100644 (file)
@@ -75,7 +75,6 @@ public:
     // --------------
 
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
 
     GtkAdjustment  *m_adjust;
     float           m_oldPos;
index bd4af3fcad80204c6f66b406197cf43a8518b036..3ff3ad6ea2f2e61692ff30c5a07a61a4a77f887c 100644 (file)
@@ -65,7 +65,6 @@ public:
     
     // implementation
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
     void GtkDisableEvents();
     void GtkEnableEvents();
 
index dfe3c40c056a4a7869fd71cda82d95775ebbb7bc..bbf998067d705e5b07170fce934707eebb489c5f 100644 (file)
@@ -53,7 +53,6 @@ public:
     void OnSize( wxSizeEvent &event );
 
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
 
     GtkAdjustment  *m_adjust;
     float           m_oldPos;
index 425f31f3353837d33e85d5260ffbf4f75dd8e90a..7ca72d8262dd6b9ae5d380e1b7b978ebc29db4b2 100644 (file)
@@ -66,7 +66,6 @@ public:
     void OnChar( wxKeyEvent &event );
     
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
     void GtkDisableEvents();
     void GtkEnableEvents();
 
index f0f1b2ff0efa759927040514fed86b3a701bf608..2bedf27d46e760b227bc5b68ae3ee441e4bc31e8 100644 (file)
@@ -45,8 +45,6 @@ public:
 
     // implementation
 
-    virtual void ApplyWidgetStyle();
-
     virtual bool IsTransparentForMouse() const { return TRUE; }
 
 private:
index eb9ee2a86ed5d47082c96a3ff89c2896b8db6b06..6686c96982fd80da969685882386aaf5925a2a6f 100644 (file)
@@ -65,8 +65,6 @@ public:
     
     // implementation
     // --------------
-    
-    void ApplyWidgetStyle();
 
 protected:
     virtual wxSize DoGetBestSize() const;
index 7ca89491e652dc9699a68f0f6f0232315c2caed9..3832c956dcabc58eb6e1f35631b0ecc3bf1f8b18 100644 (file)
@@ -133,7 +133,7 @@ public:
 
     GtkWidget* GetConnectWidget();
     bool IsOwnGtkWindow( GdkWindow *window );
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     void CalculateScrollbar();
     void OnInternalIdle();
     void UpdateFontIfNeeded();
index 7da1777c18c496d03892a01b5f270380ef10a5c1..06f317f52beaf1d44314aef236953b367f005195 100644 (file)
@@ -74,7 +74,7 @@ public:
     wxBitmap  m_bitmap;
 
     void OnSetBitmap();
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     bool IsOwnGtkWindow(GdkWindow *window);
 
     virtual void OnInternalIdle();
@@ -128,7 +128,7 @@ public:
     // implementation
     bool m_blockEvent;
 
-    void ApplyWidgetStyle();
+    void DoApplyWidgetStyle(GtkRcStyle *style);
     bool IsOwnGtkWindow(GdkWindow *window);
 
     virtual void OnInternalIdle();
index de520358355762827401503c0e43d25edfe69a5a..a0496b7fb9e12cc86dfa7767a49284fb8368de98 100644 (file)
@@ -153,10 +153,6 @@ public:
     virtual bool IsOwnGtkWindow( GdkWindow *window );
     void ConnectWidget( GtkWidget *widget );
 
-    // Creates a new widget style if none is there
-    // and sets m_widgetStyle to this value.
-    GtkStyle *GetWidgetStyle();
-
 #ifdef __WXGTK20__
     // Returns the default context which usually is anti-aliased
     PangoContext   *GtkGetPangoDefaultContext();
@@ -168,12 +164,6 @@ public:
     PangoContext   *m_x11Context;
 #endif
 
-    // Called by SetFont() and SetXXXColour etc
-    void SetWidgetStyle();
-
-    // Overridden in many GTK widgets who have to handle subwidgets
-    virtual void ApplyWidgetStyle();
-
 #if wxUSE_TOOLTIPS
     virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
 #endif // wxUSE_TOOLTIPS
@@ -247,12 +237,6 @@ public:
     bool                 m_delayedForegroundColour:1;
     bool                 m_delayedBackgroundColour:1;
 
-    // Contains GTK's widgets internal information about non-default widget
-    // font and colours. we create one for each widget that gets any
-    // non-default attribute set via SetFont() or SetForegroundColour() /
-    // SetBackgroundColour().
-    GtkStyle            *m_widgetStyle;
-
     // C++ has no virtual methods in the constrcutor of any class but we need
     // different methods of inserting a child window into a wxFrame,
     // wxMDIFrame, wxNotebook etc. this is the callback that will get used.
@@ -280,6 +264,14 @@ public:
 protected:
     // common part of all ctors (not virtual because called from ctor)
     void Init();
+    
+    // Called by ApplyWidgetStyle (which is called by SetFont() and
+    // SetXXXColour etc to apply style changed to native widgets) to create
+    // modified GTK style with non-standard attributes. 
+    GtkRcStyle *CreateWidgetStyle();
+
+    // Overridden in many GTK widgets who have to handle subwidgets
+    virtual void ApplyWidgetStyle();
 
 private:
     DECLARE_DYNAMIC_CLASS(wxWindowGTK)
index 17bc64454f6dc88505e69eddf4d3827d2e10c753..db117650134db117c4d6c76b80e2058b8df09813 100644 (file)
@@ -193,12 +193,12 @@ wxString wxBitmapButton::GetLabel() const
     return wxControl::GetLabel();
 }
 
-void wxBitmapButton::ApplyWidgetStyle()
+void wxBitmapButton::DoApplyWidgetStyle(GtkRcStyle *style)
 {
     if ( !BUTTON_CHILD(m_widget) )
         return;
 
-    wxButton::ApplyWidgetStyle();
+    wxButton::DoApplyWidgetStyle(style);
 }
 
 void wxBitmapButton::OnSetBitmap()
index f71214c940196885be711e0ffdc49fd33924c638..d64273b78006e960f02070aa9024b0b13a1ada40 100644 (file)
@@ -196,11 +196,10 @@ bool wxButton::IsOwnGtkWindow( GdkWindow *window )
 #endif
 }
 
-void wxButton::ApplyWidgetStyle()
+void wxButton::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-    gtk_widget_set_style( BUTTON_CHILD(m_widget), m_widgetStyle );
+    gtk_widget_modify_style(m_widget, style);
+    gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
 }
 
 wxSize wxButton::DoGetBestSize() const
index e7fe520d4dfebb7a1a65f3f58ed690398914b493..1c64e26ba1c5156da9fd5d2b8fc51b0a8459f0e3 100644 (file)
@@ -170,11 +170,10 @@ bool wxCheckBox::Enable( bool enable )
     return TRUE;
 }
 
-void wxCheckBox::ApplyWidgetStyle()
+void wxCheckBox::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widgetCheckbox, m_widgetStyle );
-    gtk_widget_set_style( m_widgetLabel, m_widgetStyle );
+    gtk_widget_modify_style(m_widgetCheckbox, style);
+    gtk_widget_modify_style(m_widgetLabel, style);
 }
 
 bool wxCheckBox::IsOwnGtkWindow( GdkWindow *window )
index 54f9b1de429bc3f67edbf1ae2f50881a0eaed2b8..28d895dd2e1dc9b27b7836c66f01909e1260926b 100644 (file)
@@ -437,19 +437,17 @@ void wxChoice::SetSelection( int n )
     gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp );
 }
 
-void wxChoice::ApplyWidgetStyle()
+void wxChoice::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-
     GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
 
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-    gtk_widget_set_style( GTK_WIDGET( menu_shell ), m_widgetStyle );
+    gtk_widget_modify_style( m_widget, style );
+    gtk_widget_modify_style( GTK_WIDGET( menu_shell ), style );
 
     GList *child = menu_shell->children;
     while (child)
     {
-        gtk_widget_set_style( GTK_WIDGET( child->data ), m_widgetStyle );
+        gtk_widget_modify_style( GTK_WIDGET( child->data ), style );
 
         GtkBin *bin = GTK_BIN( child->data );
         GtkWidget *label = (GtkWidget *) NULL;
@@ -458,7 +456,7 @@ void wxChoice::ApplyWidgetStyle()
         if (!label)
             label = BUTTON_CHILD(m_widget);
 
-        gtk_widget_set_style( label, m_widgetStyle );
+        gtk_widget_modify_style( label, style );
 
         child = child->next;
     }
@@ -513,7 +511,7 @@ int wxChoice::GtkAddHelper(GtkWidget *menu, int pos, const wxString& item)
         gtk_widget_realize( menu_item );
         gtk_widget_realize( GTK_BIN(menu_item)->child );
 
-        if (m_widgetStyle) ApplyWidgetStyle();
+        ApplyWidgetStyle();
     }
 
     gtk_signal_connect( GTK_OBJECT( menu_item ), "activate",
index f7950f67bfc11b12521d176521355ad21f0c6f79..2ddf6fcf952de835d301dc5fd95f43bcaf2678d0 100644 (file)
@@ -239,7 +239,7 @@ int wxComboBox::DoAppend( const wxString &item )
         gtk_widget_realize( list_item );
         gtk_widget_realize( GTK_BIN(list_item)->child );
 
-        if (m_widgetStyle) ApplyWidgetStyle();
+        ApplyWidgetStyle();
     }
 
     gtk_widget_show( list_item );
@@ -284,8 +284,7 @@ int wxComboBox::DoInsert( const wxString &item, int pos )
         gtk_widget_realize( list_item );
         gtk_widget_realize( GTK_BIN(list_item)->child );
 
-        if (m_widgetStyle)
-            ApplyWidgetStyle();
+        ApplyWidgetStyle();
     }
 
     gtk_widget_show( list_item );
@@ -722,22 +721,20 @@ void wxComboBox::OnSize( wxSizeEvent &event )
 #endif // 0
 }
 
-void wxComboBox::ApplyWidgetStyle()
+void wxComboBox::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-
-//    gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle );
-    gtk_widget_set_style( GTK_COMBO(m_widget)->entry, m_widgetStyle );
-    gtk_widget_set_style( GTK_COMBO(m_widget)->list, m_widgetStyle );
+//    gtk_widget_modify_style( GTK_COMBO(m_widget)->button, syle );
+    gtk_widget_modify_style( GTK_COMBO(m_widget)->entry, style );
+    gtk_widget_modify_style( GTK_COMBO(m_widget)->list, style );
 
     GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list );
     GList *child = list->children;
     while (child)
     {
-        gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
+        gtk_widget_modify_style( GTK_WIDGET(child->data), style );
 
         GtkBin *bin = GTK_BIN(child->data);
-        gtk_widget_set_style( bin->child, m_widgetStyle );
+        gtk_widget_modify_style( bin->child, style );
 
         child = child->next;
     }
index dfbfe4b9c0eba7cf531840269c3c511f5c72f6eb..e638c35d8d3204492cad13e0645c22adac35cb8e 100644 (file)
@@ -92,6 +92,14 @@ wxSize wxControl::DoGetBestSize() const
 void wxControl::PostCreation(const wxSize& size)
 {
     wxWindow::PostCreation();
+
+    // NB: GetBestSize needs to know the style, otherwise it will assume
+    //     default font and if the user uses a different font, determined
+    //     best size will be different (typically, smaller) than the desired
+    //     size. This call ensure that a style is available at the time
+    //     GetBestSize is called.
+    gtk_widget_ensure_style(m_widget);
+    
     InheritAttributes();
     ApplyWidgetStyle();
     SetInitialBestSize(size);
@@ -259,6 +267,21 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(GtkAdjustm
     return attr;
 }
 
+void wxControl::ApplyWidgetStyle()
+{
+    GtkRcStyle *style = CreateWidgetStyle();
+    if ( style )
+    {
+        DoApplyWidgetStyle(style);
+        gtk_rc_style_unref(style);
+    }
+}
+
+void wxControl::DoApplyWidgetStyle(GtkRcStyle *style)
+{
+    gtk_widget_modify_style(m_widget, style);
+}
+
 
 #endif // wxUSE_CONTROLS
 
index 7fe754a52e2f6a68a1ac1de0925ea6e787a1f43e..90aad2ca5b65d2f46491baef58f2bf65d6da0986 100644 (file)
@@ -106,12 +106,6 @@ int wxGauge::GetValue() const
     return m_gaugePos;
 }
 
-void wxGauge::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 wxVisualAttributes wxGauge::GetDefaultAttributes() const
 {
     // Visible gauge colours use a different colour state
index 9f06846793b89a0ec9f6bc8d1c08952555abad4d..15c355869d815c2143e9df1f74a0cbd0825ca56e 100644 (file)
@@ -575,12 +575,14 @@ void wxListBox::GtkAddItem( const wxString &item, int pos )
         gtk_widget_realize( GTK_BIN(list_item)->child );
 
         // Apply current widget style to the new list_item
-        if (m_widgetStyle)
+        GtkRcStyle *style = CreateWidgetStyle();
+        if (style)
         {
-            gtk_widget_set_style( GTK_WIDGET( list_item ), m_widgetStyle );
+            gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
             GtkBin *bin = GTK_BIN( list_item );
             GtkWidget *label = GTK_WIDGET( bin->child );
-            gtk_widget_set_style( label, m_widgetStyle );
+            gtk_widget_modify_style( label, style );
+            gtk_rc_style_unref( style );
         }
 
 #if wxUSE_TOOLTIPS
@@ -981,11 +983,9 @@ bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
     return FALSE;
 }
 
-void wxListBox::ApplyWidgetStyle()
+void wxListBox::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-
-    if (m_backgroundColour.Ok())
+    if (m_hasBgCol && m_backgroundColour.Ok())
     {
         GdkWindow *window = GTK_WIDGET(m_list)->window;
         if ( window )
@@ -999,11 +999,11 @@ void wxListBox::ApplyWidgetStyle()
     GList *child = m_list->children;
     while (child)
     {
-        gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
+        gtk_widget_modify_style( GTK_WIDGET(child->data), style );
 
         GtkBin *bin = GTK_BIN( child->data );
         GtkWidget *label = GTK_WIDGET( bin->child );
-        gtk_widget_set_style( label, m_widgetStyle );
+        gtk_widget_modify_style( label, style );
 
         child = child->next;
     }
index ded15fb845915efd490238294dddbcc25abca147..cb6e7b39d410d8d9c25570f355f7d1a7ac629bd3 100644 (file)
@@ -72,13 +72,6 @@ public:
         m_image = -1;
         m_page = (GtkNotebookPage *) NULL;
         m_box = (GtkWidget *) NULL;
-        m_labelStyle = (GtkStyle*) NULL;
-    }
-    
-    ~wxGtkNotebookPage()
-    {
-        if (m_labelStyle)
-            gtk_style_unref( m_labelStyle );
     }
     
     bool SetFont(const wxFont& font);
@@ -88,7 +81,6 @@ public:
     GtkNotebookPage   *m_page;
     GtkLabel          *m_label;
     GtkWidget         *m_box;     // in which the label and image are packed
-    GtkStyle          *m_labelStyle;
 };
 
 
@@ -97,42 +89,17 @@ bool wxGtkNotebookPage::SetFont(const wxFont& font)
     if (!m_label)
                return false;
 
-    if (m_labelStyle)
-    {
-        GtkStyle *remake = gtk_style_copy( m_labelStyle );
-
-#ifndef __WXGTK20__
-        remake->klass = m_labelStyle->klass;
-#endif
-
-        gtk_style_unref( m_labelStyle );
-        m_labelStyle = remake;
-    }
-    else
-    {
-        GtkStyle *def = gtk_rc_get_style( GTK_WIDGET(m_label) );
-
-        if (!def)
-            def = gtk_widget_get_default_style();
-
-        m_labelStyle = gtk_style_copy( def );
-
-        // FIXME: no more klass in 2.0
-#ifndef __WXGTK20__
-        m_labelStyle->klass = def->klass;
-#endif
-    }
-
 #ifdef __WXGTK20__
-       pango_font_description_free( m_labelStyle->font_desc );
-       m_labelStyle->font_desc = pango_font_description_copy( font.GetNativeFontInfo()->description );
+    gtk_widget_modify_font(GTK_WIDGET(m_label),
+                           font.GetNativeFontInfo()->description);
 #else
-       gdk_font_unref( m_labelStyle->font );
-       m_labelStyle->font = gdk_font_ref( font.GetInternalFont( 1.0 ) );
+    GtkRcStyle *style = gtk_rc_style_new();
+    style->fontset_name = 
+        g_strdup(font.GetNativeFontInfo()->GetXFontName().c_str());
+    gtk_widget_modify_style(GTK_WIDGET(m_label), style);
+    gtk_rc_style_unref(style);
 #endif
 
-    gtk_widget_set_style( GTK_WIDGET(m_label), m_labelStyle );
-
        return true;
 }
 
@@ -839,12 +806,10 @@ bool wxNotebook::DoPhase( int WXUNUSED(nPhase) )
 
 #endif
 
-void wxNotebook::ApplyWidgetStyle()
+void wxNotebook::DoApplyWidgetStyle(GtkRcStyle *style)
 {
     // TODO, font for labels etc
-
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
+    gtk_widget_modify_style( m_widget, style );
 }
 
 bool wxNotebook::IsOwnGtkWindow( GdkWindow *window )
index 3538f3c037a96e6fbb6564bd02011d03755af2a7..ea1eee523009f2267e4b1d760e14cecc3b71a6bd 100644 (file)
@@ -681,19 +681,17 @@ void wxRadioBox::GtkEnableEvents()
     }
 }
 
-void wxRadioBox::ApplyWidgetStyle()
+void wxRadioBox::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-
-    gtk_widget_set_style( m_widget, m_widgetStyle );
+    gtk_widget_modify_style( m_widget, style );
 
     wxList::compatibility_iterator node = m_boxes.GetFirst();
     while (node)
     {
         GtkWidget *widget = GTK_WIDGET( node->GetData() );
-        gtk_widget_set_style( widget, m_widgetStyle );
 
-        gtk_widget_set_style( BUTTON_CHILD(node->GetData()), m_widgetStyle );
+        gtk_widget_modify_style( widget, style );
+        gtk_widget_modify_style( BUTTON_CHILD(node->GetData()), style );
 
         node = node->GetNext();
     }
index c03a82e438a66b5684935008c37d4f93e33ee2ef..2c3e1c0d107c9d0f53c74df9c2e45fa47f2b63ca 100644 (file)
@@ -187,11 +187,10 @@ bool wxRadioButton::Enable( bool enable )
     return TRUE;
 }
 
-void wxRadioButton::ApplyWidgetStyle()
+void wxRadioButton::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-    gtk_widget_set_style( BUTTON_CHILD(m_widget), m_widgetStyle );
+    gtk_widget_modify_style(m_widget, style);
+    gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
 }
 
 bool wxRadioButton::IsOwnGtkWindow( GdkWindow *window )
index 6dcd71ec52c1cf16b1a9837e02189e8fd015c646..f2d26ced1d242ffbbcb5330de356c95abb482fe1 100644 (file)
@@ -325,12 +325,6 @@ bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window )
            );
 }
 
-void wxScrollBar::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 wxSize wxScrollBar::DoGetBestSize() const
 {
     return wxControl::DoGetBestSize();
index e7079c5c1018e46500b5fa262d1190f1bb368a49..bcd260ad6eeeb5c596cdec3f70099a5311205d04 100644 (file)
@@ -265,12 +265,6 @@ bool wxSlider::IsOwnGtkWindow( GdkWindow *window )
 #endif
 }
 
-void wxSlider::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 void wxSlider::GtkDisableEvents()
 {
     gtk_signal_disconnect_by_func( GTK_OBJECT(m_adjust),
index 423947a1d359eacb17617e3d9de272bb0f7fd386..a62d2c121e62f90a8f2dbb0dc9338421d3a54fb3 100644 (file)
@@ -225,15 +225,9 @@ bool wxSpinButton::IsOwnGtkWindow( GdkWindow *window )
     return GTK_SPIN_BUTTON(m_widget)->panel == window;
 }
 
-void wxSpinButton::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 wxSize wxSpinButton::DoGetBestSize() const
 {
-    return wxSize(15, 26);
+    return wxSize(15, 26); // FIXME
 }
 
 // static
index 80d5007a43e1c664a9b0fed0854bf588e710bf18..9390128cf0e2cd611e2c34472949b6765f1720bc 100644 (file)
@@ -298,12 +298,6 @@ bool wxSpinCtrl::IsOwnGtkWindow( GdkWindow *window )
     return FALSE;
 }
 
-void wxSpinCtrl::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 wxSize wxSpinCtrl::DoGetBestSize() const
 {
     wxSize ret( wxControl::DoGetBestSize() );
index 879e2bc579d1ceaad9741358e4411e8e86f277ff..7c3eb9678ee91cdea241dfb38a7121f90fe2cd64 100644 (file)
@@ -91,12 +91,6 @@ void wxStaticBox::SetLabel( const wxString &label )
                          m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
 }
 
-void wxStaticBox::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 // static
 wxVisualAttributes
 wxStaticBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
index 1849d21f5d3375ae3b032ef85ffc5325f476d609..d659e8cc167cbb7ab1acc629beabdbe2226d5a48 100644 (file)
@@ -168,12 +168,6 @@ bool wxStaticText::SetFont( const wxFont &font )
     return ret;
 }
 
-void wxStaticText::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 wxSize wxStaticText::DoGetBestSize() const
 {
     // Do not return any arbitrary default value...
index a2ad1509bb50d71cdfef1ff25d1257a8af080494..2d5b6460a5d7a1c651250556fe875bbbecb90585 100644 (file)
@@ -1535,10 +1535,9 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style )
     }
 }
 
-void wxTextCtrl::ApplyWidgetStyle()
+void wxTextCtrl::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-    gtk_widget_set_style( m_text, m_widgetStyle );
+    gtk_widget_modify_style(m_text, style);
 }
 
 void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
index d8aac966f6ada216abb5e384c9177a70e342c586..8ac7ec5a3c6364728ce0f8ed57194b0976e3f193 100644 (file)
@@ -159,11 +159,10 @@ bool wxToggleBitmapButton::Enable(bool enable /*=TRUE*/)
     return TRUE;
 }
 
-void wxToggleBitmapButton::ApplyWidgetStyle()
+void wxToggleBitmapButton::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-    gtk_widget_set_style(m_widget, m_widgetStyle);
-    gtk_widget_set_style(BUTTON_CHILD(m_widget), m_widgetStyle);
+    gtk_widget_modify_style(m_widget, style);
+    gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
 }
 
 bool wxToggleBitmapButton::IsOwnGtkWindow(GdkWindow *window)
@@ -300,11 +299,10 @@ bool wxToggleButton::Enable(bool enable /*=TRUE*/)
     return TRUE;
 }
 
-void wxToggleButton::ApplyWidgetStyle()
+void wxToggleButton::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-    gtk_widget_set_style(m_widget, m_widgetStyle);
-    gtk_widget_set_style(BUTTON_CHILD(m_widget), m_widgetStyle);
+    gtk_widget_modify_style(m_widget, style);
+    gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
 }
 
 bool wxToggleButton::IsOwnGtkWindow(GdkWindow *window)
index 150aabdcfc519ae9b29ce76579ceea400db3b376..13d9f19cd60ba214548cb5e449b6850888ea7fde 100644 (file)
@@ -267,10 +267,6 @@ extern bool g_mainThreadLocked;
 // debug
 //-----------------------------------------------------------------------------
 
-#ifndef __WXGTK20__
-#define DISABLE_STYLE_IF_BROKEN_THEME 0
-#endif
-
 #ifdef __WXDEBUG__
 
 #if wxUSE_THREADS
@@ -2566,7 +2562,6 @@ void wxWindowGTK::Init()
     m_oldClientHeight = 0;
 
     m_resizing = FALSE;
-    m_widgetStyle = (GtkStyle*) NULL;
 
     m_insertCallback = (wxInsertChildFunction) NULL;
 
@@ -2760,16 +2755,6 @@ wxWindowGTK::~wxWindowGTK()
         gdk_ic_attr_destroy (m_icattr);
 #endif
 
-    if (m_widgetStyle)
-    {
-#if DISABLE_STYLE_IF_BROKEN_THEME
-        // don't delete if it's a pixmap theme style
-        if (!m_widgetStyle->engine_data)
-            gtk_style_unref( m_widgetStyle );
-#endif
-        m_widgetStyle = (GtkStyle*) NULL;
-    }
-
     if (m_wxwindow)
     {
         gtk_widget_destroy( m_wxwindow );
@@ -4097,131 +4082,69 @@ PangoContext *wxWindowGTK::GtkGetPangoX11Context()
     return m_x11Context;
 }
 #endif
-
-GtkStyle *wxWindowGTK::GetWidgetStyle()
-{
-    if (m_widgetStyle)
-    {
-        GtkStyle *remake = gtk_style_copy( m_widgetStyle );
-
-        // FIXME: no more klass in 2.0
-#ifndef __WXGTK20__
-        remake->klass = m_widgetStyle->klass;
-#endif
-
-        gtk_style_unref( m_widgetStyle );
-        m_widgetStyle = remake;
-    }
-    else
-    {
-        GtkStyle *def = gtk_rc_get_style( m_widget );
-
-        if (!def)
-            def = gtk_widget_get_default_style();
-
-        m_widgetStyle = gtk_style_copy( def );
-
-        // FIXME: no more klass in 2.0
-#ifndef __WXGTK20__
-        m_widgetStyle->klass = def->klass;
-#endif
-    }
-
-    return m_widgetStyle;
-}
-
-void wxWindowGTK::SetWidgetStyle()
+GtkRcStyle *wxWindowGTK::CreateWidgetStyle()
 {
-#if DISABLE_STYLE_IF_BROKEN_THEME
-    if (m_widget->style->engine_data)
+    // do we need to apply any changes at all?
+    if ( !m_hasFont && !m_hasFgCol &&
+         (!m_hasBgCol || !m_backgroundColour.Ok()) )
     {
-        static bool s_warningPrinted = FALSE;
-        if (!s_warningPrinted)
-        {
-            printf( "wxWidgets warning: Widget styles disabled due to buggy GTK theme.\n" );
-            s_warningPrinted = TRUE;
-        }
-        m_widgetStyle = m_widget->style;
-        return;
+        return NULL;
     }
-#endif
 
-    GtkStyle *style = GetWidgetStyle();
+    GtkRcStyle *style = gtk_rc_style_new();
 
     if ( m_hasFont )
     {
 #ifdef __WXGTK20__
-        pango_font_description_free( style->font_desc );
-        style->font_desc = pango_font_description_copy( m_font.GetNativeFontInfo()->description );
+        style->font_desc = 
+            pango_font_description_copy( m_font.GetNativeFontInfo()->description );
 #else
-        gdk_font_unref( style->font );
-        style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
+        wxString xfontname = m_font.GetNativeFontInfo()->GetXFontName();
+        style->fontset_name = g_strdup(xfontname.c_str());
 #endif
     }
 
     if ( m_hasFgCol )
     {
         m_foregroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) );
-        if (m_foregroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT))
-        {
-            style->fg[GTK_STATE_NORMAL] = *m_foregroundColour.GetColor();
-            style->fg[GTK_STATE_PRELIGHT] = *m_foregroundColour.GetColor();
-            style->fg[GTK_STATE_ACTIVE] = *m_foregroundColour.GetColor();
-        }
-        else
-        {
-            // Try to restore the gtk default style.  This is still a little
-            // oversimplified for what is probably really needed here for controls
-            // other than buttons, but is better than not being able to (re)set a
-            // control's foreground colour to *wxBLACK -- RL
-            GtkStyle *def = gtk_rc_get_style( m_widget );
-
-            if (!def)
-                def = gtk_widget_get_default_style();
-
-            style->fg[GTK_STATE_NORMAL] = def->fg[GTK_STATE_NORMAL];
-            style->fg[GTK_STATE_PRELIGHT] = def->fg[GTK_STATE_PRELIGHT];
-            style->fg[GTK_STATE_ACTIVE] = def->fg[GTK_STATE_ACTIVE];
-        }
+        
+        style->fg[GTK_STATE_NORMAL] = *m_foregroundColour.GetColor();
+        style->color_flags[GTK_STATE_NORMAL] = GTK_RC_FG;
+        
+        style->fg[GTK_STATE_PRELIGHT] = *m_foregroundColour.GetColor();
+        style->color_flags[GTK_STATE_PRELIGHT] = GTK_RC_FG;
+        
+        style->fg[GTK_STATE_ACTIVE] = *m_foregroundColour.GetColor();
+        style->color_flags[GTK_STATE_ACTIVE] = GTK_RC_FG;
     }
 
     if ( m_hasBgCol && m_backgroundColour.Ok() )
     {
         m_backgroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) );
-        if (m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE))
-        {
-            style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
-            style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
-            style->bg[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
-            style->base[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
-            style->bg[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
-            style->base[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
-            style->bg[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
-            style->base[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
-        }
-        else
-        {
-            // Try to restore the gtk default style.  This is still a little
-            // oversimplified for what is probably really needed here for controls
-            // other than buttons, but is better than not being able to (re)set a
-            // control's background colour to default grey and means resetting a
-            // button to wxSYS_COLOUR_BTNFACE will restore its usual highlighting
-            // behavior -- RL
-            GtkStyle *def = gtk_rc_get_style( m_widget );
-
-            if (!def)
-                def = gtk_widget_get_default_style();
-
-            style->bg[GTK_STATE_NORMAL] = def->bg[GTK_STATE_NORMAL];
-            style->base[GTK_STATE_NORMAL] = def->base[GTK_STATE_NORMAL];
-            style->bg[GTK_STATE_PRELIGHT] = def->bg[GTK_STATE_PRELIGHT];
-            style->base[GTK_STATE_PRELIGHT] = def->base[GTK_STATE_PRELIGHT];
-            style->bg[GTK_STATE_ACTIVE] = def->bg[GTK_STATE_ACTIVE];
-            style->base[GTK_STATE_ACTIVE] = def->base[GTK_STATE_ACTIVE];
-            style->bg[GTK_STATE_INSENSITIVE] = def->bg[GTK_STATE_INSENSITIVE];
-            style->base[GTK_STATE_INSENSITIVE] = def->base[GTK_STATE_INSENSITIVE];
-        }
+        
+        style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
+        style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
+        style->color_flags[GTK_STATE_NORMAL] = (GtkRcFlags)
+            (style->color_flags[GTK_STATE_NORMAL] | GTK_RC_BG | GTK_RC_BASE);
+        
+        style->bg[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
+        style->base[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
+        style->color_flags[GTK_STATE_PRELIGHT] = (GtkRcFlags)
+            (style->color_flags[GTK_STATE_PRELIGHT] | GTK_RC_BG | GTK_RC_BASE);
+        
+        style->bg[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
+        style->base[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
+        style->color_flags[GTK_STATE_ACTIVE] = (GtkRcFlags)
+            (style->color_flags[GTK_STATE_ACTIVE] | GTK_RC_BG | GTK_RC_BASE);
+        
+        style->bg[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
+        style->base[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
+        style->color_flags[GTK_STATE_INSENSITIVE] = (GtkRcFlags)
+            (style->color_flags[GTK_STATE_INSENSITIVE] | GTK_RC_BG | GTK_RC_BASE);
     }
+    
+    return style;
 }
 
 void wxWindowGTK::ApplyWidgetStyle()
index 17bc64454f6dc88505e69eddf4d3827d2e10c753..db117650134db117c4d6c76b80e2058b8df09813 100644 (file)
@@ -193,12 +193,12 @@ wxString wxBitmapButton::GetLabel() const
     return wxControl::GetLabel();
 }
 
-void wxBitmapButton::ApplyWidgetStyle()
+void wxBitmapButton::DoApplyWidgetStyle(GtkRcStyle *style)
 {
     if ( !BUTTON_CHILD(m_widget) )
         return;
 
-    wxButton::ApplyWidgetStyle();
+    wxButton::DoApplyWidgetStyle(style);
 }
 
 void wxBitmapButton::OnSetBitmap()
index f71214c940196885be711e0ffdc49fd33924c638..d64273b78006e960f02070aa9024b0b13a1ada40 100644 (file)
@@ -196,11 +196,10 @@ bool wxButton::IsOwnGtkWindow( GdkWindow *window )
 #endif
 }
 
-void wxButton::ApplyWidgetStyle()
+void wxButton::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-    gtk_widget_set_style( BUTTON_CHILD(m_widget), m_widgetStyle );
+    gtk_widget_modify_style(m_widget, style);
+    gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
 }
 
 wxSize wxButton::DoGetBestSize() const
index e7fe520d4dfebb7a1a65f3f58ed690398914b493..1c64e26ba1c5156da9fd5d2b8fc51b0a8459f0e3 100644 (file)
@@ -170,11 +170,10 @@ bool wxCheckBox::Enable( bool enable )
     return TRUE;
 }
 
-void wxCheckBox::ApplyWidgetStyle()
+void wxCheckBox::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widgetCheckbox, m_widgetStyle );
-    gtk_widget_set_style( m_widgetLabel, m_widgetStyle );
+    gtk_widget_modify_style(m_widgetCheckbox, style);
+    gtk_widget_modify_style(m_widgetLabel, style);
 }
 
 bool wxCheckBox::IsOwnGtkWindow( GdkWindow *window )
index 54f9b1de429bc3f67edbf1ae2f50881a0eaed2b8..28d895dd2e1dc9b27b7836c66f01909e1260926b 100644 (file)
@@ -437,19 +437,17 @@ void wxChoice::SetSelection( int n )
     gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp );
 }
 
-void wxChoice::ApplyWidgetStyle()
+void wxChoice::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-
     GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
 
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-    gtk_widget_set_style( GTK_WIDGET( menu_shell ), m_widgetStyle );
+    gtk_widget_modify_style( m_widget, style );
+    gtk_widget_modify_style( GTK_WIDGET( menu_shell ), style );
 
     GList *child = menu_shell->children;
     while (child)
     {
-        gtk_widget_set_style( GTK_WIDGET( child->data ), m_widgetStyle );
+        gtk_widget_modify_style( GTK_WIDGET( child->data ), style );
 
         GtkBin *bin = GTK_BIN( child->data );
         GtkWidget *label = (GtkWidget *) NULL;
@@ -458,7 +456,7 @@ void wxChoice::ApplyWidgetStyle()
         if (!label)
             label = BUTTON_CHILD(m_widget);
 
-        gtk_widget_set_style( label, m_widgetStyle );
+        gtk_widget_modify_style( label, style );
 
         child = child->next;
     }
@@ -513,7 +511,7 @@ int wxChoice::GtkAddHelper(GtkWidget *menu, int pos, const wxString& item)
         gtk_widget_realize( menu_item );
         gtk_widget_realize( GTK_BIN(menu_item)->child );
 
-        if (m_widgetStyle) ApplyWidgetStyle();
+        ApplyWidgetStyle();
     }
 
     gtk_signal_connect( GTK_OBJECT( menu_item ), "activate",
index f7950f67bfc11b12521d176521355ad21f0c6f79..2ddf6fcf952de835d301dc5fd95f43bcaf2678d0 100644 (file)
@@ -239,7 +239,7 @@ int wxComboBox::DoAppend( const wxString &item )
         gtk_widget_realize( list_item );
         gtk_widget_realize( GTK_BIN(list_item)->child );
 
-        if (m_widgetStyle) ApplyWidgetStyle();
+        ApplyWidgetStyle();
     }
 
     gtk_widget_show( list_item );
@@ -284,8 +284,7 @@ int wxComboBox::DoInsert( const wxString &item, int pos )
         gtk_widget_realize( list_item );
         gtk_widget_realize( GTK_BIN(list_item)->child );
 
-        if (m_widgetStyle)
-            ApplyWidgetStyle();
+        ApplyWidgetStyle();
     }
 
     gtk_widget_show( list_item );
@@ -722,22 +721,20 @@ void wxComboBox::OnSize( wxSizeEvent &event )
 #endif // 0
 }
 
-void wxComboBox::ApplyWidgetStyle()
+void wxComboBox::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-
-//    gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle );
-    gtk_widget_set_style( GTK_COMBO(m_widget)->entry, m_widgetStyle );
-    gtk_widget_set_style( GTK_COMBO(m_widget)->list, m_widgetStyle );
+//    gtk_widget_modify_style( GTK_COMBO(m_widget)->button, syle );
+    gtk_widget_modify_style( GTK_COMBO(m_widget)->entry, style );
+    gtk_widget_modify_style( GTK_COMBO(m_widget)->list, style );
 
     GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list );
     GList *child = list->children;
     while (child)
     {
-        gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
+        gtk_widget_modify_style( GTK_WIDGET(child->data), style );
 
         GtkBin *bin = GTK_BIN(child->data);
-        gtk_widget_set_style( bin->child, m_widgetStyle );
+        gtk_widget_modify_style( bin->child, style );
 
         child = child->next;
     }
index dfbfe4b9c0eba7cf531840269c3c511f5c72f6eb..e638c35d8d3204492cad13e0645c22adac35cb8e 100644 (file)
@@ -92,6 +92,14 @@ wxSize wxControl::DoGetBestSize() const
 void wxControl::PostCreation(const wxSize& size)
 {
     wxWindow::PostCreation();
+
+    // NB: GetBestSize needs to know the style, otherwise it will assume
+    //     default font and if the user uses a different font, determined
+    //     best size will be different (typically, smaller) than the desired
+    //     size. This call ensure that a style is available at the time
+    //     GetBestSize is called.
+    gtk_widget_ensure_style(m_widget);
+    
     InheritAttributes();
     ApplyWidgetStyle();
     SetInitialBestSize(size);
@@ -259,6 +267,21 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(GtkAdjustm
     return attr;
 }
 
+void wxControl::ApplyWidgetStyle()
+{
+    GtkRcStyle *style = CreateWidgetStyle();
+    if ( style )
+    {
+        DoApplyWidgetStyle(style);
+        gtk_rc_style_unref(style);
+    }
+}
+
+void wxControl::DoApplyWidgetStyle(GtkRcStyle *style)
+{
+    gtk_widget_modify_style(m_widget, style);
+}
+
 
 #endif // wxUSE_CONTROLS
 
index 7fe754a52e2f6a68a1ac1de0925ea6e787a1f43e..90aad2ca5b65d2f46491baef58f2bf65d6da0986 100644 (file)
@@ -106,12 +106,6 @@ int wxGauge::GetValue() const
     return m_gaugePos;
 }
 
-void wxGauge::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 wxVisualAttributes wxGauge::GetDefaultAttributes() const
 {
     // Visible gauge colours use a different colour state
index 9f06846793b89a0ec9f6bc8d1c08952555abad4d..15c355869d815c2143e9df1f74a0cbd0825ca56e 100644 (file)
@@ -575,12 +575,14 @@ void wxListBox::GtkAddItem( const wxString &item, int pos )
         gtk_widget_realize( GTK_BIN(list_item)->child );
 
         // Apply current widget style to the new list_item
-        if (m_widgetStyle)
+        GtkRcStyle *style = CreateWidgetStyle();
+        if (style)
         {
-            gtk_widget_set_style( GTK_WIDGET( list_item ), m_widgetStyle );
+            gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
             GtkBin *bin = GTK_BIN( list_item );
             GtkWidget *label = GTK_WIDGET( bin->child );
-            gtk_widget_set_style( label, m_widgetStyle );
+            gtk_widget_modify_style( label, style );
+            gtk_rc_style_unref( style );
         }
 
 #if wxUSE_TOOLTIPS
@@ -981,11 +983,9 @@ bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
     return FALSE;
 }
 
-void wxListBox::ApplyWidgetStyle()
+void wxListBox::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-
-    if (m_backgroundColour.Ok())
+    if (m_hasBgCol && m_backgroundColour.Ok())
     {
         GdkWindow *window = GTK_WIDGET(m_list)->window;
         if ( window )
@@ -999,11 +999,11 @@ void wxListBox::ApplyWidgetStyle()
     GList *child = m_list->children;
     while (child)
     {
-        gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
+        gtk_widget_modify_style( GTK_WIDGET(child->data), style );
 
         GtkBin *bin = GTK_BIN( child->data );
         GtkWidget *label = GTK_WIDGET( bin->child );
-        gtk_widget_set_style( label, m_widgetStyle );
+        gtk_widget_modify_style( label, style );
 
         child = child->next;
     }
index ded15fb845915efd490238294dddbcc25abca147..cb6e7b39d410d8d9c25570f355f7d1a7ac629bd3 100644 (file)
@@ -72,13 +72,6 @@ public:
         m_image = -1;
         m_page = (GtkNotebookPage *) NULL;
         m_box = (GtkWidget *) NULL;
-        m_labelStyle = (GtkStyle*) NULL;
-    }
-    
-    ~wxGtkNotebookPage()
-    {
-        if (m_labelStyle)
-            gtk_style_unref( m_labelStyle );
     }
     
     bool SetFont(const wxFont& font);
@@ -88,7 +81,6 @@ public:
     GtkNotebookPage   *m_page;
     GtkLabel          *m_label;
     GtkWidget         *m_box;     // in which the label and image are packed
-    GtkStyle          *m_labelStyle;
 };
 
 
@@ -97,42 +89,17 @@ bool wxGtkNotebookPage::SetFont(const wxFont& font)
     if (!m_label)
                return false;
 
-    if (m_labelStyle)
-    {
-        GtkStyle *remake = gtk_style_copy( m_labelStyle );
-
-#ifndef __WXGTK20__
-        remake->klass = m_labelStyle->klass;
-#endif
-
-        gtk_style_unref( m_labelStyle );
-        m_labelStyle = remake;
-    }
-    else
-    {
-        GtkStyle *def = gtk_rc_get_style( GTK_WIDGET(m_label) );
-
-        if (!def)
-            def = gtk_widget_get_default_style();
-
-        m_labelStyle = gtk_style_copy( def );
-
-        // FIXME: no more klass in 2.0
-#ifndef __WXGTK20__
-        m_labelStyle->klass = def->klass;
-#endif
-    }
-
 #ifdef __WXGTK20__
-       pango_font_description_free( m_labelStyle->font_desc );
-       m_labelStyle->font_desc = pango_font_description_copy( font.GetNativeFontInfo()->description );
+    gtk_widget_modify_font(GTK_WIDGET(m_label),
+                           font.GetNativeFontInfo()->description);
 #else
-       gdk_font_unref( m_labelStyle->font );
-       m_labelStyle->font = gdk_font_ref( font.GetInternalFont( 1.0 ) );
+    GtkRcStyle *style = gtk_rc_style_new();
+    style->fontset_name = 
+        g_strdup(font.GetNativeFontInfo()->GetXFontName().c_str());
+    gtk_widget_modify_style(GTK_WIDGET(m_label), style);
+    gtk_rc_style_unref(style);
 #endif
 
-    gtk_widget_set_style( GTK_WIDGET(m_label), m_labelStyle );
-
        return true;
 }
 
@@ -839,12 +806,10 @@ bool wxNotebook::DoPhase( int WXUNUSED(nPhase) )
 
 #endif
 
-void wxNotebook::ApplyWidgetStyle()
+void wxNotebook::DoApplyWidgetStyle(GtkRcStyle *style)
 {
     // TODO, font for labels etc
-
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
+    gtk_widget_modify_style( m_widget, style );
 }
 
 bool wxNotebook::IsOwnGtkWindow( GdkWindow *window )
index 3538f3c037a96e6fbb6564bd02011d03755af2a7..ea1eee523009f2267e4b1d760e14cecc3b71a6bd 100644 (file)
@@ -681,19 +681,17 @@ void wxRadioBox::GtkEnableEvents()
     }
 }
 
-void wxRadioBox::ApplyWidgetStyle()
+void wxRadioBox::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-
-    gtk_widget_set_style( m_widget, m_widgetStyle );
+    gtk_widget_modify_style( m_widget, style );
 
     wxList::compatibility_iterator node = m_boxes.GetFirst();
     while (node)
     {
         GtkWidget *widget = GTK_WIDGET( node->GetData() );
-        gtk_widget_set_style( widget, m_widgetStyle );
 
-        gtk_widget_set_style( BUTTON_CHILD(node->GetData()), m_widgetStyle );
+        gtk_widget_modify_style( widget, style );
+        gtk_widget_modify_style( BUTTON_CHILD(node->GetData()), style );
 
         node = node->GetNext();
     }
index c03a82e438a66b5684935008c37d4f93e33ee2ef..2c3e1c0d107c9d0f53c74df9c2e45fa47f2b63ca 100644 (file)
@@ -187,11 +187,10 @@ bool wxRadioButton::Enable( bool enable )
     return TRUE;
 }
 
-void wxRadioButton::ApplyWidgetStyle()
+void wxRadioButton::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-    gtk_widget_set_style( BUTTON_CHILD(m_widget), m_widgetStyle );
+    gtk_widget_modify_style(m_widget, style);
+    gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
 }
 
 bool wxRadioButton::IsOwnGtkWindow( GdkWindow *window )
index 6dcd71ec52c1cf16b1a9837e02189e8fd015c646..f2d26ced1d242ffbbcb5330de356c95abb482fe1 100644 (file)
@@ -325,12 +325,6 @@ bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window )
            );
 }
 
-void wxScrollBar::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 wxSize wxScrollBar::DoGetBestSize() const
 {
     return wxControl::DoGetBestSize();
index e7079c5c1018e46500b5fa262d1190f1bb368a49..bcd260ad6eeeb5c596cdec3f70099a5311205d04 100644 (file)
@@ -265,12 +265,6 @@ bool wxSlider::IsOwnGtkWindow( GdkWindow *window )
 #endif
 }
 
-void wxSlider::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 void wxSlider::GtkDisableEvents()
 {
     gtk_signal_disconnect_by_func( GTK_OBJECT(m_adjust),
index 423947a1d359eacb17617e3d9de272bb0f7fd386..a62d2c121e62f90a8f2dbb0dc9338421d3a54fb3 100644 (file)
@@ -225,15 +225,9 @@ bool wxSpinButton::IsOwnGtkWindow( GdkWindow *window )
     return GTK_SPIN_BUTTON(m_widget)->panel == window;
 }
 
-void wxSpinButton::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 wxSize wxSpinButton::DoGetBestSize() const
 {
-    return wxSize(15, 26);
+    return wxSize(15, 26); // FIXME
 }
 
 // static
index 80d5007a43e1c664a9b0fed0854bf588e710bf18..9390128cf0e2cd611e2c34472949b6765f1720bc 100644 (file)
@@ -298,12 +298,6 @@ bool wxSpinCtrl::IsOwnGtkWindow( GdkWindow *window )
     return FALSE;
 }
 
-void wxSpinCtrl::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 wxSize wxSpinCtrl::DoGetBestSize() const
 {
     wxSize ret( wxControl::DoGetBestSize() );
index 879e2bc579d1ceaad9741358e4411e8e86f277ff..7c3eb9678ee91cdea241dfb38a7121f90fe2cd64 100644 (file)
@@ -91,12 +91,6 @@ void wxStaticBox::SetLabel( const wxString &label )
                          m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
 }
 
-void wxStaticBox::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 // static
 wxVisualAttributes
 wxStaticBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
index 1849d21f5d3375ae3b032ef85ffc5325f476d609..d659e8cc167cbb7ab1acc629beabdbe2226d5a48 100644 (file)
@@ -168,12 +168,6 @@ bool wxStaticText::SetFont( const wxFont &font )
     return ret;
 }
 
-void wxStaticText::ApplyWidgetStyle()
-{
-    SetWidgetStyle();
-    gtk_widget_set_style( m_widget, m_widgetStyle );
-}
-
 wxSize wxStaticText::DoGetBestSize() const
 {
     // Do not return any arbitrary default value...
index a2ad1509bb50d71cdfef1ff25d1257a8af080494..2d5b6460a5d7a1c651250556fe875bbbecb90585 100644 (file)
@@ -1535,10 +1535,9 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style )
     }
 }
 
-void wxTextCtrl::ApplyWidgetStyle()
+void wxTextCtrl::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-    gtk_widget_set_style( m_text, m_widgetStyle );
+    gtk_widget_modify_style(m_text, style);
 }
 
 void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
index d8aac966f6ada216abb5e384c9177a70e342c586..8ac7ec5a3c6364728ce0f8ed57194b0976e3f193 100644 (file)
@@ -159,11 +159,10 @@ bool wxToggleBitmapButton::Enable(bool enable /*=TRUE*/)
     return TRUE;
 }
 
-void wxToggleBitmapButton::ApplyWidgetStyle()
+void wxToggleBitmapButton::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-    gtk_widget_set_style(m_widget, m_widgetStyle);
-    gtk_widget_set_style(BUTTON_CHILD(m_widget), m_widgetStyle);
+    gtk_widget_modify_style(m_widget, style);
+    gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
 }
 
 bool wxToggleBitmapButton::IsOwnGtkWindow(GdkWindow *window)
@@ -300,11 +299,10 @@ bool wxToggleButton::Enable(bool enable /*=TRUE*/)
     return TRUE;
 }
 
-void wxToggleButton::ApplyWidgetStyle()
+void wxToggleButton::DoApplyWidgetStyle(GtkRcStyle *style)
 {
-    SetWidgetStyle();
-    gtk_widget_set_style(m_widget, m_widgetStyle);
-    gtk_widget_set_style(BUTTON_CHILD(m_widget), m_widgetStyle);
+    gtk_widget_modify_style(m_widget, style);
+    gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
 }
 
 bool wxToggleButton::IsOwnGtkWindow(GdkWindow *window)
index 150aabdcfc519ae9b29ce76579ceea400db3b376..13d9f19cd60ba214548cb5e449b6850888ea7fde 100644 (file)
@@ -267,10 +267,6 @@ extern bool g_mainThreadLocked;
 // debug
 //-----------------------------------------------------------------------------
 
-#ifndef __WXGTK20__
-#define DISABLE_STYLE_IF_BROKEN_THEME 0
-#endif
-
 #ifdef __WXDEBUG__
 
 #if wxUSE_THREADS
@@ -2566,7 +2562,6 @@ void wxWindowGTK::Init()
     m_oldClientHeight = 0;
 
     m_resizing = FALSE;
-    m_widgetStyle = (GtkStyle*) NULL;
 
     m_insertCallback = (wxInsertChildFunction) NULL;
 
@@ -2760,16 +2755,6 @@ wxWindowGTK::~wxWindowGTK()
         gdk_ic_attr_destroy (m_icattr);
 #endif
 
-    if (m_widgetStyle)
-    {
-#if DISABLE_STYLE_IF_BROKEN_THEME
-        // don't delete if it's a pixmap theme style
-        if (!m_widgetStyle->engine_data)
-            gtk_style_unref( m_widgetStyle );
-#endif
-        m_widgetStyle = (GtkStyle*) NULL;
-    }
-
     if (m_wxwindow)
     {
         gtk_widget_destroy( m_wxwindow );
@@ -4097,131 +4082,69 @@ PangoContext *wxWindowGTK::GtkGetPangoX11Context()
     return m_x11Context;
 }
 #endif
-
-GtkStyle *wxWindowGTK::GetWidgetStyle()
-{
-    if (m_widgetStyle)
-    {
-        GtkStyle *remake = gtk_style_copy( m_widgetStyle );
-
-        // FIXME: no more klass in 2.0
-#ifndef __WXGTK20__
-        remake->klass = m_widgetStyle->klass;
-#endif
-
-        gtk_style_unref( m_widgetStyle );
-        m_widgetStyle = remake;
-    }
-    else
-    {
-        GtkStyle *def = gtk_rc_get_style( m_widget );
-
-        if (!def)
-            def = gtk_widget_get_default_style();
-
-        m_widgetStyle = gtk_style_copy( def );
-
-        // FIXME: no more klass in 2.0
-#ifndef __WXGTK20__
-        m_widgetStyle->klass = def->klass;
-#endif
-    }
-
-    return m_widgetStyle;
-}
-
-void wxWindowGTK::SetWidgetStyle()
+GtkRcStyle *wxWindowGTK::CreateWidgetStyle()
 {
-#if DISABLE_STYLE_IF_BROKEN_THEME
-    if (m_widget->style->engine_data)
+    // do we need to apply any changes at all?
+    if ( !m_hasFont && !m_hasFgCol &&
+         (!m_hasBgCol || !m_backgroundColour.Ok()) )
     {
-        static bool s_warningPrinted = FALSE;
-        if (!s_warningPrinted)
-        {
-            printf( "wxWidgets warning: Widget styles disabled due to buggy GTK theme.\n" );
-            s_warningPrinted = TRUE;
-        }
-        m_widgetStyle = m_widget->style;
-        return;
+        return NULL;
     }
-#endif
 
-    GtkStyle *style = GetWidgetStyle();
+    GtkRcStyle *style = gtk_rc_style_new();
 
     if ( m_hasFont )
     {
 #ifdef __WXGTK20__
-        pango_font_description_free( style->font_desc );
-        style->font_desc = pango_font_description_copy( m_font.GetNativeFontInfo()->description );
+        style->font_desc = 
+            pango_font_description_copy( m_font.GetNativeFontInfo()->description );
 #else
-        gdk_font_unref( style->font );
-        style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
+        wxString xfontname = m_font.GetNativeFontInfo()->GetXFontName();
+        style->fontset_name = g_strdup(xfontname.c_str());
 #endif
     }
 
     if ( m_hasFgCol )
     {
         m_foregroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) );
-        if (m_foregroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT))
-        {
-            style->fg[GTK_STATE_NORMAL] = *m_foregroundColour.GetColor();
-            style->fg[GTK_STATE_PRELIGHT] = *m_foregroundColour.GetColor();
-            style->fg[GTK_STATE_ACTIVE] = *m_foregroundColour.GetColor();
-        }
-        else
-        {
-            // Try to restore the gtk default style.  This is still a little
-            // oversimplified for what is probably really needed here for controls
-            // other than buttons, but is better than not being able to (re)set a
-            // control's foreground colour to *wxBLACK -- RL
-            GtkStyle *def = gtk_rc_get_style( m_widget );
-
-            if (!def)
-                def = gtk_widget_get_default_style();
-
-            style->fg[GTK_STATE_NORMAL] = def->fg[GTK_STATE_NORMAL];
-            style->fg[GTK_STATE_PRELIGHT] = def->fg[GTK_STATE_PRELIGHT];
-            style->fg[GTK_STATE_ACTIVE] = def->fg[GTK_STATE_ACTIVE];
-        }
+        
+        style->fg[GTK_STATE_NORMAL] = *m_foregroundColour.GetColor();
+        style->color_flags[GTK_STATE_NORMAL] = GTK_RC_FG;
+        
+        style->fg[GTK_STATE_PRELIGHT] = *m_foregroundColour.GetColor();
+        style->color_flags[GTK_STATE_PRELIGHT] = GTK_RC_FG;
+        
+        style->fg[GTK_STATE_ACTIVE] = *m_foregroundColour.GetColor();
+        style->color_flags[GTK_STATE_ACTIVE] = GTK_RC_FG;
     }
 
     if ( m_hasBgCol && m_backgroundColour.Ok() )
     {
         m_backgroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) );
-        if (m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE))
-        {
-            style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
-            style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
-            style->bg[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
-            style->base[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
-            style->bg[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
-            style->base[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
-            style->bg[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
-            style->base[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
-        }
-        else
-        {
-            // Try to restore the gtk default style.  This is still a little
-            // oversimplified for what is probably really needed here for controls
-            // other than buttons, but is better than not being able to (re)set a
-            // control's background colour to default grey and means resetting a
-            // button to wxSYS_COLOUR_BTNFACE will restore its usual highlighting
-            // behavior -- RL
-            GtkStyle *def = gtk_rc_get_style( m_widget );
-
-            if (!def)
-                def = gtk_widget_get_default_style();
-
-            style->bg[GTK_STATE_NORMAL] = def->bg[GTK_STATE_NORMAL];
-            style->base[GTK_STATE_NORMAL] = def->base[GTK_STATE_NORMAL];
-            style->bg[GTK_STATE_PRELIGHT] = def->bg[GTK_STATE_PRELIGHT];
-            style->base[GTK_STATE_PRELIGHT] = def->base[GTK_STATE_PRELIGHT];
-            style->bg[GTK_STATE_ACTIVE] = def->bg[GTK_STATE_ACTIVE];
-            style->base[GTK_STATE_ACTIVE] = def->base[GTK_STATE_ACTIVE];
-            style->bg[GTK_STATE_INSENSITIVE] = def->bg[GTK_STATE_INSENSITIVE];
-            style->base[GTK_STATE_INSENSITIVE] = def->base[GTK_STATE_INSENSITIVE];
-        }
+        
+        style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
+        style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
+        style->color_flags[GTK_STATE_NORMAL] = (GtkRcFlags)
+            (style->color_flags[GTK_STATE_NORMAL] | GTK_RC_BG | GTK_RC_BASE);
+        
+        style->bg[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
+        style->base[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
+        style->color_flags[GTK_STATE_PRELIGHT] = (GtkRcFlags)
+            (style->color_flags[GTK_STATE_PRELIGHT] | GTK_RC_BG | GTK_RC_BASE);
+        
+        style->bg[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
+        style->base[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
+        style->color_flags[GTK_STATE_ACTIVE] = (GtkRcFlags)
+            (style->color_flags[GTK_STATE_ACTIVE] | GTK_RC_BG | GTK_RC_BASE);
+        
+        style->bg[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
+        style->base[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
+        style->color_flags[GTK_STATE_INSENSITIVE] = (GtkRcFlags)
+            (style->color_flags[GTK_STATE_INSENSITIVE] | GTK_RC_BG | GTK_RC_BASE);
     }
+    
+    return style;
 }
 
 void wxWindowGTK::ApplyWidgetStyle()