summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-12-18 17:42:00 +0900
committerTomaž Vajngerl <quikee@gmail.com>2017-12-19 05:25:35 +0100
commite11234d8d8d8ff2744b77a128f845dbe8e6faa1e (patch)
tree38b13c1f9b266ee862912f5e2ccf731bb8c59dcc /vcl
parent5c66c0711286bcfa9d3ab4a87777c2af9e1c25d9 (diff)
menu: pass paint size to ImplPaint and account for buttons
When a menu bar is painted it needs to take into account that the buttons (close) is positioned at the right side of the paint area. To do this we need to pass what the output size is when painting (ImplPaint) on the common menu code, instead of assuming the whole area can be used. Change-Id: I2e9d6c686929fe1cd7e28368a8055c1e2df13c49 Reviewed-on: https://gerrit.libreoffice.org/46710 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/menu.cxx9
-rw-r--r--vcl/source/window/menubarwindow.cxx25
-rw-r--r--vcl/source/window/menufloatingwindow.cxx4
3 files changed, 25 insertions, 13 deletions
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index f2f45eadd965..b6b2faa5206b 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -1661,7 +1661,7 @@ void Menu::ImplPaintMenuTitle(vcl::RenderContext& rRenderContext, const tools::R
rRenderContext.SetBackground(aOldBackground);
}
-void Menu::ImplPaint(vcl::RenderContext& rRenderContext,
+void Menu::ImplPaint(vcl::RenderContext& rRenderContext, Size const & rSize,
sal_uInt16 nBorder, long nStartY, MenuItemData const * pThisItemOnly,
bool bHighlighted, bool bLayout, bool bRollover) const
{
@@ -1686,7 +1686,7 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext,
}
// for the computations, use size of the underlying window, not of RenderContext
- Size aOutSz = pWindow->GetOutputSizePixel();
+ Size aOutSz(rSize);
size_t nCount = pItemList->size();
if (bLayout)
@@ -2135,12 +2135,13 @@ void Menu::ImplFillLayoutData() const
mpLayoutData = new MenuLayoutData;
if (IsMenuBar())
{
- ImplPaint(*pWindow, 0, 0, nullptr, false, true); // FIXME
+ ImplPaint(*pWindow, pWindow->GetOutputSizePixel(), 0, 0, nullptr, false, true); // FIXME
}
else
{
MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow.get());
- ImplPaint(*pWindow, pFloat->nScrollerHeight, pFloat->ImplGetStartY(), nullptr, false, true); //FIXME
+ ImplPaint(*pWindow, pWindow->GetOutputSizePixel(), pFloat->nScrollerHeight, pFloat->ImplGetStartY(),
+ nullptr, false, true); //FIXME
}
}
}
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 6486ffb86a9c..0b4e6b7df5bc 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -574,6 +574,10 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
long nX = 0;
size_t nCount = pMenu->pItemList->size();
+
+ Size aOutputSize = GetOutputSizePixel();
+ aOutputSize.Width() -= aCloseBtn->GetSizePixel().Width();
+
for (size_t n = 0; n < nCount; n++)
{
MenuItemData* pData = pMenu->pItemList->GetDataFromPos( n );
@@ -582,7 +586,7 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
if (pData->eType != MenuItemType::SEPARATOR)
{
// #107747# give menuitems the height of the menubar
- tools::Rectangle aRect = tools::Rectangle(Point(nX, 1), Size(pData->aSz.Width(), GetOutputSizePixel().Height() - 2));
+ tools::Rectangle aRect = tools::Rectangle(Point(nX, 1), Size(pData->aSz.Width(), aOutputSize.Height() - 2));
rRenderContext.Push(PushFlags::CLIPREGION);
rRenderContext.IntersectClipRegion(aRect);
bool bRollover, bHighlight;
@@ -607,12 +611,12 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
Erase(rRenderContext);
else
{
- tools::Rectangle aBgRegion(Point(), GetOutputSizePixel());
+ tools::Rectangle aBgRegion(Point(), aOutputSize);
rRenderContext.DrawNativeControl(ControlType::Menubar, ControlPart::Entire, aBgRegion,
ControlState::ENABLED, aControlValue, OUString());
}
- ImplAddNWFSeparator(rRenderContext, GetOutputSizePixel(), aControlValue);
+ ImplAddNWFSeparator(rRenderContext, aOutputSize, aControlValue);
// draw selected item
ControlState nState = ControlState::ENABLED;
@@ -633,7 +637,8 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
rRenderContext.DrawRect(aRect);
}
rRenderContext.Pop();
- pMenu->ImplPaint(rRenderContext, 0, 0, pData, bHighlight, false, bRollover);
+
+ pMenu->ImplPaint(rRenderContext, aOutputSize, 0, 0, pData, bHighlight, false, bRollover);
}
return;
}
@@ -854,6 +859,8 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+ Size aOutputSize = GetOutputSizePixel();
+
// no VCL paint if native menus
if (pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar())
{
@@ -871,17 +878,21 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
else
{
Point aPt;
- tools::Rectangle aCtrlRegion( aPt, GetOutputSizePixel() );
+ tools::Rectangle aCtrlRegion( aPt, aOutputSize );
rRenderContext.DrawNativeControl(ControlType::Menubar, ControlPart::Entire, aCtrlRegion,
ControlState::ENABLED, aMenubarValue, OUString());
}
- ImplAddNWFSeparator(rRenderContext, GetOutputSizePixel(), aMenubarValue);
+ ImplAddNWFSeparator(rRenderContext, aOutputSize, aMenubarValue);
}
+
+ // shrink the area of the buttons
+ aOutputSize.Width() -= aCloseBtn->GetSizePixel().Width();
+
rRenderContext.SetFillColor(rStyleSettings.GetMenuColor());
- pMenu->ImplPaint(rRenderContext, 0);
+ pMenu->ImplPaint(rRenderContext, aOutputSize, 0);
if (nHighlightedItem != ITEMPOS_INVALID)
HighlightItem(rRenderContext, nHighlightedItem);
else if (ImplGetSVData()->maNWFData.mbRolloverMenubar && nRolloveredItem != ITEMPOS_INVALID)
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index 601434cbb8c7..c66510cf8f1a 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -869,7 +869,7 @@ void MenuFloatingWindow::RenderHighlightItem(vcl::RenderContext& rRenderContext,
rRenderContext.DrawRect(aItemRect);
}
- pMenu->ImplPaint(rRenderContext, nScrollerHeight, nStartY, pData, true/*bHighlight*/);
+ pMenu->ImplPaint(rRenderContext, GetOutputSizePixel(), nScrollerHeight, nStartY, pData, true/*bHighlight*/);
if (bRestoreLineColor)
rRenderContext.SetLineColor(oldLineColor);
}
@@ -1195,7 +1195,7 @@ void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const tools::
ImplDrawScroller(rRenderContext, false);
}
rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
- pMenu->ImplPaint(rRenderContext, nScrollerHeight, ImplGetStartY());
+ pMenu->ImplPaint(rRenderContext, GetOutputSizePixel(), nScrollerHeight, ImplGetStartY());
if (nHighlightedItem != ITEMPOS_INVALID)
RenderHighlightItem(rRenderContext, nHighlightedItem);