Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _TOOLKIT_AWT_VCLXMENU_HXX_
21 : #define _TOOLKIT_AWT_VCLXMENU_HXX_
22 :
23 : #include <toolkit/dllapi.h>
24 : #include <com/sun/star/awt/XMenuBarExtended.hpp>
25 : #include <com/sun/star/awt/XPopupMenuExtended.hpp>
26 : #include <com/sun/star/lang/XServiceInfo.hpp>
27 : #include <com/sun/star/lang/XTypeProvider.hpp>
28 : #include <com/sun/star/lang/XUnoTunnel.hpp>
29 : #include <cppuhelper/weak.hxx>
30 : #include <osl/mutex.hxx>
31 :
32 : #include <tools/link.hxx>
33 :
34 : #include <toolkit/helper/listenermultiplexer.hxx>
35 : #include <vector>
36 :
37 : class Menu;
38 : class MenuBar;
39 : class VclSimpleEvent;
40 : class PopupMenu;
41 :
42 : typedef ::std::vector<
43 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >*
44 : > PopupMenuRefList;
45 :
46 : // ----------------------------------------------------
47 : // class VCLXMenu
48 : // ----------------------------------------------------
49 :
50 : class TOOLKIT_DLLPUBLIC VCLXMenu : public ::com::sun::star::awt::XMenuBarExtended,
51 : public ::com::sun::star::awt::XPopupMenuExtended,
52 : public ::com::sun::star::lang::XServiceInfo,
53 : public ::com::sun::star::lang::XTypeProvider,
54 : public ::com::sun::star::lang::XUnoTunnel,
55 : public ::cppu::OWeakObject
56 : {
57 : private:
58 : ::osl::Mutex maMutex;
59 : Menu* mpMenu;
60 : MenuListenerMultiplexer maMenuListeners;
61 : PopupMenuRefList maPopupMenueRefs;
62 :
63 : protected:
64 535 : ::osl::Mutex& GetMutex() { return maMutex; }
65 :
66 : DECL_LINK( MenuEventListener, VclSimpleEvent* );
67 :
68 : void ImplCreateMenu( sal_Bool bPopup );
69 :
70 : public:
71 : VCLXMenu();
72 : VCLXMenu( Menu* pMenu );
73 : ~VCLXMenu();
74 :
75 :
76 299 : Menu* GetMenu() const { return mpMenu; }
77 : sal_Bool IsPopupMenu() const;
78 :
79 : // ::com::sun::star::uno::XInterface
80 : ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
81 2439 : void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
82 2266 : void SAL_CALL release() throw() { OWeakObject::release(); }
83 :
84 : // ::com::sun::star::lang::XUnoTunnel
85 : static const ::com::sun::star::uno::Sequence< sal_Int8 >& GetUnoTunnelId() throw();
86 : static VCLXMenu* GetImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxIFace ) throw();
87 : sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException);
88 :
89 : // ::com::sun::star::lang::XTypeProvider
90 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
91 : ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
92 :
93 : // ::com::sun::star::awt::XMenu
94 : void SAL_CALL addMenuListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
95 : void SAL_CALL removeMenuListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
96 : void SAL_CALL insertItem( sal_Int16 nItemId, const ::rtl::OUString& aText, sal_Int16 nItemStyle, sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException);
97 : void SAL_CALL removeItem( sal_Int16 nPos, sal_Int16 nCount ) throw(::com::sun::star::uno::RuntimeException);
98 : sal_Int16 SAL_CALL getItemCount( ) throw(::com::sun::star::uno::RuntimeException);
99 : sal_Int16 SAL_CALL getItemId( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException);
100 : sal_Int16 SAL_CALL getItemPos( sal_Int16 nId ) throw(::com::sun::star::uno::RuntimeException);
101 : void SAL_CALL enableItem( sal_Int16 nItemId, sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException);
102 : sal_Bool SAL_CALL isItemEnabled( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException);
103 : void SAL_CALL setItemText( sal_Int16 nItemId, const ::rtl::OUString& aText ) throw(::com::sun::star::uno::RuntimeException);
104 : ::rtl::OUString SAL_CALL getItemText( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException);
105 : void SAL_CALL setPopupMenu( sal_Int16 nItemId, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >& aPopupMenu ) throw(::com::sun::star::uno::RuntimeException);
106 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > SAL_CALL getPopupMenu( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException);
107 :
108 : // ::com::sun::star::awt::XPopupMenu
109 : void SAL_CALL insertSeparator( sal_Int16 nPos ) throw(::com::sun::star::uno::RuntimeException);
110 : void SAL_CALL setDefaultItem( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException);
111 : sal_Int16 SAL_CALL getDefaultItem( ) throw(::com::sun::star::uno::RuntimeException);
112 : void SAL_CALL checkItem( sal_Int16 nItemId, sal_Bool bCheck ) throw(::com::sun::star::uno::RuntimeException);
113 : sal_Bool SAL_CALL isItemChecked( sal_Int16 nItemId ) throw(::com::sun::star::uno::RuntimeException);
114 : sal_Int16 SAL_CALL execute( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent, const ::com::sun::star::awt::Rectangle& Area, sal_Int16 Direction ) throw(::com::sun::star::uno::RuntimeException);
115 :
116 : // ::com::sun::star::awt::XMenuBar
117 :
118 : // ::com::sun::star::awt::XMenuExtended
119 : virtual void SAL_CALL setCommand( sal_Int16 nItemId, const ::rtl::OUString& aCommand ) throw (::com::sun::star::uno::RuntimeException);
120 : virtual ::rtl::OUString SAL_CALL getCommand( sal_Int16 nItemId ) throw (::com::sun::star::uno::RuntimeException);
121 : virtual void SAL_CALL setHelpCommand( sal_Int16 nItemId, const ::rtl::OUString& aHelp ) throw (::com::sun::star::uno::RuntimeException);
122 : virtual ::rtl::OUString SAL_CALL getHelpCommand( sal_Int16 nItemId ) throw (::com::sun::star::uno::RuntimeException);
123 :
124 : // ========================================================================
125 : // ========================================================================
126 : // ========================================================================
127 :
128 : // XMenuExtended2 Methods
129 : virtual ::sal_Bool SAL_CALL isPopupMenu( ) throw (::com::sun::star::uno::RuntimeException);
130 : virtual void SAL_CALL clear( ) throw (::com::sun::star::uno::RuntimeException);
131 : virtual ::com::sun::star::awt::MenuItemType SAL_CALL getItemType( ::sal_Int16 nItemPos ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
132 : virtual void SAL_CALL hideDisabledEntries( ::sal_Bool bHide ) throw (::com::sun::star::uno::RuntimeException);
133 :
134 : // XMenuBarExtended Methods
135 :
136 : // XPopupMenuExtended Methods
137 : virtual ::sal_Bool SAL_CALL isInExecute( ) throw (::com::sun::star::uno::RuntimeException);
138 : virtual void SAL_CALL endExecute( ) throw (::com::sun::star::uno::RuntimeException);
139 : virtual void SAL_CALL setLogo( const ::com::sun::star::awt::MenuLogo& aMenuLogo ) throw (::com::sun::star::uno::RuntimeException);
140 : virtual ::com::sun::star::awt::MenuLogo SAL_CALL getLogo( ) throw (::com::sun::star::uno::RuntimeException);
141 : virtual void SAL_CALL enableAutoMnemonics( ::sal_Bool bEnable ) throw (::com::sun::star::uno::RuntimeException);
142 : virtual void SAL_CALL setAcceleratorKeyEvent( ::sal_Int16 nItemId, const ::com::sun::star::awt::KeyEvent& aKeyEvent ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
143 : virtual ::com::sun::star::awt::KeyEvent SAL_CALL getAcceleratorKeyEvent( ::sal_Int16 nItemId ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
144 : virtual void SAL_CALL setHelpText( ::sal_Int16 nItemId, const ::rtl::OUString& sHelpText ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
145 : virtual ::rtl::OUString SAL_CALL getHelpText( ::sal_Int16 nItemId ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
146 : virtual void SAL_CALL setTipHelpText( ::sal_Int16 nItemId, const ::rtl::OUString& sTipHelpText ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
147 : virtual ::rtl::OUString SAL_CALL getTipHelpText( ::sal_Int16 nItemId ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
148 : virtual void SAL_CALL setItemImage( ::sal_Int16 nItemId, const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& xGraphic, ::sal_Bool bScale ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
149 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL getItemImage( ::sal_Int16 nItemId ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
150 : virtual void SAL_CALL setItemImageAngle( ::sal_Int16 nItemId, ::sal_Int32 nAngle ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
151 : virtual ::sal_Int32 SAL_CALL getItemImageAngle( ::sal_Int16 nItemId ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
152 : virtual void SAL_CALL setItemImageMirrorMode( ::sal_Int16 nItemId, ::sal_Bool bMirror ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
153 : virtual ::sal_Bool SAL_CALL isItemImageInMirrorMode( ::sal_Int16 nItemId ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
154 :
155 : // ::com::sun::star::lang::XServiceInfo
156 : virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
157 : virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
158 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
159 :
160 : };
161 :
162 : // ----------------------------------------------------
163 : // class VCLXMenuBar
164 : // ----------------------------------------------------
165 126 : class TOOLKIT_DLLPUBLIC VCLXMenuBar : public VCLXMenu
166 : {
167 : public:
168 : VCLXMenuBar();
169 : VCLXMenuBar( MenuBar* pMenuBar );
170 : };
171 :
172 : // ----------------------------------------------------
173 : // class VCLXPopupMenu
174 : // ----------------------------------------------------
175 0 : class TOOLKIT_DLLPUBLIC VCLXPopupMenu : public VCLXMenu
176 : {
177 : public:
178 : VCLXPopupMenu();
179 : VCLXPopupMenu( PopupMenu* pPopMenu );
180 : };
181 :
182 : #endif // _TOOLKIT_AWT_VCLXMENU_HXX_
183 :
184 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|