Branch libreoffice-5-0-4
[LibreOffice.git] / include / svtools / toolbarmenu.hxx
blob272d9358e79ce2bb2e9c156ce361061599a16bdb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVTOOLS_TOOLBARMENU_HXX
21 #define INCLUDED_SVTOOLS_TOOLBARMENU_HXX
23 #include <svtools/svtdllapi.h>
25 #include <com/sun/star/frame/FeatureStateEvent.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/frame/XFrame.hpp>
29 #include <vector>
31 #include <rtl/ref.hxx>
33 #include <vcl/ctrl.hxx>
34 #include <vcl/menu.hxx>
35 #include <vcl/dockwin.hxx>
37 class ValueSet;
39 namespace svtools {
41 class ToolbarMenuEntry;
42 struct ToolbarMenu_Impl;
44 class SVT_DLLPUBLIC ToolbarMenu : public DockingWindow
46 friend class ToolbarMenuStatusListener;
47 friend struct ToolbarMenu_Impl;
48 public:
49 ToolbarMenu(const css::uno::Reference<css::frame::XFrame>& rFrame,
50 vcl::Window* pParentWindow,
51 WinBits nBits );
53 virtual ~ToolbarMenu();
54 virtual void dispose() SAL_OVERRIDE;
56 virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
57 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
58 virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
59 virtual void KeyInput( const KeyEvent& rKEvent ) SAL_OVERRIDE;
60 virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
61 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
62 virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
63 virtual void GetFocus() SAL_OVERRIDE;
64 virtual void LoseFocus() SAL_OVERRIDE;
66 void appendEntry( int nEntryId, const OUString& rStr, MenuItemBits nItemBits = MenuItemBits::NONE );
67 void appendEntry( int nEntryId, const OUString& rStr, const Image& rImage, MenuItemBits nItemBits = MenuItemBits::NONE );
68 void appendEntry( int nEntryId, Control* pControl, MenuItemBits nItemBits = MenuItemBits::NONE );
69 void appendSeparator();
71 /** creates an empty ValueSet that is initialized and can be inserted with appendEntry. */
72 VclPtr<ValueSet> createEmptyValueSetControl();
74 void checkEntry( int nEntryId, bool bCheck = true );
76 void enableEntry( int nEntryId, bool bEnable = true );
78 void setEntryText( int nEntryId, const OUString& rStr );
80 void setEntryImage( int nEntryId, const Image& rImage );
82 const Size& getMenuSize() const;
84 void SetSelectHdl( const Link<>& rLink );
86 int getSelectedEntryId() const;
87 int getHighlightedEntryId() const;
89 void highlightFirstEntry();
91 protected:
92 virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() SAL_OVERRIDE;
94 // todo: move to new base class that will replace SfxPopupWindow
95 void AddStatusListener( const OUString& rCommandURL );
97 bool IsInPopupMode();
98 void EndPopupMode();
100 // Forwared from XStatusListener (subclasses must override this one to get
101 // the status updates):
102 virtual void statusChanged(const css::frame::FeatureStateEvent& Event ) throw (css::uno::RuntimeException);
104 void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
105 void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
107 private:
108 DECL_LINK( HighlightHdl, Control * );
110 void initStatusListener();
112 void implInit(const css::uno::Reference<css::frame::XFrame>& rFrame);
113 void initWindow();
115 Size implCalcSize();
117 void appendEntry(ToolbarMenuEntry* pEntry);
119 void implPaint(vcl::RenderContext& rRenderContext, ToolbarMenuEntry* pThisOnly = NULL, bool bHighlight = false);
121 void implHighlightEntry(vcl::RenderContext& rRenderContext, int nHighlightEntry, bool bHighlight);
122 void implHighlightAtPosition(const MouseEvent& rMEvt, bool bMBDown);
124 void implChangeHighlightEntry( int nEntry );
125 void implSelectEntry( int nSelectedEntry );
127 ToolbarMenuEntry* implCursorUpDown( bool bUp, bool bHomeEnd );
128 ToolbarMenuEntry* implGetEntry( int nEntry ) const;
129 ToolbarMenuEntry* implSearchEntry( int nEntryId ) const;
131 ToolbarMenu_Impl* mpImpl;
134 } // namespace svtools
136 #endif
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */