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 <toolkit/dllapi.h>
24 #include <toolkit/helper/listenermultiplexer.hxx>
26 #include <com/sun/star/awt/XMenuBar.hpp>
27 #include <com/sun/star/awt/XPopupMenu.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/lang/XTypeProvider.hpp>
30 #include <com/sun/star/lang/XUnoTunnel.hpp>
32 #include <comphelper/servicehelper.hxx>
33 #include <cppuhelper/weak.hxx>
34 #include <osl/mutex.hxx>
36 #include <tools/link.hxx>
37 #include <vcl/vclptr.hxx>
46 typedef ::std::vector
<
47 css::uno::Reference
< css::awt::XPopupMenu
>
54 class TOOLKIT_DLLPUBLIC VCLXMenu
: public css::awt::XMenuBar
,
55 public css::awt::XPopupMenu
,
56 public css::lang::XServiceInfo
,
57 public css::lang::XTypeProvider
,
58 public css::lang::XUnoTunnel
,
59 public ::cppu::OWeakObject
64 MenuListenerMultiplexer maMenuListeners
;
65 PopupMenuRefList maPopupMenuRefs
;
66 sal_Int16 mnDefaultItem
;
69 ::osl::Mutex
& GetMutex() { return maMutex
; }
71 DECL_LINK( MenuEventListener
, VclMenuEvent
&, void );
73 void ImplCreateMenu( bool bPopup
);
74 void ImplAddListener();
78 VCLXMenu( Menu
* pMenu
);
79 virtual ~VCLXMenu() override
;
82 Menu
* GetMenu() const { return mpMenu
; }
83 bool IsPopupMenu() const;
85 // css::uno::XInterface
86 css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
87 void SAL_CALL
acquire() throw() override
{ OWeakObject::acquire(); }
88 void SAL_CALL
release() throw() override
{ OWeakObject::release(); }
90 // css::lang::XUnoTunnel
91 UNO3_GETIMPLEMENTATION_DECL(VCLXMenu
)
93 // css::lang::XTypeProvider
94 css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
95 css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
98 virtual void SAL_CALL
addMenuListener( const css::uno::Reference
< css::awt::XMenuListener
>& xListener
) override
;
99 virtual void SAL_CALL
removeMenuListener( const css::uno::Reference
< css::awt::XMenuListener
>& xListener
) override
;
100 virtual void SAL_CALL
insertItem( sal_Int16 nItemId
, const OUString
& aText
, sal_Int16 nItemStyle
, sal_Int16 nPos
) override
;
101 virtual void SAL_CALL
removeItem( sal_Int16 nPos
, sal_Int16 nCount
) override
;
102 virtual void SAL_CALL
clear( ) override
;
103 virtual sal_Int16 SAL_CALL
getItemCount( ) override
;
104 virtual sal_Int16 SAL_CALL
getItemId( sal_Int16 nPos
) override
;
105 virtual sal_Int16 SAL_CALL
getItemPos( sal_Int16 nId
) override
;
106 virtual css::awt::MenuItemType SAL_CALL
getItemType( ::sal_Int16 nItemPos
) override
;
107 virtual void SAL_CALL
enableItem( sal_Int16 nItemId
, sal_Bool bEnable
) override
;
108 virtual sal_Bool SAL_CALL
isItemEnabled( sal_Int16 nItemId
) override
;
109 virtual void SAL_CALL
hideDisabledEntries( sal_Bool bHide
) override
;
110 virtual void SAL_CALL
enableAutoMnemonics( sal_Bool bEnable
) override
;
111 virtual void SAL_CALL
setItemText( sal_Int16 nItemId
, const OUString
& aText
) override
;
112 virtual OUString SAL_CALL
getItemText( sal_Int16 nItemId
) override
;
113 virtual void SAL_CALL
setCommand( sal_Int16 nItemId
, const OUString
& aCommand
) override
;
114 virtual OUString SAL_CALL
getCommand( sal_Int16 nItemId
) override
;
115 virtual void SAL_CALL
setHelpCommand( sal_Int16 nItemId
, const OUString
& aHelp
) override
;
116 virtual OUString SAL_CALL
getHelpCommand( sal_Int16 nItemId
) override
;
117 virtual void SAL_CALL
setHelpText( ::sal_Int16 nItemId
, const OUString
& sHelpText
) override
;
118 virtual OUString SAL_CALL
getHelpText( ::sal_Int16 nItemId
) override
;
119 virtual void SAL_CALL
setTipHelpText( ::sal_Int16 nItemId
, const OUString
& sTipHelpText
) override
;
120 virtual OUString SAL_CALL
getTipHelpText( ::sal_Int16 nItemId
) override
;
122 virtual sal_Bool SAL_CALL
isPopupMenu( ) override
;
123 virtual void SAL_CALL
setPopupMenu( sal_Int16 nItemId
, const css::uno::Reference
< css::awt::XPopupMenu
>& aPopupMenu
) override
;
124 virtual css::uno::Reference
< css::awt::XPopupMenu
> SAL_CALL
getPopupMenu( sal_Int16 nItemId
) override
;
126 // css::awt::XPopupMenu
127 virtual void SAL_CALL
insertSeparator( sal_Int16 nPos
) override
;
128 virtual void SAL_CALL
setDefaultItem( sal_Int16 nItemId
) override
;
129 virtual sal_Int16 SAL_CALL
getDefaultItem( ) override
;
130 virtual void SAL_CALL
checkItem( sal_Int16 nItemId
, sal_Bool bCheck
) override
;
131 virtual sal_Bool SAL_CALL
isItemChecked( sal_Int16 nItemId
) override
;
132 virtual ::sal_Int16 SAL_CALL
execute( const css::uno::Reference
< css::awt::XWindowPeer
>& Parent
, const css::awt::Rectangle
& Position
, ::sal_Int16 Direction
) override
;
133 virtual sal_Bool SAL_CALL
isInExecute( ) override
;
134 virtual void SAL_CALL
endExecute( ) override
;
135 virtual void SAL_CALL
setAcceleratorKeyEvent( ::sal_Int16 nItemId
, const css::awt::KeyEvent
& aKeyEvent
) override
;
136 virtual css::awt::KeyEvent SAL_CALL
getAcceleratorKeyEvent( ::sal_Int16 nItemId
) override
;
137 virtual void SAL_CALL
setItemImage( ::sal_Int16 nItemId
, const css::uno::Reference
< css::graphic::XGraphic
>& xGraphic
, sal_Bool bScale
) override
;
138 virtual css::uno::Reference
< css::graphic::XGraphic
> SAL_CALL
getItemImage( ::sal_Int16 nItemId
) override
;
140 // css::lang::XServiceInfo
141 virtual OUString SAL_CALL
getImplementationName( ) override
;
142 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
143 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
146 class TOOLKIT_DLLPUBLIC VCLXMenuBar final
: public VCLXMenu
150 VCLXMenuBar( MenuBar
* pMenuBar
);
153 class TOOLKIT_DLLPUBLIC VCLXPopupMenu final
: public VCLXMenu
157 VCLXPopupMenu( PopupMenu
* pPopMenu
);
160 #endif // INCLUDED_TOOLKIT_AWT_VCLXMENU_HXX
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */