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 <vcl/dllapi.h>
22 #include <vcl/vclenum.hxx>
23 #include <vcl/font.hxx>
24 #include <vcl/vclptr.hxx>
25 #include <vcl/uitest/factory.hxx>
26 #include <vcl/windowstate.hxx>
28 #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
29 #include <com/sun/star/accessibility/XAccessible.hpp>
35 namespace com::sun::star::awt
39 namespace com::sun::star::datatransfer::clipboard
43 namespace com::sun::star::datatransfer::dnd
47 namespace com::sun::star::graphic
51 typedef css::uno::Reference
<css::accessibility::XAccessible
> a11yref
;
52 typedef css::uno::Reference
<css::accessibility::XAccessibleRelationSet
> a11yrelationset
;
53 enum class PointerStyle
;
59 class SvNumberFormatter
;
60 class TransferDataContainer
;
67 class ILibreOfficeKitNotifier
;
68 typedef OutputDevice RenderContext
;
80 class DialogController
;
82 class VCL_DLLPUBLIC Widget
84 friend class ::LOKTrigger
;
87 Link
<Widget
&, void> m_aFocusInHdl
;
88 Link
<Widget
&, void> m_aFocusOutHdl
;
89 Link
<Widget
&, bool> m_aMnemonicActivateHdl
;
90 Link
<Widget
&, void> m_aStyleUpdatedHdl
;
91 Link
<const Size
&, void> m_aSizeAllocateHdl
;
92 Link
<const KeyEvent
&, bool> m_aKeyPressHdl
;
93 Link
<const KeyEvent
&, bool> m_aKeyReleaseHdl
;
94 Link
<const MouseEvent
&, bool> m_aMousePressHdl
;
95 Link
<const MouseEvent
&, bool> m_aMouseMotionHdl
;
96 Link
<const MouseEvent
&, bool> m_aMouseReleaseHdl
;
99 virtual void set_sensitive(bool sensitive
) = 0;
100 virtual bool get_sensitive() const = 0;
104 virtual void show() = 0;
105 virtual void hide() = 0;
107 // This function simply calls show() or hide() but is convenient when the
108 // visibility depends on some condition
109 virtual void set_visible(bool visible
)
117 // return if this widget's visibility is true
118 virtual bool get_visible() const = 0;
120 // return if this widget's visibility and that of all its parents is true
121 virtual bool is_visible() const = 0;
125 // sets if this widget can own the keyboard focus
126 virtual void set_can_focus(bool bCanFocus
) = 0;
128 // causes this widget to have the keyboard focus
129 virtual void grab_focus() = 0;
131 // returns if this widget has the keyboard focus
132 virtual bool has_focus() const = 0;
134 // if the widget that has focus is a child, which includes toplevel popup
135 // children, of this widget. So an Entry with an active popup (or dialog)
136 // has has_child_focus of true, but has_focus of false, while its popup is
138 virtual bool has_child_focus() const = 0;
140 // return if this widget has the keyboard focus within the active window
141 // TODO: review if this has any practical difference from has_focus()
142 virtual bool is_active() const = 0;
145 virtual void set_size_request(int nWidth
, int nHeight
) = 0;
146 virtual Size
get_size_request() const = 0;
147 virtual Size
get_preferred_size() const = 0;
150 virtual float get_approximate_digit_width() const = 0;
151 virtual int get_text_height() const = 0;
152 virtual Size
get_pixel_size(const OUString
& rText
) const = 0;
154 // The name of the widget in the GtkBuilder UI definition used to construct it.
155 virtual OUString
get_buildable_name() const = 0;
157 Typically there is no need to change the buildable name at runtime, changing
158 the id in .ui file itself is preferred.
160 But for ui-testing purposes it can sometimes be useful to rename
161 different widgets, that were loaded from the same .ui, to unique names
162 in order to distinguish between them
164 virtual void set_buildable_name(const OUString
& rName
) = 0;
167 The help id of the widget used to identify help for this widget.
169 By default the help id of a widget is a path-like sequence of (load-time)
170 buildable-names from the widgets UI definition ancestor to this widget,
171 e.g. grandparent/parent/widget.
173 The default can be overwritten with set_help_id
175 virtual OUString
get_help_id() const = 0;
176 virtual void set_help_id(const OUString
& rName
) = 0;
178 virtual void set_grid_left_attach(int nAttach
) = 0;
179 virtual int get_grid_left_attach() const = 0;
180 virtual void set_grid_width(int nCols
) = 0;
181 virtual void set_grid_top_attach(int nAttach
) = 0;
182 virtual int get_grid_top_attach() const = 0;
184 virtual void set_hexpand(bool bExpand
) = 0;
185 virtual bool get_hexpand() const = 0;
186 virtual void set_vexpand(bool bExpand
) = 0;
187 virtual bool get_vexpand() const = 0;
189 virtual void set_margin_top(int nMargin
) = 0;
190 virtual void set_margin_bottom(int nMargin
) = 0;
191 virtual void set_margin_start(int nMargin
) = 0;
192 virtual void set_margin_end(int nMargin
) = 0;
194 virtual int get_margin_top() const = 0;
195 virtual int get_margin_bottom() const = 0;
196 virtual int get_margin_start() const = 0;
197 virtual int get_margin_end() const = 0;
200 * Report the extents of this widget relative to the rRelative target widget.
202 * To succeed, both widgets must be realized, and must share a common toplevel.
204 * returns false if the relative extents could not be determined, e.g. if
205 * either widget was not realized, or there was no common ancestor.
208 virtual bool get_extents_relative_to(const Widget
& rRelative
, int& x
, int& y
, int& width
,
209 int& height
) const = 0;
211 virtual void set_accessible_name(const OUString
& rName
) = 0;
212 virtual void set_accessible_description(const OUString
& rDescription
) = 0;
213 virtual OUString
get_accessible_name() const = 0;
215 virtual OUString
get_accessible_description() const = 0;
217 // After this call this widget is only accessibility labelled by pLabel and
218 // pLabel only accessibility labels this widget
219 virtual void set_accessible_relation_labeled_by(weld::Widget
* pLabel
) = 0;
221 virtual void set_tooltip_text(const OUString
& rTip
) = 0;
222 virtual OUString
get_tooltip_text() const = 0;
224 virtual void set_cursor_data(void* pData
) = 0;
226 virtual void connect_focus_in(const Link
<Widget
&, void>& rLink
)
228 assert(!m_aFocusInHdl
.IsSet() || !rLink
.IsSet());
229 m_aFocusInHdl
= rLink
;
232 virtual void connect_focus_out(const Link
<Widget
&, void>& rLink
)
234 assert(!m_aFocusOutHdl
.IsSet() || !rLink
.IsSet());
235 m_aFocusOutHdl
= rLink
;
238 // rLink is called when the mnemonic for the Widget is called.
239 // If rLink returns true the Widget will not automatically gain
240 // focus as normally occurs
241 virtual void connect_mnemonic_activate(const Link
<Widget
&, bool>& rLink
)
243 assert(!m_aMnemonicActivateHdl
.IsSet() || !rLink
.IsSet());
244 m_aMnemonicActivateHdl
= rLink
;
247 virtual void connect_size_allocate(const Link
<const Size
&, void>& rLink
)
249 assert(!m_aSizeAllocateHdl
.IsSet() || !rLink
.IsSet());
250 m_aSizeAllocateHdl
= rLink
;
253 virtual void connect_key_press(const Link
<const KeyEvent
&, bool>& rLink
)
255 assert(!m_aKeyPressHdl
.IsSet() || !rLink
.IsSet());
256 m_aKeyPressHdl
= rLink
;
259 virtual void connect_key_release(const Link
<const KeyEvent
&, bool>& rLink
)
261 assert(!m_aKeyReleaseHdl
.IsSet() || !rLink
.IsSet());
262 m_aKeyReleaseHdl
= rLink
;
265 virtual void connect_mouse_press(const Link
<const MouseEvent
&, bool>& rLink
)
267 assert(!m_aMousePressHdl
.IsSet() || !rLink
.IsSet());
268 m_aMousePressHdl
= rLink
;
271 virtual void connect_mouse_move(const Link
<const MouseEvent
&, bool>& rLink
)
273 assert(!m_aMouseMotionHdl
.IsSet() || !rLink
.IsSet());
274 m_aMouseMotionHdl
= rLink
;
277 virtual void connect_mouse_release(const Link
<const MouseEvent
&, bool>& rLink
)
279 assert(!m_aMouseReleaseHdl
.IsSet() || !rLink
.IsSet());
280 m_aMouseReleaseHdl
= rLink
;
283 virtual void connect_style_updated(const Link
<Widget
&, void>& rLink
)
285 assert(!m_aStyleUpdatedHdl
.IsSet() || !rLink
.IsSet());
286 m_aStyleUpdatedHdl
= rLink
;
289 virtual void grab_add() = 0;
290 virtual bool has_grab() const = 0;
291 virtual void grab_remove() = 0;
293 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
294 virtual vcl::Font
get_font() = 0;
296 //true for rtl, false otherwise
297 virtual bool get_direction() const = 0;
298 virtual void set_direction(bool bRTL
) = 0;
300 /* Increases the freeze count on widget.
302 If the freeze count is non-zero, emission of the widget's notifications
303 is stopped. The notifications are queued until the freeze count is
304 decreased to zero. Duplicate notifications may be squashed together.
306 virtual void freeze() = 0;
308 /* Reverts the effect of a previous call to freeze.
310 The freeze count is decreased on the widget and when it reaches zero,
311 queued notifications are emitted.
313 virtual void thaw() = 0;
315 /* push/pop busy mouse cursor state
317 bBusy of true to push a busy state onto the stack and false
318 to pop it off, calls to this should balance.
320 see weld::WaitObject */
321 virtual void set_busy_cursor(bool bBusy
) = 0;
323 virtual void queue_resize() = 0;
325 virtual std::unique_ptr
<Container
> weld_parent() const = 0;
327 //iterate upwards through the hierarchy starting at this widgets parent,
328 //calling func with their helpid until func returns true or we run out of
330 virtual void help_hierarchy_foreach(const std::function
<bool(const OUString
&)>& func
) = 0;
332 virtual OUString
strip_mnemonic(const OUString
& rLabel
) const = 0;
334 virtual VclPtr
<VirtualDevice
> create_virtual_device() const = 0;
336 //do something transient to attract the attention of the user to the widget
337 virtual void call_attention_to() = 0;
339 //make this widget look like a page in a notebook
340 virtual void set_stack_background() = 0;
341 //make this widget look like it has a highlighted background
342 virtual void set_highlight_background() = 0;
343 //make this widget suitable as parent for a title
344 virtual void set_title_background() = 0;
345 //make this widget suitable for use in a toolbar
346 virtual void set_toolbar_background() = 0;
347 //trying to use a custom color for a background is generally a bad idea. If your need
348 //fits one of the above categories then that's a somewhat better choice
349 virtual void set_background(const Color
& rBackColor
) = 0;
351 virtual css::uno::Reference
<css::datatransfer::dnd::XDropTarget
> get_drop_target() = 0;
352 virtual css::uno::Reference
<css::datatransfer::clipboard::XClipboard
> get_clipboard() const = 0;
354 virtual void connect_get_property_tree(const Link
<tools::JsonWriter
&, void>& rLink
) = 0;
355 virtual void get_property_tree(tools::JsonWriter
& rJsonWriter
) = 0;
357 // render the widget to an output device
358 virtual void draw(OutputDevice
& rOutput
, const Point
& rPos
, const Size
& rSizePixel
) = 0;
363 class VCL_DLLPUBLIC Container
: virtual public Widget
365 Link
<Container
&, void> m_aContainerFocusChangedHdl
;
368 void signal_container_focus_changed() { m_aContainerFocusChangedHdl
.Call(*this); }
371 // remove from old container and add to new container in one go
372 // new container can be null to just remove from old container
373 virtual void move(weld::Widget
* pWidget
, weld::Container
* pNewParent
) = 0;
374 // create an XWindow as a child of this container. The XWindow is
375 // suitable to contain css::awt::XControl items
376 virtual css::uno::Reference
<css::awt::XWindow
> CreateChildFrame() = 0;
377 // rLink is called when the focus transitions from a widget outside the container
378 // to a widget inside the container or vice versa
379 virtual void connect_container_focus_changed(const Link
<Container
&, void>& rLink
)
381 m_aContainerFocusChangedHdl
= rLink
;
383 // causes a child of the container to have the keyboard focus
384 virtual void child_grab_focus() = 0;
387 class VCL_DLLPUBLIC Box
: virtual public Container
390 // Moves child to a new position in the list of children
391 virtual void reorder_child(weld::Widget
* pWidget
, int position
) = 0;
392 // Sort ok/cancel etc buttons in platform order
393 virtual void sort_native_button_order() = 0;
396 class VCL_DLLPUBLIC Paned
: virtual public Container
399 // set pixel position of divider
400 virtual void set_position(int nPos
) = 0;
401 // get pixel position of divider
402 virtual int get_position() const = 0;
405 class VCL_DLLPUBLIC ScrolledWindow
: virtual public Container
407 friend class ::LOKTrigger
;
409 Link
<ScrolledWindow
&, void> m_aVChangeHdl
;
410 Link
<ScrolledWindow
&, void> m_aHChangeHdl
;
413 void signal_vadjustment_changed() { m_aVChangeHdl
.Call(*this); }
414 void signal_hadjustment_changed() { m_aHChangeHdl
.Call(*this); }
417 virtual void hadjustment_configure(int value
, int lower
, int upper
, int step_increment
,
418 int page_increment
, int page_size
)
420 virtual int hadjustment_get_value() const = 0;
421 virtual void hadjustment_set_value(int value
) = 0;
422 virtual int hadjustment_get_upper() const = 0;
423 virtual void hadjustment_set_upper(int upper
) = 0;
424 virtual int hadjustment_get_page_size() const = 0;
425 virtual void hadjustment_set_page_size(int size
) = 0;
426 virtual void hadjustment_set_page_increment(int size
) = 0;
427 virtual void hadjustment_set_step_increment(int size
) = 0;
428 virtual void set_hpolicy(VclPolicyType eHPolicy
) = 0;
429 virtual VclPolicyType
get_hpolicy() const = 0;
430 void connect_hadjustment_changed(const Link
<ScrolledWindow
&, void>& rLink
)
432 m_aHChangeHdl
= rLink
;
435 virtual void vadjustment_configure(int value
, int lower
, int upper
, int step_increment
,
436 int page_increment
, int page_size
)
438 virtual int vadjustment_get_value() const = 0;
439 virtual void vadjustment_set_value(int value
) = 0;
440 virtual int vadjustment_get_upper() const = 0;
441 virtual void vadjustment_set_upper(int upper
) = 0;
442 virtual int vadjustment_get_page_size() const = 0;
443 virtual void vadjustment_set_page_size(int size
) = 0;
444 virtual void vadjustment_set_page_increment(int size
) = 0;
445 virtual void vadjustment_set_step_increment(int size
) = 0;
446 virtual int vadjustment_get_lower() const = 0;
447 virtual void vadjustment_set_lower(int upper
) = 0;
448 virtual void set_vpolicy(VclPolicyType eVPolicy
) = 0;
449 virtual VclPolicyType
get_vpolicy() const = 0;
450 void connect_vadjustment_changed(const Link
<ScrolledWindow
&, void>& rLink
)
452 m_aVChangeHdl
= rLink
;
454 virtual int get_scroll_thickness() const = 0;
455 virtual void set_scroll_thickness(int nThickness
) = 0;
457 //trying to use custom color for a scrollbar is generally a bad idea.
458 virtual void customize_scrollbars(const Color
& rBackgroundColor
, const Color
& rShadowColor
,
459 const Color
& rFaceColor
)
465 class VCL_DLLPUBLIC Frame
: virtual public Container
468 virtual void set_label(const OUString
& rText
) = 0;
469 virtual OUString
get_label() const = 0;
470 virtual std::unique_ptr
<Label
> weld_label_widget() const = 0;
473 class VCL_DLLPUBLIC Notebook
: virtual public Widget
475 friend class ::LOKTrigger
;
478 Link
<const OUString
&, bool> m_aLeavePageHdl
;
479 Link
<const OUString
&, void> m_aEnterPageHdl
;
482 virtual int get_current_page() const = 0;
483 virtual int get_page_index(const OUString
& rIdent
) const = 0;
484 virtual OUString
get_page_ident(int nPage
) const = 0;
485 virtual OUString
get_current_page_ident() const = 0;
486 virtual void set_current_page(int nPage
) = 0;
487 virtual void set_current_page(const OUString
& rIdent
) = 0;
488 virtual void remove_page(const OUString
& rIdent
) = 0;
489 virtual void insert_page(const OUString
& rIdent
, const OUString
& rLabel
, int nPos
) = 0;
490 void append_page(const OUString
& rIdent
, const OUString
& rLabel
)
492 insert_page(rIdent
, rLabel
, -1);
494 virtual void set_tab_label_text(const OUString
& rIdent
, const OUString
& rLabel
) = 0;
495 virtual OUString
get_tab_label_text(const OUString
& rIdent
) const = 0;
496 virtual void set_show_tabs(bool bShow
) = 0;
497 virtual int get_n_pages() const = 0;
498 virtual weld::Container
* get_page(const OUString
& rIdent
) const = 0;
500 void connect_leave_page(const Link
<const OUString
&, bool>& rLink
) { m_aLeavePageHdl
= rLink
; }
501 void connect_enter_page(const Link
<const OUString
&, void>& rLink
) { m_aEnterPageHdl
= rLink
; }
504 class VCL_DLLPUBLIC ScreenShotEntry
507 ScreenShotEntry(OUString aHelpId
, const basegfx::B2IRange
& rB2IRange
)
508 : msHelpId(std::move(aHelpId
))
509 , maB2IRange(rB2IRange
)
513 const basegfx::B2IRange
& getB2IRange() const { return maB2IRange
; }
515 const OUString
& GetHelpId() const { return msHelpId
; }
519 basegfx::B2IRange maB2IRange
;
522 typedef std::vector
<ScreenShotEntry
> ScreenShotCollection
;
524 class VCL_DLLPUBLIC Window
: virtual public Container
527 Link
<Widget
&, bool> m_aHelpRequestHdl
;
530 virtual void set_title(const OUString
& rTitle
) = 0;
531 virtual OUString
get_title() const = 0;
532 virtual void window_move(int x
, int y
) = 0;
533 virtual void set_modal(bool bModal
) = 0;
534 virtual bool get_modal() const = 0;
535 virtual bool get_resizable() const = 0;
536 virtual Size
get_size() const = 0;
537 virtual Point
get_position() const = 0;
538 virtual tools::Rectangle
get_monitor_workarea() const = 0;
539 // center window on is parent
541 // bTrackGeometryRequests set to true tries to ensure the window will end
542 // up still centered on its parent windows final size, taking into account
543 // that there may currently be pending geometry requests for the parent not
544 // yet processed by the underlying toolkit
546 // for e.g gtk this will means the window is always centered even when
547 // resized, calling set_centered_on_parent with false will turn this
549 virtual void set_centered_on_parent(bool bTrackGeometryRequests
) = 0;
550 // returns whether the widget that has focus is within this Window
551 // (its very possible to move this to weld::Container if that becomes
553 virtual bool has_toplevel_focus() const = 0;
554 virtual void present() = 0;
556 // with pOld of null, automatically find the old default widget and unset
557 // it, otherwise use as hint to the old default
558 virtual void change_default_widget(weld::Widget
* pOld
, weld::Widget
* pNew
) = 0;
559 virtual bool is_default_widget(const weld::Widget
* pCandidate
) const = 0;
561 virtual void set_window_state(const OUString
& rStr
) = 0;
562 virtual OUString
get_window_state(vcl::WindowDataMask nMask
) const = 0;
564 virtual css::uno::Reference
<css::awt::XWindow
> GetXWindow() = 0;
566 void connect_help(const Link
<Widget
&, bool>& rLink
) { m_aHelpRequestHdl
= rLink
; }
568 virtual SystemEnvData
get_system_data() const = 0;
570 virtual void resize_to_request() = 0;
572 // collect positions of widgets and their help ids for screenshot purposes
573 virtual ScreenShotCollection
collect_screenshot_data() = 0;
575 // render the widget to an output device
576 virtual VclPtr
<VirtualDevice
> screenshot() = 0;
578 virtual const vcl::ILibreOfficeKitNotifier
* GetLOKNotifier() = 0;
581 class VCL_DLLPUBLIC WaitObject
584 weld::Widget
* m_pWindow
;
587 WaitObject(weld::Widget
* pWindow
)
591 m_pWindow
->set_busy_cursor(true);
596 m_pWindow
->set_busy_cursor(false);
602 class VCL_DLLPUBLIC Dialog
: virtual public Window
605 friend DialogController
;
606 virtual bool runAsync(std::shared_ptr
<DialogController
>,
607 const std::function
<void(sal_Int32
)>& func
)
611 virtual int run() = 0;
612 // Run async without a controller
613 // @param self - must point to this, to enforce that the dialog was created/held by a shared_ptr
614 virtual bool runAsync(std::shared_ptr
<Dialog
> const& rxSelf
,
615 const std::function
<void(sal_Int32
)>& func
)
617 virtual void response(int response
) = 0;
618 virtual void add_button(const OUString
& rText
, int response
, const OUString
& rHelpId
= {}) = 0;
619 virtual void set_default_response(int response
) = 0;
620 virtual Button
* weld_widget_for_response(int response
) = 0;
621 virtual Container
* weld_content_area() = 0;
623 // shrink the dialog down to shown just these widgets
624 virtual void collapse(weld::Widget
* pEdit
, weld::Widget
* pButton
) = 0;
625 // undo previous dialog collapse
626 virtual void undo_collapse() = 0;
628 virtual void SetInstallLOKNotifierHdl(const Link
<void*, vcl::ILibreOfficeKitNotifier
*>& rLink
)
632 class VCL_DLLPUBLIC MessageDialog
: virtual public Dialog
635 virtual void set_primary_text(const OUString
& rText
) = 0;
636 virtual OUString
get_primary_text() const = 0;
637 virtual void set_secondary_text(const OUString
& rText
) = 0;
638 virtual OUString
get_secondary_text() const = 0;
639 virtual Container
* weld_message_area() = 0;
642 class VCL_DLLPUBLIC Assistant
: virtual public Dialog
644 Link
<const OUString
&, bool> m_aJumpPageHdl
;
647 bool signal_jump_page(const OUString
& rIdent
) { return m_aJumpPageHdl
.Call(rIdent
); }
650 virtual int get_current_page() const = 0;
651 virtual int get_n_pages() const = 0;
652 virtual OUString
get_page_ident(int nPage
) const = 0;
653 virtual OUString
get_current_page_ident() const = 0;
654 virtual void set_current_page(int nPage
) = 0;
655 virtual void set_current_page(const OUString
& rIdent
) = 0;
656 // move the page rIdent to position nIndex
657 virtual void set_page_index(const OUString
& rIdent
, int nIndex
) = 0;
658 virtual void set_page_title(const OUString
& rIdent
, const OUString
& rTitle
) = 0;
659 virtual OUString
get_page_title(const OUString
& rIdent
) const = 0;
660 virtual void set_page_sensitive(const OUString
& rIdent
, bool bSensitive
) = 0;
661 virtual weld::Container
* append_page(const OUString
& rIdent
) = 0;
663 virtual void set_page_side_help_id(const OUString
& rHelpId
) = 0;
665 virtual void set_page_side_image(const OUString
& rImage
) = 0;
667 void connect_jump_page(const Link
<const OUString
&, bool>& rLink
) { m_aJumpPageHdl
= rLink
; }
670 inline OUString
toId(const void* pValue
)
672 return OUString::number(reinterpret_cast<sal_uIntPtr
>(pValue
));
675 template <typename T
> T
fromId(const OUString
& rValue
)
677 return reinterpret_cast<T
>(rValue
.toUInt64());
680 struct VCL_DLLPUBLIC ComboBoxEntry
685 ComboBoxEntry(OUString _aString
)
686 : sString(std::move(_aString
))
689 ComboBoxEntry(OUString _aString
, OUString _aId
)
690 : sString(std::move(_aString
))
691 , sId(std::move(_aId
))
694 ComboBoxEntry(OUString _aString
, OUString _aId
, OUString _aImage
)
695 : sString(std::move(_aString
))
696 , sId(std::move(_aId
))
697 , sImage(std::move(_aImage
))
702 enum class EntryMessageType
711 /// A widget used to choose from a list of items.
712 class VCL_DLLPUBLIC ComboBox
: virtual public Widget
715 OUString m_sSavedValue
;
716 std::vector
<OUString
> m_aSavedValues
;
719 // OUString is the id of the row, it may be null to measure the height of a generic line
720 typedef std::tuple
<vcl::RenderContext
&, const tools::Rectangle
&, bool, const OUString
&>
724 Link
<ComboBox
&, void> m_aChangeHdl
;
725 Link
<ComboBox
&, void> m_aPopupToggledHdl
;
726 Link
<ComboBox
&, bool> m_aEntryActivateHdl
;
727 Link
<OUString
&, bool> m_aEntryInsertTextHdl
;
729 friend class ::LOKTrigger
;
731 void signal_changed() { m_aChangeHdl
.Call(*this); }
733 virtual void signal_popup_toggled() { m_aPopupToggledHdl
.Call(*this); }
735 Link
<render_args
, void> m_aRenderHdl
;
736 void signal_custom_render(vcl::RenderContext
& rDevice
, const tools::Rectangle
& rRect
,
737 bool bSelected
, const OUString
& rId
)
739 m_aRenderHdl
.Call(render_args(rDevice
, rRect
, bSelected
, rId
));
742 Link
<vcl::RenderContext
&, Size
> m_aGetSizeHdl
;
743 Size
signal_custom_get_size(vcl::RenderContext
& rDevice
) { return m_aGetSizeHdl
.Call(rDevice
); }
746 virtual void insert(int pos
, const OUString
& rStr
, const OUString
* pId
,
747 const OUString
* pIconName
, VirtualDevice
* pImageSurface
)
749 virtual void insert_vector(const std::vector
<weld::ComboBoxEntry
>& rItems
, bool bKeepExisting
)
751 void insert(int pos
, const weld::ComboBoxEntry
& rItem
)
753 insert(pos
, rItem
.sString
, rItem
.sId
.isEmpty() ? nullptr : &rItem
.sId
,
754 rItem
.sImage
.isEmpty() ? nullptr : &rItem
.sImage
, nullptr);
756 void insert_text(int pos
, const OUString
& rStr
)
758 insert(pos
, rStr
, nullptr, nullptr, nullptr);
760 void append(const weld::ComboBoxEntry
& rItem
) { insert(-1, rItem
); }
761 void append_text(const OUString
& rStr
) { insert(-1, rStr
, nullptr, nullptr, nullptr); }
762 void append(const OUString
& rId
, const OUString
& rStr
)
764 insert(-1, rStr
, &rId
, nullptr, nullptr);
766 void append(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
768 insert(-1, rStr
, &rId
, &rImage
, nullptr);
770 void append(const OUString
& rId
, const OUString
& rStr
, VirtualDevice
& rImage
)
772 insert(-1, rStr
, &rId
, nullptr, &rImage
);
774 void append(int pos
, const OUString
& rId
, const OUString
& rStr
)
776 insert(pos
, rStr
, &rId
, nullptr, nullptr);
778 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
779 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
781 virtual int get_count() const = 0;
782 virtual void make_sorted() = 0;
783 virtual void clear() = 0;
786 virtual int get_active() const = 0;
787 virtual void set_active(int pos
) = 0;
788 virtual void remove(int pos
) = 0;
791 virtual OUString
get_active_text() const = 0;
792 void set_active_text(const OUString
& rStr
) { set_active(find_text(rStr
)); }
793 virtual OUString
get_text(int pos
) const = 0;
794 virtual int find_text(const OUString
& rStr
) const = 0;
795 void remove_text(const OUString
& rText
) { remove(find_text(rText
)); }
798 virtual OUString
get_active_id() const = 0;
799 virtual void set_active_id(const OUString
& rStr
) = 0;
800 virtual OUString
get_id(int pos
) const = 0;
801 virtual void set_id(int row
, const OUString
& rId
) = 0;
802 virtual int find_id(const OUString
& rId
) const = 0;
803 void remove_id(const OUString
& rId
) { remove(find_id(rId
)); }
805 /* m_aChangeHdl is called when the active item is changed. The can be due
806 to the user selecting a different item from the list or while typing
807 into the entry of a combo box with an entry.
809 Use changed_by_direct_pick() to discover whether an item was actually explicitly
810 selected, e.g. from the menu.
812 void connect_changed(const Link
<ComboBox
&, void>& rLink
) { m_aChangeHdl
= rLink
; }
814 virtual bool changed_by_direct_pick() const = 0;
816 virtual void connect_popup_toggled(const Link
<ComboBox
&, void>& rLink
)
818 m_aPopupToggledHdl
= rLink
;
822 virtual bool has_entry() const = 0;
823 virtual void set_entry_message_type(EntryMessageType eType
) = 0;
824 virtual void set_entry_text(const OUString
& rStr
) = 0;
825 virtual void set_entry_width_chars(int nChars
) = 0;
826 virtual void set_entry_max_length(int nChars
) = 0;
827 virtual void select_entry_region(int nStartPos
, int nEndPos
) = 0;
828 virtual bool get_entry_selection_bounds(int& rStartPos
, int& rEndPos
) = 0;
829 virtual void set_entry_completion(bool bEnable
, bool bCaseSensitive
= false) = 0;
830 virtual void set_entry_placeholder_text(const OUString
& rText
) = 0;
831 virtual void set_entry_editable(bool bEditable
) = 0;
832 virtual void cut_entry_clipboard() = 0;
833 virtual void copy_entry_clipboard() = 0;
834 virtual void paste_entry_clipboard() = 0;
836 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
837 virtual void set_font(const vcl::Font
& rFont
) = 0;
839 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
840 virtual void set_entry_font(const vcl::Font
& rFont
) = 0;
841 virtual vcl::Font
get_entry_font() = 0;
843 virtual bool get_popup_shown() const = 0;
845 void connect_entry_insert_text(const Link
<OUString
&, bool>& rLink
)
847 m_aEntryInsertTextHdl
= rLink
;
850 // callback returns true to indicated no further processing of activate wanted
851 void connect_entry_activate(const Link
<ComboBox
&, bool>& rLink
) { m_aEntryActivateHdl
= rLink
; }
853 void save_value() { m_sSavedValue
= get_active_text(); }
855 void save_values_by_id(const OUString
& rId
)
857 m_aSavedValues
.push_back(get_text(find_id(rId
)));
860 OUString
const& get_saved_value() const { return m_sSavedValue
; }
861 OUString
const& get_saved_values(int pos
) const { return m_aSavedValues
[pos
]; }
862 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_active_text(); }
863 bool get_values_changed_from_saved() const
865 return !m_aSavedValues
.empty()
866 && std::find(m_aSavedValues
.begin(), m_aSavedValues
.end(), get_active_text())
867 == m_aSavedValues
.end();
870 void removeSavedValues() { m_aSavedValues
.clear(); }
872 // for custom rendering a row
873 void connect_custom_get_size(const Link
<vcl::RenderContext
&, Size
>& rLink
)
875 m_aGetSizeHdl
= rLink
;
877 void connect_custom_render(const Link
<render_args
, void>& rLink
) { m_aRenderHdl
= rLink
; }
878 // call set_custom_renderer after setting custom callbacks
879 virtual void set_custom_renderer(bool bOn
) = 0;
880 // create a virtual device compatible with the device passed in render_args wrt alpha
881 virtual VclPtr
<VirtualDevice
> create_render_virtual_device() const = 0;
882 // set a sub menu for a entry, only works with custom rendering
883 virtual void set_item_menu(const OUString
& rIdent
, weld::Menu
* pMenu
) = 0;
884 // get the width needed to show the menu launcher in a custom row
885 virtual int get_menu_button_width() const = 0;
888 virtual int get_max_mru_count() const = 0;
889 virtual void set_max_mru_count(int nCount
) = 0;
890 virtual OUString
get_mru_entries() const = 0;
891 virtual void set_mru_entries(const OUString
& rEntries
) = 0;
894 enum class ColumnToggleType
900 class VCL_DLLPUBLIC TreeIter
903 TreeIter(const TreeIter
&) = delete;
904 TreeIter
& operator=(const TreeIter
&) = delete;
908 virtual bool equal(const TreeIter
& rOther
) const = 0;
909 virtual ~TreeIter() {}
912 /* Model column indexes are considered to begin at 0, but with special columns
913 before index 0. A expander image column (and an additional optional toggle
914 button column when enable_toggle_buttons is used). Column index -1 is
915 reserved to access those columns.
917 class VCL_DLLPUBLIC TreeView
: virtual public Widget
919 friend class ::LOKTrigger
;
922 typedef std::pair
<const TreeIter
&, int> iter_col
;
923 typedef std::pair
<const TreeIter
&, OUString
> iter_string
;
924 // OUString is the id of the row, it may be null to measure the height of a generic line
925 typedef std::pair
<vcl::RenderContext
&, const OUString
&> get_size_args
;
926 typedef std::tuple
<vcl::RenderContext
&, const tools::Rectangle
&, bool, const OUString
&>
930 OUString m_sSavedValue
;
933 Link
<TreeView
&, void> m_aChangeHdl
;
934 Link
<TreeView
&, bool> m_aRowActivatedHdl
;
935 Link
<int, void> m_aColumnClickedHdl
;
936 Link
<const iter_col
&, void> m_aRadioToggleHdl
;
937 Link
<const TreeIter
&, bool> m_aEditingStartedHdl
;
938 Link
<const iter_string
&, bool> m_aEditingDoneHdl
;
939 // if handler returns false, the expansion of the row is refused
940 Link
<const TreeIter
&, bool> m_aExpandingHdl
;
941 // if handler returns false, the collapse of the row is refused
942 Link
<const TreeIter
&, bool> m_aCollapsingHdl
;
943 Link
<TreeView
&, void> m_aVisibleRangeChangedHdl
;
944 Link
<TreeView
&, void> m_aModelChangedHdl
;
945 // if handler returns true, then menu has been show and event is consumed
946 Link
<const CommandEvent
&, bool> m_aPopupMenuHdl
;
947 // if handler returns true, drag is disallowed, consumer can change bool
948 // arg to false to disable the treeview default dnd icon
949 Link
<bool&, bool> m_aDragBeginHdl
;
950 std::function
<int(const weld::TreeIter
&, const weld::TreeIter
&)> m_aCustomSort
;
953 void signal_changed() { m_aChangeHdl
.Call(*this); }
954 bool signal_row_activated() { return m_aRowActivatedHdl
.Call(*this); }
955 void signal_column_clicked(int nColumn
) { m_aColumnClickedHdl
.Call(nColumn
); }
956 bool signal_expanding(const TreeIter
& rIter
)
958 return !m_aExpandingHdl
.IsSet() || m_aExpandingHdl
.Call(rIter
);
960 bool signal_collapsing(const TreeIter
& rIter
)
962 return !m_aCollapsingHdl
.IsSet() || m_aCollapsingHdl
.Call(rIter
);
964 void signal_visible_range_changed() { m_aVisibleRangeChangedHdl
.Call(*this); }
965 void signal_model_changed() { m_aModelChangedHdl
.Call(*this); }
967 void signal_toggled(const iter_col
& rIterCol
) { m_aRadioToggleHdl
.Call(rIterCol
); }
969 bool signal_editing_started(const TreeIter
& rIter
) { return m_aEditingStartedHdl
.Call(rIter
); }
971 bool signal_editing_done(const iter_string
& rIterText
)
973 return m_aEditingDoneHdl
.Call(rIterText
);
976 Link
<const TreeIter
&, OUString
> m_aQueryTooltipHdl
;
977 OUString
signal_query_tooltip(const TreeIter
& rIter
) { return m_aQueryTooltipHdl
.Call(rIter
); }
979 Link
<render_args
, void> m_aRenderHdl
;
980 void signal_custom_render(vcl::RenderContext
& rDevice
, const tools::Rectangle
& rRect
,
981 bool bSelected
, const OUString
& rId
)
983 m_aRenderHdl
.Call(render_args(rDevice
, rRect
, bSelected
, rId
));
986 Link
<get_size_args
, Size
> m_aGetSizeHdl
;
987 Size
signal_custom_get_size(vcl::RenderContext
& rDevice
, const OUString
& rId
)
989 return m_aGetSizeHdl
.Call(get_size_args(rDevice
, rId
));
993 virtual void connect_query_tooltip(const Link
<const TreeIter
&, OUString
>& rLink
)
995 assert(!m_aQueryTooltipHdl
.IsSet() || !rLink
.IsSet());
996 m_aQueryTooltipHdl
= rLink
;
999 // see 'expanding on-demand node details' for bChildrenOnDemand of true
1000 virtual void insert(const TreeIter
* pParent
, int pos
, const OUString
* pStr
, const OUString
* pId
,
1001 const OUString
* pIconName
, VirtualDevice
* pImageSurface
,
1002 bool bChildrenOnDemand
, TreeIter
* pRet
)
1005 void insert(int nRow
, TreeIter
* pRet
= nullptr)
1007 insert(nullptr, nRow
, nullptr, nullptr, nullptr, nullptr, false, pRet
);
1010 void append(TreeIter
* pRet
= nullptr) { insert(-1, pRet
); }
1012 void insert(int pos
, const OUString
& rStr
, const OUString
* pId
, const OUString
* pIconName
,
1013 VirtualDevice
* pImageSurface
)
1015 insert(nullptr, pos
, &rStr
, pId
, pIconName
, pImageSurface
, false, nullptr);
1017 void insert_text(int pos
, const OUString
& rStr
)
1019 insert(nullptr, pos
, &rStr
, nullptr, nullptr, nullptr, false, nullptr);
1021 void append_text(const OUString
& rStr
)
1023 insert(nullptr, -1, &rStr
, nullptr, nullptr, nullptr, false, nullptr);
1025 void append(const OUString
& rId
, const OUString
& rStr
)
1027 insert(nullptr, -1, &rStr
, &rId
, nullptr, nullptr, false, nullptr);
1029 void append(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
1031 insert(nullptr, -1, &rStr
, &rId
, &rImage
, nullptr, false, nullptr);
1033 void append(const TreeIter
* pParent
, const OUString
& rStr
)
1035 insert(pParent
, -1, &rStr
, nullptr, nullptr, nullptr, false, nullptr);
1038 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
1039 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
1041 void connect_changed(const Link
<TreeView
&, void>& rLink
) { m_aChangeHdl
= rLink
; }
1043 /* A row is "activated" when the user double clicks a treeview row. It may
1044 also be emitted when a row is selected and Space or Enter is pressed.
1046 a return of "true" means the activation has been handled, a "false" propagates
1047 the activation to the default handler which expands/collapses the row, if possible.
1049 void connect_row_activated(const Link
<TreeView
&, bool>& rLink
) { m_aRowActivatedHdl
= rLink
; }
1051 // Argument is a pair of iter, col describing the toggled node
1052 void connect_toggled(const Link
<const iter_col
&, void>& rLink
) { m_aRadioToggleHdl
= rLink
; }
1054 void connect_column_clicked(const Link
<int, void>& rLink
) { m_aColumnClickedHdl
= rLink
; }
1055 void connect_model_changed(const Link
<TreeView
&, void>& rLink
) { m_aModelChangedHdl
= rLink
; }
1057 virtual OUString
get_selected_text() const = 0;
1058 virtual OUString
get_selected_id() const = 0;
1060 // call before inserting any content and connecting to toggle signals,
1061 // an pre-inserted checkbutton column will exist at the start of every row
1062 // inserted after this call which can be accessed with col index -1
1063 virtual void enable_toggle_buttons(ColumnToggleType eType
) = 0;
1065 virtual void set_clicks_to_toggle(int nToggleBehavior
) = 0;
1068 virtual int get_selected_index() const = 0;
1069 //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1070 virtual void select(int pos
) = 0;
1071 virtual void unselect(int pos
) = 0;
1072 virtual void remove(int pos
) = 0;
1073 // col index -1 gets the first text column
1074 virtual OUString
get_text(int row
, int col
= -1) const = 0;
1075 // col index -1 sets the first text column
1076 virtual void set_text(int row
, const OUString
& rText
, int col
= -1) = 0;
1077 // col index -1 sets all columns
1078 virtual void set_sensitive(int row
, bool bSensitive
, int col
= -1) = 0;
1079 virtual bool get_sensitive(int row
, int col
) const = 0;
1080 virtual void set_id(int row
, const OUString
& rId
) = 0;
1081 // col index -1 sets the expander toggle, enable_toggle_buttons must have been called to create that column
1082 virtual void set_toggle(int row
, TriState eState
, int col
= -1) = 0;
1083 // col index -1 gets the expander toggle, enable_toggle_buttons must have been called to create that column
1084 virtual TriState
get_toggle(int row
, int col
= -1) const = 0;
1085 // col index -1 sets the expander image
1086 virtual void set_image(int row
, const OUString
& rImage
, int col
= -1) = 0;
1087 // col index -1 sets the expander image
1088 virtual void set_image(int row
, VirtualDevice
& rImage
, int col
= -1) = 0;
1089 // col index -1 sets the expander image
1090 virtual void set_image(int row
, const css::uno::Reference
<css::graphic::XGraphic
>& rImage
,
1093 virtual void set_text_emphasis(int row
, bool bOn
, int col
) = 0;
1094 virtual bool get_text_emphasis(int row
, int col
) const = 0;
1095 virtual void set_text_align(int row
, double fAlign
, int col
) = 0;
1096 virtual void swap(int pos1
, int pos2
) = 0;
1097 virtual std::vector
<int> get_selected_rows() const = 0;
1098 virtual void set_font_color(int pos
, const Color
& rColor
) = 0;
1099 // scroll to make 'row' visible, this will also expand all parent rows of 'row' as necessary to
1100 // make 'row' visible
1101 virtual void scroll_to_row(int row
) = 0;
1102 virtual bool is_selected(int pos
) const = 0;
1103 virtual int get_cursor_index() const = 0;
1104 virtual void set_cursor(int pos
) = 0;
1107 virtual int find_text(const OUString
& rText
) const = 0;
1108 //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1109 void select_text(const OUString
& rText
) { select(find_text(rText
)); }
1110 void remove_text(const OUString
& rText
) { remove(find_text(rText
)); }
1111 std::vector
<OUString
> get_selected_rows_text() const
1113 std::vector
<int> aRows(get_selected_rows());
1114 std::vector
<OUString
> aRet
;
1115 aRet
.reserve(aRows
.size());
1116 for (auto a
: aRows
)
1117 aRet
.push_back(get_text(a
));
1122 virtual OUString
get_id(int pos
) const = 0;
1123 virtual int find_id(const OUString
& rId
) const = 0;
1124 //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1125 void select_id(const OUString
& rId
) { select(find_id(rId
)); }
1126 void remove_id(const OUString
& rText
) { remove(find_id(rText
)); }
1129 virtual std::unique_ptr
<TreeIter
> make_iterator(const TreeIter
* pOrig
= nullptr) const = 0;
1130 virtual void copy_iterator(const TreeIter
& rSource
, TreeIter
& rDest
) const = 0;
1131 virtual bool get_selected(TreeIter
* pIter
) const = 0;
1132 virtual bool get_cursor(TreeIter
* pIter
) const = 0;
1133 virtual void set_cursor(const TreeIter
& rIter
) = 0;
1134 virtual bool get_iter_first(TreeIter
& rIter
) const = 0;
1135 // set iter to point to next node at the current level
1136 virtual bool iter_next_sibling(TreeIter
& rIter
) const = 0;
1137 // set iter to point to previous node at the current level
1138 virtual bool iter_previous_sibling(TreeIter
& rIter
) const = 0;
1139 // set iter to point to next node, depth first, then sibling
1140 virtual bool iter_next(TreeIter
& rIter
) const = 0;
1141 // set iter to point to previous node, sibling first then depth
1142 virtual bool iter_previous(TreeIter
& rIter
) const = 0;
1143 // set iter to point to first child node
1144 virtual bool iter_children(TreeIter
& rIter
) const = 0;
1145 bool iter_nth_sibling(TreeIter
& rIter
, int nChild
) const
1148 for (int i
= 0; i
< nChild
&& bRet
; ++i
)
1149 bRet
= iter_next_sibling(rIter
);
1152 bool iter_nth_child(TreeIter
& rIter
, int nChild
) const
1154 if (!iter_children(rIter
))
1156 return iter_nth_sibling(rIter
, nChild
);
1158 virtual bool iter_parent(TreeIter
& rIter
) const = 0;
1159 virtual int get_iter_depth(const TreeIter
& rIter
) const = 0;
1160 virtual int get_iter_index_in_parent(const TreeIter
& rIter
) const = 0;
1161 /* Compares two paths. If a appears before b in a tree, then -1 is returned.
1162 If b appears before a , then 1 is returned. If the two nodes are equal,
1165 virtual int iter_compare(const TreeIter
& a
, const TreeIter
& b
) const = 0;
1166 virtual bool iter_has_child(const TreeIter
& rIter
) const = 0;
1167 // returns the number of direct children rIter has
1168 virtual int iter_n_children(const TreeIter
& rIter
) const = 0;
1169 virtual void remove(const TreeIter
& rIter
) = 0;
1170 //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1171 virtual void select(const TreeIter
& rIter
) = 0;
1172 virtual void unselect(const TreeIter
& rIter
) = 0;
1173 //visually indent this row as if it was at get_iter_depth() + nIndentLevel
1174 virtual void set_extra_row_indent(const TreeIter
& rIter
, int nIndentLevel
) = 0;
1175 // col index -1 sets the first text column
1176 virtual void set_text(const TreeIter
& rIter
, const OUString
& rStr
, int col
= -1) = 0;
1177 // col index -1 sets all columns
1178 virtual void set_sensitive(const TreeIter
& rIter
, bool bSensitive
, int col
= -1) = 0;
1179 virtual bool get_sensitive(const TreeIter
& rIter
, int col
) const = 0;
1180 virtual void set_text_emphasis(const TreeIter
& rIter
, bool bOn
, int col
) = 0;
1181 virtual bool get_text_emphasis(const TreeIter
& rIter
, int col
) const = 0;
1182 virtual void set_text_align(const TreeIter
& rIter
, double fAlign
, int col
) = 0;
1183 // col index -1 sets the expander toggle, enable_toggle_buttons must have been called to create that column
1184 virtual void set_toggle(const TreeIter
& rIter
, TriState bOn
, int col
= -1) = 0;
1185 // col index -1 gets the expander toggle, enable_toggle_buttons must have been called to create that column
1186 virtual TriState
get_toggle(const TreeIter
& rIter
, int col
= -1) const = 0;
1187 // col index -1 gets the first text column
1188 virtual OUString
get_text(const TreeIter
& rIter
, int col
= -1) const = 0;
1189 virtual void set_id(const TreeIter
& rIter
, const OUString
& rId
) = 0;
1190 virtual OUString
get_id(const TreeIter
& rIter
) const = 0;
1191 // col index -1 sets the expander image
1192 virtual void set_image(const TreeIter
& rIter
, const OUString
& rImage
, int col
= -1) = 0;
1193 // col index -1 sets the expander image
1194 virtual void set_image(const TreeIter
& rIter
, VirtualDevice
& rImage
, int col
= -1) = 0;
1195 // col index -1 sets the expander image
1196 virtual void set_image(const TreeIter
& rIter
,
1197 const css::uno::Reference
<css::graphic::XGraphic
>& rImage
, int col
= -1)
1199 virtual void set_font_color(const TreeIter
& rIter
, const Color
& rColor
) = 0;
1200 // scroll to make rIter visible, this will also expand all parent rows of rIter as necessary to
1201 // make rIter visible
1202 virtual void scroll_to_row(const TreeIter
& rIter
) = 0;
1203 virtual bool is_selected(const TreeIter
& rIter
) const = 0;
1205 virtual void move_subtree(TreeIter
& rNode
, const TreeIter
* pNewParent
, int nIndexInNewParent
)
1208 // call func on each element until func returns true or we run out of elements
1209 virtual void all_foreach(const std::function
<bool(TreeIter
&)>& func
) = 0;
1210 // call func on each selected element until func returns true or we run out of elements
1211 virtual void selected_foreach(const std::function
<bool(TreeIter
&)>& func
) = 0;
1212 // call func on each visible element until func returns true or we run out of elements
1213 virtual void visible_foreach(const std::function
<bool(TreeIter
&)>& func
) = 0;
1214 // clear the children of pParent (whole tree if nullptr),
1215 // then add nSourceCount rows under pParent, call func on each row
1216 // inserted with an arg of the index that this row will be when bulk insert
1219 // this enables inserting the entries backwards in models where that is faster,
1221 // pFixedWidths is optional, when present each matching entry col text
1222 // width will not be measured, and the fixed width used instead. Use
1223 // sparingly because wider text than the fixed width is clipped and cannot
1224 // be scrolled into view horizontally.
1225 virtual void bulk_insert_for_each(int nSourceCount
,
1226 const std::function
<void(TreeIter
&, int nSourceIndex
)>& func
,
1227 const weld::TreeIter
* pParent
= nullptr,
1228 const std::vector
<int>* pFixedWidths
= nullptr)
1231 /* expanding on-demand node details
1233 When a node is added with children-on-demand (typically via 'insert' with
1234 bChildrenOnDemand of true), then initially in reality the
1235 children-on-demand node is given a 'placeholder' child entry to indicate
1236 the load-on-demand state.
1238 The 'placeholder' needs to be there for the expander indicator to be
1239 drawn/shown even when there are no "real" entries yet. This child doesn't
1240 exist for the purposes of any of the iterator methods, e.g. iter_has_child
1241 on an on-demand node which hasn't been expanded yet is false. Likewise the
1242 rest of the iterator methods skip over or otherwise ignore that node.
1244 Normal usage is the user clicks on the expander, the expansion mechanism
1245 removes the 'placeholder' entry (set_children_on_demand(false)) and calls
1246 any installed expanding-callback (installable via connect_expanding) which
1247 has the opportunity to populate the node with children.
1249 If you decide to directly populate the children of an on-demand node
1250 outside of the expanding-callback then you also need to explicitly remove
1251 the 'placeholder' with set_children_on_demand(false) otherwise the treeview
1252 is in an inconsistent state. */
1254 virtual bool get_row_expanded(const TreeIter
& rIter
) const = 0;
1255 // expand row will first trigger the callback set via connect_expanding before expanding
1256 virtual void expand_row(const TreeIter
& rIter
) = 0;
1257 // collapse row will first trigger the callback set via connect_collapsing before collapsing
1258 virtual void collapse_row(const TreeIter
& rIter
) = 0;
1259 // set the empty node to appear as if it has children, true is equivalent
1260 // to 'insert' with a bChildrenOnDemand of true. See notes above.
1261 virtual void set_children_on_demand(const TreeIter
& rIter
, bool bChildrenOnDemand
) = 0;
1262 // return if the node is configured to be populated on-demand
1263 virtual bool get_children_on_demand(const TreeIter
& rIter
) const = 0;
1264 // set if the expanders are shown or not
1265 virtual void set_show_expanders(bool bShow
) = 0;
1267 void connect_expanding(const Link
<const TreeIter
&, bool>& rLink
) { m_aExpandingHdl
= rLink
; }
1268 void connect_collapsing(const Link
<const TreeIter
&, bool>& rLink
) { m_aCollapsingHdl
= rLink
; }
1270 // rStartLink returns true to allow editing, false to disallow
1271 // rEndLink returns true to accept the edit, false to reject
1272 virtual void connect_editing(const Link
<const TreeIter
&, bool>& rStartLink
,
1273 const Link
<const iter_string
&, bool>& rEndLink
)
1275 assert(rStartLink
.IsSet() == rEndLink
.IsSet() && "should be both on or both off");
1276 m_aEditingStartedHdl
= rStartLink
;
1277 m_aEditingDoneHdl
= rEndLink
;
1280 virtual void start_editing(const weld::TreeIter
& rEntry
) = 0;
1281 virtual void end_editing() = 0;
1283 virtual void connect_visible_range_changed(const Link
<TreeView
&, void>& rLink
)
1285 assert(!m_aVisibleRangeChangedHdl
.IsSet() || !rLink
.IsSet());
1286 m_aVisibleRangeChangedHdl
= rLink
;
1289 virtual void connect_popup_menu(const Link
<const CommandEvent
&, bool>& rLink
)
1291 m_aPopupMenuHdl
= rLink
;
1294 virtual void enable_drag_source(rtl::Reference
<TransferDataContainer
>& rTransferable
,
1295 sal_uInt8 eDNDConstants
)
1298 void connect_drag_begin(const Link
<bool&, bool>& rLink
) { m_aDragBeginHdl
= rLink
; }
1300 //all of them. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1301 void select_all() { unselect(-1); }
1302 void unselect_all() { select(-1); }
1304 // return the number of toplevel nodes
1305 virtual int n_children() const = 0;
1307 // afterwards, entries will be in default ascending sort order
1308 virtual void make_sorted() = 0;
1309 virtual void make_unsorted() = 0;
1310 virtual bool get_sort_order() const = 0;
1311 virtual void set_sort_order(bool bAscending
) = 0;
1313 // TRUE ascending, FALSE, descending, INDET, neither (off)
1314 virtual void set_sort_indicator(TriState eState
, int nColumn
) = 0;
1315 virtual TriState
get_sort_indicator(int nColumn
) const = 0;
1317 virtual int get_sort_column() const = 0;
1318 virtual void set_sort_column(int nColumn
) = 0;
1321 set_sort_func(const std::function
<int(const weld::TreeIter
&, const weld::TreeIter
&)>& func
)
1323 m_aCustomSort
= func
;
1326 virtual void clear() = 0;
1327 virtual int get_height_rows(int nRows
) const = 0;
1329 virtual void columns_autosize() = 0;
1330 virtual void set_column_fixed_widths(const std::vector
<int>& rWidths
) = 0;
1331 virtual void set_column_editables(const std::vector
<bool>& rEditables
) = 0;
1332 virtual int get_column_width(int nCol
) const = 0;
1333 virtual void set_centered_column(int nCol
) = 0;
1334 virtual OUString
get_column_title(int nColumn
) const = 0;
1335 virtual void set_column_title(int nColumn
, const OUString
& rTitle
) = 0;
1337 int get_checkbox_column_width() const { return get_approximate_digit_width() * 3 + 6; }
1339 virtual void set_selection_mode(SelectionMode eMode
) = 0;
1340 virtual int count_selected_rows() const = 0;
1341 // remove the selected nodes
1342 virtual void remove_selection() = 0;
1344 // only meaningful is call this from a "changed" callback, true if the change
1345 // was due to mouse hovering over the entry
1346 virtual bool changed_by_hover() const = 0;
1348 virtual void vadjustment_set_value(int value
) = 0;
1349 virtual int vadjustment_get_value() const = 0;
1351 void save_value() { m_sSavedValue
= get_selected_text(); }
1352 OUString
const& get_saved_value() const { return m_sSavedValue
; }
1353 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_selected_text(); }
1355 // for custom rendering a cell
1356 void connect_custom_get_size(const Link
<get_size_args
, Size
>& rLink
) { m_aGetSizeHdl
= rLink
; }
1357 void connect_custom_render(const Link
<render_args
, void>& rLink
) { m_aRenderHdl
= rLink
; }
1358 // call set_column_custom_renderer after setting custom callbacks
1359 virtual void set_column_custom_renderer(int nColumn
, bool bEnable
) = 0;
1360 // redraw all rows, typically only useful with custom rendering to redraw due to external
1362 virtual void queue_draw() = 0;
1364 /* with bDnDMode false simply return the row under the point
1366 * with bDnDMode true:
1367 * a) return the row which should be dropped on, which may
1368 * be different from the row the mouse is over in some backends where
1369 * positioning the mouse on the bottom half of a row indicates to drop
1371 * b) dnd highlight the dest row
1373 virtual bool get_dest_row_at_pos(const Point
& rPos
, weld::TreeIter
* pResult
, bool bDnDMode
,
1374 bool bAutoScroll
= true)
1376 virtual void unset_drag_dest_row() = 0;
1377 virtual tools::Rectangle
get_row_area(const weld::TreeIter
& rIter
) const = 0;
1378 // for dragging and dropping between TreeViews, return the active source
1379 virtual TreeView
* get_drag_source() const = 0;
1381 using Widget::set_sensitive
;
1382 using Widget::get_sensitive
;
1385 typedef std::tuple
<tools::JsonWriter
&, const TreeIter
&, std::string_view
> json_prop_query
;
1387 class VCL_DLLPUBLIC IconView
: virtual public Widget
1389 friend class ::LOKTrigger
;
1392 OUString m_sSavedValue
;
1395 Link
<IconView
&, void> m_aSelectionChangeHdl
;
1396 Link
<IconView
&, bool> m_aItemActivatedHdl
;
1397 Link
<const CommandEvent
&, bool> m_aCommandHdl
;
1398 Link
<const TreeIter
&, OUString
> m_aQueryTooltipHdl
;
1399 Link
<const json_prop_query
&, bool> m_aGetPropertyTreeElemHdl
;
1401 void signal_selection_changed() { m_aSelectionChangeHdl
.Call(*this); }
1402 bool signal_item_activated() { return m_aItemActivatedHdl
.Call(*this); }
1403 OUString
signal_query_tooltip(const TreeIter
& rIter
) const
1405 return m_aQueryTooltipHdl
.Call(rIter
);
1409 virtual int get_item_width() const = 0;
1410 virtual void set_item_width(int width
) = 0;
1412 virtual void insert(int pos
, const OUString
* pStr
, const OUString
* pId
,
1413 const OUString
* pIconName
, TreeIter
* pRet
)
1416 virtual void insert(int pos
, const OUString
* pStr
, const OUString
* pId
,
1417 const VirtualDevice
* pIcon
, TreeIter
* pRet
)
1420 virtual void insert_separator(int pos
, const OUString
* pId
) = 0;
1422 void append(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
1424 insert(-1, &rStr
, &rId
, &rImage
, nullptr);
1427 void append(const OUString
& rId
, const OUString
& rStr
, const VirtualDevice
* pImage
)
1429 insert(-1, &rStr
, &rId
, pImage
, nullptr);
1432 void append_separator(const OUString
& rId
) { insert_separator(-1, &rId
); }
1434 void connect_selection_changed(const Link
<IconView
&, void>& rLink
)
1436 m_aSelectionChangeHdl
= rLink
;
1439 /* A row is "activated" when the user double clicks a treeview row. It may
1440 also be emitted when a row is selected and Space or Enter is pressed.
1442 a return of "true" means the activation has been handled, a "false" propagates
1443 the activation to the default handler which expands/collapses the row, if possible.
1445 void connect_item_activated(const Link
<IconView
&, bool>& rLink
) { m_aItemActivatedHdl
= rLink
; }
1447 void connect_command(const Link
<const CommandEvent
&, bool>& rLink
) { m_aCommandHdl
= rLink
; }
1449 virtual void connect_query_tooltip(const Link
<const TreeIter
&, OUString
>& rLink
)
1451 m_aQueryTooltipHdl
= rLink
;
1454 // 0: json writer, 1: TreeIter, 2: property. returns true if supported
1455 virtual void connect_get_property_tree_elem(const Link
<const json_prop_query
&, bool>& rLink
)
1457 m_aGetPropertyTreeElemHdl
= rLink
;
1460 virtual OUString
get_selected_id() const = 0;
1462 virtual void clear() = 0;
1464 virtual int count_selected_items() const = 0;
1466 virtual OUString
get_selected_text() const = 0;
1468 //by index. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1469 virtual void select(int pos
) = 0;
1470 virtual void unselect(int pos
) = 0;
1473 virtual std::unique_ptr
<TreeIter
> make_iterator(const TreeIter
* pOrig
= nullptr) const = 0;
1474 virtual bool get_selected(TreeIter
* pIter
) const = 0;
1475 virtual bool get_cursor(TreeIter
* pIter
) const = 0;
1476 virtual void set_cursor(const TreeIter
& rIter
) = 0;
1477 virtual bool get_iter_first(TreeIter
& rIter
) const = 0;
1478 virtual OUString
get_id(const TreeIter
& rIter
) const = 0;
1479 virtual OUString
get_text(const TreeIter
& rIter
) const = 0;
1480 virtual void scroll_to_item(const TreeIter
& rIter
) = 0;
1482 // call func on each selected element until func returns true or we run out of elements
1483 virtual void selected_foreach(const std::function
<bool(TreeIter
&)>& func
) = 0;
1485 //all of them. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1486 void select_all() { unselect(-1); }
1487 void unselect_all() { select(-1); }
1489 // return the number of toplevel nodes
1490 virtual int n_children() const = 0;
1492 void save_value() { m_sSavedValue
= get_selected_text(); }
1493 OUString
const& get_saved_value() const { return m_sSavedValue
; }
1494 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_selected_text(); }
1497 class VCL_DLLPUBLIC Button
: virtual public Widget
1499 friend class ::LOKTrigger
;
1502 Link
<Button
&, void> m_aClickHdl
;
1504 void signal_clicked() { m_aClickHdl
.Call(*this); }
1507 virtual void set_label(const OUString
& rText
) = 0;
1508 // pDevice, the image for the button, or nullptr to unset
1509 virtual void set_image(VirtualDevice
* pDevice
) = 0;
1510 virtual void set_image(const css::uno::Reference
<css::graphic::XGraphic
>& rImage
) = 0;
1511 virtual void set_from_icon_name(const OUString
& rIconName
) = 0;
1512 virtual OUString
get_label() const = 0;
1513 void clicked() { signal_clicked(); }
1514 bool is_custom_handler_set() { return m_aClickHdl
.IsSet(); }
1516 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
1517 virtual void set_font(const vcl::Font
& rFont
) = 0;
1519 /* Sometimes, a widget should behave like a button (activate on click,
1520 accept keyboard focus, etc), but look entirely different.
1522 pDevice, the custom look to use, or nullptr to unset.
1524 Typically doing this is ill advised. Consider using
1525 set_accessible_name if you do. */
1526 virtual void set_custom_button(VirtualDevice
* pDevice
) = 0;
1528 void connect_clicked(const Link
<Button
&, void>& rLink
) { m_aClickHdl
= rLink
; }
1531 class VCL_DLLPUBLIC Toggleable
: virtual public Widget
1533 friend class ::LOKTrigger
;
1536 Link
<Toggleable
&, void> m_aToggleHdl
;
1537 TriState m_eSavedValue
= TRISTATE_FALSE
;
1539 void signal_toggled() { m_aToggleHdl
.Call(*this); }
1542 virtual void set_active(bool active
) = 0;
1543 virtual bool get_active() const = 0;
1545 virtual void set_inconsistent(bool inconsistent
) = 0;
1546 virtual bool get_inconsistent() const = 0;
1548 TriState
get_state() const
1550 if (get_inconsistent())
1551 return TRISTATE_INDET
;
1552 else if (get_active())
1553 return TRISTATE_TRUE
;
1554 return TRISTATE_FALSE
;
1557 void set_state(TriState eState
)
1561 case TRISTATE_INDET
:
1562 set_inconsistent(true);
1565 set_inconsistent(false);
1568 case TRISTATE_FALSE
:
1569 set_inconsistent(false);
1575 void save_state() { m_eSavedValue
= get_state(); }
1576 TriState
get_saved_state() const { return m_eSavedValue
; }
1577 bool get_state_changed_from_saved() const { return m_eSavedValue
!= get_state(); }
1579 virtual void connect_toggled(const Link
<Toggleable
&, void>& rLink
) { m_aToggleHdl
= rLink
; }
1582 class VCL_DLLPUBLIC ToggleButton
: virtual public Button
, virtual public Toggleable
1584 friend class ::LOKTrigger
;
1587 struct VCL_DLLPUBLIC TriStateEnabled
1590 bool bTriStateEnabled
;
1592 : eState(TRISTATE_INDET
)
1593 , bTriStateEnabled(true)
1596 void ButtonToggled(Toggleable
& rToggle
);
1599 class VCL_DLLPUBLIC MenuButton
: virtual public ToggleButton
1601 friend class ::LOKTrigger
;
1603 Link
<const OUString
&, void> m_aSelectHdl
;
1606 void signal_selected(const OUString
& rIdent
) { m_aSelectHdl
.Call(rIdent
); }
1609 void connect_selected(const Link
<const OUString
&, void>& rLink
) { m_aSelectHdl
= rLink
; }
1611 virtual void insert_item(int pos
, const OUString
& rId
, const OUString
& rStr
,
1612 const OUString
* pIconName
, VirtualDevice
* pImageSurface
,
1613 TriState eCheckRadioFalse
)
1615 void append_item(const OUString
& rId
, const OUString
& rStr
)
1617 insert_item(-1, rId
, rStr
, nullptr, nullptr, TRISTATE_INDET
);
1619 void append_item_check(const OUString
& rId
, const OUString
& rStr
)
1621 insert_item(-1, rId
, rStr
, nullptr, nullptr, TRISTATE_TRUE
);
1623 void append_item_radio(const OUString
& rId
, const OUString
& rStr
)
1625 insert_item(-1, rId
, rStr
, nullptr, nullptr, TRISTATE_FALSE
);
1627 void append_item(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
1629 insert_item(-1, rId
, rStr
, &rImage
, nullptr, TRISTATE_INDET
);
1631 void append_item(const OUString
& rId
, const OUString
& rStr
, VirtualDevice
& rImage
)
1633 insert_item(-1, rId
, rStr
, nullptr, &rImage
, TRISTATE_INDET
);
1635 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
1636 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
1637 virtual void remove_item(const OUString
& rId
) = 0;
1638 virtual void clear() = 0;
1639 virtual void set_item_sensitive(const OUString
& rIdent
, bool bSensitive
) = 0;
1640 virtual void set_item_active(const OUString
& rIdent
, bool bActive
) = 0;
1641 virtual void set_item_label(const OUString
& rIdent
, const OUString
& rLabel
) = 0;
1642 virtual OUString
get_item_label(const OUString
& rIdent
) const = 0;
1643 virtual void set_item_visible(const OUString
& rIdent
, bool bVisible
) = 0;
1645 virtual void set_popover(weld::Widget
* pPopover
) = 0;
1648 // Similar to a MenuButton except it is split into two parts, a toggle
1649 // button at the start and a menubutton at the end
1650 class VCL_DLLPUBLIC MenuToggleButton
: virtual public MenuButton
1654 class VCL_DLLPUBLIC CheckButton
: virtual public Toggleable
1657 virtual void set_label(const OUString
& rText
) = 0;
1658 virtual OUString
get_label() const = 0;
1659 virtual void set_label_wrap(bool wrap
) = 0;
1662 class VCL_DLLPUBLIC RadioButton
: virtual public CheckButton
1666 class VCL_DLLPUBLIC LinkButton
: virtual public Widget
1668 Link
<LinkButton
&, bool> m_aActivateLinkHdl
;
1671 bool signal_activate_link() { return m_aActivateLinkHdl
.Call(*this); }
1674 virtual void set_label(const OUString
& rText
) = 0;
1675 virtual OUString
get_label() const = 0;
1676 virtual void set_label_wrap(bool wrap
) = 0;
1677 virtual void set_uri(const OUString
& rUri
) = 0;
1678 virtual OUString
get_uri() const = 0;
1680 void connect_activate_link(const Link
<LinkButton
&, bool>& rLink
) { m_aActivateLinkHdl
= rLink
; }
1683 class VCL_DLLPUBLIC Scale
: virtual public Widget
1685 Link
<Scale
&, void> m_aValueChangedHdl
;
1688 void signal_value_changed() { m_aValueChangedHdl
.Call(*this); }
1691 virtual void set_value(int value
) = 0;
1692 virtual int get_value() const = 0;
1693 virtual void set_range(int min
, int max
) = 0;
1695 virtual void set_increments(int step
, int page
) = 0;
1696 virtual void get_increments(int& step
, int& page
) const = 0;
1698 void connect_value_changed(const Link
<Scale
&, void>& rLink
) { m_aValueChangedHdl
= rLink
; }
1701 class VCL_DLLPUBLIC Spinner
: virtual public Widget
1704 virtual void start() = 0;
1705 virtual void stop() = 0;
1708 class VCL_DLLPUBLIC ProgressBar
: virtual public Widget
1712 virtual void set_percentage(int value
) = 0;
1713 virtual OUString
get_text() const = 0;
1714 virtual void set_text(const OUString
& rText
) = 0;
1717 class VCL_DLLPUBLIC Entry
: virtual public Widget
1720 OUString m_sSavedValue
;
1723 Link
<Entry
&, void> m_aChangeHdl
;
1724 Link
<OUString
&, bool> m_aInsertTextHdl
;
1725 Link
<Entry
&, void> m_aCursorPositionHdl
;
1726 Link
<Entry
&, bool> m_aActivateHdl
;
1728 friend class ::LOKTrigger
;
1730 void signal_changed() { m_aChangeHdl
.Call(*this); }
1731 void signal_cursor_position() { m_aCursorPositionHdl
.Call(*this); }
1734 virtual void set_text(const OUString
& rText
) = 0;
1735 virtual OUString
get_text() const = 0;
1736 virtual void set_width_chars(int nChars
) = 0;
1737 virtual int get_width_chars() const = 0;
1738 // The maximum length of the entry. Use 0 for no maximum
1739 virtual void set_max_length(int nChars
) = 0;
1740 // nEndPos can be -1 in order to select all text
1741 virtual void select_region(int nStartPos
, int nEndPos
) = 0;
1742 // returns true if the selection has nonzero length
1743 virtual bool get_selection_bounds(int& rStartPos
, int& rEndPos
) = 0;
1744 virtual void replace_selection(const OUString
& rText
) = 0;
1745 // nCursorPos can be -1 to set to the end
1746 virtual void set_position(int nCursorPos
) = 0;
1747 virtual int get_position() const = 0;
1748 virtual void set_editable(bool bEditable
) = 0;
1749 virtual bool get_editable() const = 0;
1750 virtual void set_message_type(EntryMessageType eType
) = 0;
1751 virtual void set_placeholder_text(const OUString
& rText
) = 0;
1753 virtual void set_overwrite_mode(bool bOn
) = 0;
1754 virtual bool get_overwrite_mode() const = 0;
1756 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
1757 virtual void set_font(const vcl::Font
& rFont
) = 0;
1760 If you want to set a warning or error state, see set_message_type
1761 instead where, if the toolkit supports it, a specific warning/error
1764 This explicit text color method exists to support rendering the
1765 SvNumberformat color feature.
1767 virtual void set_font_color(const Color
& rColor
) = 0;
1769 virtual void connect_changed(const Link
<Entry
&, void>& rLink
) { m_aChangeHdl
= rLink
; }
1770 void connect_insert_text(const Link
<OUString
&, bool>& rLink
) { m_aInsertTextHdl
= rLink
; }
1771 // callback returns true to indicated no further processing of activate wanted
1772 void connect_activate(const Link
<Entry
&, bool>& rLink
) { m_aActivateHdl
= rLink
; }
1773 virtual void connect_cursor_position(const Link
<Entry
&, void>& rLink
)
1775 m_aCursorPositionHdl
= rLink
;
1778 virtual void cut_clipboard() = 0;
1779 virtual void copy_clipboard() = 0;
1780 virtual void paste_clipboard() = 0;
1782 virtual void set_alignment(TxtAlign eXAlign
) = 0;
1784 void save_value() { m_sSavedValue
= get_text(); }
1785 OUString
const& get_saved_value() const { return m_sSavedValue
; }
1786 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_text(); }
1789 class VCL_DLLPUBLIC SpinButton
: virtual public Entry
1791 friend class ::LOKTrigger
;
1793 Link
<SpinButton
&, void> m_aValueChangedHdl
;
1794 Link
<SpinButton
&, void> m_aOutputHdl
;
1795 Link
<int*, bool> m_aInputHdl
;
1798 void signal_value_changed() { m_aValueChangedHdl
.Call(*this); }
1800 bool signal_output()
1802 if (!m_aOutputHdl
.IsSet())
1804 m_aOutputHdl
.Call(*this);
1808 TriState
signal_input(int* result
)
1810 if (!m_aInputHdl
.IsSet())
1811 return TRISTATE_INDET
;
1812 return m_aInputHdl
.Call(result
) ? TRISTATE_TRUE
: TRISTATE_FALSE
;
1816 virtual void set_value(sal_Int64 value
) = 0;
1817 virtual sal_Int64
get_value() const = 0;
1818 virtual void set_range(sal_Int64 min
, sal_Int64 max
) = 0;
1819 virtual void get_range(sal_Int64
& min
, sal_Int64
& max
) const = 0;
1820 void set_min(sal_Int64 min
)
1822 sal_Int64 dummy
, max
;
1823 get_range(dummy
, max
);
1824 set_range(min
, max
);
1826 void set_max(sal_Int64 max
)
1828 sal_Int64 min
, dummy
;
1829 get_range(min
, dummy
);
1830 set_range(min
, max
);
1832 sal_Int64
get_min() const
1834 sal_Int64 min
, dummy
;
1835 get_range(min
, dummy
);
1838 sal_Int64
get_max() const
1840 sal_Int64 dummy
, max
;
1841 get_range(dummy
, max
);
1844 virtual void set_increments(int step
, int page
) = 0;
1845 virtual void get_increments(int& step
, int& page
) const = 0;
1846 virtual void set_digits(unsigned int digits
) = 0;
1847 virtual unsigned int get_digits() const = 0;
1849 void connect_value_changed(const Link
<SpinButton
&, void>& rLink
) { m_aValueChangedHdl
= rLink
; }
1851 void connect_output(const Link
<SpinButton
&, void>& rLink
) { m_aOutputHdl
= rLink
; }
1852 void connect_input(const Link
<int*, bool>& rLink
) { m_aInputHdl
= rLink
; }
1854 sal_Int64
normalize(sal_Int64 nValue
) const { return (nValue
* Power10(get_digits())); }
1856 sal_Int64
denormalize(sal_Int64 nValue
) const;
1858 static unsigned int Power10(unsigned int n
);
1861 class EntryFormatter
;
1863 // Similar to a SpinButton, but input and output formatting and range/value
1864 // are managed by a more complex Formatter which can support doubles.
1865 class VCL_DLLPUBLIC FormattedSpinButton
: virtual public Entry
1867 Link
<FormattedSpinButton
&, void> m_aValueChangedHdl
;
1870 void signal_value_changed() { m_aValueChangedHdl
.Call(*this); }
1873 virtual Formatter
& GetFormatter() = 0;
1874 // does not take ownership, and so must be deregistered if pFormatter
1876 virtual void SetFormatter(weld::EntryFormatter
* pFormatter
) = 0;
1878 void connect_value_changed(const Link
<FormattedSpinButton
&, void>& rLink
)
1880 m_aValueChangedHdl
= rLink
;
1884 friend class EntryFormatter
;
1885 virtual void sync_range_from_formatter() = 0;
1886 virtual void sync_value_from_formatter() = 0;
1887 virtual void sync_increments_from_formatter() = 0;
1890 class VCL_DLLPUBLIC Image
: virtual public Widget
1893 virtual void set_from_icon_name(const OUString
& rIconName
) = 0;
1894 virtual void set_image(VirtualDevice
* pDevice
) = 0;
1895 virtual void set_image(const css::uno::Reference
<css::graphic::XGraphic
>& rImage
) = 0;
1898 class VCL_DLLPUBLIC Calendar
: virtual public Widget
1900 Link
<Calendar
&, void> m_aSelectedHdl
;
1901 Link
<Calendar
&, void> m_aActivatedHdl
;
1904 void signal_selected() { m_aSelectedHdl
.Call(*this); }
1905 void signal_activated() { m_aActivatedHdl
.Call(*this); }
1908 void connect_selected(const Link
<Calendar
&, void>& rLink
) { m_aSelectedHdl
= rLink
; }
1909 void connect_activated(const Link
<Calendar
&, void>& rLink
) { m_aActivatedHdl
= rLink
; }
1911 virtual void set_date(const Date
& rDate
) = 0;
1912 virtual Date
get_date() const = 0;
1915 // an entry + treeview pair, where the entry autocompletes from the
1916 // treeview list, and selecting something in the list sets the
1917 // entry to that text, i.e. a visually exploded ComboBox
1918 class VCL_DLLPUBLIC EntryTreeView
: virtual public ComboBox
1921 DECL_DLLPRIVATE_LINK(ClickHdl
, weld::TreeView
&, void);
1922 DECL_DLLPRIVATE_LINK(ModifyHdl
, weld::Entry
&, void);
1923 void EntryModifyHdl(const weld::Entry
& rEntry
);
1926 std::unique_ptr
<Entry
> m_xEntry
;
1927 std::unique_ptr
<TreeView
> m_xTreeView
;
1930 EntryTreeView(std::unique_ptr
<Entry
> xEntry
, std::unique_ptr
<TreeView
> xTreeView
);
1932 virtual void insert_vector(const std::vector
<weld::ComboBoxEntry
>& rItems
,
1933 bool bKeepExisting
) override
1935 m_xTreeView
->freeze();
1937 m_xTreeView
->clear();
1938 for (const auto& rItem
: rItems
)
1940 m_xTreeView
->thaw();
1943 virtual void insert(int pos
, const OUString
& rStr
, const OUString
* pId
,
1944 const OUString
* pIconName
, VirtualDevice
* pImageSurface
) override
1946 m_xTreeView
->insert(pos
, rStr
, pId
, pIconName
, pImageSurface
);
1949 virtual int get_count() const override
{ return m_xTreeView
->n_children(); }
1950 virtual void clear() override
{ m_xTreeView
->clear(); }
1953 virtual int get_active() const override
{ return m_xTreeView
->get_selected_index(); }
1954 virtual void set_active(int pos
) override
1956 m_xTreeView
->set_cursor(pos
);
1957 m_xTreeView
->select(pos
);
1958 m_xEntry
->set_text(m_xTreeView
->get_selected_text());
1960 virtual void remove(int pos
) override
{ m_xTreeView
->remove(pos
); }
1963 virtual OUString
get_active_text() const override
{ return m_xEntry
->get_text(); }
1964 virtual OUString
get_text(int pos
) const override
{ return m_xTreeView
->get_text(pos
); }
1965 virtual int find_text(const OUString
& rStr
) const override
1967 return m_xTreeView
->find_text(rStr
);
1971 virtual OUString
get_active_id() const override
{ return m_xTreeView
->get_selected_id(); }
1972 virtual void set_active_id(const OUString
& rStr
) override
1974 m_xTreeView
->select_id(rStr
);
1975 m_xEntry
->set_text(m_xTreeView
->get_selected_text());
1977 virtual OUString
get_id(int pos
) const override
{ return m_xTreeView
->get_id(pos
); }
1978 virtual void set_id(int pos
, const OUString
& rId
) override
{ m_xTreeView
->set_id(pos
, rId
); }
1979 virtual int find_id(const OUString
& rId
) const override
{ return m_xTreeView
->find_id(rId
); }
1982 virtual bool has_entry() const override
{ return true; }
1983 virtual void set_entry_message_type(EntryMessageType eType
) override
1985 m_xEntry
->set_message_type(eType
);
1987 virtual void set_entry_text(const OUString
& rStr
) override
{ m_xEntry
->set_text(rStr
); }
1988 virtual void set_entry_width_chars(int nChars
) override
{ m_xEntry
->set_width_chars(nChars
); }
1989 virtual void set_entry_max_length(int nChars
) override
{ m_xEntry
->set_max_length(nChars
); }
1990 virtual void select_entry_region(int nStartPos
, int nEndPos
) override
1992 m_xEntry
->select_region(nStartPos
, nEndPos
);
1994 //if no text was selected, both rStartPos and rEndPos will be identical
1995 //and false will be returned
1996 virtual bool get_entry_selection_bounds(int& rStartPos
, int& rEndPos
) override
1998 return m_xEntry
->get_selection_bounds(rStartPos
, rEndPos
);
2000 void connect_row_activated(const Link
<TreeView
&, bool>& rLink
)
2002 m_xTreeView
->connect_row_activated(rLink
);
2005 virtual bool get_popup_shown() const override
{ return false; }
2007 void set_height_request_by_rows(int nRows
);
2010 class VCL_DLLPUBLIC MetricSpinButton final
2012 FieldUnit m_eSrcUnit
;
2013 std::unique_ptr
<weld::SpinButton
> m_xSpinButton
;
2014 Link
<MetricSpinButton
&, void> m_aValueChangedHdl
;
2016 DECL_LINK(spin_button_value_changed
, weld::SpinButton
&, void);
2017 DECL_LINK(spin_button_output
, weld::SpinButton
&, void);
2018 DECL_LINK(spin_button_input
, int* result
, bool);
2020 void signal_value_changed() { m_aValueChangedHdl
.Call(*this); }
2022 sal_Int64
ConvertValue(sal_Int64 nValue
, FieldUnit eInUnit
, FieldUnit eOutUnit
) const;
2023 OUString
format_number(sal_Int64 nValue
) const;
2024 void update_width_chars();
2027 MetricSpinButton(std::unique_ptr
<SpinButton
> pSpinButton
, FieldUnit eSrcUnit
)
2028 : m_eSrcUnit(eSrcUnit
)
2029 , m_xSpinButton(std::move(pSpinButton
))
2031 update_width_chars();
2032 m_xSpinButton
->connect_output(LINK(this, MetricSpinButton
, spin_button_output
));
2033 m_xSpinButton
->connect_input(LINK(this, MetricSpinButton
, spin_button_input
));
2034 m_xSpinButton
->connect_value_changed(
2035 LINK(this, MetricSpinButton
, spin_button_value_changed
));
2036 spin_button_output(*m_xSpinButton
);
2039 static OUString
MetricToString(FieldUnit rUnit
);
2041 FieldUnit
get_unit() const { return m_eSrcUnit
; }
2043 void set_unit(FieldUnit eUnit
);
2045 sal_Int64
convert_value_to(sal_Int64 nValue
, FieldUnit eValueUnit
) const
2047 return ConvertValue(nValue
, m_eSrcUnit
, eValueUnit
);
2050 sal_Int64
convert_value_from(sal_Int64 nValue
, FieldUnit eValueUnit
) const
2052 return ConvertValue(nValue
, eValueUnit
, m_eSrcUnit
);
2055 void set_value(sal_Int64 nValue
, FieldUnit eValueUnit
)
2057 m_xSpinButton
->set_value(convert_value_from(nValue
, eValueUnit
));
2060 sal_Int64
get_value(FieldUnit eDestUnit
) const
2062 return convert_value_to(m_xSpinButton
->get_value(), eDestUnit
);
2065 // typically you only need to call this if set_text (e.g. with "") was
2066 // previously called to display some arbitrary text instead of the
2067 // formatted value and now you want to show it as formatted again
2068 void reformat() { spin_button_output(*m_xSpinButton
); }
2070 void set_range(sal_Int64 min
, sal_Int64 max
, FieldUnit eValueUnit
)
2072 min
= convert_value_from(min
, eValueUnit
);
2073 max
= convert_value_from(max
, eValueUnit
);
2074 m_xSpinButton
->set_range(min
, max
);
2075 update_width_chars();
2078 void get_range(sal_Int64
& min
, sal_Int64
& max
, FieldUnit eDestUnit
) const
2080 m_xSpinButton
->get_range(min
, max
);
2081 min
= convert_value_to(min
, eDestUnit
);
2082 max
= convert_value_to(max
, eDestUnit
);
2085 void set_min(sal_Int64 min
, FieldUnit eValueUnit
)
2087 sal_Int64 dummy
, max
;
2088 get_range(dummy
, max
, eValueUnit
);
2089 set_range(min
, max
, eValueUnit
);
2092 void set_max(sal_Int64 max
, FieldUnit eValueUnit
)
2094 sal_Int64 min
, dummy
;
2095 get_range(min
, dummy
, eValueUnit
);
2096 set_range(min
, max
, eValueUnit
);
2099 sal_Int64
get_min(FieldUnit eValueUnit
) const
2101 sal_Int64 min
, dummy
;
2102 get_range(min
, dummy
, eValueUnit
);
2106 sal_Int64
get_max(FieldUnit eValueUnit
) const
2108 sal_Int64 dummy
, max
;
2109 get_range(dummy
, max
, eValueUnit
);
2113 void set_increments(int step
, int page
, FieldUnit eValueUnit
)
2115 step
= convert_value_from(step
, eValueUnit
);
2116 page
= convert_value_from(page
, eValueUnit
);
2117 m_xSpinButton
->set_increments(step
, page
);
2120 void get_increments(int& step
, int& page
, FieldUnit eDestUnit
) const
2122 m_xSpinButton
->get_increments(step
, page
);
2123 step
= convert_value_to(step
, eDestUnit
);
2124 page
= convert_value_to(page
, eDestUnit
);
2127 void connect_value_changed(const Link
<MetricSpinButton
&, void>& rLink
)
2129 m_aValueChangedHdl
= rLink
;
2132 sal_Int64
normalize(sal_Int64 nValue
) const { return m_xSpinButton
->normalize(nValue
); }
2133 sal_Int64
denormalize(sal_Int64 nValue
) const { return m_xSpinButton
->denormalize(nValue
); }
2134 void set_sensitive(bool sensitive
) { m_xSpinButton
->set_sensitive(sensitive
); }
2135 bool get_sensitive() const { return m_xSpinButton
->get_sensitive(); }
2136 bool get_visible() const { return m_xSpinButton
->get_visible(); }
2137 void grab_focus() { m_xSpinButton
->grab_focus(); }
2138 bool has_focus() const { return m_xSpinButton
->has_focus(); }
2139 void show() { m_xSpinButton
->show(); }
2140 void set_visible(bool bShow
) { m_xSpinButton
->set_visible(bShow
); }
2141 void hide() { m_xSpinButton
->hide(); }
2142 void set_digits(unsigned int digits
);
2143 void set_accessible_name(const OUString
& rName
) { m_xSpinButton
->set_accessible_name(rName
); }
2144 unsigned int get_digits() const { return m_xSpinButton
->get_digits(); }
2145 void save_value() { m_xSpinButton
->save_value(); }
2146 bool get_value_changed_from_saved() const
2148 return m_xSpinButton
->get_value_changed_from_saved();
2150 void set_text(const OUString
& rText
) { m_xSpinButton
->set_text(rText
); }
2151 OUString
get_text() const { return m_xSpinButton
->get_text(); }
2152 void set_size_request(int nWidth
, int nHeight
)
2154 m_xSpinButton
->set_size_request(nWidth
, nHeight
);
2156 Size
get_size_request() const { return m_xSpinButton
->get_size_request(); }
2157 Size
get_preferred_size() const { return m_xSpinButton
->get_preferred_size(); }
2158 void connect_focus_in(const Link
<Widget
&, void>& rLink
)
2160 m_xSpinButton
->connect_focus_in(rLink
);
2162 void connect_focus_out(const Link
<Widget
&, void>& rLink
)
2164 m_xSpinButton
->connect_focus_out(rLink
);
2166 OUString
get_buildable_name() const { return m_xSpinButton
->get_buildable_name(); }
2167 void set_help_id(const OUString
& rName
) { m_xSpinButton
->set_help_id(rName
); }
2168 void set_position(int nCursorPos
) { m_xSpinButton
->set_position(nCursorPos
); }
2169 // set the width of the underlying widget in characters, this setting is
2170 // invalidated when changing the units, range or digits, so to have effect
2171 // must come after changing those values
2172 void set_width_chars(int nChars
) { m_xSpinButton
->set_width_chars(nChars
); }
2173 int get_width_chars() const { return m_xSpinButton
->get_width_chars(); }
2174 weld::SpinButton
& get_widget() { return *m_xSpinButton
; }
2177 enum class LabelType
2182 Title
, // this is intended to be used against the background set by set_title_background
2185 class VCL_DLLPUBLIC Label
: virtual public Widget
2188 virtual void set_label(const OUString
& rText
) = 0;
2189 virtual OUString
get_label() const = 0;
2190 virtual void set_mnemonic_widget(Widget
* pTarget
) = 0;
2191 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
2192 virtual void set_font(const vcl::Font
& rFont
) = 0;
2193 virtual void set_label_type(LabelType eType
) = 0;
2195 If you want to set a warning or error state, see set_label_type
2198 virtual void set_font_color(const Color
& rColor
) = 0;
2201 class VCL_DLLPUBLIC TextView
: virtual public Widget
2203 friend class ::LOKTrigger
;
2206 OUString m_sSavedValue
;
2209 Link
<TextView
&, void> m_aChangeHdl
;
2210 Link
<TextView
&, void> m_aVChangeHdl
;
2211 Link
<TextView
&, void> m_aCursorPositionHdl
;
2213 void signal_changed() { m_aChangeHdl
.Call(*this); }
2214 void signal_cursor_position() { m_aCursorPositionHdl
.Call(*this); }
2215 void signal_vadjustment_changed() { m_aVChangeHdl
.Call(*this); }
2218 virtual void set_text(const OUString
& rText
) = 0;
2219 virtual OUString
get_text() const = 0;
2220 // if nStartPos or nEndPos is -1 the max available text pos will be used
2221 virtual void select_region(int nStartPos
, int nEndPos
) = 0;
2222 // returns true if the selection has nonzero length
2223 virtual bool get_selection_bounds(int& rStartPos
, int& rEndPos
) = 0;
2224 virtual void replace_selection(const OUString
& rText
) = 0;
2225 virtual void set_editable(bool bEditable
) = 0;
2226 virtual bool get_editable() const = 0;
2227 virtual void set_monospace(bool bMonospace
) = 0;
2228 // The maximum length of the entry. Use 0 for no maximum
2229 virtual void set_max_length(int nChars
) = 0;
2230 int get_height_rows(int nRows
) const
2232 //can improve this if needed
2233 return get_text_height() * nRows
;
2236 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
2237 virtual void set_font(const vcl::Font
& rFont
) = 0;
2240 Typically you want to avoid the temptation of customizing
2243 virtual void set_font_color(const Color
& rColor
) = 0;
2245 void save_value() { m_sSavedValue
= get_text(); }
2246 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_text(); }
2248 void connect_changed(const Link
<TextView
&, void>& rLink
) { m_aChangeHdl
= rLink
; }
2249 virtual void connect_cursor_position(const Link
<TextView
&, void>& rLink
)
2251 m_aCursorPositionHdl
= rLink
;
2254 // returns true if pressing up would move the cursor
2255 // doesn't matter if that move is to a previous line or to the start of the
2256 // current line just so long as the cursor would move
2257 virtual bool can_move_cursor_with_up() const = 0;
2259 // returns true if pressing down would move the cursor
2260 // doesn't matter if that move is to a next line or to the end of the
2261 // current line just so long as the cursor would move
2262 virtual bool can_move_cursor_with_down() const = 0;
2264 virtual void cut_clipboard() = 0;
2265 virtual void copy_clipboard() = 0;
2266 virtual void paste_clipboard() = 0;
2268 virtual void set_alignment(TxtAlign eXAlign
) = 0;
2270 virtual int vadjustment_get_value() const = 0;
2271 virtual int vadjustment_get_upper() const = 0;
2272 virtual int vadjustment_get_lower() const = 0;
2273 virtual int vadjustment_get_page_size() const = 0;
2274 virtual void vadjustment_set_value(int value
) = 0;
2275 void connect_vadjustment_changed(const Link
<TextView
&, void>& rLink
) { m_aVChangeHdl
= rLink
; }
2278 class VCL_DLLPUBLIC Expander
: virtual public Widget
2280 Link
<Expander
&, void> m_aExpandedHdl
;
2283 void signal_expanded() { m_aExpandedHdl
.Call(*this); }
2286 virtual void set_label(const OUString
& rText
) = 0;
2287 virtual OUString
get_label() const = 0;
2288 virtual bool get_expanded() const = 0;
2289 virtual void set_expanded(bool bExpand
) = 0;
2291 void connect_expanded(const Link
<Expander
&, void>& rLink
) { m_aExpandedHdl
= rLink
; }
2294 class VCL_DLLPUBLIC DrawingArea
: virtual public Widget
2297 typedef std::pair
<vcl::RenderContext
&, const tools::Rectangle
&> draw_args
;
2300 Link
<draw_args
, void> m_aDrawHdl
;
2301 Link
<const CommandEvent
&, bool> m_aCommandHdl
;
2302 Link
<Widget
&, tools::Rectangle
> m_aGetFocusRectHdl
;
2303 Link
<tools::Rectangle
&, OUString
> m_aQueryTooltipHdl
;
2304 // if handler returns true, drag is disallowed
2305 Link
<DrawingArea
&, bool> m_aDragBeginHdl
;
2306 // return position of cursor, fill OUString& with surrounding text
2307 Link
<OUString
&, int> m_aGetSurroundingHdl
;
2308 // attempt to delete the range, return true if successful
2309 Link
<const Selection
&, bool> m_aDeleteSurroundingHdl
;
2311 OUString
signal_query_tooltip(tools::Rectangle
& rHelpArea
)
2313 return m_aQueryTooltipHdl
.Call(rHelpArea
);
2316 int signal_im_context_get_surrounding(OUString
& rSurroundingText
)
2318 if (!m_aGetSurroundingHdl
.IsSet())
2320 return m_aGetSurroundingHdl
.Call(rSurroundingText
);
2323 bool signal_im_context_delete_surrounding(const Selection
& rRange
)
2325 return m_aDeleteSurroundingHdl
.Call(rRange
);
2329 void connect_draw(const Link
<draw_args
, void>& rLink
) { m_aDrawHdl
= rLink
; }
2330 void connect_command(const Link
<const CommandEvent
&, bool>& rLink
) { m_aCommandHdl
= rLink
; }
2331 void connect_focus_rect(const Link
<Widget
&, tools::Rectangle
>& rLink
)
2333 m_aGetFocusRectHdl
= rLink
;
2335 void connect_query_tooltip(const Link
<tools::Rectangle
&, OUString
>& rLink
)
2337 m_aQueryTooltipHdl
= rLink
;
2339 void connect_drag_begin(const Link
<DrawingArea
&, bool>& rLink
) { m_aDragBeginHdl
= rLink
; }
2340 void connect_im_context_get_surrounding(const Link
<OUString
&, int>& rLink
)
2342 m_aGetSurroundingHdl
= rLink
;
2344 void connect_im_context_delete_surrounding(const Link
<const Selection
&, bool>& rLink
)
2346 m_aDeleteSurroundingHdl
= rLink
;
2348 virtual void queue_draw() = 0;
2349 virtual void queue_draw_area(int x
, int y
, int width
, int height
) = 0;
2351 virtual void enable_drag_source(rtl::Reference
<TransferDataContainer
>& rTransferable
,
2352 sal_uInt8 eDNDConstants
)
2355 virtual void set_cursor(PointerStyle ePointerStyle
) = 0;
2357 virtual Point
get_pointer_position() const = 0;
2359 virtual void set_input_context(const InputContext
& rInputContext
) = 0;
2360 virtual void im_context_set_cursor_location(const tools::Rectangle
& rCursorRect
,
2361 int nExtTextInputWidth
)
2364 // use return here just to generate matching VirtualDevices
2365 virtual OutputDevice
& get_ref_device() = 0;
2367 virtual a11yref
get_accessible_parent() = 0;
2368 virtual a11yrelationset
get_accessible_relation_set() = 0;
2369 virtual Point
get_accessible_location_on_screen() = 0;
2372 friend class ::LOKTrigger
;
2374 virtual void click(const Point
&) = 0;
2376 virtual void dblclick(const Point
&){};
2378 virtual void mouse_up(const Point
&){};
2380 virtual void mouse_down(const Point
&){};
2382 virtual void mouse_move(const Point
&){};
2385 enum class Placement
2391 class VCL_DLLPUBLIC Menu
2393 Link
<const OUString
&, void> m_aActivateHdl
;
2396 void signal_activate(const OUString
& rIdent
) { m_aActivateHdl
.Call(rIdent
); }
2399 virtual OUString
popup_at_rect(weld::Widget
* pParent
, const tools::Rectangle
& rRect
,
2400 Placement ePlace
= Placement::Under
)
2403 void connect_activate(const Link
<const OUString
&, void>& rLink
) { m_aActivateHdl
= rLink
; }
2405 virtual void set_sensitive(const OUString
& rIdent
, bool bSensitive
) = 0;
2406 virtual bool get_sensitive(const OUString
& rIdent
) const = 0;
2407 virtual void set_label(const OUString
& rIdent
, const OUString
& rLabel
) = 0;
2408 virtual OUString
get_label(const OUString
& rIdent
) const = 0;
2409 virtual void set_active(const OUString
& rIdent
, bool bActive
) = 0;
2410 virtual bool get_active(const OUString
& rIdent
) const = 0;
2411 virtual void set_visible(const OUString
& rIdent
, bool bVisible
) = 0;
2413 virtual void insert(int pos
, const OUString
& rId
, const OUString
& rStr
,
2414 const OUString
* pIconName
, VirtualDevice
* pImageSurface
,
2415 const css::uno::Reference
<css::graphic::XGraphic
>& rImage
,
2416 TriState eCheckRadioFalse
)
2419 virtual void remove(const OUString
& rId
) = 0;
2421 virtual void clear() = 0;
2423 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
2424 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
2426 void append(const OUString
& rId
, const OUString
& rStr
)
2428 insert(-1, rId
, rStr
, nullptr, nullptr, nullptr, TRISTATE_INDET
);
2430 void append_check(const OUString
& rId
, const OUString
& rStr
)
2432 insert(-1, rId
, rStr
, nullptr, nullptr, nullptr, TRISTATE_TRUE
);
2434 void append_radio(const OUString
& rId
, const OUString
& rStr
)
2436 insert(-1, rId
, rStr
, nullptr, nullptr, nullptr, TRISTATE_FALSE
);
2438 void append(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
2440 insert(-1, rId
, rStr
, &rImage
, nullptr, nullptr, TRISTATE_INDET
);
2442 void append(const OUString
& rId
, const OUString
& rStr
, VirtualDevice
& rImage
)
2444 insert(-1, rId
, rStr
, nullptr, &rImage
, nullptr, TRISTATE_INDET
);
2447 // return the number of toplevel nodes
2448 virtual int n_children() const = 0;
2450 virtual OUString
get_id(int pos
) const = 0;
2455 class VCL_DLLPUBLIC Popover
: virtual public Container
2457 friend class ::LOKTrigger
;
2460 Link
<weld::Popover
&, void> m_aCloseHdl
;
2463 void signal_closed() { m_aCloseHdl
.Call(*this); }
2466 virtual void popup_at_rect(weld::Widget
* pParent
, const tools::Rectangle
& rRect
,
2467 Placement ePlace
= Placement::Under
)
2469 virtual void popdown() = 0;
2471 virtual void resize_to_request() = 0;
2473 void connect_closed(const Link
<weld::Popover
&, void>& rLink
) { m_aCloseHdl
= rLink
; }
2476 class VCL_DLLPUBLIC Toolbar
: virtual public Widget
2478 Link
<const OUString
&, void> m_aClickHdl
;
2479 Link
<const OUString
&, void> m_aToggleMenuHdl
;
2482 friend class ::LOKTrigger
;
2484 void signal_clicked(const OUString
& rIdent
) { m_aClickHdl
.Call(rIdent
); }
2485 void signal_toggle_menu(const OUString
& rIdent
) { m_aToggleMenuHdl
.Call(rIdent
); }
2488 virtual void set_item_sensitive(const OUString
& rIdent
, bool bSensitive
) = 0;
2489 virtual bool get_item_sensitive(const OUString
& rIdent
) const = 0;
2490 virtual void set_item_active(const OUString
& rIdent
, bool bActive
) = 0;
2491 virtual bool get_item_active(const OUString
& rIdent
) const = 0;
2492 virtual void set_menu_item_active(const OUString
& rIdent
, bool bActive
) = 0;
2493 virtual bool get_menu_item_active(const OUString
& rIdent
) const = 0;
2494 virtual void set_item_menu(const OUString
& rIdent
, weld::Menu
* pMenu
) = 0;
2495 virtual void set_item_popover(const OUString
& rIdent
, weld::Widget
* pPopover
) = 0;
2496 virtual void set_item_visible(const OUString
& rIdent
, bool bVisible
) = 0;
2497 virtual void set_item_help_id(const OUString
& rIdent
, const OUString
& rHelpId
) = 0;
2498 virtual bool get_item_visible(const OUString
& rIdent
) const = 0;
2499 virtual void set_item_label(const OUString
& rIdent
, const OUString
& rLabel
) = 0;
2500 virtual OUString
get_item_label(const OUString
& rIdent
) const = 0;
2501 virtual void set_item_tooltip_text(const OUString
& rIdent
, const OUString
& rTip
) = 0;
2502 virtual OUString
get_item_tooltip_text(const OUString
& rIdent
) const = 0;
2503 virtual void set_item_icon_name(const OUString
& rIdent
, const OUString
& rIconName
) = 0;
2504 virtual void set_item_image_mirrored(const OUString
& rIdent
, bool bMirrored
) = 0;
2505 virtual void set_item_image(const OUString
& rIdent
,
2506 const css::uno::Reference
<css::graphic::XGraphic
>& rIcon
)
2508 virtual void set_item_image(const OUString
& rIdent
, VirtualDevice
* pDevice
) = 0;
2510 virtual void insert_item(int pos
, const OUString
& rId
) = 0;
2511 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
2512 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
2514 virtual int get_n_items() const = 0;
2515 virtual OUString
get_item_ident(int nIndex
) const = 0;
2516 virtual void set_item_ident(int nIndex
, const OUString
& rIdent
) = 0;
2517 virtual void set_item_label(int nIndex
, const OUString
& rLabel
) = 0;
2518 virtual void set_item_image(int nIndex
,
2519 const css::uno::Reference
<css::graphic::XGraphic
>& rIcon
)
2521 virtual void set_item_tooltip_text(int nIndex
, const OUString
& rTip
) = 0;
2523 virtual vcl::ImageType
get_icon_size() const = 0;
2524 virtual void set_icon_size(vcl::ImageType eType
) = 0;
2526 // return what modifiers are held
2527 virtual sal_uInt16
get_modifier_state() const = 0;
2529 // This function returns the position a new item should be inserted if dnd
2530 // is dropped at rPoint
2531 virtual int get_drop_index(const Point
& rPoint
) const = 0;
2533 void connect_clicked(const Link
<const OUString
&, void>& rLink
) { m_aClickHdl
= rLink
; }
2534 void connect_menu_toggled(const Link
<const OUString
&, void>& rLink
)
2536 m_aToggleMenuHdl
= rLink
;
2540 class VCL_DLLPUBLIC Scrollbar
: virtual public Widget
2542 Link
<Scrollbar
&, void> m_aChangeHdl
;
2545 void signal_adjustment_changed() { m_aChangeHdl
.Call(*this); }
2548 virtual void adjustment_configure(int value
, int lower
, int upper
, int step_increment
,
2549 int page_increment
, int page_size
)
2551 virtual int adjustment_get_value() const = 0;
2552 virtual void adjustment_set_value(int value
) = 0;
2553 virtual int adjustment_get_upper() const = 0;
2554 virtual void adjustment_set_upper(int upper
) = 0;
2555 virtual int adjustment_get_page_size() const = 0;
2556 virtual void adjustment_set_page_size(int size
) = 0;
2557 virtual int adjustment_get_page_increment() const = 0;
2558 virtual void adjustment_set_page_increment(int size
) = 0;
2559 virtual int adjustment_get_step_increment() const = 0;
2560 virtual void adjustment_set_step_increment(int size
) = 0;
2561 virtual int adjustment_get_lower() const = 0;
2562 virtual void adjustment_set_lower(int upper
) = 0;
2564 virtual int get_scroll_thickness() const = 0;
2565 virtual void set_scroll_thickness(int nThickness
) = 0;
2567 virtual ScrollType
get_scroll_type() const = 0;
2569 void connect_adjustment_changed(const Link
<Scrollbar
&, void>& rLink
) { m_aChangeHdl
= rLink
; }
2572 class VCL_DLLPUBLIC SizeGroup
2575 virtual void add_widget(weld::Widget
* pWidget
) = 0;
2576 // the default mode is VclSizeGroupMode::Horizontal
2577 virtual void set_mode(VclSizeGroupMode eMode
) = 0;
2578 virtual ~SizeGroup() {}
2581 class VCL_DLLPUBLIC Builder
2584 virtual std::unique_ptr
<MessageDialog
> weld_message_dialog(const OUString
& id
) = 0;
2585 virtual std::unique_ptr
<Dialog
> weld_dialog(const OUString
& id
) = 0;
2586 virtual std::unique_ptr
<Assistant
> weld_assistant(const OUString
& id
) = 0;
2587 virtual std::unique_ptr
<Widget
> weld_widget(const OUString
& id
) = 0;
2588 virtual std::unique_ptr
<Container
> weld_container(const OUString
& id
) = 0;
2589 virtual std::unique_ptr
<Box
> weld_box(const OUString
& id
) = 0;
2590 virtual std::unique_ptr
<Paned
> weld_paned(const OUString
& id
) = 0;
2591 virtual std::unique_ptr
<Button
> weld_button(const OUString
& id
) = 0;
2592 virtual std::unique_ptr
<MenuButton
> weld_menu_button(const OUString
& id
) = 0;
2593 virtual std::unique_ptr
<MenuToggleButton
> weld_menu_toggle_button(const OUString
& id
) = 0;
2594 virtual std::unique_ptr
<Frame
> weld_frame(const OUString
& id
) = 0;
2595 /* bUserManagedScrolling of true means that the automatic scrolling of the window is disabled
2596 and the owner must specifically listen to adjustment changes and react appropriately to them.
2598 virtual std::unique_ptr
<ScrolledWindow
> weld_scrolled_window(const OUString
& id
,
2599 bool bUserManagedScrolling
= false)
2601 virtual std::unique_ptr
<Notebook
> weld_notebook(const OUString
& id
) = 0;
2602 virtual std::unique_ptr
<ToggleButton
> weld_toggle_button(const OUString
& id
) = 0;
2603 virtual std::unique_ptr
<RadioButton
> weld_radio_button(const OUString
& id
) = 0;
2604 virtual std::unique_ptr
<CheckButton
> weld_check_button(const OUString
& id
) = 0;
2605 virtual std::unique_ptr
<LinkButton
> weld_link_button(const OUString
& id
) = 0;
2606 virtual std::unique_ptr
<SpinButton
> weld_spin_button(const OUString
& id
) = 0;
2607 virtual std::unique_ptr
<MetricSpinButton
> weld_metric_spin_button(const OUString
& id
,
2610 virtual std::unique_ptr
<FormattedSpinButton
> weld_formatted_spin_button(const OUString
& id
) = 0;
2611 virtual std::unique_ptr
<ComboBox
> weld_combo_box(const OUString
& id
) = 0;
2612 virtual std::unique_ptr
<TreeView
> weld_tree_view(const OUString
& id
) = 0;
2613 virtual std::unique_ptr
<IconView
> weld_icon_view(const OUString
& id
) = 0;
2614 virtual std::unique_ptr
<Label
> weld_label(const OUString
& id
) = 0;
2615 virtual std::unique_ptr
<TextView
> weld_text_view(const OUString
& id
) = 0;
2616 virtual std::unique_ptr
<Expander
> weld_expander(const OUString
& id
) = 0;
2617 virtual std::unique_ptr
<Entry
> weld_entry(const OUString
& id
) = 0;
2618 virtual std::unique_ptr
<Scale
> weld_scale(const OUString
& id
) = 0;
2619 virtual std::unique_ptr
<ProgressBar
> weld_progress_bar(const OUString
& id
) = 0;
2620 virtual std::unique_ptr
<Spinner
> weld_spinner(const OUString
& id
) = 0;
2621 virtual std::unique_ptr
<Image
> weld_image(const OUString
& id
) = 0;
2622 virtual std::unique_ptr
<Calendar
> weld_calendar(const OUString
& id
) = 0;
2623 virtual std::unique_ptr
<DrawingArea
>
2624 weld_drawing_area(const OUString
& id
, const a11yref
& rA11yImpl
= nullptr,
2625 FactoryFunction pUITestFactoryFunction
= nullptr, void* pUserData
= nullptr)
2627 virtual std::unique_ptr
<EntryTreeView
> weld_entry_tree_view(const OUString
& containerid
,
2628 const OUString
& entryid
,
2629 const OUString
& treeviewid
)
2631 virtual std::unique_ptr
<Menu
> weld_menu(const OUString
& id
) = 0;
2632 virtual std::unique_ptr
<Popover
> weld_popover(const OUString
& id
) = 0;
2633 virtual std::unique_ptr
<Toolbar
> weld_toolbar(const OUString
& id
) = 0;
2634 virtual std::unique_ptr
<Scrollbar
> weld_scrollbar(const OUString
& id
) = 0;
2635 virtual std::unique_ptr
<SizeGroup
> create_size_group() = 0;
2636 /* return a Dialog suitable to take a screenshot of containing the contents of the .ui file.
2638 If the toplevel element is a dialog, that will be returned
2639 If the toplevel is not a dialog, a dialog will be created and the contents of the .ui
2642 virtual std::unique_ptr
<Window
> create_screenshot_window() = 0;
2643 virtual ~Builder() {}
2646 class VCL_DLLPUBLIC DialogController
: public std::enable_shared_from_this
<DialogController
>
2649 virtual Dialog
* getDialog() = 0;
2650 const Dialog
* getConstDialog() const
2652 return const_cast<DialogController
*>(this)->getDialog();
2654 virtual short run() { return getDialog()->run(); }
2655 static bool runAsync(const std::shared_ptr
<DialogController
>& rController
,
2656 const std::function
<void(sal_Int32
)>&);
2657 void set_title(const OUString
& rTitle
) { getDialog()->set_title(rTitle
); }
2658 OUString
get_title() const { return getConstDialog()->get_title(); }
2659 void set_help_id(const OUString
& rHelpId
) { getDialog()->set_help_id(rHelpId
); }
2660 OUString
get_help_id() const { return getConstDialog()->get_help_id(); }
2661 void response(int nResponse
) { getDialog()->response(nResponse
); }
2662 virtual ~DialogController() COVERITY_NOEXCEPT_FALSE
;
2665 class VCL_DLLPUBLIC GenericDialogController
: public DialogController
2668 std::unique_ptr
<weld::Builder
> m_xBuilder
;
2669 std::shared_ptr
<weld::Dialog
> m_xDialog
;
2672 GenericDialogController(weld::Widget
* pParent
, const OUString
& rUIFile
,
2673 const OUString
& rDialogId
, bool bMobile
= false);
2674 virtual Dialog
* getDialog() override
;
2675 virtual ~GenericDialogController() COVERITY_NOEXCEPT_FALSE override
;
2678 class VCL_DLLPUBLIC MessageDialogController
: public DialogController
2681 std::unique_ptr
<weld::Builder
> m_xBuilder
;
2682 std::unique_ptr
<weld::MessageDialog
> m_xDialog
;
2683 std::unique_ptr
<weld::Container
> m_xContentArea
;
2684 std::unique_ptr
<weld::Widget
> m_xRelocate
;
2685 std::unique_ptr
<weld::Container
> m_xOrigParent
;
2688 /* @param rRelocateId - optional argument of the name of a widget in the .ui file
2689 which should be relocated into the content area of the dialog.
2691 e.g. a checkbox for a "Never show this again" option.
2693 This results in the named widget relocating to the same container
2694 as the messages. This enables aligning the extra widget with the
2695 message labels in the content area container which doesn't
2696 explicitly exist in the ui description, but is only implied.
2698 MessageDialogController(weld::Widget
* pParent
, const OUString
& rUIFile
,
2699 const OUString
& rDialogId
, const OUString
& rRelocateId
= {});
2700 virtual Dialog
* getDialog() override
;
2701 virtual ~MessageDialogController() override
;
2702 void set_primary_text(const OUString
& rText
) { m_xDialog
->set_primary_text(rText
); }
2703 OUString
get_primary_text() const { return m_xDialog
->get_primary_text(); }
2704 void set_secondary_text(const OUString
& rText
) { m_xDialog
->set_secondary_text(rText
); }
2705 OUString
get_secondary_text() const { return m_xDialog
->get_secondary_text(); }
2706 void set_default_response(int nResponse
) { m_xDialog
->set_default_response(nResponse
); }
2709 class VCL_DLLPUBLIC AssistantController
: public DialogController
2712 std::unique_ptr
<weld::Builder
> m_xBuilder
;
2713 std::unique_ptr
<weld::Assistant
> m_xAssistant
;
2716 AssistantController(weld::Widget
* pParent
, const OUString
& rUIFile
, const OUString
& rDialogId
);
2717 virtual Dialog
* getDialog() override
;
2718 virtual ~AssistantController() override
;
2723 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */