Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SV_MENU_HXX
30 : : #define _SV_MENU_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <vcl/dllapi.h>
34 : : #include <tools/rc.hxx>
35 : : #include <tools/resid.hxx>
36 : : #include <vcl/bitmapex.hxx>
37 : : #include <tools/color.hxx>
38 : : #include <vcl/vclevent.hxx>
39 : : #include <com/sun/star/uno/Reference.hxx>
40 : :
41 : : struct MenuItemData;
42 : : class Point;
43 : : class Size;
44 : : class Rectangle;
45 : : class Menu;
46 : : class MenuItemList;
47 : : class HelpEvent;
48 : : class Image;
49 : : class PopupMenu;
50 : : class KeyCode;
51 : : class KeyEvent;
52 : : class MenuFloatingWindow;
53 : : class Window;
54 : : class SalMenu;
55 : : struct SystemMenuData;
56 : :
57 : : namespace com {
58 : : namespace sun {
59 : : namespace star {
60 : : namespace accessibility {
61 : : class XAccessible;
62 : : }}}}
63 : :
64 : : namespace vcl { struct MenuLayoutData; }
65 : :
66 : : // --------------
67 : : // - Menu-Types -
68 : : // --------------
69 : :
70 : : #define MENU_APPEND ((sal_uInt16)0xFFFF)
71 : : #define MENU_ITEM_NOTFOUND ((sal_uInt16)0xFFFF)
72 : :
73 : : #define POPUPMENU_EXECUTE_DOWN ((sal_uInt16)0x0001)
74 : : #define POPUPMENU_EXECUTE_UP ((sal_uInt16)0x0002)
75 : : #define POPUPMENU_EXECUTE_LEFT ((sal_uInt16)0x0004)
76 : : #define POPUPMENU_EXECUTE_RIGHT ((sal_uInt16)0x0008)
77 : :
78 : : #define POPUPMENU_NOMOUSEUPCLOSE ((sal_uInt16)0x0010)
79 : :
80 : : // By changes you must also change: rsc/vclrsc.hxx
81 : : enum MenuItemType { MENUITEM_DONTKNOW, MENUITEM_STRING, MENUITEM_IMAGE,
82 : : MENUITEM_STRINGIMAGE, MENUITEM_SEPARATOR };
83 : :
84 : : // By changes you must also change: rsc/vclrsc.hxx
85 : : typedef sal_uInt16 MenuItemBits;
86 : : #define MIB_CHECKABLE ((MenuItemBits)0x0001)
87 : : #define MIB_RADIOCHECK ((MenuItemBits)0x0002)
88 : : #define MIB_AUTOCHECK ((MenuItemBits)0x0004)
89 : : #define MIB_ABOUT ((MenuItemBits)0x0008)
90 : : #define MIB_HELP ((MenuItemBits)0x0010)
91 : : #define MIB_POPUPSELECT ((MenuItemBits)0x0020)
92 : : // not in rsc/vclsrc.hxx because only a prelimitary solution
93 : : #define MIB_NOSELECT ((MenuItemBits)0x0040)
94 : : #define MIB_ICON ((MenuItemBits)0x0080)
95 : : #define MIB_TEXT ((MenuItemBits)0x0100)
96 : :
97 : : #define MENU_FLAG_NOAUTOMNEMONICS 0x0001
98 : : #define MENU_FLAG_HIDEDISABLEDENTRIES 0x0002
99 : :
100 : : // overrides default hiding of disabled entries in popup menus
101 : : #define MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES 0x0004
102 : :
103 : : struct ImplMenuDelData
104 : : {
105 : : ImplMenuDelData* mpNext;
106 : : const Menu* mpMenu;
107 : :
108 : : ImplMenuDelData( const Menu* pMenu );
109 : : ~ImplMenuDelData();
110 : :
111 : 1722080 : bool isDeleted() const { return mpMenu == 0; }
112 : : };
113 : :
114 : : // --------
115 : : // - Menu -
116 : : // --------
117 : :
118 : 0 : struct MenuLogo
119 : : {
120 : : BitmapEx aBitmap;
121 : : Color aStartColor;
122 : : Color aEndColor;
123 : : };
124 : :
125 : : class VCL_DLLPUBLIC Menu : public Resource
126 : : {
127 : : friend class MenuBar;
128 : : friend class MenuBarWindow;
129 : : friend class MenuFloatingWindow;
130 : : friend class PopupMenu;
131 : : friend class SystemWindow;
132 : : friend struct ImplMenuDelData;
133 : : private:
134 : : ImplMenuDelData* mpFirstDel;
135 : : MenuItemList* pItemList; // Liste mit den MenuItems
136 : : MenuLogo* pLogo;
137 : : Menu* pStartedFrom;
138 : : Window* pWindow;
139 : :
140 : : Link aActivateHdl; // Active-Handler
141 : : Link aDeactivateHdl; // Deactivate-Handler
142 : : Link aHighlightHdl; // Highlight-Handler
143 : : Link aSelectHdl; // Highlight-Handler
144 : :
145 : : VclEventListeners maEventListeners;
146 : : VclEventListeners maChildEventListeners;
147 : :
148 : : XubString aTitleText; // PopupMenu text
149 : :
150 : : sal_uLong nEventId;
151 : : sal_uInt16 mnHighlightedItemPos; // for native menus: keeps track of the highlighted item
152 : : sal_uInt16 nMenuFlags;
153 : : sal_uInt16 nDefaultItem; // Id of default item
154 : : sal_uInt16 nSelectedId;
155 : :
156 : : // for output:
157 : : sal_uInt16 nImgOrChkPos;
158 : : sal_uInt16 nTextPos;
159 : :
160 : : sal_Bool bIsMenuBar : 1, // Is this a menubar?
161 : : bCanceled : 1, // Terminated during a callback
162 : : bInCallback : 1, // In Activate/Deactivate
163 : : bKilled : 1; // Killed...
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, void* );
187 : :
188 : : SAL_DLLPRIVATE void ImplFillLayoutData() const;
189 : 521194 : 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 in rCheckHeight and rRadioHeight
194 : : // return value is maximum width and height of checkboxes and radiobuttons
195 : : SAL_DLLPRIVATE Size ImplGetNativeCheckAndRadioSize( Window*, long& rCheckHeight, long& rRadioHeight ) const;
196 : :
197 : : // returns native submenu arrow size and spacing from right border
198 : : // return value is whether it's supported natively
199 : : SAL_DLLPRIVATE sal_Bool ImplGetNativeSubmenuArrowSize( Window* pWin, Size& rArrowSize, long& rArrowSpacing ) const;
200 : :
201 : : SAL_DLLPRIVATE void ImplAddDel( ImplMenuDelData &rDel );
202 : : SAL_DLLPRIVATE void ImplRemoveDel( ImplMenuDelData &rDel );
203 : : public:
204 : : SAL_DLLPRIVATE void ImplKillLayoutData() const;
205 : : SAL_DLLPRIVATE Menu* ImplGetStartedFrom() const { return pStartedFrom; }
206 : :
207 : : Menu();
208 : : Menu( sal_Bool bMenuBar );
209 : 384675 : SAL_DLLPRIVATE Window* ImplGetWindow() const { return pWindow; }
210 : : #if defined(QUARTZ)
211 : : // ImplSelectWithStart() is used in vcl/aqua/source/window/salnsmenu.mm
212 : : SAL_DLLPRIVATE void ImplSelectWithStart( Menu* pStartMenu = NULL );
213 : : #endif
214 : : public:
215 : : virtual ~Menu();
216 : :
217 : : virtual void Activate();
218 : : virtual void Deactivate();
219 : : virtual void Highlight();
220 : : virtual void Select();
221 : : virtual void RequestHelp( const HelpEvent& rHEvt );
222 : :
223 : : void InsertItem( sal_uInt16 nItemId, const XubString& rStr,
224 : : MenuItemBits nItemBits = 0,
225 : : sal_uInt16 nPos = MENU_APPEND );
226 : : void InsertItem( sal_uInt16 nItemId, const Image& rImage,
227 : : MenuItemBits nItemBits = 0,
228 : : sal_uInt16 nPos = MENU_APPEND );
229 : : void InsertItem( sal_uInt16 nItemId,
230 : : const XubString& rString, const Image& rImage,
231 : : MenuItemBits nItemBits = 0,
232 : : sal_uInt16 nPos = MENU_APPEND );
233 : : void InsertItem( const ResId& rResId, sal_uInt16 nPos = MENU_APPEND );
234 : : void InsertSeparator( sal_uInt16 nPos = MENU_APPEND );
235 : : void RemoveItem( sal_uInt16 nPos );
236 : : void CopyItem( const Menu& rMenu, sal_uInt16 nPos,
237 : : sal_uInt16 nNewPos = MENU_APPEND );
238 : : void Clear();
239 : :
240 : : void CreateAutoMnemonics();
241 : :
242 : 36 : void SetMenuFlags( sal_uInt16 nFlags ) { nMenuFlags = nFlags; }
243 : 38 : sal_uInt16 GetMenuFlags() const { return nMenuFlags; }
244 : :
245 : : sal_uInt16 GetItemCount() const;
246 : : sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
247 : : sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const;
248 : : MenuItemType GetItemType( sal_uInt16 nPos ) const;
249 : : sal_uInt16 GetCurItemId() const;
250 : :
251 : 0 : void SetDefaultItem( sal_uInt16 nItemId ) { nDefaultItem = nItemId; }
252 : 0 : 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 );
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 );
276 : 0 : void HideItem( sal_uInt16 nItemId ) { ShowItem( nItemId, sal_False ); }
277 : :
278 : : sal_Bool IsItemPosVisible( sal_uInt16 nItemPos ) const;
279 : : sal_Bool IsMenuVisible() const;
280 : 452132 : sal_Bool IsMenuBar() const { return bIsMenuBar; }
281 : :
282 : : void RemoveDisabledEntries( sal_Bool bCheckPopups = sal_True, sal_Bool bRemoveEmptyPopups = sal_False );
283 : : sal_Bool HasValidEntries( sal_Bool bCheckPopups = sal_True );
284 : :
285 : : void SetItemText( sal_uInt16 nItemId, const XubString& rStr );
286 : : XubString GetItemText( sal_uInt16 nItemId ) const;
287 : :
288 : : void SetItemImage( sal_uInt16 nItemId, const Image& rImage );
289 : : Image GetItemImage( sal_uInt16 nItemId ) const;
290 : : void SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 );
291 : : long GetItemImageAngle( sal_uInt16 nItemId ) const;
292 : : void SetItemImageMirrorMode( sal_uInt16 nItemId, sal_Bool bMirror );
293 : : sal_Bool GetItemImageMirrorMode( sal_uInt16 ) const;
294 : :
295 : : void SetItemCommand( sal_uInt16 nItemId, const XubString& rCommand );
296 : : const XubString& GetItemCommand( sal_uInt16 nItemId ) const;
297 : :
298 : : void SetHelpText( sal_uInt16 nItemId, const XubString& rString );
299 : : const XubString& GetHelpText( sal_uInt16 nItemId ) const;
300 : :
301 : : void SetTipHelpText( sal_uInt16 nItemId, const XubString& rString );
302 : : const XubString& GetTipHelpText( sal_uInt16 nItemId ) const;
303 : :
304 : : void SetHelpCommand( sal_uInt16 nItemId, const XubString& rString );
305 : : const XubString& GetHelpCommand( sal_uInt16 nItemId ) const;
306 : :
307 : : void SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId );
308 : : rtl::OString GetHelpId( sal_uInt16 nItemId ) const;
309 : :
310 : 43401 : void SetActivateHdl( const Link& rLink ) { aActivateHdl = rLink; }
311 : : const Link& GetActivateHdl() const { return aActivateHdl; }
312 : :
313 : 47122 : void SetDeactivateHdl( const Link& rLink ) { aDeactivateHdl = rLink; }
314 : : const Link& GetDeactivateHdl() const { return aDeactivateHdl; }
315 : :
316 : 43401 : void SetHighlightHdl( const Link& rLink ) { aHighlightHdl = rLink; }
317 : : const Link& GetHighlightHdl() const { return aHighlightHdl; }
318 : :
319 : 47110 : void SetSelectHdl( const Link& rLink ) { aSelectHdl = rLink; }
320 : : const Link& GetSelectHdl() const { return aSelectHdl; }
321 : :
322 : : void SetLogo( const MenuLogo& rLogo );
323 : : void SetLogo();
324 [ # # ]: 0 : sal_Bool HasLogo() const { return pLogo ? sal_True : sal_False; }
325 : : MenuLogo GetLogo() const;
326 : :
327 : : void AddEventListener( const Link& rEventListener );
328 : : void RemoveEventListener( const Link& rEventListener );
329 : : //void AddChildEventListener( const Link& rEventListener );
330 : : //void RemoveChildEventListener( const Link& rEventListener );
331 : :
332 : : Menu& operator =( const Menu& rMenu );
333 : :
334 : : // Fuer Menu-'Funktionen'
335 : 70 : MenuItemList* GetItemList() const { return pItemList; }
336 : :
337 : : // returns the system's menu handle if native menus are supported
338 : : // pData must point to a SystemMenuData structure
339 : : sal_Bool GetSystemMenuData( SystemMenuData* pData ) const;
340 : :
341 : : // accessibility helpers
342 : :
343 : : // returns the bounding box for the character at index nIndex
344 : : // where nIndex is relative to the starting index of the item
345 : : // with id nItemId (in coordinates of the displaying window)
346 : : Rectangle GetCharacterBounds( sal_uInt16 nItemId, long nIndex ) const;
347 : : // -1 is returned if no character is at that point
348 : : // if an index is found the corresponding item id is filled in (else 0)
349 : : long GetIndexForPoint( const Point& rPoint, sal_uInt16& rItemID ) const;
350 : : // returns the bounding rectangle for an item at pos nItemPos
351 : : Rectangle GetBoundingRectangle( sal_uInt16 nItemPos ) const;
352 : :
353 : : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetAccessible();
354 : : void SetAccessible( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rxAccessible );
355 : :
356 : : // gets the activation key of the specified item
357 : : KeyEvent GetActivationKey( sal_uInt16 nItemId ) const;
358 : :
359 : 7495 : Window* GetWindow() const { return pWindow; }
360 : :
361 : : void SetAccessibleName( sal_uInt16 nItemId, const XubString& rStr );
362 : : XubString GetAccessibleName( sal_uInt16 nItemId ) const;
363 : :
364 : : // returns whether the item a position nItemPos is highlighted or not.
365 : : bool IsHighlighted( sal_uInt16 nItemPos ) const;
366 : :
367 : : void HighlightItem( sal_uInt16 nItemPos );
368 : 0 : void DeHighlight() { HighlightItem( 0xFFFF ); } // MENUITEMPOS_INVALID
369 : : };
370 : :
371 : : // -----------
372 : : // - MenuBar -
373 : : // -----------
374 : :
375 : : class VCL_DLLPUBLIC MenuBar : public Menu
376 : : {
377 : : Link maCloserHdl;
378 : : Link maFloatHdl;
379 : : Link maHideHdl;
380 : : sal_Bool mbCloserVisible;
381 : : sal_Bool mbFloatBtnVisible;
382 : : sal_Bool mbHideBtnVisible;
383 : : sal_Bool mbDisplayable;
384 : :
385 : : friend class Application;
386 : : friend class Menu;
387 : : friend class MenuBarWindow;
388 : : friend class MenuFloatingWindow;
389 : : friend class SystemWindow;
390 : :
391 : : SAL_DLLPRIVATE static Window* ImplCreate( Window* pParent, Window* pWindow, MenuBar* pMenu );
392 : : SAL_DLLPRIVATE static void ImplDestroy( MenuBar* pMenu, sal_Bool bDelete );
393 : : SAL_DLLPRIVATE sal_Bool ImplHandleKeyEvent( const KeyEvent& rKEvent, sal_Bool bFromMenu = sal_True );
394 : :
395 : : public:
396 : : MenuBar();
397 : : MenuBar( const MenuBar& rMenu );
398 : : ~MenuBar();
399 : :
400 : : MenuBar& operator =( const MenuBar& rMenu );
401 : :
402 : : void ShowCloser( sal_Bool bShow = sal_True );
403 : 3422 : sal_Bool HasCloser() const { return mbCloserVisible; }
404 : 1711 : sal_Bool HasFloatButton() const { return mbFloatBtnVisible; }
405 : 1711 : sal_Bool HasHideButton() const { return mbHideBtnVisible; }
406 : : void ShowButtons( sal_Bool bClose, sal_Bool bFloat, sal_Bool bHide );
407 : :
408 : : void SelectEntry( sal_uInt16 nId );
409 : : sal_Bool HandleMenuActivateEvent( Menu *pMenu ) const;
410 : : sal_Bool HandleMenuDeActivateEvent( Menu *pMenu ) const;
411 : : sal_Bool HandleMenuHighlightEvent( Menu *pMenu, sal_uInt16 nEventId ) const;
412 : : sal_Bool HandleMenuCommandEvent( Menu *pMenu, sal_uInt16 nEventId ) const;
413 : : sal_Bool HandleMenuButtonEvent( Menu *pMenu, sal_uInt16 nEventId ) const;
414 : :
415 : 3091 : void SetCloserHdl( const Link& rLink ) { maCloserHdl = rLink; }
416 : 0 : const Link& GetCloserHdl() const { return maCloserHdl; }
417 : : void SetFloatButtonClickHdl( const Link& rLink ) { maFloatHdl = rLink; }
418 : 0 : const Link& GetFloatButtonClickHdl() const { return maFloatHdl; }
419 : : void SetHideButtonClickHdl( const Link& rLink ) { maHideHdl = rLink; }
420 : 0 : const Link& GetHideButtonClickHdl() const { return maHideHdl; }
421 : :
422 : : // - by default a menubar is displayable
423 : : // - if a menubar is not displayable, its MenuBarWindow will never be shown
424 : : // and it will be hidden if it was visible before
425 : : // - note: if a menubar is diplayable, this does not necessarily mean that it is currently visible
426 : : void SetDisplayable( sal_Bool bDisplayable );
427 : 4637 : sal_Bool IsDisplayable() const { return mbDisplayable; }
428 : :
429 : : struct MenuBarButtonCallbackArg
430 : : {
431 : : sal_uInt16 nId; // Id of the button
432 : : bool bHighlight; // highlight on/off
433 : : MenuBar* pMenuBar; // menubar the button belongs to
434 : : };
435 : : // add an arbitrary button to the menubar (will appear next to closer)
436 : : // passed link will be call with a MenuBarButtonCallbackArg on press
437 : : // passed string will be set as tooltip
438 : : sal_uInt16 AddMenuBarButton( const Image&, const Link&, const String&, sal_uInt16 nPos = 0 );
439 : : // set the highlight link for additional button with ID nId
440 : : // highlight link will be called with a MenuBarButtonHighlightArg
441 : : // the bHighlight member of that struct shall contain the new state
442 : : void SetMenuBarButtonHighlightHdl( sal_uInt16 nId, const Link& );
443 : : // returns the rectangle occupied by the additional button named nId
444 : : // coordinates are relative to the systemwindiow the menubar is attached to
445 : : // if the menubar is unattached an empty rectangle is returned
446 : : Rectangle GetMenuBarButtonRectPixel( sal_uInt16 nId );
447 : : void RemoveMenuBarButton( sal_uInt16 nId );
448 : : };
449 : :
450 : 0 : inline MenuBar& MenuBar::operator =( const MenuBar& rMenu )
451 : : {
452 : 0 : Menu::operator =( rMenu );
453 : 0 : return *this;
454 : : }
455 : :
456 : :
457 : : // -------------
458 : : // - PopupMenu -
459 : : // -------------
460 : :
461 : : class VCL_DLLPUBLIC PopupMenu : public Menu
462 : : {
463 : : friend class Menu;
464 : : friend class MenuFloatingWindow;
465 : : friend class MenuBarWindow;
466 : : friend struct MenuItemData;
467 : :
468 : : private:
469 : : Menu** pRefAutoSubMenu; // keeps track if a pointer to this Menu is stored in the MenuItemData
470 : :
471 : 64 : SAL_DLLPRIVATE MenuFloatingWindow* ImplGetFloatingWindow() const { return (MenuFloatingWindow*)Menu::ImplGetWindow(); }
472 : :
473 : : protected:
474 : : SAL_DLLPRIVATE sal_uInt16 ImplExecute( Window* pWindow, const Rectangle& rRect, sal_uLong nPopupFlags, Menu* pStaredFrom, sal_Bool bPreSelectFirst );
475 : : SAL_DLLPRIVATE long ImplCalcHeight( sal_uInt16 nEntries ) const;
476 : : SAL_DLLPRIVATE sal_uInt16 ImplCalcVisEntries( long nMaxHeight, sal_uInt16 nStartEntry = 0, sal_uInt16* pLastVisible = NULL ) const;
477 : :
478 : : public:
479 : : PopupMenu();
480 : : PopupMenu( const PopupMenu& rMenu );
481 : : PopupMenu( const ResId& rResId );
482 : : ~PopupMenu();
483 : :
484 : : void SetText( const XubString& rTitle ) { aTitleText = rTitle; }
485 : : const XubString& GetText() const { return aTitleText; }
486 : :
487 : : sal_uInt16 Execute( Window* pWindow, const Point& rPopupPos );
488 : : sal_uInt16 Execute( Window* pWindow, const Rectangle& rRect, sal_uInt16 nFlags = 0 );
489 : :
490 : : // Fuer das TestTool
491 : : void EndExecute( sal_uInt16 nSelect = 0 );
492 : : void SelectEntry( sal_uInt16 nId );
493 : : void SetSelectedEntry( sal_uInt16 nId ); // for use by native submenu only
494 : :
495 : : static sal_Bool IsInExecute();
496 : : static PopupMenu* GetActivePopupMenu();
497 : :
498 : : PopupMenu& operator =( const PopupMenu& rMenu );
499 : : };
500 : :
501 : 0 : inline PopupMenu& PopupMenu::operator =( const PopupMenu& rMenu )
502 : : {
503 : 0 : Menu::operator =( rMenu );
504 : 0 : return *this;
505 : : }
506 : :
507 : : #endif // _SV_MENU_HXX
508 : :
509 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|