diff --git a/include/wx/qt/frame.h b/include/wx/qt/frame.h index de9a508dc3..0b5b09204d 100644 --- a/include/wx/qt/frame.h +++ b/include/wx/qt/frame.h @@ -55,6 +55,7 @@ public: virtual QScrollArea *QtGetScrollBarsContainer() const override; protected: + virtual wxPoint GetClientAreaOrigin() const override; virtual void DoGetClientSize(int *width, int *height) const override; virtual void DoSetClientSize(int width, int height) override; diff --git a/src/qt/frame.cpp b/src/qt/frame.cpp index e953acbf8b..7dedebf4f8 100644 --- a/src/qt/frame.cpp +++ b/src/qt/frame.cpp @@ -208,6 +208,45 @@ QScrollArea *wxFrame::QtGetScrollBarsContainer() const return dynamic_cast (GetQMainWindow()->centralWidget() ); } +// get the origin of the client area in the client coordinates +// excluding any menubar and toolbar if any. +wxPoint wxFrame::GetClientAreaOrigin() const +{ + wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin(); + + // It seems that Qt always adds 1px border around QMainWindow, + // being resizable or not, so account for it here. + pt += wxPoint(1, 1); + +#ifndef __WXUNIVERSAL__ +#if wxUSE_MENUBAR + wxMenuBar * const menubar = GetMenuBar(); + if ( menubar && menubar->IsAttached() ) + pt.y += menubar->GetSize().y; +#endif // wxUSE_MENUBAR + +#if wxUSE_TOOLBAR + wxToolBar * const toolbar = GetToolBar(); + if ( toolbar && toolbar->IsShown() ) + { + const wxSize sizeTB = toolbar->GetSize(); + const int directionTB = toolbar->GetDirection(); + + if ( directionTB == wxTB_TOP ) + { + pt.y += sizeTB.y; + } + else if ( directionTB == wxTB_LEFT ) + { + pt.x += sizeTB.x; + } + } +#endif // wxUSE_TOOLBAR +#endif // __WXUNIVERSAL__ + + return pt; +} + void wxFrame::DoGetClientSize(int *width, int *height) const { wxWindow::DoGetClientSize(width, height);