10d63794cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
30d63794cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
40d63794cSAndrew Rist * or more contributor license agreements. See the NOTICE file
50d63794cSAndrew Rist * distributed with this work for additional information
60d63794cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
70d63794cSAndrew Rist * to you under the Apache License, Version 2.0 (the
80d63794cSAndrew Rist * "License"); you may not use this file except in compliance
90d63794cSAndrew Rist * with the License. You may obtain a copy of the License at
100d63794cSAndrew Rist *
110d63794cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
120d63794cSAndrew Rist *
130d63794cSAndrew Rist * Unless required by applicable law or agreed to in writing,
140d63794cSAndrew Rist * software distributed under the License is distributed on an
150d63794cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
160d63794cSAndrew Rist * KIND, either express or implied. See the License for the
170d63794cSAndrew Rist * specific language governing permissions and limitations
180d63794cSAndrew Rist * under the License.
190d63794cSAndrew Rist *
200d63794cSAndrew Rist *************************************************************/
210d63794cSAndrew Rist
220d63794cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _SV_MENU_HXX
25cdf0e10cSrcweir #define _SV_MENU_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <vcl/sv.h>
28cdf0e10cSrcweir #include <vcl/dllapi.h>
29cdf0e10cSrcweir #include <tools/rc.hxx>
30cdf0e10cSrcweir #include <tools/resid.hxx>
31cdf0e10cSrcweir #include <vcl/bitmapex.hxx>
32cdf0e10cSrcweir #include <tools/color.hxx>
33cdf0e10cSrcweir #include <vcl/vclevent.hxx>
34cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
35cdf0e10cSrcweir
36cdf0e10cSrcweir struct MenuItemData;
37cdf0e10cSrcweir class Point;
38cdf0e10cSrcweir class Size;
39cdf0e10cSrcweir class Rectangle;
40cdf0e10cSrcweir class Menu;
41cdf0e10cSrcweir class MenuItemList;
42cdf0e10cSrcweir class HelpEvent;
43cdf0e10cSrcweir class Image;
44cdf0e10cSrcweir class PopupMenu;
45cdf0e10cSrcweir class KeyCode;
46cdf0e10cSrcweir class KeyEvent;
47cdf0e10cSrcweir class AppBarWindow;
48cdf0e10cSrcweir class MenuFloatingWindow;
49cdf0e10cSrcweir class Window;
50cdf0e10cSrcweir class SalMenu;
51cdf0e10cSrcweir struct SystemMenuData;
52cdf0e10cSrcweir
53cdf0e10cSrcweir namespace com {
54cdf0e10cSrcweir namespace sun {
55cdf0e10cSrcweir namespace star {
56cdf0e10cSrcweir namespace accessibility {
57cdf0e10cSrcweir class XAccessible;
58cdf0e10cSrcweir }}}}
59cdf0e10cSrcweir
60cdf0e10cSrcweir namespace vcl { struct MenuLayoutData; }
61cdf0e10cSrcweir
62cdf0e10cSrcweir // --------------
63cdf0e10cSrcweir // - Menu-Types -
64cdf0e10cSrcweir // --------------
65cdf0e10cSrcweir
66cdf0e10cSrcweir #define MENU_APPEND ((sal_uInt16)0xFFFF)
67cdf0e10cSrcweir #define MENU_ITEM_NOTFOUND ((sal_uInt16)0xFFFF)
68cdf0e10cSrcweir
69cdf0e10cSrcweir #define POPUPMENU_EXECUTE_DOWN ((sal_uInt16)0x0001)
70cdf0e10cSrcweir #define POPUPMENU_EXECUTE_UP ((sal_uInt16)0x0002)
71cdf0e10cSrcweir #define POPUPMENU_EXECUTE_LEFT ((sal_uInt16)0x0004)
72cdf0e10cSrcweir #define POPUPMENU_EXECUTE_RIGHT ((sal_uInt16)0x0008)
73cdf0e10cSrcweir
74cdf0e10cSrcweir #define POPUPMENU_NOMOUSEUPCLOSE ((sal_uInt16)0x0010)
75cdf0e10cSrcweir
76cdf0e10cSrcweir // By changes you must also change: rsc/vclrsc.hxx
77cdf0e10cSrcweir enum MenuItemType { MENUITEM_DONTKNOW, MENUITEM_STRING, MENUITEM_IMAGE,
78cdf0e10cSrcweir MENUITEM_STRINGIMAGE, MENUITEM_SEPARATOR };
79cdf0e10cSrcweir
80cdf0e10cSrcweir // By changes you must also change: rsc/vclrsc.hxx
81cdf0e10cSrcweir typedef sal_uInt16 MenuItemBits;
82cdf0e10cSrcweir #define MIB_CHECKABLE ((MenuItemBits)0x0001)
83cdf0e10cSrcweir #define MIB_RADIOCHECK ((MenuItemBits)0x0002)
84cdf0e10cSrcweir #define MIB_AUTOCHECK ((MenuItemBits)0x0004)
85cdf0e10cSrcweir #define MIB_ABOUT ((MenuItemBits)0x0008)
86cdf0e10cSrcweir #define MIB_HELP ((MenuItemBits)0x0010)
87cdf0e10cSrcweir #define MIB_POPUPSELECT ((MenuItemBits)0x0020)
88cdf0e10cSrcweir // not in rsc/vclsrc.hxx because only a prelimitary solution
89cdf0e10cSrcweir #define MIB_NOSELECT ((MenuItemBits)0x0040)
90cdf0e10cSrcweir #define MIB_ICON ((MenuItemBits)0x0080)
91cdf0e10cSrcweir #define MIB_TEXT ((MenuItemBits)0x0100)
92cdf0e10cSrcweir
93cdf0e10cSrcweir #define MENU_FLAG_NOAUTOMNEMONICS 0x0001
94cdf0e10cSrcweir #define MENU_FLAG_HIDEDISABLEDENTRIES 0x0002
95cdf0e10cSrcweir
96cdf0e10cSrcweir // overrides default hiding of disabled entries in popup menus
97cdf0e10cSrcweir #define MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES 0x0004
98cdf0e10cSrcweir
99cdf0e10cSrcweir // forces images & toggle visibility for toolbar config popup
100cdf0e10cSrcweir #define MENU_FLAG_SHOWCHECKIMAGES 0x0008
101cdf0e10cSrcweir
102cdf0e10cSrcweir struct ImplMenuDelData
103cdf0e10cSrcweir {
104cdf0e10cSrcweir ImplMenuDelData* mpNext;
105cdf0e10cSrcweir const Menu* mpMenu;
106cdf0e10cSrcweir
107*e1beba7dSHerbert Dürr explicit ImplMenuDelData( const Menu* );
108cdf0e10cSrcweir ~ImplMenuDelData();
109cdf0e10cSrcweir
isDeletedImplMenuDelData110cdf0e10cSrcweir bool isDeleted() const { return mpMenu == 0; }
111cdf0e10cSrcweir };
112cdf0e10cSrcweir
113cdf0e10cSrcweir // --------
114cdf0e10cSrcweir // - Menu -
115cdf0e10cSrcweir // --------
116cdf0e10cSrcweir
117cdf0e10cSrcweir struct MenuLogo
118cdf0e10cSrcweir {
119cdf0e10cSrcweir BitmapEx aBitmap;
120cdf0e10cSrcweir Color aStartColor;
121cdf0e10cSrcweir Color aEndColor;
122cdf0e10cSrcweir };
123cdf0e10cSrcweir
124cdf0e10cSrcweir class VCL_DLLPUBLIC Menu : public Resource
125cdf0e10cSrcweir {
126cdf0e10cSrcweir friend class MenuBar;
127cdf0e10cSrcweir friend class MenuBarWindow;
128cdf0e10cSrcweir friend class MenuFloatingWindow;
129cdf0e10cSrcweir friend class PopupMenu;
130cdf0e10cSrcweir friend class SystemWindow;
131cdf0e10cSrcweir friend struct ImplMenuDelData;
132cdf0e10cSrcweir private:
133cdf0e10cSrcweir ImplMenuDelData* mpFirstDel;
134cdf0e10cSrcweir MenuItemList* pItemList; // Liste mit den MenuItems
135cdf0e10cSrcweir MenuLogo* pLogo;
136cdf0e10cSrcweir Menu* pStartedFrom;
137cdf0e10cSrcweir Window* pWindow;
138cdf0e10cSrcweir
139cdf0e10cSrcweir Link aActivateHdl; // Active-Handler
140cdf0e10cSrcweir Link aDeactivateHdl; // Deactivate-Handler
141cdf0e10cSrcweir Link aHighlightHdl; // Highlight-Handler
142cdf0e10cSrcweir Link aSelectHdl; // Highlight-Handler
143cdf0e10cSrcweir
144cdf0e10cSrcweir VclEventListeners maEventListeners;
145cdf0e10cSrcweir VclEventListeners maChildEventListeners;
146cdf0e10cSrcweir
147cdf0e10cSrcweir XubString aTitleText; // PopupMenu-Text
148cdf0e10cSrcweir
149cdf0e10cSrcweir sal_uLong nEventId;
150cdf0e10cSrcweir sal_uInt16 mnHighlightedItemPos; // for native menues: keeps track of the highlighted item
151cdf0e10cSrcweir sal_uInt16 nMenuFlags;
152cdf0e10cSrcweir sal_uInt16 nDefaultItem; // Id vom Default-Item
153cdf0e10cSrcweir sal_uInt16 nSelectedId;
154ad3a95a3SSteve Yin sal_uInt16 nHighlightedItem;
155cdf0e10cSrcweir // Fuer Ausgabe:
156cdf0e10cSrcweir sal_uInt16 nCheckPos;
157cdf0e10cSrcweir sal_uInt16 nImagePos;
158cdf0e10cSrcweir sal_uInt16 nTextPos;
159cdf0e10cSrcweir
160cdf0e10cSrcweir sal_Bool bIsMenuBar : 1, // Handelt es sich um den MenuBar
161cdf0e10cSrcweir bCanceled : 1, // Waehrend eines Callbacks abgebrochen
162cdf0e10cSrcweir bInCallback : 1, // In Activate/Deactivate
163cdf0e10cSrcweir bKilled : 1; // Gekillt...
164cdf0e10cSrcweir
165cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxAccessible;
166cdf0e10cSrcweir mutable vcl::MenuLayoutData* mpLayoutData;
167cdf0e10cSrcweir SalMenu* mpSalMenu;
168cdf0e10cSrcweir
169cdf0e10cSrcweir protected:
170cdf0e10cSrcweir SAL_DLLPRIVATE void ImplInit();
171cdf0e10cSrcweir SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
172cdf0e10cSrcweir SAL_DLLPRIVATE Menu* ImplGetStartMenu();
173cdf0e10cSrcweir SAL_DLLPRIVATE Menu* ImplFindSelectMenu();
174cdf0e10cSrcweir SAL_DLLPRIVATE Menu* ImplFindMenu( sal_uInt16 nId );
175cdf0e10cSrcweir SAL_DLLPRIVATE Size ImplCalcSize( Window* pWin );
176cdf0e10cSrcweir SAL_DLLPRIVATE sal_Bool ImplIsVisible( sal_uInt16 nPos ) const;
177cdf0e10cSrcweir SAL_DLLPRIVATE sal_Bool ImplIsSelectable( sal_uInt16 nPos ) const;
178cdf0e10cSrcweir SAL_DLLPRIVATE sal_uInt16 ImplGetVisibleItemCount() const;
179cdf0e10cSrcweir SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisible() const;
180cdf0e10cSrcweir SAL_DLLPRIVATE sal_uInt16 ImplGetPrevVisible( sal_uInt16 nPos ) const;
181cdf0e10cSrcweir SAL_DLLPRIVATE sal_uInt16 ImplGetNextVisible( sal_uInt16 nPos ) const;
182cdf0e10cSrcweir SAL_DLLPRIVATE void ImplPaint( Window* pWin, sal_uInt16 nBorder, long nOffY = 0, MenuItemData* pThisDataOnly = 0, sal_Bool bHighlighted = sal_False, bool bLayout = false ) const;
183cdf0e10cSrcweir SAL_DLLPRIVATE void ImplSelect();
184cdf0e10cSrcweir SAL_DLLPRIVATE void ImplCallHighlight( sal_uInt16 nHighlightItem );
185cdf0e10cSrcweir SAL_DLLPRIVATE void ImplCallEventListeners( sal_uLong nEvent, sal_uInt16 nPos );
186cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( ImplCallSelect, Menu* );
187cdf0e10cSrcweir
188cdf0e10cSrcweir SAL_DLLPRIVATE void ImplFillLayoutData() const;
ImplGetSalMenu()189cdf0e10cSrcweir SAL_DLLPRIVATE SalMenu* ImplGetSalMenu() { return mpSalMenu; }
190cdf0e10cSrcweir SAL_DLLPRIVATE void ImplSetSalMenu( SalMenu *pMenu );
191cdf0e10cSrcweir SAL_DLLPRIVATE const XubString& ImplGetHelpText( sal_uInt16 nItemId ) const;
192cdf0e10cSrcweir
193cdf0e10cSrcweir // returns native check and option menu symbol height;
194cdf0e10cSrcweir // return value is Max( rCheckHeight, rRadioHeight )
195cdf0e10cSrcweir SAL_DLLPRIVATE long ImplGetNativeCheckAndRadioSize( Window*, long& rCheckHeight, long& rRadioHeight, long &rMaxWidth ) const;
196cdf0e10cSrcweir
197cdf0e10cSrcweir SAL_DLLPRIVATE void ImplAddDel( ImplMenuDelData &rDel );
198cdf0e10cSrcweir SAL_DLLPRIVATE void ImplRemoveDel( ImplMenuDelData &rDel );
199cdf0e10cSrcweir public:
200cdf0e10cSrcweir SAL_DLLPRIVATE void ImplKillLayoutData() const;
201cdf0e10cSrcweir SAL_DLLPRIVATE Menu* ImplGetStartedFrom() const;
202cdf0e10cSrcweir
203cdf0e10cSrcweir Menu();
204*e1beba7dSHerbert Dürr explicit Menu( sal_Bool bMenuBar );
ImplGetWindow() const205cdf0e10cSrcweir SAL_DLLPRIVATE Window* ImplGetWindow() const { return pWindow; }
206cdf0e10cSrcweir
207cdf0e10cSrcweir
208cdf0e10cSrcweir SAL_DLLPRIVATE void ImplSelectWithStart( Menu* pStartMenu = NULL );
209cdf0e10cSrcweir public:
210cdf0e10cSrcweir virtual ~Menu();
211cdf0e10cSrcweir
212cdf0e10cSrcweir virtual void Activate();
213cdf0e10cSrcweir virtual void Deactivate();
214cdf0e10cSrcweir virtual void Highlight();
215cdf0e10cSrcweir virtual void Select();
216cdf0e10cSrcweir virtual void RequestHelp( const HelpEvent& rHEvt );
217cdf0e10cSrcweir
218cdf0e10cSrcweir void InsertItem( sal_uInt16 nItemId, const XubString& rStr,
219cdf0e10cSrcweir MenuItemBits nItemBits = 0,
220cdf0e10cSrcweir sal_uInt16 nPos = MENU_APPEND );
221cdf0e10cSrcweir void InsertItem( sal_uInt16 nItemId, const Image& rImage,
222cdf0e10cSrcweir MenuItemBits nItemBits = 0,
223cdf0e10cSrcweir sal_uInt16 nPos = MENU_APPEND );
224cdf0e10cSrcweir void InsertItem( sal_uInt16 nItemId,
225cdf0e10cSrcweir const XubString& rString, const Image& rImage,
226cdf0e10cSrcweir MenuItemBits nItemBits = 0,
227cdf0e10cSrcweir sal_uInt16 nPos = MENU_APPEND );
228cdf0e10cSrcweir void InsertItem( const ResId& rResId, sal_uInt16 nPos = MENU_APPEND );
229cdf0e10cSrcweir void InsertSeparator( sal_uInt16 nPos = MENU_APPEND );
230cdf0e10cSrcweir void RemoveItem( sal_uInt16 nPos );
231cdf0e10cSrcweir void CopyItem( const Menu& rMenu, sal_uInt16 nPos,
232cdf0e10cSrcweir sal_uInt16 nNewPos = MENU_APPEND );
233cdf0e10cSrcweir void Clear();
234cdf0e10cSrcweir
235cdf0e10cSrcweir void CreateAutoMnemonics();
236cdf0e10cSrcweir
SetMenuFlags(sal_uInt16 nFlags)237cdf0e10cSrcweir void SetMenuFlags( sal_uInt16 nFlags ) { nMenuFlags = nFlags; }
GetMenuFlags() const238cdf0e10cSrcweir sal_uInt16 GetMenuFlags() const { return nMenuFlags; }
239cdf0e10cSrcweir
240cdf0e10cSrcweir sal_uInt16 GetItemCount() const;
241cdf0e10cSrcweir sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
242cdf0e10cSrcweir sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const;
243cdf0e10cSrcweir MenuItemType GetItemType( sal_uInt16 nPos ) const;
244cdf0e10cSrcweir sal_uInt16 GetCurItemId() const;
245ad3a95a3SSteve Yin void SetHightlightItem( sal_uInt16 nHighlightedItem );
246ad3a95a3SSteve Yin sal_uInt16 GetHighlightItem() const;
247ad3a95a3SSteve Yin
248ad3a95a3SSteve Yin XubString GetItemAccKeyStrFromPos(sal_uInt16 nPos ) const ;
249cdf0e10cSrcweir
250ad3a95a3SSteve Yin sal_Bool IsTemporaryItemFromPos(sal_uInt16 nPos ) const;
SetDefaultItem(sal_uInt16 nItemId)251cdf0e10cSrcweir void SetDefaultItem( sal_uInt16 nItemId ) { nDefaultItem = nItemId; }
GetDefaultItem() const252cdf0e10cSrcweir sal_uInt16 GetDefaultItem() const { return nDefaultItem; }
253cdf0e10cSrcweir
254cdf0e10cSrcweir void SetItemBits( sal_uInt16 nItemId, MenuItemBits nBits );
255cdf0e10cSrcweir MenuItemBits GetItemBits( sal_uInt16 nItemId ) const;
256cdf0e10cSrcweir
257cdf0e10cSrcweir void SetUserValue( sal_uInt16 nItemId, sal_uLong nValue );
258cdf0e10cSrcweir sal_uLong GetUserValue( sal_uInt16 nItemId ) const;
259cdf0e10cSrcweir
260cdf0e10cSrcweir void SetPopupMenu( sal_uInt16 nItemId, PopupMenu* pMenu );
261cdf0e10cSrcweir PopupMenu* GetPopupMenu( sal_uInt16 nItemId ) const;
262cdf0e10cSrcweir
263cdf0e10cSrcweir void SetAccelKey( sal_uInt16 nItemId, const KeyCode& rKeyCode );
264cdf0e10cSrcweir KeyCode GetAccelKey( sal_uInt16 nItemId ) const;
265cdf0e10cSrcweir
266cdf0e10cSrcweir void CheckItem( sal_uInt16 nItemId, sal_Bool bCheck = sal_True );
267cdf0e10cSrcweir sal_Bool IsItemChecked( sal_uInt16 nItemId ) const;
268cdf0e10cSrcweir
269cdf0e10cSrcweir void SelectItem( sal_uInt16 nItemId );
DeSelect()270cdf0e10cSrcweir void DeSelect() { SelectItem( 0xFFFF ); } // MENUITEMPOS_INVALID
271cdf0e10cSrcweir
272cdf0e10cSrcweir void EnableItem( sal_uInt16 nItemId, sal_Bool bEnable = sal_True );
273cdf0e10cSrcweir sal_Bool IsItemEnabled( sal_uInt16 nItemId ) const;
274cdf0e10cSrcweir
275cdf0e10cSrcweir void ShowItem( sal_uInt16 nItemId, sal_Bool bVisible = sal_True );
HideItem(sal_uInt16 nItemId)276cdf0e10cSrcweir void HideItem( sal_uInt16 nItemId ) { ShowItem( nItemId, sal_False ); }
277cdf0e10cSrcweir
278cdf0e10cSrcweir sal_Bool IsItemVisible( sal_uInt16 nItemId ) const;
279cdf0e10cSrcweir sal_Bool IsItemPosVisible( sal_uInt16 nItemPos ) const;
280cdf0e10cSrcweir sal_Bool IsMenuVisible() const;
IsMenuBar() const281cdf0e10cSrcweir sal_Bool IsMenuBar() const { return bIsMenuBar; }
282cdf0e10cSrcweir
283cdf0e10cSrcweir void RemoveDisabledEntries( sal_Bool bCheckPopups = sal_True, sal_Bool bRemoveEmptyPopups = sal_False );
284cdf0e10cSrcweir sal_Bool HasValidEntries( sal_Bool bCheckPopups = sal_True );
285cdf0e10cSrcweir
286cdf0e10cSrcweir void SetItemText( sal_uInt16 nItemId, const XubString& rStr );
287cdf0e10cSrcweir XubString GetItemText( sal_uInt16 nItemId ) const;
288cdf0e10cSrcweir
289cdf0e10cSrcweir void SetItemImage( sal_uInt16 nItemId, const Image& rImage );
290cdf0e10cSrcweir Image GetItemImage( sal_uInt16 nItemId ) const;
291cdf0e10cSrcweir void SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 );
292cdf0e10cSrcweir long GetItemImageAngle( sal_uInt16 nItemId ) const;
293cdf0e10cSrcweir void SetItemImageMirrorMode( sal_uInt16 nItemId, sal_Bool bMirror );
294cdf0e10cSrcweir sal_Bool GetItemImageMirrorMode( sal_uInt16 ) const;
295cdf0e10cSrcweir
296cdf0e10cSrcweir void SetItemCommand( sal_uInt16 nItemId, const XubString& rCommand );
297cdf0e10cSrcweir const XubString& GetItemCommand( sal_uInt16 nItemId ) const;
298cdf0e10cSrcweir
299cdf0e10cSrcweir void SetHelpText( sal_uInt16 nItemId, const XubString& rString );
300cdf0e10cSrcweir const XubString& GetHelpText( sal_uInt16 nItemId ) const;
301cdf0e10cSrcweir
302cdf0e10cSrcweir void SetTipHelpText( sal_uInt16 nItemId, const XubString& rString );
303cdf0e10cSrcweir const XubString& GetTipHelpText( sal_uInt16 nItemId ) const;
304cdf0e10cSrcweir
305cdf0e10cSrcweir void SetHelpCommand( sal_uInt16 nItemId, const XubString& rString );
306cdf0e10cSrcweir const XubString& GetHelpCommand( sal_uInt16 nItemId ) const;
307cdf0e10cSrcweir
308cdf0e10cSrcweir void SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId );
309cdf0e10cSrcweir rtl::OString GetHelpId( sal_uInt16 nItemId ) const;
310cdf0e10cSrcweir
SetActivateHdl(const Link & rLink)311cdf0e10cSrcweir void SetActivateHdl( const Link& rLink ) { aActivateHdl = rLink; }
GetActivateHdl() const312cdf0e10cSrcweir const Link& GetActivateHdl() const { return aActivateHdl; }
313cdf0e10cSrcweir
SetDeactivateHdl(const Link & rLink)314cdf0e10cSrcweir void SetDeactivateHdl( const Link& rLink ) { aDeactivateHdl = rLink; }
GetDeactivateHdl() const315cdf0e10cSrcweir const Link& GetDeactivateHdl() const { return aDeactivateHdl; }
316cdf0e10cSrcweir
SetHighlightHdl(const Link & rLink)317cdf0e10cSrcweir void SetHighlightHdl( const Link& rLink ) { aHighlightHdl = rLink; }
GetHighlightHdl() const318cdf0e10cSrcweir const Link& GetHighlightHdl() const { return aHighlightHdl; }
319cdf0e10cSrcweir
SetSelectHdl(const Link & rLink)320cdf0e10cSrcweir void SetSelectHdl( const Link& rLink ) { aSelectHdl = rLink; }
GetSelectHdl() const321cdf0e10cSrcweir const Link& GetSelectHdl() const { return aSelectHdl; }
322cdf0e10cSrcweir
323cdf0e10cSrcweir void SetLogo( const MenuLogo& rLogo );
324cdf0e10cSrcweir void SetLogo();
HasLogo() const325cdf0e10cSrcweir sal_Bool HasLogo() const { return pLogo ? sal_True : sal_False; }
326cdf0e10cSrcweir MenuLogo GetLogo() const;
327cdf0e10cSrcweir
328cdf0e10cSrcweir void AddEventListener( const Link& rEventListener );
329cdf0e10cSrcweir void RemoveEventListener( const Link& rEventListener );
330cdf0e10cSrcweir //void AddChildEventListener( const Link& rEventListener );
331cdf0e10cSrcweir //void RemoveChildEventListener( const Link& rEventListener );
332cdf0e10cSrcweir
333cdf0e10cSrcweir Menu& operator =( const Menu& rMenu );
334cdf0e10cSrcweir
335cdf0e10cSrcweir // Fuer Menu-'Funktionen'
GetItemList() const336cdf0e10cSrcweir MenuItemList* GetItemList() const { return pItemList; }
337cdf0e10cSrcweir
338cdf0e10cSrcweir // returns the system's menu handle if native menues are supported
339cdf0e10cSrcweir // pData must point to a SystemMenuData structure
340cdf0e10cSrcweir sal_Bool GetSystemMenuData( SystemMenuData* pData ) const;
341cdf0e10cSrcweir
342cdf0e10cSrcweir // accessibility helpers
343cdf0e10cSrcweir
344cdf0e10cSrcweir // gets the displayed text
345cdf0e10cSrcweir String GetDisplayText() const;
346cdf0e10cSrcweir // returns the bounding box for the character at index nIndex
347cdf0e10cSrcweir // where nIndex is relative to the starting index of the item
348cdf0e10cSrcweir // with id nItemId (in coordinates of the displaying window)
349cdf0e10cSrcweir Rectangle GetCharacterBounds( sal_uInt16 nItemId, long nIndex ) const;
350cdf0e10cSrcweir // -1 is returned if no character is at that point
351cdf0e10cSrcweir // if an index is found the corresponding item id is filled in (else 0)
352cdf0e10cSrcweir long GetIndexForPoint( const Point& rPoint, sal_uInt16& rItemID ) const;
353cdf0e10cSrcweir // returns the number of lines in the result of GetDisplayText()
354cdf0e10cSrcweir long GetLineCount() const;
355cdf0e10cSrcweir // returns the interval [start,end] of line nLine
356cdf0e10cSrcweir // returns [-1,-1] for an invalid line
357cdf0e10cSrcweir Pair GetLineStartEnd( long nLine ) const;
358cdf0e10cSrcweir // like GetLineStartEnd but first finds the line number for the item
359cdf0e10cSrcweir Pair GetItemStartEnd( sal_uInt16 nItemId ) const;
360cdf0e10cSrcweir // returns the item id for line nLine or 0 if nLine is invalid
361cdf0e10cSrcweir sal_uInt16 GetDisplayItemId( long nLine ) const;
362cdf0e10cSrcweir // returns the bounding rectangle for an item at pos nItemPos
363cdf0e10cSrcweir Rectangle GetBoundingRectangle( sal_uInt16 nItemPos ) const;
364cdf0e10cSrcweir sal_Bool ConvertPoint( Point& rPoint, Window* pReferenceWindow ) const;
365cdf0e10cSrcweir
366cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetAccessible();
367cdf0e10cSrcweir void SetAccessible( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rxAccessible );
368cdf0e10cSrcweir
369cdf0e10cSrcweir // gets the activation key of the specified item
370cdf0e10cSrcweir KeyEvent GetActivationKey( sal_uInt16 nItemId ) const;
371cdf0e10cSrcweir
GetWindow() const372cdf0e10cSrcweir Window* GetWindow() const { return pWindow; }
373cdf0e10cSrcweir
374cdf0e10cSrcweir void SetAccessibleName( sal_uInt16 nItemId, const XubString& rStr );
375cdf0e10cSrcweir XubString GetAccessibleName( sal_uInt16 nItemId ) const;
376cdf0e10cSrcweir
377cdf0e10cSrcweir void SetAccessibleDescription( sal_uInt16 nItemId, const XubString& rStr );
378cdf0e10cSrcweir XubString GetAccessibleDescription( sal_uInt16 nItemId ) const;
GetStartedFromMenu()379ad3a95a3SSteve Yin Menu* GetStartedFromMenu(){ return pStartedFrom ;}
380cdf0e10cSrcweir
381cdf0e10cSrcweir // returns whether the item a position nItemPos is highlighted or not.
382cdf0e10cSrcweir bool IsHighlighted( sal_uInt16 nItemPos ) const;
383cdf0e10cSrcweir
384cdf0e10cSrcweir void HighlightItem( sal_uInt16 nItemPos );
DeHighlight()385cdf0e10cSrcweir void DeHighlight() { HighlightItem( 0xFFFF ); } // MENUITEMPOS_INVALID
386cdf0e10cSrcweir
387cdf0e10cSrcweir
388cdf0e10cSrcweir void doLazyDelete();
389cdf0e10cSrcweir };
390cdf0e10cSrcweir
391cdf0e10cSrcweir // -----------
392cdf0e10cSrcweir // - MenuBar -
393cdf0e10cSrcweir // -----------
394cdf0e10cSrcweir
395cdf0e10cSrcweir class VCL_DLLPUBLIC MenuBar : public Menu
396cdf0e10cSrcweir {
397cdf0e10cSrcweir Link maCloserHdl;
398cdf0e10cSrcweir Link maFloatHdl;
399cdf0e10cSrcweir Link maHideHdl;
400cdf0e10cSrcweir sal_Bool mbCloserVisible;
401cdf0e10cSrcweir sal_Bool mbFloatBtnVisible;
402cdf0e10cSrcweir sal_Bool mbHideBtnVisible;
403cdf0e10cSrcweir sal_Bool mbDisplayable;
404cdf0e10cSrcweir
405cdf0e10cSrcweir //#if 0 // _SOLAR__PRIVATE
406cdf0e10cSrcweir friend class Application;
407cdf0e10cSrcweir friend class Menu;
408cdf0e10cSrcweir friend class MenuBarWindow;
409cdf0e10cSrcweir friend class MenuFloatingWindow;
410cdf0e10cSrcweir friend class SystemWindow;
411cdf0e10cSrcweir
412cdf0e10cSrcweir SAL_DLLPRIVATE static Window* ImplCreate( Window* pParent, Window* pWindow, MenuBar* pMenu );
413cdf0e10cSrcweir SAL_DLLPRIVATE static void ImplDestroy( MenuBar* pMenu, sal_Bool bDelete );
414cdf0e10cSrcweir SAL_DLLPRIVATE sal_Bool ImplHandleKeyEvent( const KeyEvent& rKEvent, sal_Bool bFromMenu = sal_True );
415cdf0e10cSrcweir //#endif
416cdf0e10cSrcweir
417cdf0e10cSrcweir public:
418cdf0e10cSrcweir MenuBar();
419*e1beba7dSHerbert Dürr explicit MenuBar( const ResId& );
420cdf0e10cSrcweir MenuBar( const MenuBar& rMenu );
421*e1beba7dSHerbert Dürr virtual ~MenuBar();
422cdf0e10cSrcweir
423cdf0e10cSrcweir MenuBar& operator =( const MenuBar& rMenu );
424cdf0e10cSrcweir
425cdf0e10cSrcweir void ShowCloser( sal_Bool bShow = sal_True );
HasCloser() const426cdf0e10cSrcweir sal_Bool HasCloser() const { return mbCloserVisible; }
427cdf0e10cSrcweir void ShowFloatButton( sal_Bool bShow = sal_True );
HasFloatButton() const428cdf0e10cSrcweir sal_Bool HasFloatButton() const { return mbFloatBtnVisible; }
429cdf0e10cSrcweir void ShowHideButton( sal_Bool bShow = sal_True );
HasHideButton() const430cdf0e10cSrcweir sal_Bool HasHideButton() const { return mbHideBtnVisible; }
431cdf0e10cSrcweir void ShowButtons( sal_Bool bClose, sal_Bool bFloat, sal_Bool bHide );
432cdf0e10cSrcweir
433cdf0e10cSrcweir void SelectEntry( sal_uInt16 nId );
434cdf0e10cSrcweir sal_Bool HandleMenuActivateEvent( Menu *pMenu ) const;
435cdf0e10cSrcweir sal_Bool HandleMenuDeActivateEvent( Menu *pMenu ) const;
436cdf0e10cSrcweir sal_Bool HandleMenuHighlightEvent( Menu *pMenu, sal_uInt16 nEventId ) const;
437cdf0e10cSrcweir sal_Bool HandleMenuCommandEvent( Menu *pMenu, sal_uInt16 nEventId ) const;
438cdf0e10cSrcweir sal_Bool HandleMenuButtonEvent( Menu *pMenu, sal_uInt16 nEventId ) const;
439cdf0e10cSrcweir
SetCloserHdl(const Link & rLink)440cdf0e10cSrcweir void SetCloserHdl( const Link& rLink ) { maCloserHdl = rLink; }
GetCloserHdl() const441cdf0e10cSrcweir const Link& GetCloserHdl() const { return maCloserHdl; }
SetFloatButtonClickHdl(const Link & rLink)442cdf0e10cSrcweir void SetFloatButtonClickHdl( const Link& rLink ) { maFloatHdl = rLink; }
GetFloatButtonClickHdl() const443cdf0e10cSrcweir const Link& GetFloatButtonClickHdl() const { return maFloatHdl; }
SetHideButtonClickHdl(const Link & rLink)444cdf0e10cSrcweir void SetHideButtonClickHdl( const Link& rLink ) { maHideHdl = rLink; }
GetHideButtonClickHdl() const445cdf0e10cSrcweir const Link& GetHideButtonClickHdl() const { return maHideHdl; }
446cdf0e10cSrcweir
447cdf0e10cSrcweir // - by default a menubar is displayable
448cdf0e10cSrcweir // - if a menubar is not displayable, its MenuBarWindow will never be shown
449cdf0e10cSrcweir // and it will be hidden if it was visible before
450cdf0e10cSrcweir // - note: if a menubar is diplayable, this does not necessarily mean that it is currently visible
451cdf0e10cSrcweir void SetDisplayable( sal_Bool bDisplayable );
IsDisplayable() const452cdf0e10cSrcweir sal_Bool IsDisplayable() const { return mbDisplayable; }
453cdf0e10cSrcweir
454cdf0e10cSrcweir struct MenuBarButtonCallbackArg
455cdf0e10cSrcweir {
456cdf0e10cSrcweir sal_uInt16 nId; // Id of the button
457cdf0e10cSrcweir bool bHighlight; // highlight on/off
458cdf0e10cSrcweir MenuBar* pMenuBar; // menubar the button belongs to
459cdf0e10cSrcweir };
460cdf0e10cSrcweir // add an arbitrary button to the menubar (will appear next to closer)
461cdf0e10cSrcweir // passed link will be call with a MenuBarButtonCallbackArg on press
462cdf0e10cSrcweir sal_uInt16 AddMenuBarButton( const Image&, const Link&, sal_uInt16 nPos = 0 );
463cdf0e10cSrcweir // add an arbitrary button to the menubar (will appear next to closer)
464cdf0e10cSrcweir // passed link will be call with a MenuBarButtonCallbackArg on press
465cdf0e10cSrcweir // passed string will be set as tooltip
466cdf0e10cSrcweir sal_uInt16 AddMenuBarButton( const Image&, const Link&, const String&, sal_uInt16 nPos = 0 );
467cdf0e10cSrcweir // set the highlight link for additional button with ID nId
468cdf0e10cSrcweir // highlight link will be called with a MenuBarButtonHighlightArg
469cdf0e10cSrcweir // the bHighlight member of that struct shall contain the new state
470cdf0e10cSrcweir void SetMenuBarButtonHighlightHdl( sal_uInt16 nId, const Link& );
471cdf0e10cSrcweir // returns the rectangle occupied by the additional button named nId
472cdf0e10cSrcweir // coordinates are relative to the systemwindiow the menubar is attached to
473cdf0e10cSrcweir // if the menubar is unattached an empty rectangle is returned
474cdf0e10cSrcweir Rectangle GetMenuBarButtonRectPixel( sal_uInt16 nId );
475cdf0e10cSrcweir void RemoveMenuBarButton( sal_uInt16 nId );
476cdf0e10cSrcweir };
477cdf0e10cSrcweir
operator =(const MenuBar & rMenu)478cdf0e10cSrcweir inline MenuBar& MenuBar::operator =( const MenuBar& rMenu )
479cdf0e10cSrcweir {
480cdf0e10cSrcweir Menu::operator =( rMenu );
481cdf0e10cSrcweir return *this;
482cdf0e10cSrcweir }
483cdf0e10cSrcweir
484cdf0e10cSrcweir
485cdf0e10cSrcweir // -------------
486cdf0e10cSrcweir // - PopupMenu -
487cdf0e10cSrcweir // -------------
488cdf0e10cSrcweir
489cdf0e10cSrcweir class VCL_DLLPUBLIC PopupMenu : public Menu
490cdf0e10cSrcweir {
491cdf0e10cSrcweir friend class Menu;
492cdf0e10cSrcweir friend class MenuFloatingWindow;
493cdf0e10cSrcweir friend class MenuBarWindow;
494cdf0e10cSrcweir friend struct MenuItemData;
495cdf0e10cSrcweir
496cdf0e10cSrcweir private:
497cdf0e10cSrcweir Menu** pRefAutoSubMenu; // keeps track if a pointer to this Menu is stored in the MenuItemData
498cdf0e10cSrcweir
ImplGetFloatingWindow() const499cdf0e10cSrcweir SAL_DLLPRIVATE MenuFloatingWindow* ImplGetFloatingWindow() const { return (MenuFloatingWindow*)Menu::ImplGetWindow(); }
500cdf0e10cSrcweir
501cdf0e10cSrcweir protected:
502cdf0e10cSrcweir SAL_DLLPRIVATE sal_uInt16 ImplExecute( Window* pWindow, const Rectangle& rRect, sal_uLong nPopupFlags, Menu* pStaredFrom, sal_Bool bPreSelectFirst );
503cdf0e10cSrcweir SAL_DLLPRIVATE long ImplCalcHeight( sal_uInt16 nEntries ) const;
504cdf0e10cSrcweir SAL_DLLPRIVATE sal_uInt16 ImplCalcVisEntries( long nMaxHeight, sal_uInt16 nStartEntry = 0, sal_uInt16* pLastVisible = NULL ) const;
505cdf0e10cSrcweir
506cdf0e10cSrcweir public:
507cdf0e10cSrcweir PopupMenu();
508cdf0e10cSrcweir PopupMenu( const PopupMenu& rMenu );
509*e1beba7dSHerbert Dürr explicit PopupMenu( const ResId& );
510*e1beba7dSHerbert Dürr virtual ~PopupMenu();
511cdf0e10cSrcweir
SetText(const XubString & rTitle)512cdf0e10cSrcweir void SetText( const XubString& rTitle ) { aTitleText = rTitle; }
GetText() const513cdf0e10cSrcweir const XubString& GetText() const { return aTitleText; }
514cdf0e10cSrcweir
515cdf0e10cSrcweir sal_uInt16 Execute( Window* pWindow, const Point& rPopupPos );
516cdf0e10cSrcweir sal_uInt16 Execute( Window* pWindow, const Rectangle& rRect, sal_uInt16 nFlags = 0 );
517cdf0e10cSrcweir
518cdf0e10cSrcweir // Fuer das TestTool
519cdf0e10cSrcweir void EndExecute( sal_uInt16 nSelect = 0 );
520cdf0e10cSrcweir void SelectEntry( sal_uInt16 nId );
521cdf0e10cSrcweir void SetSelectedEntry( sal_uInt16 nId ); // for use by native submenu only
522cdf0e10cSrcweir
523cdf0e10cSrcweir static sal_Bool IsInExecute();
524cdf0e10cSrcweir static PopupMenu* GetActivePopupMenu();
525cdf0e10cSrcweir
526cdf0e10cSrcweir PopupMenu& operator =( const PopupMenu& rMenu );
527cdf0e10cSrcweir };
528cdf0e10cSrcweir
operator =(const PopupMenu & rMenu)529cdf0e10cSrcweir inline PopupMenu& PopupMenu::operator =( const PopupMenu& rMenu )
530cdf0e10cSrcweir {
531cdf0e10cSrcweir Menu::operator =( rMenu );
532cdf0e10cSrcweir return *this;
533cdf0e10cSrcweir }
534cdf0e10cSrcweir
535cdf0e10cSrcweir #endif // _SV_MENU_HXX
536cdf0e10cSrcweir
537