From db434467a143a2c847c4bcfe987f0202c2d02bf2 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 4 Jan 2000 13:02:27 +0000 Subject: [PATCH] New colour, font, theme and size code.. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5228 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/button.h | 3 + include/wx/gtk/notebook.h | 32 ++++----- include/wx/gtk/radiobut.h | 3 + include/wx/gtk1/button.h | 3 + include/wx/gtk1/notebook.h | 32 ++++----- include/wx/gtk1/radiobut.h | 3 + src/common/wincmn.cpp | 2 +- src/gtk/button.cpp | 42 ++++++------ src/gtk/checkbox.cpp | 19 ++++-- src/gtk/choice.cpp | 21 ++++-- src/gtk/combobox.cpp | 31 +++++---- src/gtk/menu.cpp | 4 ++ src/gtk/notebook.cpp | 12 ++-- src/gtk/radiobox.cpp | 17 +++-- src/gtk/radiobut.cpp | 54 +++++++++------ src/gtk/settings.cpp | 131 ++++++++++++++++++++----------------- src/gtk/spinctrl.cpp | 24 ++++--- src/gtk/statbox.cpp | 8 ++- src/gtk/stattext.cpp | 17 +++-- src/gtk/textctrl.cpp | 19 +++--- src/gtk/window.cpp | 42 +++++++----- src/gtk1/button.cpp | 42 ++++++------ src/gtk1/checkbox.cpp | 19 ++++-- src/gtk1/choice.cpp | 21 ++++-- src/gtk1/combobox.cpp | 31 +++++---- src/gtk1/menu.cpp | 4 ++ src/gtk1/notebook.cpp | 12 ++-- src/gtk1/radiobox.cpp | 17 +++-- src/gtk1/radiobut.cpp | 54 +++++++++------ src/gtk1/settings.cpp | 131 ++++++++++++++++++++----------------- src/gtk1/spinctrl.cpp | 24 ++++--- src/gtk1/statbox.cpp | 8 ++- src/gtk1/stattext.cpp | 17 +++-- src/gtk1/textctrl.cpp | 19 +++--- src/gtk1/window.cpp | 42 +++++++----- 35 files changed, 579 insertions(+), 381 deletions(-) diff --git a/include/wx/gtk/button.h b/include/wx/gtk/button.h index 538720c63c..c239f5b7a1 100644 --- a/include/wx/gtk/button.h +++ b/include/wx/gtk/button.h @@ -64,6 +64,9 @@ public: void ApplyWidgetStyle(); +protected: + virtual wxSize DoGetBestSize() const; + private: DECLARE_DYNAMIC_CLASS(wxButton) }; diff --git a/include/wx/gtk/notebook.h b/include/wx/gtk/notebook.h index d8c772d7a0..6e8a0a1f40 100644 --- a/include/wx/gtk/notebook.h +++ b/include/wx/gtk/notebook.h @@ -133,27 +133,29 @@ public: // overridden from wxWindow to make tabbing work void SetFocus(); - // implementation + // implementation + // -------------- - void SetConstraintSizes(bool recurse); - bool DoPhase(int phase); - void ApplyWidgetStyle(); + void SetConstraintSizes(bool recurse); + bool DoPhase(int phase); + void ApplyWidgetStyle(); - // report if window belongs to notebook - bool IsOwnGtkWindow( GdkWindow *window ); + // report if window belongs to notebook + bool IsOwnGtkWindow( GdkWindow *window ); - // common part of all ctors - void Init(); + // common part of all ctors + void Init(); - // helper function - wxNotebookPage* GetNotebookPage(int page) const; + // helper function + wxNotebookPage* GetNotebookPage(int page) const; - wxImageList* m_imageList; - wxList m_pages; - int m_lastSelection; /* hack */ + wxImageList* m_imageList; + wxList m_pages; + int m_lastSelection; /* hack */ - DECLARE_DYNAMIC_CLASS(wxNotebook) - DECLARE_EVENT_TABLE() +private: + DECLARE_DYNAMIC_CLASS(wxNotebook) + DECLARE_EVENT_TABLE() }; #endif diff --git a/include/wx/gtk/radiobut.h b/include/wx/gtk/radiobut.h index c6717e8a6e..9435869fee 100644 --- a/include/wx/gtk/radiobut.h +++ b/include/wx/gtk/radiobut.h @@ -70,6 +70,9 @@ public: bool IsOwnGtkWindow( GdkWindow *window ); void OnInternalIdle(); +protected: + virtual wxSize DoGetBestSize() const; + private: DECLARE_DYNAMIC_CLASS(wxRadioButton) }; diff --git a/include/wx/gtk1/button.h b/include/wx/gtk1/button.h index 538720c63c..c239f5b7a1 100644 --- a/include/wx/gtk1/button.h +++ b/include/wx/gtk1/button.h @@ -64,6 +64,9 @@ public: void ApplyWidgetStyle(); +protected: + virtual wxSize DoGetBestSize() const; + private: DECLARE_DYNAMIC_CLASS(wxButton) }; diff --git a/include/wx/gtk1/notebook.h b/include/wx/gtk1/notebook.h index d8c772d7a0..6e8a0a1f40 100644 --- a/include/wx/gtk1/notebook.h +++ b/include/wx/gtk1/notebook.h @@ -133,27 +133,29 @@ public: // overridden from wxWindow to make tabbing work void SetFocus(); - // implementation + // implementation + // -------------- - void SetConstraintSizes(bool recurse); - bool DoPhase(int phase); - void ApplyWidgetStyle(); + void SetConstraintSizes(bool recurse); + bool DoPhase(int phase); + void ApplyWidgetStyle(); - // report if window belongs to notebook - bool IsOwnGtkWindow( GdkWindow *window ); + // report if window belongs to notebook + bool IsOwnGtkWindow( GdkWindow *window ); - // common part of all ctors - void Init(); + // common part of all ctors + void Init(); - // helper function - wxNotebookPage* GetNotebookPage(int page) const; + // helper function + wxNotebookPage* GetNotebookPage(int page) const; - wxImageList* m_imageList; - wxList m_pages; - int m_lastSelection; /* hack */ + wxImageList* m_imageList; + wxList m_pages; + int m_lastSelection; /* hack */ - DECLARE_DYNAMIC_CLASS(wxNotebook) - DECLARE_EVENT_TABLE() +private: + DECLARE_DYNAMIC_CLASS(wxNotebook) + DECLARE_EVENT_TABLE() }; #endif diff --git a/include/wx/gtk1/radiobut.h b/include/wx/gtk1/radiobut.h index c6717e8a6e..9435869fee 100644 --- a/include/wx/gtk1/radiobut.h +++ b/include/wx/gtk1/radiobut.h @@ -70,6 +70,9 @@ public: bool IsOwnGtkWindow( GdkWindow *window ); void OnInternalIdle(); +protected: + virtual wxSize DoGetBestSize() const; + private: DECLARE_DYNAMIC_CLASS(wxRadioButton) }; diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index dd3822251d..39fae1d525 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -119,7 +119,7 @@ void wxWindowBase::InitBase() m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_BTNFACE); m_foregroundColour = *wxBLACK; // TODO take this from sys settings too? -#ifndef __WXMAC__ +#if !defined(__WXMAC__) && !defined(__WXGTK__) m_font = *wxSWISS_FONT; // and this? #else m_font = settings.GetSystemFont(wxSYS_DEFAULT_GUI_FONT); diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 47662e31de..5b16248fcd 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -111,24 +111,6 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE ); #endif - int x = 0; int y = 0; - wxFont new_font( parent->GetFont() ); - GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font ); - - wxSize newSize = size; - if (newSize.x == -1) - { - newSize.x = 12+x; - if (newSize.x < 80) newSize.x = 80; - } - if (newSize.y == -1) - { - newSize.y = 11+y; - if (newSize.y < 26) newSize.y = 26; - } - - SetSize( newSize.x, newSize.y ); - gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); @@ -136,9 +118,23 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, PostCreation(); + ApplyWidgetStyle(); + + SetFont( parent->GetFont() ); + + wxSize best_size( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = best_size.x; + if (new_size.y == -1) + new_size.y = best_size.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + + SetSize( new_size ); + SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); @@ -184,3 +180,11 @@ void wxButton::ApplyWidgetStyle() gtk_widget_set_style( m_widget, m_widgetStyle ); gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle ); } + +wxSize wxButton::DoGetBestSize() const +{ + wxSize ret( wxControl::DoGetBestSize() ); + if (ret.x < 80) ret.x = 80; + return ret; +} + diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index 5d638cd07c..051e51b500 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -106,8 +106,6 @@ bool wxCheckBox::Create(wxWindow *parent, m_widget = m_widgetCheckbox; } - SetSizeOrDefault( size ); - gtk_signal_connect( GTK_OBJECT(m_widgetCheckbox), "clicked", GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback), @@ -117,9 +115,21 @@ bool wxCheckBox::Create(wxWindow *parent, PostCreation(); + ApplyWidgetStyle(); + + SetFont( parent->GetFont() ); + + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = size_best.x; + if (new_size.y == -1) + new_size.y = size_best.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); @@ -203,8 +213,7 @@ void wxCheckBox::OnInternalIdle() wxSize wxCheckBox::DoGetBestSize() const { - return wxSize( 25 + gdk_string_measure( m_widgetCheckbox->style->font, - m_label.mbc_str() ), 26 ); + return wxControl::DoGetBestSize(); } #endif diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index 97ea9be8b9..dda0c63e8f 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -90,8 +90,6 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, m_widget = gtk_option_menu_new(); - SetSizeOrDefault( size ); - if ( style & wxCB_SORT ) { // if our m_strings != NULL, DoAppend() will check for it and insert @@ -112,9 +110,21 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, PostCreation(); + ApplyWidgetStyle(); + + SetFont( parent->GetFont() ); + + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = size_best.x; + if (new_size.y == -1) + new_size.y = size_best.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); @@ -396,7 +406,10 @@ size_t wxChoice::GtkAppendHelper(GtkWidget *menu, const wxString& item) wxSize wxChoice::DoGetBestSize() const { - return wxSize(80, 26); + wxSize ret( wxControl::DoGetBestSize() ); + if (ret.x < 80) ret.x = 80; + ret.y = 16 + gdk_char_height( m_widget->style->font, 'H' ); + return ret; } #endif diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 0571f48fe4..eb10d33e38 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -101,17 +101,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, m_needParent = TRUE; m_acceptsFocus = TRUE; - wxSize newSize = size, - bestSize = DoGetBestSize(); - - if (newSize.x == -1) - newSize.x = bestSize.x; - if (newSize.y == -1) - newSize.y = bestSize.y; - if (newSize.y > 22) - newSize.y = 22; - - if (!PreCreation( parent, pos, newSize ) || + if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxComboBox creation failed") ); @@ -148,6 +138,8 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, PostCreation(); + ApplyWidgetStyle(); + ConnectWidget( GTK_COMBO(m_widget)->button ); if (!value.IsNull()) SetValue( value ); @@ -158,9 +150,19 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget)->entry), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = size_best.x; + if (new_size.y == -1) + new_size.y = size_best.y; + if (new_size.y > size_best.y) + new_size.y = size_best.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_WINDOW ) ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); @@ -665,8 +667,9 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) wxSize wxComboBox::DoGetBestSize() const { - // totally bogus - should measure the strings in the combo! - return wxSize(100, 22); + wxSize ret( wxControl::DoGetBestSize() ); + if (ret.x < 100) ret.x = 100; + return ret; } #endif diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 094b02165a..6758d6b4ba 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -78,6 +78,8 @@ wxMenuBar::wxMenuBar( long style ) } PostCreation(); + + ApplyWidgetStyle(); } wxMenuBar::wxMenuBar() @@ -108,6 +110,8 @@ wxMenuBar::wxMenuBar() m_widget = GTK_WIDGET(m_menubar); PostCreation(); + + ApplyWidgetStyle(); } wxMenuBar::~wxMenuBar() diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index ead3936605..942914458c 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -213,7 +213,7 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id, !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxNoteBook creation failed") ); - return FALSE; + return FALSE; } @@ -230,15 +230,17 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id, m_parent->DoAddChild( this ); - if(m_windowStyle & wxNB_RIGHT) + if (m_windowStyle & wxNB_RIGHT) gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_RIGHT ); - if(m_windowStyle & wxNB_LEFT) + if (m_windowStyle & wxNB_LEFT) gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_LEFT ); - if(m_windowStyle & wxNB_BOTTOM) + if (m_windowStyle & wxNB_BOTTOM) gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM ); PostCreation(); + SetFont( parent->GetFont() ); + gtk_signal_connect( GTK_OBJECT(m_widget), "realize", GTK_SIGNAL_FUNC(gtk_notebook_realized_callback), (gpointer) this ); @@ -625,6 +627,8 @@ bool wxNotebook::DoPhase( int WXUNUSED(nPhase) ) void wxNotebook::ApplyWidgetStyle() { + // TODO, font for labels etc + SetWidgetStyle(); gtk_widget_set_style( m_widget, m_widgetStyle ); } diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index 6dda8dc6c4..2afc3aec55 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -180,6 +180,16 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, m_x+10, m_y+10+(i*24), 10, 10 ); } + m_parent->DoAddChild( this ); + + PostCreation(); + + ApplyWidgetStyle(); + + SetLabel( title ); + + SetFont( parent->GetFont() ); + wxSize ls = LayoutItems(); wxSize newSize = size; @@ -187,15 +197,8 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, if (newSize.y == -1) newSize.y = ls.y; SetSize( newSize.x, newSize.y ); - m_parent->DoAddChild( this ); - - PostCreation(); - - SetLabel( title ); - SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); diff --git a/src/gtk/radiobut.cpp b/src/gtk/radiobut.cpp index 5f58c9331e..830c410d4f 100644 --- a/src/gtk/radiobut.cpp +++ b/src/gtk/radiobut.cpp @@ -84,36 +84,31 @@ bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& lab wxRadioButton *chief = (wxRadioButton*) NULL; wxWindowList::Node *node = parent->GetChildren().GetLast(); while (node) - { - wxWindow *child = node->GetData(); - if (child->m_isRadioButton) { - chief = (wxRadioButton*) child; - if (child->HasFlag(wxRB_GROUP)) break; - } - node = node->GetPrevious(); + wxWindow *child = node->GetData(); + if (child->m_isRadioButton) + { + chief = (wxRadioButton*) child; + if (child->HasFlag(wxRB_GROUP)) break; + } + node = node->GetPrevious(); } - if (chief) - { + if (chief) + { /* we are part of the group started by chief */ - m_radioButtonGroup = gtk_radio_button_group( GTK_RADIO_BUTTON(chief->m_widget) ); - } - else - { + m_radioButtonGroup = gtk_radio_button_group( GTK_RADIO_BUTTON(chief->m_widget) ); + } + else + { /* start a new group */ m_radioButtonGroup = (GSList*) NULL; - } + } } m_widget = gtk_radio_button_new_with_label( m_radioButtonGroup, label.mbc_str() ); SetLabel(label); - wxSize newSize = size; - if (newSize.x == -1) newSize.x = 22+gdk_string_measure( m_widget->style->font, label.mbc_str() ); - if (newSize.y == -1) newSize.y = 26; - SetSize( newSize.x, newSize.y ); - gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); @@ -121,9 +116,21 @@ bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& lab PostCreation(); + ApplyWidgetStyle(); + + SetFont( parent->GetFont() ); + + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = size_best.x; + if (new_size.y == -1) + new_size.y = size_best.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); @@ -204,10 +211,15 @@ void wxRadioButton::OnInternalIdle() windows above so that checking for the current cursor is not possible. */ - gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widget)->event_window, cursor.GetCursor() ); + gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widget)->event_window, cursor.GetCursor() ); } UpdateWindowUI(); } +wxSize wxRadioButton::DoGetBestSize() const +{ + return wxControl::DoGetBestSize(); +} + #endif diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index 99894b71a2..2fde66188c 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -76,65 +76,78 @@ void wxSystemSettings::Done() wxColour wxSystemSettings::GetSystemColour( int index ) { - switch (index) - { - case wxSYS_COLOUR_SCROLLBAR: - case wxSYS_COLOUR_BACKGROUND: - case wxSYS_COLOUR_ACTIVECAPTION: - case wxSYS_COLOUR_INACTIVECAPTION: - case wxSYS_COLOUR_MENU: - case wxSYS_COLOUR_WINDOWFRAME: - case wxSYS_COLOUR_ACTIVEBORDER: - case wxSYS_COLOUR_INACTIVEBORDER: - case wxSYS_COLOUR_BTNFACE: - { - if (!g_systemBtnFaceColour) - { - g_systemBtnFaceColour = - new wxColour( 0xd6d6 >> SHIFT, - 0xd6d6 >> SHIFT, - 0xd6d6 >> SHIFT ); - } - return *g_systemBtnFaceColour; - } - case wxSYS_COLOUR_WINDOW: - { - return *wxWHITE; - } - case wxSYS_COLOUR_GRAYTEXT: - case wxSYS_COLOUR_BTNSHADOW: - { - if (!g_systemBtnShadowColour) - { - g_systemBtnShadowColour = - new wxColour( 0x7530 >> SHIFT, - 0x7530 >> SHIFT, - 0x7530 >> SHIFT ); - } - return *g_systemBtnShadowColour; - } - case wxSYS_COLOUR_BTNHIGHLIGHT: - { - if (!g_systemBtnHighlightColour) - { - g_systemBtnHighlightColour = - new wxColour( 0xea60 >> SHIFT, - 0xea60 >> SHIFT, - 0xea60 >> SHIFT ); - } - return *g_systemBtnHighlightColour; - } - case wxSYS_COLOUR_HIGHLIGHT: + switch (index) { - if (!g_systemHighlightColour) - { - g_systemHighlightColour = - new wxColour( 0 >> SHIFT, - 0 >> SHIFT, - 0x9c40 >> SHIFT ); - } - return *g_systemHighlightColour; - } + case wxSYS_COLOUR_SCROLLBAR: + case wxSYS_COLOUR_BACKGROUND: + case wxSYS_COLOUR_ACTIVECAPTION: + case wxSYS_COLOUR_INACTIVECAPTION: + case wxSYS_COLOUR_MENU: + case wxSYS_COLOUR_WINDOWFRAME: + case wxSYS_COLOUR_ACTIVEBORDER: + case wxSYS_COLOUR_INACTIVEBORDER: + case wxSYS_COLOUR_BTNFACE: + { + if (!g_systemBtnFaceColour) + { + g_systemBtnFaceColour = + new wxColour( 0xd6d6 >> SHIFT, + 0xd6d6 >> SHIFT, + 0xd6d6 >> SHIFT ); + } + return *g_systemBtnFaceColour; + } + case wxSYS_COLOUR_WINDOW: + { + return *wxWHITE; + } + case wxSYS_COLOUR_GRAYTEXT: + case wxSYS_COLOUR_BTNSHADOW: + { + if (!g_systemBtnShadowColour) + { + g_systemBtnShadowColour = + new wxColour( 0x7530 >> SHIFT, + 0x7530 >> SHIFT, + 0x7530 >> SHIFT ); + } + return *g_systemBtnShadowColour; + } + case wxSYS_COLOUR_BTNHIGHLIGHT: + { + if (!g_systemBtnHighlightColour) + { + g_systemBtnHighlightColour = + new wxColour( 0xea60 >> SHIFT, + 0xea60 >> SHIFT, + 0xea60 >> SHIFT ); + } + return *g_systemBtnHighlightColour; + } + case wxSYS_COLOUR_HIGHLIGHT: + { + if (!g_systemHighlightColour) + { +/* + g_systemHighlightColour = + new wxColour( 0 >> SHIFT, + 0 >> SHIFT, + 0x9c40 >> SHIFT ); +*/ + GtkWidget *widget = gtk_button_new(); + GtkStyle *def = gtk_rc_get_style( widget ); + int red = def->bg[GTK_STATE_SELECTED].red; + int green = def->bg[GTK_STATE_SELECTED].green; + int blue = def->bg[GTK_STATE_SELECTED].blue; + gtk_widget_destroy( widget ); + + g_systemHighlightColour = + new wxColour( red >> SHIFT, + green >> SHIFT, + blue >> SHIFT ); + } + return *g_systemHighlightColour; + } case wxSYS_COLOUR_MENUTEXT: case wxSYS_COLOUR_WINDOWTEXT: case wxSYS_COLOUR_CAPTIONTEXT: @@ -173,7 +186,7 @@ wxFont wxSystemSettings::GetSystemFont( int index ) case wxSYS_DEFAULT_GUI_FONT: { if (!g_systemFont) - g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); + g_systemFont = new wxFont( 16, wxSWISS, wxNORMAL, wxNORMAL ); return *g_systemFont; } } diff --git a/src/gtk/spinctrl.cpp b/src/gtk/spinctrl.cpp index 230914ab94..9e51422831 100644 --- a/src/gtk/spinctrl.cpp +++ b/src/gtk/spinctrl.cpp @@ -88,24 +88,28 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, m_widget = gtk_spin_button_new( m_adjust, 1, 0 ); - wxSize new_size = size, - sizeBest = DoGetBestSize(); - if (new_size.x == -1) - new_size.x = sizeBest.x; - if (new_size.y == -1) - new_size.y = sizeBest.y; - - if ((new_size.x != size.x) || (new_size.y != size.y)) - SetSize( new_size.x, new_size.y ); - gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget), (int)(m_windowStyle & wxSP_WRAP) ); GtkEnableEvents(); + m_parent->DoAddChild( this ); PostCreation(); + ApplyWidgetStyle(); + + SetFont( parent->GetFont() ); + + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = size_best.x; + if (new_size.y == -1) + new_size.y = size_best.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + SetBackgroundColour( parent->GetBackgroundColour() ); SetValue( value ); diff --git a/src/gtk/statbox.cpp b/src/gtk/statbox.cpp index b7697b9ce7..eb53692cfc 100644 --- a/src/gtk/statbox.cpp +++ b/src/gtk/statbox.cpp @@ -45,7 +45,7 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxStaticBox creation failed") ); - return FALSE; + return FALSE; } m_isStaticBox = TRUE; @@ -61,9 +61,13 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label SetLabel(label); + ApplyWidgetStyle(); + + SetFont( parent->GetFont() ); + + SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); diff --git a/src/gtk/stattext.cpp b/src/gtk/stattext.cpp index 8136ac250c..54d7366a4f 100644 --- a/src/gtk/stattext.cpp +++ b/src/gtk/stattext.cpp @@ -62,8 +62,6 @@ bool wxStaticText::Create(wxWindow *parent, wxControl::SetLabel(label); m_widget = gtk_label_new( m_label.mbc_str() ); - wxControl::SetFont( parent->GetFont() ); - GtkJustification justify; if ( style & wxALIGN_CENTER ) justify = GTK_JUSTIFY_CENTER; @@ -80,12 +78,23 @@ bool wxStaticText::Create(wxWindow *parent, // do not move this call elsewhere gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE ); - SetSizeOrDefault( size ); - m_parent->DoAddChild( this ); PostCreation(); + ApplyWidgetStyle(); + + wxControl::SetFont( parent->GetFont() ); + + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = size_best.x; + if (new_size.y == -1) + new_size.y = size_best.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); Show( TRUE ); diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index e832dcdf05..ddd7432d18 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -192,20 +192,21 @@ bool wxTextCtrl::Create( wxWindow *parent, m_text = gtk_entry_new(); } - wxSize new_size = size, - sizeBest = DoGetBestSize(); + m_parent->DoAddChild( this ); + + PostCreation(); + + SetFont( parent->GetFont() ); + + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); if (new_size.x == -1) - new_size.x = sizeBest.x; + new_size.x = size_best.x; if (new_size.y == -1) - new_size.y = sizeBest.y; - + new_size.y = size_best.y; if ((new_size.x != size.x) || (new_size.y != size.y)) SetSize( new_size.x, new_size.y ); - m_parent->DoAddChild( this ); - - PostCreation(); - if (multi_line) gtk_widget_show(m_text); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index a1484b1489..6c749174f2 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1634,9 +1634,6 @@ gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win ) if (g_isIdle) wxapp_install_idle_handler(); - if (win->m_delayedFont) - win->SetFont( win->GetFont() ); - if (win->m_delayedBackgroundColour) win->SetBackgroundColour( win->GetBackgroundColour() ); @@ -2025,6 +2022,8 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, PostCreation(); + ApplyWidgetStyle(); + Show( TRUE ); return TRUE; @@ -2963,7 +2962,7 @@ GtkStyle *wxWindow::GetWidgetStyle() { if (m_widgetStyle) gtk_style_unref( m_widgetStyle ); - m_widgetStyle = gtk_style_copy( gtk_widget_get_style( m_widget ) ); + m_widgetStyle = gtk_style_copy( gtk_rc_get_style( m_widget ) ); return m_widgetStyle; } @@ -2972,28 +2971,37 @@ void wxWindow::SetWidgetStyle() { GtkStyle *style = GetWidgetStyle(); - gdk_font_unref( style->font ); - style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) ); + if (m_font != wxSystemSettings::GetSystemFont( wxSYS_DEFAULT_GUI_FONT )) + { + gdk_font_unref( style->font ); + style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) ); + } if (m_foregroundColour.Ok()) { m_foregroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) ); - style->fg[GTK_STATE_NORMAL] = *m_foregroundColour.GetColor(); - style->fg[GTK_STATE_PRELIGHT] = *m_foregroundColour.GetColor(); - style->fg[GTK_STATE_ACTIVE] = *m_foregroundColour.GetColor(); + if (m_foregroundColour != wxSystemSettings::GetSystemColour(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(); + } } if (m_backgroundColour.Ok()) { m_backgroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) ); - 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(); + if (m_backgroundColour != wxSystemSettings::GetSystemColour(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(); + } } } diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index 47662e31de..5b16248fcd 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -111,24 +111,6 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE ); #endif - int x = 0; int y = 0; - wxFont new_font( parent->GetFont() ); - GetTextExtent( m_label, &x, &y, (int*)NULL, (int*)NULL, &new_font ); - - wxSize newSize = size; - if (newSize.x == -1) - { - newSize.x = 12+x; - if (newSize.x < 80) newSize.x = 80; - } - if (newSize.y == -1) - { - newSize.y = 11+y; - if (newSize.y < 26) newSize.y = 26; - } - - SetSize( newSize.x, newSize.y ); - gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); @@ -136,9 +118,23 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, PostCreation(); + ApplyWidgetStyle(); + + SetFont( parent->GetFont() ); + + wxSize best_size( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = best_size.x; + if (new_size.y == -1) + new_size.y = best_size.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + + SetSize( new_size ); + SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); @@ -184,3 +180,11 @@ void wxButton::ApplyWidgetStyle() gtk_widget_set_style( m_widget, m_widgetStyle ); gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle ); } + +wxSize wxButton::DoGetBestSize() const +{ + wxSize ret( wxControl::DoGetBestSize() ); + if (ret.x < 80) ret.x = 80; + return ret; +} + diff --git a/src/gtk1/checkbox.cpp b/src/gtk1/checkbox.cpp index 5d638cd07c..051e51b500 100644 --- a/src/gtk1/checkbox.cpp +++ b/src/gtk1/checkbox.cpp @@ -106,8 +106,6 @@ bool wxCheckBox::Create(wxWindow *parent, m_widget = m_widgetCheckbox; } - SetSizeOrDefault( size ); - gtk_signal_connect( GTK_OBJECT(m_widgetCheckbox), "clicked", GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback), @@ -117,9 +115,21 @@ bool wxCheckBox::Create(wxWindow *parent, PostCreation(); + ApplyWidgetStyle(); + + SetFont( parent->GetFont() ); + + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = size_best.x; + if (new_size.y == -1) + new_size.y = size_best.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); @@ -203,8 +213,7 @@ void wxCheckBox::OnInternalIdle() wxSize wxCheckBox::DoGetBestSize() const { - return wxSize( 25 + gdk_string_measure( m_widgetCheckbox->style->font, - m_label.mbc_str() ), 26 ); + return wxControl::DoGetBestSize(); } #endif diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index 97ea9be8b9..dda0c63e8f 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -90,8 +90,6 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, m_widget = gtk_option_menu_new(); - SetSizeOrDefault( size ); - if ( style & wxCB_SORT ) { // if our m_strings != NULL, DoAppend() will check for it and insert @@ -112,9 +110,21 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, PostCreation(); + ApplyWidgetStyle(); + + SetFont( parent->GetFont() ); + + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = size_best.x; + if (new_size.y == -1) + new_size.y = size_best.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); @@ -396,7 +406,10 @@ size_t wxChoice::GtkAppendHelper(GtkWidget *menu, const wxString& item) wxSize wxChoice::DoGetBestSize() const { - return wxSize(80, 26); + wxSize ret( wxControl::DoGetBestSize() ); + if (ret.x < 80) ret.x = 80; + ret.y = 16 + gdk_char_height( m_widget->style->font, 'H' ); + return ret; } #endif diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 0571f48fe4..eb10d33e38 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -101,17 +101,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, m_needParent = TRUE; m_acceptsFocus = TRUE; - wxSize newSize = size, - bestSize = DoGetBestSize(); - - if (newSize.x == -1) - newSize.x = bestSize.x; - if (newSize.y == -1) - newSize.y = bestSize.y; - if (newSize.y > 22) - newSize.y = 22; - - if (!PreCreation( parent, pos, newSize ) || + if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxComboBox creation failed") ); @@ -148,6 +138,8 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, PostCreation(); + ApplyWidgetStyle(); + ConnectWidget( GTK_COMBO(m_widget)->button ); if (!value.IsNull()) SetValue( value ); @@ -158,9 +150,19 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget)->entry), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = size_best.x; + if (new_size.y == -1) + new_size.y = size_best.y; + if (new_size.y > size_best.y) + new_size.y = size_best.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_WINDOW ) ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); @@ -665,8 +667,9 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) wxSize wxComboBox::DoGetBestSize() const { - // totally bogus - should measure the strings in the combo! - return wxSize(100, 22); + wxSize ret( wxControl::DoGetBestSize() ); + if (ret.x < 100) ret.x = 100; + return ret; } #endif diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 094b02165a..6758d6b4ba 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -78,6 +78,8 @@ wxMenuBar::wxMenuBar( long style ) } PostCreation(); + + ApplyWidgetStyle(); } wxMenuBar::wxMenuBar() @@ -108,6 +110,8 @@ wxMenuBar::wxMenuBar() m_widget = GTK_WIDGET(m_menubar); PostCreation(); + + ApplyWidgetStyle(); } wxMenuBar::~wxMenuBar() diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index ead3936605..942914458c 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -213,7 +213,7 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id, !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxNoteBook creation failed") ); - return FALSE; + return FALSE; } @@ -230,15 +230,17 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id, m_parent->DoAddChild( this ); - if(m_windowStyle & wxNB_RIGHT) + if (m_windowStyle & wxNB_RIGHT) gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_RIGHT ); - if(m_windowStyle & wxNB_LEFT) + if (m_windowStyle & wxNB_LEFT) gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_LEFT ); - if(m_windowStyle & wxNB_BOTTOM) + if (m_windowStyle & wxNB_BOTTOM) gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM ); PostCreation(); + SetFont( parent->GetFont() ); + gtk_signal_connect( GTK_OBJECT(m_widget), "realize", GTK_SIGNAL_FUNC(gtk_notebook_realized_callback), (gpointer) this ); @@ -625,6 +627,8 @@ bool wxNotebook::DoPhase( int WXUNUSED(nPhase) ) void wxNotebook::ApplyWidgetStyle() { + // TODO, font for labels etc + SetWidgetStyle(); gtk_widget_set_style( m_widget, m_widgetStyle ); } diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp index 6dda8dc6c4..2afc3aec55 100644 --- a/src/gtk1/radiobox.cpp +++ b/src/gtk1/radiobox.cpp @@ -180,6 +180,16 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, m_x+10, m_y+10+(i*24), 10, 10 ); } + m_parent->DoAddChild( this ); + + PostCreation(); + + ApplyWidgetStyle(); + + SetLabel( title ); + + SetFont( parent->GetFont() ); + wxSize ls = LayoutItems(); wxSize newSize = size; @@ -187,15 +197,8 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, if (newSize.y == -1) newSize.y = ls.y; SetSize( newSize.x, newSize.y ); - m_parent->DoAddChild( this ); - - PostCreation(); - - SetLabel( title ); - SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); diff --git a/src/gtk1/radiobut.cpp b/src/gtk1/radiobut.cpp index 5f58c9331e..830c410d4f 100644 --- a/src/gtk1/radiobut.cpp +++ b/src/gtk1/radiobut.cpp @@ -84,36 +84,31 @@ bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& lab wxRadioButton *chief = (wxRadioButton*) NULL; wxWindowList::Node *node = parent->GetChildren().GetLast(); while (node) - { - wxWindow *child = node->GetData(); - if (child->m_isRadioButton) { - chief = (wxRadioButton*) child; - if (child->HasFlag(wxRB_GROUP)) break; - } - node = node->GetPrevious(); + wxWindow *child = node->GetData(); + if (child->m_isRadioButton) + { + chief = (wxRadioButton*) child; + if (child->HasFlag(wxRB_GROUP)) break; + } + node = node->GetPrevious(); } - if (chief) - { + if (chief) + { /* we are part of the group started by chief */ - m_radioButtonGroup = gtk_radio_button_group( GTK_RADIO_BUTTON(chief->m_widget) ); - } - else - { + m_radioButtonGroup = gtk_radio_button_group( GTK_RADIO_BUTTON(chief->m_widget) ); + } + else + { /* start a new group */ m_radioButtonGroup = (GSList*) NULL; - } + } } m_widget = gtk_radio_button_new_with_label( m_radioButtonGroup, label.mbc_str() ); SetLabel(label); - wxSize newSize = size; - if (newSize.x == -1) newSize.x = 22+gdk_string_measure( m_widget->style->font, label.mbc_str() ); - if (newSize.y == -1) newSize.y = 26; - SetSize( newSize.x, newSize.y ); - gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); @@ -121,9 +116,21 @@ bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& lab PostCreation(); + ApplyWidgetStyle(); + + SetFont( parent->GetFont() ); + + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = size_best.x; + if (new_size.y == -1) + new_size.y = size_best.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); @@ -204,10 +211,15 @@ void wxRadioButton::OnInternalIdle() windows above so that checking for the current cursor is not possible. */ - gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widget)->event_window, cursor.GetCursor() ); + gdk_window_set_cursor( GTK_TOGGLE_BUTTON(m_widget)->event_window, cursor.GetCursor() ); } UpdateWindowUI(); } +wxSize wxRadioButton::DoGetBestSize() const +{ + return wxControl::DoGetBestSize(); +} + #endif diff --git a/src/gtk1/settings.cpp b/src/gtk1/settings.cpp index 99894b71a2..2fde66188c 100644 --- a/src/gtk1/settings.cpp +++ b/src/gtk1/settings.cpp @@ -76,65 +76,78 @@ void wxSystemSettings::Done() wxColour wxSystemSettings::GetSystemColour( int index ) { - switch (index) - { - case wxSYS_COLOUR_SCROLLBAR: - case wxSYS_COLOUR_BACKGROUND: - case wxSYS_COLOUR_ACTIVECAPTION: - case wxSYS_COLOUR_INACTIVECAPTION: - case wxSYS_COLOUR_MENU: - case wxSYS_COLOUR_WINDOWFRAME: - case wxSYS_COLOUR_ACTIVEBORDER: - case wxSYS_COLOUR_INACTIVEBORDER: - case wxSYS_COLOUR_BTNFACE: - { - if (!g_systemBtnFaceColour) - { - g_systemBtnFaceColour = - new wxColour( 0xd6d6 >> SHIFT, - 0xd6d6 >> SHIFT, - 0xd6d6 >> SHIFT ); - } - return *g_systemBtnFaceColour; - } - case wxSYS_COLOUR_WINDOW: - { - return *wxWHITE; - } - case wxSYS_COLOUR_GRAYTEXT: - case wxSYS_COLOUR_BTNSHADOW: - { - if (!g_systemBtnShadowColour) - { - g_systemBtnShadowColour = - new wxColour( 0x7530 >> SHIFT, - 0x7530 >> SHIFT, - 0x7530 >> SHIFT ); - } - return *g_systemBtnShadowColour; - } - case wxSYS_COLOUR_BTNHIGHLIGHT: - { - if (!g_systemBtnHighlightColour) - { - g_systemBtnHighlightColour = - new wxColour( 0xea60 >> SHIFT, - 0xea60 >> SHIFT, - 0xea60 >> SHIFT ); - } - return *g_systemBtnHighlightColour; - } - case wxSYS_COLOUR_HIGHLIGHT: + switch (index) { - if (!g_systemHighlightColour) - { - g_systemHighlightColour = - new wxColour( 0 >> SHIFT, - 0 >> SHIFT, - 0x9c40 >> SHIFT ); - } - return *g_systemHighlightColour; - } + case wxSYS_COLOUR_SCROLLBAR: + case wxSYS_COLOUR_BACKGROUND: + case wxSYS_COLOUR_ACTIVECAPTION: + case wxSYS_COLOUR_INACTIVECAPTION: + case wxSYS_COLOUR_MENU: + case wxSYS_COLOUR_WINDOWFRAME: + case wxSYS_COLOUR_ACTIVEBORDER: + case wxSYS_COLOUR_INACTIVEBORDER: + case wxSYS_COLOUR_BTNFACE: + { + if (!g_systemBtnFaceColour) + { + g_systemBtnFaceColour = + new wxColour( 0xd6d6 >> SHIFT, + 0xd6d6 >> SHIFT, + 0xd6d6 >> SHIFT ); + } + return *g_systemBtnFaceColour; + } + case wxSYS_COLOUR_WINDOW: + { + return *wxWHITE; + } + case wxSYS_COLOUR_GRAYTEXT: + case wxSYS_COLOUR_BTNSHADOW: + { + if (!g_systemBtnShadowColour) + { + g_systemBtnShadowColour = + new wxColour( 0x7530 >> SHIFT, + 0x7530 >> SHIFT, + 0x7530 >> SHIFT ); + } + return *g_systemBtnShadowColour; + } + case wxSYS_COLOUR_BTNHIGHLIGHT: + { + if (!g_systemBtnHighlightColour) + { + g_systemBtnHighlightColour = + new wxColour( 0xea60 >> SHIFT, + 0xea60 >> SHIFT, + 0xea60 >> SHIFT ); + } + return *g_systemBtnHighlightColour; + } + case wxSYS_COLOUR_HIGHLIGHT: + { + if (!g_systemHighlightColour) + { +/* + g_systemHighlightColour = + new wxColour( 0 >> SHIFT, + 0 >> SHIFT, + 0x9c40 >> SHIFT ); +*/ + GtkWidget *widget = gtk_button_new(); + GtkStyle *def = gtk_rc_get_style( widget ); + int red = def->bg[GTK_STATE_SELECTED].red; + int green = def->bg[GTK_STATE_SELECTED].green; + int blue = def->bg[GTK_STATE_SELECTED].blue; + gtk_widget_destroy( widget ); + + g_systemHighlightColour = + new wxColour( red >> SHIFT, + green >> SHIFT, + blue >> SHIFT ); + } + return *g_systemHighlightColour; + } case wxSYS_COLOUR_MENUTEXT: case wxSYS_COLOUR_WINDOWTEXT: case wxSYS_COLOUR_CAPTIONTEXT: @@ -173,7 +186,7 @@ wxFont wxSystemSettings::GetSystemFont( int index ) case wxSYS_DEFAULT_GUI_FONT: { if (!g_systemFont) - g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); + g_systemFont = new wxFont( 16, wxSWISS, wxNORMAL, wxNORMAL ); return *g_systemFont; } } diff --git a/src/gtk1/spinctrl.cpp b/src/gtk1/spinctrl.cpp index 230914ab94..9e51422831 100644 --- a/src/gtk1/spinctrl.cpp +++ b/src/gtk1/spinctrl.cpp @@ -88,24 +88,28 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, m_widget = gtk_spin_button_new( m_adjust, 1, 0 ); - wxSize new_size = size, - sizeBest = DoGetBestSize(); - if (new_size.x == -1) - new_size.x = sizeBest.x; - if (new_size.y == -1) - new_size.y = sizeBest.y; - - if ((new_size.x != size.x) || (new_size.y != size.y)) - SetSize( new_size.x, new_size.y ); - gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget), (int)(m_windowStyle & wxSP_WRAP) ); GtkEnableEvents(); + m_parent->DoAddChild( this ); PostCreation(); + ApplyWidgetStyle(); + + SetFont( parent->GetFont() ); + + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = size_best.x; + if (new_size.y == -1) + new_size.y = size_best.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + SetBackgroundColour( parent->GetBackgroundColour() ); SetValue( value ); diff --git a/src/gtk1/statbox.cpp b/src/gtk1/statbox.cpp index b7697b9ce7..eb53692cfc 100644 --- a/src/gtk1/statbox.cpp +++ b/src/gtk1/statbox.cpp @@ -45,7 +45,7 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxStaticBox creation failed") ); - return FALSE; + return FALSE; } m_isStaticBox = TRUE; @@ -61,9 +61,13 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label SetLabel(label); + ApplyWidgetStyle(); + + SetFont( parent->GetFont() ); + + SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); diff --git a/src/gtk1/stattext.cpp b/src/gtk1/stattext.cpp index 8136ac250c..54d7366a4f 100644 --- a/src/gtk1/stattext.cpp +++ b/src/gtk1/stattext.cpp @@ -62,8 +62,6 @@ bool wxStaticText::Create(wxWindow *parent, wxControl::SetLabel(label); m_widget = gtk_label_new( m_label.mbc_str() ); - wxControl::SetFont( parent->GetFont() ); - GtkJustification justify; if ( style & wxALIGN_CENTER ) justify = GTK_JUSTIFY_CENTER; @@ -80,12 +78,23 @@ bool wxStaticText::Create(wxWindow *parent, // do not move this call elsewhere gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE ); - SetSizeOrDefault( size ); - m_parent->DoAddChild( this ); PostCreation(); + ApplyWidgetStyle(); + + wxControl::SetFont( parent->GetFont() ); + + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); + if (new_size.x == -1) + new_size.x = size_best.x; + if (new_size.y == -1) + new_size.y = size_best.y; + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); + SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); Show( TRUE ); diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index e832dcdf05..ddd7432d18 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -192,20 +192,21 @@ bool wxTextCtrl::Create( wxWindow *parent, m_text = gtk_entry_new(); } - wxSize new_size = size, - sizeBest = DoGetBestSize(); + m_parent->DoAddChild( this ); + + PostCreation(); + + SetFont( parent->GetFont() ); + + wxSize size_best( DoGetBestSize() ); + wxSize new_size( size ); if (new_size.x == -1) - new_size.x = sizeBest.x; + new_size.x = size_best.x; if (new_size.y == -1) - new_size.y = sizeBest.y; - + new_size.y = size_best.y; if ((new_size.x != size.x) || (new_size.y != size.y)) SetSize( new_size.x, new_size.y ); - m_parent->DoAddChild( this ); - - PostCreation(); - if (multi_line) gtk_widget_show(m_text); diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index a1484b1489..6c749174f2 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1634,9 +1634,6 @@ gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win ) if (g_isIdle) wxapp_install_idle_handler(); - if (win->m_delayedFont) - win->SetFont( win->GetFont() ); - if (win->m_delayedBackgroundColour) win->SetBackgroundColour( win->GetBackgroundColour() ); @@ -2025,6 +2022,8 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, PostCreation(); + ApplyWidgetStyle(); + Show( TRUE ); return TRUE; @@ -2963,7 +2962,7 @@ GtkStyle *wxWindow::GetWidgetStyle() { if (m_widgetStyle) gtk_style_unref( m_widgetStyle ); - m_widgetStyle = gtk_style_copy( gtk_widget_get_style( m_widget ) ); + m_widgetStyle = gtk_style_copy( gtk_rc_get_style( m_widget ) ); return m_widgetStyle; } @@ -2972,28 +2971,37 @@ void wxWindow::SetWidgetStyle() { GtkStyle *style = GetWidgetStyle(); - gdk_font_unref( style->font ); - style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) ); + if (m_font != wxSystemSettings::GetSystemFont( wxSYS_DEFAULT_GUI_FONT )) + { + gdk_font_unref( style->font ); + style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) ); + } if (m_foregroundColour.Ok()) { m_foregroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) ); - style->fg[GTK_STATE_NORMAL] = *m_foregroundColour.GetColor(); - style->fg[GTK_STATE_PRELIGHT] = *m_foregroundColour.GetColor(); - style->fg[GTK_STATE_ACTIVE] = *m_foregroundColour.GetColor(); + if (m_foregroundColour != wxSystemSettings::GetSystemColour(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(); + } } if (m_backgroundColour.Ok()) { m_backgroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) ); - 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(); + if (m_backgroundColour != wxSystemSettings::GetSystemColour(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(); + } } } -- 2.47.2