1*01aa44aaSAndrew Rist /************************************************************** 2*01aa44aaSAndrew Rist * 3*01aa44aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*01aa44aaSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*01aa44aaSAndrew Rist * distributed with this work for additional information 6*01aa44aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*01aa44aaSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*01aa44aaSAndrew Rist * "License"); you may not use this file except in compliance 9*01aa44aaSAndrew Rist * with the License. You may obtain a copy of the License at 10*01aa44aaSAndrew Rist * 11*01aa44aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*01aa44aaSAndrew Rist * 13*01aa44aaSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*01aa44aaSAndrew Rist * software distributed under the License is distributed on an 15*01aa44aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*01aa44aaSAndrew Rist * KIND, either express or implied. See the License for the 17*01aa44aaSAndrew Rist * specific language governing permissions and limitations 18*01aa44aaSAndrew Rist * under the License. 19*01aa44aaSAndrew Rist * 20*01aa44aaSAndrew Rist *************************************************************/ 21*01aa44aaSAndrew Rist 22*01aa44aaSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SVTOOLS_TOOLBARMENU_HXX_ 25cdf0e10cSrcweir #define _SVTOOLS_TOOLBARMENU_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "svtools/svtdllapi.h" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <com/sun/star/frame/FeatureStateEvent.hpp> 30cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 31cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <vector> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <rtl/ref.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <vcl/ctrl.hxx> 38cdf0e10cSrcweir #include <vcl/menu.hxx> 39cdf0e10cSrcweir #include <vcl/dockwin.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir class ValueSet; 42cdf0e10cSrcweir 43cdf0e10cSrcweir namespace svtools { 44cdf0e10cSrcweir 45cdf0e10cSrcweir class ToolbarMenuEntry; 46cdf0e10cSrcweir struct ToolbarMenu_Impl; 47cdf0e10cSrcweir 48cdf0e10cSrcweir class SVT_DLLPUBLIC ToolbarMenu : public DockingWindow 49cdf0e10cSrcweir { 50cdf0e10cSrcweir friend class ToolbarMenuStatusListener; 51cdf0e10cSrcweir friend struct ToolbarMenu_Impl; 52cdf0e10cSrcweir public: 53cdf0e10cSrcweir ToolbarMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, 54cdf0e10cSrcweir Window* pParentWindow, 55cdf0e10cSrcweir WinBits nBits ); 56cdf0e10cSrcweir 57cdf0e10cSrcweir ToolbarMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, 58cdf0e10cSrcweir Window* pParentWindow, 59cdf0e10cSrcweir const ResId& rResId ); 60cdf0e10cSrcweir 61cdf0e10cSrcweir ~ToolbarMenu(); 62cdf0e10cSrcweir 63cdf0e10cSrcweir virtual void MouseMove( const MouseEvent& rMEvt ); 64cdf0e10cSrcweir virtual void MouseButtonDown( const MouseEvent& rMEvt ); 65cdf0e10cSrcweir virtual void MouseButtonUp( const MouseEvent& rMEvt ); 66cdf0e10cSrcweir virtual void KeyInput( const KeyEvent& rKEvent ); 67cdf0e10cSrcweir virtual void Command( const CommandEvent& rCEvt ); 68cdf0e10cSrcweir virtual void Paint( const Rectangle& rRect ); 69cdf0e10cSrcweir virtual void RequestHelp( const HelpEvent& rHEvt ); 70cdf0e10cSrcweir virtual void GetFocus(); 71cdf0e10cSrcweir virtual void LoseFocus(); 72cdf0e10cSrcweir 73cdf0e10cSrcweir void appendEntry( int nEntryId, const String& rStr, MenuItemBits nItemBits = 0 ); 74cdf0e10cSrcweir void appendEntry( int nEntryId, const Image& rImage, MenuItemBits nItemBits = 0 ); 75cdf0e10cSrcweir void appendEntry( int nEntryId, const String& rStr, const Image& rImage, MenuItemBits nItemBits = 0 ); 76cdf0e10cSrcweir void appendEntry( int nEntryId, Control* pControl, MenuItemBits nItemBits = 0 ); 77cdf0e10cSrcweir void appendSeparator(); 78cdf0e10cSrcweir 79cdf0e10cSrcweir /** creates an empty ValueSet that is initialized and can be inserted with appendEntry. */ 80cdf0e10cSrcweir ValueSet* createEmptyValueSetControl(); 81cdf0e10cSrcweir 82cdf0e10cSrcweir void checkEntry( int nEntryId, bool bCheck = true ); 83cdf0e10cSrcweir bool isEntryChecked( int nEntryId ) const; 84cdf0e10cSrcweir 85cdf0e10cSrcweir void enableEntry( int nEntryId, bool bEnable = true ); 86cdf0e10cSrcweir bool isEntryEnabled( int nEntryId ) const; 87cdf0e10cSrcweir 88cdf0e10cSrcweir void setEntryText( int nEntryId, const String& rStr ); 89cdf0e10cSrcweir const String& getEntryText( int nEntryId ) const; 90cdf0e10cSrcweir 91cdf0e10cSrcweir void setEntryImage( int nEntryId, const Image& rImage ); 92cdf0e10cSrcweir const Image& getEntryImage( int nEntryId ) const; 93cdf0e10cSrcweir 94cdf0e10cSrcweir const Size& getMenuSize() const; 95cdf0e10cSrcweir 96cdf0e10cSrcweir void SetSelectHdl( const Link& rLink ); 97cdf0e10cSrcweir const Link& GetSelectHdl() const; 98cdf0e10cSrcweir 99cdf0e10cSrcweir int getSelectedEntryId() const; 100cdf0e10cSrcweir int getHighlightedEntryId() const; 101cdf0e10cSrcweir 102cdf0e10cSrcweir void highlightFirstEntry(); 103cdf0e10cSrcweir 104cdf0e10cSrcweir protected: 105cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); 106cdf0e10cSrcweir 107cdf0e10cSrcweir // todo: move to new base class that will replace SfxPopupWindow 108cdf0e10cSrcweir void AddStatusListener( const rtl::OUString& rCommandURL ); 109cdf0e10cSrcweir void RemoveStatusListener( const rtl::OUString& rCommandURL ); 110cdf0e10cSrcweir void UpdateStatus( const rtl::OUString& rCommandURL ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir bool IsInPopupMode(); 113cdf0e10cSrcweir void EndPopupMode(); 114cdf0e10cSrcweir 115cdf0e10cSrcweir // XStatusListener (subclasses must override this one to get the status updates 116cdf0e10cSrcweir virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); 117cdf0e10cSrcweir 118cdf0e10cSrcweir void StateChanged( StateChangedType nType ); 119cdf0e10cSrcweir void DataChanged( const DataChangedEvent& rDCEvt ); 120cdf0e10cSrcweir 121cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrame() const; 122cdf0e10cSrcweir private: 123cdf0e10cSrcweir DECL_LINK( HighlightHdl, Control * ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir void initStatusListener(); 126cdf0e10cSrcweir 127cdf0e10cSrcweir void implInit( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ); 128cdf0e10cSrcweir void initWindow(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir Size implCalcSize(); 131cdf0e10cSrcweir 132cdf0e10cSrcweir void appendEntry( ToolbarMenuEntry* pEntry ); 133cdf0e10cSrcweir 134cdf0e10cSrcweir void implPaint( ToolbarMenuEntry* pThisOnly = NULL, bool bHighlight = false ); 135cdf0e10cSrcweir 136cdf0e10cSrcweir void implHighlightEntry( int nHighlightEntry, bool bHighlight ); 137cdf0e10cSrcweir void implHighlightEntry( const MouseEvent& rMEvt, bool bMBDown ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir void implChangeHighlightEntry( int nEntry ); 140cdf0e10cSrcweir void implSelectEntry( int nSelectedEntry ); 141cdf0e10cSrcweir 142cdf0e10cSrcweir ToolbarMenuEntry* implCursorUpDown( bool bUp, bool bHomeEnd ); 143cdf0e10cSrcweir ToolbarMenuEntry* implGetEntry( int nEntry ) const; 144cdf0e10cSrcweir ToolbarMenuEntry* implSearchEntry( int nEntryId ) const; 145cdf0e10cSrcweir 146cdf0e10cSrcweir ToolbarMenu_Impl* mpImpl; 147cdf0e10cSrcweir }; 148cdf0e10cSrcweir 149cdf0e10cSrcweir } // namespace svtools 150cdf0e10cSrcweir 151cdf0e10cSrcweir #endif 152