LibreOffice Module vcl (master)  1
customweld.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_CUSTOMWELD_HXX
11 #define INCLUDED_VCL_CUSTOMWELD_HXX
12 
13 #include <vcl/weld.hxx>
14 
15 namespace weld
16 {
18 {
19 private:
22 
23 public:
24  virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible()
25  {
26  return css::uno::Reference<css::accessibility::XAccessible>();
27  }
28  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) = 0;
29  virtual void Resize() {}
30  virtual bool MouseButtonDown(const MouseEvent&) { return false; }
31  virtual bool MouseMove(const MouseEvent&) { return false; }
32  virtual bool MouseButtonUp(const MouseEvent&) { return false; }
33  virtual void GetFocus() {}
34  virtual void LoseFocus() {}
35  virtual void StyleUpdated() { Invalidate(); }
36  virtual bool Command(const CommandEvent&) { return false; }
37  virtual bool KeyInput(const KeyEvent&) { return false; }
39  virtual FactoryFunction GetUITestFactory() const { return nullptr; }
40  virtual OUString RequestHelp(tools::Rectangle&) { return OUString(); }
41  virtual OUString GetHelpText() const { return m_pDrawingArea->get_tooltip_text(); }
42  Size const& GetOutputSizePixel() const { return m_aSize; }
43  void SetOutputSizePixel(const Size& rSize) { m_aSize = rSize; }
44  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) { m_pDrawingArea = pDrawingArea; }
45  weld::DrawingArea* GetDrawingArea() const { return m_pDrawingArea; }
46  void Invalidate() { m_pDrawingArea->queue_draw(); }
47  static bool IsUpdateMode() { return true; }
48  void Invalidate(const tools::Rectangle& rRect)
49  {
50  m_pDrawingArea->queue_draw_area(rRect.Left(), rRect.Top(), rRect.GetWidth(),
51  rRect.GetHeight());
52  }
53  virtual void Show() { m_pDrawingArea->show(); }
54  virtual void Hide() { m_pDrawingArea->hide(); }
55  void GrabFocus() { m_pDrawingArea->grab_focus(); }
56  bool HasFocus() const { return m_pDrawingArea->has_focus(); }
57  bool IsVisible() const { return m_pDrawingArea->get_visible(); }
58  bool IsReallyVisible() const { return m_pDrawingArea->is_visible(); }
59  bool IsEnabled() const { return m_pDrawingArea->get_sensitive(); }
60  bool IsActive() const { return m_pDrawingArea->is_active(); }
61  int GetTextHeight() const { return m_pDrawingArea->get_text_height(); }
62  OUString GetAccessibleName() const { return m_pDrawingArea->get_accessible_name(); }
63  OUString GetAccessibleDescription() const
64  {
65  return m_pDrawingArea->get_accessible_description();
66  }
67  void CaptureMouse() { m_pDrawingArea->grab_add(); }
68  bool IsMouseCaptured() const { return m_pDrawingArea->has_grab(); }
69  void EnableRTL(bool bEnable) { m_pDrawingArea->set_direction(bEnable); }
70  bool IsRTLEnabled() const { return m_pDrawingArea->get_direction(); }
71  void ReleaseMouse() { m_pDrawingArea->grab_remove(); }
72  void SetPointer(PointerStyle ePointerStyle) { m_pDrawingArea->set_cursor(ePointerStyle); }
73  void SetHelpId(const OString& rHelpId) { m_pDrawingArea->set_help_id(rHelpId); }
74  void SetAccessibleName(const OUString& rName) { m_pDrawingArea->set_accessible_name(rName); }
75  void set_size_request(int nWidth, int nHeight)
76  {
77  m_pDrawingArea->set_size_request(nWidth, nHeight);
78  }
79  void queue_resize() { m_pDrawingArea->queue_resize(); }
81  : m_pDrawingArea(nullptr)
82  {
83  }
84  virtual ~CustomWidgetController();
85 
88  CustomWidgetController& operator=(CustomWidgetController const&) = default;
89  CustomWidgetController& operator=(CustomWidgetController&&) = default;
90 };
91 
93 {
94 private:
96  std::unique_ptr<weld::DrawingArea> m_xDrawingArea;
97 
98  DECL_LINK(DoResize, const Size& rSize, void);
100  DECL_LINK(DoMouseButtonDown, const MouseEvent&, bool);
101  DECL_LINK(DoMouseMove, const MouseEvent&, bool);
102  DECL_LINK(DoMouseButtonUp, const MouseEvent&, bool);
103  DECL_LINK(DoGetFocus, weld::Widget&, void);
104  DECL_LINK(DoLoseFocus, weld::Widget&, void);
105  DECL_LINK(DoKeyPress, const KeyEvent&, bool);
106  DECL_LINK(DoFocusRect, weld::Widget&, tools::Rectangle);
107  DECL_LINK(DoCommand, const CommandEvent&, bool);
108  DECL_LINK(DoStyleUpdated, weld::Widget&, void);
109  DECL_LINK(DoRequestHelp, tools::Rectangle&, OUString);
110 
111 public:
112  CustomWeld(weld::Builder& rBuilder, const OString& rDrawingId,
113  CustomWidgetController& rWidgetController);
114  void queue_draw() { m_xDrawingArea->queue_draw(); }
115  void queue_draw_area(int x, int y, int width, int height)
116  {
117  m_xDrawingArea->queue_draw_area(x, y, width, height);
118  }
119  void set_size_request(int nWidth, int nHeight)
120  {
121  m_xDrawingArea->set_size_request(nWidth, nHeight);
122  }
123  void show() { m_xDrawingArea->show(); }
124  void hide() { m_xDrawingArea->hide(); }
125  void set_margin_top(int nMargin) { m_xDrawingArea->set_margin_top(nMargin); }
126  void set_margin_bottom(int nMargin) { m_xDrawingArea->set_margin_bottom(nMargin); }
127  void set_sensitive(bool bSensitive) { m_xDrawingArea->set_sensitive(bSensitive); }
128  bool get_sensitive() const { return m_xDrawingArea->get_sensitive(); }
129  bool get_visible() const { return m_xDrawingArea->get_visible(); }
130  void set_grid_left_attach(int nAttach) { m_xDrawingArea->set_grid_left_attach(nAttach); }
131  int get_grid_left_attach() const { return m_xDrawingArea->get_grid_left_attach(); }
132  void set_help_id(const OString& rHelpId) { m_xDrawingArea->set_help_id(rHelpId); }
133 };
134 }
135 #endif
136 
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void queue_draw_area(int x, int y, int width, int height)
Definition: customweld.hxx:115
virtual FactoryFunction GetUITestFactory() const
Definition: customweld.hxx:39
long GetWidth() const
virtual OUString RequestHelp(tools::Rectangle &)
Definition: customweld.hxx:40
virtual OUString GetHelpText() const
Definition: customweld.hxx:41
long GetHeight() const
void set_help_id(const OString &rHelpId)
Definition: customweld.hxx:132
virtual void hide()=0
void SetHelpId(const OString &rHelpId)
Definition: customweld.hxx:73
void set_margin_top(int nMargin)
Definition: customweld.hxx:125
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
std::unique_ptr< weld::DrawingArea > m_xDrawingArea
Definition: customweld.hxx:96
OUString GetAccessibleDescription() const
Definition: customweld.hxx:63
virtual bool MouseButtonUp(const MouseEvent &)
Definition: customweld.hxx:32
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
virtual bool MouseMove(const MouseEvent &)
Definition: customweld.hxx:31
std::pair< vcl::RenderContext &, const tools::Rectangle & > draw_args
Definition: weld.hxx:1817
virtual bool get_direction() const =0
virtual void queue_draw()=0
Size const & GetOutputSizePixel() const
Definition: customweld.hxx:42
void Invalidate(const tools::Rectangle &rRect)
Definition: customweld.hxx:48
virtual void show()=0
void set_grid_left_attach(int nAttach)
Definition: customweld.hxx:130
virtual void set_help_id(const OString &rName)=0
long Top() const
virtual bool get_visible() const =0
void set_margin_bottom(int nMargin)
Definition: customweld.hxx:126
virtual void set_cursor(PointerStyle ePointerStyle)=0
virtual void queue_resize()=0
OUString GetAccessibleName() const
Definition: customweld.hxx:62
virtual bool has_focus() const =0
bool get_sensitive() const
Definition: customweld.hxx:128
virtual void grab_remove()=0
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
virtual void set_direction(bool bRTL)=0
virtual tools::Rectangle GetFocusRect()
Definition: customweld.hxx:38
virtual bool KeyInput(const KeyEvent &)
Definition: customweld.hxx:37
void SetAccessibleName(const OUString &rName)
Definition: customweld.hxx:74
void SetOutputSizePixel(const Size &rSize)
Definition: customweld.hxx:43
virtual bool has_grab() const =0
virtual bool get_sensitive() const =0
void set_size_request(int nWidth, int nHeight)
Definition: customweld.hxx:75
virtual OUString get_tooltip_text() const =0
weld::DrawingArea * GetDrawingArea() const
Definition: customweld.hxx:45
virtual OUString get_accessible_description() const =0
virtual bool is_active() const =0
virtual bool MouseButtonDown(const MouseEvent &)
Definition: customweld.hxx:30
virtual void grab_focus()=0
weld::DrawingArea * m_pDrawingArea
Definition: customweld.hxx:21
void set_size_request(int nWidth, int nHeight)
Definition: customweld.hxx:119
virtual int get_text_height() const =0
virtual void grab_add()=0
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
Definition: customweld.hxx:44
long Left() const
PointerStyle
Definition: ptrstyle.hxx:25
int get_grid_left_attach() const
Definition: customweld.hxx:131
bool get_visible() const
Definition: customweld.hxx:129
virtual OUString get_accessible_name() const =0
void set_sensitive(bool bSensitive)
Definition: customweld.hxx:127
virtual bool is_visible() const =0
virtual void queue_draw_area(int x, int y, int width, int height)=0
weld::CustomWidgetController & m_rWidgetController
Definition: customweld.hxx:95
virtual void set_accessible_name(const OUString &rName)=0
virtual void set_size_request(int nWidth, int nHeight)=0
void SetPointer(PointerStyle ePointerStyle)
Definition: customweld.hxx:72
virtual bool Command(const CommandEvent &)
Definition: customweld.hxx:36
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
Definition: customweld.hxx:24
void EnableRTL(bool bEnable)
Definition: customweld.hxx:69