From 7bce6aec996f0e9da49963af7183f7bc9cd1fca3 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 30 Oct 1998 19:37:03 +0000 Subject: [PATCH] Fixes to fonts, static text, radiobox, frame git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@944 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/gtk/todo.txt | 2 +- include/wx/generic/treectrl.h | 2 +- samples/controls/controls.cpp | 54 +++++++++++++++++++++----------- samples/controls/icons/gauge.xpm | 27 ++++++++++++++++ src/gtk/combobox.cpp | 4 +-- src/gtk/font.cpp | 21 ++++++++++--- src/gtk/frame.cpp | 4 ++- src/gtk/listbox.cpp | 4 +-- src/gtk/radiobox.cpp | 2 +- src/gtk/stattext.cpp | 45 +++++++++++++------------- src/gtk1/combobox.cpp | 4 +-- src/gtk1/font.cpp | 21 ++++++++++--- src/gtk1/frame.cpp | 4 ++- src/gtk1/listbox.cpp | 4 +-- src/gtk1/radiobox.cpp | 2 +- src/gtk1/stattext.cpp | 45 +++++++++++++------------- user/wxTest/wxTest.cpp | 3 +- 17 files changed, 162 insertions(+), 86 deletions(-) create mode 100644 samples/controls/icons/gauge.xpm diff --git a/docs/gtk/todo.txt b/docs/gtk/todo.txt index 4065f62bc2..dd92811715 100644 --- a/docs/gtk/todo.txt +++ b/docs/gtk/todo.txt @@ -5,7 +5,7 @@ wxTreeCtrl -> Make it compile. Keyboard handling, icon support. wxListCtrl - -> Icon support in list mode. Backgroundcolour, font? + -> Icon support in list mode wxClipboard -> Urgh. diff --git a/include/wx/generic/treectrl.h b/include/wx/generic/treectrl.h index 31afdb3d16..4cd110949e 100644 --- a/include/wx/generic/treectrl.h +++ b/include/wx/generic/treectrl.h @@ -56,7 +56,7 @@ public: wxTreeItemId(long itemId) { m_pItem = (wxGenericTreeItem *)itemId; } operator long() const { return (long)m_pItem; } -protected: +//protected: // for wxTreeCtrl usage only wxTreeItemId(wxGenericTreeItem *pItem) { m_pItem = pItem; } diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 8ce29591c8..fa791e095f 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -64,6 +64,7 @@ class MyPanel: public wxPanel void OnRadioButtons( wxCommandEvent &event ); void OnSetFont( wxCommandEvent &event ); void OnPageChanged( wxNotebookEvent &event ); + void OnSliderUpdate( wxCommandEvent &event ); wxListBox *m_listbox; wxChoice *m_choice; @@ -215,12 +216,13 @@ BEGIN_EVENT_TABLE(MyPanel, wxPanel) EVT_BUTTON (ID_RADIOBOX_FONT, MyPanel::OnRadioButtons) EVT_CHECKBOX (ID_RADIOBOX_ENABLE, MyPanel::OnRadioButtons) EVT_BUTTON (ID_SET_FONT, MyPanel::OnSetFont) + EVT_SLIDER (ID_SLIDER, MyPanel::OnSliderUpdate) END_EVENT_TABLE() MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) ) { -// SetBackgroundColour("cadet blue"); + SetBackgroundColour("cadet blue"); m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE ); m_text->SetBackgroundColour("wheat"); @@ -291,8 +293,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : m_notebook->AddPage(panel, "wxList", FALSE, Image_List); panel = new wxPanel(m_notebook); -// panel->SetBackgroundColour("cadet blue"); -// panel->SetForegroundColour("blue"); + panel->SetBackgroundColour("cadet blue"); + panel->SetForegroundColour("blue"); m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices ); m_choice->SetBackgroundColour("wheat"); (void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); @@ -305,10 +307,10 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice); panel = new wxPanel(m_notebook); -// panel->SetBackgroundColour("cadet blue"); -// panel->SetForegroundColour("blue"); + panel->SetBackgroundColour("cadet blue"); + panel->SetForegroundColour("blue"); m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 5, choices ); -// m_combo->SetBackgroundColour("wheat"); + m_combo->SetBackgroundColour("wheat"); (void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); (void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) ); (void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) ); @@ -319,12 +321,12 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : m_notebook->AddPage(panel, "wxComboBox", FALSE, Image_Combo); panel = new wxPanel(m_notebook); -// panel->SetBackgroundColour("cadet blue"); -// panel->SetForegroundColour("blue"); + panel->SetBackgroundColour("cadet blue"); + panel->SetForegroundColour("blue"); wxTextCtrl *tc = new wxTextCtrl( panel, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(350,28)); -// tc->SetBackgroundColour("wheat"); + tc->SetBackgroundColour("wheat"); tc = new wxTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(350,160), wxTE_MULTILINE ); -// tc->SetBackgroundColour("wheat"); + tc->SetBackgroundColour("wheat"); m_notebook->AddPage(panel, "wxTextCtrl" , FALSE, Image_Text); wxString choices2[] = @@ -334,12 +336,12 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : }; panel = new wxPanel(m_notebook); -// panel->SetBackgroundColour("cadet blue"); -// panel->SetForegroundColour("blue"); + panel->SetBackgroundColour("cadet blue"); + panel->SetForegroundColour("blue"); m_radio = new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), 2, choices2, 1, wxRA_HORIZONTAL ); -// m_radio->SetBackgroundColour("wheat"); + m_radio->SetBackgroundColour("wheat"); m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), 5, choices, 1, wxRA_VERTICAL ); -// m_radio->SetBackgroundColour("wheat"); + m_radio->SetBackgroundColour("wheat"); (void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); (void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(180,80), wxSize(140,30) ); (void)new wxButton( panel, ID_RADIOBOX_FONT, "Set Italic font", wxPoint(180,130), wxSize(140,30) ); @@ -348,13 +350,22 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : m_notebook->AddPage(panel, "wxRadioBox", FALSE, Image_Radio); panel = new wxPanel(m_notebook); -// panel->SetBackgroundColour("cadet blue"); -// panel->SetForegroundColour("blue"); + panel->SetBackgroundColour("cadet blue"); + panel->SetForegroundColour("blue"); (void)new wxStaticBox( panel, -1, "wxGauge and wxSlider", wxPoint(10,10), wxSize(180,130) ); m_gauge = new wxGauge( panel, -1, 200, wxPoint(18,50), wxSize(155,-1) ); -// m_gauge->SetBackgroundColour("wheat"); - m_slider = new wxSlider( panel, -1, 0, 0, 200, wxPoint(18,90), wxSize(155,-1) ); -// m_slider->SetBackgroundColour("wheat"); + m_gauge->SetBackgroundColour("wheat"); + m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200, wxPoint(18,90), wxSize(155,-1) ); + m_slider->SetBackgroundColour("wheat"); + (void)new wxStaticBox( panel, -1, "Explanation", wxPoint(200,10), wxSize(290,130) ); + (void)new wxStaticText( panel, -1, + "In order see the gauge (aka progress bar)\n" + "control do something you have to drag the\n" + "handle of the slider to the right.\n" + "\n" + "This is also supposed to demonstrate how\n" + "to use static controls.\n", + wxPoint(208,25) ); m_notebook->AddPage(panel, "wxGauge", FALSE, Image_Gauge); } @@ -563,6 +574,11 @@ void MyPanel::OnSetFont( wxCommandEvent &WXUNUSED(event) ) m_text->SetFont( *wxITALIC_FONT ); } +void MyPanel::OnSliderUpdate( wxCommandEvent &WXUNUSED(event) ) +{ + m_gauge->SetValue( m_slider->GetValue() ); +} + MyPanel::~MyPanel() { delete m_notebook->GetImageList(); diff --git a/samples/controls/icons/gauge.xpm b/samples/controls/icons/gauge.xpm new file mode 100644 index 0000000000..947bbdf024 --- /dev/null +++ b/samples/controls/icons/gauge.xpm @@ -0,0 +1,27 @@ +/* XPM */ +static char * gauge_xpm[] = { +/* width height ncolors chars_per_pixel */ +"16 16 5 1", +/* colors */ +" s None c None", +". c #000000", +"+ c #000080", +"@ c #c0c0c0", +"# c #808080", +/* pixels */ +" ", +" ", +" ", +"################", +"#..............#", +"#.++++++++@@@@@#", +"#.++++++++@@@@@#", +"#.++++++++@@@@@#", +"#.++++++++@@@@@#", +"#.++++++++@@@@@#", +"#.++++++++@@@@@#", +"#.++++++++@@@@@#", +"################", +" ", +" ", +" "}; diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 38e40a9642..1b72045d73 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -136,8 +136,6 @@ void wxComboBox::Append( const wxString &item, char *clientData ) GtkWidget *list_item = gtk_list_item_new_with_label( item ); - if (m_widgetStyle) ApplyWidgetStyle(); - gtk_signal_connect( GTK_OBJECT(list_item), "select", GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); @@ -145,6 +143,8 @@ void wxComboBox::Append( const wxString &item, char *clientData ) gtk_container_add( GTK_CONTAINER(list), list_item ); + if (m_widgetStyle) ApplyWidgetStyle(); + gtk_widget_show( list_item ); } diff --git a/src/gtk/font.cpp b/src/gtk/font.cpp index a8c1aacb2d..e7685ea382 100644 --- a/src/gtk/font.cpp +++ b/src/gtk/font.cpp @@ -102,6 +102,9 @@ wxFont::wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight, { m_refData = new wxFontRefData(); + if (FontIdOrFamily == wxDEFAULT) FontIdOrFamily = wxSWISS; + M_FONTDATA->m_family = FontIdOrFamily; + if ((M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL) ) { M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, FontIdOrFamily ); @@ -112,11 +115,12 @@ wxFont::wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight, M_FONTDATA->m_fontId = FontIdOrFamily; M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily ); } - if (Style == wxDEFAULT) Style = wxSWISS; + + if (Style == wxDEFAULT) Style = wxNORMAL; M_FONTDATA->m_style = Style; if (Weight == wxDEFAULT) Weight = wxNORMAL; M_FONTDATA->m_weight = Weight; - if (PointSize == wxDEFAULT) PointSize = 10; + if (PointSize == wxDEFAULT) PointSize = 12; M_FONTDATA->m_pointSize = PointSize; M_FONTDATA->m_underlined = Underlined; @@ -361,12 +365,19 @@ GdkFont *wxFont::GetInternalFont(float scale) const } else { +/* + if (int_scale == 100) printf( "int_scale.\n" ); + if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" ); + if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" ); + if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" ); + if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" ); +*/ if ((int_scale == 100) && - (M_FONTDATA->m_style == wxSWISS) && + (M_FONTDATA->m_family == wxSWISS) && + (M_FONTDATA->m_style == wxNORMAL) && (M_FONTDATA->m_pointSize == 12) && (M_FONTDATA->m_weight == wxNORMAL) && - (M_FONTDATA->m_underlined == FALSE) && - (M_FONTDATA->m_style == wxNORMAL)) + (M_FONTDATA->m_underlined == FALSE)) { font = gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" ); } diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 838f26607c..235078cff1 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -337,7 +337,9 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height if (m_frameToolBar) { - gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, wxMENU_HEIGHT ); + int y = 0; + if (m_frameMenuBar) y = wxMENU_HEIGHT; + gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, y ); gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height ); } diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 995a81a402..bca38181d5 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -144,8 +144,6 @@ void wxListBox::Append( const wxString &item, char *clientData ) GtkWidget *list_item = gtk_list_item_new_with_label( item ); - if (m_widgetStyle) ApplyWidgetStyle(); - gtk_signal_connect( GTK_OBJECT(list_item), "select", GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this ); @@ -159,6 +157,8 @@ void wxListBox::Append( const wxString &item, char *clientData ) gtk_container_add( GTK_CONTAINER(m_list), list_item ); + if (m_widgetStyle) ApplyWidgetStyle(); + gtk_widget_show( list_item ); ConnectWidget( list_item ); diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index fab780db60..c9e905199e 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -104,7 +104,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y ); - int tmp = 22+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] ); + int tmp = 25+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] ); if (tmp > maxLen) maxLen = tmp; width = m_width-10; diff --git a/src/gtk/stattext.cpp b/src/gtk/stattext.cpp index 48a3173820..978321af9f 100644 --- a/src/gtk/stattext.cpp +++ b/src/gtk/stattext.cpp @@ -54,37 +54,40 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe gtk_label_set_justify(GTK_LABEL(m_widget), justify); int y = 1; - if (newSize.x == -1) { + if (newSize.x == -1) + { char *s = WXSTRINGCAST m_label; char *nl = strchr(s, '\n'); - if (nl) { - do { + if (nl) + { + do + { *nl = 0; - int x = gdk_string_measure( m_widget->style->font, s ); - if (x > newSize.x) { - newSize.x = x; - } + int x = gdk_string_measure( m_widget->style->font, s ) + 4; + if (x > newSize.x) newSize.x = x; *nl++ = '\n'; - if ((nl = strchr(s = nl, '\n'))) { + if ((nl = strchr(s = nl, '\n'))) + { ++y; - } else { - int x = gdk_string_measure( m_widget->style->font, s ); - if (x > newSize.x) { - newSize.x = x; - } + } + else + { + int x = gdk_string_measure( m_widget->style->font, s ) + 4; + if (x > newSize.x) newSize.x = x; } } while (nl); - } else { - newSize.x = gdk_string_measure( m_widget->style->font, label ); + } + else + { + newSize.x = gdk_string_measure( m_widget->style->font, label ) + 4; } } - if (newSize.y == -1) { - if (y == 1) { + if (newSize.y == -1) + { + if (y == 1) newSize.y = 26; - } else { - newSize.y - = y * (m_widget->style->font->ascent +m_widget->style->font->descent); - } + else + newSize.y = 4 + y * (m_widget->style->font->ascent + 2*m_widget->style->font->descent); } SetSize( newSize.x, newSize.y ); diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 38e40a9642..1b72045d73 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -136,8 +136,6 @@ void wxComboBox::Append( const wxString &item, char *clientData ) GtkWidget *list_item = gtk_list_item_new_with_label( item ); - if (m_widgetStyle) ApplyWidgetStyle(); - gtk_signal_connect( GTK_OBJECT(list_item), "select", GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); @@ -145,6 +143,8 @@ void wxComboBox::Append( const wxString &item, char *clientData ) gtk_container_add( GTK_CONTAINER(list), list_item ); + if (m_widgetStyle) ApplyWidgetStyle(); + gtk_widget_show( list_item ); } diff --git a/src/gtk1/font.cpp b/src/gtk1/font.cpp index a8c1aacb2d..e7685ea382 100644 --- a/src/gtk1/font.cpp +++ b/src/gtk1/font.cpp @@ -102,6 +102,9 @@ wxFont::wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight, { m_refData = new wxFontRefData(); + if (FontIdOrFamily == wxDEFAULT) FontIdOrFamily = wxSWISS; + M_FONTDATA->m_family = FontIdOrFamily; + if ((M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL) ) { M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, FontIdOrFamily ); @@ -112,11 +115,12 @@ wxFont::wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight, M_FONTDATA->m_fontId = FontIdOrFamily; M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily ); } - if (Style == wxDEFAULT) Style = wxSWISS; + + if (Style == wxDEFAULT) Style = wxNORMAL; M_FONTDATA->m_style = Style; if (Weight == wxDEFAULT) Weight = wxNORMAL; M_FONTDATA->m_weight = Weight; - if (PointSize == wxDEFAULT) PointSize = 10; + if (PointSize == wxDEFAULT) PointSize = 12; M_FONTDATA->m_pointSize = PointSize; M_FONTDATA->m_underlined = Underlined; @@ -361,12 +365,19 @@ GdkFont *wxFont::GetInternalFont(float scale) const } else { +/* + if (int_scale == 100) printf( "int_scale.\n" ); + if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" ); + if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" ); + if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" ); + if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" ); +*/ if ((int_scale == 100) && - (M_FONTDATA->m_style == wxSWISS) && + (M_FONTDATA->m_family == wxSWISS) && + (M_FONTDATA->m_style == wxNORMAL) && (M_FONTDATA->m_pointSize == 12) && (M_FONTDATA->m_weight == wxNORMAL) && - (M_FONTDATA->m_underlined == FALSE) && - (M_FONTDATA->m_style == wxNORMAL)) + (M_FONTDATA->m_underlined == FALSE)) { font = gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" ); } diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 838f26607c..235078cff1 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -337,7 +337,9 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height if (m_frameToolBar) { - gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, wxMENU_HEIGHT ); + int y = 0; + if (m_frameMenuBar) y = wxMENU_HEIGHT; + gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, y ); gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height ); } diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index 995a81a402..bca38181d5 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -144,8 +144,6 @@ void wxListBox::Append( const wxString &item, char *clientData ) GtkWidget *list_item = gtk_list_item_new_with_label( item ); - if (m_widgetStyle) ApplyWidgetStyle(); - gtk_signal_connect( GTK_OBJECT(list_item), "select", GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this ); @@ -159,6 +157,8 @@ void wxListBox::Append( const wxString &item, char *clientData ) gtk_container_add( GTK_CONTAINER(m_list), list_item ); + if (m_widgetStyle) ApplyWidgetStyle(); + gtk_widget_show( list_item ); ConnectWidget( list_item ); diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp index fab780db60..c9e905199e 100644 --- a/src/gtk1/radiobox.cpp +++ b/src/gtk1/radiobox.cpp @@ -104,7 +104,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y ); - int tmp = 22+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] ); + int tmp = 25+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] ); if (tmp > maxLen) maxLen = tmp; width = m_width-10; diff --git a/src/gtk1/stattext.cpp b/src/gtk1/stattext.cpp index 48a3173820..978321af9f 100644 --- a/src/gtk1/stattext.cpp +++ b/src/gtk1/stattext.cpp @@ -54,37 +54,40 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe gtk_label_set_justify(GTK_LABEL(m_widget), justify); int y = 1; - if (newSize.x == -1) { + if (newSize.x == -1) + { char *s = WXSTRINGCAST m_label; char *nl = strchr(s, '\n'); - if (nl) { - do { + if (nl) + { + do + { *nl = 0; - int x = gdk_string_measure( m_widget->style->font, s ); - if (x > newSize.x) { - newSize.x = x; - } + int x = gdk_string_measure( m_widget->style->font, s ) + 4; + if (x > newSize.x) newSize.x = x; *nl++ = '\n'; - if ((nl = strchr(s = nl, '\n'))) { + if ((nl = strchr(s = nl, '\n'))) + { ++y; - } else { - int x = gdk_string_measure( m_widget->style->font, s ); - if (x > newSize.x) { - newSize.x = x; - } + } + else + { + int x = gdk_string_measure( m_widget->style->font, s ) + 4; + if (x > newSize.x) newSize.x = x; } } while (nl); - } else { - newSize.x = gdk_string_measure( m_widget->style->font, label ); + } + else + { + newSize.x = gdk_string_measure( m_widget->style->font, label ) + 4; } } - if (newSize.y == -1) { - if (y == 1) { + if (newSize.y == -1) + { + if (y == 1) newSize.y = 26; - } else { - newSize.y - = y * (m_widget->style->font->ascent +m_widget->style->font->descent); - } + else + newSize.y = 4 + y * (m_widget->style->font->ascent + 2*m_widget->style->font->descent); } SetSize( newSize.x, newSize.y ); diff --git a/user/wxTest/wxTest.cpp b/user/wxTest/wxTest.cpp index 4ffdab896b..a43d89fda8 100644 --- a/user/wxTest/wxTest.cpp +++ b/user/wxTest/wxTest.cpp @@ -445,6 +445,7 @@ END_EVENT_TABLE() MyFrame::MyFrame(void) : wxFrame( (wxFrame *) NULL, -1, (char *) "Robert's Test application", wxPoint(20,20), wxSize(470,360) ) { +/* wxMenu *file_menu = new wxMenu( "Test" ); file_menu->Append( ID_OPEN, "Open.."); file_menu->Append( ID_MSG, "MessageBox.."); @@ -460,6 +461,7 @@ MyFrame::MyFrame(void) : menu_bar->Show( TRUE ); SetMenuBar( menu_bar ); +*/ CreateStatusBar( 2 ); @@ -470,7 +472,6 @@ MyFrame::MyFrame(void) : m_canvas->SetScrollbars( 10, 10, 50, 50 ); m_tb = CreateToolBar(); - m_tb->SetMargins( 2, 2 ); m_tb->AddTool( 0, wxBitmap( list_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "This is a button" ); m_tb->AddTool( 0, wxBitmap( folder_xpm ), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, "This is a toggle" ); m_tb->Realize(); -- 2.45.2