From: Vadim Zeitlin Date: Tue, 22 Sep 2009 00:23:03 +0000 (+0000) Subject: Add a separate wxControlRenderer::DrawButtonLabel() too. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/fdc468a0a6476eff5996c80580e27b506340c305 Add a separate wxControlRenderer::DrawButtonLabel() too. wxControlRenderer::DrawLabel() was used by both wxStaticText and wxButton but their labels may need to be drawn differently and wxRenderer does have different DrawLabel() and DrawButtonLabel() to do it. Now also add a separate method for the buttons to wxControlRenderer. See #11220. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62004 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/univ/renderer.h b/include/wx/univ/renderer.h index cec9197297..c03a245dc3 100644 --- a/include/wx/univ/renderer.h +++ b/include/wx/univ/renderer.h @@ -870,8 +870,9 @@ public: wxControlRenderer(wxWindow *control, wxDC& dc, wxRenderer *renderer); // operations - void DrawLabel(const wxBitmap& bitmap = wxNullBitmap, - wxCoord marginX = 0, wxCoord marginY = 0); + void DrawLabel(); + void DrawButtonLabel(const wxBitmap& bitmap = wxNullBitmap, + wxCoord marginX = 0, wxCoord marginY = 0); #if wxUSE_LISTBOX void DrawItems(const wxListBox *listbox, size_t itemFirst, size_t itemLast); diff --git a/src/univ/button.cpp b/src/univ/button.cpp index 05f3c3373f..4d9a843084 100644 --- a/src/univ/button.cpp +++ b/src/univ/button.cpp @@ -213,7 +213,7 @@ void wxButton::DoDraw(wxControlRenderer *renderer) renderer->DrawButtonBorder(); } - renderer->DrawLabel(m_bitmap, m_marginBmpX, m_marginBmpY); + renderer->DrawButtonLabel(m_bitmap, m_marginBmpX, m_marginBmpY); } bool wxButton::DoDrawBackground(wxDC& dc) diff --git a/src/univ/ctrlrend.cpp b/src/univ/ctrlrend.cpp index 60d561ea24..1a55bb9576 100644 --- a/src/univ/ctrlrend.cpp +++ b/src/univ/ctrlrend.cpp @@ -67,8 +67,28 @@ wxControlRenderer::wxControlRenderer(wxWindow *window, m_rect.height = size.y; } -void wxControlRenderer::DrawLabel(const wxBitmap& bitmap, - wxCoord marginX, wxCoord marginY) +void wxControlRenderer::DrawLabel() +{ + m_dc.SetBackgroundMode(wxTRANSPARENT); + m_dc.SetFont(m_window->GetFont()); + m_dc.SetTextForeground(m_window->GetForegroundColour()); + + wxString label = m_window->GetLabel(); + if ( !label.empty() ) + { + wxControl *ctrl = wxStaticCast(m_window, wxControl); + + m_renderer->DrawLabel(m_dc, + label, + m_rect, + m_window->GetStateFlags(), + ctrl->GetAlignment(), + ctrl->GetAccelIndex()); + } +} + +void wxControlRenderer::DrawButtonLabel(const wxBitmap& bitmap, + wxCoord marginX, wxCoord marginY) { m_dc.SetBackgroundMode(wxTRANSPARENT); m_dc.SetFont(m_window->GetFont());