bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / svtools / toolbarmenu.hxx
blobbd73d7cb27848e63eebae32b7c35cb141b024f5c
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 <memory>
27 #include <rtl/ref.hxx>
28 #include <vcl/dockwin.hxx>
30 namespace com :: sun :: star :: frame { class XFrame; }
31 namespace com :: sun :: star :: frame { struct FeatureStateEvent; }
32 namespace svt { class FrameStatusListener; }
34 class Control;
35 class ValueSet;
37 namespace svtools {
39 class ToolbarMenuEntry;
40 struct ToolbarMenu_Impl;
42 class SVT_DLLPUBLIC ToolbarPopupBase
44 friend class ToolbarPopupStatusListener;
45 public:
46 ToolbarPopupBase(const css::uno::Reference<css::frame::XFrame>& rFrame);
47 virtual ~ToolbarPopupBase();
49 protected:
50 void AddStatusListener( const OUString& rCommandURL );
52 // Forwarded from XStatusListener (subclasses must override this one to get the status updates):
53 /// @throws css::uno::RuntimeException
54 virtual void statusChanged(const css::frame::FeatureStateEvent& Event );
56 css::uno::Reference<css::frame::XFrame> mxFrame;
57 rtl::Reference<svt::FrameStatusListener> mxStatusListener;
60 class SVT_DLLPUBLIC ToolbarPopup : public DockingWindow, public ToolbarPopupBase
62 public:
63 ToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame,
64 vcl::Window* pParentWindow,
65 WinBits nBits );
66 ToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame,
67 vcl::Window* pParentWindow,
68 const OString& rID, const OUString& rUIXMLDescription );
69 virtual ~ToolbarPopup() override;
70 virtual void dispose() override;
72 protected:
73 bool IsInPopupMode();
74 void EndPopupMode();
76 private:
77 void init();
80 class SVT_DLLPUBLIC ToolbarMenu : public ToolbarPopup
82 friend struct ToolbarMenu_Impl;
83 public:
84 ToolbarMenu(const css::uno::Reference<css::frame::XFrame>& rFrame,
85 vcl::Window* pParentWindow,
86 WinBits nBits );
88 virtual ~ToolbarMenu() override;
89 virtual void dispose() override;
91 virtual void MouseMove( const MouseEvent& rMEvt ) override;
92 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
93 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
94 virtual void KeyInput( const KeyEvent& rKEvent ) override;
95 virtual void Command( const CommandEvent& rCEvt ) override;
96 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
97 virtual void GetFocus() override;
98 virtual void LoseFocus() override;
100 void appendEntry( int nEntryId, const OUString& rStr, MenuItemBits nItemBits = MenuItemBits::NONE );
101 void appendEntry( int nEntryId, const OUString& rStr, const Image& rImage );
102 void appendEntry( int nEntryId, Control* pControl );
103 void appendSeparator();
105 /** creates an empty ValueSet that is initialized and can be inserted with appendEntry. */
106 VclPtr<ValueSet> createEmptyValueSetControl();
108 void checkEntry( int nEntryId, bool bCheck );
110 void enableEntry( int nEntryId, bool bEnable );
112 void setEntryText( int nEntryId, const OUString& rStr );
114 void setEntryImage( int nEntryId, const Image& rImage );
116 const Size& getMenuSize() const;
118 void SetSelectHdl( const Link<ToolbarMenu*,void>& rLink );
120 int getSelectedEntryId() const;
121 int getHighlightedEntryId() const;
123 protected:
124 virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
126 void StateChanged( StateChangedType nType ) override;
127 void DataChanged( const DataChangedEvent& rDCEvt ) override;
129 private:
130 DECL_LINK( HighlightHdl, ValueSet*, void );
132 void initWindow();
134 Size implCalcSize();
136 void appendEntry(std::unique_ptr<ToolbarMenuEntry> pEntry);
138 void implPaint(vcl::RenderContext& rRenderContext, ToolbarMenuEntry const * pThisOnly = nullptr, bool bHighlight = false);
140 void implHighlightEntry(vcl::RenderContext& rRenderContext, int nHighlightEntry);
141 void implHighlightAtPosition(const MouseEvent& rMEvt);
143 void implChangeHighlightEntry( int nEntry );
144 void implSelectEntry( int nSelectedEntry );
146 ToolbarMenuEntry* implCursorUpDown( bool bUp, bool bHomeEnd );
147 ToolbarMenuEntry* implGetEntry( int nEntry ) const;
148 ToolbarMenuEntry* implSearchEntry( int nEntryId ) const;
150 std::unique_ptr<ToolbarMenu_Impl> mpImpl;
153 } // namespace svtools
155 #endif
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */