Update bitmap size automatically on DPI change in wxMSW wxToolBar
Remove the now unnecessary wxEVT_DPI_CHANGED event handler in the sample.
This commit is contained in:
@@ -111,7 +111,6 @@ public:
|
|||||||
void OnAbout(wxCommandEvent& event);
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnSize(wxSizeEvent& event);
|
void OnSize(wxSizeEvent& event);
|
||||||
void OnDPIChanged(wxDPIChangedEvent& event);
|
|
||||||
|
|
||||||
void OnToggleToolbar(wxCommandEvent& event);
|
void OnToggleToolbar(wxCommandEvent& event);
|
||||||
void OnToggleAnotherToolbar(wxCommandEvent& event);
|
void OnToggleAnotherToolbar(wxCommandEvent& event);
|
||||||
@@ -242,7 +241,6 @@ enum
|
|||||||
|
|
||||||
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
EVT_SIZE(MyFrame::OnSize)
|
EVT_SIZE(MyFrame::OnSize)
|
||||||
EVT_DPI_CHANGED(MyFrame::OnDPIChanged)
|
|
||||||
|
|
||||||
EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
|
EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
|
||||||
EVT_MENU(wxID_HELP, MyFrame::OnAbout)
|
EVT_MENU(wxID_HELP, MyFrame::OnAbout)
|
||||||
@@ -698,16 +696,6 @@ void MyFrame::OnSize(wxSizeEvent& event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFrame::OnDPIChanged(wxDPIChangedEvent& event)
|
|
||||||
{
|
|
||||||
event.Skip();
|
|
||||||
|
|
||||||
// We check the DPI scaling factor when the toolbar is created, so just
|
|
||||||
// recreate it whenever DPI changes. We could also just update the tools
|
|
||||||
// bitmaps, but this is simpler and doesn't have any significant drawbacks.
|
|
||||||
RecreateToolbar();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyFrame::OnToggleToolbar(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnToggleToolbar(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxToolBar *tbar = GetToolBar();
|
wxToolBar *tbar = GetToolBar();
|
||||||
|
@@ -1949,6 +1949,10 @@ void wxToolBar::RealizeHelper()
|
|||||||
|
|
||||||
void wxToolBar::OnDPIChanged(wxDPIChangedEvent& event)
|
void wxToolBar::OnDPIChanged(wxDPIChangedEvent& event)
|
||||||
{
|
{
|
||||||
|
// Ensure that when Realize() is called, the bitmaps size corresponding to
|
||||||
|
// the new resolution will be used.
|
||||||
|
SetToolBitmapSize(event.Scale(wxSize(m_defaultWidth, m_defaultHeight)));
|
||||||
|
|
||||||
// Manually scale the size of the controls. Even though the font has been
|
// Manually scale the size of the controls. Even though the font has been
|
||||||
// updated, the internal size of the controls does not.
|
// updated, the internal size of the controls does not.
|
||||||
wxToolBarToolsList::compatibility_iterator node;
|
wxToolBarToolsList::compatibility_iterator node;
|
||||||
|
Reference in New Issue
Block a user