1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #ifndef INCLUDED_VCL_WELD_HXX
11 #define INCLUDED_VCL_WELD_HXX
13 #include <basegfx/range/b2irange.hxx>
14 #include <rtl/ustring.hxx>
15 #include <tools/color.hxx>
16 #include <tools/date.hxx>
17 #include <tools/fldunit.hxx>
18 #include <tools/gen.hxx>
19 #include <tools/link.hxx>
20 #include <tools/time.hxx>
21 #include <vcl/dllapi.h>
22 #include <vcl/vclenum.hxx>
23 #include <vcl/font.hxx>
24 #include <vcl/menu.hxx>
25 #include <vcl/uitest/factory.hxx>
27 #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
28 #include <com/sun/star/accessibility/XAccessible.hpp>
44 namespace datatransfer
59 typedef css::uno::Reference
<css::accessibility::XAccessible
> a11yref
;
60 typedef css::uno::Reference
<css::accessibility::XAccessibleRelationSet
> a11yrelationset
;
62 enum class PointerStyle
;
63 class SvNumberFormatter
;
72 class ILibreOfficeKitNotifier
;
80 class DialogController
;
82 class VCL_DLLPUBLIC Widget
85 Link
<Widget
&, void> m_aFocusInHdl
;
86 Link
<Widget
&, void> m_aFocusOutHdl
;
87 Link
<Widget
&, bool> m_aMnemonicActivateHdl
;
88 Link
<const Size
&, void> m_aSizeAllocateHdl
;
89 Link
<const KeyEvent
&, bool> m_aKeyPressHdl
;
90 Link
<const KeyEvent
&, bool> m_aKeyReleaseHdl
;
91 Link
<const MouseEvent
&, bool> m_aMousePressHdl
;
92 Link
<const MouseEvent
&, bool> m_aMouseMotionHdl
;
93 Link
<const MouseEvent
&, bool> m_aMouseReleaseHdl
;
96 virtual void set_sensitive(bool sensitive
) = 0;
97 virtual bool get_sensitive() const = 0;
98 virtual void show() = 0;
99 virtual void hide() = 0;
100 // This function simply calls show() or hide() but is convenient when the
101 // visibility depends on some condition
102 virtual void set_visible(bool visible
)
109 virtual bool get_visible() const = 0; //if this widget visibility is true
110 virtual bool is_visible() const = 0; //if this widget visibility and all parents is true
111 virtual void set_can_focus(bool bCanFocus
) = 0;
112 virtual void grab_focus() = 0;
113 virtual bool has_focus() const = 0;
114 virtual bool is_active() const = 0; //if this widget has the focus within the active window
115 virtual void set_has_default(bool has_default
) = 0;
116 virtual bool get_has_default() const = 0;
117 virtual void set_size_request(int nWidth
, int nHeight
) = 0;
118 virtual Size
get_size_request() const = 0;
119 virtual Size
get_preferred_size() const = 0;
120 virtual float get_approximate_digit_width() const = 0;
121 virtual int get_text_height() const = 0;
122 virtual Size
get_pixel_size(const OUString
& rText
) const = 0;
123 virtual OString
get_buildable_name() const = 0;
124 virtual void set_help_id(const OString
& rName
) = 0;
125 virtual OString
get_help_id() const = 0;
127 virtual void set_grid_left_attach(int nAttach
) = 0;
128 virtual int get_grid_left_attach() const = 0;
129 virtual void set_grid_width(int nCols
) = 0;
130 virtual void set_grid_top_attach(int nAttach
) = 0;
131 virtual int get_grid_top_attach() const = 0;
133 virtual void set_hexpand(bool bExpand
) = 0;
134 virtual bool get_hexpand() const = 0;
135 virtual void set_vexpand(bool bExpand
) = 0;
136 virtual bool get_vexpand() const = 0;
138 virtual void set_secondary(bool bSecondary
) = 0;
140 virtual void set_margin_top(int nMargin
) = 0;
141 virtual void set_margin_bottom(int nMargin
) = 0;
142 virtual void set_margin_left(int nMargin
) = 0;
143 virtual void set_margin_right(int nMargin
) = 0;
145 virtual int get_margin_top() const = 0;
146 virtual int get_margin_bottom() const = 0;
147 virtual int get_margin_left() const = 0;
148 virtual int get_margin_right() const = 0;
150 virtual bool get_extents_relative_to(Widget
& rRelative
, int& x
, int& y
, int& width
, int& height
)
153 virtual void set_accessible_name(const OUString
& rName
) = 0;
154 virtual OUString
get_accessible_name() const = 0;
156 virtual OUString
get_accessible_description() const = 0;
158 virtual void set_accessible_relation_labeled_by(weld::Widget
* pLabel
) = 0;
159 virtual void set_accessible_relation_label_for(weld::Widget
* pLabeled
) = 0;
161 virtual void set_tooltip_text(const OUString
& rTip
) = 0;
162 virtual OUString
get_tooltip_text() const = 0;
164 virtual void connect_focus_in(const Link
<Widget
&, void>& rLink
)
166 assert(!m_aFocusInHdl
.IsSet() || !rLink
.IsSet());
167 m_aFocusInHdl
= rLink
;
170 virtual void connect_focus_out(const Link
<Widget
&, void>& rLink
)
172 assert(!m_aFocusOutHdl
.IsSet() || !rLink
.IsSet());
173 m_aFocusOutHdl
= rLink
;
176 // rLink is called when the mnemonic for the Widget is called.
177 // If rLink returns true the Widget will not automatically gain
178 // focus as normally occurs
179 virtual void connect_mnemonic_activate(const Link
<Widget
&, bool>& rLink
)
181 assert(!m_aMnemonicActivateHdl
.IsSet() || !rLink
.IsSet());
182 m_aMnemonicActivateHdl
= rLink
;
185 virtual void connect_size_allocate(const Link
<const Size
&, void>& rLink
)
187 assert(!m_aSizeAllocateHdl
.IsSet() || !rLink
.IsSet());
188 m_aSizeAllocateHdl
= rLink
;
191 virtual void connect_key_press(const Link
<const KeyEvent
&, bool>& rLink
)
193 assert(!m_aKeyPressHdl
.IsSet() || !rLink
.IsSet());
194 m_aKeyPressHdl
= rLink
;
197 virtual void connect_key_release(const Link
<const KeyEvent
&, bool>& rLink
)
199 assert(!m_aKeyReleaseHdl
.IsSet() || !rLink
.IsSet());
200 m_aKeyReleaseHdl
= rLink
;
203 virtual void connect_mouse_press(const Link
<const MouseEvent
&, bool>& rLink
)
205 assert(!m_aMousePressHdl
.IsSet() || !rLink
.IsSet());
206 m_aMousePressHdl
= rLink
;
209 virtual void connect_mouse_move(const Link
<const MouseEvent
&, bool>& rLink
)
211 assert(!m_aMouseMotionHdl
.IsSet() || !rLink
.IsSet());
212 m_aMouseMotionHdl
= rLink
;
215 virtual void connect_mouse_release(const Link
<const MouseEvent
&, bool>& rLink
)
217 assert(!m_aMouseReleaseHdl
.IsSet() || !rLink
.IsSet());
218 m_aMouseReleaseHdl
= rLink
;
221 virtual void grab_add() = 0;
222 virtual bool has_grab() const = 0;
223 virtual void grab_remove() = 0;
225 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
226 virtual vcl::Font
get_font() = 0;
228 //true for rtl, false otherwise
229 virtual bool get_direction() const = 0;
230 virtual void set_direction(bool bRTL
) = 0;
232 virtual void freeze() = 0;
233 virtual void thaw() = 0;
235 virtual std::unique_ptr
<Container
> weld_parent() const = 0;
237 //iterate upwards through the hierarchy starting at this widgets parent,
238 //calling func with their helpid until func returns true or we run out of
240 virtual void help_hierarchy_foreach(const std::function
<bool(const OString
&)>& func
) = 0;
242 virtual OUString
strip_mnemonic(const OUString
& rLabel
) const = 0;
244 virtual VclPtr
<VirtualDevice
> create_virtual_device() const = 0;
246 //make this widget look like a page in a notebook
247 virtual void set_stack_background() = 0;
248 //make this widget look like it has a highlighted background
249 virtual void set_highlight_background() = 0;
251 virtual css::uno::Reference
<css::datatransfer::dnd::XDropTarget
> get_drop_target() = 0;
256 class VCL_DLLPUBLIC Container
: virtual public Widget
259 // remove and add in one go
260 virtual void move(weld::Widget
* pWidget
, weld::Container
* pNewParent
) = 0;
261 // recursively unset has-default on any buttons in the widget hierarchy
262 virtual void recursively_unset_default_buttons() = 0;
263 // create an XWindow as a child of this container. The XWindow is
264 // suitable to contain css::awt::XControl items
265 virtual css::uno::Reference
<css::awt::XWindow
> CreateChildFrame() = 0;
268 class VCL_DLLPUBLIC Box
: virtual public Container
271 // Moves child to a new position in the list of children
272 virtual void reorder_child(weld::Widget
* pWidget
, int position
) = 0;
275 class VCL_DLLPUBLIC ScrolledWindow
: virtual public Container
278 Link
<ScrolledWindow
&, void> m_aVChangeHdl
;
279 Link
<ScrolledWindow
&, void> m_aHChangeHdl
;
281 void signal_vadjustment_changed() { m_aVChangeHdl
.Call(*this); }
282 void signal_hadjustment_changed() { m_aHChangeHdl
.Call(*this); }
285 virtual void set_user_managed_scrolling() = 0;
287 virtual void hadjustment_configure(int value
, int lower
, int upper
, int step_increment
,
288 int page_increment
, int page_size
)
290 virtual int hadjustment_get_value() const = 0;
291 virtual void hadjustment_set_value(int value
) = 0;
292 virtual int hadjustment_get_upper() const = 0;
293 virtual void hadjustment_set_upper(int upper
) = 0;
294 virtual int hadjustment_get_page_size() const = 0;
295 virtual void hadjustment_set_page_size(int size
) = 0;
296 virtual void hadjustment_set_page_increment(int size
) = 0;
297 virtual void hadjustment_set_step_increment(int size
) = 0;
298 virtual void set_hpolicy(VclPolicyType eHPolicy
) = 0;
299 virtual VclPolicyType
get_hpolicy() const = 0;
300 void connect_hadjustment_changed(const Link
<ScrolledWindow
&, void>& rLink
)
302 m_aHChangeHdl
= rLink
;
304 virtual int get_hscroll_height() const = 0;
306 virtual void vadjustment_configure(int value
, int lower
, int upper
, int step_increment
,
307 int page_increment
, int page_size
)
309 virtual int vadjustment_get_value() const = 0;
310 virtual void vadjustment_set_value(int value
) = 0;
311 virtual int vadjustment_get_upper() const = 0;
312 virtual void vadjustment_set_upper(int upper
) = 0;
313 virtual int vadjustment_get_page_size() const = 0;
314 virtual void vadjustment_set_page_size(int size
) = 0;
315 virtual void vadjustment_set_page_increment(int size
) = 0;
316 virtual void vadjustment_set_step_increment(int size
) = 0;
317 virtual int vadjustment_get_lower() const = 0;
318 virtual void vadjustment_set_lower(int upper
) = 0;
319 virtual void set_vpolicy(VclPolicyType eVPolicy
) = 0;
320 virtual VclPolicyType
get_vpolicy() const = 0;
321 void connect_vadjustment_changed(const Link
<ScrolledWindow
&, void>& rLink
)
323 m_aVChangeHdl
= rLink
;
325 virtual int get_vscroll_width() const = 0;
330 class VCL_DLLPUBLIC Frame
: virtual public Container
333 virtual void set_label(const OUString
& rText
) = 0;
334 virtual OUString
get_label() const = 0;
335 virtual std::unique_ptr
<Label
> weld_label_widget() const = 0;
338 class VCL_DLLPUBLIC Notebook
: virtual public Container
341 Link
<const OString
&, bool> m_aLeavePageHdl
;
342 Link
<const OString
&, void> m_aEnterPageHdl
;
345 virtual int get_current_page() const = 0;
346 virtual OString
get_page_ident(int nPage
) const = 0;
347 virtual OString
get_current_page_ident() const = 0;
348 virtual void set_current_page(int nPage
) = 0;
349 virtual void set_current_page(const OString
& rIdent
) = 0;
350 virtual void remove_page(const OString
& rIdent
) = 0;
351 virtual void append_page(const OString
& rIdent
, const OUString
& rLabel
) = 0;
352 virtual void set_tab_label_text(const OString
& rIdent
, const OUString
& rLabel
) = 0;
353 virtual OUString
get_tab_label_text(const OString
& rIdent
) const = 0;
354 virtual int get_n_pages() const = 0;
355 virtual weld::Container
* get_page(const OString
& rIdent
) const = 0;
357 void connect_leave_page(const Link
<const OString
&, bool>& rLink
) { m_aLeavePageHdl
= rLink
; }
359 void connect_enter_page(const Link
<const OString
&, void>& rLink
) { m_aEnterPageHdl
= rLink
; }
362 class VCL_DLLPUBLIC ScreenShotEntry
365 ScreenShotEntry(const OString
& rHelpId
, const basegfx::B2IRange
& rB2IRange
)
367 , maB2IRange(rB2IRange
)
371 const basegfx::B2IRange
& getB2IRange() const { return maB2IRange
; }
373 const OString
& GetHelpId() const { return msHelpId
; }
377 basegfx::B2IRange maB2IRange
;
380 typedef std::vector
<ScreenShotEntry
> ScreenShotCollection
;
382 class VCL_DLLPUBLIC Window
: virtual public Container
385 Link
<Widget
&, bool> m_aHelpRequestHdl
;
386 Link
<Widget
&, void> m_aTopLevelFocusChangedHdl
;
388 void signal_toplevel_focus_changed() { m_aTopLevelFocusChangedHdl
.Call(*this); }
391 virtual void set_title(const OUString
& rTitle
) = 0;
392 virtual OUString
get_title() const = 0;
393 virtual void set_busy_cursor(bool bBusy
) = 0;
394 virtual void window_move(int x
, int y
) = 0;
395 virtual void set_modal(bool bModal
) = 0;
396 virtual bool get_modal() const = 0;
397 virtual bool get_resizable() const = 0;
398 virtual Size
get_size() const = 0;
399 virtual Point
get_position() const = 0;
400 virtual tools::Rectangle
get_monitor_workarea() const = 0;
401 // center window on is parent
403 // bTrackGeometryRequests set to true tries to ensure the window will end
404 // up still centered on its parent windows final size, taking into account
405 // that there may currently be pending geometry requests for the parent not
406 // yet processed by the underlying toolkit
408 // for e.g gtk this will means the window is always centered even when
409 // resized, calling set_centered_on_parent with false will turn this
411 virtual void set_centered_on_parent(bool bTrackGeometryRequests
) = 0;
412 virtual bool has_toplevel_focus() const = 0;
413 virtual void present() = 0;
414 virtual void set_window_state(const OString
& rStr
) = 0;
415 virtual OString
get_window_state(WindowStateMask nMask
) const = 0;
417 virtual css::uno::Reference
<css::awt::XWindow
> GetXWindow() = 0;
419 void connect_help(const Link
<Widget
&, bool>& rLink
) { m_aHelpRequestHdl
= rLink
; }
420 virtual void connect_toplevel_focus_changed(const Link
<Widget
&, void>& rLink
)
422 m_aTopLevelFocusChangedHdl
= rLink
;
425 virtual SystemEnvData
get_system_data() const = 0;
427 virtual void resize_to_request() = 0;
429 // render the dialog for a screenshot
430 virtual void draw(VirtualDevice
& rOutput
) = 0;
431 // collect positions of widgets and their help ids for screenshot purposes
432 virtual ScreenShotCollection
collect_screenshot_data() = 0;
435 class VCL_DLLPUBLIC WaitObject
438 weld::Window
* m_pWindow
;
441 WaitObject(weld::Window
* pWindow
)
445 m_pWindow
->set_busy_cursor(true);
450 m_pWindow
->set_busy_cursor(false);
456 class VCL_DLLPUBLIC Dialog
: virtual public Window
459 friend DialogController
;
460 virtual bool runAsync(std::shared_ptr
<DialogController
>,
461 const std::function
<void(sal_Int32
)>& func
)
465 virtual int run() = 0;
466 // Run async without a controller
467 // @param self - must point to this, to enforce that the dialog was created/held by a shared_ptr
468 virtual bool runAsync(std::shared_ptr
<Dialog
> const& rxSelf
,
469 const std::function
<void(sal_Int32
)>& func
)
471 virtual void response(int response
) = 0;
472 virtual void add_button(const OUString
& rText
, int response
, const OString
& rHelpId
= OString())
474 virtual void set_default_response(int response
) = 0;
475 virtual Button
* weld_widget_for_response(int response
) = 0;
476 virtual Container
* weld_content_area() = 0;
478 // shrink the dialog down to shown just these widgets
479 virtual void collapse(weld::Widget
* pEdit
, weld::Widget
* pButton
) = 0;
480 // undo previous dialog collapse
481 virtual void undo_collapse() = 0;
483 virtual void SetInstallLOKNotifierHdl(const Link
<void*, vcl::ILibreOfficeKitNotifier
*>& rLink
)
487 class VCL_DLLPUBLIC MessageDialog
: virtual public Dialog
490 virtual void set_primary_text(const OUString
& rText
) = 0;
491 virtual OUString
get_primary_text() const = 0;
492 virtual void set_secondary_text(const OUString
& rText
) = 0;
493 virtual OUString
get_secondary_text() const = 0;
494 virtual Container
* weld_message_area() = 0;
497 class VCL_DLLPUBLIC AboutDialog
: virtual public Dialog
500 virtual void set_version(const OUString
& rVersion
) = 0;
501 virtual void set_copyright(const OUString
& rCopyright
) = 0;
502 virtual void set_website(const OUString
& rURL
) = 0;
503 virtual void set_website_label(const OUString
& rLabel
) = 0;
504 virtual OUString
get_website_label() const = 0;
505 virtual void set_logo(const css::uno::Reference
<css::graphic::XGraphic
>& rImage
) = 0;
506 virtual void set_background(const css::uno::Reference
<css::graphic::XGraphic
>& rImage
) = 0;
509 class VCL_DLLPUBLIC Assistant
: virtual public Dialog
512 Link
<const OString
&, bool> m_aJumpPageHdl
;
514 bool signal_jump_page(const OString
& rIdent
) { return m_aJumpPageHdl
.Call(rIdent
); }
517 virtual int get_current_page() const = 0;
518 virtual int get_n_pages() const = 0;
519 virtual OString
get_page_ident(int nPage
) const = 0;
520 virtual OString
get_current_page_ident() const = 0;
521 virtual void set_current_page(int nPage
) = 0;
522 virtual void set_current_page(const OString
& rIdent
) = 0;
523 // move the page rIdent to position nIndex
524 virtual void set_page_index(const OString
& rIdent
, int nIndex
) = 0;
525 virtual void set_page_title(const OString
& rIdent
, const OUString
& rTitle
) = 0;
526 virtual OUString
get_page_title(const OString
& rIdent
) const = 0;
527 virtual void set_page_sensitive(const OString
& rIdent
, bool bSensitive
) = 0;
528 virtual weld::Container
* append_page(const OString
& rIdent
) = 0;
530 virtual void set_page_side_help_id(const OString
& rHelpId
) = 0;
532 void connect_jump_page(const Link
<const OString
&, bool>& rLink
) { m_aJumpPageHdl
= rLink
; }
535 struct VCL_DLLPUBLIC ComboBoxEntry
540 ComboBoxEntry(const OUString
& rString
)
544 ComboBoxEntry(const OUString
& rString
, const OUString
& rId
)
549 ComboBoxEntry(const OUString
& rString
, const OUString
& rId
, const OUString
& rImage
)
557 enum class EntryMessageType
564 /// A widget used to choose from a list of items.
565 class VCL_DLLPUBLIC ComboBox
: virtual public Container
568 OUString m_sSavedValue
;
571 Link
<ComboBox
&, void> m_aChangeHdl
;
572 Link
<ComboBox
&, void> m_aPopupToggledHdl
;
573 Link
<ComboBox
&, bool> m_aEntryActivateHdl
;
574 Link
<OUString
&, bool> m_aEntryInsertTextHdl
;
576 friend class ::LOKTrigger
;
578 void signal_changed() { m_aChangeHdl
.Call(*this); }
580 virtual void signal_popup_toggled() { m_aPopupToggledHdl
.Call(*this); }
583 virtual void insert(int pos
, const OUString
& rStr
, const OUString
* pId
,
584 const OUString
* pIconName
, VirtualDevice
* pImageSurface
)
586 virtual void insert_vector(const std::vector
<weld::ComboBoxEntry
>& rItems
, bool bKeepExisting
)
588 void insert_text(int pos
, const OUString
& rStr
)
590 insert(pos
, rStr
, nullptr, nullptr, nullptr);
592 void append_text(const OUString
& rStr
) { insert(-1, rStr
, nullptr, nullptr, nullptr); }
593 void append(const OUString
& rId
, const OUString
& rStr
)
595 insert(-1, rStr
, &rId
, nullptr, nullptr);
597 void append(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
599 insert(-1, rStr
, &rId
, &rImage
, nullptr);
601 void append(const OUString
& rId
, const OUString
& rStr
, VirtualDevice
& rImage
)
603 insert(-1, rStr
, &rId
, nullptr, &rImage
);
605 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
606 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
608 virtual int get_count() const = 0;
609 virtual void make_sorted() = 0;
610 virtual void clear() = 0;
613 virtual int get_active() const = 0;
614 virtual void set_active(int pos
) = 0;
615 virtual void remove(int pos
) = 0;
618 virtual OUString
get_active_text() const = 0;
619 void set_active_text(const OUString
& rStr
) { set_active(find_text(rStr
)); }
620 virtual OUString
get_text(int pos
) const = 0;
621 virtual int find_text(const OUString
& rStr
) const = 0;
622 void remove_text(const OUString
& rText
) { remove(find_text(rText
)); }
625 virtual OUString
get_active_id() const = 0;
626 virtual void set_active_id(const OUString
& rStr
) = 0;
627 virtual OUString
get_id(int pos
) const = 0;
628 virtual void set_id(int row
, const OUString
& rId
) = 0;
629 virtual int find_id(const OUString
& rId
) const = 0;
630 void remove_id(const OUString
& rId
) { remove(find_id(rId
)); }
632 void connect_changed(const Link
<ComboBox
&, void>& rLink
) { m_aChangeHdl
= rLink
; }
633 virtual void connect_popup_toggled(const Link
<ComboBox
&, void>& rLink
)
635 m_aPopupToggledHdl
= rLink
;
639 virtual bool has_entry() const = 0;
640 virtual void set_entry_message_type(EntryMessageType eType
) = 0;
641 virtual void set_entry_text(const OUString
& rStr
) = 0;
642 virtual void set_entry_width_chars(int nChars
) = 0;
643 virtual void set_entry_max_length(int nChars
) = 0;
644 virtual void select_entry_region(int nStartPos
, int nEndPos
) = 0;
645 virtual bool get_entry_selection_bounds(int& rStartPos
, int& rEndPos
) = 0;
646 virtual void set_entry_completion(bool bEnable
, bool bCaseSensitive
= false) = 0;
648 virtual bool get_popup_shown() const = 0;
650 void connect_entry_insert_text(const Link
<OUString
&, bool>& rLink
)
652 m_aEntryInsertTextHdl
= rLink
;
655 // callback returns true to indicated no further processing of activate wanted
656 void connect_entry_activate(const Link
<ComboBox
&, bool>& rLink
) { m_aEntryActivateHdl
= rLink
; }
658 void save_value() { m_sSavedValue
= get_active_text(); }
659 OUString
const& get_saved_value() const { return m_sSavedValue
; }
660 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_active_text(); }
663 class VCL_DLLPUBLIC TreeIter
666 TreeIter(const TreeIter
&) = delete;
667 TreeIter
& operator=(const TreeIter
&) = delete;
671 virtual bool equal(const TreeIter
& rOther
) const = 0;
672 virtual ~TreeIter() {}
675 class VCL_DLLPUBLIC TreeView
: virtual public Container
678 OUString m_sSavedValue
;
681 Link
<TreeView
&, void> m_aChangeHdl
;
682 Link
<TreeView
&, bool> m_aRowActivatedHdl
;
683 Link
<int, void> m_aColumnClickedHdl
;
684 Link
<const std::pair
<int, int>&, void> m_aRadioToggleHdl
;
685 Link
<const TreeIter
&, bool> m_aEditingStartedHdl
;
686 Link
<const std::pair
<const TreeIter
&, OUString
>&, bool> m_aEditingDoneHdl
;
687 // if handler returns false, the expansion of the row is refused
688 Link
<const TreeIter
&, bool> m_aExpandingHdl
;
689 Link
<TreeView
&, void> m_aVisibleRangeChangedHdl
;
690 Link
<TreeView
&, void> m_aModelChangedHdl
;
691 Link
<const CommandEvent
&, bool> m_aPopupMenuHdl
;
692 std::function
<int(const weld::TreeIter
&, const weld::TreeIter
&)> m_aCustomSort
;
694 std::vector
<int> m_aRadioIndexes
;
696 void signal_changed() { m_aChangeHdl
.Call(*this); }
697 bool signal_row_activated() { return m_aRowActivatedHdl
.Call(*this); }
698 void signal_column_clicked(int nColumn
) { m_aColumnClickedHdl
.Call(nColumn
); }
699 bool signal_expanding(const TreeIter
& rIter
)
701 return !m_aExpandingHdl
.IsSet() || m_aExpandingHdl
.Call(rIter
);
703 void signal_visible_range_changed() { m_aVisibleRangeChangedHdl
.Call(*this); }
704 void signal_model_changed() { m_aModelChangedHdl
.Call(*this); }
706 // arg is pair<row,col>
707 void signal_toggled(const std::pair
<int, int>& rRowCol
) { m_aRadioToggleHdl
.Call(rRowCol
); }
709 bool signal_editing_started(const TreeIter
& rIter
) { return m_aEditingStartedHdl
.Call(rIter
); }
711 bool signal_editing_done(const std::pair
<const TreeIter
&, OUString
>& rIterText
)
713 return m_aEditingDoneHdl
.Call(rIterText
);
717 virtual void insert(const TreeIter
* pParent
, int pos
, const OUString
* pStr
, const OUString
* pId
,
718 const OUString
* pIconName
, VirtualDevice
* pImageSurface
,
719 const OUString
* pExpanderName
, bool bChildrenOnDemand
, TreeIter
* pRet
)
722 void insert(int nRow
, TreeIter
* pRet
= nullptr)
724 insert(nullptr, nRow
, nullptr, nullptr, nullptr, nullptr, nullptr, false, pRet
);
727 void append(TreeIter
* pRet
= nullptr) { insert(-1, pRet
); }
729 void insert(int pos
, const OUString
& rStr
, const OUString
* pId
, const OUString
* pIconName
,
730 VirtualDevice
* pImageSurface
)
732 insert(nullptr, pos
, &rStr
, pId
, pIconName
, pImageSurface
, nullptr, false, nullptr);
734 void insert_text(int pos
, const OUString
& rStr
)
736 insert(nullptr, pos
, &rStr
, nullptr, nullptr, nullptr, nullptr, false, nullptr);
738 void append_text(const OUString
& rStr
)
740 insert(nullptr, -1, &rStr
, nullptr, nullptr, nullptr, nullptr, false, nullptr);
742 void append(const OUString
& rId
, const OUString
& rStr
)
744 insert(nullptr, -1, &rStr
, &rId
, nullptr, nullptr, nullptr, false, nullptr);
746 void append(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
748 insert(nullptr, -1, &rStr
, &rId
, &rImage
, nullptr, nullptr, false, nullptr);
750 void append(const TreeIter
* pParent
, const OUString
& rId
, const OUString
& rStr
,
751 const OUString
& rImage
)
753 insert(pParent
, -1, &rStr
, &rId
, &rImage
, nullptr, nullptr, false, nullptr);
755 void append(const TreeIter
* pParent
, const OUString
& rStr
)
757 insert(pParent
, -1, &rStr
, nullptr, nullptr, nullptr, nullptr, false, nullptr);
759 void append(const OUString
& rId
, const OUString
& rStr
, VirtualDevice
& rImage
)
761 insert(nullptr, -1, &rStr
, &rId
, nullptr, &rImage
, nullptr, false, nullptr);
764 void connect_changed(const Link
<TreeView
&, void>& rLink
) { m_aChangeHdl
= rLink
; }
766 /* A row is "activated" when the user double clicks a treeview row. It may
767 also be emitted when a row is selected and Space or Enter is pressed.
769 a return of "true" means the activation has been handled, a "false" propagates
770 the activation to the default handler which expands/collapses the row, if possible.
772 void connect_row_activated(const Link
<TreeView
&, bool>& rLink
) { m_aRowActivatedHdl
= rLink
; }
774 // Argument is a pair of row, col describing the node in non-tree mode.
775 // If in tree mode, then retrieve the toggled node with get_cursor
776 void connect_toggled(const Link
<const std::pair
<int, int>&, void>& rLink
)
778 m_aRadioToggleHdl
= rLink
;
781 void connect_column_clicked(const Link
<int, void>& rLink
) { m_aColumnClickedHdl
= rLink
; }
782 void connect_model_changed(const Link
<TreeView
&, void>& rLink
) { m_aModelChangedHdl
= rLink
; }
784 virtual OUString
get_selected_text() const = 0;
785 virtual OUString
get_selected_id() const = 0;
788 virtual int get_selected_index() const = 0;
789 virtual void select(int pos
) = 0;
790 virtual void unselect(int pos
) = 0;
791 virtual void remove(int pos
) = 0;
792 virtual OUString
get_text(int row
, int col
= -1) const = 0;
793 virtual void set_text(int row
, const OUString
& rText
, int col
= -1) = 0;
794 virtual void set_sensitive(int row
, bool bSensitive
, int col
= -1) = 0;
795 virtual void set_id(int row
, const OUString
& rId
) = 0;
796 virtual void set_toggle(int row
, TriState eState
, int col
) = 0;
797 virtual TriState
get_toggle(int row
, int col
) const = 0;
798 virtual void set_image(int row
, const OUString
& rImage
, int col
= -1) = 0;
799 virtual void set_image(int row
, VirtualDevice
& rImage
, int col
= -1) = 0;
800 virtual void set_image(int row
, const css::uno::Reference
<css::graphic::XGraphic
>& rImage
,
803 virtual void set_text_emphasis(int row
, bool bOn
, int col
) = 0;
804 virtual bool get_text_emphasis(int row
, int col
) const = 0;
805 virtual void swap(int pos1
, int pos2
) = 0;
806 virtual std::vector
<int> get_selected_rows() const = 0;
807 virtual void set_font_color(int pos
, const Color
& rColor
) const = 0;
808 virtual void scroll_to_row(int pos
) = 0;
809 virtual bool is_selected(int pos
) const = 0;
810 virtual int get_cursor_index() const = 0;
811 virtual void set_cursor(int pos
) = 0;
814 virtual int find_text(const OUString
& rText
) const = 0;
815 void select_text(const OUString
& rText
) { select(find_text(rText
)); }
816 void remove_text(const OUString
& rText
) { remove(find_text(rText
)); }
817 std::vector
<OUString
> get_selected_rows_text() const
819 std::vector
<int> aRows(get_selected_rows());
820 std::vector
<OUString
> aRet
;
821 aRet
.reserve(aRows
.size());
823 aRet
.push_back(get_text(a
));
828 virtual OUString
get_id(int pos
) const = 0;
829 virtual int find_id(const OUString
& rId
) const = 0;
830 void select_id(const OUString
& rId
) { select(find_id(rId
)); }
831 void remove_id(const OUString
& rText
) { remove(find_id(rText
)); }
834 virtual std::unique_ptr
<TreeIter
> make_iterator(const TreeIter
* pOrig
= nullptr) const = 0;
835 virtual void copy_iterator(const TreeIter
& rSource
, TreeIter
& rDest
) const = 0;
836 virtual bool get_selected(TreeIter
* pIter
) const = 0;
837 virtual bool get_cursor(TreeIter
* pIter
) const = 0;
838 virtual void set_cursor(const TreeIter
& rIter
) = 0;
839 virtual bool get_iter_first(TreeIter
& rIter
) const = 0;
840 // set iter to point to next node at the current level
841 virtual bool iter_next_sibling(TreeIter
& rIter
) const = 0;
842 // set iter to point to next node, depth first, then sibling
843 virtual bool iter_next(TreeIter
& rIter
) const = 0;
844 virtual bool iter_children(TreeIter
& rIter
) const = 0;
845 bool iter_nth_sibling(TreeIter
& rIter
, int nChild
) const
848 for (int i
= 0; i
< nChild
&& bRet
; ++i
)
849 bRet
= iter_next_sibling(rIter
);
852 bool iter_nth_child(TreeIter
& rIter
, int nChild
) const
854 if (!iter_children(rIter
))
856 return iter_nth_sibling(rIter
, nChild
);
858 virtual bool iter_parent(TreeIter
& rIter
) const = 0;
859 virtual int get_iter_depth(const TreeIter
& rIter
) const = 0;
860 virtual int get_iter_index_in_parent(const TreeIter
& rIter
) const = 0;
861 /* Compares two paths. If a appears before b in a tree, then -1 is returned.
862 If b appears before a , then 1 is returned. If the two nodes are equal,
865 virtual int iter_compare(const TreeIter
& a
, const TreeIter
& b
) const = 0;
866 virtual bool iter_has_child(const TreeIter
& rIter
) const = 0;
867 virtual void remove(const TreeIter
& rIter
) = 0;
868 virtual void select(const TreeIter
& rIter
) = 0;
869 virtual void unselect(const TreeIter
& rIter
) = 0;
870 virtual bool get_row_expanded(const TreeIter
& rIter
) const = 0;
871 virtual void expand_row(const TreeIter
& rIter
) = 0;
872 virtual void collapse_row(const TreeIter
& rIter
) = 0;
873 virtual void set_text(const TreeIter
& rIter
, const OUString
& rStr
, int col
= -1) = 0;
874 virtual void set_sensitive(const TreeIter
& rIter
, bool bSensitive
, int col
= -1) = 0;
875 virtual void set_text_emphasis(const TreeIter
& rIter
, bool bOn
, int col
) = 0;
876 virtual bool get_text_emphasis(const TreeIter
& rIter
, int col
) const = 0;
877 virtual void set_toggle(const TreeIter
& rIter
, TriState bOn
, int col
) = 0;
878 virtual TriState
get_toggle(const TreeIter
& rIter
, int col
) const = 0;
879 virtual OUString
get_text(const TreeIter
& rIter
, int col
= -1) const = 0;
880 virtual void set_id(const TreeIter
& rIter
, const OUString
& rId
) = 0;
881 virtual OUString
get_id(const TreeIter
& rIter
) const = 0;
882 virtual void set_image(const TreeIter
& rIter
, const OUString
& rImage
, int col
= -1) = 0;
883 virtual void set_image(const TreeIter
& rIter
, VirtualDevice
& rImage
, int col
= -1) = 0;
884 virtual void set_image(const TreeIter
& rIter
,
885 const css::uno::Reference
<css::graphic::XGraphic
>& rImage
, int col
= -1)
887 virtual void set_font_color(const TreeIter
& rIter
, const Color
& rColor
) const = 0;
888 virtual void scroll_to_row(const TreeIter
& rIter
) = 0;
889 virtual bool is_selected(const TreeIter
& rIter
) const = 0;
891 virtual void move_subtree(TreeIter
& rNode
, const TreeIter
* pNewParent
, int nIndexInNewParent
)
894 // call func on each element until func returns true or we run out of elements
895 virtual void all_foreach(const std::function
<bool(TreeIter
&)>& func
) = 0;
896 // call func on each selected element until func returns true or we run out of elements
897 virtual void selected_foreach(const std::function
<bool(TreeIter
&)>& func
) = 0;
898 // call func on each visible element until func returns true or we run out of elements
899 virtual void visible_foreach(const std::function
<bool(TreeIter
&)>& func
) = 0;
900 // clear the tree, then add nSourceCount rows, call func on each row
901 // inserted with an arg of the index that this row will be when bulk insert
904 // this enables inserting the entries backwards in models where that is faster,
906 // pFixedWidths is optional, when present each matching entry col text
907 // width will not be measured, and the fixed width used instead. Use
908 // sparingly because wider text than the fixed width is clipped and cannot
909 // be scrolled into view horizontally.
910 virtual void bulk_insert_for_each(int nSourceCount
,
911 const std::function
<void(TreeIter
&, int nSourceIndex
)>& func
,
912 const std::vector
<int>* pFixedWidths
= nullptr)
915 void connect_expanding(const Link
<const TreeIter
&, bool>& rLink
) { m_aExpandingHdl
= rLink
; }
917 // rStartLink returns true to allow editing, false to disallow
918 // rEndLink returns true to accept the edit, false to reject
920 connect_editing(const Link
<const TreeIter
&, bool>& rStartLink
,
921 const Link
<const std::pair
<const TreeIter
&, OUString
>&, bool>& rEndLink
)
923 assert(rStartLink
.IsSet() == rEndLink
.IsSet() && "should be both on or both off");
924 m_aEditingStartedHdl
= rStartLink
;
925 m_aEditingDoneHdl
= rEndLink
;
928 virtual void start_editing(const weld::TreeIter
& rEntry
) = 0;
929 virtual void end_editing() = 0;
931 virtual void connect_visible_range_changed(const Link
<TreeView
&, void>& rLink
)
933 assert(!m_aVisibleRangeChangedHdl
.IsSet() || !rLink
.IsSet());
934 m_aVisibleRangeChangedHdl
= rLink
;
937 virtual void connect_popup_menu(const Link
<const CommandEvent
&, bool>& rLink
)
939 m_aPopupMenuHdl
= rLink
;
943 void select_all() { unselect(-1); }
944 void unselect_all() { select(-1); }
946 // return the number of toplevel nodes
947 virtual int n_children() const = 0;
949 virtual void make_sorted() = 0;
950 virtual void make_unsorted() = 0;
951 virtual bool get_sort_order() const = 0;
952 virtual void set_sort_order(bool bAscending
) = 0;
954 // TRUE ascending, FALSE, descending, INDET, neither (off)
955 virtual void set_sort_indicator(TriState eState
, int nColumn
= -1) = 0;
956 virtual TriState
get_sort_indicator(int nColumn
= -1) const = 0;
958 virtual int get_sort_column() const = 0;
959 virtual void set_sort_column(int nColumn
) = 0;
962 set_sort_func(const std::function
<int(const weld::TreeIter
&, const weld::TreeIter
&)>& func
)
964 m_aCustomSort
= func
;
967 virtual void clear() = 0;
968 virtual int get_height_rows(int nRows
) const = 0;
970 virtual void columns_autosize() = 0;
971 virtual void set_column_fixed_widths(const std::vector
<int>& rWidths
) = 0;
972 virtual int get_column_width(int nCol
) const = 0;
973 virtual void set_centered_column(int nCol
) = 0;
974 virtual OUString
get_column_title(int nColumn
) const = 0;
975 virtual void set_column_title(int nColumn
, const OUString
& rTitle
) = 0;
977 int get_checkbox_column_width() const { return get_approximate_digit_width() * 3 + 6; }
979 virtual void set_selection_mode(SelectionMode eMode
) = 0;
980 virtual int count_selected_rows() const = 0;
981 // remove the selected nodes
982 virtual void remove_selection() = 0;
984 void set_toggle_columns_as_radio(const std::vector
<int>& rCols
) { m_aRadioIndexes
= rCols
; }
986 void save_value() { m_sSavedValue
= get_selected_text(); }
987 OUString
const& get_saved_value() const { return m_sSavedValue
; }
988 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_selected_text(); }
991 virtual bool get_dest_row_at_pos(const Point
& rPos
, weld::TreeIter
* pResult
) = 0;
992 // for dragging and dropping between TreeViews, return the active source
993 virtual TreeView
* get_drag_source() const = 0;
995 using Widget::set_sensitive
;
998 class VCL_DLLPUBLIC IconView
: virtual public Container
1001 OUString m_sSavedValue
;
1004 Link
<IconView
&, void> m_aSelectionChangeHdl
;
1005 Link
<IconView
&, bool> m_aItemActivatedHdl
;
1007 void signal_selection_changed() { m_aSelectionChangeHdl
.Call(*this); }
1008 bool signal_item_activated() { return m_aItemActivatedHdl
.Call(*this); }
1011 virtual void insert(int pos
, const OUString
* pStr
, const OUString
* pId
,
1012 const OUString
* pIconName
, TreeIter
* pRet
)
1015 void append(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
1017 insert(-1, &rStr
, &rId
, &rImage
, nullptr);
1020 void connect_selection_changed(const Link
<IconView
&, void>& rLink
)
1022 m_aSelectionChangeHdl
= rLink
;
1025 /* A row is "activated" when the user double clicks a treeview row. It may
1026 also be emitted when a row is selected and Space or Enter is pressed.
1028 a return of "true" means the activation has been handled, a "false" propagates
1029 the activation to the default handler which expands/collapses the row, if possible.
1031 void connect_item_activated(const Link
<IconView
&, bool>& rLink
) { m_aItemActivatedHdl
= rLink
; }
1033 virtual OUString
get_selected_id() const = 0;
1035 virtual void clear() = 0;
1037 virtual int count_selected_items() const = 0;
1039 virtual OUString
get_selected_text() const = 0;
1042 virtual void select(int pos
) = 0;
1043 virtual void unselect(int pos
) = 0;
1046 virtual std::unique_ptr
<TreeIter
> make_iterator(const TreeIter
* pOrig
= nullptr) const = 0;
1047 virtual bool get_selected(TreeIter
* pIter
) const = 0;
1048 virtual bool get_cursor(TreeIter
* pIter
) const = 0;
1049 virtual void set_cursor(const TreeIter
& rIter
) = 0;
1050 virtual bool get_iter_first(TreeIter
& rIter
) const = 0;
1051 virtual OUString
get_id(const TreeIter
& rIter
) const = 0;
1052 virtual void scroll_to_item(const TreeIter
& rIter
) = 0;
1054 // call func on each selected element until func returns true or we run out of elements
1055 virtual void selected_foreach(const std::function
<bool(TreeIter
&)>& func
) = 0;
1058 void select_all() { unselect(-1); }
1059 void unselect_all() { select(-1); }
1061 // return the number of toplevel nodes
1062 virtual int n_children() const = 0;
1064 void save_value() { m_sSavedValue
= get_selected_text(); }
1065 OUString
const& get_saved_value() const { return m_sSavedValue
; }
1066 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_selected_text(); }
1069 class VCL_DLLPUBLIC Button
: virtual public Container
1072 Link
<Button
&, void> m_aClickHdl
;
1074 void signal_clicked() { m_aClickHdl
.Call(*this); }
1077 virtual void set_label(const OUString
& rText
) = 0;
1078 // pDevice, the image for the button, or nullptr to unset
1079 virtual void set_image(VirtualDevice
* pDevice
) = 0;
1080 virtual void set_image(const css::uno::Reference
<css::graphic::XGraphic
>& rImage
) = 0;
1081 virtual void set_from_icon_name(const OUString
& rIconName
) = 0;
1082 virtual OUString
get_label() const = 0;
1083 virtual void set_label_line_wrap(bool wrap
) = 0;
1084 void clicked() { signal_clicked(); }
1086 void connect_clicked(const Link
<Button
&, void>& rLink
) { m_aClickHdl
= rLink
; }
1089 class VCL_DLLPUBLIC ToggleButton
: virtual public Button
1092 Link
<ToggleButton
&, void> m_aToggleHdl
;
1093 TriState m_eSavedValue
= TRISTATE_FALSE
;
1095 void signal_toggled() { m_aToggleHdl
.Call(*this); }
1098 virtual void set_active(bool active
) = 0;
1099 virtual bool get_active() const = 0;
1101 virtual void set_inconsistent(bool inconsistent
) = 0;
1102 virtual bool get_inconsistent() const = 0;
1104 TriState
get_state() const
1106 if (get_inconsistent())
1107 return TRISTATE_INDET
;
1108 else if (get_active())
1109 return TRISTATE_TRUE
;
1110 return TRISTATE_FALSE
;
1113 void set_state(TriState eState
)
1117 case TRISTATE_INDET
:
1118 set_inconsistent(true);
1121 set_inconsistent(false);
1124 case TRISTATE_FALSE
:
1125 set_inconsistent(false);
1131 void save_state() { m_eSavedValue
= get_state(); }
1132 TriState
get_saved_state() const { return m_eSavedValue
; }
1133 bool get_state_changed_from_saved() const { return m_eSavedValue
!= get_state(); }
1135 virtual void connect_toggled(const Link
<ToggleButton
&, void>& rLink
) { m_aToggleHdl
= rLink
; }
1138 struct VCL_DLLPUBLIC TriStateEnabled
1141 bool bTriStateEnabled
;
1143 : eState(TRISTATE_INDET
)
1144 , bTriStateEnabled(true)
1147 void ButtonToggled(ToggleButton
& rToggle
);
1150 class VCL_DLLPUBLIC MenuButton
: virtual public ToggleButton
1153 Link
<const OString
&, void> m_aSelectHdl
;
1155 void signal_selected(const OString
& rIdent
) { m_aSelectHdl
.Call(rIdent
); }
1158 void connect_selected(const Link
<const OString
&, void>& rLink
) { m_aSelectHdl
= rLink
; }
1160 virtual void insert_item(int pos
, const OUString
& rId
, const OUString
& rStr
,
1161 const OUString
* pIconName
, VirtualDevice
* pImageSufface
, bool bCheck
)
1163 void append_item(const OUString
& rId
, const OUString
& rStr
)
1165 insert_item(-1, rId
, rStr
, nullptr, nullptr, false);
1167 void append_item_check(const OUString
& rId
, const OUString
& rStr
)
1169 insert_item(-1, rId
, rStr
, nullptr, nullptr, true);
1171 void append_item(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
1173 insert_item(-1, rId
, rStr
, &rImage
, nullptr, false);
1175 void append_item(const OUString
& rId
, const OUString
& rStr
, VirtualDevice
& rImage
)
1177 insert_item(-1, rId
, rStr
, nullptr, &rImage
, false);
1179 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
1180 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
1181 virtual void remove_item(const OString
& rId
) = 0;
1182 virtual void clear() = 0;
1183 virtual void set_item_sensitive(const OString
& rIdent
, bool bSensitive
) = 0;
1184 virtual void set_item_active(const OString
& rIdent
, bool bActive
) = 0;
1185 virtual void set_item_label(const OString
& rIdent
, const OUString
& rLabel
) = 0;
1186 virtual OUString
get_item_label(const OString
& rIdent
) const = 0;
1187 virtual void set_item_help_id(const OString
& rIdent
, const OString
& rHelpId
) = 0;
1188 virtual void set_item_visible(const OString
& rIdent
, bool bVisible
) = 0;
1189 virtual OString
get_item_help_id(const OString
& rIdent
) const = 0;
1191 virtual void set_popover(weld::Widget
* pPopover
) = 0;
1194 class VCL_DLLPUBLIC CheckButton
: virtual public ToggleButton
1198 class VCL_DLLPUBLIC RadioButton
: virtual public ToggleButton
1202 class VCL_DLLPUBLIC LinkButton
: virtual public Container
1205 Link
<LinkButton
&, bool> m_aActivateLinkHdl
;
1207 bool signal_activate_link() { return m_aActivateLinkHdl
.Call(*this); }
1210 virtual void set_label(const OUString
& rText
) = 0;
1211 virtual OUString
get_label() const = 0;
1212 virtual void set_uri(const OUString
& rUri
) = 0;
1213 virtual OUString
get_uri() const = 0;
1215 void connect_activate_link(const Link
<LinkButton
&, bool>& rLink
) { m_aActivateLinkHdl
= rLink
; }
1218 class VCL_DLLPUBLIC Scale
: virtual public Widget
1221 Link
<Scale
&, void> m_aValueChangedHdl
;
1223 void signal_value_changed() { m_aValueChangedHdl
.Call(*this); }
1226 virtual void set_value(int value
) = 0;
1227 virtual int get_value() const = 0;
1228 virtual void set_range(int min
, int max
) = 0;
1229 void connect_value_changed(const Link
<Scale
&, void>& rLink
) { m_aValueChangedHdl
= rLink
; }
1232 class VCL_DLLPUBLIC Spinner
: virtual public Widget
1235 virtual void start() = 0;
1236 virtual void stop() = 0;
1239 class VCL_DLLPUBLIC ProgressBar
: virtual public Widget
1243 virtual void set_percentage(int value
) = 0;
1244 virtual OUString
get_text() const = 0;
1245 virtual void set_text(const OUString
& rText
) = 0;
1248 class VCL_DLLPUBLIC Entry
: virtual public Widget
1251 OUString m_sSavedValue
;
1254 Link
<Entry
&, void> m_aChangeHdl
;
1255 Link
<OUString
&, bool> m_aInsertTextHdl
;
1256 Link
<Entry
&, void> m_aCursorPositionHdl
;
1257 Link
<Entry
&, bool> m_aActivateHdl
;
1259 friend class ::LOKTrigger
;
1261 void signal_changed() { m_aChangeHdl
.Call(*this); }
1262 void signal_cursor_position() { m_aCursorPositionHdl
.Call(*this); }
1263 void signal_insert_text(OUString
& rString
);
1266 virtual void set_text(const OUString
& rText
) = 0;
1267 virtual OUString
get_text() const = 0;
1268 virtual void set_width_chars(int nChars
) = 0;
1269 virtual int get_width_chars() const = 0;
1270 // The maximum length of the entry. Use 0 for no maximum
1271 virtual void set_max_length(int nChars
) = 0;
1272 // nEndPos can be -1 in order to select all text
1273 virtual void select_region(int nStartPos
, int nEndPos
) = 0;
1274 // returns true if the selection has nonzero length
1275 virtual bool get_selection_bounds(int& rStartPos
, int& rEndPos
) = 0;
1276 virtual void replace_selection(const OUString
& rText
) = 0;
1277 // nCursorPos can be -1 to set to the end
1278 virtual void set_position(int nCursorPos
) = 0;
1279 virtual int get_position() const = 0;
1280 virtual void set_editable(bool bEditable
) = 0;
1281 virtual bool get_editable() const = 0;
1282 virtual void set_message_type(EntryMessageType eType
) = 0;
1284 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
1285 virtual void set_font(const vcl::Font
& rFont
) = 0;
1287 void connect_changed(const Link
<Entry
&, void>& rLink
) { m_aChangeHdl
= rLink
; }
1288 void connect_insert_text(const Link
<OUString
&, bool>& rLink
) { m_aInsertTextHdl
= rLink
; }
1289 // callback returns true to indicated no further processing of activate wanted
1290 void connect_activate(const Link
<Entry
&, bool>& rLink
) { m_aActivateHdl
= rLink
; }
1291 virtual void connect_cursor_position(const Link
<Entry
&, void>& rLink
)
1293 m_aCursorPositionHdl
= rLink
;
1296 virtual void cut_clipboard() = 0;
1297 virtual void copy_clipboard() = 0;
1298 virtual void paste_clipboard() = 0;
1300 void save_value() { m_sSavedValue
= get_text(); }
1301 OUString
const& get_saved_value() const { return m_sSavedValue
; }
1302 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_text(); }
1305 class VCL_DLLPUBLIC SpinButton
: virtual public Entry
1308 Link
<SpinButton
&, void> m_aValueChangedHdl
;
1309 Link
<SpinButton
&, void> m_aOutputHdl
;
1310 Link
<int*, bool> m_aInputHdl
;
1312 void signal_value_changed() { m_aValueChangedHdl
.Call(*this); }
1314 bool signal_output()
1316 if (!m_aOutputHdl
.IsSet())
1318 m_aOutputHdl
.Call(*this);
1322 TriState
signal_input(int* result
)
1324 if (!m_aInputHdl
.IsSet())
1325 return TRISTATE_INDET
;
1326 return m_aInputHdl
.Call(result
) ? TRISTATE_TRUE
: TRISTATE_FALSE
;
1330 virtual void set_value(int value
) = 0;
1331 virtual int get_value() const = 0;
1332 virtual void set_range(int min
, int max
) = 0;
1333 virtual void get_range(int& min
, int& max
) const = 0;
1334 void set_min(int min
)
1337 get_range(dummy
, max
);
1338 set_range(min
, max
);
1340 void set_max(int max
)
1343 get_range(min
, dummy
);
1344 set_range(min
, max
);
1349 get_range(min
, dummy
);
1355 get_range(dummy
, max
);
1358 virtual void set_increments(int step
, int page
) = 0;
1359 virtual void get_increments(int& step
, int& page
) const = 0;
1360 virtual void set_digits(unsigned int digits
) = 0;
1361 virtual unsigned int get_digits() const = 0;
1363 void connect_value_changed(const Link
<SpinButton
&, void>& rLink
) { m_aValueChangedHdl
= rLink
; }
1365 void connect_output(const Link
<SpinButton
&, void>& rLink
) { m_aOutputHdl
= rLink
; }
1366 void connect_input(const Link
<int*, bool>& rLink
) { m_aInputHdl
= rLink
; }
1368 int normalize(int nValue
) const { return (nValue
* Power10(get_digits())); }
1370 int denormalize(int nValue
) const;
1372 static unsigned int Power10(unsigned int n
);
1375 class VCL_DLLPUBLIC FormattedSpinButton
: virtual public Entry
1378 Link
<FormattedSpinButton
&, void> m_aValueChangedHdl
;
1380 void signal_value_changed() { m_aValueChangedHdl
.Call(*this); }
1383 virtual void set_value(double value
) = 0;
1384 virtual double get_value() const = 0;
1385 virtual void set_range(double min
, double max
) = 0;
1386 virtual void get_range(double& min
, double& max
) const = 0;
1388 void set_max(double max
)
1391 get_range(min
, dummy
);
1392 set_range(min
, max
);
1395 virtual void set_formatter(SvNumberFormatter
* pFormatter
) = 0;
1396 virtual sal_Int32
get_format_key() const = 0;
1397 virtual void set_format_key(sal_Int32 nFormatKey
) = 0;
1399 void connect_value_changed(const Link
<FormattedSpinButton
&, void>& rLink
)
1401 m_aValueChangedHdl
= rLink
;
1405 class VCL_DLLPUBLIC Image
: virtual public Widget
1408 virtual void set_from_icon_name(const OUString
& rIconName
) = 0;
1409 virtual void set_image(VirtualDevice
* pDevice
) = 0;
1410 virtual void set_image(const css::uno::Reference
<css::graphic::XGraphic
>& rImage
) = 0;
1413 class VCL_DLLPUBLIC Calendar
: virtual public Widget
1416 Link
<Calendar
&, void> m_aSelectedHdl
;
1417 Link
<Calendar
&, void> m_aActivatedHdl
;
1419 void signal_selected() { m_aSelectedHdl
.Call(*this); }
1420 void signal_activated() { m_aActivatedHdl
.Call(*this); }
1423 void connect_selected(const Link
<Calendar
&, void>& rLink
) { m_aSelectedHdl
= rLink
; }
1424 void connect_activated(const Link
<Calendar
&, void>& rLink
) { m_aActivatedHdl
= rLink
; }
1426 virtual void set_date(const Date
& rDate
) = 0;
1427 virtual Date
get_date() const = 0;
1430 // an entry + treeview pair, where the entry autocompletes from the
1431 // treeview list, and selecting something in the list sets the
1432 // entry to that text, i.e. a visually exploded ComboBox
1433 class VCL_DLLPUBLIC EntryTreeView
: virtual public ComboBox
1436 DECL_DLLPRIVATE_LINK(ClickHdl
, weld::TreeView
&, void);
1437 DECL_DLLPRIVATE_LINK(ModifyHdl
, weld::Entry
&, void);
1438 void EntryModifyHdl(const weld::Entry
& rEntry
);
1441 std::unique_ptr
<Entry
> m_xEntry
;
1442 std::unique_ptr
<TreeView
> m_xTreeView
;
1445 EntryTreeView(std::unique_ptr
<Entry
> xEntry
, std::unique_ptr
<TreeView
> xTreeView
);
1447 virtual void insert_vector(const std::vector
<weld::ComboBoxEntry
>& rItems
,
1448 bool bKeepExisting
) override
1450 m_xTreeView
->freeze();
1452 m_xTreeView
->clear();
1453 for (const auto& rItem
: rItems
)
1455 m_xTreeView
->insert(-1, rItem
.sString
, rItem
.sId
.isEmpty() ? nullptr : &rItem
.sId
,
1456 rItem
.sImage
.isEmpty() ? nullptr : &rItem
.sImage
, nullptr);
1458 m_xTreeView
->thaw();
1461 virtual void insert(int pos
, const OUString
& rStr
, const OUString
* pId
,
1462 const OUString
* pIconName
, VirtualDevice
* pImageSurface
) override
1464 m_xTreeView
->insert(pos
, rStr
, pId
, pIconName
, pImageSurface
);
1467 virtual int get_count() const override
{ return m_xTreeView
->n_children(); }
1468 virtual void clear() override
{ m_xTreeView
->clear(); }
1471 virtual int get_active() const override
{ return m_xTreeView
->get_selected_index(); }
1472 virtual void set_active(int pos
) override
1474 m_xTreeView
->set_cursor(pos
);
1475 m_xTreeView
->select(pos
);
1476 m_xEntry
->set_text(m_xTreeView
->get_selected_text());
1478 virtual void remove(int pos
) override
{ m_xTreeView
->remove(pos
); }
1481 virtual OUString
get_active_text() const override
{ return m_xEntry
->get_text(); }
1482 virtual OUString
get_text(int pos
) const override
{ return m_xTreeView
->get_text(pos
); }
1483 virtual int find_text(const OUString
& rStr
) const override
1485 return m_xTreeView
->find_text(rStr
);
1489 virtual OUString
get_active_id() const override
{ return m_xTreeView
->get_selected_id(); }
1490 virtual void set_active_id(const OUString
& rStr
) override
1492 m_xTreeView
->select_id(rStr
);
1493 m_xEntry
->set_text(m_xTreeView
->get_selected_text());
1495 virtual OUString
get_id(int pos
) const override
{ return m_xTreeView
->get_id(pos
); }
1496 virtual void set_id(int pos
, const OUString
& rId
) override
{ m_xTreeView
->set_id(pos
, rId
); }
1497 virtual int find_id(const OUString
& rId
) const override
{ return m_xTreeView
->find_id(rId
); }
1500 virtual bool has_entry() const override
{ return true; }
1501 virtual void set_entry_message_type(EntryMessageType eType
) override
1503 m_xEntry
->set_message_type(eType
);
1505 virtual void set_entry_text(const OUString
& rStr
) override
{ m_xEntry
->set_text(rStr
); }
1506 virtual void set_entry_width_chars(int nChars
) override
{ m_xEntry
->set_width_chars(nChars
); }
1507 virtual void set_entry_max_length(int nChars
) override
{ m_xEntry
->set_max_length(nChars
); }
1508 virtual void select_entry_region(int nStartPos
, int nEndPos
) override
1510 m_xEntry
->select_region(nStartPos
, nEndPos
);
1512 //if not text was selected, both rStartPos and rEndPos will be identical
1513 //and false will be returned
1514 virtual bool get_entry_selection_bounds(int& rStartPos
, int& rEndPos
) override
1516 return m_xEntry
->get_selection_bounds(rStartPos
, rEndPos
);
1518 void connect_row_activated(const Link
<TreeView
&, bool>& rLink
)
1520 m_xTreeView
->connect_row_activated(rLink
);
1523 virtual bool get_popup_shown() const override
{ return false; }
1525 void set_height_request_by_rows(int nRows
);
1528 class VCL_DLLPUBLIC MetricSpinButton final
1530 FieldUnit m_eSrcUnit
;
1531 std::unique_ptr
<weld::SpinButton
> m_xSpinButton
;
1532 Link
<MetricSpinButton
&, void> m_aValueChangedHdl
;
1534 DECL_LINK(spin_button_value_changed
, weld::SpinButton
&, void);
1535 DECL_LINK(spin_button_output
, weld::SpinButton
&, void);
1536 DECL_LINK(spin_button_input
, int* result
, bool);
1538 void signal_value_changed() { m_aValueChangedHdl
.Call(*this); }
1540 int ConvertValue(int nValue
, FieldUnit eInUnit
, FieldUnit eOutUnit
) const;
1541 OUString
format_number(int nValue
) const;
1542 void update_width_chars();
1545 MetricSpinButton(std::unique_ptr
<SpinButton
> pSpinButton
, FieldUnit eSrcUnit
)
1546 : m_eSrcUnit(eSrcUnit
)
1547 , m_xSpinButton(std::move(pSpinButton
))
1549 update_width_chars();
1550 m_xSpinButton
->connect_output(LINK(this, MetricSpinButton
, spin_button_output
));
1551 m_xSpinButton
->connect_input(LINK(this, MetricSpinButton
, spin_button_input
));
1552 m_xSpinButton
->connect_value_changed(
1553 LINK(this, MetricSpinButton
, spin_button_value_changed
));
1554 spin_button_output(*m_xSpinButton
);
1557 static OUString
MetricToString(FieldUnit rUnit
);
1559 FieldUnit
get_unit() const { return m_eSrcUnit
; }
1561 void set_unit(FieldUnit eUnit
);
1563 int convert_value_to(int nValue
, FieldUnit eValueUnit
) const
1565 return ConvertValue(nValue
, m_eSrcUnit
, eValueUnit
);
1568 int convert_value_from(int nValue
, FieldUnit eValueUnit
) const
1570 return ConvertValue(nValue
, eValueUnit
, m_eSrcUnit
);
1573 void set_value(int nValue
, FieldUnit eValueUnit
)
1575 m_xSpinButton
->set_value(convert_value_from(nValue
, eValueUnit
));
1578 int get_value(FieldUnit eDestUnit
) const
1580 return convert_value_to(m_xSpinButton
->get_value(), eDestUnit
);
1583 // typically you only need to call this if set_text (e.g. with "") was
1584 // previously called to display some arbitrary text instead of the
1585 // formatted value and now you want to show it as formatted again
1586 void reformat() { spin_button_output(*m_xSpinButton
); }
1588 void set_range(int min
, int max
, FieldUnit eValueUnit
)
1590 min
= convert_value_from(min
, eValueUnit
);
1591 max
= convert_value_from(max
, eValueUnit
);
1592 m_xSpinButton
->set_range(min
, max
);
1593 update_width_chars();
1596 void get_range(int& min
, int& max
, FieldUnit eDestUnit
) const
1598 m_xSpinButton
->get_range(min
, max
);
1599 min
= convert_value_to(min
, eDestUnit
);
1600 max
= convert_value_to(max
, eDestUnit
);
1603 void set_min(int min
, FieldUnit eValueUnit
)
1606 get_range(dummy
, max
, eValueUnit
);
1607 set_range(min
, max
, eValueUnit
);
1610 void set_max(int max
, FieldUnit eValueUnit
)
1613 get_range(min
, dummy
, eValueUnit
);
1614 set_range(min
, max
, eValueUnit
);
1617 int get_min(FieldUnit eValueUnit
) const
1620 get_range(min
, dummy
, eValueUnit
);
1624 int get_max(FieldUnit eValueUnit
) const
1627 get_range(dummy
, max
, eValueUnit
);
1631 void set_increments(int step
, int page
, FieldUnit eValueUnit
)
1633 step
= convert_value_from(step
, eValueUnit
);
1634 page
= convert_value_from(page
, eValueUnit
);
1635 m_xSpinButton
->set_increments(step
, page
);
1638 void get_increments(int& step
, int& page
, FieldUnit eDestUnit
) const
1640 m_xSpinButton
->get_increments(step
, page
);
1641 step
= convert_value_to(step
, eDestUnit
);
1642 page
= convert_value_to(page
, eDestUnit
);
1645 void connect_value_changed(const Link
<MetricSpinButton
&, void>& rLink
)
1647 m_aValueChangedHdl
= rLink
;
1650 int normalize(int nValue
) const { return m_xSpinButton
->normalize(nValue
); }
1651 int denormalize(int nValue
) const { return m_xSpinButton
->denormalize(nValue
); }
1652 void set_sensitive(bool sensitive
) { m_xSpinButton
->set_sensitive(sensitive
); }
1653 bool get_sensitive() const { return m_xSpinButton
->get_sensitive(); }
1654 bool get_visible() const { return m_xSpinButton
->get_visible(); }
1655 void grab_focus() { m_xSpinButton
->grab_focus(); }
1656 bool has_focus() const { return m_xSpinButton
->has_focus(); }
1657 void show() { m_xSpinButton
->show(); }
1658 void set_visible(bool bShow
) { m_xSpinButton
->set_visible(bShow
); }
1659 void hide() { m_xSpinButton
->hide(); }
1660 void set_digits(unsigned int digits
);
1661 void set_accessible_name(const OUString
& rName
) { m_xSpinButton
->set_accessible_name(rName
); }
1662 unsigned int get_digits() const { return m_xSpinButton
->get_digits(); }
1663 void save_value() { m_xSpinButton
->save_value(); }
1664 bool get_value_changed_from_saved() const
1666 return m_xSpinButton
->get_value_changed_from_saved();
1668 void set_text(const OUString
& rText
) { m_xSpinButton
->set_text(rText
); }
1669 OUString
get_text() const { return m_xSpinButton
->get_text(); }
1670 void set_size_request(int nWidth
, int nHeight
)
1672 m_xSpinButton
->set_size_request(nWidth
, nHeight
);
1674 Size
get_size_request() const { return m_xSpinButton
->get_size_request(); }
1675 Size
get_preferred_size() const { return m_xSpinButton
->get_preferred_size(); }
1676 void connect_focus_in(const Link
<Widget
&, void>& rLink
)
1678 m_xSpinButton
->connect_focus_in(rLink
);
1680 void connect_focus_out(const Link
<Widget
&, void>& rLink
)
1682 m_xSpinButton
->connect_focus_out(rLink
);
1684 OString
get_buildable_name() { return m_xSpinButton
->get_buildable_name(); }
1685 void set_help_id(const OString
& rName
) { m_xSpinButton
->set_help_id(rName
); }
1686 void set_position(int nCursorPos
) { m_xSpinButton
->set_position(nCursorPos
); }
1687 weld::SpinButton
& get_widget() { return *m_xSpinButton
; }
1690 class VCL_DLLPUBLIC TimeSpinButton final
1692 TimeFieldFormat
const m_eFormat
;
1693 std::unique_ptr
<weld::SpinButton
> m_xSpinButton
;
1694 Link
<TimeSpinButton
&, void> m_aValueChangedHdl
;
1696 DECL_LINK(spin_button_value_changed
, weld::SpinButton
&, void);
1697 DECL_LINK(spin_button_output
, weld::SpinButton
&, void);
1698 DECL_LINK(spin_button_input
, int* result
, bool);
1699 DECL_LINK(spin_button_cursor_position
, weld::Entry
&, void);
1701 void signal_value_changed() { m_aValueChangedHdl
.Call(*this); }
1703 static tools::Time
ConvertValue(int nValue
);
1704 static int ConvertValue(const tools::Time
& rTime
);
1705 OUString
format_number(int nValue
) const;
1706 void update_width_chars();
1709 TimeSpinButton(std::unique_ptr
<SpinButton
> pSpinButton
, TimeFieldFormat eFormat
)
1710 : m_eFormat(eFormat
)
1711 , m_xSpinButton(std::move(pSpinButton
))
1713 update_width_chars();
1714 m_xSpinButton
->connect_output(LINK(this, TimeSpinButton
, spin_button_output
));
1715 m_xSpinButton
->connect_input(LINK(this, TimeSpinButton
, spin_button_input
));
1716 m_xSpinButton
->connect_value_changed(LINK(this, TimeSpinButton
, spin_button_value_changed
));
1717 m_xSpinButton
->connect_cursor_position(
1718 LINK(this, TimeSpinButton
, spin_button_cursor_position
));
1719 spin_button_output(*m_xSpinButton
);
1722 void set_value(const tools::Time
& rTime
) { m_xSpinButton
->set_value(ConvertValue(rTime
)); }
1724 tools::Time
get_value() const { return ConvertValue(m_xSpinButton
->get_value()); }
1726 void connect_value_changed(const Link
<TimeSpinButton
&, void>& rLink
)
1728 m_aValueChangedHdl
= rLink
;
1731 void set_sensitive(bool sensitive
) { m_xSpinButton
->set_sensitive(sensitive
); }
1732 bool get_sensitive() const { return m_xSpinButton
->get_sensitive(); }
1733 void set_visible(bool bShow
) { m_xSpinButton
->set_visible(bShow
); }
1734 bool get_visible() const { return m_xSpinButton
->get_visible(); }
1735 void grab_focus() { m_xSpinButton
->grab_focus(); }
1736 bool has_focus() const { return m_xSpinButton
->has_focus(); }
1737 void show() { m_xSpinButton
->show(); }
1738 void hide() { m_xSpinButton
->hide(); }
1739 void save_value() { m_xSpinButton
->save_value(); }
1740 bool get_value_changed_from_saved() const
1742 return m_xSpinButton
->get_value_changed_from_saved();
1744 void set_position(int nCursorPos
) { m_xSpinButton
->set_position(nCursorPos
); }
1745 void set_text(const OUString
& rText
) { m_xSpinButton
->set_text(rText
); }
1746 OUString
get_text() const { return m_xSpinButton
->get_text(); }
1747 weld::SpinButton
& get_widget() { return *m_xSpinButton
; }
1750 class VCL_DLLPUBLIC Label
: virtual public Widget
1753 virtual void set_label(const OUString
& rText
) = 0;
1754 virtual OUString
get_label() const = 0;
1755 virtual void set_mnemonic_widget(Widget
* pTarget
) = 0;
1756 virtual void set_message_type(EntryMessageType eType
) = 0;
1757 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
1758 virtual void set_font(const vcl::Font
& rFont
) = 0;
1761 class VCL_DLLPUBLIC TextView
: virtual public Container
1763 friend class ::LOKTrigger
;
1766 OUString m_sSavedValue
;
1769 Link
<TextView
&, void> m_aChangeHdl
;
1770 Link
<TextView
&, void> m_aVChangeHdl
;
1771 Link
<TextView
&, void> m_aCursorPositionHdl
;
1773 void signal_changed() { m_aChangeHdl
.Call(*this); }
1774 void signal_cursor_position() { m_aCursorPositionHdl
.Call(*this); }
1775 void signal_vadjustment_changed() { m_aVChangeHdl
.Call(*this); }
1778 virtual void set_text(const OUString
& rText
) = 0;
1779 virtual OUString
get_text() const = 0;
1780 virtual void select_region(int nStartPos
, int nEndPos
) = 0;
1781 virtual bool get_selection_bounds(int& rStartPos
, int& rEndPos
) = 0;
1782 virtual void replace_selection(const OUString
& rText
) = 0;
1783 virtual void set_editable(bool bEditable
) = 0;
1784 virtual void set_monospace(bool bMonospace
) = 0;
1785 int get_height_rows(int nRows
) const
1787 //can improve this if needed
1788 return get_text_height() * nRows
;
1791 void save_value() { m_sSavedValue
= get_text(); }
1792 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_text(); }
1794 void connect_changed(const Link
<TextView
&, void>& rLink
) { m_aChangeHdl
= rLink
; }
1795 virtual void connect_cursor_position(const Link
<TextView
&, void>& rLink
)
1797 m_aCursorPositionHdl
= rLink
;
1800 virtual int vadjustment_get_value() const = 0;
1801 virtual int vadjustment_get_upper() const = 0;
1802 virtual int vadjustment_get_lower() const = 0;
1803 virtual int vadjustment_get_page_size() const = 0;
1804 virtual void vadjustment_set_value(int value
) = 0;
1805 void connect_vadjustment_changed(const Link
<TextView
&, void>& rLink
) { m_aVChangeHdl
= rLink
; }
1808 class VCL_DLLPUBLIC Expander
: virtual public Container
1811 Link
<Expander
&, void> m_aExpandedHdl
;
1813 void signal_expanded() { m_aExpandedHdl
.Call(*this); }
1816 virtual bool get_expanded() const = 0;
1817 virtual void set_expanded(bool bExpand
) = 0;
1819 void connect_expanded(const Link
<Expander
&, void>& rLink
) { m_aExpandedHdl
= rLink
; }
1822 class VCL_DLLPUBLIC DrawingArea
: virtual public Widget
1825 typedef std::pair
<vcl::RenderContext
&, const tools::Rectangle
&> draw_args
;
1828 Link
<draw_args
, void> m_aDrawHdl
;
1829 Link
<Widget
&, void> m_aStyleUpdatedHdl
;
1830 Link
<const CommandEvent
&, bool> m_aCommandHdl
;
1831 Link
<Widget
&, tools::Rectangle
> m_aGetFocusRectHdl
;
1832 Link
<tools::Rectangle
&, OUString
> m_aQueryTooltipHdl
;
1834 OUString
signal_query_tooltip(tools::Rectangle
& rHelpArea
)
1836 return m_aQueryTooltipHdl
.Call(rHelpArea
);
1840 void connect_draw(const Link
<draw_args
, void>& rLink
) { m_aDrawHdl
= rLink
; }
1841 void connect_style_updated(const Link
<Widget
&, void>& rLink
) { m_aStyleUpdatedHdl
= rLink
; }
1842 void connect_command(const Link
<const CommandEvent
&, bool>& rLink
) { m_aCommandHdl
= rLink
; }
1843 void connect_focus_rect(const Link
<Widget
&, tools::Rectangle
>& rLink
)
1845 m_aGetFocusRectHdl
= rLink
;
1847 void connect_query_tooltip(const Link
<tools::Rectangle
&, OUString
>& rLink
)
1849 m_aQueryTooltipHdl
= rLink
;
1851 virtual void queue_draw() = 0;
1852 virtual void queue_draw_area(int x
, int y
, int width
, int height
) = 0;
1853 virtual void queue_resize() = 0;
1855 virtual void set_cursor(PointerStyle ePointerStyle
) = 0;
1857 // use return here just to generate matching VirtualDevices
1858 virtual OutputDevice
& get_ref_device() = 0;
1860 virtual a11yref
get_accessible_parent() = 0;
1861 virtual a11yrelationset
get_accessible_relation_set() = 0;
1862 virtual Point
get_accessible_location() = 0;
1865 friend class ::LOKTrigger
;
1867 virtual void click(const Point
& rPos
) = 0;
1870 class VCL_DLLPUBLIC Menu
1873 Link
<const OString
&, void> m_aActivateHdl
;
1875 void signal_activate(const OString
& rIdent
) { m_aActivateHdl
.Call(rIdent
); }
1878 virtual OString
popup_at_rect(weld::Widget
* pParent
, const tools::Rectangle
& rRect
) = 0;
1880 void connect_activate(const Link
<const OString
&, void>& rLink
) { m_aActivateHdl
= rLink
; }
1882 virtual void set_sensitive(const OString
& rIdent
, bool bSensitive
) = 0;
1883 virtual void set_label(const OString
& rIdent
, const OUString
& rLabel
) = 0;
1884 virtual void set_active(const OString
& rIdent
, bool bActive
) = 0;
1885 virtual bool get_active(const OString
& rIdent
) const = 0;
1886 virtual void set_visible(const OString
& rIdent
, bool bVisible
) = 0;
1888 virtual void insert(int pos
, const OUString
& rId
, const OUString
& rStr
,
1889 const OUString
* pIconName
, VirtualDevice
* pImageSufface
, bool bCheck
)
1892 virtual void clear() = 0;
1894 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
1895 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
1897 void append(const OUString
& rId
, const OUString
& rStr
)
1899 insert(-1, rId
, rStr
, nullptr, nullptr, false);
1901 void append_check(const OUString
& rId
, const OUString
& rStr
)
1903 insert(-1, rId
, rStr
, nullptr, nullptr, true);
1905 void append(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
1907 insert(-1, rId
, rStr
, &rImage
, nullptr, false);
1909 void append(const OUString
& rId
, const OUString
& rStr
, VirtualDevice
& rImage
)
1911 insert(-1, rId
, rStr
, nullptr, &rImage
, false);
1917 class VCL_DLLPUBLIC Toolbar
: virtual public Widget
1920 Link
<const OString
&, void> m_aClickHdl
;
1922 friend class ::LOKTrigger
;
1924 virtual void signal_clicked(const OString
& rIdent
) { m_aClickHdl
.Call(rIdent
); }
1927 virtual void set_item_sensitive(const OString
& rIdent
, bool bSensitive
) = 0;
1928 virtual bool get_item_sensitive(const OString
& rIdent
) const = 0;
1929 virtual void set_item_active(const OString
& rIdent
, bool bActive
) = 0;
1930 virtual bool get_item_active(const OString
& rIdent
) const = 0;
1931 virtual void set_item_menu(const OString
& rIdent
, weld::Menu
* pMenu
) = 0;
1932 virtual void set_item_popover(const OString
& rIdent
, weld::Widget
* pPopover
) = 0;
1933 virtual void set_item_visible(const OString
& rIdent
, bool bVisible
) = 0;
1934 virtual bool get_item_visible(const OString
& rIdent
) const = 0;
1935 virtual void set_item_label(const OString
& rIdent
, const OUString
& rLabel
) = 0;
1936 virtual OUString
get_item_label(const OString
& rIdent
) const = 0;
1937 virtual void set_item_tooltip_text(const OString
& rIdent
, const OUString
& rTip
) = 0;
1939 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
1940 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
1942 virtual int get_n_items() const = 0;
1943 virtual OString
get_item_ident(int nIndex
) const = 0;
1944 virtual void set_item_ident(int nIndex
, const OString
& rIdent
) = 0;
1945 virtual void set_item_label(int nIndex
, const OUString
& rLabel
) = 0;
1946 virtual void set_item_icon(int nIndex
, const css::uno::Reference
<css::graphic::XGraphic
>& rIcon
)
1948 virtual void set_item_tooltip_text(int nIndex
, const OUString
& rTip
) = 0;
1950 virtual vcl::ImageType
get_icon_size() const = 0;
1952 void connect_clicked(const Link
<const OString
&, void>& rLink
) { m_aClickHdl
= rLink
; }
1955 class VCL_DLLPUBLIC SizeGroup
1958 virtual void add_widget(weld::Widget
* pWidget
) = 0;
1959 // the default mode is VclSizeGroupMode::Horizontal
1960 virtual void set_mode(VclSizeGroupMode eMode
) = 0;
1961 virtual ~SizeGroup() {}
1964 class VCL_DLLPUBLIC Builder
1967 OString m_sHelpRoot
;
1970 Builder(const OUString
& rUIFile
)
1971 : m_sHelpRoot(OUStringToOString(rUIFile
, RTL_TEXTENCODING_UTF8
))
1973 sal_Int32 nIdx
= m_sHelpRoot
.lastIndexOf('.');
1975 m_sHelpRoot
= m_sHelpRoot
.copy(0, nIdx
);
1976 m_sHelpRoot
+= OString('/');
1978 virtual std::unique_ptr
<MessageDialog
> weld_message_dialog(const OString
& id
,
1979 bool bTakeOwnership
= true)
1981 virtual std::unique_ptr
<Dialog
> weld_dialog(const OString
& id
, bool bTakeOwnership
= true) = 0;
1982 virtual std::unique_ptr
<AboutDialog
> weld_about_dialog(const OString
& id
,
1983 bool bTakeOwnership
= true)
1985 virtual std::unique_ptr
<Assistant
> weld_assistant(const OString
& id
, bool bTakeOwnership
= true)
1987 virtual std::unique_ptr
<Window
> weld_window(const OString
& id
, bool bTakeOwnership
= true) = 0;
1988 virtual std::unique_ptr
<Widget
> weld_widget(const OString
& id
, bool bTakeOwnership
= false) = 0;
1989 virtual std::unique_ptr
<Container
> weld_container(const OString
& id
,
1990 bool bTakeOwnership
= false)
1992 virtual std::unique_ptr
<Box
> weld_box(const OString
& id
, bool bTakeOwnership
= false) = 0;
1993 virtual std::unique_ptr
<Button
> weld_button(const OString
& id
, bool bTakeOwnership
= false) = 0;
1994 virtual std::unique_ptr
<MenuButton
> weld_menu_button(const OString
& id
,
1995 bool bTakeOwnership
= false)
1997 virtual std::unique_ptr
<Frame
> weld_frame(const OString
& id
, bool bTakeOwnership
= false) = 0;
1998 virtual std::unique_ptr
<ScrolledWindow
> weld_scrolled_window(const OString
& id
,
1999 bool bTakeOwnership
= false)
2001 virtual std::unique_ptr
<Notebook
> weld_notebook(const OString
& id
, bool bTakeOwnership
= false)
2003 virtual std::unique_ptr
<ToggleButton
> weld_toggle_button(const OString
& id
,
2004 bool bTakeOwnership
= false)
2006 virtual std::unique_ptr
<RadioButton
> weld_radio_button(const OString
& id
,
2007 bool bTakeOwnership
= false)
2009 virtual std::unique_ptr
<CheckButton
> weld_check_button(const OString
& id
,
2010 bool bTakeOwnership
= false)
2012 virtual std::unique_ptr
<LinkButton
> weld_link_button(const OString
& id
,
2013 bool bTakeOwnership
= false)
2015 virtual std::unique_ptr
<SpinButton
> weld_spin_button(const OString
& id
,
2016 bool bTakeOwnership
= false)
2018 virtual std::unique_ptr
<MetricSpinButton
>
2019 weld_metric_spin_button(const OString
& id
, FieldUnit eUnit
, bool bTakeOwnership
= false) = 0;
2020 virtual std::unique_ptr
<FormattedSpinButton
>
2021 weld_formatted_spin_button(const OString
& id
, bool bTakeOwnership
= false) = 0;
2022 virtual std::unique_ptr
<TimeSpinButton
>
2023 weld_time_spin_button(const OString
& id
, TimeFieldFormat eFormat
, bool bTakeOwnership
= false)
2025 virtual std::unique_ptr
<ComboBox
> weld_combo_box(const OString
& id
, bool bTakeOwnership
= false)
2027 virtual std::unique_ptr
<TreeView
> weld_tree_view(const OString
& id
, bool bTakeOwnership
= false)
2029 virtual std::unique_ptr
<IconView
> weld_icon_view(const OString
& id
, bool bTakeOwnership
= false)
2031 virtual std::unique_ptr
<Label
> weld_label(const OString
& id
, bool bTakeOwnership
= false) = 0;
2032 virtual std::unique_ptr
<TextView
> weld_text_view(const OString
& id
, bool bTakeOwnership
= false)
2034 virtual std::unique_ptr
<Expander
> weld_expander(const OString
& id
, bool bTakeOwnership
= false)
2036 virtual std::unique_ptr
<Entry
> weld_entry(const OString
& id
, bool bTakeOwnership
= false) = 0;
2037 virtual std::unique_ptr
<Scale
> weld_scale(const OString
& id
, bool bTakeOwnership
= false) = 0;
2038 virtual std::unique_ptr
<ProgressBar
> weld_progress_bar(const OString
& id
,
2039 bool bTakeOwnership
= false)
2041 virtual std::unique_ptr
<Spinner
> weld_spinner(const OString
& id
, bool bTakeOwnership
= false)
2043 virtual std::unique_ptr
<Image
> weld_image(const OString
& id
, bool bTakeOwnership
= false) = 0;
2044 virtual std::unique_ptr
<Calendar
> weld_calendar(const OString
& id
, bool bTakeOwnership
= false)
2046 virtual std::unique_ptr
<DrawingArea
>
2047 weld_drawing_area(const OString
& id
, const a11yref
& rA11yImpl
= nullptr,
2048 FactoryFunction pUITestFactoryFunction
= nullptr, void* pUserData
= nullptr,
2049 bool bTakeOwnership
= false)
2051 virtual std::unique_ptr
<EntryTreeView
>
2052 weld_entry_tree_view(const OString
& containerid
, const OString
& entryid
,
2053 const OString
& treeviewid
, bool bTakeOwnership
= false)
2055 virtual std::unique_ptr
<Menu
> weld_menu(const OString
& id
, bool bTakeOwnership
= true) = 0;
2056 virtual std::unique_ptr
<Toolbar
> weld_toolbar(const OString
& id
, bool bTakeOwnership
= true)
2058 virtual std::unique_ptr
<SizeGroup
> create_size_group() = 0;
2059 /* return a Dialog suitable to take a screenshot of containing the contents of the .ui file.
2061 If the toplevel element is a dialog, that will be returned
2062 If the toplevel is not a dialog, a dialog will be created and the contents of the .ui
2065 virtual std::unique_ptr
<Window
> create_screenshot_window() = 0;
2066 virtual ~Builder() {}
2069 class VCL_DLLPUBLIC DialogController
: public std::enable_shared_from_this
<DialogController
>
2072 virtual Dialog
* getDialog() = 0;
2073 const Dialog
* getConstDialog() const
2075 return const_cast<DialogController
*>(this)->getDialog();
2077 virtual short run() { return getDialog()->run(); }
2078 static bool runAsync(const std::shared_ptr
<DialogController
>& rController
,
2079 const std::function
<void(sal_Int32
)>&);
2080 void set_title(const OUString
& rTitle
) { getDialog()->set_title(rTitle
); }
2081 OUString
get_title() const { return getConstDialog()->get_title(); }
2082 void set_help_id(const OString
& rHelpId
) { getDialog()->set_help_id(rHelpId
); }
2083 OString
get_help_id() const { return getConstDialog()->get_help_id(); }
2084 void response(int nResponse
) { getDialog()->response(nResponse
); }
2085 virtual ~DialogController() COVERITY_NOEXCEPT_FALSE
;
2088 class VCL_DLLPUBLIC GenericDialogController
: public DialogController
2091 std::unique_ptr
<weld::Builder
> m_xBuilder
;
2092 std::shared_ptr
<weld::Dialog
> m_xDialog
;
2095 GenericDialogController(weld::Widget
* pParent
, const OUString
& rUIFile
,
2096 const OString
& rDialogId
, bool bMobile
= false);
2097 virtual Dialog
* getDialog() override
;
2098 virtual ~GenericDialogController() COVERITY_NOEXCEPT_FALSE override
;
2101 class VCL_DLLPUBLIC MessageDialogController
: public DialogController
2104 std::unique_ptr
<weld::Builder
> m_xBuilder
;
2105 std::unique_ptr
<weld::MessageDialog
> m_xDialog
;
2106 std::unique_ptr
<weld::Container
> m_xContentArea
;
2107 std::unique_ptr
<weld::Widget
> m_xRelocate
;
2108 std::unique_ptr
<weld::Container
> m_xOrigParent
;
2111 /* @param rRelocateId - optional argument of the name of a widget in the .ui file
2112 which should be relocated into the content area of the dialog.
2114 e.g. a checkbox for a "Never show this again" option.
2116 This results in the named widget relocating to the same container
2117 as the messages. This enables aligning the extra widget with the
2118 message labels in the content area container which doesn't
2119 explicitly exist in the ui description, but is only implied.
2121 MessageDialogController(weld::Widget
* pParent
, const OUString
& rUIFile
,
2122 const OString
& rDialogId
, const OString
& rRelocateId
= OString());
2123 virtual Dialog
* getDialog() override
;
2124 virtual ~MessageDialogController() override
;
2125 void set_primary_text(const OUString
& rText
) { m_xDialog
->set_primary_text(rText
); }
2126 OUString
get_primary_text() const { return m_xDialog
->get_primary_text(); }
2127 void set_default_response(int nResponse
) { m_xDialog
->set_default_response(nResponse
); }
2130 class VCL_DLLPUBLIC AssistantController
: public DialogController
2133 std::unique_ptr
<weld::Builder
> m_xBuilder
;
2134 std::unique_ptr
<weld::Assistant
> m_xAssistant
;
2137 AssistantController(weld::Widget
* pParent
, const OUString
& rUIFile
, const OString
& rDialogId
);
2138 virtual Dialog
* getDialog() override
;
2139 virtual ~AssistantController() override
;
2144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */