LibreOffice Module vcl (master)  1
weldutils.hxx
Go to the documentation of this file.
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 
10 #ifndef INCLUDED_VCL_WELDUTILS_HXX
11 #define INCLUDED_VCL_WELDUTILS_HXX
12 
13 #include <com/sun/star/awt/XWindow.hpp>
14 #include <com/sun/star/uno/Reference.hxx>
16 #include <cppuhelper/compbase.hxx>
17 #include <tools/link.hxx>
18 #include <vcl/dllapi.h>
19 #include <vcl/weld.hxx>
20 
21 namespace weld
22 {
23 typedef cppu::WeakComponentImplHelper<css::awt::XWindow> TransportAsXWindow_Base;
24 
25 class VCL_DLLPUBLIC TransportAsXWindow : public TransportAsXWindow_Base
26 {
27 private:
28  osl::Mutex m_aHelperMtx;
30 
37 
38 public:
40  : TransportAsXWindow_Base(m_aHelperMtx)
41  , m_pWeldWidget(pWeldWidget)
42  , m_aWindowListeners(m_aHelperMtx)
43  , m_aKeyListeners(m_aHelperMtx)
44  , m_aFocusListeners(m_aHelperMtx)
45  , m_aMouseListeners(m_aHelperMtx)
46  , m_aMotionListeners(m_aHelperMtx)
47  , m_aPaintListeners(m_aHelperMtx)
48  {
49  }
50 
51  weld::Widget* getWidget() const { return m_pWeldWidget; }
52 
53  virtual void clear() { m_pWeldWidget = nullptr; }
54 
55  // css::awt::XWindow
56  void SAL_CALL setPosSize(sal_Int32, sal_Int32, sal_Int32, sal_Int32, sal_Int16) override
57  {
58  throw css::uno::RuntimeException("not implemented");
59  }
60 
61  css::awt::Rectangle SAL_CALL getPosSize() override
62  {
63  throw css::uno::RuntimeException("not implemented");
64  }
65 
66  void SAL_CALL setVisible(sal_Bool bVisible) override { m_pWeldWidget->set_visible(bVisible); }
67 
68  void SAL_CALL setEnable(sal_Bool bSensitive) override
69  {
70  m_pWeldWidget->set_sensitive(bSensitive);
71  }
72 
73  void SAL_CALL setFocus() override { m_pWeldWidget->grab_focus(); }
74 
75  void SAL_CALL
76  addWindowListener(const css::uno::Reference<css::awt::XWindowListener>& rListener) override
77  {
78  m_aWindowListeners.addInterface(rListener);
79  }
80 
81  void SAL_CALL
82  removeWindowListener(const css::uno::Reference<css::awt::XWindowListener>& rListener) override
83  {
84  m_aWindowListeners.removeInterface(rListener);
85  }
86 
87  void SAL_CALL
88  addFocusListener(const css::uno::Reference<css::awt::XFocusListener>& rListener) override
89  {
90  m_aFocusListeners.addInterface(rListener);
91  }
92 
93  void SAL_CALL
94  removeFocusListener(const css::uno::Reference<css::awt::XFocusListener>& rListener) override
95  {
96  m_aFocusListeners.removeInterface(rListener);
97  }
98 
99  void SAL_CALL
100  addKeyListener(const css::uno::Reference<css::awt::XKeyListener>& rListener) override
101  {
102  m_aKeyListeners.addInterface(rListener);
103  }
104 
105  void SAL_CALL
106  removeKeyListener(const css::uno::Reference<css::awt::XKeyListener>& rListener) override
107  {
108  m_aKeyListeners.removeInterface(rListener);
109  }
110 
111  void SAL_CALL
112  addMouseListener(const css::uno::Reference<css::awt::XMouseListener>& rListener) override
113  {
114  m_aMouseListeners.addInterface(rListener);
115  }
116 
117  void SAL_CALL
118  removeMouseListener(const css::uno::Reference<css::awt::XMouseListener>& rListener) override
119  {
120  m_aMouseListeners.removeInterface(rListener);
121  }
122 
123  void SAL_CALL addMouseMotionListener(
124  const css::uno::Reference<css::awt::XMouseMotionListener>& rListener) override
125  {
126  m_aMotionListeners.addInterface(rListener);
127  }
128 
130  const css::uno::Reference<css::awt::XMouseMotionListener>& rListener) override
131  {
132  m_aMotionListeners.removeInterface(rListener);
133  }
134 
135  void SAL_CALL
136  addPaintListener(const css::uno::Reference<css::awt::XPaintListener>& rListener) override
137  {
138  m_aPaintListeners.addInterface(rListener);
139  }
140 
141  void SAL_CALL
142  removePaintListener(const css::uno::Reference<css::awt::XPaintListener>& rListener) override
143  {
144  m_aPaintListeners.removeInterface(rListener);
145  }
146 };
147 }
148 
149 #endif
150 
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
comphelper::OInterfaceContainerHelper2 m_aMouseListeners
Definition: weldutils.hxx:34
weld::Widget * m_pWeldWidget
Definition: weldutils.hxx:29
comphelper::OInterfaceContainerHelper2 m_aPaintListeners
Definition: weldutils.hxx:36
void SAL_CALL addFocusListener(const css::uno::Reference< css::awt::XFocusListener > &rListener) override
Definition: weldutils.hxx:88
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
void SAL_CALL addMouseMotionListener(const css::uno::Reference< css::awt::XMouseMotionListener > &rListener) override
Definition: weldutils.hxx:123
sal_Int32 addInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
sal_Int32 removeInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
comphelper::OInterfaceContainerHelper2 m_aMotionListeners
Definition: weldutils.hxx:35
void SAL_CALL removeMouseListener(const css::uno::Reference< css::awt::XMouseListener > &rListener) override
Definition: weldutils.hxx:118
void SAL_CALL removeKeyListener(const css::uno::Reference< css::awt::XKeyListener > &rListener) override
Definition: weldutils.hxx:106
virtual void clear()
Definition: weldutils.hxx:53
void SAL_CALL addPaintListener(const css::uno::Reference< css::awt::XPaintListener > &rListener) override
Definition: weldutils.hxx:136
void SAL_CALL addKeyListener(const css::uno::Reference< css::awt::XKeyListener > &rListener) override
Definition: weldutils.hxx:100
void SAL_CALL removePaintListener(const css::uno::Reference< css::awt::XPaintListener > &rListener) override
Definition: weldutils.hxx:142
cppu::WeakComponentImplHelper< css::awt::XWindow > TransportAsXWindow_Base
Definition: weldutils.hxx:23
void SAL_CALL setEnable(sal_Bool bSensitive) override
Definition: weldutils.hxx:68
void SAL_CALL setFocus() override
Definition: weldutils.hxx:73
comphelper::OInterfaceContainerHelper2 m_aKeyListeners
Definition: weldutils.hxx:32
unsigned char sal_Bool
TransportAsXWindow(weld::Widget *pWeldWidget)
Definition: weldutils.hxx:39
comphelper::OInterfaceContainerHelper2 m_aFocusListeners
Definition: weldutils.hxx:33
void SAL_CALL setVisible(sal_Bool bVisible) override
Definition: weldutils.hxx:66
void SAL_CALL removeFocusListener(const css::uno::Reference< css::awt::XFocusListener > &rListener) override
Definition: weldutils.hxx:94
void SAL_CALL addWindowListener(const css::uno::Reference< css::awt::XWindowListener > &rListener) override
Definition: weldutils.hxx:76
virtual void grab_focus()=0
void SAL_CALL removeMouseMotionListener(const css::uno::Reference< css::awt::XMouseMotionListener > &rListener) override
Definition: weldutils.hxx:129
comphelper::OInterfaceContainerHelper2 m_aWindowListeners
Definition: weldutils.hxx:31
void SAL_CALL addMouseListener(const css::uno::Reference< css::awt::XMouseListener > &rListener) override
Definition: weldutils.hxx:112
void SAL_CALL removeWindowListener(const css::uno::Reference< css::awt::XWindowListener > &rListener) override
Definition: weldutils.hxx:82
void SAL_CALL setPosSize(sal_Int32, sal_Int32, sal_Int32, sal_Int32, sal_Int16) override
Definition: weldutils.hxx:56
virtual void set_visible(bool visible)
Definition: weld.hxx:103
weld::Widget * getWidget() const
Definition: weldutils.hxx:51
virtual void set_sensitive(bool sensitive)=0
css::awt::Rectangle SAL_CALL getPosSize() override
Definition: weldutils.hxx:61