Kaydet (Commit) 8c4b77ac authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

partially refactor MenuBar to use RenderContext

Change-Id: I91353f2a74cdcafbe53fec3bd3ee58883c21fec5
üst f6e2c4eb
...@@ -186,7 +186,7 @@ protected: ...@@ -186,7 +186,7 @@ protected:
SAL_DLLPRIVATE sal_uInt16 ImplGetPrevVisible( sal_uInt16 nPos ) const; SAL_DLLPRIVATE sal_uInt16 ImplGetPrevVisible( sal_uInt16 nPos ) const;
SAL_DLLPRIVATE sal_uInt16 ImplGetNextVisible( 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 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 ImplSelect();
SAL_DLLPRIVATE void ImplCallHighlight( sal_uInt16 nHighlightItem ); SAL_DLLPRIVATE void ImplCallHighlight( sal_uInt16 nHighlightItem );
SAL_DLLPRIVATE void ImplCallEventListeners( sal_uLong nEvent, sal_uInt16 nPos ); SAL_DLLPRIVATE void ImplCallEventListeners( sal_uLong nEvent, sal_uInt16 nPos );
......
...@@ -1783,39 +1783,40 @@ static OUString getShortenedString( const OUString& i_rLong, vcl::Window* i_pWin ...@@ -1783,39 +1783,40 @@ static OUString getShortenedString( const OUString& i_rLong, vcl::Window* i_pWin
return aNonMnem; 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 // Save previous graphical settings, set new one
pWin->Push( PushFlags::FONT | PushFlags::FILLCOLOR ); rRenderContext.Push(PushFlags::FONT | PushFlags::FILLCOLOR);
Color aBg = pWin->GetSettings().GetStyleSettings().GetMenuBarColor(); Color aBackgroundColor = rRenderContext.GetSettings().GetStyleSettings().GetMenuBarColor();
pWin->SetBackground( Wallpaper( aBg ) ); rRenderContext.SetBackground(Wallpaper(aBackgroundColor));
pWin->SetFillColor( aBg ); rRenderContext.SetFillColor(aBackgroundColor);
vcl::Font aFont = pWin->GetFont(); vcl::Font aFont = rRenderContext.GetFont();
aFont.SetWeight(WEIGHT_BOLD); aFont.SetWeight(WEIGHT_BOLD);
pWin->SetFont(aFont); rRenderContext.SetFont(aFont);
// Draw background rectangle // Draw background rectangle
Rectangle aBgRect( rRect ); Rectangle aBgRect(rRect);
int nOuterSpaceX = ImplGetSVData()->maNWFData.mnMenuFormatBorderX; int nOuterSpaceX = ImplGetSVData()->maNWFData.mnMenuFormatBorderX;
aBgRect.setX( aBgRect.getX() + SPACE_AROUND_TITLE); aBgRect.setX(aBgRect.getX() + SPACE_AROUND_TITLE);
aBgRect.setWidth( aBgRect.getWidth() - 2 * SPACE_AROUND_TITLE - 2 * nOuterSpaceX ); aBgRect.setWidth(aBgRect.getWidth() - 2 * SPACE_AROUND_TITLE - 2 * nOuterSpaceX);
aBgRect.setY( aBgRect.getY() + SPACE_AROUND_TITLE ); aBgRect.setY(aBgRect.getY() + SPACE_AROUND_TITLE);
aBgRect.setHeight( nTitleHeight - 2 * SPACE_AROUND_TITLE ); aBgRect.setHeight(nTitleHeight - 2 * SPACE_AROUND_TITLE);
pWin->DrawRect( aBgRect ); rRenderContext.DrawRect(aBgRect);
// Draw the text centered // Draw the text centered
Point aTextTopLeft( rRect.TopLeft() ); Point aTextTopLeft(rRect.TopLeft());
long textWidth = pWin->GetTextWidth(aTitleText); long textWidth = rRenderContext.GetTextWidth(aTitleText);
aTextTopLeft.X() += ( aBgRect.getWidth() - textWidth ) / 2; aTextTopLeft.X() += (aBgRect.getWidth() - textWidth) / 2;
aTextTopLeft.Y() += SPACE_AROUND_TITLE; aTextTopLeft.Y() += SPACE_AROUND_TITLE;
pWin->DrawText( aTextTopLeft, aTitleText, 0, aTitleText.getLength() ); rRenderContext.DrawText(aTextTopLeft, aTitleText, 0, aTitleText.getLength());
// Restore // Restore
pWin->SetBackground(); rRenderContext.SetBackground();
pWin->Pop(); 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 // for symbols: nFontHeight x nFontHeight
long nFontHeight = pWin->GetTextHeight(); long nFontHeight = pWin->GetTextHeight();
...@@ -1846,8 +1847,8 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI ...@@ -1846,8 +1847,8 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
mpLayoutData->m_aVisibleItemBoundRects.clear(); mpLayoutData->m_aVisibleItemBoundRects.clear();
// Paint title // Paint title
if ( !pThisItemOnly && !IsMenuBar() && nTitleHeight > 0 ) if (!pThisItemOnly && !IsMenuBar() && nTitleHeight > 0)
ImplPaintMenuTitle( pWin, Rectangle( aTopLeft, aOutSz ) ); ImplPaintMenuTitle(*pWin/*rRenderContext*/, Rectangle(aTopLeft, aOutSz));
for ( size_t n = 0; n < nCount; n++ ) for ( size_t n = 0; n < nCount; n++ )
{ {
......
...@@ -563,23 +563,25 @@ static int ImplGetTopDockingAreaHeight( vcl::Window *pWindow ) ...@@ -563,23 +563,25 @@ static int ImplGetTopDockingAreaHeight( vcl::Window *pWindow )
return 0; return 0;
} }
static void ImplAddNWFSeparator( vcl::Window *pThis, const MenubarValue& rMenubarValue ) static void ImplAddNWFSeparator( vcl::RenderContext& rRenderContext, const MenubarValue& rMenubarValue )
{ {
// add a separator if // add a separator if
// - we have an adjacent docking area // - we have an adjacent docking area
// - and if toolbars would draw them as well (mbDockingAreaSeparateTB must not be set, see dockingarea.cxx) // - 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 // 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; Point aPt;
Rectangle aRect( aPt, pThis->GetOutputSizePixel() ); Rectangle aRect(aPt, rRenderContext.GetOutputSizePixel());
pThis->DrawLine( aRect.BottomLeft(), aRect.BottomRight() ); rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
} }
} }
void MenuBarWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight ) void MenuBarWindow::HighlightItem(sal_uInt16 nPos, bool bHighlight)
{ {
if( ! pMenu ) if( ! pMenu )
return; return;
...@@ -620,7 +622,7 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight ) ...@@ -620,7 +622,7 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight )
OUString() ); OUString() );
} }
ImplAddNWFSeparator( this, aControlValue ); ImplAddNWFSeparator(*this, aControlValue); // FIXME
// draw selected item // draw selected item
ControlState nState = ControlState::ENABLED; ControlState nState = ControlState::ENABLED;
...@@ -663,7 +665,7 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight ) ...@@ -663,7 +665,7 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight )
DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRect, ControlState::ENABLED, aMenubarValue, OUString() ); DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRect, ControlState::ENABLED, aMenubarValue, OUString() );
} }
ImplAddNWFSeparator( this, aMenubarValue ); ImplAddNWFSeparator(*this, aMenubarValue); // FIXME
} }
else else
Erase( aRect ); Erase( aRect );
...@@ -870,52 +872,56 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu ) ...@@ -870,52 +872,56 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu )
return bDone; return bDone;
} }
void MenuBarWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& ) void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{ {
if( ! pMenu ) if (!pMenu)
return; return;
const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
// no VCL paint if native menus // no VCL paint if native menus
if( pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar() ) if (pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar())
{ {
ImplGetFrame()->DrawMenuBar(); ImplGetFrame()->DrawMenuBar();
return; return;
} }
if( IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) ) if (rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_ENTIRE_CONTROL))
{ {
MenubarValue aMenubarValue; MenubarValue aMenubarValue;
aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this ); aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight(this);
if ( !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() ) if (!rStyleSettings.GetPersonaHeader().IsEmpty())
Erase(); rRenderContext.Erase();
else else
{ {
Point aPt; Point aPt;
Rectangle aCtrlRegion( aPt, GetOutputSizePixel() ); 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() ); rRenderContext.SetFillColor(rStyleSettings.GetMenuColor());
pMenu->ImplPaint( this, 0 );
if ( nHighlightedItem != ITEMPOS_INVALID ) pMenu->ImplPaint(this, 0);
HighlightItem( nHighlightedItem, true ); if (nHighlightedItem != ITEMPOS_INVALID)
HighlightItem(nHighlightedItem, true );
// in high contrast mode draw a separating line on the lower edge // in high contrast mode draw a separating line on the lower edge
if( ! IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) && if (!rRenderContext.IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) &&
GetSettings().GetStyleSettings().GetHighContrastMode() ) rStyleSettings.GetHighContrastMode())
{ {
Push( PushFlags::LINECOLOR | PushFlags::MAPMODE ); rRenderContext.Push(PushFlags::LINECOLOR | PushFlags::MAPMODE);
SetLineColor( Color( COL_WHITE ) ); rRenderContext.SetLineColor(Color(COL_WHITE));
SetMapMode( MapMode( MAP_PIXEL ) ); rRenderContext.SetMapMode(MapMode(MAP_PIXEL));
Size aSize = GetSizePixel(); Size aSize = GetSizePixel();
DrawLine( Point( 0, aSize.Height()-1 ), Point( aSize.Width()-1, aSize.Height()-1 ) ); rRenderContext.DrawLine(Point(0, aSize.Height() - 1),
Pop(); Point(aSize.Width() - 1, aSize.Height() - 1));
rRenderContext.Pop();
} }
} }
void MenuBarWindow::Resize() void MenuBarWindow::Resize()
...@@ -1069,11 +1075,11 @@ void MenuBarWindow::GetFocus() ...@@ -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(); xAcc = pMenu->GetAccessible();
return xAcc; return xAcc;
......
...@@ -119,7 +119,7 @@ public: ...@@ -119,7 +119,7 @@ public:
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE; virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE; virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void KeyInput( const KeyEvent& rKEvent ) 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 Resize() SAL_OVERRIDE;
virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE; virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
......
...@@ -1083,34 +1083,32 @@ void MenuFloatingWindow::KeyInput( const KeyEvent& rKEvent ) ...@@ -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; 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; long nX = pMenu->pLogo ? pMenu->pLogo->aBitmap.GetSizePixel().Width() : 0;
Size aPxSize( GetOutputSizePixel() ); Size aPxSize(rRenderContext.GetOutputSizePixel());
aPxSize.Width() -= nX; aPxSize.Width() -= nX;
ImplControlValue aVal( pMenu->nTextPos-GUTTERBORDER ); ImplControlValue aVal(pMenu->nTextPos - GUTTERBORDER);
DrawNativeControl( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL, rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL,
Rectangle( Point( nX, 0 ), aPxSize ), Rectangle(Point(nX, 0), aPxSize),
ControlState::ENABLED, ControlState::ENABLED, aVal, OUString());
aVal,
OUString() );
InitMenuClipRegion(); InitMenuClipRegion();
} }
if ( IsScrollMenu() ) if (IsScrollMenu())
{ {
ImplDrawScroller( true ); ImplDrawScroller( true );
ImplDrawScroller( false ); ImplDrawScroller( false );
} }
SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() ); rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
pMenu->ImplPaint( this, nScrollerHeight, ImplGetStartY() ); pMenu->ImplPaint(this, nScrollerHeight, ImplGetStartY());
if ( nHighlightedItem != ITEMPOS_INVALID ) if (nHighlightedItem != ITEMPOS_INVALID)
HighlightItem( nHighlightedItem, true ); HighlightItem(nHighlightedItem, true);
} }
void MenuFloatingWindow::ImplDrawScroller( bool bUp ) void MenuFloatingWindow::ImplDrawScroller( bool bUp )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment