Fix wxStatusBar font and position after DPI changes
Update the font of the associated wxDC so ellipsization uses the correct font size.
This commit is contained in:
@@ -72,6 +72,8 @@ protected:
|
|||||||
// implementation of the public SetStatusWidths()
|
// implementation of the public SetStatusWidths()
|
||||||
void MSWUpdateFieldsWidths();
|
void MSWUpdateFieldsWidths();
|
||||||
|
|
||||||
|
virtual void MSWUpdateFontOnDPIChange(const wxSize& newDPI) wxOVERRIDE;
|
||||||
|
|
||||||
// used by DoUpdateStatusText()
|
// used by DoUpdateStatusText()
|
||||||
wxClientDC *m_pDC;
|
wxClientDC *m_pDC;
|
||||||
|
|
||||||
|
@@ -335,6 +335,14 @@ void wxFrame::PositionStatusBar()
|
|||||||
//else: no adjustments necessary for the toolbar on top
|
//else: no adjustments necessary for the toolbar on top
|
||||||
#endif // wxUSE_TOOLBAR
|
#endif // wxUSE_TOOLBAR
|
||||||
|
|
||||||
|
// GetSize returns the height of the clientSize in which the statusbar
|
||||||
|
// height is subtracted (see wxFrame::DoGetClientSize). When the DPI of the
|
||||||
|
// window changes, the statusbar height will likely change so we need to
|
||||||
|
// account for this difference. If not, the statusbar will be positioned
|
||||||
|
// too high or low.
|
||||||
|
int shOld;
|
||||||
|
m_frameStatusBar->GetSize(NULL, &shOld);
|
||||||
|
|
||||||
// Resize the status bar to its default height, as it could have been set
|
// Resize the status bar to its default height, as it could have been set
|
||||||
// to a wrong value before by WM_SIZE sent during the frame creation and
|
// to a wrong value before by WM_SIZE sent during the frame creation and
|
||||||
// our status bars preserve their programmatically set size to avoid being
|
// our status bars preserve their programmatically set size to avoid being
|
||||||
@@ -342,8 +350,9 @@ void wxFrame::PositionStatusBar()
|
|||||||
// this here, the status bar would retain the possibly wrong current height.
|
// this here, the status bar would retain the possibly wrong current height.
|
||||||
m_frameStatusBar->SetSize(x, h, w, wxDefaultCoord, wxSIZE_AUTO_HEIGHT);
|
m_frameStatusBar->SetSize(x, h, w, wxDefaultCoord, wxSIZE_AUTO_HEIGHT);
|
||||||
|
|
||||||
int sw, sh;
|
int sh;
|
||||||
m_frameStatusBar->GetSize(&sw, &sh);
|
m_frameStatusBar->GetSize(NULL, &sh);
|
||||||
|
h += shOld - sh;
|
||||||
|
|
||||||
// Since we wish the status bar to be directly under the client area,
|
// Since we wish the status bar to be directly under the client area,
|
||||||
// we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
|
// we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
|
||||||
|
@@ -166,7 +166,8 @@ bool wxStatusBar::SetFont(const wxFont& font)
|
|||||||
if (!wxWindow::SetFont(font))
|
if (!wxWindow::SetFont(font))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_pDC) m_pDC->SetFont(font);
|
if ( m_pDC )
|
||||||
|
m_pDC->SetFont(m_font);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,6 +257,14 @@ void wxStatusBar::MSWUpdateFieldsWidths()
|
|||||||
delete [] pWidths;
|
delete [] pWidths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxStatusBar::MSWUpdateFontOnDPIChange(const wxSize& newDPI)
|
||||||
|
{
|
||||||
|
wxStatusBarBase::MSWUpdateFontOnDPIChange(newDPI);
|
||||||
|
|
||||||
|
if ( m_pDC && m_font.IsOk() )
|
||||||
|
m_pDC->SetFont(m_font);
|
||||||
|
}
|
||||||
|
|
||||||
void wxStatusBar::DoUpdateStatusText(int nField)
|
void wxStatusBar::DoUpdateStatusText(int nField)
|
||||||
{
|
{
|
||||||
if (!m_pDC)
|
if (!m_pDC)
|
||||||
|
Reference in New Issue
Block a user