LibreOffice Module vcl (master)  1
customweld.cxx
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 #include <vcl/customweld.hxx>
11 
12 namespace weld
13 {
15 
16 CustomWeld::CustomWeld(weld::Builder& rBuilder, const OString& rDrawingId,
17  CustomWidgetController& rWidgetController)
18  : m_rWidgetController(rWidgetController)
19  , m_xDrawingArea(rBuilder.weld_drawing_area(rDrawingId, rWidgetController.CreateAccessible(),
20  rWidgetController.GetUITestFactory(),
21  &rWidgetController))
22 {
23  m_xDrawingArea->connect_size_allocate(LINK(this, CustomWeld, DoResize));
24  m_xDrawingArea->connect_draw(LINK(this, CustomWeld, DoPaint));
25  m_xDrawingArea->connect_mouse_press(LINK(this, CustomWeld, DoMouseButtonDown));
26  m_xDrawingArea->connect_mouse_move(LINK(this, CustomWeld, DoMouseMove));
27  m_xDrawingArea->connect_mouse_release(LINK(this, CustomWeld, DoMouseButtonUp));
28  m_xDrawingArea->connect_focus_in(LINK(this, CustomWeld, DoGetFocus));
29  m_xDrawingArea->connect_focus_out(LINK(this, CustomWeld, DoLoseFocus));
30  m_xDrawingArea->connect_key_press(LINK(this, CustomWeld, DoKeyPress));
31  m_xDrawingArea->connect_focus_rect(LINK(this, CustomWeld, DoFocusRect));
32  m_xDrawingArea->connect_style_updated(LINK(this, CustomWeld, DoStyleUpdated));
33  m_xDrawingArea->connect_command(LINK(this, CustomWeld, DoCommand));
34  m_xDrawingArea->connect_query_tooltip(LINK(this, CustomWeld, DoRequestHelp));
36 }
37 
38 IMPL_LINK(CustomWeld, DoResize, const Size&, rSize, void)
39 {
40  m_rWidgetController.SetOutputSizePixel(rSize);
41  m_rWidgetController.Resize();
42 }
43 
45 {
46  m_rWidgetController.Paint(aPayload.first, aPayload.second);
47 }
48 
49 IMPL_LINK(CustomWeld, DoMouseButtonDown, const MouseEvent&, rMEvt, bool)
50 {
51  return m_rWidgetController.MouseButtonDown(rMEvt);
52 }
53 
54 IMPL_LINK(CustomWeld, DoMouseMove, const MouseEvent&, rMEvt, bool)
55 {
56  return m_rWidgetController.MouseMove(rMEvt);
57 }
58 
59 IMPL_LINK(CustomWeld, DoMouseButtonUp, const MouseEvent&, rMEvt, bool)
60 {
61  return m_rWidgetController.MouseButtonUp(rMEvt);
62 }
63 
64 IMPL_LINK_NOARG(CustomWeld, DoGetFocus, weld::Widget&, void) { m_rWidgetController.GetFocus(); }
65 
66 IMPL_LINK_NOARG(CustomWeld, DoLoseFocus, weld::Widget&, void) { m_rWidgetController.LoseFocus(); }
67 
68 IMPL_LINK(CustomWeld, DoKeyPress, const KeyEvent&, rKEvt, bool)
69 {
70  return m_rWidgetController.KeyInput(rKEvt);
71 }
72 
74 {
75  return m_rWidgetController.GetFocusRect();
76 }
77 
78 IMPL_LINK_NOARG(CustomWeld, DoStyleUpdated, weld::Widget&, void)
79 {
80  m_rWidgetController.StyleUpdated();
81 }
82 
83 IMPL_LINK(CustomWeld, DoCommand, const CommandEvent&, rPos, bool)
84 {
85  return m_rWidgetController.Command(rPos);
86 }
87 
88 IMPL_LINK(CustomWeld, DoRequestHelp, tools::Rectangle&, rHelpArea, OUString)
89 {
90  return m_rWidgetController.RequestHelp(rHelpArea);
91 }
92 }
93 
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
CustomWeld(weld::Builder &rBuilder, const OString &rDrawingId, CustomWidgetController &rWidgetController)
Definition: customweld.cxx:16
std::unique_ptr< weld::DrawingArea > m_xDrawingArea
Definition: customweld.hxx:96
std::pair< vcl::RenderContext &, const tools::Rectangle & > draw_args
Definition: weld.hxx:1817
IMPL_LINK(CustomWeld, DoResize, const Size &, rSize, void)
Definition: customweld.cxx:38
IMPL_LINK_NOARG(HexColorControl, OnAsyncModifyHdl, void *, void)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
Definition: customweld.hxx:44
weld::CustomWidgetController & m_rWidgetController
Definition: customweld.hxx:95