1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
12 #include <vcl/dllapi.h>
13 #include <vcl/uitest/uiobject.hxx>
14 #include <vcl/weld.hxx>
15 #include <unordered_map>
20 static void trigger_changed(weld::TextView
& rView
) { rView
.signal_changed(); }
22 static void trigger_changed(weld::Entry
& rEdit
) { rEdit
.signal_changed(); }
24 static void trigger_changed(weld::ComboBox
& rComboBox
) { rComboBox
.signal_changed(); }
26 static void trigger_changed(weld::TreeView
& rTreeView
) { rTreeView
.signal_selection_changed(); }
28 static void trigger_changed(weld::IconView
& rIconView
) { rIconView
.signal_selection_changed(); }
30 static void trigger_scrollv(weld::ScrolledWindow
& rScrolledWindow
)
32 rScrolledWindow
.signal_vadjustment_changed();
35 static void trigger_scrollh(weld::ScrolledWindow
& rScrolledWindow
)
37 rScrolledWindow
.signal_hadjustment_changed();
40 static void trigger_toggled(weld::Toggleable
& rButton
) { rButton
.signal_toggled(); }
42 static void trigger_row_activated(weld::TreeView
& rTreeView
)
44 rTreeView
.signal_row_activated();
47 static void trigger_popup_menu(weld::TreeView
& rTreeView
, const CommandEvent
& rCommand
)
49 rTreeView
.signal_popup_menu(rCommand
);
52 static void trigger_activated(weld::Menu
& rMenu
, const OUString
& rIdent
)
54 rMenu
.signal_activate(rIdent
);
57 static void trigger_item_activated(weld::IconView
& rIconView
)
59 rIconView
.signal_item_activated();
62 static void trigger_clicked(weld::Toolbar
& rToolbar
, const OUString
& rIdent
)
64 rToolbar
.signal_clicked(rIdent
);
67 static void trigger_clicked(weld::Button
& rButton
) { rButton
.signal_clicked(); }
69 static void trigger_click(weld::DrawingArea
& rDrawingArea
, const Point
& rPos
)
71 rDrawingArea
.click(rPos
);
74 static void trigger_dblclick(weld::DrawingArea
& rDrawingArea
, const Point
& rPos
)
76 rDrawingArea
.dblclick(rPos
);
79 static void trigger_mouse_up(weld::DrawingArea
& rDrawingArea
, const Point
& rPos
)
81 rDrawingArea
.mouse_up(rPos
);
84 static void trigger_mouse_down(weld::DrawingArea
& rDrawingArea
, const Point
& rPos
)
86 rDrawingArea
.mouse_down(rPos
);
89 static void trigger_mouse_move(weld::DrawingArea
& rDrawingArea
, const Point
& rPos
)
91 rDrawingArea
.mouse_move(rPos
);
94 static void trigger_selected(weld::MenuButton
& rButton
, const OUString
& rIdent
)
96 rButton
.signal_selected(rIdent
);
99 static void trigger_selected(weld::Calendar
& rCalendar
) { rCalendar
.signal_selected(); }
101 static void trigger_activated(weld::Calendar
& rCalendar
) { rCalendar
.signal_activated(); }
103 static void trigger_value_changed(weld::SpinButton
& rSpinButton
)
105 rSpinButton
.signal_value_changed();
108 static void trigger_value_changed(weld::FormattedSpinButton
& rSpinButton
)
110 rSpinButton
.signal_value_changed();
113 static void trigger_closed(weld::Popover
& rPopover
) { rPopover
.popdown(); }
115 static void trigger_key_press(weld::Widget
& rWidget
, const KeyEvent
& rEvent
)
117 rWidget
.m_aKeyPressHdl
.Call(rEvent
);
120 static void trigger_key_release(weld::Widget
& rWidget
, const KeyEvent
& rEvent
)
122 rWidget
.m_aKeyReleaseHdl
.Call(rEvent
);
125 static void command(weld::DrawingArea
& rArea
, const CommandEvent
& rCmd
)
127 rArea
.m_aCommandHdl
.Call(rCmd
);
130 static void enter_page(weld::Notebook
& rNotebook
, const OUString
& rPage
)
132 rNotebook
.m_aEnterPageHdl
.Call(rPage
);
135 static void leave_page(weld::Notebook
& rNotebook
, const OUString
& rPage
)
137 rNotebook
.m_aLeavePageHdl
.Call(rPage
);
140 static bool activate_link(weld::LinkButton
& rLinkButton
)
142 return rLinkButton
.signal_activate_link();
148 // type used to store key-value pairs to put in the generated messages
149 typedef std::unordered_map
<OString
, OUString
> ActionDataMap
;
151 /// execute action on a widget
152 VCL_DLLPUBLIC
bool ExecuteAction(const OUString
& nWindowId
, const OUString
& rWidget
,
154 /// send full update message to the client
155 VCL_DLLPUBLIC
void SendFullUpdate(const OUString
& nWindowId
, const OUString
& rWidget
);
156 /// send action message to the client
157 VCL_DLLPUBLIC
void SendAction(const OUString
& nWindowId
, const OUString
& rWidget
,
158 std::unique_ptr
<ActionDataMap
> pData
);
159 VCL_DLLPUBLIC StringMap
jsonToStringMap(const char* pJSON
);
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */