diff options
-rw-r--r-- | include/vcl/button.hxx | 1 | ||||
-rw-r--r-- | include/vcl/menubtn.hxx | 10 | ||||
-rw-r--r-- | sfx2/source/dialog/backingwindow.cxx | 12 | ||||
-rw-r--r-- | sfx2/source/dialog/backingwindow.hxx | 6 | ||||
-rw-r--r-- | vcl/source/control/button.cxx | 20 | ||||
-rw-r--r-- | vcl/source/control/menubtn.cxx | 18 |
6 files changed, 58 insertions, 9 deletions
diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx index 0fb7c98e72c6..a020bd6769e8 100644 --- a/include/vcl/button.hxx +++ b/include/vcl/button.hxx @@ -120,6 +120,7 @@ protected: PushButtonDropdownStyle mnDDStyle; bool mbPressed; bool mbInUserDraw; + bool mbIsActive; SAL_DLLPRIVATE void ImplInitPushButtonData(); SAL_DLLPRIVATE WinBits ImplInitStyle( const vcl::Window* pPrevWindow, WinBits nStyle ); diff --git a/include/vcl/menubtn.hxx b/include/vcl/menubtn.hxx index 8d8438fac58b..0e57668037f4 100644 --- a/include/vcl/menubtn.hxx +++ b/include/vcl/menubtn.hxx @@ -78,6 +78,16 @@ public: void SetSelectHdl( const Link<MenuButton *, void>& rLink ) { maSelectHdl = rLink; } }; + +class VCL_DLLPUBLIC MenuToggleButton : public MenuButton +{ +public: + explicit MenuToggleButton( vcl::Window* pParent, WinBits nStyle = 0 ); + virtual ~MenuToggleButton(); + + void SetActive( bool bSel ); +}; + #endif // INCLUDED_VCL_MENUBTN_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index 9c054d56f633..ef27a2dc02f2 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -256,6 +256,7 @@ void BackingWindow::initControls() mpAllRecentThumbnails->mnFileTypes |= TYPE_OTHER; mpAllRecentThumbnails->Reload(); mpAllRecentThumbnails->ShowTooltips( true ); + mpRecentButton->SetActive(true); //initialize Template view mpLocalView->SetStyle( mpLocalView->GetStyle() | WB_VSCROLL); @@ -345,7 +346,7 @@ void BackingWindow::setupButton( PushButton* pButton ) pButton->SetClickHdl( LINK( this, BackingWindow, ClickHdl ) ); } -void BackingWindow::setupButton( MenuButton* pButton ) +void BackingWindow::setupButton( MenuToggleButton* pButton ) { vcl::Font aFont(pButton->GetSettings().GetStyleSettings().GetPushButtonFont()); aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * fMultiplier)); @@ -595,6 +596,9 @@ IMPL_LINK_TYPED( BackingWindow, ClickHdl, Button*, pButton, void ) mpLocalView->Hide(); mpAllRecentThumbnails->Show(); mpAllRecentThumbnails->GrabFocus(); + mpRecentButton->SetActive(true); + mpTemplateButton->SetActive(false); + mpTemplateButton->Invalidate(); } else if( pButton == mpTemplateButton ) { @@ -604,6 +608,9 @@ IMPL_LINK_TYPED( BackingWindow, ClickHdl, Button*, pButton, void ) mpLocalView->Show(); mpLocalView->reload(); mpLocalView->GrabFocus(); + mpRecentButton->SetActive(false); + mpRecentButton->Invalidate(); + mpTemplateButton->SetActive(true); } } @@ -654,6 +661,9 @@ IMPL_LINK_TYPED( BackingWindow, MenuSelectHdl, MenuButton*, pButton, void ) mpLocalView->Show(); mpLocalView->reload(); mpLocalView->GrabFocus(); + mpRecentButton->SetActive(false); + mpTemplateButton->SetActive(true); + mpRecentButton->Invalidate(); } } diff --git a/sfx2/source/dialog/backingwindow.hxx b/sfx2/source/dialog/backingwindow.hxx index 4c80c9f5ba31..499d8b3dc367 100644 --- a/sfx2/source/dialog/backingwindow.hxx +++ b/sfx2/source/dialog/backingwindow.hxx @@ -59,9 +59,9 @@ class BackingWindow : public vcl::Window, public VclBuilderContainer css::uno::Reference<css::datatransfer::dnd::XDropTargetListener> mxDropTargetListener; VclPtr<PushButton> mpOpenButton; - VclPtr<MenuButton> mpRecentButton; + VclPtr<MenuToggleButton> mpRecentButton; VclPtr<PushButton> mpRemoteButton; - VclPtr<MenuButton> mpTemplateButton; + VclPtr<MenuToggleButton> mpTemplateButton; VclPtr<FixedText> mpCreateLabel; @@ -93,7 +93,7 @@ class BackingWindow : public vcl::Window, public VclBuilderContainer std::unique_ptr<svt::AcceleratorExecute> mpAccExec; void setupButton(PushButton* pButton); - void setupButton(MenuButton* pButton); + void setupButton(MenuToggleButton* pButton); void dispatchURL(const OUString& i_rURL, const OUString& i_rTarget = OUString("_default"), diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 0e4dc5b16a9c..3c53cbbd7e32 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -642,6 +642,7 @@ void PushButton::ImplInitPushButtonData() meState = TRISTATE_FALSE; meSaveValue = TRISTATE_FALSE; mnDDStyle = PushButtonDropdownStyle::NONE; + mbIsActive = false; mbPressed = false; mbInUserDraw = false; } @@ -951,7 +952,7 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext) bool bNativeOK = false; // adjust style if button should be rendered 'pressed' - if (mbPressed) + if (mbPressed || mbIsActive) nButtonStyle |= DrawButtonFlags::Pressed; // TODO: move this to Window class or make it a member !!! @@ -1004,7 +1005,7 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext) ImplControlValue aControlValue; ControlState nState = ControlState::NONE; - if (mbPressed) + if (mbPressed || mbIsActive) nState |= ControlState::PRESSED; if (ImplGetButtonState() & DrawButtonFlags::Pressed) nState |= ControlState::PRESSED; @@ -1018,6 +1019,12 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext) if (IsMouseOver() && aInRect.IsInside(GetPointerPosPixel())) nState |= ControlState::ROLLOVER; + if ( IsMouseOver() && aInRect.IsInside(GetPointerPosPixel()) && mbIsActive) + { + nState |= ControlState::ROLLOVER; + nButtonStyle &= ~DrawButtonFlags::Pressed; + } + bNativeOK = rRenderContext.DrawNativeControl(aCtrlType, ControlPart::ButtonDown, aInRect, nState, aControlValue, OUString()); } @@ -1027,7 +1034,7 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext) if (bNativeOK) return; - bool bRollOver = IsMouseOver() && aInRect.IsInside(GetPointerPosPixel()); + bool bRollOver = (IsMouseOver() && aInRect.IsInside(GetPointerPosPixel())); bool bDrawMenuSep = true; if (GetStyle() & WB_FLATBUTTON) { @@ -1040,7 +1047,7 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext) Rectangle aCtrlRegion(aInRect); ControlState nState = ControlState::NONE; - if (mbPressed || IsChecked()) + if (mbPressed || IsChecked() || mbIsActive) nState |= ControlState::PRESSED; if (ImplGetButtonState() & DrawButtonFlags::Pressed) nState |= ControlState::PRESSED; @@ -1051,9 +1058,12 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext) if (Window::IsEnabled()) nState |= ControlState::ENABLED; - if (bRollOver) + if (bRollOver || mbIsActive) nState |= ControlState::ROLLOVER; + if (mbIsActive && bRollOver) + nState &= ~ControlState::PRESSED; + if (GetStyle() & WB_BEVELBUTTON) aControlValue.mbBevelButton = true; diff --git a/vcl/source/control/menubtn.cxx b/vcl/source/control/menubtn.cxx index 702d7201dbe5..918e10b000ab 100644 --- a/vcl/source/control/menubtn.cxx +++ b/vcl/source/control/menubtn.cxx @@ -168,4 +168,22 @@ void MenuButton::SetPopupMenu( PopupMenu* pNewMenu ) mpMenu = pNewMenu; } +//class MenuToggleButton ---------------------------------------------------- + +MenuToggleButton::MenuToggleButton( vcl::Window* pParent, WinBits nWinBits ) + : MenuButton( pParent, nWinBits ) +{ +} + +MenuToggleButton::~MenuToggleButton() +{ + disposeOnce(); +} + +void MenuToggleButton::SetActive( bool bSel ) +{ + mbIsActive = bSel; +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |