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 TransferDataContainer
;
66 class ILibreOfficeKitNotifier
;
67 typedef OutputDevice RenderContext
;
79 class DialogController
;
81 class VCL_DLLPUBLIC Widget
83 friend class ::LOKTrigger
;
86 Link
<Widget
&, void> m_aFocusInHdl
;
87 Link
<Widget
&, void> m_aFocusOutHdl
;
88 Link
<Widget
&, bool> m_aMnemonicActivateHdl
;
89 Link
<Widget
&, void> m_aStyleUpdatedHdl
;
90 Link
<const Size
&, void> m_aSizeAllocateHdl
;
91 Link
<const KeyEvent
&, bool> m_aKeyPressHdl
;
92 Link
<const KeyEvent
&, bool> m_aKeyReleaseHdl
;
93 Link
<const MouseEvent
&, bool> m_aMousePressHdl
;
94 Link
<const MouseEvent
&, bool> m_aMouseMotionHdl
;
95 Link
<const MouseEvent
&, bool> m_aMouseReleaseHdl
;
97 void signal_focus_in() { m_aFocusInHdl
.Call(*this); }
98 void signal_focus_out() { m_aFocusOutHdl
.Call(*this); }
99 bool signal_mnemonic_activate() { return m_aMnemonicActivateHdl
.Call(*this); }
100 void signal_style_updated() { m_aStyleUpdatedHdl
.Call(*this); }
101 void signal_size_allocate(const Size
& rSize
) { m_aSizeAllocateHdl
.Call(rSize
); }
102 bool signal_key_press(const KeyEvent
& rKeyEvent
) { return m_aKeyPressHdl
.Call(rKeyEvent
); }
103 bool signal_key_release(const KeyEvent
& rKeyEvent
) { return m_aKeyReleaseHdl
.Call(rKeyEvent
); }
104 bool signal_mouse_press(const MouseEvent
& rMouseEvent
)
106 return m_aMousePressHdl
.Call(rMouseEvent
);
108 bool signal_mouse_motion(const MouseEvent
& rMouseEvent
)
110 return m_aMouseMotionHdl
.Call(rMouseEvent
);
112 bool signal_mouse_release(const MouseEvent
& rMouseEvent
)
114 return m_aMouseReleaseHdl
.Call(rMouseEvent
);
118 virtual void set_sensitive(bool sensitive
) = 0;
119 virtual bool get_sensitive() const = 0;
123 virtual void show() = 0;
124 virtual void hide() = 0;
126 // This function simply calls show() or hide() but is convenient when the
127 // visibility depends on some condition
128 virtual void set_visible(bool visible
)
136 // return if this widget's visibility is true
137 virtual bool get_visible() const = 0;
139 // return if this widget's visibility and that of all its parents is true
140 virtual bool is_visible() const = 0;
144 // sets if this widget can own the keyboard focus
145 virtual void set_can_focus(bool bCanFocus
) = 0;
147 // causes this widget to have the keyboard focus
148 virtual void grab_focus() = 0;
150 // returns if this widget has the keyboard focus
151 virtual bool has_focus() const = 0;
153 // if the widget that has focus is a child, which includes toplevel popup
154 // children, of this widget. So an Entry with an active popup (or dialog)
155 // has has_child_focus of true, but has_focus of false, while its popup is
157 virtual bool has_child_focus() const = 0;
159 // return if this widget has the keyboard focus within the active window
160 // TODO: review if this has any practical difference from has_focus()
161 virtual bool is_active() const = 0;
164 virtual void set_size_request(int nWidth
, int nHeight
) = 0;
165 virtual Size
get_size_request() const = 0;
166 virtual Size
get_preferred_size() const = 0;
169 virtual float get_approximate_digit_width() const = 0;
170 virtual int get_text_height() const = 0;
171 virtual Size
get_pixel_size(const OUString
& rText
) const = 0;
173 // The name of the widget in the GtkBuilder UI definition used to construct it.
174 virtual OUString
get_buildable_name() const = 0;
176 Typically there is no need to change the buildable name at runtime, changing
177 the id in .ui file itself is preferred.
179 But for ui-testing purposes it can sometimes be useful to rename
180 different widgets, that were loaded from the same .ui, to unique names
181 in order to distinguish between them
183 virtual void set_buildable_name(const OUString
& rName
) = 0;
186 The help id of the widget used to identify help for this widget.
188 By default the help id of a widget is a path-like sequence of (load-time)
189 buildable-names from the widgets UI definition ancestor to this widget,
190 e.g. grandparent/parent/widget.
192 The default can be overwritten with set_help_id
194 virtual OUString
get_help_id() const = 0;
195 virtual void set_help_id(const OUString
& rName
) = 0;
197 virtual void set_hexpand(bool bExpand
) = 0;
198 virtual bool get_hexpand() const = 0;
199 virtual void set_vexpand(bool bExpand
) = 0;
200 virtual bool get_vexpand() const = 0;
202 virtual void set_margin_top(int nMargin
) = 0;
203 virtual void set_margin_bottom(int nMargin
) = 0;
204 virtual void set_margin_start(int nMargin
) = 0;
205 virtual void set_margin_end(int nMargin
) = 0;
207 virtual int get_margin_top() const = 0;
208 virtual int get_margin_bottom() const = 0;
209 virtual int get_margin_start() const = 0;
210 virtual int get_margin_end() const = 0;
213 * Report the extents of this widget relative to the rRelative target widget.
215 * To succeed, both widgets must be realized, and must share a common toplevel.
217 * returns false if the relative extents could not be determined, e.g. if
218 * either widget was not realized, or there was no common ancestor.
221 virtual bool get_extents_relative_to(const Widget
& rRelative
, int& x
, int& y
, int& width
,
222 int& height
) const = 0;
224 virtual void set_accessible_name(const OUString
& rName
) = 0;
225 virtual void set_accessible_description(const OUString
& rDescription
) = 0;
226 virtual OUString
get_accessible_name() const = 0;
228 virtual OUString
get_accessible_description() const = 0;
230 virtual OUString
get_accessible_id() const = 0;
232 // After this call this widget is only accessibility labelled by pLabel and
233 // pLabel only accessibility labels this widget
234 virtual void set_accessible_relation_labeled_by(weld::Widget
* pLabel
) = 0;
236 virtual void set_tooltip_text(const OUString
& rTip
) = 0;
237 virtual OUString
get_tooltip_text() const = 0;
239 virtual void set_cursor_data(void* pData
) = 0;
241 virtual void connect_focus_in(const Link
<Widget
&, void>& rLink
)
243 assert(!m_aFocusInHdl
.IsSet() || !rLink
.IsSet());
244 m_aFocusInHdl
= rLink
;
247 virtual void connect_focus_out(const Link
<Widget
&, void>& rLink
)
249 assert(!m_aFocusOutHdl
.IsSet() || !rLink
.IsSet());
250 m_aFocusOutHdl
= rLink
;
253 // rLink is called when the mnemonic for the Widget is called.
254 // If rLink returns true the Widget will not automatically gain
255 // focus as normally occurs
256 virtual void connect_mnemonic_activate(const Link
<Widget
&, bool>& rLink
)
258 assert(!m_aMnemonicActivateHdl
.IsSet() || !rLink
.IsSet());
259 m_aMnemonicActivateHdl
= rLink
;
262 virtual void connect_size_allocate(const Link
<const Size
&, void>& rLink
)
264 assert(!m_aSizeAllocateHdl
.IsSet() || !rLink
.IsSet());
265 m_aSizeAllocateHdl
= rLink
;
268 virtual void connect_key_press(const Link
<const KeyEvent
&, bool>& rLink
)
270 assert(!m_aKeyPressHdl
.IsSet() || !rLink
.IsSet());
271 m_aKeyPressHdl
= rLink
;
274 virtual void connect_key_release(const Link
<const KeyEvent
&, bool>& rLink
)
276 assert(!m_aKeyReleaseHdl
.IsSet() || !rLink
.IsSet());
277 m_aKeyReleaseHdl
= rLink
;
280 virtual void connect_mouse_press(const Link
<const MouseEvent
&, bool>& rLink
)
282 assert(!m_aMousePressHdl
.IsSet() || !rLink
.IsSet());
283 m_aMousePressHdl
= rLink
;
286 virtual void connect_mouse_move(const Link
<const MouseEvent
&, bool>& rLink
)
288 assert(!m_aMouseMotionHdl
.IsSet() || !rLink
.IsSet());
289 m_aMouseMotionHdl
= rLink
;
292 virtual void connect_mouse_release(const Link
<const MouseEvent
&, bool>& rLink
)
294 assert(!m_aMouseReleaseHdl
.IsSet() || !rLink
.IsSet());
295 m_aMouseReleaseHdl
= rLink
;
298 virtual void connect_style_updated(const Link
<Widget
&, void>& rLink
)
300 assert(!m_aStyleUpdatedHdl
.IsSet() || !rLink
.IsSet());
301 m_aStyleUpdatedHdl
= rLink
;
304 virtual void grab_add() = 0;
305 virtual bool has_grab() const = 0;
306 virtual void grab_remove() = 0;
308 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
309 virtual vcl::Font
get_font() = 0;
311 //true for rtl, false otherwise
312 virtual bool get_direction() const = 0;
313 virtual void set_direction(bool bRTL
) = 0;
315 /* Increases the freeze count on widget.
317 If the freeze count is non-zero, emission of the widget's notifications
318 is stopped. The notifications are queued until the freeze count is
319 decreased to zero. Duplicate notifications may be squashed together.
321 virtual void freeze() = 0;
323 /* Reverts the effect of a previous call to freeze.
325 The freeze count is decreased on the widget and when it reaches zero,
326 queued notifications are emitted.
328 virtual void thaw() = 0;
330 /* push/pop busy mouse cursor state
332 bBusy of true to push a busy state onto the stack and false
333 to pop it off, calls to this should balance.
335 see weld::WaitObject */
336 virtual void set_busy_cursor(bool bBusy
) = 0;
338 virtual void queue_resize() = 0;
340 virtual std::unique_ptr
<Container
> weld_parent() const = 0;
342 //iterate upwards through the hierarchy starting at this widgets parent,
343 //calling func with their helpid until func returns true or we run out of
345 virtual void help_hierarchy_foreach(const std::function
<bool(const OUString
&)>& func
) = 0;
347 virtual OUString
strip_mnemonic(const OUString
& rLabel
) const = 0;
349 /* Escapes string contents which are interpreted by the UI.
351 Should be overwritten by each VCL implementation to account for the
352 string contents which are interpreted by its ui.
354 virtual OUString
escape_ui_str(const OUString
& rLabel
) const = 0;
356 virtual VclPtr
<VirtualDevice
> create_virtual_device() const = 0;
358 //do something transient to attract the attention of the user to the widget
359 virtual void call_attention_to() = 0;
361 //make this widget look like a page in a notebook
362 virtual void set_stack_background() = 0;
363 //make this widget look like it has a highlighted background
364 virtual void set_highlight_background() = 0;
365 //make this widget suitable as parent for a title
366 virtual void set_title_background() = 0;
367 //make this widget suitable for use in a toolbar
368 virtual void set_toolbar_background() = 0;
369 //trying to use a custom color for a background is generally a bad idea. If your need
370 //fits one of the above categories then that's a somewhat better choice
371 virtual void set_background(const Color
& rBackColor
) = 0;
373 virtual css::uno::Reference
<css::datatransfer::dnd::XDropTarget
> get_drop_target() = 0;
374 virtual css::uno::Reference
<css::datatransfer::clipboard::XClipboard
> get_clipboard() const = 0;
376 virtual void connect_get_property_tree(const Link
<tools::JsonWriter
&, void>& rLink
) = 0;
377 virtual void get_property_tree(tools::JsonWriter
& rJsonWriter
) = 0;
379 // render the widget to an output device
380 virtual void draw(OutputDevice
& rOutput
, const Point
& rPos
, const Size
& rSizePixel
) = 0;
385 class VCL_DLLPUBLIC Container
: virtual public Widget
387 Link
<Container
&, void> m_aContainerFocusChangedHdl
;
390 void signal_container_focus_changed() { m_aContainerFocusChangedHdl
.Call(*this); }
393 // remove from old container and add to new container in one go
394 // new container can be null to just remove from old container
395 virtual void move(weld::Widget
* pWidget
, weld::Container
* pNewParent
) = 0;
396 // create an XWindow as a child of this container. The XWindow is
397 // suitable to contain css::awt::XControl items
398 virtual css::uno::Reference
<css::awt::XWindow
> CreateChildFrame() = 0;
399 // rLink is called when the focus transitions from a widget outside the container
400 // to a widget inside the container or vice versa
401 virtual void connect_container_focus_changed(const Link
<Container
&, void>& rLink
)
403 m_aContainerFocusChangedHdl
= rLink
;
405 // causes a child of the container to have the keyboard focus
406 virtual void child_grab_focus() = 0;
409 class VCL_DLLPUBLIC Box
: virtual public Container
412 // Moves child to a new position in the list of children
413 virtual void reorder_child(weld::Widget
* pWidget
, int position
) = 0;
414 // Sort ok/cancel etc buttons in platform order
415 virtual void sort_native_button_order() = 0;
418 class VCL_DLLPUBLIC Grid
: virtual public Container
421 virtual void set_child_left_attach(weld::Widget
& rWidget
, int nAttach
) = 0;
422 virtual int get_child_left_attach(weld::Widget
& rWidget
) const = 0;
423 virtual void set_child_column_span(weld::Widget
& rWidget
, int nCols
) = 0;
424 virtual void set_child_top_attach(weld::Widget
& rWidget
, int nAttach
) = 0;
425 virtual int get_child_top_attach(weld::Widget
& rWidget
) const = 0;
428 class VCL_DLLPUBLIC Paned
: virtual public Container
431 // set pixel position of divider
432 virtual void set_position(int nPos
) = 0;
433 // get pixel position of divider
434 virtual int get_position() const = 0;
437 class VCL_DLLPUBLIC ScrolledWindow
: virtual public Container
439 friend class ::LOKTrigger
;
441 Link
<ScrolledWindow
&, void> m_aVChangeHdl
;
442 Link
<ScrolledWindow
&, void> m_aHChangeHdl
;
445 void signal_vadjustment_changed() { m_aVChangeHdl
.Call(*this); }
446 void signal_hadjustment_changed() { m_aHChangeHdl
.Call(*this); }
449 virtual void hadjustment_configure(int value
, int lower
, int upper
, int step_increment
,
450 int page_increment
, int page_size
)
452 virtual int hadjustment_get_value() const = 0;
453 virtual void hadjustment_set_value(int value
) = 0;
454 virtual int hadjustment_get_upper() const = 0;
455 virtual void hadjustment_set_upper(int upper
) = 0;
456 virtual int hadjustment_get_page_size() const = 0;
457 virtual void hadjustment_set_page_size(int size
) = 0;
458 virtual void hadjustment_set_page_increment(int size
) = 0;
459 virtual void hadjustment_set_step_increment(int size
) = 0;
460 virtual void set_hpolicy(VclPolicyType eHPolicy
) = 0;
461 virtual VclPolicyType
get_hpolicy() const = 0;
462 void connect_hadjustment_changed(const Link
<ScrolledWindow
&, void>& rLink
)
464 m_aHChangeHdl
= rLink
;
467 virtual void vadjustment_configure(int value
, int lower
, int upper
, int step_increment
,
468 int page_increment
, int page_size
)
470 virtual int vadjustment_get_value() const = 0;
471 virtual void vadjustment_set_value(int value
) = 0;
472 virtual int vadjustment_get_upper() const = 0;
473 virtual void vadjustment_set_upper(int upper
) = 0;
474 virtual int vadjustment_get_page_size() const = 0;
475 virtual void vadjustment_set_page_size(int size
) = 0;
476 virtual void vadjustment_set_page_increment(int size
) = 0;
477 virtual void vadjustment_set_step_increment(int size
) = 0;
478 virtual int vadjustment_get_lower() const = 0;
479 virtual void vadjustment_set_lower(int lower
) = 0;
480 virtual void set_vpolicy(VclPolicyType eVPolicy
) = 0;
481 virtual VclPolicyType
get_vpolicy() const = 0;
482 void connect_vadjustment_changed(const Link
<ScrolledWindow
&, void>& rLink
)
484 m_aVChangeHdl
= rLink
;
486 virtual int get_scroll_thickness() const = 0;
487 virtual void set_scroll_thickness(int nThickness
) = 0;
489 //trying to use custom color for a scrollbar is generally a bad idea.
490 virtual void customize_scrollbars(const Color
& rBackgroundColor
, const Color
& rShadowColor
,
491 const Color
& rFaceColor
)
497 class VCL_DLLPUBLIC Frame
: virtual public Container
500 virtual void set_label(const OUString
& rText
) = 0;
501 virtual OUString
get_label() const = 0;
502 virtual std::unique_ptr
<Label
> weld_label_widget() const = 0;
505 class VCL_DLLPUBLIC Notebook
: virtual public Widget
507 friend class ::LOKTrigger
;
510 Link
<const OUString
&, bool> m_aLeavePageHdl
;
511 Link
<const OUString
&, void> m_aEnterPageHdl
;
514 virtual int get_current_page() const = 0;
515 virtual int get_page_index(const OUString
& rIdent
) const = 0;
516 virtual OUString
get_page_ident(int nPage
) const = 0;
517 virtual OUString
get_current_page_ident() const = 0;
518 virtual void set_current_page(int nPage
) = 0;
519 virtual void set_current_page(const OUString
& rIdent
) = 0;
520 virtual void remove_page(const OUString
& rIdent
) = 0;
521 virtual void insert_page(const OUString
& rIdent
, const OUString
& rLabel
, int nPos
) = 0;
522 void append_page(const OUString
& rIdent
, const OUString
& rLabel
)
524 insert_page(rIdent
, rLabel
, -1);
526 virtual void set_tab_label_text(const OUString
& rIdent
, const OUString
& rLabel
) = 0;
527 virtual OUString
get_tab_label_text(const OUString
& rIdent
) const = 0;
528 virtual void set_show_tabs(bool bShow
) = 0;
529 virtual int get_n_pages() const = 0;
530 virtual weld::Container
* get_page(const OUString
& rIdent
) const = 0;
532 void connect_leave_page(const Link
<const OUString
&, bool>& rLink
) { m_aLeavePageHdl
= rLink
; }
533 void connect_enter_page(const Link
<const OUString
&, void>& rLink
) { m_aEnterPageHdl
= rLink
; }
536 class VCL_DLLPUBLIC ScreenShotEntry
539 ScreenShotEntry(OUString aHelpId
, const basegfx::B2IRange
& rB2IRange
)
540 : msHelpId(std::move(aHelpId
))
541 , maB2IRange(rB2IRange
)
545 const basegfx::B2IRange
& getB2IRange() const { return maB2IRange
; }
547 const OUString
& GetHelpId() const { return msHelpId
; }
551 basegfx::B2IRange maB2IRange
;
554 typedef std::vector
<ScreenShotEntry
> ScreenShotCollection
;
556 class VCL_DLLPUBLIC Window
: virtual public Container
559 Link
<Widget
&, bool> m_aHelpRequestHdl
;
562 virtual void set_title(const OUString
& rTitle
) = 0;
563 virtual OUString
get_title() const = 0;
564 virtual void window_move(int x
, int y
) = 0;
565 virtual bool get_resizable() const = 0;
566 virtual Size
get_size() const = 0;
567 virtual Point
get_position() const = 0;
568 virtual AbsoluteScreenPixelRectangle
get_monitor_workarea() const = 0;
570 // returns whether the widget that has focus is within this Window
571 // (its very possible to move this to weld::Container if that becomes
573 virtual bool has_toplevel_focus() const = 0;
574 virtual void present() = 0;
576 // with pOld of null, automatically find the old default widget and unset
577 // it, otherwise use as hint to the old default
578 virtual void change_default_widget(weld::Widget
* pOld
, weld::Widget
* pNew
) = 0;
579 virtual bool is_default_widget(const weld::Widget
* pCandidate
) const = 0;
581 virtual void set_window_state(const OUString
& rStr
) = 0;
582 virtual OUString
get_window_state(vcl::WindowDataMask nMask
) const = 0;
584 virtual css::uno::Reference
<css::awt::XWindow
> GetXWindow() = 0;
586 void connect_help(const Link
<Widget
&, bool>& rLink
) { m_aHelpRequestHdl
= rLink
; }
588 virtual SystemEnvData
get_system_data() const = 0;
590 virtual void resize_to_request() = 0;
592 // collect positions of widgets and their help ids for screenshot purposes
593 virtual ScreenShotCollection
collect_screenshot_data() = 0;
595 // render the widget to an output device
596 virtual VclPtr
<VirtualDevice
> screenshot() = 0;
598 virtual const vcl::ILibreOfficeKitNotifier
* GetLOKNotifier() = 0;
601 class VCL_DLLPUBLIC WaitObject
604 weld::Widget
* m_pWindow
;
607 WaitObject(weld::Widget
* pWindow
)
611 m_pWindow
->set_busy_cursor(true);
616 m_pWindow
->set_busy_cursor(false);
622 class VCL_DLLPUBLIC Dialog
: virtual public Window
625 friend DialogController
;
626 virtual bool runAsync(std::shared_ptr
<DialogController
> const& rxOwner
,
627 const std::function
<void(sal_Int32
)>& func
)
631 virtual void set_modal(bool bModal
) = 0;
632 virtual bool get_modal() const = 0;
634 // center dialog on its parent
636 // bTrackGeometryRequests set to true tries to ensure the dialog will end
637 // up still centered on its parent windows final size, taking into account
638 // that there may currently be pending geometry requests for the parent not
639 // yet processed by the underlying toolkit
641 // for e.g gtk this will means the dialog is always centered even when
642 // resized, calling set_centered_on_parent with false will turn this
644 virtual void set_centered_on_parent(bool bTrackGeometryRequests
) = 0;
646 virtual int run() = 0;
647 // Run async without a controller
648 // @param self - must point to this, to enforce that the dialog was created/held by a shared_ptr
649 virtual bool runAsync(std::shared_ptr
<Dialog
> const& rxSelf
,
650 const std::function
<void(sal_Int32
)>& func
)
652 virtual void response(int response
) = 0;
653 virtual void add_button(const OUString
& rText
, int response
, const OUString
& rHelpId
= {}) = 0;
654 virtual void set_default_response(int response
) = 0;
655 virtual std::unique_ptr
<Button
> weld_button_for_response(int response
) = 0;
656 virtual std::unique_ptr
<weld::Container
> weld_content_area() = 0;
658 // shrink the dialog down to shown just these widgets
659 virtual void collapse(weld::Widget
* pEdit
, weld::Widget
* pButton
) = 0;
660 // undo previous dialog collapse
661 virtual void undo_collapse() = 0;
663 virtual void SetInstallLOKNotifierHdl(const Link
<void*, vcl::ILibreOfficeKitNotifier
*>& rLink
)
667 class VCL_DLLPUBLIC MessageDialog
: virtual public Dialog
670 virtual void set_primary_text(const OUString
& rText
) = 0;
671 virtual OUString
get_primary_text() const = 0;
672 virtual void set_secondary_text(const OUString
& rText
) = 0;
673 virtual OUString
get_secondary_text() const = 0;
674 virtual std::unique_ptr
<Container
> weld_message_area() = 0;
677 class VCL_DLLPUBLIC Assistant
: virtual public Dialog
679 Link
<const OUString
&, bool> m_aJumpPageHdl
;
682 bool signal_jump_page(const OUString
& rIdent
) { return m_aJumpPageHdl
.Call(rIdent
); }
685 virtual int get_current_page() const = 0;
686 virtual int get_n_pages() const = 0;
687 virtual OUString
get_page_ident(int nPage
) const = 0;
688 virtual OUString
get_current_page_ident() const = 0;
689 virtual void set_current_page(int nPage
) = 0;
690 virtual void set_current_page(const OUString
& rIdent
) = 0;
691 // move the page rIdent to position nIndex
692 virtual void set_page_index(const OUString
& rIdent
, int nIndex
) = 0;
693 virtual void set_page_title(const OUString
& rIdent
, const OUString
& rTitle
) = 0;
694 virtual OUString
get_page_title(const OUString
& rIdent
) const = 0;
695 virtual void set_page_sensitive(const OUString
& rIdent
, bool bSensitive
) = 0;
696 virtual weld::Container
* append_page(const OUString
& rIdent
) = 0;
698 virtual void set_page_side_help_id(const OUString
& rHelpId
) = 0;
700 virtual void set_page_side_image(const OUString
& rImage
) = 0;
702 void connect_jump_page(const Link
<const OUString
&, bool>& rLink
) { m_aJumpPageHdl
= rLink
; }
705 inline OUString
toId(const void* pValue
)
707 return OUString::number(reinterpret_cast<sal_uIntPtr
>(pValue
));
710 template <typename T
> T
fromId(const OUString
& rValue
)
712 return reinterpret_cast<T
>(rValue
.toUInt64());
715 struct VCL_DLLPUBLIC ComboBoxEntry
720 ComboBoxEntry(OUString _aString
)
721 : sString(std::move(_aString
))
724 ComboBoxEntry(OUString _aString
, OUString _aId
)
725 : sString(std::move(_aString
))
726 , sId(std::move(_aId
))
729 ComboBoxEntry(OUString _aString
, OUString _aId
, OUString _aImage
)
730 : sString(std::move(_aString
))
731 , sId(std::move(_aId
))
732 , sImage(std::move(_aImage
))
737 enum class EntryMessageType
746 /// A widget used to choose from a list of items.
747 class VCL_DLLPUBLIC ComboBox
: virtual public Widget
750 OUString m_sSavedValue
;
751 std::vector
<OUString
> m_aSavedValues
;
754 // OUString is the id of the row, it may be null to measure the height of a generic line
755 typedef std::tuple
<vcl::RenderContext
&, const tools::Rectangle
&, bool, const OUString
&>
759 Link
<ComboBox
&, void> m_aChangeHdl
;
760 Link
<ComboBox
&, void> m_aPopupToggledHdl
;
761 Link
<ComboBox
&, bool> m_aEntryActivateHdl
;
762 Link
<OUString
&, bool> m_aEntryInsertTextHdl
;
764 friend class ::LOKTrigger
;
766 void signal_changed() { m_aChangeHdl
.Call(*this); }
768 virtual void signal_popup_toggled() { m_aPopupToggledHdl
.Call(*this); }
770 Link
<render_args
, void> m_aRenderHdl
;
771 void signal_custom_render(vcl::RenderContext
& rDevice
, const tools::Rectangle
& rRect
,
772 bool bSelected
, const OUString
& rId
)
774 m_aRenderHdl
.Call(render_args(rDevice
, rRect
, bSelected
, rId
));
777 Link
<vcl::RenderContext
&, Size
> m_aGetSizeHdl
;
778 Size
signal_custom_get_size(vcl::RenderContext
& rDevice
) { return m_aGetSizeHdl
.Call(rDevice
); }
781 virtual void insert(int pos
, const OUString
& rStr
, const OUString
* pId
,
782 const OUString
* pIconName
, VirtualDevice
* pImageSurface
)
784 virtual void insert_vector(const std::vector
<weld::ComboBoxEntry
>& rItems
, bool bKeepExisting
)
786 void insert(int pos
, const weld::ComboBoxEntry
& rItem
)
788 insert(pos
, rItem
.sString
, rItem
.sId
.isEmpty() ? nullptr : &rItem
.sId
,
789 rItem
.sImage
.isEmpty() ? nullptr : &rItem
.sImage
, nullptr);
791 void insert_text(int pos
, const OUString
& rStr
)
793 insert(pos
, rStr
, nullptr, nullptr, nullptr);
795 void append(const weld::ComboBoxEntry
& rItem
) { insert(-1, rItem
); }
796 void append_text(const OUString
& rStr
) { insert(-1, rStr
, nullptr, nullptr, nullptr); }
797 void append(const OUString
& rId
, const OUString
& rStr
)
799 insert(-1, rStr
, &rId
, nullptr, nullptr);
801 void append(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
803 insert(-1, rStr
, &rId
, &rImage
, nullptr);
805 void append(const OUString
& rId
, const OUString
& rStr
, VirtualDevice
& rImage
)
807 insert(-1, rStr
, &rId
, nullptr, &rImage
);
809 void append(int pos
, const OUString
& rId
, const OUString
& rStr
)
811 insert(pos
, rStr
, &rId
, nullptr, nullptr);
813 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
814 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
816 virtual int get_count() const = 0;
817 virtual void make_sorted() = 0;
818 virtual void clear() = 0;
820 //by index, returns -1 if nothing is selected
821 virtual int get_active() const = 0;
822 virtual void set_active(int pos
) = 0;
823 virtual void remove(int pos
) = 0;
826 virtual OUString
get_active_text() const = 0;
827 void set_active_text(const OUString
& rStr
) { set_active(find_text(rStr
)); }
828 virtual OUString
get_text(int pos
) const = 0;
829 virtual int find_text(const OUString
& rStr
) const = 0;
830 void remove_text(const OUString
& rText
) { remove(find_text(rText
)); }
833 virtual OUString
get_active_id() const = 0;
834 virtual void set_active_id(const OUString
& rStr
) = 0;
835 virtual OUString
get_id(int pos
) const = 0;
836 virtual void set_id(int row
, const OUString
& rId
) = 0;
837 virtual int find_id(const OUString
& rId
) const = 0;
838 void remove_id(const OUString
& rId
) { remove(find_id(rId
)); }
840 /* m_aChangeHdl is called when the active item is changed. The can be due
841 to the user selecting a different item from the list or while typing
842 into the entry of a combo box with an entry.
844 Use changed_by_direct_pick() to discover whether an item was actually explicitly
845 selected, e.g. from the menu.
847 void connect_changed(const Link
<ComboBox
&, void>& rLink
) { m_aChangeHdl
= rLink
; }
849 virtual bool changed_by_direct_pick() const = 0;
851 virtual void connect_popup_toggled(const Link
<ComboBox
&, void>& rLink
)
853 m_aPopupToggledHdl
= rLink
;
857 virtual bool has_entry() const = 0;
858 virtual void set_entry_message_type(EntryMessageType eType
) = 0;
859 virtual void set_entry_text(const OUString
& rStr
) = 0;
860 virtual void set_entry_width_chars(int nChars
) = 0;
861 virtual void set_entry_max_length(int nChars
) = 0;
862 virtual void select_entry_region(int nStartPos
, int nEndPos
) = 0;
863 virtual bool get_entry_selection_bounds(int& rStartPos
, int& rEndPos
) = 0;
864 virtual void set_entry_completion(bool bEnable
, bool bCaseSensitive
= false) = 0;
865 virtual void set_entry_placeholder_text(const OUString
& rText
) = 0;
866 virtual void set_entry_editable(bool bEditable
) = 0;
867 virtual void cut_entry_clipboard() = 0;
868 virtual void copy_entry_clipboard() = 0;
869 virtual void paste_entry_clipboard() = 0;
871 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
872 virtual void set_font(const vcl::Font
& rFont
) = 0;
874 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
875 virtual void set_entry_font(const vcl::Font
& rFont
) = 0;
876 virtual vcl::Font
get_entry_font() = 0;
878 virtual bool get_popup_shown() const = 0;
880 void connect_entry_insert_text(const Link
<OUString
&, bool>& rLink
)
882 m_aEntryInsertTextHdl
= rLink
;
885 // callback returns true to indicated no further processing of activate wanted
886 void connect_entry_activate(const Link
<ComboBox
&, bool>& rLink
) { m_aEntryActivateHdl
= rLink
; }
888 void save_value() { m_sSavedValue
= get_active_text(); }
890 void save_values_by_id(const OUString
& rId
)
892 m_aSavedValues
.push_back(get_text(find_id(rId
)));
895 OUString
const& get_saved_value() const { return m_sSavedValue
; }
896 OUString
const& get_saved_values(int pos
) const { return m_aSavedValues
[pos
]; }
897 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_active_text(); }
898 bool get_values_changed_from_saved() const
900 return !m_aSavedValues
.empty()
901 && std::find(m_aSavedValues
.begin(), m_aSavedValues
.end(), get_active_text())
902 == m_aSavedValues
.end();
905 void removeSavedValues() { m_aSavedValues
.clear(); }
907 // for custom rendering a row
908 void connect_custom_get_size(const Link
<vcl::RenderContext
&, Size
>& rLink
)
910 m_aGetSizeHdl
= rLink
;
912 void connect_custom_render(const Link
<render_args
, void>& rLink
) { m_aRenderHdl
= rLink
; }
913 // call set_custom_renderer after setting custom callbacks
914 virtual void set_custom_renderer(bool bOn
) = 0;
915 // create a virtual device compatible with the device passed in render_args wrt alpha
916 virtual VclPtr
<VirtualDevice
> create_render_virtual_device() const = 0;
917 // set a sub menu for a entry, only works with custom rendering
918 virtual void set_item_menu(const OUString
& rIdent
, weld::Menu
* pMenu
) = 0;
919 // get the width needed to show the menu launcher in a custom row
920 virtual int get_menu_button_width() const = 0;
923 virtual int get_max_mru_count() const = 0;
924 virtual void set_max_mru_count(int nCount
) = 0;
925 virtual OUString
get_mru_entries() const = 0;
926 virtual void set_mru_entries(const OUString
& rEntries
) = 0;
928 // Backwards compatibility, should be avoided to allow
930 virtual void set_max_drop_down_rows(int nRows
) = 0;
933 enum class ColumnToggleType
939 class VCL_DLLPUBLIC TreeIter
942 TreeIter(const TreeIter
&) = delete;
943 TreeIter
& operator=(const TreeIter
&) = delete;
947 virtual bool equal(const TreeIter
& rOther
) const = 0;
948 virtual ~TreeIter() {}
951 /* Model column indexes are considered to begin at 0, but with special columns
952 before index 0. A expander image column (and an additional optional toggle
953 button column when enable_toggle_buttons is used). Column index -1 is
954 reserved to access those columns.
956 class VCL_DLLPUBLIC TreeView
: virtual public Widget
958 friend class ::LOKTrigger
;
961 typedef std::pair
<const TreeIter
&, int> iter_col
;
962 typedef std::pair
<const TreeIter
&, OUString
> iter_string
;
963 // OUString is the id of the row, it may be null to measure the height of a generic line
964 typedef std::pair
<vcl::RenderContext
&, const OUString
&> get_size_args
;
965 typedef std::tuple
<vcl::RenderContext
&, const tools::Rectangle
&, bool, const OUString
&>
969 OUString m_sSavedValue
;
972 Link
<TreeView
&, void> m_aSelectionChangedHdl
;
973 Link
<TreeView
&, bool> m_aRowActivatedHdl
;
974 Link
<int, void> m_aColumnClickedHdl
;
975 Link
<const iter_col
&, void> m_aRadioToggleHdl
;
976 Link
<const TreeIter
&, bool> m_aEditingStartedHdl
;
977 Link
<const iter_string
&, bool> m_aEditingDoneHdl
;
978 // if handler returns false, the expansion of the row is refused
979 Link
<const TreeIter
&, bool> m_aExpandingHdl
;
980 // if handler returns false, the collapse of the row is refused
981 Link
<const TreeIter
&, bool> m_aCollapsingHdl
;
982 Link
<TreeView
&, void> m_aVisibleRangeChangedHdl
;
983 Link
<TreeView
&, void> m_aModelChangedHdl
;
984 // if handler returns true, then menu has been show and event is consumed
985 Link
<const CommandEvent
&, bool> m_aPopupMenuHdl
;
986 // if handler returns true, drag is disallowed, consumer can change bool
987 // arg to false to disable the treeview default dnd icon
988 Link
<bool&, bool> m_aDragBeginHdl
;
989 std::function
<int(const weld::TreeIter
&, const weld::TreeIter
&)> m_aCustomSort
;
992 void signal_selection_changed() { m_aSelectionChangedHdl
.Call(*this); }
993 bool signal_row_activated() { return m_aRowActivatedHdl
.Call(*this); }
994 void signal_column_clicked(int nColumn
) { m_aColumnClickedHdl
.Call(nColumn
); }
995 bool signal_expanding(const TreeIter
& rIter
)
997 return !m_aExpandingHdl
.IsSet() || m_aExpandingHdl
.Call(rIter
);
999 bool signal_collapsing(const TreeIter
& rIter
)
1001 return !m_aCollapsingHdl
.IsSet() || m_aCollapsingHdl
.Call(rIter
);
1003 void signal_visible_range_changed() { m_aVisibleRangeChangedHdl
.Call(*this); }
1004 void signal_model_changed() { m_aModelChangedHdl
.Call(*this); }
1006 void signal_toggled(const iter_col
& rIterCol
) { m_aRadioToggleHdl
.Call(rIterCol
); }
1008 bool signal_editing_started(const TreeIter
& rIter
) { return m_aEditingStartedHdl
.Call(rIter
); }
1010 bool signal_editing_done(const iter_string
& rIterText
)
1012 return m_aEditingDoneHdl
.Call(rIterText
);
1015 void signal_popup_menu(const CommandEvent
& rCommand
) { m_aPopupMenuHdl
.Call(rCommand
); }
1017 Link
<const TreeIter
&, OUString
> m_aQueryTooltipHdl
;
1018 OUString
signal_query_tooltip(const TreeIter
& rIter
) { return m_aQueryTooltipHdl
.Call(rIter
); }
1020 Link
<render_args
, void> m_aRenderHdl
;
1021 void signal_custom_render(vcl::RenderContext
& rDevice
, const tools::Rectangle
& rRect
,
1022 bool bSelected
, const OUString
& rId
)
1024 m_aRenderHdl
.Call(render_args(rDevice
, rRect
, bSelected
, rId
));
1027 Link
<get_size_args
, Size
> m_aGetSizeHdl
;
1028 Size
signal_custom_get_size(vcl::RenderContext
& rDevice
, const OUString
& rId
)
1030 return m_aGetSizeHdl
.Call(get_size_args(rDevice
, rId
));
1034 virtual void connect_query_tooltip(const Link
<const TreeIter
&, OUString
>& rLink
)
1036 assert(!m_aQueryTooltipHdl
.IsSet() || !rLink
.IsSet());
1037 m_aQueryTooltipHdl
= rLink
;
1040 // see 'expanding on-demand node details' for bChildrenOnDemand of true
1041 virtual void insert(const TreeIter
* pParent
, int pos
, const OUString
* pStr
, const OUString
* pId
,
1042 const OUString
* pIconName
, VirtualDevice
* pImageSurface
,
1043 bool bChildrenOnDemand
, TreeIter
* pRet
)
1046 void insert(int nRow
, TreeIter
* pRet
= nullptr)
1048 insert(nullptr, nRow
, nullptr, nullptr, nullptr, nullptr, false, pRet
);
1051 void append(TreeIter
* pRet
= nullptr) { insert(-1, pRet
); }
1053 void insert(int pos
, const OUString
& rStr
, const OUString
* pId
, const OUString
* pIconName
,
1054 VirtualDevice
* pImageSurface
)
1056 insert(nullptr, pos
, &rStr
, pId
, pIconName
, pImageSurface
, false, nullptr);
1058 void insert_text(int pos
, const OUString
& rStr
)
1060 insert(nullptr, pos
, &rStr
, nullptr, nullptr, nullptr, false, nullptr);
1062 void append_text(const OUString
& rStr
)
1064 insert(nullptr, -1, &rStr
, nullptr, nullptr, nullptr, false, nullptr);
1066 void append(const OUString
& rId
, const OUString
& rStr
)
1068 insert(nullptr, -1, &rStr
, &rId
, nullptr, nullptr, false, nullptr);
1070 void append(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
1072 insert(nullptr, -1, &rStr
, &rId
, &rImage
, nullptr, false, nullptr);
1074 void append(const TreeIter
* pParent
, const OUString
& rStr
)
1076 insert(pParent
, -1, &rStr
, nullptr, nullptr, nullptr, false, nullptr);
1079 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
1080 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
1082 void connect_selection_changed(const Link
<TreeView
&, void>& rLink
)
1084 m_aSelectionChangedHdl
= rLink
;
1087 /* A row is "activated" when the user double clicks a treeview row. It may
1088 also be emitted when a row is selected and Space or Enter is pressed.
1090 a return of "true" means the activation has been handled, a "false" propagates
1091 the activation to the default handler which expands/collapses the row, if possible.
1093 void connect_row_activated(const Link
<TreeView
&, bool>& rLink
) { m_aRowActivatedHdl
= rLink
; }
1095 // Argument is a pair of iter, col describing the toggled node
1096 void connect_toggled(const Link
<const iter_col
&, void>& rLink
) { m_aRadioToggleHdl
= rLink
; }
1098 void connect_column_clicked(const Link
<int, void>& rLink
) { m_aColumnClickedHdl
= rLink
; }
1099 void connect_model_changed(const Link
<TreeView
&, void>& rLink
) { m_aModelChangedHdl
= rLink
; }
1101 virtual OUString
get_selected_text() const = 0;
1102 virtual OUString
get_selected_id() const = 0;
1104 // call before inserting any content and connecting to toggle signals,
1105 // an pre-inserted checkbutton column will exist at the start of every row
1106 // inserted after this call which can be accessed with col index -1
1107 virtual void enable_toggle_buttons(ColumnToggleType eType
) = 0;
1109 virtual void set_clicks_to_toggle(int nToggleBehavior
) = 0;
1112 virtual int get_selected_index() const = 0;
1113 //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1114 virtual void select(int pos
) = 0;
1115 virtual void unselect(int pos
) = 0;
1116 virtual void remove(int pos
) = 0;
1117 // col index -1 gets the first text column
1118 virtual OUString
get_text(int row
, int col
= -1) const = 0;
1119 // col index -1 sets the first text column
1120 virtual void set_text(int row
, const OUString
& rText
, int col
= -1) = 0;
1121 // col index -1 sets all columns
1122 virtual void set_sensitive(int row
, bool bSensitive
, int col
= -1) = 0;
1123 virtual bool get_sensitive(int row
, int col
) const = 0;
1124 virtual void set_id(int row
, const OUString
& rId
) = 0;
1125 // col index -1 sets the expander toggle, enable_toggle_buttons must have been called to create that column
1126 virtual void set_toggle(int row
, TriState eState
, int col
= -1) = 0;
1127 // col index -1 gets the expander toggle, enable_toggle_buttons must have been called to create that column
1128 virtual TriState
get_toggle(int row
, int col
= -1) const = 0;
1129 // col index -1 sets the expander image
1130 virtual void set_image(int row
, const OUString
& rImage
, int col
= -1) = 0;
1131 // col index -1 sets the expander image
1132 virtual void set_image(int row
, VirtualDevice
& rImage
, int col
= -1) = 0;
1133 // col index -1 sets the expander image
1134 virtual void set_image(int row
, const css::uno::Reference
<css::graphic::XGraphic
>& rImage
,
1137 virtual void set_text_emphasis(int row
, bool bOn
, int col
) = 0;
1138 virtual bool get_text_emphasis(int row
, int col
) const = 0;
1139 virtual void set_text_align(int row
, double fAlign
, int col
) = 0;
1140 virtual void swap(int pos1
, int pos2
) = 0;
1141 virtual std::vector
<int> get_selected_rows() const = 0;
1142 virtual void set_font_color(int pos
, const Color
& rColor
) = 0;
1143 // scroll to make 'row' visible, this will also expand all parent rows of 'row' as necessary to
1144 // make 'row' visible
1145 virtual void scroll_to_row(int row
) = 0;
1146 virtual bool is_selected(int pos
) const = 0;
1147 virtual int get_cursor_index() const = 0;
1148 virtual void set_cursor(int pos
) = 0;
1151 virtual int find_text(const OUString
& rText
) const = 0;
1152 //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1153 void select_text(const OUString
& rText
) { select(find_text(rText
)); }
1154 void remove_text(const OUString
& rText
) { remove(find_text(rText
)); }
1155 std::vector
<OUString
> get_selected_rows_text() const
1157 std::vector
<int> aRows(get_selected_rows());
1158 std::vector
<OUString
> aRet
;
1159 aRet
.reserve(aRows
.size());
1160 for (auto a
: aRows
)
1161 aRet
.push_back(get_text(a
));
1166 virtual OUString
get_id(int pos
) const = 0;
1167 virtual int find_id(const OUString
& rId
) const = 0;
1168 //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1169 void select_id(const OUString
& rId
) { select(find_id(rId
)); }
1170 void remove_id(const OUString
& rText
) { remove(find_id(rText
)); }
1173 virtual std::unique_ptr
<TreeIter
> make_iterator(const TreeIter
* pOrig
= nullptr) const = 0;
1174 virtual void copy_iterator(const TreeIter
& rSource
, TreeIter
& rDest
) const = 0;
1175 virtual bool get_selected(TreeIter
* pIter
) const = 0;
1176 virtual bool get_cursor(TreeIter
* pIter
) const = 0;
1177 virtual void set_cursor(const TreeIter
& rIter
) = 0;
1178 virtual bool get_iter_first(TreeIter
& rIter
) const = 0;
1179 // set iter to point to next node at the current level
1180 virtual bool iter_next_sibling(TreeIter
& rIter
) const = 0;
1181 // set iter to point to previous node at the current level
1182 virtual bool iter_previous_sibling(TreeIter
& rIter
) const = 0;
1183 // set iter to point to next node, depth first, then sibling
1184 virtual bool iter_next(TreeIter
& rIter
) const = 0;
1185 // set iter to point to previous node, sibling first then depth
1186 virtual bool iter_previous(TreeIter
& rIter
) const = 0;
1187 // set iter to point to first child node
1188 virtual bool iter_children(TreeIter
& rIter
) const = 0;
1189 bool iter_nth_sibling(TreeIter
& rIter
, int nChild
) const
1192 for (int i
= 0; i
< nChild
&& bRet
; ++i
)
1193 bRet
= iter_next_sibling(rIter
);
1196 bool iter_nth_child(TreeIter
& rIter
, int nChild
) const
1198 if (!iter_children(rIter
))
1200 return iter_nth_sibling(rIter
, nChild
);
1202 virtual bool iter_parent(TreeIter
& rIter
) const = 0;
1203 virtual int get_iter_depth(const TreeIter
& rIter
) const = 0;
1204 virtual int get_iter_index_in_parent(const TreeIter
& rIter
) const = 0;
1205 /* Compares two paths. If a appears before b in a tree, then -1 is returned.
1206 If b appears before a , then 1 is returned. If the two nodes are equal,
1209 virtual int iter_compare(const TreeIter
& a
, const TreeIter
& b
) const = 0;
1210 virtual bool iter_has_child(const TreeIter
& rIter
) const = 0;
1211 // returns the number of direct children rIter has
1212 virtual int iter_n_children(const TreeIter
& rIter
) const = 0;
1213 virtual void remove(const TreeIter
& rIter
) = 0;
1214 //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1215 virtual void select(const TreeIter
& rIter
) = 0;
1216 virtual void unselect(const TreeIter
& rIter
) = 0;
1217 //visually indent this row as if it was at get_iter_depth() + nIndentLevel
1218 virtual void set_extra_row_indent(const TreeIter
& rIter
, int nIndentLevel
) = 0;
1219 // col index -1 sets the first text column
1220 virtual void set_text(const TreeIter
& rIter
, const OUString
& rStr
, int col
= -1) = 0;
1221 // col index -1 sets all columns
1222 virtual void set_sensitive(const TreeIter
& rIter
, bool bSensitive
, int col
= -1) = 0;
1223 virtual bool get_sensitive(const TreeIter
& rIter
, int col
) const = 0;
1224 virtual void set_text_emphasis(const TreeIter
& rIter
, bool bOn
, int col
) = 0;
1225 virtual bool get_text_emphasis(const TreeIter
& rIter
, int col
) const = 0;
1226 virtual void set_text_align(const TreeIter
& rIter
, double fAlign
, int col
) = 0;
1227 // col index -1 sets the expander toggle, enable_toggle_buttons must have been called to create that column
1228 virtual void set_toggle(const TreeIter
& rIter
, TriState bOn
, int col
= -1) = 0;
1229 // col index -1 gets the expander toggle, enable_toggle_buttons must have been called to create that column
1230 virtual TriState
get_toggle(const TreeIter
& rIter
, int col
= -1) const = 0;
1231 // col index -1 gets the first text column
1232 virtual OUString
get_text(const TreeIter
& rIter
, int col
= -1) const = 0;
1233 virtual void set_id(const TreeIter
& rIter
, const OUString
& rId
) = 0;
1234 virtual OUString
get_id(const TreeIter
& rIter
) const = 0;
1235 // col index -1 sets the expander image
1236 virtual void set_image(const TreeIter
& rIter
, const OUString
& rImage
, int col
= -1) = 0;
1237 // col index -1 sets the expander image
1238 virtual void set_image(const TreeIter
& rIter
, VirtualDevice
& rImage
, int col
= -1) = 0;
1239 // col index -1 sets the expander image
1240 virtual void set_image(const TreeIter
& rIter
,
1241 const css::uno::Reference
<css::graphic::XGraphic
>& rImage
, int col
= -1)
1243 virtual void set_font_color(const TreeIter
& rIter
, const Color
& rColor
) = 0;
1244 // scroll to make rIter visible, this will also expand all parent rows of rIter as necessary to
1245 // make rIter visible
1246 virtual void scroll_to_row(const TreeIter
& rIter
) = 0;
1247 virtual bool is_selected(const TreeIter
& rIter
) const = 0;
1249 virtual void move_subtree(TreeIter
& rNode
, const TreeIter
* pNewParent
, int nIndexInNewParent
)
1252 // call func on each element until func returns true or we run out of elements
1253 virtual void all_foreach(const std::function
<bool(TreeIter
&)>& func
) = 0;
1254 // call func on each selected element until func returns true or we run out of elements
1255 virtual void selected_foreach(const std::function
<bool(TreeIter
&)>& func
) = 0;
1256 // call func on each visible element until func returns true or we run out of elements
1257 virtual void visible_foreach(const std::function
<bool(TreeIter
&)>& func
) = 0;
1258 // clear the children of pParent (whole tree if nullptr),
1259 // then add nSourceCount rows under pParent, call func on each row
1260 // inserted with an arg of the index that this row will be when bulk insert
1263 // this enables inserting the entries backwards in models where that is faster,
1265 // pFixedWidths is optional, when present each matching entry col text
1266 // width will not be measured, and the fixed width used instead. Use
1267 // sparingly because wider text than the fixed width is clipped and cannot
1268 // be scrolled into view horizontally.
1269 // @param bGoingToSetText needs to be true, if you plan to call set_text inside the insert func.
1270 virtual void bulk_insert_for_each(int nSourceCount
,
1271 const std::function
<void(TreeIter
&, int nSourceIndex
)>& func
,
1272 const weld::TreeIter
* pParent
= nullptr,
1273 const std::vector
<int>* pFixedWidths
= nullptr,
1274 bool bGoingToSetText
= false)
1277 /* expanding on-demand node details
1279 When a node is added with children-on-demand (typically via 'insert' with
1280 bChildrenOnDemand of true), then initially in reality the
1281 children-on-demand node is given a 'placeholder' child entry to indicate
1282 the load-on-demand state.
1284 The 'placeholder' needs to be there for the expander indicator to be
1285 drawn/shown even when there are no "real" entries yet. This child doesn't
1286 exist for the purposes of any of the iterator methods, e.g. iter_has_child
1287 on an on-demand node which hasn't been expanded yet is false. Likewise the
1288 rest of the iterator methods skip over or otherwise ignore that node.
1290 Normal usage is the user clicks on the expander, the expansion mechanism
1291 removes the 'placeholder' entry (set_children_on_demand(false)) and calls
1292 any installed expanding-callback (installable via connect_expanding) which
1293 has the opportunity to populate the node with children.
1295 If you decide to directly populate the children of an on-demand node
1296 outside of the expanding-callback then you also need to explicitly remove
1297 the 'placeholder' with set_children_on_demand(false) otherwise the treeview
1298 is in an inconsistent state. */
1300 virtual bool get_row_expanded(const TreeIter
& rIter
) const = 0;
1301 // expand row will first trigger the callback set via connect_expanding before expanding
1302 virtual void expand_row(const TreeIter
& rIter
) = 0;
1303 // collapse row will first trigger the callback set via connect_collapsing before collapsing
1304 virtual void collapse_row(const TreeIter
& rIter
) = 0;
1305 // set the empty node to appear as if it has children, true is equivalent
1306 // to 'insert' with a bChildrenOnDemand of true. See notes above.
1307 virtual void set_children_on_demand(const TreeIter
& rIter
, bool bChildrenOnDemand
) = 0;
1308 // return if the node is configured to be populated on-demand
1309 virtual bool get_children_on_demand(const TreeIter
& rIter
) const = 0;
1310 // set if the expanders are shown or not
1311 virtual void set_show_expanders(bool bShow
) = 0;
1313 void connect_expanding(const Link
<const TreeIter
&, bool>& rLink
) { m_aExpandingHdl
= rLink
; }
1314 void connect_collapsing(const Link
<const TreeIter
&, bool>& rLink
) { m_aCollapsingHdl
= rLink
; }
1316 // rStartLink returns true to allow editing, false to disallow
1317 // rEndLink returns true to accept the edit, false to reject
1318 virtual void connect_editing(const Link
<const TreeIter
&, bool>& rStartLink
,
1319 const Link
<const iter_string
&, bool>& rEndLink
)
1321 assert(rStartLink
.IsSet() == rEndLink
.IsSet() && "should be both on or both off");
1322 m_aEditingStartedHdl
= rStartLink
;
1323 m_aEditingDoneHdl
= rEndLink
;
1326 virtual void start_editing(const weld::TreeIter
& rEntry
) = 0;
1327 virtual void end_editing() = 0;
1329 virtual void connect_visible_range_changed(const Link
<TreeView
&, void>& rLink
)
1331 assert(!m_aVisibleRangeChangedHdl
.IsSet() || !rLink
.IsSet());
1332 m_aVisibleRangeChangedHdl
= rLink
;
1335 virtual void connect_popup_menu(const Link
<const CommandEvent
&, bool>& rLink
)
1337 m_aPopupMenuHdl
= rLink
;
1340 virtual void enable_drag_source(rtl::Reference
<TransferDataContainer
>& rTransferable
,
1341 sal_uInt8 eDNDConstants
)
1344 void connect_drag_begin(const Link
<bool&, bool>& rLink
) { m_aDragBeginHdl
= rLink
; }
1346 //all of them. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1347 void select_all() { unselect(-1); }
1348 void unselect_all() { select(-1); }
1350 // return the number of toplevel nodes
1351 virtual int n_children() const = 0;
1353 // afterwards, entries will be in default ascending sort order
1354 virtual void make_sorted() = 0;
1355 virtual void make_unsorted() = 0;
1356 virtual bool get_sort_order() const = 0;
1357 virtual void set_sort_order(bool bAscending
) = 0;
1359 // TRUE ascending, FALSE, descending, INDET, neither (off)
1360 virtual void set_sort_indicator(TriState eState
, int nColumn
) = 0;
1361 virtual TriState
get_sort_indicator(int nColumn
) const = 0;
1363 virtual int get_sort_column() const = 0;
1364 virtual void set_sort_column(int nColumn
) = 0;
1367 set_sort_func(const std::function
<int(const weld::TreeIter
&, const weld::TreeIter
&)>& func
)
1369 m_aCustomSort
= func
;
1372 virtual void clear() = 0;
1373 virtual int get_height_rows(int nRows
) const = 0;
1375 virtual void columns_autosize() = 0;
1376 virtual void set_column_fixed_widths(const std::vector
<int>& rWidths
) = 0;
1377 virtual void set_column_editables(const std::vector
<bool>& rEditables
) = 0;
1378 virtual int get_column_width(int nCol
) const = 0;
1379 virtual void set_centered_column(int nCol
) = 0;
1380 virtual OUString
get_column_title(int nColumn
) const = 0;
1381 virtual void set_column_title(int nColumn
, const OUString
& rTitle
) = 0;
1383 int get_checkbox_column_width() const { return get_approximate_digit_width() * 3 + 6; }
1385 virtual void set_selection_mode(SelectionMode eMode
) = 0;
1386 virtual int count_selected_rows() const = 0;
1387 // remove the selected nodes
1388 virtual void remove_selection() = 0;
1390 // only meaningful is call this from a "changed" callback, true if the change
1391 // was due to mouse hovering over the entry
1392 virtual bool changed_by_hover() const = 0;
1394 virtual void vadjustment_set_value(int value
) = 0;
1395 virtual int vadjustment_get_value() const = 0;
1397 void save_value() { m_sSavedValue
= get_selected_text(); }
1398 OUString
const& get_saved_value() const { return m_sSavedValue
; }
1399 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_selected_text(); }
1401 // for custom rendering a cell
1402 void connect_custom_get_size(const Link
<get_size_args
, Size
>& rLink
) { m_aGetSizeHdl
= rLink
; }
1403 void connect_custom_render(const Link
<render_args
, void>& rLink
) { m_aRenderHdl
= rLink
; }
1404 // call set_column_custom_renderer after setting custom callbacks
1405 virtual void set_column_custom_renderer(int nColumn
, bool bEnable
) = 0;
1406 // redraw all rows, typically only useful with custom rendering to redraw due to external
1408 virtual void queue_draw() = 0;
1410 /* with bDnDMode false simply return the row under the point
1412 * with bDnDMode true:
1413 * a) return the row which should be dropped on, which may
1414 * be different from the row the mouse is over in some backends where
1415 * positioning the mouse on the bottom half of a row indicates to drop
1417 * b) dnd highlight the dest row
1419 virtual bool get_dest_row_at_pos(const Point
& rPos
, weld::TreeIter
* pResult
, bool bDnDMode
,
1420 bool bAutoScroll
= true)
1422 virtual void unset_drag_dest_row() = 0;
1423 virtual tools::Rectangle
get_row_area(const weld::TreeIter
& rIter
) const = 0;
1424 // for dragging and dropping between TreeViews, return the active source
1425 virtual TreeView
* get_drag_source() const = 0;
1427 using Widget::set_sensitive
;
1428 using Widget::get_sensitive
;
1431 typedef std::tuple
<OUString
&, const TreeIter
&> encoded_image_query
;
1433 class VCL_DLLPUBLIC IconView
: virtual public Widget
1435 friend class ::LOKTrigger
;
1438 OUString m_sSavedValue
;
1441 Link
<IconView
&, void> m_aSelectionChangeHdl
;
1442 Link
<IconView
&, bool> m_aItemActivatedHdl
;
1443 Link
<const CommandEvent
&, bool> m_aCommandHdl
;
1444 Link
<const TreeIter
&, OUString
> m_aQueryTooltipHdl
;
1445 Link
<const encoded_image_query
&, bool> m_aGetPropertyTreeElemHdl
;
1447 void signal_selection_changed() { m_aSelectionChangeHdl
.Call(*this); }
1448 bool signal_item_activated() { return m_aItemActivatedHdl
.Call(*this); }
1449 OUString
signal_query_tooltip(const TreeIter
& rIter
) const
1451 return m_aQueryTooltipHdl
.Call(rIter
);
1455 virtual int get_item_width() const = 0;
1456 virtual void set_item_width(int width
) = 0;
1458 virtual void insert(int pos
, const OUString
* pStr
, const OUString
* pId
,
1459 const OUString
* pIconName
, TreeIter
* pRet
)
1462 virtual void insert(int pos
, const OUString
* pStr
, const OUString
* pId
,
1463 const VirtualDevice
* pIcon
, TreeIter
* pRet
)
1466 virtual void insert_separator(int pos
, const OUString
* pId
) = 0;
1468 void append(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
1470 insert(-1, &rStr
, &rId
, &rImage
, nullptr);
1473 void append(const OUString
& rId
, const OUString
& rStr
, const VirtualDevice
* pImage
)
1475 insert(-1, &rStr
, &rId
, pImage
, nullptr);
1478 void append_separator(const OUString
& rId
) { insert_separator(-1, &rId
); }
1480 void connect_selection_changed(const Link
<IconView
&, void>& rLink
)
1482 m_aSelectionChangeHdl
= rLink
;
1485 /* A row is "activated" when the user double clicks a treeview row. It may
1486 also be emitted when a row is selected and Space or Enter is pressed.
1488 a return of "true" means the activation has been handled, a "false" propagates
1489 the activation to the default handler which expands/collapses the row, if possible.
1491 void connect_item_activated(const Link
<IconView
&, bool>& rLink
) { m_aItemActivatedHdl
= rLink
; }
1493 void connect_command(const Link
<const CommandEvent
&, bool>& rLink
) { m_aCommandHdl
= rLink
; }
1495 virtual void connect_query_tooltip(const Link
<const TreeIter
&, OUString
>& rLink
)
1497 m_aQueryTooltipHdl
= rLink
;
1500 // 0: OUString, 1: TreeIter, returns true if supported
1501 virtual void connect_get_image(const Link
<const encoded_image_query
&, bool>& rLink
)
1503 m_aGetPropertyTreeElemHdl
= rLink
;
1506 virtual OUString
get_selected_id() const = 0;
1508 virtual void clear() = 0;
1510 virtual int count_selected_items() const = 0;
1512 virtual OUString
get_selected_text() const = 0;
1514 //by index. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1515 virtual OUString
get_id(int pos
) const = 0;
1516 virtual void select(int pos
) = 0;
1517 virtual void unselect(int pos
) = 0;
1518 virtual void set_image(int pos
, VirtualDevice
* pDevice
) = 0;
1519 virtual void set_text(int pos
, const OUString
& rText
) = 0;
1520 virtual void set_id(int pos
, const OUString
& rId
) = 0;
1521 virtual void remove(int pos
) = 0;
1522 virtual tools::Rectangle
get_rect(int pos
) const = 0;
1525 virtual std::unique_ptr
<TreeIter
> make_iterator(const TreeIter
* pOrig
= nullptr) const = 0;
1526 virtual bool get_selected(TreeIter
* pIter
) const = 0;
1527 virtual bool get_cursor(TreeIter
* pIter
) const = 0;
1528 virtual void set_cursor(const TreeIter
& rIter
) = 0;
1529 virtual bool get_iter_first(TreeIter
& rIter
) const = 0;
1530 virtual OUString
get_id(const TreeIter
& rIter
) const = 0;
1531 virtual OUString
get_text(const TreeIter
& rIter
) const = 0;
1532 virtual bool iter_next_sibling(TreeIter
& rIter
) const = 0;
1533 virtual void scroll_to_item(const TreeIter
& rIter
) = 0;
1535 // call func on each selected element until func returns true or we run out of elements
1536 virtual void selected_foreach(const std::function
<bool(TreeIter
&)>& func
) = 0;
1538 //all of them. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1539 void select_all() { unselect(-1); }
1540 void unselect_all() { select(-1); }
1542 // return the number of toplevel nodes
1543 virtual int n_children() const = 0;
1545 void save_value() { m_sSavedValue
= get_selected_text(); }
1546 OUString
const& get_saved_value() const { return m_sSavedValue
; }
1547 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_selected_text(); }
1550 class VCL_DLLPUBLIC Button
: virtual public Widget
1552 friend class ::LOKTrigger
;
1555 Link
<Button
&, void> m_aClickHdl
;
1557 void signal_clicked() { m_aClickHdl
.Call(*this); }
1560 virtual void set_label(const OUString
& rText
) = 0;
1561 // pDevice, the image for the button, or nullptr to unset
1562 virtual void set_image(VirtualDevice
* pDevice
) = 0;
1563 virtual void set_image(const css::uno::Reference
<css::graphic::XGraphic
>& rImage
) = 0;
1564 virtual void set_from_icon_name(const OUString
& rIconName
) = 0;
1565 virtual OUString
get_label() const = 0;
1566 void clicked() { signal_clicked(); }
1567 bool is_custom_handler_set() { return m_aClickHdl
.IsSet(); }
1569 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
1570 virtual void set_font(const vcl::Font
& rFont
) = 0;
1572 /* Sometimes, a widget should behave like a button (activate on click,
1573 accept keyboard focus, etc), but look entirely different.
1575 pDevice, the custom look to use, or nullptr to unset.
1577 Typically doing this is ill advised. Consider using
1578 set_accessible_name if you do. */
1579 virtual void set_custom_button(VirtualDevice
* pDevice
) = 0;
1581 virtual void connect_clicked(const Link
<Button
&, void>& rLink
) { m_aClickHdl
= rLink
; }
1584 class VCL_DLLPUBLIC Toggleable
: virtual public Widget
1586 friend class ::LOKTrigger
;
1589 Link
<Toggleable
&, void> m_aToggleHdl
;
1590 TriState m_eSavedValue
= TRISTATE_FALSE
;
1592 void signal_toggled() { m_aToggleHdl
.Call(*this); }
1595 virtual void set_active(bool active
) = 0;
1596 virtual bool get_active() const = 0;
1598 virtual void set_inconsistent(bool inconsistent
) = 0;
1599 virtual bool get_inconsistent() const = 0;
1601 TriState
get_state() const
1603 if (get_inconsistent())
1604 return TRISTATE_INDET
;
1605 else if (get_active())
1606 return TRISTATE_TRUE
;
1607 return TRISTATE_FALSE
;
1610 void set_state(TriState eState
)
1614 case TRISTATE_INDET
:
1615 set_inconsistent(true);
1618 set_inconsistent(false);
1621 case TRISTATE_FALSE
:
1622 set_inconsistent(false);
1628 void save_state() { m_eSavedValue
= get_state(); }
1629 TriState
get_saved_state() const { return m_eSavedValue
; }
1630 bool get_state_changed_from_saved() const { return m_eSavedValue
!= get_state(); }
1632 virtual void connect_toggled(const Link
<Toggleable
&, void>& rLink
) { m_aToggleHdl
= rLink
; }
1635 class VCL_DLLPUBLIC ToggleButton
: virtual public Button
, virtual public Toggleable
1637 friend class ::LOKTrigger
;
1640 struct VCL_DLLPUBLIC TriStateEnabled
1643 bool bTriStateEnabled
;
1645 : eState(TRISTATE_INDET
)
1646 , bTriStateEnabled(true)
1649 void ButtonToggled(Toggleable
& rToggle
);
1652 class VCL_DLLPUBLIC MenuButton
: virtual public ToggleButton
1654 friend class ::LOKTrigger
;
1656 Link
<const OUString
&, void> m_aSelectHdl
;
1659 void signal_selected(const OUString
& rIdent
) { m_aSelectHdl
.Call(rIdent
); }
1662 void connect_selected(const Link
<const OUString
&, void>& rLink
) { m_aSelectHdl
= rLink
; }
1664 virtual void insert_item(int pos
, const OUString
& rId
, const OUString
& rStr
,
1665 const OUString
* pIconName
, VirtualDevice
* pImageSurface
,
1666 TriState eCheckRadioFalse
)
1668 void append_item(const OUString
& rId
, const OUString
& rStr
)
1670 insert_item(-1, rId
, rStr
, nullptr, nullptr, TRISTATE_INDET
);
1672 void append_item_check(const OUString
& rId
, const OUString
& rStr
)
1674 insert_item(-1, rId
, rStr
, nullptr, nullptr, TRISTATE_TRUE
);
1676 void append_item_radio(const OUString
& rId
, const OUString
& rStr
)
1678 insert_item(-1, rId
, rStr
, nullptr, nullptr, TRISTATE_FALSE
);
1680 void append_item(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
1682 insert_item(-1, rId
, rStr
, &rImage
, nullptr, TRISTATE_INDET
);
1684 void append_item(const OUString
& rId
, const OUString
& rStr
, VirtualDevice
& rImage
)
1686 insert_item(-1, rId
, rStr
, nullptr, &rImage
, TRISTATE_INDET
);
1688 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
1689 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
1690 virtual void remove_item(const OUString
& rId
) = 0;
1691 virtual void clear() = 0;
1692 virtual void set_item_sensitive(const OUString
& rIdent
, bool bSensitive
) = 0;
1693 virtual void set_item_active(const OUString
& rIdent
, bool bActive
) = 0;
1694 virtual void set_item_label(const OUString
& rIdent
, const OUString
& rLabel
) = 0;
1695 virtual OUString
get_item_label(const OUString
& rIdent
) const = 0;
1696 virtual void set_item_visible(const OUString
& rIdent
, bool bVisible
) = 0;
1698 virtual void set_popover(weld::Widget
* pPopover
) = 0;
1701 // Similar to a MenuButton except it is split into two parts, a toggle
1702 // button at the start and a menubutton at the end
1703 class VCL_DLLPUBLIC MenuToggleButton
: virtual public MenuButton
1707 class VCL_DLLPUBLIC CheckButton
: virtual public Toggleable
1710 virtual void set_label(const OUString
& rText
) = 0;
1711 virtual OUString
get_label() const = 0;
1712 virtual void set_label_wrap(bool wrap
) = 0;
1715 class VCL_DLLPUBLIC RadioButton
: virtual public CheckButton
1719 class VCL_DLLPUBLIC LinkButton
: virtual public Widget
1721 friend class ::LOKTrigger
;
1723 Link
<LinkButton
&, bool> m_aActivateLinkHdl
;
1726 bool signal_activate_link() { return m_aActivateLinkHdl
.Call(*this); }
1729 virtual void set_label(const OUString
& rText
) = 0;
1730 virtual OUString
get_label() const = 0;
1731 virtual void set_label_wrap(bool wrap
) = 0;
1732 virtual void set_uri(const OUString
& rUri
) = 0;
1733 virtual OUString
get_uri() const = 0;
1735 void connect_activate_link(const Link
<LinkButton
&, bool>& rLink
) { m_aActivateLinkHdl
= rLink
; }
1738 class VCL_DLLPUBLIC Scale
: virtual public Widget
1740 Link
<Scale
&, void> m_aValueChangedHdl
;
1743 void signal_value_changed() { m_aValueChangedHdl
.Call(*this); }
1746 virtual void set_value(int value
) = 0;
1747 virtual int get_value() const = 0;
1748 virtual void set_range(int min
, int max
) = 0;
1750 virtual void set_increments(int step
, int page
) = 0;
1751 virtual void get_increments(int& step
, int& page
) const = 0;
1753 void connect_value_changed(const Link
<Scale
&, void>& rLink
) { m_aValueChangedHdl
= rLink
; }
1756 class VCL_DLLPUBLIC Spinner
: virtual public Widget
1759 virtual void start() = 0;
1760 virtual void stop() = 0;
1763 class VCL_DLLPUBLIC ProgressBar
: virtual public Widget
1767 virtual void set_percentage(int value
) = 0;
1768 virtual OUString
get_text() const = 0;
1769 virtual void set_text(const OUString
& rText
) = 0;
1772 class VCL_DLLPUBLIC LevelBar
: virtual public Widget
1775 /// Sets LevelBar fill percentage.
1776 /// @param fPercentage bar's fill percentage, [0.0, 100.0]
1777 virtual void set_percentage(double fPercentage
) = 0;
1780 class VCL_DLLPUBLIC Entry
: virtual public Widget
1783 OUString m_sSavedValue
;
1786 Link
<Entry
&, void> m_aChangeHdl
;
1787 Link
<OUString
&, bool> m_aInsertTextHdl
;
1788 Link
<Entry
&, void> m_aCursorPositionHdl
;
1789 Link
<Entry
&, bool> m_aActivateHdl
;
1791 friend class ::LOKTrigger
;
1793 void signal_changed() { m_aChangeHdl
.Call(*this); }
1794 void signal_cursor_position() { m_aCursorPositionHdl
.Call(*this); }
1797 virtual void set_text(const OUString
& rText
) = 0;
1798 virtual OUString
get_text() const = 0;
1799 virtual void set_width_chars(int nChars
) = 0;
1800 virtual int get_width_chars() const = 0;
1801 // The maximum length of the entry. Use 0 for no maximum
1802 virtual void set_max_length(int nChars
) = 0;
1803 // nEndPos can be -1 in order to select all text
1804 virtual void select_region(int nStartPos
, int nEndPos
) = 0;
1805 // returns true if the selection has nonzero length
1806 virtual bool get_selection_bounds(int& rStartPos
, int& rEndPos
) = 0;
1807 virtual void replace_selection(const OUString
& rText
) = 0;
1808 // nCursorPos can be -1 to set to the end
1809 virtual void set_position(int nCursorPos
) = 0;
1810 virtual int get_position() const = 0;
1811 virtual void set_editable(bool bEditable
) = 0;
1812 virtual bool get_editable() const = 0;
1813 virtual void set_visibility(bool bVisible
) = 0;
1814 virtual void set_message_type(EntryMessageType eType
) = 0;
1815 virtual void set_placeholder_text(const OUString
& rText
) = 0;
1817 virtual void set_overwrite_mode(bool bOn
) = 0;
1818 virtual bool get_overwrite_mode() const = 0;
1820 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
1821 virtual void set_font(const vcl::Font
& rFont
) = 0;
1824 If you want to set a warning or error state, see set_message_type
1825 instead where, if the toolkit supports it, a specific warning/error
1828 This explicit text color method exists to support rendering the
1829 SvNumberformat color feature.
1831 virtual void set_font_color(const Color
& rColor
) = 0;
1833 virtual void connect_changed(const Link
<Entry
&, void>& rLink
) { m_aChangeHdl
= rLink
; }
1834 void connect_insert_text(const Link
<OUString
&, bool>& rLink
) { m_aInsertTextHdl
= rLink
; }
1835 // callback returns true to indicated no further processing of activate wanted
1836 void connect_activate(const Link
<Entry
&, bool>& rLink
) { m_aActivateHdl
= rLink
; }
1837 virtual void connect_cursor_position(const Link
<Entry
&, void>& rLink
)
1839 m_aCursorPositionHdl
= rLink
;
1842 virtual void cut_clipboard() = 0;
1843 virtual void copy_clipboard() = 0;
1844 virtual void paste_clipboard() = 0;
1846 virtual void set_alignment(TxtAlign eXAlign
) = 0;
1848 void save_value() { m_sSavedValue
= get_text(); }
1849 OUString
const& get_saved_value() const { return m_sSavedValue
; }
1850 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_text(); }
1853 class VCL_DLLPUBLIC SpinButton
: virtual public Entry
1855 friend class ::LOKTrigger
;
1857 Link
<SpinButton
&, void> m_aValueChangedHdl
;
1858 Link
<SpinButton
&, void> m_aOutputHdl
;
1859 Link
<int*, bool> m_aInputHdl
;
1862 void signal_value_changed() { m_aValueChangedHdl
.Call(*this); }
1864 bool signal_output()
1866 if (!m_aOutputHdl
.IsSet())
1868 m_aOutputHdl
.Call(*this);
1872 TriState
signal_input(int* result
)
1874 if (!m_aInputHdl
.IsSet())
1875 return TRISTATE_INDET
;
1876 return m_aInputHdl
.Call(result
) ? TRISTATE_TRUE
: TRISTATE_FALSE
;
1880 virtual void set_value(sal_Int64 value
) = 0;
1881 virtual sal_Int64
get_value() const = 0;
1882 virtual void set_range(sal_Int64 min
, sal_Int64 max
) = 0;
1883 virtual void get_range(sal_Int64
& min
, sal_Int64
& max
) const = 0;
1884 void set_min(sal_Int64 min
)
1886 sal_Int64 dummy
, max
;
1887 get_range(dummy
, max
);
1888 set_range(min
, max
);
1890 void set_max(sal_Int64 max
)
1892 sal_Int64 min
, dummy
;
1893 get_range(min
, dummy
);
1894 set_range(min
, max
);
1896 sal_Int64
get_min() const
1898 sal_Int64 min
, dummy
;
1899 get_range(min
, dummy
);
1902 sal_Int64
get_max() const
1904 sal_Int64 dummy
, max
;
1905 get_range(dummy
, max
);
1908 virtual void set_increments(sal_Int64 step
, sal_Int64 page
) = 0;
1909 virtual void get_increments(sal_Int64
& step
, sal_Int64
& page
) const = 0;
1910 virtual void set_digits(unsigned int digits
) = 0;
1911 virtual unsigned int get_digits() const = 0;
1913 void connect_value_changed(const Link
<SpinButton
&, void>& rLink
) { m_aValueChangedHdl
= rLink
; }
1915 void connect_output(const Link
<SpinButton
&, void>& rLink
) { m_aOutputHdl
= rLink
; }
1916 void connect_input(const Link
<int*, bool>& rLink
) { m_aInputHdl
= rLink
; }
1918 sal_Int64
normalize(sal_Int64 nValue
) const { return (nValue
* Power10(get_digits())); }
1920 sal_Int64
denormalize(sal_Int64 nValue
) const;
1922 static unsigned int Power10(unsigned int n
);
1925 class EntryFormatter
;
1927 // Similar to a SpinButton, but input and output formatting and range/value
1928 // are managed by a more complex Formatter which can support doubles.
1929 class VCL_DLLPUBLIC FormattedSpinButton
: virtual public Entry
1931 friend class ::LOKTrigger
;
1933 Link
<FormattedSpinButton
&, void> m_aValueChangedHdl
;
1936 void signal_value_changed() { m_aValueChangedHdl
.Call(*this); }
1939 virtual Formatter
& GetFormatter() = 0;
1940 // does not take ownership, and so must be deregistered if pFormatter
1942 virtual void SetFormatter(weld::EntryFormatter
* pFormatter
) = 0;
1944 void connect_value_changed(const Link
<FormattedSpinButton
&, void>& rLink
)
1946 m_aValueChangedHdl
= rLink
;
1950 friend class EntryFormatter
;
1951 virtual void sync_range_from_formatter() = 0;
1952 virtual void sync_value_from_formatter() = 0;
1953 virtual void sync_increments_from_formatter() = 0;
1956 class VCL_DLLPUBLIC Image
: virtual public Widget
1959 virtual void set_from_icon_name(const OUString
& rIconName
) = 0;
1960 virtual void set_image(VirtualDevice
* pDevice
) = 0;
1961 virtual void set_image(const css::uno::Reference
<css::graphic::XGraphic
>& rImage
) = 0;
1964 class VCL_DLLPUBLIC Calendar
: virtual public Widget
1966 friend class ::LOKTrigger
;
1968 Link
<Calendar
&, void> m_aSelectedHdl
;
1969 Link
<Calendar
&, void> m_aActivatedHdl
;
1972 void signal_selected() { m_aSelectedHdl
.Call(*this); }
1973 void signal_activated() { m_aActivatedHdl
.Call(*this); }
1976 void connect_selected(const Link
<Calendar
&, void>& rLink
) { m_aSelectedHdl
= rLink
; }
1977 void connect_activated(const Link
<Calendar
&, void>& rLink
) { m_aActivatedHdl
= rLink
; }
1979 virtual void set_date(const Date
& rDate
) = 0;
1980 virtual Date
get_date() const = 0;
1983 // an entry + treeview pair, where the entry autocompletes from the
1984 // treeview list, and selecting something in the list sets the
1985 // entry to that text, i.e. a visually exploded ComboBox
1986 class VCL_DLLPUBLIC EntryTreeView
: virtual public ComboBox
1989 DECL_DLLPRIVATE_LINK(ClickHdl
, weld::TreeView
&, void);
1990 DECL_DLLPRIVATE_LINK(ModifyHdl
, weld::Entry
&, void);
1991 void EntryModifyHdl(const weld::Entry
& rEntry
);
1994 std::unique_ptr
<Entry
> m_xEntry
;
1995 std::unique_ptr
<TreeView
> m_xTreeView
;
1998 EntryTreeView(std::unique_ptr
<Entry
> xEntry
, std::unique_ptr
<TreeView
> xTreeView
);
2000 virtual void insert_vector(const std::vector
<weld::ComboBoxEntry
>& rItems
,
2001 bool bKeepExisting
) override
2003 m_xTreeView
->freeze();
2005 m_xTreeView
->clear();
2006 for (const auto& rItem
: rItems
)
2008 m_xTreeView
->thaw();
2011 virtual void insert(int pos
, const OUString
& rStr
, const OUString
* pId
,
2012 const OUString
* pIconName
, VirtualDevice
* pImageSurface
) override
2014 m_xTreeView
->insert(pos
, rStr
, pId
, pIconName
, pImageSurface
);
2017 virtual int get_count() const override
{ return m_xTreeView
->n_children(); }
2018 virtual void clear() override
{ m_xTreeView
->clear(); }
2021 virtual int get_active() const override
{ return m_xTreeView
->get_selected_index(); }
2022 virtual void set_active(int pos
) override
2024 m_xTreeView
->set_cursor(pos
);
2025 m_xTreeView
->select(pos
);
2026 m_xEntry
->set_text(m_xTreeView
->get_selected_text());
2028 virtual void remove(int pos
) override
{ m_xTreeView
->remove(pos
); }
2031 virtual OUString
get_active_text() const override
{ return m_xEntry
->get_text(); }
2032 virtual OUString
get_text(int pos
) const override
{ return m_xTreeView
->get_text(pos
); }
2033 virtual int find_text(const OUString
& rStr
) const override
2035 return m_xTreeView
->find_text(rStr
);
2039 virtual OUString
get_active_id() const override
{ return m_xTreeView
->get_selected_id(); }
2040 virtual void set_active_id(const OUString
& rStr
) override
2042 m_xTreeView
->select_id(rStr
);
2043 m_xEntry
->set_text(m_xTreeView
->get_selected_text());
2045 virtual OUString
get_id(int pos
) const override
{ return m_xTreeView
->get_id(pos
); }
2046 virtual void set_id(int pos
, const OUString
& rId
) override
{ m_xTreeView
->set_id(pos
, rId
); }
2047 virtual int find_id(const OUString
& rId
) const override
{ return m_xTreeView
->find_id(rId
); }
2050 virtual bool has_entry() const override
{ return true; }
2051 virtual void set_entry_message_type(EntryMessageType eType
) override
2053 m_xEntry
->set_message_type(eType
);
2055 virtual void set_entry_text(const OUString
& rStr
) override
{ m_xEntry
->set_text(rStr
); }
2056 virtual void set_entry_width_chars(int nChars
) override
{ m_xEntry
->set_width_chars(nChars
); }
2057 virtual void set_entry_max_length(int nChars
) override
{ m_xEntry
->set_max_length(nChars
); }
2058 virtual void select_entry_region(int nStartPos
, int nEndPos
) override
2060 m_xEntry
->select_region(nStartPos
, nEndPos
);
2062 //if no text was selected, both rStartPos and rEndPos will be identical
2063 //and false will be returned
2064 virtual bool get_entry_selection_bounds(int& rStartPos
, int& rEndPos
) override
2066 return m_xEntry
->get_selection_bounds(rStartPos
, rEndPos
);
2068 void connect_row_activated(const Link
<TreeView
&, bool>& rLink
)
2070 m_xTreeView
->connect_row_activated(rLink
);
2073 virtual bool get_popup_shown() const override
{ return false; }
2075 void set_height_request_by_rows(int nRows
);
2078 class VCL_DLLPUBLIC MetricSpinButton final
2080 FieldUnit m_eSrcUnit
;
2081 std::unique_ptr
<weld::SpinButton
> m_xSpinButton
;
2082 Link
<MetricSpinButton
&, void> m_aValueChangedHdl
;
2084 DECL_LINK(spin_button_value_changed
, weld::SpinButton
&, void);
2085 DECL_LINK(spin_button_output
, weld::SpinButton
&, void);
2086 DECL_LINK(spin_button_input
, int* result
, bool);
2088 void signal_value_changed() { m_aValueChangedHdl
.Call(*this); }
2090 sal_Int64
ConvertValue(sal_Int64 nValue
, FieldUnit eInUnit
, FieldUnit eOutUnit
) const;
2091 OUString
format_number(sal_Int64 nValue
) const;
2092 void update_width_chars();
2095 MetricSpinButton(std::unique_ptr
<SpinButton
> pSpinButton
, FieldUnit eSrcUnit
)
2096 : m_eSrcUnit(eSrcUnit
)
2097 , m_xSpinButton(std::move(pSpinButton
))
2099 update_width_chars();
2100 m_xSpinButton
->connect_output(LINK(this, MetricSpinButton
, spin_button_output
));
2101 m_xSpinButton
->connect_input(LINK(this, MetricSpinButton
, spin_button_input
));
2102 m_xSpinButton
->connect_value_changed(
2103 LINK(this, MetricSpinButton
, spin_button_value_changed
));
2104 spin_button_output(*m_xSpinButton
);
2107 static OUString
MetricToString(FieldUnit rUnit
);
2109 FieldUnit
get_unit() const { return m_eSrcUnit
; }
2111 void set_unit(FieldUnit eUnit
);
2113 sal_Int64
convert_value_to(sal_Int64 nValue
, FieldUnit eValueUnit
) const
2115 return ConvertValue(nValue
, m_eSrcUnit
, eValueUnit
);
2118 sal_Int64
convert_value_from(sal_Int64 nValue
, FieldUnit eValueUnit
) const
2120 return ConvertValue(nValue
, eValueUnit
, m_eSrcUnit
);
2123 void set_value(sal_Int64 nValue
, FieldUnit eValueUnit
)
2125 m_xSpinButton
->set_value(convert_value_from(nValue
, eValueUnit
));
2128 sal_Int64
get_value(FieldUnit eDestUnit
) const
2130 return convert_value_to(m_xSpinButton
->get_value(), eDestUnit
);
2133 // typically you only need to call this if set_text (e.g. with "") was
2134 // previously called to display some arbitrary text instead of the
2135 // formatted value and now you want to show it as formatted again
2136 void reformat() { spin_button_output(*m_xSpinButton
); }
2138 void set_range(sal_Int64 min
, sal_Int64 max
, FieldUnit eValueUnit
)
2140 min
= convert_value_from(min
, eValueUnit
);
2141 max
= convert_value_from(max
, eValueUnit
);
2142 m_xSpinButton
->set_range(min
, max
);
2143 update_width_chars();
2146 void get_range(sal_Int64
& min
, sal_Int64
& max
, FieldUnit eDestUnit
) const
2148 m_xSpinButton
->get_range(min
, max
);
2149 min
= convert_value_to(min
, eDestUnit
);
2150 max
= convert_value_to(max
, eDestUnit
);
2153 void set_min(sal_Int64 min
, FieldUnit eValueUnit
)
2155 sal_Int64 dummy
, max
;
2156 get_range(dummy
, max
, eValueUnit
);
2157 set_range(min
, max
, eValueUnit
);
2160 void set_max(sal_Int64 max
, FieldUnit eValueUnit
)
2162 sal_Int64 min
, dummy
;
2163 get_range(min
, dummy
, eValueUnit
);
2164 set_range(min
, max
, eValueUnit
);
2167 sal_Int64
get_min(FieldUnit eValueUnit
) const
2169 sal_Int64 min
, dummy
;
2170 get_range(min
, dummy
, eValueUnit
);
2174 sal_Int64
get_max(FieldUnit eValueUnit
) const
2176 sal_Int64 dummy
, max
;
2177 get_range(dummy
, max
, eValueUnit
);
2181 void set_increments(sal_Int64 step
, sal_Int64 page
, FieldUnit eValueUnit
)
2183 step
= convert_value_from(step
, eValueUnit
);
2184 page
= convert_value_from(page
, eValueUnit
);
2185 m_xSpinButton
->set_increments(step
, page
);
2188 void get_increments(sal_Int64
& step
, sal_Int64
& page
, FieldUnit eDestUnit
) const
2190 m_xSpinButton
->get_increments(step
, page
);
2191 step
= convert_value_to(step
, eDestUnit
);
2192 page
= convert_value_to(page
, eDestUnit
);
2195 void connect_value_changed(const Link
<MetricSpinButton
&, void>& rLink
)
2197 m_aValueChangedHdl
= rLink
;
2200 sal_Int64
normalize(sal_Int64 nValue
) const { return m_xSpinButton
->normalize(nValue
); }
2201 sal_Int64
denormalize(sal_Int64 nValue
) const { return m_xSpinButton
->denormalize(nValue
); }
2202 void set_sensitive(bool sensitive
) { m_xSpinButton
->set_sensitive(sensitive
); }
2203 bool get_sensitive() const { return m_xSpinButton
->get_sensitive(); }
2204 bool get_visible() const { return m_xSpinButton
->get_visible(); }
2205 void grab_focus() { m_xSpinButton
->grab_focus(); }
2206 bool has_focus() const { return m_xSpinButton
->has_focus(); }
2207 void show() { m_xSpinButton
->show(); }
2208 void set_visible(bool bShow
) { m_xSpinButton
->set_visible(bShow
); }
2209 void hide() { m_xSpinButton
->hide(); }
2210 void set_digits(unsigned int digits
);
2211 void set_accessible_name(const OUString
& rName
) { m_xSpinButton
->set_accessible_name(rName
); }
2212 unsigned int get_digits() const { return m_xSpinButton
->get_digits(); }
2213 void save_value() { m_xSpinButton
->save_value(); }
2214 bool get_value_changed_from_saved() const
2216 return m_xSpinButton
->get_value_changed_from_saved();
2218 void set_text(const OUString
& rText
) { m_xSpinButton
->set_text(rText
); }
2219 OUString
get_text() const { return m_xSpinButton
->get_text(); }
2220 void set_size_request(int nWidth
, int nHeight
)
2222 m_xSpinButton
->set_size_request(nWidth
, nHeight
);
2224 Size
get_size_request() const { return m_xSpinButton
->get_size_request(); }
2225 Size
get_preferred_size() const { return m_xSpinButton
->get_preferred_size(); }
2226 void connect_focus_in(const Link
<Widget
&, void>& rLink
)
2228 m_xSpinButton
->connect_focus_in(rLink
);
2230 void connect_focus_out(const Link
<Widget
&, void>& rLink
)
2232 m_xSpinButton
->connect_focus_out(rLink
);
2234 OUString
get_buildable_name() const { return m_xSpinButton
->get_buildable_name(); }
2235 void set_help_id(const OUString
& rName
) { m_xSpinButton
->set_help_id(rName
); }
2236 void set_position(int nCursorPos
) { m_xSpinButton
->set_position(nCursorPos
); }
2237 // set the width of the underlying widget in characters, this setting is
2238 // invalidated when changing the units, range or digits, so to have effect
2239 // must come after changing those values
2240 void set_width_chars(int nChars
) { m_xSpinButton
->set_width_chars(nChars
); }
2241 int get_width_chars() const { return m_xSpinButton
->get_width_chars(); }
2242 weld::SpinButton
& get_widget() { return *m_xSpinButton
; }
2245 enum class LabelType
2250 Title
, // this is intended to be used against the background set by set_title_background
2253 class VCL_DLLPUBLIC Label
: virtual public Widget
2256 virtual void set_label(const OUString
& rText
) = 0;
2257 virtual OUString
get_label() const = 0;
2258 virtual void set_mnemonic_widget(Widget
* pTarget
) = 0;
2259 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
2260 virtual void set_font(const vcl::Font
& rFont
) = 0;
2261 virtual void set_label_type(LabelType eType
) = 0;
2263 If you want to set a warning or error state, see set_label_type
2266 virtual void set_font_color(const Color
& rColor
) = 0;
2269 class VCL_DLLPUBLIC TextView
: virtual public Widget
2271 friend class ::LOKTrigger
;
2274 OUString m_sSavedValue
;
2277 Link
<TextView
&, void> m_aChangeHdl
;
2278 Link
<TextView
&, void> m_aVChangeHdl
;
2279 Link
<TextView
&, void> m_aCursorPositionHdl
;
2281 void signal_changed() { m_aChangeHdl
.Call(*this); }
2282 void signal_cursor_position() { m_aCursorPositionHdl
.Call(*this); }
2283 void signal_vadjustment_changed() { m_aVChangeHdl
.Call(*this); }
2286 virtual void set_text(const OUString
& rText
) = 0;
2287 virtual OUString
get_text() const = 0;
2288 // if nStartPos or nEndPos is -1 the max available text pos will be used
2289 virtual void select_region(int nStartPos
, int nEndPos
) = 0;
2290 // returns true if the selection has nonzero length
2291 virtual bool get_selection_bounds(int& rStartPos
, int& rEndPos
) = 0;
2292 virtual void replace_selection(const OUString
& rText
) = 0;
2293 virtual void set_editable(bool bEditable
) = 0;
2294 virtual bool get_editable() const = 0;
2295 virtual void set_monospace(bool bMonospace
) = 0;
2296 // The maximum length of the entry. Use 0 for no maximum
2297 virtual void set_max_length(int nChars
) = 0;
2298 int get_height_rows(int nRows
) const
2300 //can improve this if needed
2301 return get_text_height() * nRows
;
2304 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
2305 virtual void set_font(const vcl::Font
& rFont
) = 0;
2308 Typically you want to avoid the temptation of customizing
2311 virtual void set_font_color(const Color
& rColor
) = 0;
2313 void save_value() { m_sSavedValue
= get_text(); }
2314 bool get_value_changed_from_saved() const { return m_sSavedValue
!= get_text(); }
2316 void connect_changed(const Link
<TextView
&, void>& rLink
) { m_aChangeHdl
= rLink
; }
2317 virtual void connect_cursor_position(const Link
<TextView
&, void>& rLink
)
2319 m_aCursorPositionHdl
= rLink
;
2322 // returns true if pressing up would move the cursor
2323 // doesn't matter if that move is to a previous line or to the start of the
2324 // current line just so long as the cursor would move
2325 virtual bool can_move_cursor_with_up() const = 0;
2327 // returns true if pressing down would move the cursor
2328 // doesn't matter if that move is to a next line or to the end of the
2329 // current line just so long as the cursor would move
2330 virtual bool can_move_cursor_with_down() const = 0;
2332 virtual void cut_clipboard() = 0;
2333 virtual void copy_clipboard() = 0;
2334 virtual void paste_clipboard() = 0;
2336 virtual void set_alignment(TxtAlign eXAlign
) = 0;
2338 virtual int vadjustment_get_value() const = 0;
2339 virtual int vadjustment_get_upper() const = 0;
2340 virtual int vadjustment_get_lower() const = 0;
2341 virtual int vadjustment_get_page_size() const = 0;
2342 virtual void vadjustment_set_value(int value
) = 0;
2343 void connect_vadjustment_changed(const Link
<TextView
&, void>& rLink
) { m_aVChangeHdl
= rLink
; }
2346 class VCL_DLLPUBLIC Expander
: virtual public Widget
2348 Link
<Expander
&, void> m_aExpandedHdl
;
2351 void signal_expanded() { m_aExpandedHdl
.Call(*this); }
2354 virtual void set_label(const OUString
& rText
) = 0;
2355 virtual OUString
get_label() const = 0;
2356 virtual bool get_expanded() const = 0;
2357 virtual void set_expanded(bool bExpand
) = 0;
2359 void connect_expanded(const Link
<Expander
&, void>& rLink
) { m_aExpandedHdl
= rLink
; }
2362 class VCL_DLLPUBLIC DrawingArea
: virtual public Widget
2365 typedef std::pair
<vcl::RenderContext
&, const tools::Rectangle
&> draw_args
;
2368 Link
<draw_args
, void> m_aDrawHdl
;
2369 Link
<const CommandEvent
&, bool> m_aCommandHdl
;
2370 Link
<Widget
&, tools::Rectangle
> m_aGetFocusRectHdl
;
2371 Link
<tools::Rectangle
&, OUString
> m_aQueryTooltipHdl
;
2372 // if handler returns true, drag is disallowed
2373 Link
<DrawingArea
&, bool> m_aDragBeginHdl
;
2374 // return position of cursor, fill OUString& with surrounding text
2375 Link
<OUString
&, int> m_aGetSurroundingHdl
;
2376 // attempt to delete the range, return true if successful
2377 Link
<const Selection
&, bool> m_aDeleteSurroundingHdl
;
2379 OUString
signal_query_tooltip(tools::Rectangle
& rHelpArea
)
2381 return m_aQueryTooltipHdl
.Call(rHelpArea
);
2384 int signal_im_context_get_surrounding(OUString
& rSurroundingText
)
2386 if (!m_aGetSurroundingHdl
.IsSet())
2388 return m_aGetSurroundingHdl
.Call(rSurroundingText
);
2391 bool signal_im_context_delete_surrounding(const Selection
& rRange
)
2393 return m_aDeleteSurroundingHdl
.Call(rRange
);
2397 void connect_draw(const Link
<draw_args
, void>& rLink
) { m_aDrawHdl
= rLink
; }
2398 void connect_command(const Link
<const CommandEvent
&, bool>& rLink
) { m_aCommandHdl
= rLink
; }
2399 void connect_focus_rect(const Link
<Widget
&, tools::Rectangle
>& rLink
)
2401 m_aGetFocusRectHdl
= rLink
;
2403 void connect_query_tooltip(const Link
<tools::Rectangle
&, OUString
>& rLink
)
2405 m_aQueryTooltipHdl
= rLink
;
2407 void connect_drag_begin(const Link
<DrawingArea
&, bool>& rLink
) { m_aDragBeginHdl
= rLink
; }
2408 void connect_im_context_get_surrounding(const Link
<OUString
&, int>& rLink
)
2410 m_aGetSurroundingHdl
= rLink
;
2412 void connect_im_context_delete_surrounding(const Link
<const Selection
&, bool>& rLink
)
2414 m_aDeleteSurroundingHdl
= rLink
;
2416 virtual void queue_draw() = 0;
2417 virtual void queue_draw_area(int x
, int y
, int width
, int height
) = 0;
2419 virtual void enable_drag_source(rtl::Reference
<TransferDataContainer
>& rTransferable
,
2420 sal_uInt8 eDNDConstants
)
2423 virtual void set_cursor(PointerStyle ePointerStyle
) = 0;
2425 virtual Point
get_pointer_position() const = 0;
2427 virtual void set_input_context(const InputContext
& rInputContext
) = 0;
2428 virtual void im_context_set_cursor_location(const tools::Rectangle
& rCursorRect
,
2429 int nExtTextInputWidth
)
2432 // use return here just to generate matching VirtualDevices
2433 virtual OutputDevice
& get_ref_device() = 0;
2435 virtual a11yref
get_accessible_parent() = 0;
2436 virtual a11yrelationset
get_accessible_relation_set() = 0;
2437 virtual AbsoluteScreenPixelPoint
get_accessible_location_on_screen() = 0;
2440 friend class ::LOKTrigger
;
2442 virtual void click(const Point
&) = 0;
2444 virtual void dblclick(const Point
&){};
2446 virtual void mouse_up(const Point
&){};
2448 virtual void mouse_down(const Point
&){};
2450 virtual void mouse_move(const Point
&){};
2453 enum class Placement
2459 class VCL_DLLPUBLIC Menu
2461 friend class ::LOKTrigger
;
2463 Link
<const OUString
&, void> m_aActivateHdl
;
2466 void signal_activate(const OUString
& rIdent
) { m_aActivateHdl
.Call(rIdent
); }
2469 virtual OUString
popup_at_rect(weld::Widget
* pParent
, const tools::Rectangle
& rRect
,
2470 Placement ePlace
= Placement::Under
)
2473 void connect_activate(const Link
<const OUString
&, void>& rLink
) { m_aActivateHdl
= rLink
; }
2475 virtual void set_sensitive(const OUString
& rIdent
, bool bSensitive
) = 0;
2476 virtual bool get_sensitive(const OUString
& rIdent
) const = 0;
2477 virtual void set_label(const OUString
& rIdent
, const OUString
& rLabel
) = 0;
2478 virtual OUString
get_label(const OUString
& rIdent
) const = 0;
2479 virtual void set_active(const OUString
& rIdent
, bool bActive
) = 0;
2480 virtual bool get_active(const OUString
& rIdent
) const = 0;
2481 virtual void set_visible(const OUString
& rIdent
, bool bVisible
) = 0;
2483 virtual void insert(int pos
, const OUString
& rId
, const OUString
& rStr
,
2484 const OUString
* pIconName
, VirtualDevice
* pImageSurface
,
2485 const css::uno::Reference
<css::graphic::XGraphic
>& rImage
,
2486 TriState eCheckRadioFalse
)
2489 virtual void set_item_help_id(const OUString
& rIdent
, const OUString
& rHelpId
) = 0;
2490 virtual void remove(const OUString
& rId
) = 0;
2492 virtual void clear() = 0;
2494 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
2495 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
2497 void append(const OUString
& rId
, const OUString
& rStr
)
2499 insert(-1, rId
, rStr
, nullptr, nullptr, nullptr, TRISTATE_INDET
);
2501 void append_check(const OUString
& rId
, const OUString
& rStr
)
2503 insert(-1, rId
, rStr
, nullptr, nullptr, nullptr, TRISTATE_TRUE
);
2505 void append_radio(const OUString
& rId
, const OUString
& rStr
)
2507 insert(-1, rId
, rStr
, nullptr, nullptr, nullptr, TRISTATE_FALSE
);
2509 void append(const OUString
& rId
, const OUString
& rStr
, const OUString
& rImage
)
2511 insert(-1, rId
, rStr
, &rImage
, nullptr, nullptr, TRISTATE_INDET
);
2513 void append(const OUString
& rId
, const OUString
& rStr
, VirtualDevice
& rImage
)
2515 insert(-1, rId
, rStr
, nullptr, &rImage
, nullptr, TRISTATE_INDET
);
2518 // return the number of toplevel nodes
2519 virtual int n_children() const = 0;
2521 virtual OUString
get_id(int pos
) const = 0;
2526 class VCL_DLLPUBLIC Popover
: virtual public Container
2528 friend class ::LOKTrigger
;
2531 Link
<weld::Popover
&, void> m_aCloseHdl
;
2534 void signal_closed() { m_aCloseHdl
.Call(*this); }
2537 virtual void popup_at_rect(weld::Widget
* pParent
, const tools::Rectangle
& rRect
,
2538 Placement ePlace
= Placement::Under
)
2540 virtual void popdown() = 0;
2542 virtual void resize_to_request() = 0;
2544 void connect_closed(const Link
<weld::Popover
&, void>& rLink
) { m_aCloseHdl
= rLink
; }
2547 class VCL_DLLPUBLIC Toolbar
: virtual public Widget
2549 Link
<const OUString
&, void> m_aClickHdl
;
2550 Link
<const OUString
&, void> m_aToggleMenuHdl
;
2553 friend class ::LOKTrigger
;
2555 void signal_clicked(const OUString
& rIdent
) { m_aClickHdl
.Call(rIdent
); }
2556 void signal_toggle_menu(const OUString
& rIdent
) { m_aToggleMenuHdl
.Call(rIdent
); }
2559 virtual void set_item_sensitive(const OUString
& rIdent
, bool bSensitive
) = 0;
2560 virtual bool get_item_sensitive(const OUString
& rIdent
) const = 0;
2561 virtual void set_item_active(const OUString
& rIdent
, bool bActive
) = 0;
2562 virtual bool get_item_active(const OUString
& rIdent
) const = 0;
2563 virtual void set_menu_item_active(const OUString
& rIdent
, bool bActive
) = 0;
2564 virtual bool get_menu_item_active(const OUString
& rIdent
) const = 0;
2565 virtual void set_item_menu(const OUString
& rIdent
, weld::Menu
* pMenu
) = 0;
2566 virtual void set_item_popover(const OUString
& rIdent
, weld::Widget
* pPopover
) = 0;
2567 virtual void set_item_visible(const OUString
& rIdent
, bool bVisible
) = 0;
2568 virtual void set_item_help_id(const OUString
& rIdent
, const OUString
& rHelpId
) = 0;
2569 virtual bool get_item_visible(const OUString
& rIdent
) const = 0;
2570 virtual void set_item_label(const OUString
& rIdent
, const OUString
& rLabel
) = 0;
2571 virtual OUString
get_item_label(const OUString
& rIdent
) const = 0;
2572 virtual void set_item_tooltip_text(const OUString
& rIdent
, const OUString
& rTip
) = 0;
2573 virtual OUString
get_item_tooltip_text(const OUString
& rIdent
) const = 0;
2574 virtual void set_item_icon_name(const OUString
& rIdent
, const OUString
& rIconName
) = 0;
2575 virtual void set_item_image_mirrored(const OUString
& rIdent
, bool bMirrored
) = 0;
2576 virtual void set_item_image(const OUString
& rIdent
,
2577 const css::uno::Reference
<css::graphic::XGraphic
>& rIcon
)
2579 virtual void set_item_image(const OUString
& rIdent
, VirtualDevice
* pDevice
) = 0;
2581 virtual void insert_item(int pos
, const OUString
& rId
) = 0;
2582 virtual void insert_separator(int pos
, const OUString
& rId
) = 0;
2583 void append_separator(const OUString
& rId
) { insert_separator(-1, rId
); }
2585 virtual int get_n_items() const = 0;
2586 virtual OUString
get_item_ident(int nIndex
) const = 0;
2587 virtual void set_item_ident(int nIndex
, const OUString
& rIdent
) = 0;
2588 virtual void set_item_label(int nIndex
, const OUString
& rLabel
) = 0;
2589 virtual void set_item_image(int nIndex
,
2590 const css::uno::Reference
<css::graphic::XGraphic
>& rIcon
)
2592 virtual void set_item_tooltip_text(int nIndex
, const OUString
& rTip
) = 0;
2593 virtual void set_item_accessible_name(int nIndex
, const OUString
& rName
) = 0;
2594 virtual void set_item_accessible_name(const OUString
& rIdent
, const OUString
& rName
) = 0;
2596 virtual vcl::ImageType
get_icon_size() const = 0;
2597 virtual void set_icon_size(vcl::ImageType eType
) = 0;
2599 // return what modifiers are held
2600 virtual sal_uInt16
get_modifier_state() const = 0;
2602 // This function returns the position a new item should be inserted if dnd
2603 // is dropped at rPoint
2604 virtual int get_drop_index(const Point
& rPoint
) const = 0;
2606 void connect_clicked(const Link
<const OUString
&, void>& rLink
) { m_aClickHdl
= rLink
; }
2607 void connect_menu_toggled(const Link
<const OUString
&, void>& rLink
)
2609 m_aToggleMenuHdl
= rLink
;
2613 class VCL_DLLPUBLIC Scrollbar
: virtual public Widget
2615 Link
<Scrollbar
&, void> m_aChangeHdl
;
2618 void signal_adjustment_changed() { m_aChangeHdl
.Call(*this); }
2621 virtual void adjustment_configure(int value
, int lower
, int upper
, int step_increment
,
2622 int page_increment
, int page_size
)
2624 virtual int adjustment_get_value() const = 0;
2625 virtual void adjustment_set_value(int value
) = 0;
2626 virtual int adjustment_get_upper() const = 0;
2627 virtual void adjustment_set_upper(int upper
) = 0;
2628 virtual int adjustment_get_page_size() const = 0;
2629 virtual void adjustment_set_page_size(int size
) = 0;
2630 virtual int adjustment_get_page_increment() const = 0;
2631 virtual void adjustment_set_page_increment(int size
) = 0;
2632 virtual int adjustment_get_step_increment() const = 0;
2633 virtual void adjustment_set_step_increment(int size
) = 0;
2634 virtual int adjustment_get_lower() const = 0;
2635 virtual void adjustment_set_lower(int upper
) = 0;
2637 virtual int get_scroll_thickness() const = 0;
2638 virtual void set_scroll_thickness(int nThickness
) = 0;
2639 virtual void set_scroll_swap_arrows(bool bSwap
) = 0;
2641 virtual ScrollType
get_scroll_type() const = 0;
2643 void connect_adjustment_changed(const Link
<Scrollbar
&, void>& rLink
) { m_aChangeHdl
= rLink
; }
2646 class VCL_DLLPUBLIC SizeGroup
2649 virtual void add_widget(weld::Widget
* pWidget
) = 0;
2650 // the default mode is VclSizeGroupMode::Horizontal
2651 virtual void set_mode(VclSizeGroupMode eMode
) = 0;
2652 virtual ~SizeGroup() {}
2655 class VCL_DLLPUBLIC Builder
2658 virtual std::unique_ptr
<MessageDialog
> weld_message_dialog(const OUString
& id
) = 0;
2659 virtual std::unique_ptr
<Dialog
> weld_dialog(const OUString
& id
) = 0;
2660 virtual std::unique_ptr
<Assistant
> weld_assistant(const OUString
& id
) = 0;
2661 virtual std::unique_ptr
<Widget
> weld_widget(const OUString
& id
) = 0;
2662 virtual std::unique_ptr
<Container
> weld_container(const OUString
& id
) = 0;
2663 virtual std::unique_ptr
<Box
> weld_box(const OUString
& id
) = 0;
2664 virtual std::unique_ptr
<Grid
> weld_grid(const OUString
& id
) = 0;
2665 virtual std::unique_ptr
<Paned
> weld_paned(const OUString
& id
) = 0;
2666 virtual std::unique_ptr
<Button
> weld_button(const OUString
& id
) = 0;
2667 virtual std::unique_ptr
<MenuButton
> weld_menu_button(const OUString
& id
) = 0;
2668 virtual std::unique_ptr
<MenuToggleButton
> weld_menu_toggle_button(const OUString
& id
) = 0;
2669 virtual std::unique_ptr
<Frame
> weld_frame(const OUString
& id
) = 0;
2670 /* bUserManagedScrolling of true means that the automatic scrolling of the window is disabled
2671 and the owner must specifically listen to adjustment changes and react appropriately to them.
2673 virtual std::unique_ptr
<ScrolledWindow
> weld_scrolled_window(const OUString
& id
,
2674 bool bUserManagedScrolling
= false)
2676 virtual std::unique_ptr
<Notebook
> weld_notebook(const OUString
& id
) = 0;
2677 virtual std::unique_ptr
<ToggleButton
> weld_toggle_button(const OUString
& id
) = 0;
2678 virtual std::unique_ptr
<RadioButton
> weld_radio_button(const OUString
& id
) = 0;
2679 virtual std::unique_ptr
<CheckButton
> weld_check_button(const OUString
& id
) = 0;
2680 virtual std::unique_ptr
<LinkButton
> weld_link_button(const OUString
& id
) = 0;
2681 virtual std::unique_ptr
<SpinButton
> weld_spin_button(const OUString
& id
) = 0;
2682 virtual std::unique_ptr
<MetricSpinButton
> weld_metric_spin_button(const OUString
& id
,
2685 virtual std::unique_ptr
<FormattedSpinButton
> weld_formatted_spin_button(const OUString
& id
) = 0;
2686 virtual std::unique_ptr
<ComboBox
> weld_combo_box(const OUString
& id
) = 0;
2687 virtual std::unique_ptr
<TreeView
> weld_tree_view(const OUString
& id
) = 0;
2688 virtual std::unique_ptr
<IconView
> weld_icon_view(const OUString
& id
) = 0;
2689 virtual std::unique_ptr
<Label
> weld_label(const OUString
& id
) = 0;
2690 virtual std::unique_ptr
<TextView
> weld_text_view(const OUString
& id
) = 0;
2691 virtual std::unique_ptr
<Expander
> weld_expander(const OUString
& id
) = 0;
2692 virtual std::unique_ptr
<Entry
> weld_entry(const OUString
& id
) = 0;
2693 virtual std::unique_ptr
<Scale
> weld_scale(const OUString
& id
) = 0;
2694 virtual std::unique_ptr
<ProgressBar
> weld_progress_bar(const OUString
& id
) = 0;
2695 virtual std::unique_ptr
<LevelBar
> weld_level_bar(const OUString
& id
) = 0;
2696 virtual std::unique_ptr
<Spinner
> weld_spinner(const OUString
& id
) = 0;
2697 virtual std::unique_ptr
<Image
> weld_image(const OUString
& id
) = 0;
2698 virtual std::unique_ptr
<Calendar
> weld_calendar(const OUString
& id
) = 0;
2699 virtual std::unique_ptr
<DrawingArea
>
2700 weld_drawing_area(const OUString
& id
, const a11yref
& rA11yImpl
= nullptr,
2701 FactoryFunction pUITestFactoryFunction
= nullptr, void* pUserData
= nullptr)
2703 virtual std::unique_ptr
<EntryTreeView
> weld_entry_tree_view(const OUString
& containerid
,
2704 const OUString
& entryid
,
2705 const OUString
& treeviewid
)
2707 virtual std::unique_ptr
<Menu
> weld_menu(const OUString
& id
) = 0;
2708 virtual std::unique_ptr
<Popover
> weld_popover(const OUString
& id
) = 0;
2709 virtual std::unique_ptr
<Toolbar
> weld_toolbar(const OUString
& id
) = 0;
2710 virtual std::unique_ptr
<Scrollbar
> weld_scrollbar(const OUString
& id
) = 0;
2711 virtual std::unique_ptr
<SizeGroup
> create_size_group() = 0;
2712 /* return a Dialog suitable to take a screenshot of containing the contents of the .ui file.
2714 If the toplevel element is a dialog, that will be returned
2715 If the toplevel is not a dialog, a dialog will be created and the contents of the .ui
2718 virtual std::unique_ptr
<Window
> create_screenshot_window() = 0;
2719 virtual ~Builder() {}
2722 class VCL_DLLPUBLIC DialogController
: public std::enable_shared_from_this
<DialogController
>
2725 virtual Dialog
* getDialog() = 0;
2726 const Dialog
* getConstDialog() const
2728 return const_cast<DialogController
*>(this)->getDialog();
2730 virtual short run() { return getDialog()->run(); }
2731 static bool runAsync(const std::shared_ptr
<DialogController
>& rController
,
2732 const std::function
<void(sal_Int32
)>&);
2733 void set_title(const OUString
& rTitle
) { getDialog()->set_title(rTitle
); }
2734 OUString
get_title() const { return getConstDialog()->get_title(); }
2735 void set_help_id(const OUString
& rHelpId
) { getDialog()->set_help_id(rHelpId
); }
2736 OUString
get_help_id() const { return getConstDialog()->get_help_id(); }
2737 void response(int nResponse
) { getDialog()->response(nResponse
); }
2738 virtual ~DialogController() COVERITY_NOEXCEPT_FALSE
;
2741 class VCL_DLLPUBLIC GenericDialogController
: public DialogController
2744 std::unique_ptr
<weld::Builder
> m_xBuilder
;
2745 std::shared_ptr
<weld::Dialog
> m_xDialog
;
2748 GenericDialogController(weld::Widget
* pParent
, const OUString
& rUIFile
,
2749 const OUString
& rDialogId
, bool bMobile
= false);
2750 virtual Dialog
* getDialog() override
;
2751 virtual ~GenericDialogController() COVERITY_NOEXCEPT_FALSE override
;
2754 class VCL_DLLPUBLIC MessageDialogController
: public DialogController
2757 std::unique_ptr
<weld::Builder
> m_xBuilder
;
2758 std::unique_ptr
<weld::MessageDialog
> m_xDialog
;
2759 std::unique_ptr
<weld::Container
> m_xContentArea
;
2760 std::unique_ptr
<weld::Widget
> m_xRelocate
;
2761 std::unique_ptr
<weld::Container
> m_xOrigParent
;
2764 /* @param rRelocateId - optional argument of the name of a widget in the .ui file
2765 which should be relocated into the content area of the dialog.
2767 e.g. a checkbox for a "Never show this again" option.
2769 This results in the named widget relocating to the same container
2770 as the messages. This enables aligning the extra widget with the
2771 message labels in the content area container which doesn't
2772 explicitly exist in the ui description, but is only implied.
2774 MessageDialogController(weld::Widget
* pParent
, const OUString
& rUIFile
,
2775 const OUString
& rDialogId
, const OUString
& rRelocateId
= {});
2776 virtual Dialog
* getDialog() override
;
2777 virtual ~MessageDialogController() override
;
2778 void set_primary_text(const OUString
& rText
) { m_xDialog
->set_primary_text(rText
); }
2779 OUString
get_primary_text() const { return m_xDialog
->get_primary_text(); }
2780 void set_secondary_text(const OUString
& rText
) { m_xDialog
->set_secondary_text(rText
); }
2781 OUString
get_secondary_text() const { return m_xDialog
->get_secondary_text(); }
2782 void set_default_response(int nResponse
) { m_xDialog
->set_default_response(nResponse
); }
2785 class VCL_DLLPUBLIC AssistantController
: public DialogController
2788 std::unique_ptr
<weld::Builder
> m_xBuilder
;
2789 std::unique_ptr
<weld::Assistant
> m_xAssistant
;
2792 SAL_DLLPRIVATE
AssistantController(weld::Widget
* pParent
, const OUString
& rUIFile
,
2793 const OUString
& rDialogId
);
2794 virtual Dialog
* getDialog() override
;
2795 SAL_DLLPRIVATE
virtual ~AssistantController() override
;
2800 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */