]> git.saurik.com Git - wxWidgets.git/commitdiff
Show status bar panes rectangles in the sample.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 21 Sep 2009 13:00:07 +0000 (13:00 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 21 Sep 2009 13:00:07 +0000 (13:00 +0000)
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

samples/statbar/statbar.cpp

index f8f1e92cb164d692ef29c6311232e696468f9d1d..be3119d5e84b039f4395497e9f5c2ffb838cf6e1 100644 (file)
@@ -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);