1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
31 #include <rtl/ref.hxx>
33 #include <vcl/ctrl.hxx>
34 #include <vcl/menu.hxx>
35 #include <vcl/dockwin.hxx>
41 class ToolbarMenuEntry
;
42 struct ToolbarMenu_Impl
;
44 class SVT_DLLPUBLIC ToolbarMenu
: public DockingWindow
46 friend class ToolbarMenuStatusListener
;
47 friend struct ToolbarMenu_Impl
;
49 ToolbarMenu( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
,
50 Window
* pParentWindow
,
53 ToolbarMenu( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
,
54 Window
* pParentWindow
,
55 const ResId
& rResId
);
59 virtual void MouseMove( const MouseEvent
& rMEvt
);
60 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
61 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
62 virtual void KeyInput( const KeyEvent
& rKEvent
);
63 virtual void Command( const CommandEvent
& rCEvt
);
64 virtual void Paint( const Rectangle
& rRect
);
65 virtual void RequestHelp( const HelpEvent
& rHEvt
);
66 virtual void GetFocus();
67 virtual void LoseFocus();
69 void appendEntry( int nEntryId
, const OUString
& rStr
, MenuItemBits nItemBits
= 0 );
70 void appendEntry( int nEntryId
, const OUString
& rStr
, const Image
& rImage
, MenuItemBits nItemBits
= 0 );
71 void appendEntry( int nEntryId
, Control
* pControl
, MenuItemBits nItemBits
= 0 );
72 void appendSeparator();
74 /** creates an empty ValueSet that is initialized and can be inserted with appendEntry. */
75 ValueSet
* createEmptyValueSetControl();
77 void checkEntry( int nEntryId
, bool bCheck
= true );
79 void enableEntry( int nEntryId
, bool bEnable
= true );
81 void setEntryText( int nEntryId
, const OUString
& rStr
);
83 void setEntryImage( int nEntryId
, const Image
& rImage
);
85 const Size
& getMenuSize() const;
87 void SetSelectHdl( const Link
& rLink
);
89 int getSelectedEntryId() const;
90 int getHighlightedEntryId() const;
92 void highlightFirstEntry();
95 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> CreateAccessible();
97 // todo: move to new base class that will replace SfxPopupWindow
98 void AddStatusListener( const OUString
& rCommandURL
);
100 bool IsInPopupMode();
103 // XStatusListener (subclasses must override this one to get the status updates
104 virtual void SAL_CALL
statusChanged( const ::com::sun::star::frame::FeatureStateEvent
& Event
) throw ( ::com::sun::star::uno::RuntimeException
);
106 void StateChanged( StateChangedType nType
);
107 void DataChanged( const DataChangedEvent
& rDCEvt
);
110 DECL_LINK( HighlightHdl
, Control
* );
112 void initStatusListener();
114 void implInit( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
);
119 void appendEntry( ToolbarMenuEntry
* pEntry
);
121 void implPaint( ToolbarMenuEntry
* pThisOnly
= NULL
, bool bHighlight
= false );
123 void implHighlightEntry( int nHighlightEntry
, bool bHighlight
);
124 void implHighlightEntry( const MouseEvent
& rMEvt
, bool bMBDown
);
126 void implChangeHighlightEntry( int nEntry
);
127 void implSelectEntry( int nSelectedEntry
);
129 ToolbarMenuEntry
* implCursorUpDown( bool bUp
, bool bHomeEnd
);
130 ToolbarMenuEntry
* implGetEntry( int nEntry
) const;
131 ToolbarMenuEntry
* implSearchEntry( int nEntryId
) const;
133 ToolbarMenu_Impl
* mpImpl
;
136 } // namespace svtools
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */