]> git.saurik.com Git - wxWidgets.git/commitdiff
Get(Class)DefaultAttributes() for wxGTK controls
authorRobin Dunn <robin@alldunn.com>
Thu, 6 May 2004 17:26:25 +0000 (17:26 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 6 May 2004 17:26:25 +0000 (17:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27115 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

84 files changed:
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/statbmp.h
include/wx/gtk/statbox.h
include/wx/gtk/statline.h
include/wx/gtk/stattext.h
include/wx/gtk/tbargtk.h
include/wx/gtk/textctrl.h
include/wx/gtk/tglbtn.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/statbmp.h
include/wx/gtk1/statbox.h
include/wx/gtk1/statline.h
include/wx/gtk1/stattext.h
include/wx/gtk1/tbargtk.h
include/wx/gtk1/textctrl.h
include/wx/gtk1/tglbtn.h
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/statbmp.cpp
src/gtk/statbox.cpp
src/gtk/statline.cpp
src/gtk/stattext.cpp
src/gtk/tbargtk.cpp
src/gtk/textctrl.cpp
src/gtk/tglbtn.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/statbmp.cpp
src/gtk1/statbox.cpp
src/gtk1/statline.cpp
src/gtk1/stattext.cpp
src/gtk1/tbargtk.cpp
src/gtk1/textctrl.cpp
src/gtk1/tglbtn.cpp

index 5c90c03e246c6af811697876638e8718edc8a7a8..3a55ddec52e9ae6d5e996178d0f456b172529934 100644 (file)
@@ -71,6 +71,9 @@ public:
     // to override this here too...
     virtual bool ShouldInheritColours() const { return false; }
     
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
 protected:
     virtual wxSize DoGetBestSize() const;
 
index 11f89e0a478bf38870c26fc7f69bc8554d685671..0fefb3c67cf9eb397ce089d95a20c8aee2145d25 100644 (file)
@@ -45,6 +45,9 @@ public:
     virtual void SetLabel( const wxString& label );
     virtual bool Enable( bool enable = TRUE );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     // --------------
 
index d738e3e253e614adda99eb9af47a8509fc5d0287..17ae9edeb229e2e666aa8fdddb7a96d6014656d4 100644 (file)
@@ -77,6 +77,9 @@ public:
     wxString GetString( int n ) const;
     void SetString( int n, const wxString& string );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
 protected:
     wxList m_clientList;    // contains the client data for the items
 
@@ -92,6 +95,7 @@ protected:
     virtual wxSize DoGetBestSize() const;
 
     virtual bool IsOwnGtkWindow( GdkWindow *window );
+
 private:
     // common part of Create() and DoAppend()
     int GtkAddHelper(GtkWidget *menu, int pos, const wxString& item);
index b3756066cc289528c49df240c94c9b8870088650..39bbb7ed548b924cb552ed31413a30e1690cb4cc 100644 (file)
@@ -134,6 +134,9 @@ public:
 
     wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
 protected:
     virtual int DoAppend(const wxString& item);
     virtual int DoInsert(const wxString& item, int pos);
@@ -145,6 +148,10 @@ protected:
 
     virtual wxSize DoGetBestSize() const;
 
+    // Widgets that use the style->base colour for the BG colour should
+    // override this and return true.
+    virtual bool UseGTKStyleBase() const { return true; }
+
 private:
     DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
     DECLARE_EVENT_TABLE()
index 38b277a8587debc95b2019b7aa826f70483610b9..be6f36bc1c395a6cc4c69d1c940cc381b08e44ab 100644 (file)
@@ -53,6 +53,8 @@ public:
     virtual void SetLabel( const wxString &label );
     virtual wxString GetLabel() const;
 
+    virtual wxVisualAttributes GetDefaultAttributes() const;
+
 protected:
     virtual wxSize DoGetBestSize() const;
     void PostCreation(const wxSize& size);
@@ -61,6 +63,29 @@ protected:
     wxString PrepareLabelMnemonics( const wxString &label ) const;
 #endif
 
+    // These are used by GetDefaultAttributes
+    static wxVisualAttributes
+        GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
+                                          bool useBase = false,
+                                          int state = -1);
+    static wxVisualAttributes
+        GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(void),
+                                          bool useBase = false,
+                                          int state = -1);
+    static wxVisualAttributes
+        GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(const gchar*),
+                                          bool useBase = false,
+                                          int state = -1);
+
+    static wxVisualAttributes
+        GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(GtkAdjustment*),
+                                          bool useBase = false,
+                                          int state = -1);
+
+    // Widgets that use the style->base colour for the BG colour should
+    // override this and return true.
+    virtual bool UseGTKStyleBase() const { return false; }
+
     wxString   m_label;
     char       m_chAccel;  // enabled to avoid breaking binary compatibility later on
 
index 5ca47abcf643511403dfdb8e688878edcf52670f..5652b6b5cbc0c31798aac0e982ab2ae694d76c13 100644 (file)
@@ -77,6 +77,9 @@ public:
 
     bool IsVertical() const { return HasFlag(wxGA_VERTICAL); }
     
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     // -------------
 
@@ -100,6 +103,8 @@ protected:
 
     virtual wxSize DoGetBestSize() const;
 
+    virtual wxVisualAttributes GetDefaultAttributes() const;
+
 private:
     DECLARE_DYNAMIC_CLASS(wxGauge)
 };
index 7974011566c330fd78e44a99574c26bb6963a52c..ff8d595c6c57e0fdd6e2318cd6fe2ead189a6a60 100644 (file)
@@ -96,6 +96,9 @@ public:
     virtual void DoSetItemClientObject(int n, wxClientData* clientData);
     virtual wxClientData* DoGetItemClientObject(int n) const;
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation from now on
 
     void GtkAddItem( const wxString &item, int pos=-1 );
@@ -127,6 +130,10 @@ protected:
     // return the string label for the given item
     wxString GetRealLabel(struct _GList *item) const;
 
+    // Widgets that use the style->base colour for the BG colour should
+    // override this and return true.
+    virtual bool UseGTKStyleBase() const { return true; }
+
 private:
     // this array is only used for controls with wxCB_SORT style, so only
     // allocate it if it's needed (hence using pointer)
index 9dfef193c1f5b1d51b1d5e649108c0bff666d2fc..664eb5f1993558a22326b82dff7ea10ea75369c7 100644 (file)
@@ -98,6 +98,10 @@ public:
     // --------------------------
     void OnNavigationKey(wxNavigationKeyEvent& event);
 
+
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     // --------------
 
index cfdcef9c94b7e7db4028230b3504acd745adc999..882bda03579e3298fac5f5971faf3508a4561685 100644 (file)
@@ -111,6 +111,9 @@ public:
     virtual bool Show( bool show = TRUE );
     virtual bool Enable( bool enable = TRUE );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
     // implementation
     // --------------
 
index af716335eab44068a179abf2805f10ea244a365a..39c442216f2d6ae3e67651973614e0d1bd26eb7d 100644 (file)
@@ -49,6 +49,9 @@ public:
     virtual bool GetValue() const;
     virtual bool Enable( bool enable = TRUE );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
     // implementation
 
     virtual bool IsRadioButton() const { return TRUE; }
index 4f43d99e7e954d0ac686b8862c33623957494de2..8ce5e82897110387af9b9f44f09f3a9bd632a37a 100644 (file)
@@ -68,6 +68,9 @@ public:
     void SetObjectLength( int objectLength );
     void SetViewLength( int viewLength );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     // --------------
 
index 945c726ededcf7915ed8bd2f5dd675a8a7fca5ef..bd4af3fcad80204c6f66b406197cf43a8518b036 100644 (file)
@@ -60,6 +60,9 @@ public:
     virtual void SetThumbLength(int lenPixels);
     virtual int GetThumbLength() const;
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     bool IsOwnGtkWindow( GdkWindow *window );
     void ApplyWidgetStyle();
index ce80a907e56fc5fab06c829f43fa907f346d2d2c..dfe3c40c056a4a7869fd71cda82d95775ebbb7bc 100644 (file)
@@ -46,6 +46,9 @@ public:
     virtual int GetMin() const;
     virtual int GetMax() const;
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     void OnSize( wxSizeEvent &event );
 
index f39e5184e632f7d2c3f69c29651e5e161d23d1dc..425f31f3353837d33e85d5260ffbf4f75dd8e90a 100644 (file)
@@ -59,6 +59,9 @@ public:
     virtual int GetMin() const;
     virtual int GetMax() const;
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     void OnChar( wxKeyEvent &event );
     
@@ -73,6 +76,10 @@ public:
 protected:
     virtual wxSize DoGetBestSize() const;
 
+    // Widgets that use the style->base colour for the BG colour should
+    // override this and return true.
+    virtual bool UseGTKStyleBase() const { return true; }
+
 private:
     DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
     DECLARE_EVENT_TABLE()
index 642e70844846235ccc6c4c14e9097f7780df00df..00677618dea55eeacadb6f151320192617688375 100644 (file)
@@ -52,6 +52,9 @@ public:
         return (const wxIcon &)m_bitmap;
     }
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
 private:
     // creates the new pixmap widget
     void CreatePixmapWidget();
index fa4d65228ad46eddbe28a2c8fdf3d112dc9cbc35..f0f1b2ff0efa759927040514fed86b3a701bf608 100644 (file)
@@ -40,6 +40,9 @@ public:
 
     virtual void SetLabel( const wxString &label );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
     // implementation
 
     virtual void ApplyWidgetStyle();
index 2324b012049032517a25f148f14f85898b80ada0..803ae2018acb3f06ab5b3c697c629e97a5541396 100644 (file)
@@ -45,6 +45,10 @@ public:
     bool Create(  wxWindow *parent, wxWindowID id,
             const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, 
             long style = wxLI_HORIZONTAL, const wxString &name = wxStaticTextNameStr );
+
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
 };
 
 #endif 
index ca98ba9015e11245c8408d6ba95bdc5b01da89f8..eb9ee2a86ed5d47082c96a3ff89c2896b8db6b06 100644 (file)
@@ -59,6 +59,9 @@ public:
 
     bool SetFont( const wxFont &font );
     bool SetForegroundColour( const wxColour& colour );
+
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
     
     // implementation
     // --------------
index c3c585be05f44c83f87e4b1a23cad614a8073125..340d70d6658d1b0ae596ee09ae389022bf451e14 100644 (file)
@@ -56,6 +56,9 @@ public:
 
     virtual void SetWindowStyleFlag( long style );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation from now on
     // --------------------------
 
index 88ebbb41afc7271ca604ad3a3c97173795b377c0..7ca89491e652dc9699a68f0f6f0232315c2caed9 100644 (file)
@@ -162,6 +162,9 @@ public:
     // should we ignore the changed signal? always resets the flag
     bool IgnoreTextUpdate();
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
 protected:
     virtual wxSize DoGetBestSize() const;
 
@@ -175,6 +178,10 @@ protected:
     // scroll position changed
     bool DoScroll(GtkAdjustment *adj, int diff);
 
+    // Widgets that use the style->base colour for the BG colour should
+    // override this and return true.
+    virtual bool UseGTKStyleBase() const { return true; }
+
 private:
     // change the font for everything in this control
     void ChangeFontGlobally();
index 9d66c44797b54d9d7c58f5141b241883bb77627e..7da1777c18c496d03892a01b5f270380ef10a5c1 100644 (file)
@@ -66,7 +66,9 @@ public:
     void SetLabel(const wxBitmap& label);
     bool Enable(bool enable = TRUE);
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
     // implementation
     bool      m_blockEvent;
     wxBitmap  m_bitmap;
@@ -81,6 +83,7 @@ public:
 private:
     DECLARE_DYNAMIC_CLASS(wxToggleBitmapButton)
 };
+
 //-----------------------------------------------------------------------------
 // wxToggleButton
 //-----------------------------------------------------------------------------
@@ -119,6 +122,8 @@ public:
     void SetLabel(const wxString& label);
     bool Enable(bool enable = TRUE);
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
  
     // implementation
     bool m_blockEvent;
index 5c90c03e246c6af811697876638e8718edc8a7a8..3a55ddec52e9ae6d5e996178d0f456b172529934 100644 (file)
@@ -71,6 +71,9 @@ public:
     // to override this here too...
     virtual bool ShouldInheritColours() const { return false; }
     
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
 protected:
     virtual wxSize DoGetBestSize() const;
 
index 11f89e0a478bf38870c26fc7f69bc8554d685671..0fefb3c67cf9eb397ce089d95a20c8aee2145d25 100644 (file)
@@ -45,6 +45,9 @@ public:
     virtual void SetLabel( const wxString& label );
     virtual bool Enable( bool enable = TRUE );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     // --------------
 
index d738e3e253e614adda99eb9af47a8509fc5d0287..17ae9edeb229e2e666aa8fdddb7a96d6014656d4 100644 (file)
@@ -77,6 +77,9 @@ public:
     wxString GetString( int n ) const;
     void SetString( int n, const wxString& string );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
 protected:
     wxList m_clientList;    // contains the client data for the items
 
@@ -92,6 +95,7 @@ protected:
     virtual wxSize DoGetBestSize() const;
 
     virtual bool IsOwnGtkWindow( GdkWindow *window );
+
 private:
     // common part of Create() and DoAppend()
     int GtkAddHelper(GtkWidget *menu, int pos, const wxString& item);
index b3756066cc289528c49df240c94c9b8870088650..39bbb7ed548b924cb552ed31413a30e1690cb4cc 100644 (file)
@@ -134,6 +134,9 @@ public:
 
     wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
 protected:
     virtual int DoAppend(const wxString& item);
     virtual int DoInsert(const wxString& item, int pos);
@@ -145,6 +148,10 @@ protected:
 
     virtual wxSize DoGetBestSize() const;
 
+    // Widgets that use the style->base colour for the BG colour should
+    // override this and return true.
+    virtual bool UseGTKStyleBase() const { return true; }
+
 private:
     DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
     DECLARE_EVENT_TABLE()
index 38b277a8587debc95b2019b7aa826f70483610b9..be6f36bc1c395a6cc4c69d1c940cc381b08e44ab 100644 (file)
@@ -53,6 +53,8 @@ public:
     virtual void SetLabel( const wxString &label );
     virtual wxString GetLabel() const;
 
+    virtual wxVisualAttributes GetDefaultAttributes() const;
+
 protected:
     virtual wxSize DoGetBestSize() const;
     void PostCreation(const wxSize& size);
@@ -61,6 +63,29 @@ protected:
     wxString PrepareLabelMnemonics( const wxString &label ) const;
 #endif
 
+    // These are used by GetDefaultAttributes
+    static wxVisualAttributes
+        GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
+                                          bool useBase = false,
+                                          int state = -1);
+    static wxVisualAttributes
+        GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(void),
+                                          bool useBase = false,
+                                          int state = -1);
+    static wxVisualAttributes
+        GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(const gchar*),
+                                          bool useBase = false,
+                                          int state = -1);
+
+    static wxVisualAttributes
+        GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(GtkAdjustment*),
+                                          bool useBase = false,
+                                          int state = -1);
+
+    // Widgets that use the style->base colour for the BG colour should
+    // override this and return true.
+    virtual bool UseGTKStyleBase() const { return false; }
+
     wxString   m_label;
     char       m_chAccel;  // enabled to avoid breaking binary compatibility later on
 
index 5ca47abcf643511403dfdb8e688878edcf52670f..5652b6b5cbc0c31798aac0e982ab2ae694d76c13 100644 (file)
@@ -77,6 +77,9 @@ public:
 
     bool IsVertical() const { return HasFlag(wxGA_VERTICAL); }
     
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     // -------------
 
@@ -100,6 +103,8 @@ protected:
 
     virtual wxSize DoGetBestSize() const;
 
+    virtual wxVisualAttributes GetDefaultAttributes() const;
+
 private:
     DECLARE_DYNAMIC_CLASS(wxGauge)
 };
index 7974011566c330fd78e44a99574c26bb6963a52c..ff8d595c6c57e0fdd6e2318cd6fe2ead189a6a60 100644 (file)
@@ -96,6 +96,9 @@ public:
     virtual void DoSetItemClientObject(int n, wxClientData* clientData);
     virtual wxClientData* DoGetItemClientObject(int n) const;
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation from now on
 
     void GtkAddItem( const wxString &item, int pos=-1 );
@@ -127,6 +130,10 @@ protected:
     // return the string label for the given item
     wxString GetRealLabel(struct _GList *item) const;
 
+    // Widgets that use the style->base colour for the BG colour should
+    // override this and return true.
+    virtual bool UseGTKStyleBase() const { return true; }
+
 private:
     // this array is only used for controls with wxCB_SORT style, so only
     // allocate it if it's needed (hence using pointer)
index 9dfef193c1f5b1d51b1d5e649108c0bff666d2fc..664eb5f1993558a22326b82dff7ea10ea75369c7 100644 (file)
@@ -98,6 +98,10 @@ public:
     // --------------------------
     void OnNavigationKey(wxNavigationKeyEvent& event);
 
+
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     // --------------
 
index cfdcef9c94b7e7db4028230b3504acd745adc999..882bda03579e3298fac5f5971faf3508a4561685 100644 (file)
@@ -111,6 +111,9 @@ public:
     virtual bool Show( bool show = TRUE );
     virtual bool Enable( bool enable = TRUE );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
     // implementation
     // --------------
 
index af716335eab44068a179abf2805f10ea244a365a..39c442216f2d6ae3e67651973614e0d1bd26eb7d 100644 (file)
@@ -49,6 +49,9 @@ public:
     virtual bool GetValue() const;
     virtual bool Enable( bool enable = TRUE );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
     // implementation
 
     virtual bool IsRadioButton() const { return TRUE; }
index 4f43d99e7e954d0ac686b8862c33623957494de2..8ce5e82897110387af9b9f44f09f3a9bd632a37a 100644 (file)
@@ -68,6 +68,9 @@ public:
     void SetObjectLength( int objectLength );
     void SetViewLength( int viewLength );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     // --------------
 
index 945c726ededcf7915ed8bd2f5dd675a8a7fca5ef..bd4af3fcad80204c6f66b406197cf43a8518b036 100644 (file)
@@ -60,6 +60,9 @@ public:
     virtual void SetThumbLength(int lenPixels);
     virtual int GetThumbLength() const;
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     bool IsOwnGtkWindow( GdkWindow *window );
     void ApplyWidgetStyle();
index ce80a907e56fc5fab06c829f43fa907f346d2d2c..dfe3c40c056a4a7869fd71cda82d95775ebbb7bc 100644 (file)
@@ -46,6 +46,9 @@ public:
     virtual int GetMin() const;
     virtual int GetMax() const;
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     void OnSize( wxSizeEvent &event );
 
index f39e5184e632f7d2c3f69c29651e5e161d23d1dc..425f31f3353837d33e85d5260ffbf4f75dd8e90a 100644 (file)
@@ -59,6 +59,9 @@ public:
     virtual int GetMin() const;
     virtual int GetMax() const;
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation
     void OnChar( wxKeyEvent &event );
     
@@ -73,6 +76,10 @@ public:
 protected:
     virtual wxSize DoGetBestSize() const;
 
+    // Widgets that use the style->base colour for the BG colour should
+    // override this and return true.
+    virtual bool UseGTKStyleBase() const { return true; }
+
 private:
     DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
     DECLARE_EVENT_TABLE()
index 642e70844846235ccc6c4c14e9097f7780df00df..00677618dea55eeacadb6f151320192617688375 100644 (file)
@@ -52,6 +52,9 @@ public:
         return (const wxIcon &)m_bitmap;
     }
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
 private:
     // creates the new pixmap widget
     void CreatePixmapWidget();
index fa4d65228ad46eddbe28a2c8fdf3d112dc9cbc35..f0f1b2ff0efa759927040514fed86b3a701bf608 100644 (file)
@@ -40,6 +40,9 @@ public:
 
     virtual void SetLabel( const wxString &label );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
     // implementation
 
     virtual void ApplyWidgetStyle();
index 2324b012049032517a25f148f14f85898b80ada0..803ae2018acb3f06ab5b3c697c629e97a5541396 100644 (file)
@@ -45,6 +45,10 @@ public:
     bool Create(  wxWindow *parent, wxWindowID id,
             const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, 
             long style = wxLI_HORIZONTAL, const wxString &name = wxStaticTextNameStr );
+
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
 };
 
 #endif 
index ca98ba9015e11245c8408d6ba95bdc5b01da89f8..eb9ee2a86ed5d47082c96a3ff89c2896b8db6b06 100644 (file)
@@ -59,6 +59,9 @@ public:
 
     bool SetFont( const wxFont &font );
     bool SetForegroundColour( const wxColour& colour );
+
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
     
     // implementation
     // --------------
index c3c585be05f44c83f87e4b1a23cad614a8073125..340d70d6658d1b0ae596ee09ae389022bf451e14 100644 (file)
@@ -56,6 +56,9 @@ public:
 
     virtual void SetWindowStyleFlag( long style );
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation from now on
     // --------------------------
 
index 88ebbb41afc7271ca604ad3a3c97173795b377c0..7ca89491e652dc9699a68f0f6f0232315c2caed9 100644 (file)
@@ -162,6 +162,9 @@ public:
     // should we ignore the changed signal? always resets the flag
     bool IgnoreTextUpdate();
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
 protected:
     virtual wxSize DoGetBestSize() const;
 
@@ -175,6 +178,10 @@ protected:
     // scroll position changed
     bool DoScroll(GtkAdjustment *adj, int diff);
 
+    // Widgets that use the style->base colour for the BG colour should
+    // override this and return true.
+    virtual bool UseGTKStyleBase() const { return true; }
+
 private:
     // change the font for everything in this control
     void ChangeFontGlobally();
index 9d66c44797b54d9d7c58f5141b241883bb77627e..7da1777c18c496d03892a01b5f270380ef10a5c1 100644 (file)
@@ -66,7 +66,9 @@ public:
     void SetLabel(const wxBitmap& label);
     bool Enable(bool enable = TRUE);
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
     // implementation
     bool      m_blockEvent;
     wxBitmap  m_bitmap;
@@ -81,6 +83,7 @@ public:
 private:
     DECLARE_DYNAMIC_CLASS(wxToggleBitmapButton)
 };
+
 //-----------------------------------------------------------------------------
 // wxToggleButton
 //-----------------------------------------------------------------------------
@@ -119,6 +122,8 @@ public:
     void SetLabel(const wxString& label);
     bool Enable(bool enable = TRUE);
 
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
  
     // implementation
     bool m_blockEvent;
index 1fc794b7636fd7f24e84e0b957ca1611a37b7925..4638f0a6b1d0f74dc7b42339d6f7a7c0f7ac6def 100644 (file)
@@ -232,5 +232,12 @@ wxSize wxButton::DoGetBestSize() const
     return ret;
 }
 
+// static
+wxVisualAttributes
+wxButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_button_new);
+}
+
 #endif // wxUSE_BUTTON
 
index 33437d0b08207032d8ce9cf5f29e23ef06d803ef..e7fe520d4dfebb7a1a65f3f58ed690398914b493 100644 (file)
@@ -216,4 +216,11 @@ wxSize wxCheckBox::DoGetBestSize() const
     return wxControl::DoGetBestSize();
 }
 
+// static
+wxVisualAttributes
+wxCheckBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_check_button_new);
+}
+
 #endif
index 9c63f8502ff7e0eacd4bb65878359d3e5485853b..384f8b5d0048366b24c45f4d8736dff21b23c026 100644 (file)
@@ -574,6 +574,13 @@ bool wxChoice::IsOwnGtkWindow( GdkWindow *window )
 #endif
 }
 
+// static
+wxVisualAttributes
+wxChoice::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_option_menu_new);
+}
+
 
 #endif // wxUSE_CHOICE
 
index 2972a0a99858f706c304259c1687bd69836724ae..f7950f67bfc11b12521d176521355ad21f0c6f79 100644 (file)
@@ -779,4 +779,11 @@ wxSize wxComboBox::DoGetBestSize() const
     return ret;
 }
 
+// static
+wxVisualAttributes
+wxComboBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_combo_new, true);
+}
+
 #endif
index 8e3e23ee5756e97f49cfe2989957bb73497bfd27..dfbfe4b9c0eba7cf531840269c3c511f5c72f6eb 100644 (file)
@@ -19,6 +19,8 @@
 #if wxUSE_CONTROLS
 
 #include "wx/control.h"
+#include "wx/fontutil.h"
+#include "wx/settings.h"
 
 #include <gtk/gtk.h>
 
@@ -140,5 +142,123 @@ wxString wxControl::PrepareLabelMnemonics( const wxString &label ) const
 }
 #endif
 
+
+wxVisualAttributes wxControl::GetDefaultAttributes() const
+{
+    return GetDefaultAttributesFromGTKWidget(m_widget,
+                                             UseGTKStyleBase());
+}
+
+
+#define SHIFT (8*(sizeof(short int)-sizeof(char)))
+
+// static
+wxVisualAttributes
+wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
+                                             bool useBase,
+                                             int state)
+{
+    GtkStyle* style;
+    wxVisualAttributes attr;
+
+    style = gtk_rc_get_style(widget);
+    if (!style)
+        style = gtk_widget_get_default_style();
+
+    if (!style)
+    {
+        return wxWindow::GetClassDefaultAttributes(wxWINDOW_VARIANT_NORMAL);
+    }
+
+    if (state == -1)
+        state = GTK_STATE_NORMAL;
+        
+    // get the style's colours
+    attr.colFg = wxColour(style->fg[state].red   >> SHIFT,
+                          style->fg[state].green >> SHIFT,
+                          style->fg[state].blue  >> SHIFT);
+    if (useBase)
+        attr.colBg = wxColour(style->base[state].red   >> SHIFT,
+                              style->base[state].green >> SHIFT,
+                              style->base[state].blue  >> SHIFT);
+    else
+        attr.colBg = wxColour(style->bg[state].red   >> SHIFT,
+                              style->bg[state].green >> SHIFT,
+                              style->bg[state].blue  >> SHIFT);
+
+    // get the style's font
+#ifdef __WXGTK20__
+    if ( !style->font_desc )
+        style = gtk_widget_get_default_style();  
+    if ( style && style->font_desc )
+    {  
+        wxNativeFontInfo info;  
+        info.description = style->font_desc;  
+        attr.font = wxFont(info);  
+    }  
+    else  
+    {  
+        GtkSettings *settings = gtk_settings_get_default();
+        gchar *font_name = NULL;
+        g_object_get ( settings,
+                       "gtk-font-name", 
+                       &font_name,
+                       NULL);
+        if (!font_name)
+            attr.font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
+        else
+            attr.font = wxFont(wxString::FromAscii(font_name));
+        g_free (font_name);
+    }  
+#else
+    // TODO: isn't there a way to get a standard gtk 1.2 font?
+    attr.font = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
+#endif
+    
+    return attr;
+}
+
+
+//static
+wxVisualAttributes
+wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(void),
+                                             bool useBase,
+                                             int state)
+{
+    wxVisualAttributes attr;
+    GtkWidget* widget = widget_new();
+    attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state);
+    gtk_widget_destroy(widget);
+    return attr;
+}
+
+//static
+wxVisualAttributes
+wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(const gchar*),
+                                             bool useBase,
+                                             int state)
+{
+    wxVisualAttributes attr;
+    GtkWidget* widget = widget_new("");
+    attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state);
+    gtk_widget_destroy(widget);
+    return attr;
+}
+
+
+//static
+wxVisualAttributes
+wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(GtkAdjustment*),
+                                             bool useBase,
+                                             int state)
+{
+    wxVisualAttributes attr;
+    GtkWidget* widget = widget_new(NULL);
+    attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state);
+    gtk_widget_destroy(widget);
+    return attr;
+}
+
+
 #endif // wxUSE_CONTROLS
 
index 54360ce314f8da049eef15184831e8535c28b38b..b6cd78c4c5a4c1905bc56b3a5e8eef5647d59999 100644 (file)
@@ -112,5 +112,22 @@ void wxGauge::ApplyWidgetStyle()
     gtk_widget_set_style( m_widget, m_widgetStyle );
 }
 
+wxVisualAttributes wxGauge::GetDefaultAttributes() const
+{
+    // Visible gauge colours use a different colour state
+    return GetDefaultAttributesFromGTKWidget(m_widget,
+                                             UseGTKStyleBase(),
+                                             GTK_STATE_ACTIVE);
+
+}
+
+// static
+wxVisualAttributes
+wxGauge::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_progress_bar_new,
+                                             false, GTK_STATE_ACTIVE);
+}
+
 #endif // wxUSE_GAUGE
 
index 3436dae15661ebf53b883a90dff336f93b910dc5..9f06846793b89a0ec9f6bc8d1c08952555abad4d 100644 (file)
@@ -1087,5 +1087,13 @@ void wxListBox::FixUpMouseEvent(GtkWidget *widget, wxCoord& x, wxCoord& y)
     y += widget->allocation.y;
 }
 
+
+// static
+wxVisualAttributes
+wxListBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_list_new, true);
+}
+
 #endif // wxUSE_LISTBOX
 
index 25edf2c1105058f75d15fe9c82dcc7659dc1b4b7..ded15fb845915efd490238294dddbcc25abca147 100644 (file)
@@ -866,6 +866,13 @@ bool  wxNotebook::SetFont(const wxFont& font)
        return rc;
 }
 
+// static
+wxVisualAttributes
+wxNotebook::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_notebook_new);
+}
+
 //-----------------------------------------------------------------------------
 // wxNotebookEvent
 //-----------------------------------------------------------------------------
index 37c9f529f2ea800779d6bbcc102239402925b545..3538f3c037a96e6fbb6564bd02011d03755af2a7 100644 (file)
@@ -752,5 +752,16 @@ void wxRadioBox::OnInternalIdle()
     }
 }
 
+// static
+wxVisualAttributes
+wxRadioBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    wxVisualAttributes attr;
+    GtkWidget* widget = gtk_radio_button_new_with_label(NULL, "");
+    attr = GetDefaultAttributesFromGTKWidget(widget);
+    gtk_widget_destroy(widget);
+    return attr;
+}
+
 #endif // wxUSE_RADIOBOX
 
index 1fd39b77fba8688504a2b5e62c0181ed5c222377..c03a82e438a66b5684935008c37d4f93e33ee2ef 100644 (file)
@@ -233,4 +233,16 @@ wxSize wxRadioButton::DoGetBestSize() const
     return wxControl::DoGetBestSize();
 }
 
+// static
+wxVisualAttributes
+wxRadioButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    wxVisualAttributes attr;
+    GtkWidget* widget = gtk_radio_button_new_with_label(NULL, "");
+    attr = GetDefaultAttributesFromGTKWidget(widget);
+    gtk_widget_destroy(widget);
+    return attr;
+}
+
+
 #endif
index 4aa408af1f440c51ac5a7e496176669d8600dc2a..6dcd71ec52c1cf16b1a9837e02189e8fd015c646 100644 (file)
@@ -336,4 +336,11 @@ wxSize wxScrollBar::DoGetBestSize() const
     return wxControl::DoGetBestSize();
 }
 
+// static
+wxVisualAttributes
+wxScrollBar::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_vscrollbar_new);
+}
+
 #endif
index 2dcc57d58ec2b56d374885209260935a3f0bbfeb..e7079c5c1018e46500b5fa262d1190f1bb368a49 100644 (file)
@@ -286,4 +286,11 @@ void wxSlider::GtkEnableEvents()
                         (gpointer) this );
 }
 
+// static
+wxVisualAttributes
+wxSlider::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_vscale_new);
+}
+
 #endif
index f0db6cb58b897f76b7d2fe3cd2b9a6607c50b35c..423947a1d359eacb17617e3d9de272bb0f7fd386 100644 (file)
@@ -236,4 +236,13 @@ wxSize wxSpinButton::DoGetBestSize() const
     return wxSize(15, 26);
 }
 
+// static
+wxVisualAttributes
+wxSpinButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    // TODO: overload to accept functions like gtk_spin_button_new?
+    // Until then use a similar type
+    return GetDefaultAttributesFromGTKWidget(gtk_button_new);
+}
+
 #endif
index e5d32a1f85110deff169df24020af8c7e714a35e..45cc31f6b839d06390cb7045648872305158a872 100644 (file)
@@ -310,5 +310,14 @@ wxSize wxSpinCtrl::DoGetBestSize() const
     return wxSize(95, ret.y);
 }
 
+// static
+wxVisualAttributes
+wxSpinCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    // TODO: overload to accept functions like gtk_spin_button_new?
+    // Until then use a similar type
+    return GetDefaultAttributesFromGTKWidget(gtk_entry_new, true);
+}
+
 #endif
    // wxUSE_SPINCTRL
index 9d206950ea3ae8e26bf9f083fd0f342d94518c25..48a8dafe73e7241e5735e3dacecd62cb3755b5d3 100644 (file)
@@ -117,5 +117,13 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
     }
 }
 
+// static
+wxVisualAttributes
+wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    // TODO: overload to allow using gtk_pixmap_new?
+    return GetDefaultAttributesFromGTKWidget(gtk_label_new);
+}
+
 #endif // wxUSE_STATBMP
 
index 3bf811a25be7d0b8ae87c68b2971921205d975e1..879e2bc579d1ceaad9741358e4411e8e86f277ff 100644 (file)
@@ -97,4 +97,11 @@ void wxStaticBox::ApplyWidgetStyle()
     gtk_widget_set_style( m_widget, m_widgetStyle );
 }
 
+// static
+wxVisualAttributes
+wxStaticBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_frame_new);
+}
+
 #endif // wxUSE_STATBOX
index d10067f6acd179fe56bff23063ccb29b3bc73452..3f95edd803b53931fa465226d912df09c52624fa 100644 (file)
@@ -79,4 +79,11 @@ bool wxStaticLine::Create( wxWindow *parent, wxWindowID id,
     return TRUE;
 }
 
+// static
+wxVisualAttributes
+wxStaticLine::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_vseparator_new);
+}
+
 #endif
index 7073bcd6ccafc9d431f923c1cb6caf64bdade0ec..89594853ae3c86e34eaf5be907cc7d4a3c47a08e 100644 (file)
@@ -199,4 +199,11 @@ bool wxStaticText::SetForegroundColour(const wxColour& colour)
     return true;
 }
 
+// static
+wxVisualAttributes
+wxStaticText::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_label_new);
+}
+
 #endif // wxUSE_STATTEXT
index 61804aa0488364fa2c1195df8cf66fde3dafce75..3360929f68c4371d596ec600209d5fc77c4b856e 100644 (file)
@@ -703,4 +703,22 @@ void wxToolBar::OnInternalIdle()
         UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
 }
 
+
+// ----------------------------------------------------------------------------
+
+// static
+wxVisualAttributes
+wxToolBar::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+#ifdef __WXGTK20__
+    return GetDefaultAttributesFromGTKWidget(gtk_toolbar_new);
+#else
+    wxVisualAttributes attr;
+    GtkWidget* widget = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
+    attr = GetDefaultAttributesFromGTKWidget(widget);
+    gtk_widget_destroy(widget);
+    return attr;
+#endif
+}
+
 #endif // wxUSE_TOOLBAR_NATIVE
index 815c0c66ac1831ac5efc95e010abb50da11fdd39..f37ca3d41ee4adca008aa5d64f7c70178ec0b48d 100644 (file)
@@ -303,7 +303,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
         gtk_container_add( GTK_CONTAINER(m_widget), m_text );
 
         // Global settings which can be overridden by tags, I guess.
-        if (HasFlag( wxHSCROLL ))
+        if (HasFlag( wxHSCROLL ) || HasFlag( wxTE_DONTWRAP ))
             gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), GTK_WRAP_NONE );
         else
             gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), GTK_WRAP_WORD );
@@ -415,16 +415,16 @@ bool wxTextCtrl::Create( wxWindow *parent,
 #ifdef __WXGTK20__
         else
             gtk_text_view_set_editable( GTK_TEXT_VIEW( m_text), FALSE);
-    }
 #else
     }
     else
     {
         if (multi_line)
             gtk_text_set_editable( GTK_TEXT(m_text), 1 );
-    }
 #endif
+    }
 
+    
     // We want to be notified about text changes.
 #ifdef __WXGTK20__
     if (multi_line)
@@ -434,26 +434,21 @@ bool wxTextCtrl::Create( wxWindow *parent,
     }
     else
 #endif
+    
     {
         gtk_signal_connect( GTK_OBJECT(m_text), "changed",
             GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
     }
 
-    // we don't set a valid background colour, because the window
-    // manager should use a default one
-    m_backgroundColour = wxColour();
-
-    wxColour colFg = parent->GetForegroundColour();
-    SetForegroundColour( colFg );
-
     m_cursor = wxCursor( wxCURSOR_IBEAM );
 
-    wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() );
+    wxTextAttr attrDef(GetForegroundColour(), GetBackgroundColour(), GetFont());
     SetDefaultStyle( attrDef );
 
     return TRUE;
 }
 
+
 void wxTextCtrl::CalculateScrollbar()
 {
 #ifndef __WXGTK20__
@@ -1522,11 +1517,11 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style )
 
 void wxTextCtrl::ApplyWidgetStyle()
 {
-    if (m_windowStyle & wxTE_MULTILINE)
-    {
-        // how ?
-    }
-    else
+//     if (m_windowStyle & wxTE_MULTILINE)
+//     {
+//         // how ?
+//     }
+//     else
     {
         SetWidgetStyle();
         gtk_widget_set_style( m_text, m_widgetStyle );
@@ -1724,3 +1719,10 @@ bool wxTextCtrl::ScrollPages(int pages)
 #endif
 }
 
+
+// static
+wxVisualAttributes
+wxTextCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_entry_new, true);
+}
index 4d57e220cf5ecf7898cd670b518d70819daa73d8..d8aac966f6ada216abb5e384c9177a70e342c586 100644 (file)
@@ -207,6 +207,16 @@ wxSize wxToggleBitmapButton::DoGetBestSize() const
     }
     return best;
 }
+
+
+// static
+wxVisualAttributes
+wxToggleBitmapButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_toggle_button_new);
+}
+
+
 // ------------------------------------------------------------------------
 // wxToggleButton
 // ------------------------------------------------------------------------
@@ -339,5 +349,12 @@ wxSize wxToggleButton::DoGetBestSize() const
    return ret;
 }
 
+// static
+wxVisualAttributes
+wxToggleButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_toggle_button_new);
+}
+
 #endif // wxUSE_TOGGLEBTN
 
index 1fc794b7636fd7f24e84e0b957ca1611a37b7925..4638f0a6b1d0f74dc7b42339d6f7a7c0f7ac6def 100644 (file)
@@ -232,5 +232,12 @@ wxSize wxButton::DoGetBestSize() const
     return ret;
 }
 
+// static
+wxVisualAttributes
+wxButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_button_new);
+}
+
 #endif // wxUSE_BUTTON
 
index 33437d0b08207032d8ce9cf5f29e23ef06d803ef..e7fe520d4dfebb7a1a65f3f58ed690398914b493 100644 (file)
@@ -216,4 +216,11 @@ wxSize wxCheckBox::DoGetBestSize() const
     return wxControl::DoGetBestSize();
 }
 
+// static
+wxVisualAttributes
+wxCheckBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_check_button_new);
+}
+
 #endif
index 9c63f8502ff7e0eacd4bb65878359d3e5485853b..384f8b5d0048366b24c45f4d8736dff21b23c026 100644 (file)
@@ -574,6 +574,13 @@ bool wxChoice::IsOwnGtkWindow( GdkWindow *window )
 #endif
 }
 
+// static
+wxVisualAttributes
+wxChoice::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_option_menu_new);
+}
+
 
 #endif // wxUSE_CHOICE
 
index 2972a0a99858f706c304259c1687bd69836724ae..f7950f67bfc11b12521d176521355ad21f0c6f79 100644 (file)
@@ -779,4 +779,11 @@ wxSize wxComboBox::DoGetBestSize() const
     return ret;
 }
 
+// static
+wxVisualAttributes
+wxComboBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_combo_new, true);
+}
+
 #endif
index 8e3e23ee5756e97f49cfe2989957bb73497bfd27..dfbfe4b9c0eba7cf531840269c3c511f5c72f6eb 100644 (file)
@@ -19,6 +19,8 @@
 #if wxUSE_CONTROLS
 
 #include "wx/control.h"
+#include "wx/fontutil.h"
+#include "wx/settings.h"
 
 #include <gtk/gtk.h>
 
@@ -140,5 +142,123 @@ wxString wxControl::PrepareLabelMnemonics( const wxString &label ) const
 }
 #endif
 
