New colour, font, theme and size code..

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5228 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 2000-01-04 13:02:27 +00:00
parent bf9b671186
commit db434467a1
35 changed files with 581 additions and 383 deletions

View File

@ -64,6 +64,9 @@ public:
void ApplyWidgetStyle();
protected:
virtual wxSize DoGetBestSize() const;
private:
DECLARE_DYNAMIC_CLASS(wxButton)
};

View File

@ -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

View File

@ -70,6 +70,9 @@ public:
bool IsOwnGtkWindow( GdkWindow *window );
void OnInternalIdle();
protected:
virtual wxSize DoGetBestSize() const;
private:
DECLARE_DYNAMIC_CLASS(wxRadioButton)
};

View File

@ -64,6 +64,9 @@ public:
void ApplyWidgetStyle();
protected:
virtual wxSize DoGetBestSize() const;
private:
DECLARE_DYNAMIC_CLASS(wxButton)
};

View File

@ -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

View File

@ -70,6 +70,9 @@ public:
bool IsOwnGtkWindow( GdkWindow *window );
void OnInternalIdle();
protected:
virtual wxSize DoGetBestSize() const;
private:
DECLARE_DYNAMIC_CLASS(wxRadioButton)
};

View File

@ -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);

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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 );
}

View File

@ -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 );

View File

@ -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

View File

@ -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:
switch (index)
{
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 );
}
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;
}
}

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );

View File

@ -192,20 +192,21 @@ bool wxTextCtrl::Create( wxWindow *parent,
m_text = gtk_entry_new();
}
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 );
m_parent->DoAddChild( this );
PostCreation();
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 );
if (multi_line)
gtk_widget_show(m_text);

View File

@ -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();
}
}
}

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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 );
}

View File

@ -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 );

View File

@ -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

View File

@ -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:
switch (index)
{
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 );
}
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;
}
}

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );

View File

@ -192,20 +192,21 @@ bool wxTextCtrl::Create( wxWindow *parent,
m_text = gtk_entry_new();
}
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 );
m_parent->DoAddChild( this );
PostCreation();
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 );
if (multi_line)
gtk_widget_show(m_text);

View File

@ -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();
}
}
}