fixed GTK styles handling:
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
This commit is contained in:
parent
fae763d088
commit
f40fdaa339
@ -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)
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
void ApplyWidgetStyle();
|
||||
void DoApplyWidgetStyle(GtkRcStyle *style);
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void OnInternalIdle();
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -130,7 +130,7 @@ public:
|
||||
void EnableEvents();
|
||||
GtkWidget* GetConnectWidget();
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
void DoApplyWidgetStyle(GtkRcStyle *style);
|
||||
|
||||
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -83,8 +83,6 @@ public:
|
||||
// implementation
|
||||
// -------------
|
||||
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
// the max and current gauge values
|
||||
int m_rangeMax,
|
||||
m_gaugePos;
|
||||
|
@ -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
|
||||
|
@ -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 );
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
@ -75,7 +75,6 @@ public:
|
||||
// --------------
|
||||
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
GtkAdjustment *m_adjust;
|
||||
float m_oldPos;
|
||||
|
@ -65,7 +65,6 @@ public:
|
||||
|
||||
// implementation
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
void GtkDisableEvents();
|
||||
void GtkEnableEvents();
|
||||
|
||||
|
@ -53,7 +53,6 @@ public:
|
||||
void OnSize( wxSizeEvent &event );
|
||||
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
GtkAdjustment *m_adjust;
|
||||
float m_oldPos;
|
||||
|
@ -66,7 +66,6 @@ public:
|
||||
void OnChar( wxKeyEvent &event );
|
||||
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
void GtkDisableEvents();
|
||||
void GtkEnableEvents();
|
||||
|
||||
|
@ -45,8 +45,6 @@ public:
|
||||
|
||||
// implementation
|
||||
|
||||
virtual void ApplyWidgetStyle();
|
||||
|
||||
virtual bool IsTransparentForMouse() const { return TRUE; }
|
||||
|
||||
private:
|
||||
|
@ -65,8 +65,6 @@ public:
|
||||
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
@ -133,7 +133,7 @@ public:
|
||||
|
||||
GtkWidget* GetConnectWidget();
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
void DoApplyWidgetStyle(GtkRcStyle *style);
|
||||
void CalculateScrollbar();
|
||||
void OnInternalIdle();
|
||||
void UpdateFontIfNeeded();
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
void ApplyWidgetStyle();
|
||||
void DoApplyWidgetStyle(GtkRcStyle *style);
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void OnInternalIdle();
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -130,7 +130,7 @@ public:
|
||||
void EnableEvents();
|
||||
GtkWidget* GetConnectWidget();
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
void DoApplyWidgetStyle(GtkRcStyle *style);
|
||||
|
||||
wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -83,8 +83,6 @@ public:
|
||||
// implementation
|
||||
// -------------
|
||||
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
// the max and current gauge values
|
||||
int m_rangeMax,
|
||||
m_gaugePos;
|
||||
|
@ -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
|
||||
|
@ -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 );
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
@ -75,7 +75,6 @@ public:
|
||||
// --------------
|
||||
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
GtkAdjustment *m_adjust;
|
||||
float m_oldPos;
|
||||
|
@ -65,7 +65,6 @@ public:
|
||||
|
||||
// implementation
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
void GtkDisableEvents();
|
||||
void GtkEnableEvents();
|
||||
|
||||
|
@ -53,7 +53,6 @@ public:
|
||||
void OnSize( wxSizeEvent &event );
|
||||
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
GtkAdjustment *m_adjust;
|
||||
float m_oldPos;
|
||||
|
@ -66,7 +66,6 @@ public:
|
||||
void OnChar( wxKeyEvent &event );
|
||||
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
void GtkDisableEvents();
|
||||
void GtkEnableEvents();
|
||||
|
||||
|
@ -45,8 +45,6 @@ public:
|
||||
|
||||
// implementation
|
||||
|
||||
virtual void ApplyWidgetStyle();
|
||||
|
||||
virtual bool IsTransparentForMouse() const { return TRUE; }
|
||||
|
||||
private:
|
||||
|
@ -65,8 +65,6 @@ public:
|
||||
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
@ -133,7 +133,7 @@ public:
|
||||
|
||||
GtkWidget* GetConnectWidget();
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
void DoApplyWidgetStyle(GtkRcStyle *style);
|
||||
void CalculateScrollbar();
|
||||
void OnInternalIdle();
|
||||
void UpdateFontIfNeeded();
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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 )
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 )
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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 )
|
||||
|
@ -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();
|
||||
|
@ -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),
|
||||
|
@ -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
|
||||
|
@ -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() );
|
||||
|
@ -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))
|
||||
|
@ -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...
|
||||
|
@ -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))
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
||||
GtkRcStyle *wxWindowGTK::CreateWidgetStyle()
|
||||
{
|
||||
if (m_widgetStyle)
|
||||
// do we need to apply any changes at all?
|
||||
if ( !m_hasFont && !m_hasFgCol &&
|
||||
(!m_hasBgCol || !m_backgroundColour.Ok()) )
|
||||
{
|
||||
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 NULL;
|
||||
}
|
||||
|
||||
return m_widgetStyle;
|
||||
}
|
||||
|
||||
void wxWindowGTK::SetWidgetStyle()
|
||||
{
|
||||
#if DISABLE_STYLE_IF_BROKEN_THEME
|
||||
if (m_widget->style->engine_data)
|
||||
{
|
||||
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;
|
||||
}
|
||||
#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()
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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 )
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 )
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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 )
|
||||
|
@ -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();
|
||||
|
@ -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),
|
||||
|
@ -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
|
||||
|
@ -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() );
|
||||
|
@ -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))
|
||||
|
@ -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...
|
||||
|
@ -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))
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
||||
GtkRcStyle *wxWindowGTK::CreateWidgetStyle()
|
||||
{
|
||||
if (m_widgetStyle)
|
||||
// do we need to apply any changes at all?
|
||||
if ( !m_hasFont && !m_hasFgCol &&
|
||||
(!m_hasBgCol || !m_backgroundColour.Ok()) )
|
||||
{
|
||||
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 NULL;
|
||||
}
|
||||
|
||||
return m_widgetStyle;
|
||||
}
|
||||
|
||||
void wxWindowGTK::SetWidgetStyle()
|
||||
{
|
||||
#if DISABLE_STYLE_IF_BROKEN_THEME
|
||||
if (m_widget->style->engine_data)
|
||||
{
|
||||
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;
|
||||
}
|
||||
#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()
|
||||
|
Loading…
Reference in New Issue
Block a user