diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-05-18 15:13:16 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-05-18 15:55:01 +0900 |
commit | 7092c767b54df65e64b6059a531de4950c1a3b92 (patch) | |
tree | 265b15b9972bb277c5615507c4830ffff1b3574a | |
parent | 12443d117c1289210aad08f92bf21594e9a632aa (diff) |
ApplySettings for Menu
Change-Id: Iaf004e3deed19dfc9f808b53f0bbe45e0949c034
-rw-r--r-- | vcl/source/window/menubarwindow.cxx | 116 | ||||
-rw-r--r-- | vcl/source/window/menubarwindow.hxx | 12 | ||||
-rw-r--r-- | vcl/source/window/menufloatingwindow.cxx | 20 | ||||
-rw-r--r-- | vcl/source/window/menufloatingwindow.hxx | 18 |
4 files changed, 113 insertions, 53 deletions
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx index a98948144421..faab3d9aebcf 100644 --- a/vcl/source/window/menubarwindow.cxx +++ b/vcl/source/window/menubarwindow.cxx @@ -120,10 +120,10 @@ void DecoToolBox::SetImages( long nMaxHeight, bool bForce ) MenuBarWindow::MenuBarWindow( vcl::Window* pParent ) : Window( pParent, 0 ), aCloseBtn(VclPtr<DecoToolBox>::Create(this)), - aFloatBtn(VclPtr<PushButton>::Create( this, WB_NOPOINTERFOCUS | WB_SMALLSTYLE | WB_RECTSTYLE )), - aHideBtn(VclPtr<PushButton>::Create(this, WB_NOPOINTERFOCUS | WB_SMALLSTYLE | WB_RECTSTYLE )) + aFloatBtn(VclPtr<PushButton>::Create(this, WB_NOPOINTERFOCUS | WB_SMALLSTYLE | WB_RECTSTYLE)), + aHideBtn(VclPtr<PushButton>::Create(this, WB_NOPOINTERFOCUS | WB_SMALLSTYLE | WB_RECTSTYLE)) { - SetType( WINDOW_MENUBARWINDOW ); + SetType(WINDOW_MENUBARWINDOW); pMenu = NULL; pActivePopup = NULL; nSaveFocusId = 0; @@ -136,9 +136,9 @@ MenuBarWindow::MenuBarWindow( vcl::Window* pParent ) : ResMgr* pResMgr = ImplGetResMgr(); - if( pResMgr ) + if(pResMgr) { - BitmapEx aBitmap( ResId( SV_RESID_BITMAP_CLOSEDOC, *pResMgr ) ); + BitmapEx aBitmap(ResId(SV_RESID_BITMAP_CLOSEDOC, *pResMgr)); aCloseBtn->maImage = Image(aBitmap); aCloseBtn->SetOutStyle(TOOLBOX_STYLE_FLAT); @@ -162,7 +162,7 @@ MenuBarWindow::MenuBarWindow( vcl::Window* pParent ) : ImplInitStyleSettings(); - AddEventListener( LINK( this, MenuBarWindow, ShowHideListener ) ); + AddEventListener(LINK(this, MenuBarWindow, ShowHideListener)); } MenuBarWindow::~MenuBarWindow() @@ -187,8 +187,8 @@ void MenuBarWindow::SetMenu( MenuBar* pMen ) pMenu = pMen; KillActivePopup(); nHighlightedItem = ITEMPOS_INVALID; - ImplInitMenuWindow( this, true, true ); - if ( pMen ) + ImplInitMenuWindow(this, true, true); + if (pMen) { aCloseBtn->ShowItem(IID_DOCUMENTCLOSE, pMen->HasCloseButton()); aCloseBtn->Show(pMen->HasCloseButton() || !m_aAddButtons.empty()); @@ -988,55 +988,93 @@ void MenuBarWindow::StateChanged( StateChangedType nType ) { Window::StateChanged( nType ); - if ( ( nType == StateChangedType::ControlForeground ) || - ( nType == StateChangedType::ControlBackground ) ) + if (nType == StateChangedType::ControlForeground || + nType == StateChangedType::ControlBackground) { - ImplInitMenuWindow( this, false, true ); + ImplInitMenuWindow(this, false, true); Invalidate(); } - else if( pMenu ) + else if(pMenu) + { pMenu->ImplKillLayoutData(); - + } } void MenuBarWindow::LayoutChanged() { - if( pMenu ) + if (!pMenu) + return; + + ImplInitMenuWindow(this, true, true); + + // if the font was changed. + long nHeight = pMenu->ImplCalcSize(this).Height(); + + // depending on the native implementation or the displayable flag + // the menubar windows is suppressed (ie, height=0) + if (!static_cast<MenuBar*>(pMenu)->IsDisplayable() || + (pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar())) { - ImplInitMenuWindow( this, true, true ); - // if the font was changed. - long nHeight = pMenu->ImplCalcSize( this ).Height(); - - // depending on the native implementation or the displayable flag - // the menubar windows is suppressed (ie, height=0) - if( !static_cast<MenuBar*>(pMenu)->IsDisplayable() || - ( pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar() ) ) - nHeight = 0; - - setPosSizePixel( 0, 0, 0, nHeight, WINDOW_POSSIZE_HEIGHT ); - GetParent()->Resize(); - Invalidate(); - Resize(); - if( pMenu ) - pMenu->ImplKillLayoutData(); + nHeight = 0; } + setPosSizePixel(0, 0, 0, nHeight, WINDOW_POSSIZE_HEIGHT); + GetParent()->Resize(); + Invalidate(); + Resize(); + + pMenu->ImplKillLayoutData(); +} + +void MenuBarWindow::ApplySettings(vcl::RenderContext& rRenderContext) +{ + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + + SetPointFont(rRenderContext, rStyleSettings.GetMenuFont()); + + const BitmapEx& rPersonaBitmap = Application::GetSettings().GetStyleSettings().GetPersonaHeader(); + if (!rPersonaBitmap.IsEmpty()) + { + Wallpaper aWallpaper(rPersonaBitmap); + aWallpaper.SetStyle(WALLPAPER_TOPRIGHT); + aWallpaper.SetColor(Application::GetSettings().GetStyleSettings().GetWorkspaceColor()); + + rRenderContext.SetBackground(aWallpaper); + SetPaintTransparent(false); + SetParentClipMode(0); + } + else if (rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_ENTIRE_CONTROL)) + { + rRenderContext.SetBackground(); // background will be drawn by NWF + } + else + { + Wallpaper aWallpaper; + aWallpaper.SetStyle(WALLPAPER_APPLICATIONGRADIENT); + rRenderContext.SetBackground(aWallpaper); + SetPaintTransparent(false); + SetParentClipMode(0); + } + + rRenderContext.SetTextColor(rStyleSettings.GetMenuBarTextColor()); + rRenderContext.SetTextFillColor(); + rRenderContext.SetLineColor(); } void MenuBarWindow::ImplInitStyleSettings() { - if( IsNativeControlSupported( CTRL_MENUBAR, PART_MENU_ITEM ) && - IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL ) ) + if (IsNativeControlSupported(CTRL_MENUBAR, PART_MENU_ITEM) && + IsNativeControlSupported(CTRL_MENUBAR, PART_ENTIRE_CONTROL)) { - AllSettings aSettings( GetSettings() ); - ImplGetFrame()->UpdateSettings( aSettings ); // to update persona - StyleSettings aStyle( aSettings.GetStyleSettings() ); + AllSettings aSettings(GetSettings()); + ImplGetFrame()->UpdateSettings(aSettings); // to update persona + StyleSettings aStyle(aSettings.GetStyleSettings()); Color aHighlightTextColor = ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor; - if( aHighlightTextColor != Color( COL_TRANSPARENT ) ) + if (aHighlightTextColor != Color(COL_TRANSPARENT)) { - aStyle.SetMenuHighlightTextColor( aHighlightTextColor ); + aStyle.SetMenuHighlightTextColor(aHighlightTextColor); } - aSettings.SetStyleSettings( aStyle ); - OutputDevice::SetSettings( aSettings ); + aSettings.SetStyleSettings(aStyle); + OutputDevice::SetSettings(aSettings); } } diff --git a/vcl/source/window/menubarwindow.hxx b/vcl/source/window/menubarwindow.hxx index ee1036ebd77f..0ebb19a65b35 100644 --- a/vcl/source/window/menubarwindow.hxx +++ b/vcl/source/window/menubarwindow.hxx @@ -97,11 +97,13 @@ private: void ImplInitStyleSettings(); - DECL_LINK_TYPED(CloseHdl, ToolBox *, void); - DECL_LINK(FloatHdl, void *); - DECL_LINK(HideHdl, void *); - DECL_LINK( ToolboxEventHdl, VclWindowEvent* ); - DECL_LINK( ShowHideListener, VclWindowEvent* ); + virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE; + + DECL_LINK_TYPED(CloseHdl, ToolBox *, void); + DECL_LINK(FloatHdl, void *); + DECL_LINK(HideHdl, void *); + DECL_LINK( ToolboxEventHdl, VclWindowEvent* ); + DECL_LINK( ShowHideListener, VclWindowEvent* ); void StateChanged( StateChangedType nType ) SAL_OVERRIDE; void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE; diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx index e9cfd06210e1..dea30161b8ba 100644 --- a/vcl/source/window/menufloatingwindow.cxx +++ b/vcl/source/window/menufloatingwindow.cxx @@ -119,6 +119,24 @@ void MenuFloatingWindow::Resize() InitMenuClipRegion(*this); // FIXME } +void MenuFloatingWindow::ApplySettings(vcl::RenderContext& rRenderContext) +{ + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + + SetPointFont(rRenderContext, rStyleSettings.GetMenuFont()); + + if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL)) + { + rRenderContext.SetBackground(); // background will be drawn by NWF + } + else + rRenderContext.SetBackground(Wallpaper(rStyleSettings.GetMenuColor())); + + rRenderContext.SetTextColor(rStyleSettings.GetMenuTextColor()); + rRenderContext.SetTextFillColor(); + rRenderContext.SetLineColor(); +} + long MenuFloatingWindow::ImplGetStartY() const { long nY = 0; @@ -1110,7 +1128,7 @@ void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const Rectang void MenuFloatingWindow::ImplDrawScroller(vcl::RenderContext& rRenderContext, bool bUp) { - if( ! pMenu ) + if (!pMenu) return; rRenderContext.SetClipRegion(); diff --git a/vcl/source/window/menufloatingwindow.hxx b/vcl/source/window/menufloatingwindow.hxx index 721ba72012e6..9336664a5bc9 100644 --- a/vcl/source/window/menufloatingwindow.hxx +++ b/vcl/source/window/menufloatingwindow.hxx @@ -80,21 +80,23 @@ protected: Rectangle ImplGetItemRect( sal_uInt16 nPos ); public: - MenuFloatingWindow( Menu* pMenu, vcl::Window* pParent, WinBits nStyle ); - virtual ~MenuFloatingWindow(); + MenuFloatingWindow(Menu* pMenu, vcl::Window* pParent, WinBits nStyle); + virtual ~MenuFloatingWindow(); virtual void dispose() SAL_OVERRIDE; void doShutdown(); - virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE; - 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 Command( const CommandEvent& rCEvt ) SAL_OVERRIDE; - virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE; + virtual void MouseMove(const MouseEvent& rMEvt) SAL_OVERRIDE; + 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 Command(const CommandEvent& rCEvt) SAL_OVERRIDE; + virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE; virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE; virtual void Resize() SAL_OVERRIDE; + virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE; + void SetFocusId( sal_uLong nId ) { nSaveFocusId = nId; } sal_uLong GetFocusId() const { return nSaveFocusId; } |