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