1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_TOOLKIT_AWT_VCLXMENU_HXX
21 #define INCLUDED_TOOLKIT_AWT_VCLXMENU_HXX
23 #include <config_options.h>
24 #include <toolkit/dllapi.h>
25 #include <toolkit/helper/listenermultiplexer.hxx>
27 #include <com/sun/star/awt/XMenuBar.hpp>
28 #include <com/sun/star/awt/XPopupMenu.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/lang/XTypeProvider.hpp>
32 #include <cppuhelper/weak.hxx>
35 #include <tools/link.hxx>
36 #include <vcl/vclptr.hxx>
45 typedef ::std::vector
<
46 css::uno::Reference
< css::awt::XPopupMenu
>
49 typedef void (*MenuUserDataReleaseFunction
)(void*);
51 class TOOLKIT_DLLPUBLIC VCLXMenu
: public css::awt::XMenuBar
,
52 public css::awt::XPopupMenu
,
53 public css::lang::XServiceInfo
,
54 public css::lang::XTypeProvider
,
55 public ::cppu::OWeakObject
60 MenuListenerMultiplexer maMenuListeners
;
61 PopupMenuRefList maPopupMenuRefs
;
62 sal_Int16 mnDefaultItem
;
66 DECL_DLLPRIVATE_LINK( MenuEventListener
, VclMenuEvent
&, void );
68 void ImplCreateMenu( bool bPopup
);
69 void ImplAddListener();
73 VCLXMenu( Menu
* pMenu
);
74 virtual ~VCLXMenu() override
;
77 Menu
* GetMenu() const { return mpMenu
; }
78 bool IsPopupMenu() const;
79 void setUserValue(sal_uInt16 nItemId
, void* nUserValue
, MenuUserDataReleaseFunction aFunc
);
80 void* getUserValue(sal_uInt16 nItemId
);
82 // css::uno::XInterface
83 css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
84 void SAL_CALL
acquire() noexcept override
{ OWeakObject::acquire(); }
85 void SAL_CALL
release() noexcept override
{ OWeakObject::release(); }
87 // css::lang::XTypeProvider
88 css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
89 css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
92 virtual void SAL_CALL
addMenuListener( const css::uno::Reference
< css::awt::XMenuListener
>& xListener
) override
;
93 virtual void SAL_CALL
removeMenuListener( const css::uno::Reference
< css::awt::XMenuListener
>& xListener
) override
;
94 virtual void SAL_CALL
insertItem( sal_Int16 nItemId
, const OUString
& aText
, sal_Int16 nItemStyle
, sal_Int16 nPos
) override
;
95 virtual void SAL_CALL
removeItem( sal_Int16 nPos
, sal_Int16 nCount
) override
;
96 virtual void SAL_CALL
clear( ) override
;
97 virtual sal_Int16 SAL_CALL
getItemCount( ) override
;
98 virtual sal_Int16 SAL_CALL
getItemId( sal_Int16 nPos
) override
;
99 virtual sal_Int16 SAL_CALL
getItemPos( sal_Int16 nId
) override
;
100 virtual css::awt::MenuItemType SAL_CALL
getItemType( ::sal_Int16 nItemPos
) override
;
101 virtual void SAL_CALL
enableItem( sal_Int16 nItemId
, sal_Bool bEnable
) override
;
102 virtual sal_Bool SAL_CALL
isItemEnabled( sal_Int16 nItemId
) override
;
103 virtual void SAL_CALL
hideDisabledEntries( sal_Bool bHide
) override
;
104 virtual void SAL_CALL
enableAutoMnemonics( sal_Bool bEnable
) override
;
105 virtual void SAL_CALL
setItemText( sal_Int16 nItemId
, const OUString
& aText
) override
;
106 virtual OUString SAL_CALL
getItemText( sal_Int16 nItemId
) override
;
107 virtual void SAL_CALL
setCommand( sal_Int16 nItemId
, const OUString
& aCommand
) override
;
108 virtual OUString SAL_CALL
getCommand( sal_Int16 nItemId
) override
;
109 virtual void SAL_CALL
setHelpCommand( sal_Int16 nItemId
, const OUString
& aHelp
) override
;
110 virtual OUString SAL_CALL
getHelpCommand( sal_Int16 nItemId
) override
;
111 virtual void SAL_CALL
setHelpText( ::sal_Int16 nItemId
, const OUString
& sHelpText
) override
;
112 virtual OUString SAL_CALL
getHelpText( ::sal_Int16 nItemId
) override
;
113 virtual void SAL_CALL
setTipHelpText( ::sal_Int16 nItemId
, const OUString
& sTipHelpText
) override
;
114 virtual OUString SAL_CALL
getTipHelpText( ::sal_Int16 nItemId
) override
;
116 virtual sal_Bool SAL_CALL
isPopupMenu( ) override
;
117 virtual void SAL_CALL
setPopupMenu( sal_Int16 nItemId
, const css::uno::Reference
< css::awt::XPopupMenu
>& aPopupMenu
) override
;
118 virtual css::uno::Reference
< css::awt::XPopupMenu
> SAL_CALL
getPopupMenu( sal_Int16 nItemId
) override
;
120 // css::awt::XPopupMenu
121 virtual void SAL_CALL
insertSeparator( sal_Int16 nPos
) override
;
122 virtual void SAL_CALL
setDefaultItem( sal_Int16 nItemId
) override
;
123 virtual sal_Int16 SAL_CALL
getDefaultItem( ) override
;
124 virtual void SAL_CALL
checkItem( sal_Int16 nItemId
, sal_Bool bCheck
) override
;
125 virtual sal_Bool SAL_CALL
isItemChecked( sal_Int16 nItemId
) override
;
126 virtual ::sal_Int16 SAL_CALL
execute( const css::uno::Reference
< css::awt::XWindowPeer
>& Parent
, const css::awt::Rectangle
& Position
, ::sal_Int16 Direction
) override
;
127 virtual sal_Bool SAL_CALL
isInExecute( ) override
;
128 virtual void SAL_CALL
endExecute( ) override
;
129 virtual void SAL_CALL
setAcceleratorKeyEvent( ::sal_Int16 nItemId
, const css::awt::KeyEvent
& aKeyEvent
) override
;
130 virtual css::awt::KeyEvent SAL_CALL
getAcceleratorKeyEvent( ::sal_Int16 nItemId
) override
;
131 virtual void SAL_CALL
setItemImage( ::sal_Int16 nItemId
, const css::uno::Reference
< css::graphic::XGraphic
>& xGraphic
, sal_Bool bScale
) override
;
132 virtual css::uno::Reference
< css::graphic::XGraphic
> SAL_CALL
getItemImage( ::sal_Int16 nItemId
) override
;
134 // css::lang::XServiceInfo
135 virtual OUString SAL_CALL
getImplementationName( ) override
;
136 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
137 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
140 class UNLESS_MERGELIBS(TOOLKIT_DLLPUBLIC
) VCLXMenuBar final
: public VCLXMenu
144 VCLXMenuBar( MenuBar
* pMenuBar
);
147 class TOOLKIT_DLLPUBLIC VCLXPopupMenu final
: public VCLXMenu
151 VCLXPopupMenu( PopupMenu
* pPopMenu
);
153 ~VCLXPopupMenu() override
;
156 #endif // INCLUDED_TOOLKIT_AWT_VCLXMENU_HXX
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */