From: Vadim Zeitlin Date: Mon, 21 Sep 2009 13:00:07 +0000 (+0000) Subject: Show status bar panes rectangles in the sample. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ee38a8cf7f2b8ad296f4968252bd5552d70e1bbf Show status bar panes rectangles in the sample. Display the rectangles returned by wxStatusBar::GetFieldRect() to be able to visually check if they are correct. See #10696. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/statbar/statbar.cpp b/samples/statbar/statbar.cpp index f8f1e92cb1..be3119d5e8 100644 --- a/samples/statbar/statbar.cpp +++ b/samples/statbar/statbar.cpp @@ -30,6 +30,7 @@ // for all others, include the necessary headers #ifndef WX_PRECOMP #include "wx/app.h" + #include "wx/dcclient.h" #include "wx/log.h" #include "wx/frame.h" #include "wx/statusbr.h" @@ -163,6 +164,7 @@ public: void OnPopStatusText(wxCommandEvent& event); void OnResetFieldsWidth(wxCommandEvent& event); + void OnShowFieldsRect(wxCommandEvent& event); void OnSetStatusFields(wxCommandEvent& event); void OnSetStatusFont(wxCommandEvent& event); void OnRecreateStatusBar(wxCommandEvent& event); @@ -221,6 +223,7 @@ enum StatusBar_PopText, StatusBar_SetFont, StatusBar_ResetFieldsWidth, + StatusBar_ShowFieldsRect, StatusBar_Recreate, StatusBar_Toggle, @@ -260,6 +263,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(StatusBar_PopText, MyFrame::OnPopStatusText) EVT_MENU(StatusBar_SetFont, MyFrame::OnSetStatusFont) EVT_MENU(StatusBar_ResetFieldsWidth, MyFrame::OnResetFieldsWidth) + EVT_MENU(StatusBar_ShowFieldsRect, MyFrame::OnShowFieldsRect) EVT_MENU(StatusBar_Recreate, MyFrame::OnRecreateStatusBar) EVT_MENU(StatusBar_About, MyFrame::OnAbout) EVT_MENU(StatusBar_Toggle, MyFrame::OnStatusBarToggle) @@ -411,6 +415,9 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) statbarMenu->Append(StatusBar_ResetFieldsWidth, wxT("Reset field widths"), wxT("Sets all fields to the same width")); + statbarMenu->Append(StatusBar_ShowFieldsRect, + wxT("Sho&w field rectangles\tCtrl-W"), + wxT("Visually show field rectangles")); statbarMenu->AppendSeparator(); statbarMenu->AppendCheckItem(StatusBar_Toggle, wxT("&Toggle Status Bar"), @@ -659,6 +666,25 @@ void MyFrame::OnResetFieldsWidth(wxCommandEvent& WXUNUSED(event)) pStat->SetStatusText("same size", i); } +void MyFrame::OnShowFieldsRect(wxCommandEvent& WXUNUSED(event)) +{ + wxStatusBar *pStat = GetStatusBar(); + if ( !pStat ) + return; + + wxClientDC dc(pStat); + dc.SetPen(*wxRED_PEN); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + + const int n = pStat->GetFieldsCount(); + for ( int i = 0; i < n; i++ ) + { + wxRect r; + if ( pStat->GetFieldRect(i, r) ) + dc.DrawRectangle(r); + } +} + void MyFrame::OnUpdateStatusBarToggle(wxUpdateUIEvent& event) { event.Check(GetStatusBar() != NULL);