Remove redundant code from wxStatusBarMac
Remove a lot of Mac-specific code from wxStatusBarMac in favour of using shared wxStatusBarGeneric: - Now that wxFRAME_EX_METAL aka NSWindowStyleMaskTexturedBackground doesn’t affect text placement, there’s no reason for customized DrawFieldText(). As a side effect of this removal, ellipsizing fields is now supported. - Remove customized DoUpdateStatusText() code that is no longer needed. See https://github.com/wxWidgets/wxWidgets/pull/2160#pullrequestreview-563916013
This commit is contained in:
@@ -70,7 +70,7 @@ protected:
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||
|
||||
protected:
|
||||
|
||||
virtual int GetEffectiveFieldStyle(int i) const { return m_panes[i].GetStyle(); }
|
||||
virtual void DrawFieldText(wxDC& dc, const wxRect& rc, int i, int textHeight);
|
||||
virtual void DrawField(wxDC& dc, int i, int textHeight);
|
||||
|
||||
|
@@ -31,9 +31,7 @@ public:
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
|
||||
protected:
|
||||
virtual void DrawFieldText(wxDC& dc, const wxRect& rc, int i, int textHeight) wxOVERRIDE;
|
||||
virtual void DrawField(wxDC& dc, int i, int textHeight) wxOVERRIDE;
|
||||
virtual void DoUpdateStatusText(int number = 0) wxOVERRIDE;
|
||||
virtual int GetEffectiveFieldStyle(int WXUNUSED(i)) const wxOVERRIDE { return wxSB_NORMAL; }
|
||||
|
||||
virtual void InitColours() wxOVERRIDE;
|
||||
|
||||
|
@@ -265,9 +265,11 @@ void wxStatusBarGeneric::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int
|
||||
SetEllipsizedFlag(i, text != GetStatusText(i));
|
||||
}
|
||||
|
||||
#if defined( __WXGTK__ ) || defined(__WXMAC__)
|
||||
#if defined( __WXGTK__ )
|
||||
xpos++;
|
||||
ypos++;
|
||||
#elif defined(__WXMAC__)
|
||||
xpos++;
|
||||
#endif
|
||||
|
||||
// draw the text
|
||||
@@ -285,7 +287,7 @@ void wxStatusBarGeneric::DrawField(wxDC& dc, int i, int textHeight)
|
||||
if (rect.GetWidth() <= 0)
|
||||
return; // happens when the status bar is shrunk in a very small area!
|
||||
|
||||
int style = m_panes[i].GetStyle();
|
||||
int style = GetEffectiveFieldStyle(i);
|
||||
if (style == wxSB_RAISED || style == wxSB_SUNKEN)
|
||||
{
|
||||
// Draw border
|
||||
|
@@ -97,51 +97,6 @@ void wxStatusBarMac::InitColours()
|
||||
}
|
||||
}
|
||||
|
||||
void wxStatusBarMac::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int textHeight)
|
||||
{
|
||||
int w, h;
|
||||
GetSize( &w , &h );
|
||||
|
||||
wxString text(GetStatusText( i ));
|
||||
|
||||
int xpos = rect.x + wxFIELD_TEXT_MARGIN + 1;
|
||||
int ypos = 2 + (rect.height - textHeight) / 2;
|
||||
|
||||
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, int textHeight)
|
||||
{
|
||||
wxRect rect;
|
||||
GetFieldRect(i, rect);
|
||||
|
||||
DrawFieldText(dc, rect, i, textHeight);
|
||||
}
|
||||
|
||||
void wxStatusBarMac::DoUpdateStatusText(int number)
|
||||
{
|
||||
wxRect rect;
|
||||
GetFieldRect(number, rect);
|
||||
|
||||
int w, h;
|
||||
GetSize( &w, &h );
|
||||
|
||||
rect.y = 0;
|
||||
rect.height = h ;
|
||||
|
||||
Refresh( true, &rect );
|
||||
// we should have to force the update here
|
||||
// TODO Remove if no regressions occur
|
||||
#if 0
|
||||
Update();
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
|
Reference in New Issue
Block a user