summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-15 17:05:14 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-15 17:10:25 +0900
commit8c4b77ac55d1dadfdcdb5b54aac6523bd894ea36 (patch)
tree2b29138196546a5e352030a7780ade7186dff30e
parentf6e2c4eb4a934dc36c5467cf2c7c8ecc05f2814a (diff)
partially refactor MenuBar to use RenderContext
Change-Id: I91353f2a74cdcafbe53fec3bd3ee58883c21fec5
-rw-r--r--include/vcl/menu.hxx2
-rw-r--r--vcl/source/window/menu.cxx45
-rw-r--r--vcl/source/window/menubarwindow.cxx70
-rw-r--r--vcl/source/window/menubarwindow.hxx2
-rw-r--r--vcl/source/window/menufloatingwindow.cxx30
5 files changed, 77 insertions, 72 deletions
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index b0d26d7be4a9..f4d57a4d937a 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -186,7 +186,7 @@ protected:
SAL_DLLPRIVATE sal_uInt16 ImplGetPrevVisible( sal_uInt16 nPos ) const;
SAL_DLLPRIVATE sal_uInt16 ImplGetNextVisible( sal_uInt16 nPos ) const;
SAL_DLLPRIVATE void ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nOffY = 0, MenuItemData* pThisDataOnly = 0, bool bHighlighted = false, bool bLayout = false, bool bRollover = false ) const;
- SAL_DLLPRIVATE void ImplPaintMenuTitle( vcl::Window* pWin, const Rectangle& rRect ) const;
+ SAL_DLLPRIVATE void ImplPaintMenuTitle(vcl::RenderContext&, const Rectangle& rRect) const;
SAL_DLLPRIVATE void ImplSelect();
SAL_DLLPRIVATE void ImplCallHighlight( sal_uInt16 nHighlightItem );
SAL_DLLPRIVATE void ImplCallEventListeners( sal_uLong nEvent, sal_uInt16 nPos );
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 1f563b69f4f7..7c9900323884 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -1783,39 +1783,40 @@ static OUString getShortenedString( const OUString& i_rLong, vcl::Window* i_pWin
return aNonMnem;
}
-void Menu::ImplPaintMenuTitle( vcl::Window* pWin, const Rectangle& rRect ) const
+void Menu::ImplPaintMenuTitle(vcl::RenderContext& rRenderContext, const Rectangle& rRect ) const
{
// Save previous graphical settings, set new one
- pWin->Push( PushFlags::FONT | PushFlags::FILLCOLOR );
- Color aBg = pWin->GetSettings().GetStyleSettings().GetMenuBarColor();
- pWin->SetBackground( Wallpaper( aBg ) );
- pWin->SetFillColor( aBg );
- vcl::Font aFont = pWin->GetFont();
+ rRenderContext.Push(PushFlags::FONT | PushFlags::FILLCOLOR);
+ Color aBackgroundColor = rRenderContext.GetSettings().GetStyleSettings().GetMenuBarColor();
+ rRenderContext.SetBackground(Wallpaper(aBackgroundColor));
+ rRenderContext.SetFillColor(aBackgroundColor);
+ vcl::Font aFont = rRenderContext.GetFont();
aFont.SetWeight(WEIGHT_BOLD);
- pWin->SetFont(aFont);
+ rRenderContext.SetFont(aFont);
// Draw background rectangle
- Rectangle aBgRect( rRect );
+ Rectangle aBgRect(rRect);
int nOuterSpaceX = ImplGetSVData()->maNWFData.mnMenuFormatBorderX;
- aBgRect.setX( aBgRect.getX() + SPACE_AROUND_TITLE);
- aBgRect.setWidth( aBgRect.getWidth() - 2 * SPACE_AROUND_TITLE - 2 * nOuterSpaceX );
- aBgRect.setY( aBgRect.getY() + SPACE_AROUND_TITLE );
- aBgRect.setHeight( nTitleHeight - 2 * SPACE_AROUND_TITLE );
- pWin->DrawRect( aBgRect );
+ aBgRect.setX(aBgRect.getX() + SPACE_AROUND_TITLE);
+ aBgRect.setWidth(aBgRect.getWidth() - 2 * SPACE_AROUND_TITLE - 2 * nOuterSpaceX);
+ aBgRect.setY(aBgRect.getY() + SPACE_AROUND_TITLE);
+ aBgRect.setHeight(nTitleHeight - 2 * SPACE_AROUND_TITLE);
+ rRenderContext.DrawRect(aBgRect);
// Draw the text centered
- Point aTextTopLeft( rRect.TopLeft() );
- long textWidth = pWin->GetTextWidth(aTitleText);
- aTextTopLeft.X() += ( aBgRect.getWidth() - textWidth ) / 2;
+ Point aTextTopLeft(rRect.TopLeft());
+ long textWidth = rRenderContext.GetTextWidth(aTitleText);
+ aTextTopLeft.X() += (aBgRect.getWidth() - textWidth) / 2;
aTextTopLeft.Y() += SPACE_AROUND_TITLE;
- pWin->DrawText( aTextTopLeft, aTitleText, 0, aTitleText.getLength() );
+ rRenderContext.DrawText(aTextTopLeft, aTitleText, 0, aTitleText.getLength());
// Restore
- pWin->SetBackground();
- pWin->Pop();
+ rRenderContext.SetBackground();
+ rRenderContext.Pop();
}
-void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemData* pThisItemOnly, bool bHighlighted, bool bLayout, bool bRollover ) const
+void Menu::ImplPaint(vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemData* pThisItemOnly,
+ bool bHighlighted, bool bLayout, bool bRollover) const
{
// for symbols: nFontHeight x nFontHeight
long nFontHeight = pWin->GetTextHeight();
@@ -1846,8 +1847,8 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
mpLayoutData->m_aVisibleItemBoundRects.clear();
// Paint title
- if ( !pThisItemOnly && !IsMenuBar() && nTitleHeight > 0 )
- ImplPaintMenuTitle( pWin, Rectangle( aTopLeft, aOutSz ) );
+ if (!pThisItemOnly && !IsMenuBar() && nTitleHeight > 0)
+ ImplPaintMenuTitle(*pWin/*rRenderContext*/, Rectangle(aTopLeft, aOutSz));
for ( size_t n = 0; n < nCount; n++ )
{
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 942f184e8c3d..970154798881 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -563,23 +563,25 @@ static int ImplGetTopDockingAreaHeight( vcl::Window *pWindow )
return 0;
}
-static void ImplAddNWFSeparator( vcl::Window *pThis, const MenubarValue& rMenubarValue )
+static void ImplAddNWFSeparator( vcl::RenderContext& rRenderContext, const MenubarValue& rMenubarValue )
{
// add a separator if
// - we have an adjacent docking area
// - and if toolbars would draw them as well (mbDockingAreaSeparateTB must not be set, see dockingarea.cxx)
- if( rMenubarValue.maTopDockingAreaHeight && !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB && !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames )
+ if (rMenubarValue.maTopDockingAreaHeight
+ && !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB
+ && !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames)
{
// note: the menubar only provides the upper (dark) half of it, the rest (bright part) is drawn by the docking area
- pThis->SetLineColor( pThis->GetSettings().GetStyleSettings().GetSeparatorColor() );
+ rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetSeparatorColor());
Point aPt;
- Rectangle aRect( aPt, pThis->GetOutputSizePixel() );
- pThis->DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
+ Rectangle aRect(aPt, rRenderContext.GetOutputSizePixel());
+ rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
}
}
-void MenuBarWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight )
+void MenuBarWindow::HighlightItem(sal_uInt16 nPos, bool bHighlight)
{
if( ! pMenu )
return;
@@ -620,7 +622,7 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight )
OUString() );
}
- ImplAddNWFSeparator( this, aControlValue );
+ ImplAddNWFSeparator(*this, aControlValue); // FIXME
// draw selected item
ControlState nState = ControlState::ENABLED;
@@ -663,7 +665,7 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight )
DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRect, ControlState::ENABLED, aMenubarValue, OUString() );
}
- ImplAddNWFSeparator( this, aMenubarValue );
+ ImplAddNWFSeparator(*this, aMenubarValue); // FIXME
}
else
Erase( aRect );
@@ -870,52 +872,56 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu )
return bDone;
}
-void MenuBarWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{
- if( ! pMenu )
+ if (!pMenu)
return;
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+
// no VCL paint if native menus
- if( pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar() )
+ if (pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar())
{
ImplGetFrame()->DrawMenuBar();
return;
}
- if( IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_ENTIRE_CONTROL))
{
MenubarValue aMenubarValue;
- aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this );
+ aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight(this);
- if ( !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
- Erase();
+ if (!rStyleSettings.GetPersonaHeader().IsEmpty())
+ rRenderContext.Erase();
else
{
Point aPt;
Rectangle aCtrlRegion( aPt, GetOutputSizePixel() );
- DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRegion, ControlState::ENABLED, aMenubarValue, OUString() );
+ rRenderContext.DrawNativeControl(CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRegion,
+ ControlState::ENABLED, aMenubarValue, OUString());
}
- ImplAddNWFSeparator( this, aMenubarValue );
+ ImplAddNWFSeparator(rRenderContext, aMenubarValue);
}
- SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() );
- pMenu->ImplPaint( this, 0 );
- if ( nHighlightedItem != ITEMPOS_INVALID )
- HighlightItem( nHighlightedItem, true );
+ rRenderContext.SetFillColor(rStyleSettings.GetMenuColor());
+
+ pMenu->ImplPaint(this, 0);
+ if (nHighlightedItem != ITEMPOS_INVALID)
+ HighlightItem(nHighlightedItem, true );
// in high contrast mode draw a separating line on the lower edge
- if( ! IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) &&
- GetSettings().GetStyleSettings().GetHighContrastMode() )
+ if (!rRenderContext.IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) &&
+ rStyleSettings.GetHighContrastMode())
{
- Push( PushFlags::LINECOLOR | PushFlags::MAPMODE );
- SetLineColor( Color( COL_WHITE ) );
- SetMapMode( MapMode( MAP_PIXEL ) );
+ rRenderContext.Push(PushFlags::LINECOLOR | PushFlags::MAPMODE);
+ rRenderContext.SetLineColor(Color(COL_WHITE));
+ rRenderContext.SetMapMode(MapMode(MAP_PIXEL));
Size aSize = GetSizePixel();
- DrawLine( Point( 0, aSize.Height()-1 ), Point( aSize.Width()-1, aSize.Height()-1 ) );
- Pop();
+ rRenderContext.DrawLine(Point(0, aSize.Height() - 1),
+ Point(aSize.Width() - 1, aSize.Height() - 1));
+ rRenderContext.Pop();
}
-
}
void MenuBarWindow::Resize()
@@ -1069,11 +1075,11 @@ void MenuBarWindow::GetFocus()
}
}
-::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > MenuBarWindow::CreateAccessible()
+css::uno::Reference<css::accessibility::XAccessible> MenuBarWindow::CreateAccessible()
{
- ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc;
+ css::uno::Reference<css::accessibility::XAccessible> xAcc;
- if ( pMenu )
+ if (pMenu)
xAcc = pMenu->GetAccessible();
return xAcc;
diff --git a/vcl/source/window/menubarwindow.hxx b/vcl/source/window/menubarwindow.hxx
index 5a6f2e92f7ec..2c664befe122 100644
--- a/vcl/source/window/menubarwindow.hxx
+++ b/vcl/source/window/menubarwindow.hxx
@@ -119,7 +119,7 @@ public:
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void KeyInput( const KeyEvent& rKEvent ) SAL_OVERRIDE;
- virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect ) SAL_OVERRIDE;
+ virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
virtual void Resize() SAL_OVERRIDE;
virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index e4a979804ec2..32acf47fb628 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -1083,34 +1083,32 @@ void MenuFloatingWindow::KeyInput( const KeyEvent& rKEvent )
}
}
-void MenuFloatingWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{
- if( ! pMenu )
+ if (!pMenu)
return;
- if( IsNativeControlSupported( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL ) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL))
{
- SetClipRegion();
+ rRenderContext.SetClipRegion();
long nX = pMenu->pLogo ? pMenu->pLogo->aBitmap.GetSizePixel().Width() : 0;
- Size aPxSize( GetOutputSizePixel() );
+ Size aPxSize(rRenderContext.GetOutputSizePixel());
aPxSize.Width() -= nX;
- ImplControlValue aVal( pMenu->nTextPos-GUTTERBORDER );
- DrawNativeControl( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL,
- Rectangle( Point( nX, 0 ), aPxSize ),
- ControlState::ENABLED,
- aVal,
- OUString() );
+ ImplControlValue aVal(pMenu->nTextPos - GUTTERBORDER);
+ rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL,
+ Rectangle(Point(nX, 0), aPxSize),
+ ControlState::ENABLED, aVal, OUString());
InitMenuClipRegion();
}
- if ( IsScrollMenu() )
+ if (IsScrollMenu())
{
ImplDrawScroller( true );
ImplDrawScroller( false );
}
- SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() );
- pMenu->ImplPaint( this, nScrollerHeight, ImplGetStartY() );
- if ( nHighlightedItem != ITEMPOS_INVALID )
- HighlightItem( nHighlightedItem, true );
+ rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
+ pMenu->ImplPaint(this, nScrollerHeight, ImplGetStartY());
+ if (nHighlightedItem != ITEMPOS_INVALID)
+ HighlightItem(nHighlightedItem, true);
}
void MenuFloatingWindow::ImplDrawScroller( bool bUp )