summaryrefslogtreecommitdiff
path: root/vcl/inc/vcl/menu.hxx
blob: 908f3e30319c01262c3833f91dbcb8c4e6346600 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _SV_MENU_HXX
#define _SV_MENU_HXX

#include <vcl/sv.h>
#include <vcl/dllapi.h>
#include <tools/rc.hxx>
#include <tools/resid.hxx>
#include <vcl/bitmapex.hxx>
#include <tools/color.hxx>
#include <vcl/vclevent.hxx>
#include <com/sun/star/uno/Reference.hxx>

struct MenuItemData;
class Point;
class Size;
class Rectangle;
class Menu;
class MenuItemList;
class HelpEvent;
class Image;
class PopupMenu;
class KeyCode;
class KeyEvent;
class AppBarWindow;
class MenuFloatingWindow;
class Window;
class SalMenu;
struct SystemMenuData;

namespace com {
namespace sun {
namespace star {
namespace accessibility {
    class XAccessible;
}}}}

namespace vcl { struct MenuLayoutData; }

// --------------
// - Menu-Types -
// --------------

#define MENU_APPEND             ((USHORT)0xFFFF)
#define MENU_ITEM_NOTFOUND      ((USHORT)0xFFFF)

#define POPUPMENU_EXECUTE_DOWN  ((USHORT)0x0001)
#define POPUPMENU_EXECUTE_UP    ((USHORT)0x0002)
#define POPUPMENU_EXECUTE_LEFT  ((USHORT)0x0004)
#define POPUPMENU_EXECUTE_RIGHT ((USHORT)0x0008)

#define POPUPMENU_NOMOUSEUPCLOSE ((USHORT)0x0010)

// By changes you must also change: rsc/vclrsc.hxx
enum MenuItemType { MENUITEM_DONTKNOW, MENUITEM_STRING, MENUITEM_IMAGE,
                    MENUITEM_STRINGIMAGE, MENUITEM_SEPARATOR };

// By changes you must also change: rsc/vclrsc.hxx
typedef USHORT MenuItemBits;
#define MIB_CHECKABLE           ((MenuItemBits)0x0001)
#define MIB_RADIOCHECK          ((MenuItemBits)0x0002)
#define MIB_AUTOCHECK           ((MenuItemBits)0x0004)
#define MIB_ABOUT               ((MenuItemBits)0x0008)
#define MIB_HELP                ((MenuItemBits)0x0010)
#define MIB_POPUPSELECT         ((MenuItemBits)0x0020)
// not in rsc/vclsrc.hxx because only a prelimitary solution
#define MIB_NOSELECT            ((MenuItemBits)0x0040)
#define MIB_ICON            ((MenuItemBits)0x0080)
#define MIB_TEXT            ((MenuItemBits)0x0100)

#define MENU_FLAG_NOAUTOMNEMONICS       0x0001
#define MENU_FLAG_HIDEDISABLEDENTRIES   0x0002

// overrides default hiding of disabled entries in popup menus
#define MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES 0x0004

// forces images & toggle visibility for toolbar config popup
#define MENU_FLAG_SHOWCHECKIMAGES     0x0008

struct ImplMenuDelData
{
    ImplMenuDelData* mpNext;
    const Menu* mpMenu;

    ImplMenuDelData( const Menu* pMenu );
    ~ImplMenuDelData();

    bool isDeleted() const { return mpMenu == 0; }
};

// --------
// - Menu -
// --------

struct MenuLogo
{
    BitmapEx    aBitmap;
    Color       aStartColor;
    Color       aEndColor;
};

class VCL_DLLPUBLIC Menu : public Resource
{
    friend class MenuBar;
    friend class MenuBarWindow;
    friend class MenuFloatingWindow;
    friend class PopupMenu;
    friend class SystemWindow;
    friend struct ImplMenuDelData;
private:
    ImplMenuDelData*    mpFirstDel;
    MenuItemList*       pItemList;          // Liste mit den MenuItems
    MenuLogo*           pLogo;
    Menu*               pStartedFrom;
    Window*             pWindow;

    Link                aActivateHdl;       // Active-Handler
    Link                aDeactivateHdl;     // Deactivate-Handler
    Link                aHighlightHdl;      // Highlight-Handler
    Link                aSelectHdl;         // Highlight-Handler

    VclEventListeners   maEventListeners;
    VclEventListeners   maChildEventListeners;

    XubString           aTitleText;         // PopupMenu-Text

    ULONG               nEventId;
    USHORT              mnHighlightedItemPos; // for native menues: keeps track of the highlighted item
    USHORT              nMenuFlags;
    USHORT              nDefaultItem;       // Id vom Default-Item
    USHORT              nSelectedId;

    // Fuer Ausgabe:
    USHORT              nCheckPos;
    USHORT              nImagePos;
    USHORT              nTextPos;

    BOOL                bIsMenuBar  : 1,        // Handelt es sich um den MenuBar
                        bCanceled   : 1,        // Waehrend eines Callbacks abgebrochen
                        bInCallback : 1,        // In Activate/Deactivate
                        bKilled     : 1;        // Gekillt...

    ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxAccessible;
    mutable vcl::MenuLayoutData* mpLayoutData;
    SalMenu*            mpSalMenu;

protected:
    SAL_DLLPRIVATE void             ImplInit();
    SAL_DLLPRIVATE void             ImplLoadRes( const ResId& rResId );
    SAL_DLLPRIVATE Menu*            ImplGetStartMenu();
    SAL_DLLPRIVATE Menu*            ImplFindSelectMenu();
    SAL_DLLPRIVATE Menu*            ImplFindMenu( USHORT nId );
    SAL_DLLPRIVATE Size             ImplCalcSize( Window* pWin );
    SAL_DLLPRIVATE BOOL             ImplIsVisible( USHORT nPos ) const;
    SAL_DLLPRIVATE BOOL             ImplIsSelectable( USHORT nPos ) const;
    SAL_DLLPRIVATE USHORT           ImplGetVisibleItemCount() const;
    SAL_DLLPRIVATE USHORT           ImplGetFirstVisible() const;
    SAL_DLLPRIVATE USHORT           ImplGetPrevVisible( USHORT nPos ) const;
    SAL_DLLPRIVATE USHORT           ImplGetNextVisible( USHORT nPos ) const;
    SAL_DLLPRIVATE void             ImplPaint( Window* pWin, USHORT nBorder, long nOffY = 0, MenuItemData* pThisDataOnly = 0, BOOL bHighlighted = FALSE, bool bLayout = false ) const;
    SAL_DLLPRIVATE void             ImplSelect();
    SAL_DLLPRIVATE void             ImplCallHighlight( USHORT nHighlightItem );
    SAL_DLLPRIVATE void             ImplCallEventListeners( ULONG nEvent, USHORT nPos );
    DECL_DLLPRIVATE_LINK(           ImplCallSelect, Menu* );

    SAL_DLLPRIVATE void             ImplFillLayoutData() const;
    SAL_DLLPRIVATE SalMenu*         ImplGetSalMenu() { return mpSalMenu; }
    SAL_DLLPRIVATE void             ImplSetSalMenu( SalMenu *pMenu );
    SAL_DLLPRIVATE const XubString& ImplGetHelpText( USHORT nItemId ) const;

    // returns native check and option menu symbol height;
    // return value is Max( rCheckHeight, rRadioHeight )
    SAL_DLLPRIVATE long             ImplGetNativeCheckAndRadioSize( Window*, long& rCheckHeight, long& rRadioHeight, long &rMaxWidth ) const;

    SAL_DLLPRIVATE void                ImplAddDel( ImplMenuDelData &rDel );
    SAL_DLLPRIVATE void                ImplRemoveDel( ImplMenuDelData &rDel );
public:
    SAL_DLLPRIVATE void             ImplKillLayoutData() const;
    SAL_DLLPRIVATE Menu*            ImplGetStartedFrom() const;

                            Menu();
                            Menu( BOOL bMenuBar );
    SAL_DLLPRIVATE Window*  ImplGetWindow() const { return pWindow; }


    SAL_DLLPRIVATE void ImplSelectWithStart( Menu* pStartMenu = NULL );
public:
    virtual             ~Menu();

    virtual void        Activate();
    virtual void        Deactivate();
    virtual void        Highlight();
    virtual void        Select();
    virtual void        RequestHelp( const HelpEvent& rHEvt );

    void                InsertItem( USHORT nItemId, const XubString& rStr,
                                    MenuItemBits nItemBits = 0,
                                    USHORT nPos = MENU_APPEND );
    void                InsertItem( USHORT nItemId, const Image& rImage,
                                    MenuItemBits nItemBits = 0,
                                    USHORT nPos = MENU_APPEND );
    void                InsertItem( USHORT nItemId,
                                    const XubString& rString, const Image& rImage,
                                    MenuItemBits nItemBits = 0,
                                    USHORT nPos = MENU_APPEND );
    void                InsertItem( const ResId& rResId, USHORT nPos = MENU_APPEND );
    void                InsertSeparator( USHORT nPos = MENU_APPEND );
    void                RemoveItem( USHORT nPos );
    void                CopyItem( const Menu& rMenu, USHORT nPos,
                                  USHORT nNewPos = MENU_APPEND );
    void                Clear();

    void                CreateAutoMnemonics();

    void                SetMenuFlags( USHORT nFlags ) { nMenuFlags = nFlags; }
    USHORT              GetMenuFlags() const { return nMenuFlags; }

    USHORT              GetItemCount() const;
    USHORT              GetItemId( USHORT nPos ) const;
    USHORT              GetItemPos( USHORT nItemId ) const;
    MenuItemType        GetItemType( USHORT nPos ) const;
    USHORT              GetCurItemId() const;

    void                SetDefaultItem( USHORT nItemId )    { nDefaultItem = nItemId; }
    USHORT              GetDefaultItem() const              { return nDefaultItem; }

    void                SetItemBits( USHORT nItemId, MenuItemBits nBits );
    MenuItemBits        GetItemBits( USHORT nItemId ) const;

    void                SetUserValue( USHORT nItemId, ULONG nValue );
    ULONG               GetUserValue( USHORT nItemId ) const;

    void                SetPopupMenu( USHORT nItemId, PopupMenu* pMenu );
    PopupMenu*          GetPopupMenu( USHORT nItemId ) const;

    void                SetAccelKey( USHORT nItemId, const KeyCode& rKeyCode );
    KeyCode             GetAccelKey( USHORT nItemId ) const;

    void                CheckItem( USHORT nItemId, BOOL bCheck = TRUE );
    BOOL                IsItemChecked( USHORT nItemId ) const;

    void                SelectItem( USHORT nItemId );
    void                DeSelect() { SelectItem( 0xFFFF ); } // MENUITEMPOS_INVALID

    void                EnableItem( USHORT nItemId, BOOL bEnable = TRUE );
    BOOL                IsItemEnabled( USHORT nItemId ) const;

    void                ShowItem( USHORT nItemId, BOOL bVisible = TRUE );
    void                HideItem( USHORT nItemId ) { ShowItem( nItemId, FALSE ); }

    BOOL                IsItemVisible( USHORT nItemId ) const;
    BOOL                IsItemPosVisible( USHORT nItemPos ) const;
    BOOL                IsMenuVisible() const;
    BOOL                IsMenuBar() const { return bIsMenuBar; }

    void                RemoveDisabledEntries( BOOL bCheckPopups = TRUE, BOOL bRemoveEmptyPopups = FALSE );
    BOOL                HasValidEntries( BOOL bCheckPopups = TRUE );

    void                SetItemText( USHORT nItemId, const XubString& rStr );
    XubString           GetItemText( USHORT nItemId ) const;

    void                SetItemImage( USHORT nItemId, const Image& rImage );
    Image               GetItemImage( USHORT nItemId ) const;
    void                SetItemImageAngle( USHORT nItemId, long nAngle10 );
    long                GetItemImageAngle( USHORT nItemId ) const;
    void                SetItemImageMirrorMode( USHORT nItemId, BOOL bMirror );
    BOOL                GetItemImageMirrorMode( USHORT ) const;

    void                SetItemCommand( USHORT nItemId, const XubString& rCommand );
    const XubString&    GetItemCommand( USHORT nItemId ) const;

    void                SetHelpText( USHORT nItemId, const XubString& rString );
    const XubString&    GetHelpText( USHORT nItemId ) const;

    void                SetTipHelpText( USHORT nItemId, const XubString& rString );
    const XubString&    GetTipHelpText( USHORT nItemId ) const;

    void                SetHelpCommand( USHORT nItemId, const XubString& rString );
    const XubString&    GetHelpCommand( USHORT nItemId ) const;

    void                SetHelpId( USHORT nItemId, ULONG nHelpId );
    ULONG               GetHelpId( USHORT nItemId ) const;

    void                SetActivateHdl( const Link& rLink )     { aActivateHdl = rLink; }
    const Link&         GetActivateHdl() const                  { return aActivateHdl; }

    void                SetDeactivateHdl( const Link& rLink )   { aDeactivateHdl = rLink; }
    const Link&         GetDeactivateHdl() const                { return aDeactivateHdl; }

    void                SetHighlightHdl( const Link& rLink )    { aHighlightHdl = rLink; }
    const Link&         GetHighlightHdl() const                 { return aHighlightHdl; }

    void                SetSelectHdl( const Link& rLink )       { aSelectHdl = rLink; }
    const Link&         GetSelectHdl() const                    { return aSelectHdl; }

    void                SetLogo( const MenuLogo& rLogo );
    void                SetLogo();
    BOOL                HasLogo() const { return pLogo ? TRUE : FALSE; }
    MenuLogo            GetLogo() const;

    void                AddEventListener( const Link& rEventListener );
    void                RemoveEventListener( const Link& rEventListener );
    //void                AddChildEventListener( const Link& rEventListener );
    //void                RemoveChildEventListener( const Link& rEventListener );

    Menu&               operator =( const Menu& rMenu );

    // Fuer Menu-'Funktionen'
    MenuItemList*       GetItemList() const                     { return pItemList; }

    // returns the system's menu handle if native menues are supported
    // pData must point to a SystemMenuData structure
    BOOL                GetSystemMenuData( SystemMenuData* pData ) const;

    // accessibility helpers

    // gets the displayed text
    String GetDisplayText() const;
    // returns the bounding box for the character at index nIndex
    // where nIndex is relative to the starting index of the item
    // with id nItemId (in coordinates of the displaying window)
    Rectangle GetCharacterBounds( USHORT nItemId, long nIndex ) const;
    // -1 is returned if no character is at that point
    // if an index is found the corresponding item id is filled in (else 0)
    long GetIndexForPoint( const Point& rPoint, USHORT& rItemID ) const;
    // returns the number of lines in the result of GetDisplayText()
    long GetLineCount() const;
    // returns the interval [start,end] of line nLine
    // returns [-1,-1] for an invalid line
    Pair GetLineStartEnd( long nLine ) const;
    // like GetLineStartEnd but first finds the line number for the item
    Pair GetItemStartEnd( USHORT nItemId ) const;
    // returns the item id for line nLine or 0 if nLine is invalid
    USHORT GetDisplayItemId( long nLine ) const;
    // returns the bounding rectangle for an item at pos nItemPos
    Rectangle GetBoundingRectangle( USHORT nItemPos ) const;
    BOOL ConvertPoint( Point& rPoint, Window* pReferenceWindow ) const;

    ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetAccessible();
    void SetAccessible( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rxAccessible );

    // gets the activation key of the specified item
    KeyEvent GetActivationKey( USHORT nItemId ) const;

    Window*             GetWindow() const { return pWindow; }

    void                SetAccessibleName( USHORT nItemId, const XubString& rStr );
    XubString           GetAccessibleName( USHORT nItemId ) const;

    void                SetAccessibleDescription( USHORT nItemId, const XubString& rStr );
    XubString           GetAccessibleDescription( USHORT nItemId ) const;

    // returns whether the item a position nItemPos is highlighted or not.
    bool  IsHighlighted( USHORT nItemPos ) const;

    void                HighlightItem( USHORT nItemPos );
    void                DeHighlight() { HighlightItem( 0xFFFF ); } // MENUITEMPOS_INVALID


    void doLazyDelete();
};

// -----------
// - MenuBar -
// -----------

class VCL_DLLPUBLIC MenuBar : public Menu
{
    Link                maCloserHdl;
    Link                maFloatHdl;
    Link                maHideHdl;
    BOOL                mbCloserVisible;
    BOOL                mbFloatBtnVisible;
    BOOL                mbHideBtnVisible;
    BOOL                mbDisplayable;

//#if 0 // _SOLAR__PRIVATE
    friend class Application;
    friend class Menu;
    friend class MenuBarWindow;
    friend class MenuFloatingWindow;
    friend class SystemWindow;

    SAL_DLLPRIVATE static Window*   ImplCreate( Window* pParent, Window* pWindow, MenuBar* pMenu );
    SAL_DLLPRIVATE static void      ImplDestroy( MenuBar* pMenu, BOOL bDelete );
    SAL_DLLPRIVATE BOOL             ImplHandleKeyEvent( const KeyEvent& rKEvent, BOOL bFromMenu = TRUE );
//#endif

public:
                        MenuBar();
                        MenuBar( const ResId& rResId );
                        MenuBar( const MenuBar& rMenu );
                        ~MenuBar();

    MenuBar&            operator =( const MenuBar& rMenu );

    void                ShowCloser( BOOL bShow = TRUE );
    BOOL                HasCloser() const { return mbCloserVisible; }
    void                ShowFloatButton( BOOL bShow = TRUE );
    BOOL                HasFloatButton() const { return mbFloatBtnVisible; }
    void                ShowHideButton( BOOL bShow = TRUE );
    BOOL                HasHideButton() const { return mbHideBtnVisible; }
    void                ShowButtons( BOOL bClose, BOOL bFloat, BOOL bHide );

    void                SelectEntry( USHORT nId );
    BOOL                HandleMenuActivateEvent( Menu *pMenu ) const;
    BOOL                HandleMenuDeActivateEvent( Menu *pMenu ) const;
    BOOL                HandleMenuHighlightEvent( Menu *pMenu, USHORT nEventId ) const;
    BOOL                HandleMenuCommandEvent( Menu *pMenu, USHORT nEventId ) const;
    BOOL                HandleMenuButtonEvent( Menu *pMenu, USHORT nEventId ) const;

    void                SetCloserHdl( const Link& rLink )           { maCloserHdl = rLink; }
    const Link&         GetCloserHdl() const                        { return maCloserHdl; }
    void                SetFloatButtonClickHdl( const Link& rLink ) { maFloatHdl = rLink; }
    const Link&         GetFloatButtonClickHdl() const              { return maFloatHdl; }
    void                SetHideButtonClickHdl( const Link& rLink )  { maHideHdl = rLink; }
    const Link&         GetHideButtonClickHdl() const               { return maHideHdl; }

    //  - by default a menubar is displayable
    //  - if a menubar is not displayable, its MenuBarWindow will never be shown
    //    and it will be hidden if it was visible before
    //  - note: if a menubar is diplayable, this does not necessarily mean that it is currently visible
    void                SetDisplayable( BOOL bDisplayable );
    BOOL                IsDisplayable() const                       { return mbDisplayable; }

    struct MenuBarButtonCallbackArg
    {
        USHORT      nId;             // Id of the button
        bool        bHighlight;      // highlight on/off
        MenuBar*    pMenuBar;        // menubar the button belongs to
    };
    // add an arbitrary button to the menubar (will appear next to closer)
    // passed link will be call with a MenuBarButtonCallbackArg on press
    USHORT              AddMenuBarButton( const Image&, const Link&, USHORT nPos = 0 );
    // add an arbitrary button to the menubar (will appear next to closer)
    // passed link will be call with a MenuBarButtonCallbackArg on press
    // passed string will be set as tooltip
    USHORT              AddMenuBarButton( const Image&, const Link&, const String&, USHORT nPos = 0 );
    // set the highlight link for additional button with ID nId
    // highlight link will be called with a MenuBarButtonHighlightArg
    // the bHighlight member of that struct shall contain the new state
    void                SetMenuBarButtonHighlightHdl( USHORT nId, const Link& );
    // returns the rectangle occupied by the additional button named nId
    // coordinates are relative to the systemwindiow the menubar is attached to
    // if the menubar is unattached an empty rectangle is returned
    Rectangle           GetMenuBarButtonRectPixel( USHORT nId );
    void                RemoveMenuBarButton( USHORT nId );
};

inline MenuBar& MenuBar::operator =( const MenuBar& rMenu )
{
    Menu::operator =( rMenu );
    return *this;
}


// -------------
// - PopupMenu -
// -------------

class VCL_DLLPUBLIC PopupMenu : public Menu
{
    friend class Menu;
    friend class MenuFloatingWindow;
    friend class MenuBarWindow;
    friend struct MenuItemData;

private:
    Menu**              pRefAutoSubMenu;    // keeps track if a pointer to this Menu is stored in the MenuItemData

    SAL_DLLPRIVATE MenuFloatingWindow*   ImplGetFloatingWindow() const { return (MenuFloatingWindow*)Menu::ImplGetWindow(); }

protected:
    SAL_DLLPRIVATE USHORT                ImplExecute( Window* pWindow, const Rectangle& rRect, ULONG nPopupFlags, Menu* pStaredFrom, BOOL bPreSelectFirst );
    SAL_DLLPRIVATE long                  ImplCalcHeight( USHORT nEntries ) const;
    SAL_DLLPRIVATE USHORT                ImplCalcVisEntries( long nMaxHeight, USHORT nStartEntry = 0, USHORT* pLastVisible = NULL ) const;

public:
                        PopupMenu();
                        PopupMenu( const PopupMenu& rMenu );
                        PopupMenu( const ResId& rResId );
                        ~PopupMenu();

    void                SetText( const XubString& rTitle )  { aTitleText = rTitle; }
    const XubString&    GetText() const                     { return aTitleText; }

    USHORT              Execute( Window* pWindow, const Point& rPopupPos );
    USHORT              Execute( Window* pWindow, const Rectangle& rRect, USHORT nFlags = 0 );

    // Fuer das TestTool
    void                EndExecute( USHORT nSelect = 0 );
    void                SelectEntry( USHORT nId );
    void                SetSelectedEntry( USHORT nId ); // for use by native submenu only

    static BOOL         IsInExecute();
    static PopupMenu*   GetActivePopupMenu();

    PopupMenu&          operator =( const PopupMenu& rMenu );
};

inline PopupMenu& PopupMenu::operator =( const PopupMenu& rMenu )
{
    Menu::operator =( rMenu );
    return *this;
}

#endif // _SV_MENU_HXX