X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1f0c8f31f407ecfce909060464c0ea655221cdab..833e100f7ff356db8469721ae104b6b2177c0dae:/src/osx/carbon/statbrma.cpp diff --git a/src/osx/carbon/statbrma.cpp b/src/osx/carbon/statbrma.cpp index ba190b0df3..a23e9180ac 100644 --- a/src/osx/carbon/statbrma.cpp +++ b/src/osx/carbon/statbrma.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/statbarma.cpp +// Name: src/osx/carbon/statbarma.cpp // Purpose: native implementation of wxStatusBar (optional) // Author: Stefan Csomor // Modified by: @@ -23,6 +23,9 @@ #include "wx/osx/private.h" +// Margin between the field text and the field rect +#define wxFIELD_TEXT_MARGIN 2 + BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric) EVT_PAINT(wxStatusBarMac::OnPaint) @@ -58,7 +61,7 @@ bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, if ( !wxStatusBarGeneric::Create( parent, id, style, name ) ) return false; - if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() ) + if ( parent->MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL ) SetBackgroundStyle( wxBG_STYLE_TRANSPARENT ); // normal system font is too tall for fitting into the standard height @@ -67,55 +70,49 @@ bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, return true; } -void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) +void wxStatusBarMac::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int WXUNUSED(textHeight)) { int w, h; GetSize( &w , &h ); - wxRect rect; - GetFieldRect( i, rect ); if ( !MacIsReallyHilited() ) dc.SetTextForeground( wxColour( 0x80, 0x80, 0x80 ) ); wxString text(GetStatusText( i )); - wxCoord x, y; - dc.GetTextExtent(text, &x, &y); + /*wxCoord x, y; + dc.GetTextExtent(text, &x, &y); -- seems unused (FM)*/ - int leftMargin = 2; - int xpos = rect.x + leftMargin + 1; + int xpos = rect.x + wxFIELD_TEXT_MARGIN + 1; int ypos = 1; - if ( MacGetTopLevelWindow()->MacGetMetalAppearance() ) + if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL ) ypos++; dc.SetClippingRegion(rect.x, 0, rect.width, h); - dc.DrawText(text, xpos, ypos); - dc.DestroyClippingRegion(); } -void wxStatusBarMac::DrawField(wxDC& dc, int i) +void wxStatusBarMac::DrawField(wxDC& dc, int i, int textHeight) { - DrawFieldText(dc, i); + wxRect rect; + GetFieldRect(i, rect); + + DrawFieldText(dc, rect, i, textHeight); } -void wxStatusBarMac::SetStatusText(const wxString& text, int number) +void wxStatusBarMac::DoUpdateStatusText(int number) { - wxCHECK_RET( (number >= 0) && (number < m_nFields), - wxT("invalid status bar field index") ); - - if ( m_statusStrings[number] == text ) - return ; - - m_statusStrings[number] = text; wxRect rect; GetFieldRect(number, rect); + int w, h; GetSize( &w, &h ); + rect.y = 0; rect.height = h ; + Refresh( true, &rect ); Update(); } @@ -136,7 +133,7 @@ void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event)) if (major >= 10) { // Finder statusbar border color: (Project Builder similar is 9B9B9B) - if ( MacGetTopLevelWindow()->MacGetMetalAppearance() ) + if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL ) dc.SetPen(wxPen(wxColour(0x40, 0x40, 0x40), 1, wxSOLID)); else dc.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID)); @@ -162,13 +159,15 @@ void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event)) dc.DrawLine(0, 0, w, 0); } - int i; - if ( GetFont().Ok() ) + if ( GetFont().IsOk() ) dc.SetFont(GetFont()); dc.SetBackgroundMode(wxTRANSPARENT); - for ( i = 0; i < m_nFields; i ++ ) - DrawField(dc, i); + // compute char height only once for all panes: + int textHeight = dc.GetCharHeight(); + + for ( size_t i = 0; i < m_panes.GetCount(); i ++ ) + DrawField(dc, i, textHeight); } void wxStatusBarMac::MacHiliteChanged()