From 2a90b100687149c030cbda96e3b5d1fb0d8f118d Mon Sep 17 00:00:00 2001 From: Francesco Montorsi Date: Sun, 8 Feb 2009 22:11:26 +0000 Subject: [PATCH] allow the user to set the status bar font git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58776 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/statbar/statbar.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/samples/statbar/statbar.cpp b/samples/statbar/statbar.cpp index a8b0c69a8a..1c5c0a008b 100644 --- a/samples/statbar/statbar.cpp +++ b/samples/statbar/statbar.cpp @@ -48,6 +48,7 @@ #include "wx/datetime.h" #include "wx/numdlg.h" +#include "wx/fontdlg.h" #ifndef __WXMSW__ #include "../sample.xpm" @@ -160,6 +161,7 @@ class MyFrame : public wxMDIParentFrame void OnResetFieldsWidth(wxCommandEvent& event); void OnSetStatusFields(wxCommandEvent& event); void OnSetStatusTexts(wxCommandEvent& event); + void OnSetStatusFont(wxCommandEvent& event); void OnRecreateStatusBar(wxCommandEvent& event); void OnSetStyleNormal(wxCommandEvent& event); void OnSetStyleFlat(wxCommandEvent& event); @@ -211,6 +213,7 @@ enum StatusBar_SetFields, StatusBar_SetTexts, + StatusBar_SetFont, StatusBar_ResetFieldsWidth, StatusBar_Recreate, @@ -241,6 +244,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(StatusBar_Quit, MyFrame::OnQuit) EVT_MENU(StatusBar_SetFields, MyFrame::OnSetStatusFields) EVT_MENU(StatusBar_SetTexts, MyFrame::OnSetStatusTexts) + EVT_MENU(StatusBar_SetFont, MyFrame::OnSetStatusFont) EVT_MENU(StatusBar_ResetFieldsWidth, MyFrame::OnResetFieldsWidth) EVT_MENU(StatusBar_Recreate, MyFrame::OnRecreateStatusBar) EVT_MENU(StatusBar_About, MyFrame::OnAbout) @@ -337,6 +341,8 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) _T("Set the number of status bar fields")); statbarMenu->Append(StatusBar_SetTexts, _T("&Set field text\tCtrl-T"), _T("Set the text to display for each status bar field")); + statbarMenu->Append(StatusBar_SetFont, _T("&Set field font\tCtrl-F"), + _T("Set the font to use for rendering status bar fields")); wxMenu *statbarStyleMenu = new wxMenu; statbarStyleMenu->Append(StatusBar_SetStyleNormal, _T("&Normal"), _T("Sets the style of the first field to normal (sunken) look"), true); @@ -442,6 +448,18 @@ void MyFrame::OnSetStatusTexts(wxCommandEvent& WXUNUSED(event)) } } +void MyFrame::OnSetStatusFont(wxCommandEvent& WXUNUSED(event)) +{ + wxStatusBar *sb = GetStatusBar(); + + wxFont fnt = wxGetFontFromUser(this, sb->GetFont(), "Choose statusbar font"); + if (fnt.IsOk()) + { + sb->SetFont(fnt); + sb->SetSize(sb->GetBestSize()); + } +} + void MyFrame::OnSetStatusFields(wxCommandEvent& WXUNUSED(event)) { wxStatusBar *sb = GetStatusBar();