From 616ad0d92b957dbd625a2905ea4e4320a23c4606 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 25 Oct 2019 02:47:50 +0200 Subject: [PATCH] Show status bar fields coordinates in a message box in the sample Showing them directly on the screen using wxClientDC doesn't work in all ports, notable under Mac. See #18469. --- samples/statbar/statbar.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/samples/statbar/statbar.cpp b/samples/statbar/statbar.cpp index 9a4f0e4128..3811033306 100644 --- a/samples/statbar/statbar.cpp +++ b/samples/statbar/statbar.cpp @@ -668,13 +668,28 @@ void MyFrame::OnShowFieldsRect(wxCommandEvent& WXUNUSED(event)) dc.SetPen(*wxRED_PEN); dc.SetBrush(*wxTRANSPARENT_BRUSH); + // Not all systems support drawing using wxClientDC, so also show the + // coordinates in a message box. + wxString msg; + const wxSize size = pStat->GetClientSize(); + msg.Printf("Status bar client size is (%d,%d)\n\n", size.x, size.y); + const int n = pStat->GetFieldsCount(); for ( int i = 0; i < n; i++ ) { wxRect r; if ( pStat->GetFieldRect(i, r) ) + { + msg += wxString::Format("Field %d rectangle is (%d,%d)-(%d,%d)\n", + i, + r.x, r.y, + r.x + r.width, + r.y + r.height); dc.DrawRectangle(r); + } } + + wxLogMessage("%s", msg); } void MyFrame::OnUpdateStatusBarToggle(wxUpdateUIEvent& event)