Improve high DPI support in wxAui

Window initial/minimum/maximum sizes are now treated as logical pixels.

Furthermore, many margins and paddings are now converted using
wxWindow::FromDIP() to allow their growth in accord with screen DPI.
This places buttons on toolbars more apart on high DPI screens providing
space for easier touch operations.

Closes https://github.com/wxWidgets/wxWidgets/pull/933
This commit is contained in:
Simon Rozman
2018-09-14 14:27:05 +02:00
committed by Vadim Zeitlin
parent 2af7e38153
commit 770e0bcd16
14 changed files with 294 additions and 268 deletions

View File

@@ -517,7 +517,11 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd)
}
if (button.id == wxAUI_BUTTON_RIGHT)
{
if (visible_width < m_rect.GetWidth() - ((int)button_count*16))
int button_width = 0;
for (i = 0; i < button_count; ++i)
button_width += m_buttons.Item(button_count - i - 1).rect.GetWidth();
if (visible_width < m_rect.GetWidth() - button_width)
button.curState |= wxAUI_BUTTON_STATE_DISABLED;
else
button.curState &= ~wxAUI_BUTTON_STATE_DISABLED;
@@ -651,7 +655,7 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd)
}
rect.x = offset;
rect.width = m_rect.width - right_buttons_width - offset - 2;
rect.width = m_rect.width - right_buttons_width - offset - wnd->FromDIP(2);
if (rect.width <= 0)
break;
@@ -796,7 +800,7 @@ bool wxAuiTabContainer::IsTabVisible(int tabPage, int tabOffset, wxDC* dc, wxWin
wxAuiTabContainerButton& tab_button = m_tabCloseButtons.Item(i);
rect.x = offset;
rect.width = m_rect.width - right_buttons_width - offset - 2;
rect.width = m_rect.width - right_buttons_width - offset - wnd->FromDIP(2);
if (rect.width <= 0)
return false; // haven't found the tab, and we've run out of space, so return false
@@ -816,7 +820,7 @@ bool wxAuiTabContainer::IsTabVisible(int tabPage, int tabOffset, wxDC* dc, wxWin
{
// If not all of the tab is visible, and supposing there's space to display it all,
// we could do better so we return false.
if (((m_rect.width - right_buttons_width - offset - 2) <= 0) && ((m_rect.width - right_buttons_width - left_buttons_width) > x_extent))
if (((m_rect.width - right_buttons_width - offset - wnd->FromDIP(2)) <= 0) && ((m_rect.width - right_buttons_width - left_buttons_width) > x_extent))
return false;
else
return true;
@@ -1501,8 +1505,8 @@ public:
wxTabFrame()
{
m_tabs = NULL;
m_rect = wxRect(0,0,200,200);
m_tabCtrlHeight = 20;
m_rect = wxRect(wxPoint(0,0), FromDIP(wxSize(200,200)));
m_tabCtrlHeight = FromDIP(20);
}
~wxTabFrame()
@@ -1672,7 +1676,7 @@ void wxAuiNotebook::Init()
m_curPage = -1;
m_tabIdCounter = wxAuiBaseTabCtrlId;
m_dummyWnd = NULL;
m_tabCtrlHeight = 20;
m_tabCtrlHeight = FromDIP(20);
m_requestedBmpSize = wxDefaultSize;
m_requestedTabCtrlHeight = -1;
}
@@ -1700,7 +1704,7 @@ void wxAuiNotebook::InitNotebook(long style)
m_tabIdCounter = wxAuiBaseTabCtrlId;
m_dummyWnd = NULL;
m_flags = (unsigned int)style;
m_tabCtrlHeight = 20;
m_tabCtrlHeight = FromDIP(20);
m_normalFont = *wxNORMAL_FONT;
m_selectedFont = *wxNORMAL_FONT;
@@ -1709,7 +1713,7 @@ void wxAuiNotebook::InitNotebook(long style)
SetArtProvider(new wxAuiDefaultTabArt);
m_dummyWnd = new wxWindow(this, wxID_ANY, wxPoint(0,0), wxSize(0,0));
m_dummyWnd->SetSize(200, 200);
m_dummyWnd->SetSize(FromDIP(wxSize(200, 200)));
m_dummyWnd->Show(false);
m_mgr.SetManagedWindow(this);
@@ -1870,7 +1874,7 @@ wxSize wxAuiNotebook::CalculateNewSplitSize()
{
// this is in place of a more complicated calculation
// that needs to be implemented
new_split_size = wxSize(180,180);
new_split_size = FromDIP(wxSize(180,180));
}
return new_split_size;