+
+wxVisualAttributes wxControl::GetDefaultAttributes() const
+{
+    return GetDefaultAttributesFromGTKWidget(m_widget,
+                                             UseGTKStyleBase());
+}
+
+
+#define SHIFT (8*(sizeof(short int)-sizeof(char)))
+
+// static
+wxVisualAttributes
+wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
+                                             bool useBase,
+                                             int state)
+{
+    GtkStyle* style;
+    wxVisualAttributes attr;
+
+    style = gtk_rc_get_style(widget);
+    if (!style)
+        style = gtk_widget_get_default_style();
+
+    if (!style)
+    {
+        return wxWindow::GetClassDefaultAttributes(wxWINDOW_VARIANT_NORMAL);
+    }
+
+    if (state == -1)
+        state = GTK_STATE_NORMAL;
+        
+    // get the style's colours
+    attr.colFg = wxColour(style->fg[state].red   >> SHIFT,
+                          style->fg[state].green >> SHIFT,
+                          style->fg[state].blue  >> SHIFT);
+    if (useBase)
+        attr.colBg = wxColour(style->base[state].red   >> SHIFT,
+                              style->base[state].green >> SHIFT,
+                              style->base[state].blue  >> SHIFT);
+    else
+        attr.colBg = wxColour(style->bg[state].red   >> SHIFT,
+                              style->bg[state].green >> SHIFT,
+                              style->bg[state].blue  >> SHIFT);
+
+    // get the style's font
+#ifdef __WXGTK20__
+    if ( !style->font_desc )
+        style = gtk_widget_get_default_style();  
+    if ( style && style->font_desc )
+    {  
+        wxNativeFontInfo info;  
+        info.description = style->font_desc;  
+        attr.font = wxFont(info);  
+    }  
+    else  
+    {  
+        GtkSettings *settings = gtk_settings_get_default();
+        gchar *font_name = NULL;
+        g_object_get ( settings,
+                       "gtk-font-name", 
+                       &font_name,
+                       NULL);
+        if (!font_name)
+            attr.font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
+        else
+            attr.font = wxFont(wxString::FromAscii(font_name));
+        g_free (font_name);
+    }  
+#else
+    // TODO: isn't there a way to get a standard gtk 1.2 font?
+    attr.font = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
+#endif
+    
+    return attr;
+}
+
+
+//static
+wxVisualAttributes
+wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(void),
+                                             bool useBase,
+                                             int state)
+{
+    wxVisualAttributes attr;
+    GtkWidget* widget = widget_new();
+    attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state);
+    gtk_widget_destroy(widget);
+    return attr;
+}
+
+//static
+wxVisualAttributes
+wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(const gchar*),
+                                             bool useBase,
+                                             int state)
+{
+    wxVisualAttributes attr;
+    GtkWidget* widget = widget_new("");
+    attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state);
+    gtk_widget_destroy(widget);
+    return attr;
+}
+
+
+//static
+wxVisualAttributes
+wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* (*widget_new)(GtkAdjustment*),
+                                             bool useBase,
+                                             int state)
+{
+    wxVisualAttributes attr;
+    GtkWidget* widget = widget_new(NULL);
+    attr = GetDefaultAttributesFromGTKWidget(widget, useBase, state);
+    gtk_widget_destroy(widget);
+    return attr;
+}
+
+
 #endif // wxUSE_CONTROLS
 
index 54360ce314f8da049eef15184831e8535c28b38b..b6cd78c4c5a4c1905bc56b3a5e8eef5647d59999 100644 (file)
@@ -112,5 +112,22 @@ void wxGauge::ApplyWidgetStyle()
     gtk_widget_set_style( m_widget, m_widgetStyle );
 }
 
+wxVisualAttributes wxGauge::GetDefaultAttributes() const
+{
+    // Visible gauge colours use a different colour state
+    return GetDefaultAttributesFromGTKWidget(m_widget,
+                                             UseGTKStyleBase(),
+                                             GTK_STATE_ACTIVE);
+
+}
+
+// static
+wxVisualAttributes
+wxGauge::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_progress_bar_new,
+                                             false, GTK_STATE_ACTIVE);
+}
+
 #endif // wxUSE_GAUGE
 
index 3436dae15661ebf53b883a90dff336f93b910dc5..9f06846793b89a0ec9f6bc8d1c08952555abad4d 100644 (file)
@@ -1087,5 +1087,13 @@ void wxListBox::FixUpMouseEvent(GtkWidget *widget, wxCoord& x, wxCoord& y)
     y += widget->allocation.y;
 }
 
+
+// static
+wxVisualAttributes
+wxListBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_list_new, true);
+}
+
 #endif // wxUSE_LISTBOX
 
index 25edf2c1105058f75d15fe9c82dcc7659dc1b4b7..ded15fb845915efd490238294dddbcc25abca147 100644 (file)
@@ -866,6 +866,13 @@ bool  wxNotebook::SetFont(const wxFont& font)
        return rc;
 }
 
+// static
+wxVisualAttributes
+wxNotebook::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_notebook_new);
+}
+
 //-----------------------------------------------------------------------------
 // wxNotebookEvent
 //-----------------------------------------------------------------------------
index 37c9f529f2ea800779d6bbcc102239402925b545..3538f3c037a96e6fbb6564bd02011d03755af2a7 100644 (file)
@@ -752,5 +752,16 @@ void wxRadioBox::OnInternalIdle()
     }
 }
 
+// static
+wxVisualAttributes
+wxRadioBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    wxVisualAttributes attr;
+    GtkWidget* widget = gtk_radio_button_new_with_label(NULL, "");
+    attr = GetDefaultAttributesFromGTKWidget(widget);
+    gtk_widget_destroy(widget);
+    return attr;
+}
+
 #endif // wxUSE_RADIOBOX
 
index 1fd39b77fba8688504a2b5e62c0181ed5c222377..c03a82e438a66b5684935008c37d4f93e33ee2ef 100644 (file)
@@ -233,4 +233,16 @@ wxSize wxRadioButton::DoGetBestSize() const
     return wxControl::DoGetBestSize();
 }
 
+// static
+wxVisualAttributes
+wxRadioButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    wxVisualAttributes attr;
+    GtkWidget* widget = gtk_radio_button_new_with_label(NULL, "");
+    attr = GetDefaultAttributesFromGTKWidget(widget);
+    gtk_widget_destroy(widget);
+    return attr;
+}
+
+
 #endif
index 4aa408af1f440c51ac5a7e496176669d8600dc2a..6dcd71ec52c1cf16b1a9837e02189e8fd015c646 100644 (file)
@@ -336,4 +336,11 @@ wxSize wxScrollBar::DoGetBestSize() const
     return wxControl::DoGetBestSize();
 }
 
+// static
+wxVisualAttributes
+wxScrollBar::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_vscrollbar_new);
+}
+
 #endif
index 2dcc57d58ec2b56d374885209260935a3f0bbfeb..e7079c5c1018e46500b5fa262d1190f1bb368a49 100644 (file)
@@ -286,4 +286,11 @@ void wxSlider::GtkEnableEvents()
                         (gpointer) this );
 }
 
+// static
+wxVisualAttributes
+wxSlider::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_vscale_new);
+}
+
 #endif
index f0db6cb58b897f76b7d2fe3cd2b9a6607c50b35c..423947a1d359eacb17617e3d9de272bb0f7fd386 100644 (file)
@@ -236,4 +236,13 @@ wxSize wxSpinButton::DoGetBestSize() const
     return wxSize(15, 26);
 }
 
+// static
+wxVisualAttributes
+wxSpinButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    // TODO: overload to accept functions like gtk_spin_button_new?
+    // Until then use a similar type
+    return GetDefaultAttributesFromGTKWidget(gtk_button_new);
+}
+
 #endif
index e5d32a1f85110deff169df24020af8c7e714a35e..45cc31f6b839d06390cb7045648872305158a872 100644 (file)
@@ -310,5 +310,14 @@ wxSize wxSpinCtrl::DoGetBestSize() const
     return wxSize(95, ret.y);
 }
 
+// static
+wxVisualAttributes
+wxSpinCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    // TODO: overload to accept functions like gtk_spin_button_new?
+    // Until then use a similar type
+    return GetDefaultAttributesFromGTKWidget(gtk_entry_new, true);
+}
+
 #endif
    // wxUSE_SPINCTRL
index 9d206950ea3ae8e26bf9f083fd0f342d94518c25..48a8dafe73e7241e5735e3dacecd62cb3755b5d3 100644 (file)
@@ -117,5 +117,13 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
     }
 }
 
+// static
+wxVisualAttributes
+wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    // TODO: overload to allow using gtk_pixmap_new?
+    return GetDefaultAttributesFromGTKWidget(gtk_label_new);
+}
+
 #endif // wxUSE_STATBMP
 
index 3bf811a25be7d0b8ae87c68b2971921205d975e1..879e2bc579d1ceaad9741358e4411e8e86f277ff 100644 (file)
@@ -97,4 +97,11 @@ void wxStaticBox::ApplyWidgetStyle()
     gtk_widget_set_style( m_widget, m_widgetStyle );
 }
 
+// static
+wxVisualAttributes
+wxStaticBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_frame_new);
+}
+
 #endif // wxUSE_STATBOX
index d10067f6acd179fe56bff23063ccb29b3bc73452..3f95edd803b53931fa465226d912df09c52624fa 100644 (file)
@@ -79,4 +79,11 @@ bool wxStaticLine::Create( wxWindow *parent, wxWindowID id,
     return TRUE;
 }
 
+// static
+wxVisualAttributes
+wxStaticLine::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_vseparator_new);
+}
+
 #endif
index 7073bcd6ccafc9d431f923c1cb6caf64bdade0ec..89594853ae3c86e34eaf5be907cc7d4a3c47a08e 100644 (file)
@@ -199,4 +199,11 @@ bool wxStaticText::SetForegroundColour(const wxColour& colour)
     return true;
 }
 
+// static
+wxVisualAttributes
+wxStaticText::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_label_new);
+}
+
 #endif // wxUSE_STATTEXT
index 61804aa0488364fa2c1195df8cf66fde3dafce75..3360929f68c4371d596ec600209d5fc77c4b856e 100644 (file)
@@ -703,4 +703,22 @@ void wxToolBar::OnInternalIdle()
         UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
 }
 
+
+// ----------------------------------------------------------------------------
+
+// static
+wxVisualAttributes
+wxToolBar::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+#ifdef __WXGTK20__
+    return GetDefaultAttributesFromGTKWidget(gtk_toolbar_new);
+#else
+    wxVisualAttributes attr;
+    GtkWidget* widget = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
+    attr = GetDefaultAttributesFromGTKWidget(widget);
+    gtk_widget_destroy(widget);
+    return attr;
+#endif
+}
+
 #endif // wxUSE_TOOLBAR_NATIVE
index 815c0c66ac1831ac5efc95e010abb50da11fdd39..f37ca3d41ee4adca008aa5d64f7c70178ec0b48d 100644 (file)
@@ -303,7 +303,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
         gtk_container_add( GTK_CONTAINER(m_widget), m_text );
 
         // Global settings which can be overridden by tags, I guess.
-        if (HasFlag( wxHSCROLL ))
+        if (HasFlag( wxHSCROLL ) || HasFlag( wxTE_DONTWRAP ))
             gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), GTK_WRAP_NONE );
         else
             gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), GTK_WRAP_WORD );
@@ -415,16 +415,16 @@ bool wxTextCtrl::Create( wxWindow *parent,
 #ifdef __WXGTK20__
         else
             gtk_text_view_set_editable( GTK_TEXT_VIEW( m_text), FALSE);
-    }
 #else
     }
     else
     {
         if (multi_line)
             gtk_text_set_editable( GTK_TEXT(m_text), 1 );
-    }
 #endif
+    }
 
+    
     // We want to be notified about text changes.
 #ifdef __WXGTK20__
     if (multi_line)
@@ -434,26 +434,21 @@ bool wxTextCtrl::Create( wxWindow *parent,
     }
     else
 #endif
+    
     {
         gtk_signal_connect( GTK_OBJECT(m_text), "changed",
             GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
     }
 
-    // we don't set a valid background colour, because the window
-    // manager should use a default one
-    m_backgroundColour = wxColour();
-
-    wxColour colFg = parent->GetForegroundColour();
-    SetForegroundColour( colFg );
-
     m_cursor = wxCursor( wxCURSOR_IBEAM );
 
-    wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() );
+    wxTextAttr attrDef(GetForegroundColour(), GetBackgroundColour(), GetFont());
     SetDefaultStyle( attrDef );
 
     return TRUE;
 }
 
+
 void wxTextCtrl::CalculateScrollbar()
 {
 #ifndef __WXGTK20__
@@ -1522,11 +1517,11 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style )
 
 void wxTextCtrl::ApplyWidgetStyle()
 {
-    if (m_windowStyle & wxTE_MULTILINE)
-    {
-        // how ?
-    }
-    else
+//     if (m_windowStyle & wxTE_MULTILINE)
+//     {
+//         // how ?
+//     }
+//     else
     {
         SetWidgetStyle();
         gtk_widget_set_style( m_text, m_widgetStyle );
@@ -1724,3 +1719,10 @@ bool wxTextCtrl::ScrollPages(int pages)
 #endif
 }
 
+
+// static
+wxVisualAttributes
+wxTextCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_entry_new, true);
+}
index 4d57e220cf5ecf7898cd670b518d70819daa73d8..d8aac966f6ada216abb5e384c9177a70e342c586 100644 (file)
@@ -207,6 +207,16 @@ wxSize wxToggleBitmapButton::DoGetBestSize() const
     }
     return best;
 }
+
+
+// static
+wxVisualAttributes
+wxToggleBitmapButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_toggle_button_new);
+}
+
+
 // ------------------------------------------------------------------------
 // wxToggleButton
 // ------------------------------------------------------------------------
@@ -339,5 +349,12 @@ wxSize wxToggleButton::DoGetBestSize() const
    return ret;
 }
 
+// static
+wxVisualAttributes
+wxToggleButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+    return GetDefaultAttributesFromGTKWidget(gtk_toggle_button_new);
+}
+
 #endif // wxUSE_TOGGLEBTN