Implement weld::IconView::[gs]et_item_width
[LibreOffice.git] / include / vcl / weld.hxx
blobdba513870818ad5d7fa54770766df2b6ce2394ff
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
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>
21 #include <vcl/vclenum.hxx>
22 #include <vcl/font.hxx>
23 #include <vcl/vclptr.hxx>
24 #include <vcl/uitest/factory.hxx>
26 #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
27 #include <com/sun/star/accessibility/XAccessible.hpp>
29 #include <assert.h>
30 #include <memory>
31 #include <vector>
33 namespace com::sun::star::awt
35 class XWindow;
37 namespace com::sun::star::datatransfer::clipboard
39 class XClipboard;
41 namespace com::sun::star::datatransfer::dnd
43 class XDropTarget;
45 namespace com::sun::star::graphic
47 class XGraphic;
49 typedef css::uno::Reference<css::accessibility::XAccessible> a11yref;
50 typedef css::uno::Reference<css::accessibility::XAccessibleRelationSet> a11yrelationset;
51 enum class PointerStyle;
52 class CommandEvent;
53 class Formatter;
54 class InputContext;
55 class KeyEvent;
56 class MouseEvent;
57 class SvNumberFormatter;
58 class TransferDataContainer;
59 class OutputDevice;
60 class VirtualDevice;
61 struct SystemEnvData;
63 namespace vcl
65 class ILibreOfficeKitNotifier;
66 typedef OutputDevice RenderContext;
68 namespace tools
70 class JsonWriter;
73 class LOKTrigger;
75 namespace weld
77 class Container;
78 class DialogController;
80 class VCL_DLLPUBLIC Widget
82 friend class ::LOKTrigger;
84 protected:
85 Link<Widget&, void> m_aFocusInHdl;
86 Link<Widget&, void> m_aFocusOutHdl;
87 Link<Widget&, bool> m_aMnemonicActivateHdl;
88 Link<const Size&, void> m_aSizeAllocateHdl;
89 Link<const KeyEvent&, bool> m_aKeyPressHdl;
90 Link<const KeyEvent&, bool> m_aKeyReleaseHdl;
91 Link<const MouseEvent&, bool> m_aMousePressHdl;
92 Link<const MouseEvent&, bool> m_aMouseMotionHdl;
93 Link<const MouseEvent&, bool> m_aMouseReleaseHdl;
95 public:
96 virtual void set_sensitive(bool sensitive) = 0;
97 virtual bool get_sensitive() const = 0;
99 /* visibility */
101 virtual void show() = 0;
102 virtual void hide() = 0;
104 // This function simply calls show() or hide() but is convenient when the
105 // visibility depends on some condition
106 virtual void set_visible(bool visible)
108 if (visible)
109 show();
110 else
111 hide();
114 // return if this widget's visibility is true
115 virtual bool get_visible() const = 0;
117 // return if this widget's visibility and that of all its parents is true
118 virtual bool is_visible() const = 0;
120 /* focus */
122 // sets if this widget can own the keyboard focus
123 virtual void set_can_focus(bool bCanFocus) = 0;
125 // causes this widget to have the keyboard focus
126 virtual void grab_focus() = 0;
128 // returns if this widget has the keyboard focus
129 virtual bool has_focus() const = 0;
131 // if the widget that has focus is a child, which includes toplevel popup
132 // children, of this widget. So an Entry with an active popup (or dialog)
133 // has has_child_focus of true, but has_focus of false, while its popup is
134 // shown
135 virtual bool has_child_focus() const = 0;
137 // return if this widget has the keyboard focus within the active window
138 // TODO: review if this has any practical difference from has_focus()
139 virtual bool is_active() const = 0;
141 /* size */
142 virtual void set_size_request(int nWidth, int nHeight) = 0;
143 virtual Size get_size_request() const = 0;
144 virtual Size get_preferred_size() const = 0;
146 /* measure */
147 virtual float get_approximate_digit_width() const = 0;
148 virtual int get_text_height() const = 0;
149 virtual Size get_pixel_size(const OUString& rText) const = 0;
151 // The name of the widget in the GtkBuilder UI definition used to construct it.
152 virtual OString get_buildable_name() const = 0;
154 Typically there is no need to change the buildable name at runtime, changing
155 the id in .ui file itself is preferred.
157 But for ui-testing purposes it can sometimes be useful to rename
158 different widgets, that were loaded from the same .ui, to unique names
159 in order to distinguish between them
161 virtual void set_buildable_name(const OString& rName) = 0;
164 The help id of the widget used to identify help for this widget.
166 By default the help id of a widget is a path-like sequence of (load-time)
167 buildable-names from the widgets UI definition ancestor to this widget,
168 e.g. grandparent/parent/widget.
170 The default can be overwritten with set_help_id
172 virtual OString get_help_id() const = 0;
173 virtual void set_help_id(const OString& rName) = 0;
175 virtual void set_grid_left_attach(int nAttach) = 0;
176 virtual int get_grid_left_attach() const = 0;
177 virtual void set_grid_width(int nCols) = 0;
178 virtual void set_grid_top_attach(int nAttach) = 0;
179 virtual int get_grid_top_attach() const = 0;
181 virtual void set_hexpand(bool bExpand) = 0;
182 virtual bool get_hexpand() const = 0;
183 virtual void set_vexpand(bool bExpand) = 0;
184 virtual bool get_vexpand() const = 0;
186 virtual void set_margin_top(int nMargin) = 0;
187 virtual void set_margin_bottom(int nMargin) = 0;
188 virtual void set_margin_start(int nMargin) = 0;
189 virtual void set_margin_end(int nMargin) = 0;
191 virtual int get_margin_top() const = 0;
192 virtual int get_margin_bottom() const = 0;
193 virtual int get_margin_start() const = 0;
194 virtual int get_margin_end() const = 0;
197 * Report the extents of this widget relative to the rRelative target widget.
199 * To succeed, both widgets must be realized, and must share a common toplevel.
201 * returns false if the relative extents could not be determined, e.g. if
202 * either widget was not realized, or there was no common ancestor.
203 * Otherwise true.
205 virtual bool get_extents_relative_to(const Widget& rRelative, int& x, int& y, int& width,
206 int& height) const = 0;
208 virtual void set_accessible_name(const OUString& rName) = 0;
209 virtual void set_accessible_description(const OUString& rDescription) = 0;
210 virtual OUString get_accessible_name() const = 0;
212 virtual OUString get_accessible_description() const = 0;
214 // After this call this widget is only accessibility labelled by pLabel and
215 // pLabel only accessibility labels this widget
216 virtual void set_accessible_relation_labeled_by(weld::Widget* pLabel) = 0;
218 virtual void set_tooltip_text(const OUString& rTip) = 0;
219 virtual OUString get_tooltip_text() const = 0;
221 virtual void connect_focus_in(const Link<Widget&, void>& rLink)
223 assert(!m_aFocusInHdl.IsSet() || !rLink.IsSet());
224 m_aFocusInHdl = rLink;
227 virtual void connect_focus_out(const Link<Widget&, void>& rLink)
229 assert(!m_aFocusOutHdl.IsSet() || !rLink.IsSet());
230 m_aFocusOutHdl = rLink;
233 // rLink is called when the mnemonic for the Widget is called.
234 // If rLink returns true the Widget will not automatically gain
235 // focus as normally occurs
236 virtual void connect_mnemonic_activate(const Link<Widget&, bool>& rLink)
238 assert(!m_aMnemonicActivateHdl.IsSet() || !rLink.IsSet());
239 m_aMnemonicActivateHdl = rLink;
242 virtual void connect_size_allocate(const Link<const Size&, void>& rLink)
244 assert(!m_aSizeAllocateHdl.IsSet() || !rLink.IsSet());
245 m_aSizeAllocateHdl = rLink;
248 virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink)
250 assert(!m_aKeyPressHdl.IsSet() || !rLink.IsSet());
251 m_aKeyPressHdl = rLink;
254 virtual void connect_key_release(const Link<const KeyEvent&, bool>& rLink)
256 assert(!m_aKeyReleaseHdl.IsSet() || !rLink.IsSet());
257 m_aKeyReleaseHdl = rLink;
260 virtual void connect_mouse_press(const Link<const MouseEvent&, bool>& rLink)
262 assert(!m_aMousePressHdl.IsSet() || !rLink.IsSet());
263 m_aMousePressHdl = rLink;
266 virtual void connect_mouse_move(const Link<const MouseEvent&, bool>& rLink)
268 assert(!m_aMouseMotionHdl.IsSet() || !rLink.IsSet());
269 m_aMouseMotionHdl = rLink;
272 virtual void connect_mouse_release(const Link<const MouseEvent&, bool>& rLink)
274 assert(!m_aMouseReleaseHdl.IsSet() || !rLink.IsSet());
275 m_aMouseReleaseHdl = rLink;
278 virtual void grab_add() = 0;
279 virtual bool has_grab() const = 0;
280 virtual void grab_remove() = 0;
282 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
283 virtual vcl::Font get_font() = 0;
285 //true for rtl, false otherwise
286 virtual bool get_direction() const = 0;
287 virtual void set_direction(bool bRTL) = 0;
289 /* Increases the freeze count on widget.
291 If the freeze count is non-zero, emission of the widget's notifications
292 is stopped. The notifications are queued until the freeze count is
293 decreased to zero. Duplicate notifications may be squashed together.
295 virtual void freeze() = 0;
297 /* Reverts the effect of a previous call to freeze.
299 The freeze count is decreased on the widget and when it reaches zero,
300 queued notifications are emitted.
302 virtual void thaw() = 0;
304 /* push/pop busy mouse cursor state
306 bBusy of true to push a busy state onto the stack and false
307 to pop it off, calls to this should balance.
309 see weld::WaitObject */
310 virtual void set_busy_cursor(bool bBusy) = 0;
312 virtual void queue_resize() = 0;
314 virtual std::unique_ptr<Container> weld_parent() const = 0;
316 //iterate upwards through the hierarchy starting at this widgets parent,
317 //calling func with their helpid until func returns true or we run out of
318 //parents
319 virtual void help_hierarchy_foreach(const std::function<bool(const OString&)>& func) = 0;
321 virtual OUString strip_mnemonic(const OUString& rLabel) const = 0;
323 virtual VclPtr<VirtualDevice> create_virtual_device() const = 0;
325 //do something transient to attract the attention of the user to the widget
326 virtual void call_attention_to() = 0;
328 //make this widget look like a page in a notebook
329 virtual void set_stack_background() = 0;
330 //make this widget look like it has a highlighted background
331 virtual void set_highlight_background() = 0;
332 //make this widget suitable as parent for a title
333 virtual void set_title_background() = 0;
334 //make this widget suitable for use in a toolbar
335 virtual void set_toolbar_background() = 0;
336 //trying to use a custom color for a background is generally a bad idea. If your need
337 //fits one of the above categories then that's a somewhat better choice
338 virtual void set_background(const Color& rBackColor) = 0;
340 virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() = 0;
341 virtual css::uno::Reference<css::datatransfer::clipboard::XClipboard> get_clipboard() const = 0;
343 virtual void connect_get_property_tree(const Link<tools::JsonWriter&, void>& rLink) = 0;
344 virtual void get_property_tree(tools::JsonWriter& rJsonWriter) = 0;
346 // render the widget to an output device
347 virtual void draw(OutputDevice& rOutput, const Point& rPos, const Size& rSizePixel) = 0;
349 virtual ~Widget() {}
352 class VCL_DLLPUBLIC Container : virtual public Widget
354 protected:
355 Link<Container&, void> m_aContainerFocusChangedHdl;
357 void signal_container_focus_changed() { m_aContainerFocusChangedHdl.Call(*this); }
359 public:
360 // remove and add in one go
361 virtual void move(weld::Widget* pWidget, weld::Container* pNewParent) = 0;
362 // create an XWindow as a child of this container. The XWindow is
363 // suitable to contain css::awt::XControl items
364 virtual css::uno::Reference<css::awt::XWindow> CreateChildFrame() = 0;
365 // rLink is called when the focus transitions from a widget outside the container
366 // to a widget inside the container or vice versa
367 virtual void connect_container_focus_changed(const Link<Container&, void>& rLink)
369 m_aContainerFocusChangedHdl = rLink;
371 // causes a child of the container to have the keyboard focus
372 virtual void child_grab_focus() = 0;
375 class VCL_DLLPUBLIC Box : virtual public Container
377 public:
378 // Moves child to a new position in the list of children
379 virtual void reorder_child(weld::Widget* pWidget, int position) = 0;
380 // Sort ok/cancel etc buttons in platform order
381 virtual void sort_native_button_order() = 0;
384 class VCL_DLLPUBLIC Paned : virtual public Container
386 public:
387 // set pixel position of divider
388 virtual void set_position(int nPos) = 0;
389 // get pixel position of divider
390 virtual int get_position() const = 0;
393 class VCL_DLLPUBLIC ScrolledWindow : virtual public Container
395 protected:
396 Link<ScrolledWindow&, void> m_aVChangeHdl;
397 Link<ScrolledWindow&, void> m_aHChangeHdl;
399 void signal_vadjustment_changed() { m_aVChangeHdl.Call(*this); }
400 void signal_hadjustment_changed() { m_aHChangeHdl.Call(*this); }
402 public:
403 virtual void hadjustment_configure(int value, int lower, int upper, int step_increment,
404 int page_increment, int page_size)
405 = 0;
406 virtual int hadjustment_get_value() const = 0;
407 virtual void hadjustment_set_value(int value) = 0;
408 virtual int hadjustment_get_upper() const = 0;
409 virtual void hadjustment_set_upper(int upper) = 0;
410 virtual int hadjustment_get_page_size() const = 0;
411 virtual void hadjustment_set_page_size(int size) = 0;
412 virtual void hadjustment_set_page_increment(int size) = 0;
413 virtual void hadjustment_set_step_increment(int size) = 0;
414 virtual void set_hpolicy(VclPolicyType eHPolicy) = 0;
415 virtual VclPolicyType get_hpolicy() const = 0;
416 void connect_hadjustment_changed(const Link<ScrolledWindow&, void>& rLink)
418 m_aHChangeHdl = rLink;
421 virtual void vadjustment_configure(int value, int lower, int upper, int step_increment,
422 int page_increment, int page_size)
423 = 0;
424 virtual int vadjustment_get_value() const = 0;
425 virtual void vadjustment_set_value(int value) = 0;
426 virtual int vadjustment_get_upper() const = 0;
427 virtual void vadjustment_set_upper(int upper) = 0;
428 virtual int vadjustment_get_page_size() const = 0;
429 virtual void vadjustment_set_page_size(int size) = 0;
430 virtual void vadjustment_set_page_increment(int size) = 0;
431 virtual void vadjustment_set_step_increment(int size) = 0;
432 virtual int vadjustment_get_lower() const = 0;
433 virtual void vadjustment_set_lower(int upper) = 0;
434 virtual void set_vpolicy(VclPolicyType eVPolicy) = 0;
435 virtual VclPolicyType get_vpolicy() const = 0;
436 void connect_vadjustment_changed(const Link<ScrolledWindow&, void>& rLink)
438 m_aVChangeHdl = rLink;
440 virtual int get_scroll_thickness() const = 0;
441 virtual void set_scroll_thickness(int nThickness) = 0;
443 //trying to use custom color for a scrollbar is generally a bad idea.
444 virtual void customize_scrollbars(const Color& rBackgroundColor, const Color& rShadowColor,
445 const Color& rFaceColor)
446 = 0;
449 class Label;
451 class VCL_DLLPUBLIC Frame : virtual public Container
453 public:
454 virtual void set_label(const OUString& rText) = 0;
455 virtual OUString get_label() const = 0;
456 virtual std::unique_ptr<Label> weld_label_widget() const = 0;
459 class VCL_DLLPUBLIC Notebook : virtual public Widget
461 protected:
462 Link<const OString&, bool> m_aLeavePageHdl;
463 Link<const OString&, void> m_aEnterPageHdl;
465 public:
466 virtual int get_current_page() const = 0;
467 virtual int get_page_index(const OString& rIdent) const = 0;
468 virtual OString get_page_ident(int nPage) const = 0;
469 virtual OString get_current_page_ident() const = 0;
470 virtual void set_current_page(int nPage) = 0;
471 virtual void set_current_page(const OString& rIdent) = 0;
472 virtual void remove_page(const OString& rIdent) = 0;
473 virtual void insert_page(const OString& rIdent, const OUString& rLabel, int nPos) = 0;
474 void append_page(const OString& rIdent, const OUString& rLabel)
476 insert_page(rIdent, rLabel, -1);
478 virtual void set_tab_label_text(const OString& rIdent, const OUString& rLabel) = 0;
479 virtual OUString get_tab_label_text(const OString& rIdent) const = 0;
480 virtual int get_n_pages() const = 0;
481 virtual weld::Container* get_page(const OString& rIdent) const = 0;
483 void connect_leave_page(const Link<const OString&, bool>& rLink) { m_aLeavePageHdl = rLink; }
485 void connect_enter_page(const Link<const OString&, void>& rLink) { m_aEnterPageHdl = rLink; }
488 class VCL_DLLPUBLIC ScreenShotEntry
490 public:
491 ScreenShotEntry(const OString& rHelpId, const basegfx::B2IRange& rB2IRange)
492 : msHelpId(rHelpId)
493 , maB2IRange(rB2IRange)
497 const basegfx::B2IRange& getB2IRange() const { return maB2IRange; }
499 const OString& GetHelpId() const { return msHelpId; }
501 private:
502 OString msHelpId;
503 basegfx::B2IRange maB2IRange;
506 typedef std::vector<ScreenShotEntry> ScreenShotCollection;
508 class VCL_DLLPUBLIC Window : virtual public Container
510 protected:
511 Link<Widget&, bool> m_aHelpRequestHdl;
513 public:
514 virtual void set_title(const OUString& rTitle) = 0;
515 virtual OUString get_title() const = 0;
516 virtual void window_move(int x, int y) = 0;
517 virtual void set_modal(bool bModal) = 0;
518 virtual bool get_modal() const = 0;
519 virtual bool get_resizable() const = 0;
520 virtual Size get_size() const = 0;
521 virtual Point get_position() const = 0;
522 virtual tools::Rectangle get_monitor_workarea() const = 0;
523 // center window on is parent
525 // bTrackGeometryRequests set to true tries to ensure the window will end
526 // up still centered on its parent windows final size, taking into account
527 // that there may currently be pending geometry requests for the parent not
528 // yet processed by the underlying toolkit
530 // for e.g gtk this will means the window is always centered even when
531 // resized, calling set_centered_on_parent with false will turn this
532 // off again.
533 virtual void set_centered_on_parent(bool bTrackGeometryRequests) = 0;
534 // returns whether the widget that has focus is within this Window
535 // (its very possible to move this to weld::Container if that becomes
536 // desirable)
537 virtual bool has_toplevel_focus() const = 0;
538 virtual void present() = 0;
540 // with pOld of null, automatically find the old default widget and unset
541 // it, otherwise use as hint to the old default
542 virtual void change_default_widget(weld::Widget* pOld, weld::Widget* pNew) = 0;
543 virtual bool is_default_widget(const weld::Widget* pCandidate) const = 0;
545 virtual void set_window_state(const OString& rStr) = 0;
546 virtual OString get_window_state(WindowStateMask nMask) const = 0;
548 virtual css::uno::Reference<css::awt::XWindow> GetXWindow() = 0;
550 void connect_help(const Link<Widget&, bool>& rLink) { m_aHelpRequestHdl = rLink; }
552 virtual SystemEnvData get_system_data() const = 0;
554 virtual void resize_to_request() = 0;
556 // collect positions of widgets and their help ids for screenshot purposes
557 virtual ScreenShotCollection collect_screenshot_data() = 0;
559 // render the widget to an output device
560 virtual VclPtr<VirtualDevice> screenshot() = 0;
563 class VCL_DLLPUBLIC WaitObject
565 private:
566 weld::Widget* m_pWindow;
568 public:
569 WaitObject(weld::Widget* pWindow)
570 : m_pWindow(pWindow)
572 if (m_pWindow)
573 m_pWindow->set_busy_cursor(true);
575 ~WaitObject()
577 if (m_pWindow)
578 m_pWindow->set_busy_cursor(false);
582 class Button;
584 class VCL_DLLPUBLIC Dialog : virtual public Window
586 private:
587 friend DialogController;
588 virtual bool runAsync(std::shared_ptr<DialogController>,
589 const std::function<void(sal_Int32)>& func)
590 = 0;
592 public:
593 virtual int run() = 0;
594 // Run async without a controller
595 // @param self - must point to this, to enforce that the dialog was created/held by a shared_ptr
596 virtual bool runAsync(std::shared_ptr<Dialog> const& rxSelf,
597 const std::function<void(sal_Int32)>& func)
598 = 0;
599 virtual void response(int response) = 0;
600 virtual void add_button(const OUString& rText, int response, const OString& rHelpId = OString())
601 = 0;
602 virtual void set_default_response(int response) = 0;
603 virtual Button* weld_widget_for_response(int response) = 0;
604 virtual Container* weld_content_area() = 0;
606 // shrink the dialog down to shown just these widgets
607 virtual void collapse(weld::Widget* pEdit, weld::Widget* pButton) = 0;
608 // undo previous dialog collapse
609 virtual void undo_collapse() = 0;
611 virtual void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink)
612 = 0;
615 class VCL_DLLPUBLIC MessageDialog : virtual public Dialog
617 public:
618 virtual void set_primary_text(const OUString& rText) = 0;
619 virtual OUString get_primary_text() const = 0;
620 virtual void set_secondary_text(const OUString& rText) = 0;
621 virtual OUString get_secondary_text() const = 0;
622 virtual Container* weld_message_area() = 0;
625 class VCL_DLLPUBLIC Assistant : virtual public Dialog
627 protected:
628 Link<const OString&, bool> m_aJumpPageHdl;
630 bool signal_jump_page(const OString& rIdent) { return m_aJumpPageHdl.Call(rIdent); }
632 public:
633 virtual int get_current_page() const = 0;
634 virtual int get_n_pages() const = 0;
635 virtual OString get_page_ident(int nPage) const = 0;
636 virtual OString get_current_page_ident() const = 0;
637 virtual void set_current_page(int nPage) = 0;
638 virtual void set_current_page(const OString& rIdent) = 0;
639 // move the page rIdent to position nIndex
640 virtual void set_page_index(const OString& rIdent, int nIndex) = 0;
641 virtual void set_page_title(const OString& rIdent, const OUString& rTitle) = 0;
642 virtual OUString get_page_title(const OString& rIdent) const = 0;
643 virtual void set_page_sensitive(const OString& rIdent, bool bSensitive) = 0;
644 virtual weld::Container* append_page(const OString& rIdent) = 0;
646 virtual void set_page_side_help_id(const OString& rHelpId) = 0;
648 void connect_jump_page(const Link<const OString&, bool>& rLink) { m_aJumpPageHdl = rLink; }
651 inline OUString toId(const void* pValue)
653 return OUString::number(reinterpret_cast<sal_uInt64>(pValue));
656 template <typename T> T fromId(const OUString& rValue)
658 return reinterpret_cast<T>(rValue.toUInt64());
661 struct VCL_DLLPUBLIC ComboBoxEntry
663 OUString sString;
664 OUString sId;
665 OUString sImage;
666 ComboBoxEntry(const OUString& rString)
667 : sString(rString)
670 ComboBoxEntry(const OUString& rString, const OUString& rId)
671 : sString(rString)
672 , sId(rId)
675 ComboBoxEntry(const OUString& rString, const OUString& rId, const OUString& rImage)
676 : sString(rString)
677 , sId(rId)
678 , sImage(rImage)
683 enum class EntryMessageType
685 Normal,
686 Warning,
687 Error,
690 class Menu;
692 /// A widget used to choose from a list of items.
693 class VCL_DLLPUBLIC ComboBox : virtual public Widget
695 private:
696 OUString m_sSavedValue;
698 public:
699 // OUString is the id of the row, it may be null to measure the height of a generic line
700 typedef std::tuple<vcl::RenderContext&, const tools::Rectangle&, bool, const OUString&>
701 render_args;
703 protected:
704 Link<ComboBox&, void> m_aChangeHdl;
705 Link<ComboBox&, void> m_aPopupToggledHdl;
706 Link<ComboBox&, bool> m_aEntryActivateHdl;
707 Link<OUString&, bool> m_aEntryInsertTextHdl;
709 friend class ::LOKTrigger;
711 void signal_changed() { m_aChangeHdl.Call(*this); }
713 virtual void signal_popup_toggled() { m_aPopupToggledHdl.Call(*this); }
715 Link<render_args, void> m_aRenderHdl;
716 void signal_custom_render(vcl::RenderContext& rDevice, const tools::Rectangle& rRect,
717 bool bSelected, const OUString& rId)
719 m_aRenderHdl.Call(render_args(rDevice, rRect, bSelected, rId));
722 Link<vcl::RenderContext&, Size> m_aGetSizeHdl;
723 Size signal_custom_get_size(vcl::RenderContext& rDevice) { return m_aGetSizeHdl.Call(rDevice); }
725 public:
726 virtual void insert(int pos, const OUString& rStr, const OUString* pId,
727 const OUString* pIconName, VirtualDevice* pImageSurface)
728 = 0;
729 virtual void insert_vector(const std::vector<weld::ComboBoxEntry>& rItems, bool bKeepExisting)
730 = 0;
731 void insert_text(int pos, const OUString& rStr)
733 insert(pos, rStr, nullptr, nullptr, nullptr);
735 void append_text(const OUString& rStr) { insert(-1, rStr, nullptr, nullptr, nullptr); }
736 void append(const OUString& rId, const OUString& rStr)
738 insert(-1, rStr, &rId, nullptr, nullptr);
740 void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
742 insert(-1, rStr, &rId, &rImage, nullptr);
744 void append(const OUString& rId, const OUString& rStr, VirtualDevice& rImage)
746 insert(-1, rStr, &rId, nullptr, &rImage);
748 virtual void insert_separator(int pos, const OUString& rId) = 0;
749 void append_separator(const OUString& rId) { insert_separator(-1, rId); }
751 virtual int get_count() const = 0;
752 virtual void make_sorted() = 0;
753 virtual void clear() = 0;
755 //by index
756 virtual int get_active() const = 0;
757 virtual void set_active(int pos) = 0;
758 virtual void remove(int pos) = 0;
760 //by text
761 virtual OUString get_active_text() const = 0;
762 void set_active_text(const OUString& rStr) { set_active(find_text(rStr)); }
763 virtual OUString get_text(int pos) const = 0;
764 virtual int find_text(const OUString& rStr) const = 0;
765 void remove_text(const OUString& rText) { remove(find_text(rText)); }
767 //by id
768 virtual OUString get_active_id() const = 0;
769 virtual void set_active_id(const OUString& rStr) = 0;
770 virtual OUString get_id(int pos) const = 0;
771 virtual void set_id(int row, const OUString& rId) = 0;
772 virtual int find_id(const OUString& rId) const = 0;
773 void remove_id(const OUString& rId) { remove(find_id(rId)); }
775 /* m_aChangeHdl is called when the active item is changed. The can be due
776 to the user selecting a different item from the list or while typing
777 into the entry of a combo box with an entry.
779 Use changed_by_direct_pick() to discover whether an item was actually explicitly
780 selected, e.g. from the menu.
782 void connect_changed(const Link<ComboBox&, void>& rLink) { m_aChangeHdl = rLink; }
784 virtual bool changed_by_direct_pick() const = 0;
786 virtual void connect_popup_toggled(const Link<ComboBox&, void>& rLink)
788 m_aPopupToggledHdl = rLink;
791 //entry related
792 virtual bool has_entry() const = 0;
793 virtual void set_entry_message_type(EntryMessageType eType) = 0;
794 virtual void set_entry_text(const OUString& rStr) = 0;
795 virtual void set_entry_width_chars(int nChars) = 0;
796 virtual void set_entry_max_length(int nChars) = 0;
797 virtual void select_entry_region(int nStartPos, int nEndPos) = 0;
798 virtual bool get_entry_selection_bounds(int& rStartPos, int& rEndPos) = 0;
799 virtual void set_entry_completion(bool bEnable, bool bCaseSensitive = false) = 0;
800 virtual void set_entry_placeholder_text(const OUString& rText) = 0;
801 virtual void set_entry_editable(bool bEditable) = 0;
802 virtual void cut_entry_clipboard() = 0;
803 virtual void copy_entry_clipboard() = 0;
804 virtual void paste_entry_clipboard() = 0;
806 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
807 virtual void set_font(const vcl::Font& rFont) = 0;
809 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
810 virtual void set_entry_font(const vcl::Font& rFont) = 0;
811 virtual vcl::Font get_entry_font() = 0;
813 virtual bool get_popup_shown() const = 0;
815 void connect_entry_insert_text(const Link<OUString&, bool>& rLink)
817 m_aEntryInsertTextHdl = rLink;
820 // callback returns true to indicated no further processing of activate wanted
821 void connect_entry_activate(const Link<ComboBox&, bool>& rLink) { m_aEntryActivateHdl = rLink; }
823 void save_value() { m_sSavedValue = get_active_text(); }
824 OUString const& get_saved_value() const { return m_sSavedValue; }
825 bool get_value_changed_from_saved() const { return m_sSavedValue != get_active_text(); }
827 // for custom rendering a row
828 void connect_custom_get_size(const Link<vcl::RenderContext&, Size>& rLink)
830 m_aGetSizeHdl = rLink;
832 void connect_custom_render(const Link<render_args, void>& rLink) { m_aRenderHdl = rLink; }
833 // call set_custom_renderer after setting custom callbacks
834 virtual void set_custom_renderer(bool bOn) = 0;
835 // create a virtual device compatible with the device passed in render_args wrt alpha
836 virtual VclPtr<VirtualDevice> create_render_virtual_device() const = 0;
837 // set a sub menu for a entry, only works with custom rendering
838 virtual void set_item_menu(const OString& rIdent, weld::Menu* pMenu) = 0;
839 // get the width needed to show the menu launcher in a custom row
840 virtual int get_menu_button_width() const = 0;
842 // for mru support
843 virtual int get_max_mru_count() const = 0;
844 virtual void set_max_mru_count(int nCount) = 0;
845 virtual OUString get_mru_entries() const = 0;
846 virtual void set_mru_entries(const OUString& rEntries) = 0;
849 enum class ColumnToggleType
851 Check,
852 Radio
855 class VCL_DLLPUBLIC TreeIter
857 private:
858 TreeIter(const TreeIter&) = delete;
859 TreeIter& operator=(const TreeIter&) = delete;
861 public:
862 TreeIter() {}
863 virtual bool equal(const TreeIter& rOther) const = 0;
864 virtual ~TreeIter() {}
867 /* Model column indexes are considered to begin at 0, but with special columns
868 before index 0. A expander image column (and an additional optional toggle
869 button column when enable_toggle_buttons is used). Column index -1 is
870 reserved to access those columns.
872 class VCL_DLLPUBLIC TreeView : virtual public Widget
874 friend class ::LOKTrigger;
876 public:
877 typedef std::pair<const TreeIter&, int> iter_col;
878 typedef std::pair<const TreeIter&, OUString> iter_string;
879 // OUString is the id of the row, it may be null to measure the height of a generic line
880 typedef std::pair<vcl::RenderContext&, const OUString&> get_size_args;
881 typedef std::tuple<vcl::RenderContext&, const tools::Rectangle&, bool, const OUString&>
882 render_args;
884 private:
885 OUString m_sSavedValue;
887 protected:
888 Link<TreeView&, void> m_aChangeHdl;
889 Link<TreeView&, bool> m_aRowActivatedHdl;
890 Link<int, void> m_aColumnClickedHdl;
891 Link<const iter_col&, void> m_aRadioToggleHdl;
892 Link<const TreeIter&, bool> m_aEditingStartedHdl;
893 Link<const iter_string&, bool> m_aEditingDoneHdl;
894 // if handler returns false, the expansion of the row is refused
895 Link<const TreeIter&, bool> m_aExpandingHdl;
896 // if handler returns false, the collapse of the row is refused
897 Link<const TreeIter&, bool> m_aCollapsingHdl;
898 Link<TreeView&, void> m_aVisibleRangeChangedHdl;
899 Link<TreeView&, void> m_aModelChangedHdl;
900 // if handler returns true, then menu has been show and event is consumed
901 Link<const CommandEvent&, bool> m_aPopupMenuHdl;
902 // if handler returns true, drag is disallowed, consumer can change bool
903 // arg to false to disable the treeview default dnd icon
904 Link<bool&, bool> m_aDragBeginHdl;
905 std::function<int(const weld::TreeIter&, const weld::TreeIter&)> m_aCustomSort;
907 protected:
908 void signal_changed() { m_aChangeHdl.Call(*this); }
909 bool signal_row_activated() { return m_aRowActivatedHdl.Call(*this); }
910 void signal_column_clicked(int nColumn) { m_aColumnClickedHdl.Call(nColumn); }
911 bool signal_expanding(const TreeIter& rIter)
913 return !m_aExpandingHdl.IsSet() || m_aExpandingHdl.Call(rIter);
915 bool signal_collapsing(const TreeIter& rIter)
917 return !m_aCollapsingHdl.IsSet() || m_aCollapsingHdl.Call(rIter);
919 void signal_visible_range_changed() { m_aVisibleRangeChangedHdl.Call(*this); }
920 void signal_model_changed() { m_aModelChangedHdl.Call(*this); }
922 void signal_toggled(const iter_col& rIterCol) { m_aRadioToggleHdl.Call(rIterCol); }
924 bool signal_editing_started(const TreeIter& rIter) { return m_aEditingStartedHdl.Call(rIter); }
926 bool signal_editing_done(const iter_string& rIterText)
928 return m_aEditingDoneHdl.Call(rIterText);
931 Link<const TreeIter&, OUString> m_aQueryTooltipHdl;
932 OUString signal_query_tooltip(const TreeIter& rIter) { return m_aQueryTooltipHdl.Call(rIter); }
934 Link<render_args, void> m_aRenderHdl;
935 void signal_custom_render(vcl::RenderContext& rDevice, const tools::Rectangle& rRect,
936 bool bSelected, const OUString& rId)
938 m_aRenderHdl.Call(render_args(rDevice, rRect, bSelected, rId));
941 Link<get_size_args, Size> m_aGetSizeHdl;
942 Size signal_custom_get_size(vcl::RenderContext& rDevice, const OUString& rId)
944 return m_aGetSizeHdl.Call(get_size_args(rDevice, rId));
947 public:
948 virtual void connect_query_tooltip(const Link<const TreeIter&, OUString>& rLink)
950 assert(!m_aQueryTooltipHdl.IsSet() || !rLink.IsSet());
951 m_aQueryTooltipHdl = rLink;
954 // see 'expanding on-demand node details' for bChildrenOnDemand of true
955 virtual void insert(const TreeIter* pParent, int pos, const OUString* pStr, const OUString* pId,
956 const OUString* pIconName, VirtualDevice* pImageSurface,
957 bool bChildrenOnDemand, TreeIter* pRet)
958 = 0;
960 void insert(int nRow, TreeIter* pRet = nullptr)
962 insert(nullptr, nRow, nullptr, nullptr, nullptr, nullptr, false, pRet);
965 void append(TreeIter* pRet = nullptr) { insert(-1, pRet); }
967 void insert(int pos, const OUString& rStr, const OUString* pId, const OUString* pIconName,
968 VirtualDevice* pImageSurface)
970 insert(nullptr, pos, &rStr, pId, pIconName, pImageSurface, false, nullptr);
972 void insert_text(int pos, const OUString& rStr)
974 insert(nullptr, pos, &rStr, nullptr, nullptr, nullptr, false, nullptr);
976 void append_text(const OUString& rStr)
978 insert(nullptr, -1, &rStr, nullptr, nullptr, nullptr, false, nullptr);
980 void append(const OUString& rId, const OUString& rStr)
982 insert(nullptr, -1, &rStr, &rId, nullptr, nullptr, false, nullptr);
984 void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
986 insert(nullptr, -1, &rStr, &rId, &rImage, nullptr, false, nullptr);
988 void append(const TreeIter* pParent, const OUString& rStr)
990 insert(pParent, -1, &rStr, nullptr, nullptr, nullptr, false, nullptr);
993 virtual void insert_separator(int pos, const OUString& rId) = 0;
994 void append_separator(const OUString& rId) { insert_separator(-1, rId); }
996 void connect_changed(const Link<TreeView&, void>& rLink) { m_aChangeHdl = rLink; }
998 /* A row is "activated" when the user double clicks a treeview row. It may
999 also be emitted when a row is selected and Space or Enter is pressed.
1001 a return of "true" means the activation has been handled, a "false" propagates
1002 the activation to the default handler which expands/collapses the row, if possible.
1004 void connect_row_activated(const Link<TreeView&, bool>& rLink) { m_aRowActivatedHdl = rLink; }
1006 // Argument is a pair of iter, col describing the toggled node
1007 void connect_toggled(const Link<const iter_col&, void>& rLink) { m_aRadioToggleHdl = rLink; }
1009 void connect_column_clicked(const Link<int, void>& rLink) { m_aColumnClickedHdl = rLink; }
1010 void connect_model_changed(const Link<TreeView&, void>& rLink) { m_aModelChangedHdl = rLink; }
1012 virtual OUString get_selected_text() const = 0;
1013 virtual OUString get_selected_id() const = 0;
1015 // call before inserting any content and connecting to toggle signals,
1016 // an pre-inserted checkbutton column will exist at the start of every row
1017 // inserted after this call which can be accessed with col index -1
1018 virtual void enable_toggle_buttons(ColumnToggleType eType) = 0;
1020 virtual void set_clicks_to_toggle(int nToggleBehavior) = 0;
1022 //by index
1023 virtual int get_selected_index() const = 0;
1024 //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1025 virtual void select(int pos) = 0;
1026 virtual void unselect(int pos) = 0;
1027 virtual void remove(int pos) = 0;
1028 // col index -1 gets the first text column
1029 virtual OUString get_text(int row, int col = -1) const = 0;
1030 // col index -1 sets the first text column
1031 virtual void set_text(int row, const OUString& rText, int col = -1) = 0;
1032 // col index -1 sets the first text column
1033 virtual void set_sensitive(int row, bool bSensitive, int col = -1) = 0;
1034 virtual void set_id(int row, const OUString& rId) = 0;
1035 // col index -1 sets the expander toggle, enable_toggle_buttons must have been called to create that column
1036 virtual void set_toggle(int row, TriState eState, int col = -1) = 0;
1037 // col index -1 gets the expander toggle, enable_toggle_buttons must have been called to create that column
1038 virtual TriState get_toggle(int row, int col = -1) const = 0;
1039 // col index -1 sets the expander image
1040 virtual void set_image(int row, const OUString& rImage, int col = -1) = 0;
1041 // col index -1 sets the expander image
1042 virtual void set_image(int row, VirtualDevice& rImage, int col = -1) = 0;
1043 // col index -1 sets the expander image
1044 virtual void set_image(int row, const css::uno::Reference<css::graphic::XGraphic>& rImage,
1045 int col = -1)
1046 = 0;
1047 virtual void set_text_emphasis(int row, bool bOn, int col) = 0;
1048 virtual bool get_text_emphasis(int row, int col) const = 0;
1049 virtual void set_text_align(int row, double fAlign, int col) = 0;
1050 virtual void swap(int pos1, int pos2) = 0;
1051 virtual std::vector<int> get_selected_rows() const = 0;
1052 virtual void set_font_color(int pos, const Color& rColor) = 0;
1053 // scroll to make 'row' visible, this will also expand all parent rows of 'row' as necessary to
1054 // make 'row' visible
1055 virtual void scroll_to_row(int row) = 0;
1056 virtual bool is_selected(int pos) const = 0;
1057 virtual int get_cursor_index() const = 0;
1058 virtual void set_cursor(int pos) = 0;
1060 //by text
1061 virtual int find_text(const OUString& rText) const = 0;
1062 //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1063 void select_text(const OUString& rText) { select(find_text(rText)); }
1064 void remove_text(const OUString& rText) { remove(find_text(rText)); }
1065 std::vector<OUString> get_selected_rows_text() const
1067 std::vector<int> aRows(get_selected_rows());
1068 std::vector<OUString> aRet;
1069 aRet.reserve(aRows.size());
1070 for (auto a : aRows)
1071 aRet.push_back(get_text(a));
1072 return aRet;
1075 //by id
1076 virtual OUString get_id(int pos) const = 0;
1077 virtual int find_id(const OUString& rId) const = 0;
1078 //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1079 void select_id(const OUString& rId) { select(find_id(rId)); }
1080 void remove_id(const OUString& rText) { remove(find_id(rText)); }
1082 //via iter
1083 virtual std::unique_ptr<TreeIter> make_iterator(const TreeIter* pOrig = nullptr) const = 0;
1084 virtual void copy_iterator(const TreeIter& rSource, TreeIter& rDest) const = 0;
1085 virtual bool get_selected(TreeIter* pIter) const = 0;
1086 virtual bool get_cursor(TreeIter* pIter) const = 0;
1087 virtual void set_cursor(const TreeIter& rIter) = 0;
1088 virtual bool get_iter_first(TreeIter& rIter) const = 0;
1089 // set iter to point to next node at the current level
1090 virtual bool iter_next_sibling(TreeIter& rIter) const = 0;
1091 // set iter to point to previous node at the current level
1092 virtual bool iter_previous_sibling(TreeIter& rIter) const = 0;
1093 // set iter to point to next node, depth first, then sibling
1094 virtual bool iter_next(TreeIter& rIter) const = 0;
1095 // set iter to point to previous node, sibling first then depth
1096 virtual bool iter_previous(TreeIter& rIter) const = 0;
1097 // set iter to point to first child node
1098 virtual bool iter_children(TreeIter& rIter) const = 0;
1099 bool iter_nth_sibling(TreeIter& rIter, int nChild) const
1101 bool bRet = true;
1102 for (int i = 0; i < nChild && bRet; ++i)
1103 bRet = iter_next_sibling(rIter);
1104 return bRet;
1106 bool iter_nth_child(TreeIter& rIter, int nChild) const
1108 if (!iter_children(rIter))
1109 return false;
1110 return iter_nth_sibling(rIter, nChild);
1112 virtual bool iter_parent(TreeIter& rIter) const = 0;
1113 virtual int get_iter_depth(const TreeIter& rIter) const = 0;
1114 virtual int get_iter_index_in_parent(const TreeIter& rIter) const = 0;
1115 /* Compares two paths. If a appears before b in a tree, then -1 is returned.
1116 If b appears before a , then 1 is returned. If the two nodes are equal,
1117 then 0 is returned.
1119 virtual int iter_compare(const TreeIter& a, const TreeIter& b) const = 0;
1120 virtual bool iter_has_child(const TreeIter& rIter) const = 0;
1121 // returns the number of direct children rIter has
1122 virtual int iter_n_children(const TreeIter& rIter) const = 0;
1123 virtual void remove(const TreeIter& rIter) = 0;
1124 //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1125 virtual void select(const TreeIter& rIter) = 0;
1126 virtual void unselect(const TreeIter& rIter) = 0;
1127 //visually indent this row as if it was at get_iter_depth() + nIndentLevel
1128 virtual void set_extra_row_indent(const TreeIter& rIter, int nIndentLevel) = 0;
1129 // col index -1 sets the first text column
1130 virtual void set_text(const TreeIter& rIter, const OUString& rStr, int col = -1) = 0;
1131 // col index -1 sets the first text column
1132 virtual void set_sensitive(const TreeIter& rIter, bool bSensitive, int col = -1) = 0;
1133 virtual void set_text_emphasis(const TreeIter& rIter, bool bOn, int col) = 0;
1134 virtual bool get_text_emphasis(const TreeIter& rIter, int col) const = 0;
1135 virtual void set_text_align(const TreeIter& rIter, double fAlign, int col) = 0;
1136 // col index -1 sets the expander toggle, enable_toggle_buttons must have been called to create that column
1137 virtual void set_toggle(const TreeIter& rIter, TriState bOn, int col = -1) = 0;
1138 // col index -1 gets the expander toggle, enable_toggle_buttons must have been called to create that column
1139 virtual TriState get_toggle(const TreeIter& rIter, int col = -1) const = 0;
1140 // col index -1 gets the first text column
1141 virtual OUString get_text(const TreeIter& rIter, int col = -1) const = 0;
1142 virtual void set_id(const TreeIter& rIter, const OUString& rId) = 0;
1143 virtual OUString get_id(const TreeIter& rIter) const = 0;
1144 // col index -1 sets the expander image
1145 virtual void set_image(const TreeIter& rIter, const OUString& rImage, int col = -1) = 0;
1146 // col index -1 sets the expander image
1147 virtual void set_image(const TreeIter& rIter, VirtualDevice& rImage, int col = -1) = 0;
1148 // col index -1 sets the expander image
1149 virtual void set_image(const TreeIter& rIter,
1150 const css::uno::Reference<css::graphic::XGraphic>& rImage, int col = -1)
1151 = 0;
1152 virtual void set_font_color(const TreeIter& rIter, const Color& rColor) = 0;
1153 // scroll to make rIter visible, this will also expand all parent rows of rIter as necessary to
1154 // make rIter visible
1155 virtual void scroll_to_row(const TreeIter& rIter) = 0;
1156 virtual bool is_selected(const TreeIter& rIter) const = 0;
1158 virtual void move_subtree(TreeIter& rNode, const TreeIter* pNewParent, int nIndexInNewParent)
1159 = 0;
1161 // call func on each element until func returns true or we run out of elements
1162 virtual void all_foreach(const std::function<bool(TreeIter&)>& func) = 0;
1163 // call func on each selected element until func returns true or we run out of elements
1164 virtual void selected_foreach(const std::function<bool(TreeIter&)>& func) = 0;
1165 // call func on each visible element until func returns true or we run out of elements
1166 virtual void visible_foreach(const std::function<bool(TreeIter&)>& func) = 0;
1167 // clear the children of pParent (whole tree if nullptr),
1168 // then add nSourceCount rows under pParent, call func on each row
1169 // inserted with an arg of the index that this row will be when bulk insert
1170 // ends.
1172 // this enables inserting the entries backwards in models where that is faster,
1174 // pFixedWidths is optional, when present each matching entry col text
1175 // width will not be measured, and the fixed width used instead. Use
1176 // sparingly because wider text than the fixed width is clipped and cannot
1177 // be scrolled into view horizontally.
1178 virtual void bulk_insert_for_each(int nSourceCount,
1179 const std::function<void(TreeIter&, int nSourceIndex)>& func,
1180 const weld::TreeIter* pParent = nullptr,
1181 const std::vector<int>* pFixedWidths = nullptr)
1182 = 0;
1184 /* expanding on-demand node details
1186 When a node is added with children-on-demand (typically via 'insert' with
1187 bChildrenOnDemand of true), then initially in reality the
1188 children-on-demand node is given a 'placeholder' child entry to indicate
1189 the load-on-demand state.
1191 The 'placeholder' needs to be there for the expander indicator to be
1192 drawn/shown even when there are no "real" entries yet. This child doesn't
1193 exist for the purposes of any of the iterator methods, e.g. iter_has_child
1194 on an on-demand node which hasn't been expanded yet is false. Likewise the
1195 rest of the iterator methods skip over or otherwise ignore that node.
1197 Normal usage is the user clicks on the expander, the expansion mechanism
1198 removes the 'placeholder' entry (set_children_on_demand(false)) and calls
1199 any installed expanding-callback (installable via connect_expanding) which
1200 has the opportunity to populate the node with children.
1202 If you decide to directly populate the children of an on-demand node
1203 outside of the expanding-callback then you also need to explicitly remove
1204 the 'placeholder' with set_children_on_demand(false) otherwise the treeview
1205 is in an inconsistent state. */
1207 virtual bool get_row_expanded(const TreeIter& rIter) const = 0;
1208 // expand row will first trigger the callback set via connect_expanding before expanding
1209 virtual void expand_row(const TreeIter& rIter) = 0;
1210 // collapse row will first trigger the callback set via connect_collapsing before collapsing
1211 virtual void collapse_row(const TreeIter& rIter) = 0;
1212 // set the empty node to appear as if it has children, true is equivalent
1213 // to 'insert' with a bChildrenOnDemand of true. See notes above.
1214 virtual void set_children_on_demand(const TreeIter& rIter, bool bChildrenOnDemand) = 0;
1215 // return if the node is configured to be populated on-demand
1216 virtual bool get_children_on_demand(const TreeIter& rIter) const = 0;
1217 // set if the expanders are shown or not
1218 virtual void set_show_expanders(bool bShow) = 0;
1220 void connect_expanding(const Link<const TreeIter&, bool>& rLink) { m_aExpandingHdl = rLink; }
1221 void connect_collapsing(const Link<const TreeIter&, bool>& rLink) { m_aCollapsingHdl = rLink; }
1223 // rStartLink returns true to allow editing, false to disallow
1224 // rEndLink returns true to accept the edit, false to reject
1225 virtual void connect_editing(const Link<const TreeIter&, bool>& rStartLink,
1226 const Link<const iter_string&, bool>& rEndLink)
1228 assert(rStartLink.IsSet() == rEndLink.IsSet() && "should be both on or both off");
1229 m_aEditingStartedHdl = rStartLink;
1230 m_aEditingDoneHdl = rEndLink;
1233 virtual void start_editing(const weld::TreeIter& rEntry) = 0;
1234 virtual void end_editing() = 0;
1236 virtual void connect_visible_range_changed(const Link<TreeView&, void>& rLink)
1238 assert(!m_aVisibleRangeChangedHdl.IsSet() || !rLink.IsSet());
1239 m_aVisibleRangeChangedHdl = rLink;
1242 virtual void connect_popup_menu(const Link<const CommandEvent&, bool>& rLink)
1244 m_aPopupMenuHdl = rLink;
1247 virtual void enable_drag_source(rtl::Reference<TransferDataContainer>& rTransferrable,
1248 sal_uInt8 eDNDConstants)
1249 = 0;
1251 void connect_drag_begin(const Link<bool&, bool>& rLink) { m_aDragBeginHdl = rLink; }
1253 //all of them. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1254 void select_all() { unselect(-1); }
1255 void unselect_all() { select(-1); }
1257 // return the number of toplevel nodes
1258 virtual int n_children() const = 0;
1260 // afterwards, entries will be in default ascending sort order
1261 virtual void make_sorted() = 0;
1262 virtual void make_unsorted() = 0;
1263 virtual bool get_sort_order() const = 0;
1264 virtual void set_sort_order(bool bAscending) = 0;
1266 // TRUE ascending, FALSE, descending, INDET, neither (off)
1267 virtual void set_sort_indicator(TriState eState, int nColumn) = 0;
1268 virtual TriState get_sort_indicator(int nColumn) const = 0;
1270 virtual int get_sort_column() const = 0;
1271 virtual void set_sort_column(int nColumn) = 0;
1273 virtual void
1274 set_sort_func(const std::function<int(const weld::TreeIter&, const weld::TreeIter&)>& func)
1276 m_aCustomSort = func;
1279 virtual void clear() = 0;
1280 virtual int get_height_rows(int nRows) const = 0;
1282 virtual void columns_autosize() = 0;
1283 virtual void set_column_fixed_widths(const std::vector<int>& rWidths) = 0;
1284 virtual void set_column_editables(const std::vector<bool>& rEditables) = 0;
1285 virtual int get_column_width(int nCol) const = 0;
1286 virtual void set_centered_column(int nCol) = 0;
1287 virtual OUString get_column_title(int nColumn) const = 0;
1288 virtual void set_column_title(int nColumn, const OUString& rTitle) = 0;
1290 int get_checkbox_column_width() const { return get_approximate_digit_width() * 3 + 6; }
1292 virtual void set_selection_mode(SelectionMode eMode) = 0;
1293 virtual int count_selected_rows() const = 0;
1294 // remove the selected nodes
1295 virtual void remove_selection() = 0;
1297 // only meaningful is call this from a "changed" callback, true if the change
1298 // was due to mouse hovering over the entry
1299 virtual bool changed_by_hover() const = 0;
1301 virtual void vadjustment_set_value(int value) = 0;
1302 virtual int vadjustment_get_value() const = 0;
1304 void save_value() { m_sSavedValue = get_selected_text(); }
1305 OUString const& get_saved_value() const { return m_sSavedValue; }
1306 bool get_value_changed_from_saved() const { return m_sSavedValue != get_selected_text(); }
1308 // for custom rendering a cell
1309 void connect_custom_get_size(const Link<get_size_args, Size>& rLink) { m_aGetSizeHdl = rLink; }
1310 void connect_custom_render(const Link<render_args, void>& rLink) { m_aRenderHdl = rLink; }
1311 // call set_column_custom_renderer after setting custom callbacks
1312 virtual void set_column_custom_renderer(int nColumn, bool bEnable) = 0;
1313 // redraw all rows, typically only useful with custom rendering to redraw due to external
1314 // state change
1315 virtual void queue_draw() = 0;
1317 /* with bDnDMode false simply return the row under the point
1319 * with bDnDMode true:
1320 * a) return the row which should be dropped on, which may
1321 * be different from the row the mouse is over in some backends where
1322 * positioning the mouse on the bottom half of a row indicates to drop
1323 * after the row
1324 * b) dnd highlight the dest row
1326 virtual bool get_dest_row_at_pos(const Point& rPos, weld::TreeIter* pResult, bool bDnDMode) = 0;
1327 virtual void unset_drag_dest_row() = 0;
1328 virtual tools::Rectangle get_row_area(const weld::TreeIter& rIter) const = 0;
1329 // for dragging and dropping between TreeViews, return the active source
1330 virtual TreeView* get_drag_source() const = 0;
1332 using Widget::set_sensitive;
1335 class VCL_DLLPUBLIC IconView : virtual public Widget
1337 friend class ::LOKTrigger;
1339 private:
1340 OUString m_sSavedValue;
1342 protected:
1343 Link<IconView&, void> m_aSelectionChangeHdl;
1344 Link<IconView&, bool> m_aItemActivatedHdl;
1345 Link<const CommandEvent&, bool> m_aCommandHdl;
1346 Link<const TreeIter&, OUString> m_aQueryTooltipHdl;
1348 void signal_selection_changed() { m_aSelectionChangeHdl.Call(*this); }
1349 bool signal_item_activated() { return m_aItemActivatedHdl.Call(*this); }
1350 OUString signal_query_tooltip(const TreeIter& rIter) { return m_aQueryTooltipHdl.Call(rIter); }
1352 public:
1353 virtual int get_item_width() const = 0;
1354 virtual void set_item_width(int width) = 0;
1356 virtual void insert(int pos, const OUString* pStr, const OUString* pId,
1357 const OUString* pIconName, TreeIter* pRet)
1358 = 0;
1360 virtual void insert(int pos, const OUString* pStr, const OUString* pId,
1361 const VirtualDevice* pIcon, TreeIter* pRet)
1362 = 0;
1364 void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
1366 insert(-1, &rStr, &rId, &rImage, nullptr);
1369 void append(const OUString& rId, const OUString& rStr, const VirtualDevice* pImage)
1371 insert(-1, &rStr, &rId, pImage, nullptr);
1374 void connect_selection_changed(const Link<IconView&, void>& rLink)
1376 m_aSelectionChangeHdl = rLink;
1379 /* A row is "activated" when the user double clicks a treeview row. It may
1380 also be emitted when a row is selected and Space or Enter is pressed.
1382 a return of "true" means the activation has been handled, a "false" propagates
1383 the activation to the default handler which expands/collapses the row, if possible.
1385 void connect_item_activated(const Link<IconView&, bool>& rLink) { m_aItemActivatedHdl = rLink; }
1387 void connect_command(const Link<const CommandEvent&, bool>& rLink) { m_aCommandHdl = rLink; }
1389 virtual void connect_query_tooltip(const Link<const TreeIter&, OUString>& rLink)
1391 m_aQueryTooltipHdl = rLink;
1394 virtual OUString get_selected_id() const = 0;
1396 virtual void clear() = 0;
1398 virtual int count_selected_items() const = 0;
1400 virtual OUString get_selected_text() const = 0;
1402 //by index. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1403 virtual void select(int pos) = 0;
1404 virtual void unselect(int pos) = 0;
1406 //via iter
1407 virtual std::unique_ptr<TreeIter> make_iterator(const TreeIter* pOrig = nullptr) const = 0;
1408 virtual bool get_selected(TreeIter* pIter) const = 0;
1409 virtual bool get_cursor(TreeIter* pIter) const = 0;
1410 virtual void set_cursor(const TreeIter& rIter) = 0;
1411 virtual bool get_iter_first(TreeIter& rIter) const = 0;
1412 virtual OUString get_id(const TreeIter& rIter) const = 0;
1413 virtual void scroll_to_item(const TreeIter& rIter) = 0;
1415 // call func on each selected element until func returns true or we run out of elements
1416 virtual void selected_foreach(const std::function<bool(TreeIter&)>& func) = 0;
1418 //all of them. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1419 void select_all() { unselect(-1); }
1420 void unselect_all() { select(-1); }
1422 // return the number of toplevel nodes
1423 virtual int n_children() const = 0;
1425 void save_value() { m_sSavedValue = get_selected_text(); }
1426 OUString const& get_saved_value() const { return m_sSavedValue; }
1427 bool get_value_changed_from_saved() const { return m_sSavedValue != get_selected_text(); }
1430 class VCL_DLLPUBLIC Button : virtual public Widget
1432 friend class ::LOKTrigger;
1434 protected:
1435 Link<Button&, void> m_aClickHdl;
1437 void signal_clicked() { m_aClickHdl.Call(*this); }
1439 public:
1440 virtual void set_label(const OUString& rText) = 0;
1441 // pDevice, the image for the button, or nullptr to unset
1442 virtual void set_image(VirtualDevice* pDevice) = 0;
1443 virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) = 0;
1444 virtual void set_from_icon_name(const OUString& rIconName) = 0;
1445 virtual OUString get_label() const = 0;
1446 void clicked() { signal_clicked(); }
1448 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
1449 virtual void set_font(const vcl::Font& rFont) = 0;
1451 /* Sometimes, a widget should behave like a button (activate on click,
1452 accept keyboard focus, etc), but look entirely different.
1454 pDevice, the custom look to use, or nullptr to unset.
1456 Typically doing this is ill advised. Consider using
1457 set_accessible_name if you do. */
1458 virtual void set_custom_button(VirtualDevice* pDevice) = 0;
1460 void connect_clicked(const Link<Button&, void>& rLink) { m_aClickHdl = rLink; }
1463 class VCL_DLLPUBLIC Toggleable : virtual public Widget
1465 friend class ::LOKTrigger;
1467 protected:
1468 Link<Toggleable&, void> m_aToggleHdl;
1469 TriState m_eSavedValue = TRISTATE_FALSE;
1471 void signal_toggled() { m_aToggleHdl.Call(*this); }
1473 public:
1474 virtual void set_active(bool active) = 0;
1475 virtual bool get_active() const = 0;
1477 virtual void set_inconsistent(bool inconsistent) = 0;
1478 virtual bool get_inconsistent() const = 0;
1480 TriState get_state() const
1482 if (get_inconsistent())
1483 return TRISTATE_INDET;
1484 else if (get_active())
1485 return TRISTATE_TRUE;
1486 return TRISTATE_FALSE;
1489 void set_state(TriState eState)
1491 switch (eState)
1493 case TRISTATE_INDET:
1494 set_inconsistent(true);
1495 break;
1496 case TRISTATE_TRUE:
1497 set_inconsistent(false);
1498 set_active(true);
1499 break;
1500 case TRISTATE_FALSE:
1501 set_inconsistent(false);
1502 set_active(false);
1503 break;
1507 void save_state() { m_eSavedValue = get_state(); }
1508 TriState get_saved_state() const { return m_eSavedValue; }
1509 bool get_state_changed_from_saved() const { return m_eSavedValue != get_state(); }
1511 virtual void connect_toggled(const Link<Toggleable&, void>& rLink) { m_aToggleHdl = rLink; }
1514 class VCL_DLLPUBLIC ToggleButton : virtual public Button, virtual public Toggleable
1516 friend class ::LOKTrigger;
1519 struct VCL_DLLPUBLIC TriStateEnabled
1521 TriState eState;
1522 bool bTriStateEnabled;
1523 TriStateEnabled()
1524 : eState(TRISTATE_INDET)
1525 , bTriStateEnabled(true)
1528 void ButtonToggled(Toggleable& rToggle);
1531 class VCL_DLLPUBLIC MenuButton : virtual public ToggleButton
1533 protected:
1534 Link<const OString&, void> m_aSelectHdl;
1536 void signal_selected(const OString& rIdent) { m_aSelectHdl.Call(rIdent); }
1538 public:
1539 void connect_selected(const Link<const OString&, void>& rLink) { m_aSelectHdl = rLink; }
1541 virtual void insert_item(int pos, const OUString& rId, const OUString& rStr,
1542 const OUString* pIconName, VirtualDevice* pImageSurface,
1543 TriState eCheckRadioFalse)
1544 = 0;
1545 void append_item(const OUString& rId, const OUString& rStr)
1547 insert_item(-1, rId, rStr, nullptr, nullptr, TRISTATE_INDET);
1549 void append_item_check(const OUString& rId, const OUString& rStr)
1551 insert_item(-1, rId, rStr, nullptr, nullptr, TRISTATE_TRUE);
1553 void append_item_radio(const OUString& rId, const OUString& rStr)
1555 insert_item(-1, rId, rStr, nullptr, nullptr, TRISTATE_FALSE);
1557 void append_item(const OUString& rId, const OUString& rStr, const OUString& rImage)
1559 insert_item(-1, rId, rStr, &rImage, nullptr, TRISTATE_INDET);
1561 void append_item(const OUString& rId, const OUString& rStr, VirtualDevice& rImage)
1563 insert_item(-1, rId, rStr, nullptr, &rImage, TRISTATE_INDET);
1565 virtual void insert_separator(int pos, const OUString& rId) = 0;
1566 void append_separator(const OUString& rId) { insert_separator(-1, rId); }
1567 virtual void remove_item(const OString& rId) = 0;
1568 virtual void clear() = 0;
1569 virtual void set_item_sensitive(const OString& rIdent, bool bSensitive) = 0;
1570 virtual void set_item_active(const OString& rIdent, bool bActive) = 0;
1571 virtual void set_item_label(const OString& rIdent, const OUString& rLabel) = 0;
1572 virtual OUString get_item_label(const OString& rIdent) const = 0;
1573 virtual void set_item_visible(const OString& rIdent, bool bVisible) = 0;
1575 virtual void set_popover(weld::Widget* pPopover) = 0;
1578 // Similar to a MenuButton except it is split into two parts, a toggle
1579 // button at the start and a menubutton at the end
1580 class VCL_DLLPUBLIC MenuToggleButton : virtual public MenuButton
1584 class VCL_DLLPUBLIC CheckButton : virtual public Toggleable
1586 public:
1587 virtual void set_label(const OUString& rText) = 0;
1588 virtual OUString get_label() const = 0;
1589 virtual void set_label_wrap(bool wrap) = 0;
1592 class VCL_DLLPUBLIC RadioButton : virtual public CheckButton
1596 class VCL_DLLPUBLIC LinkButton : virtual public Widget
1598 protected:
1599 Link<LinkButton&, bool> m_aActivateLinkHdl;
1601 bool signal_activate_link() { return m_aActivateLinkHdl.Call(*this); }
1603 public:
1604 virtual void set_label(const OUString& rText) = 0;
1605 virtual OUString get_label() const = 0;
1606 virtual void set_uri(const OUString& rUri) = 0;
1607 virtual OUString get_uri() const = 0;
1609 void connect_activate_link(const Link<LinkButton&, bool>& rLink) { m_aActivateLinkHdl = rLink; }
1612 class VCL_DLLPUBLIC Scale : virtual public Widget
1614 protected:
1615 Link<Scale&, void> m_aValueChangedHdl;
1617 void signal_value_changed() { m_aValueChangedHdl.Call(*this); }
1619 public:
1620 virtual void set_value(int value) = 0;
1621 virtual int get_value() const = 0;
1622 virtual void set_range(int min, int max) = 0;
1624 virtual void set_increments(int step, int page) = 0;
1625 virtual void get_increments(int& step, int& page) const = 0;
1627 void connect_value_changed(const Link<Scale&, void>& rLink) { m_aValueChangedHdl = rLink; }
1630 class VCL_DLLPUBLIC Spinner : virtual public Widget
1632 public:
1633 virtual void start() = 0;
1634 virtual void stop() = 0;
1637 class VCL_DLLPUBLIC ProgressBar : virtual public Widget
1639 public:
1640 //0-100
1641 virtual void set_percentage(int value) = 0;
1642 virtual OUString get_text() const = 0;
1643 virtual void set_text(const OUString& rText) = 0;
1646 class VCL_DLLPUBLIC Entry : virtual public Widget
1648 private:
1649 OUString m_sSavedValue;
1651 protected:
1652 Link<Entry&, void> m_aChangeHdl;
1653 Link<OUString&, bool> m_aInsertTextHdl;
1654 Link<Entry&, void> m_aCursorPositionHdl;
1655 Link<Entry&, bool> m_aActivateHdl;
1657 friend class ::LOKTrigger;
1659 void signal_changed() { m_aChangeHdl.Call(*this); }
1660 void signal_cursor_position() { m_aCursorPositionHdl.Call(*this); }
1662 public:
1663 virtual void set_text(const OUString& rText) = 0;
1664 virtual OUString get_text() const = 0;
1665 virtual void set_width_chars(int nChars) = 0;
1666 virtual int get_width_chars() const = 0;
1667 // The maximum length of the entry. Use 0 for no maximum
1668 virtual void set_max_length(int nChars) = 0;
1669 // nEndPos can be -1 in order to select all text
1670 virtual void select_region(int nStartPos, int nEndPos) = 0;
1671 // returns true if the selection has nonzero length
1672 virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) = 0;
1673 virtual void replace_selection(const OUString& rText) = 0;
1674 // nCursorPos can be -1 to set to the end
1675 virtual void set_position(int nCursorPos) = 0;
1676 virtual int get_position() const = 0;
1677 virtual void set_editable(bool bEditable) = 0;
1678 virtual bool get_editable() const = 0;
1679 virtual void set_message_type(EntryMessageType eType) = 0;
1680 virtual void set_placeholder_text(const OUString& rText) = 0;
1682 virtual void set_overwrite_mode(bool bOn) = 0;
1683 virtual bool get_overwrite_mode() const = 0;
1685 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
1686 virtual void set_font(const vcl::Font& rFont) = 0;
1689 If you want to set a warning or error state, see set_message_type
1690 instead where, if the toolkit supports it, a specific warning/error
1691 indicator is shown.
1693 This explicit text color method exists to support rendering the
1694 SvNumberformat color feature.
1696 virtual void set_font_color(const Color& rColor) = 0;
1698 virtual void connect_changed(const Link<Entry&, void>& rLink) { m_aChangeHdl = rLink; }
1699 void connect_insert_text(const Link<OUString&, bool>& rLink) { m_aInsertTextHdl = rLink; }
1700 // callback returns true to indicated no further processing of activate wanted
1701 void connect_activate(const Link<Entry&, bool>& rLink) { m_aActivateHdl = rLink; }
1702 virtual void connect_cursor_position(const Link<Entry&, void>& rLink)
1704 m_aCursorPositionHdl = rLink;
1707 virtual void cut_clipboard() = 0;
1708 virtual void copy_clipboard() = 0;
1709 virtual void paste_clipboard() = 0;
1711 virtual void set_alignment(TxtAlign eXAlign) = 0;
1713 void save_value() { m_sSavedValue = get_text(); }
1714 OUString const& get_saved_value() const { return m_sSavedValue; }
1715 bool get_value_changed_from_saved() const { return m_sSavedValue != get_text(); }
1718 class VCL_DLLPUBLIC SpinButton : virtual public Entry
1720 friend class ::LOKTrigger;
1722 protected:
1723 Link<SpinButton&, void> m_aValueChangedHdl;
1724 Link<SpinButton&, void> m_aOutputHdl;
1725 Link<int*, bool> m_aInputHdl;
1727 void signal_value_changed() { m_aValueChangedHdl.Call(*this); }
1729 bool signal_output()
1731 if (!m_aOutputHdl.IsSet())
1732 return false;
1733 m_aOutputHdl.Call(*this);
1734 return true;
1737 TriState signal_input(int* result)
1739 if (!m_aInputHdl.IsSet())
1740 return TRISTATE_INDET;
1741 return m_aInputHdl.Call(result) ? TRISTATE_TRUE : TRISTATE_FALSE;
1744 public:
1745 virtual void set_value(sal_Int64 value) = 0;
1746 virtual sal_Int64 get_value() const = 0;
1747 virtual void set_range(sal_Int64 min, sal_Int64 max) = 0;
1748 virtual void get_range(sal_Int64& min, sal_Int64& max) const = 0;
1749 void set_min(sal_Int64 min)
1751 sal_Int64 dummy, max;
1752 get_range(dummy, max);
1753 set_range(min, max);
1755 void set_max(sal_Int64 max)
1757 sal_Int64 min, dummy;
1758 get_range(min, dummy);
1759 set_range(min, max);
1761 sal_Int64 get_min() const
1763 sal_Int64 min, dummy;
1764 get_range(min, dummy);
1765 return min;
1767 sal_Int64 get_max() const
1769 sal_Int64 dummy, max;
1770 get_range(dummy, max);
1771 return max;
1773 virtual void set_increments(int step, int page) = 0;
1774 virtual void get_increments(int& step, int& page) const = 0;
1775 virtual void set_digits(unsigned int digits) = 0;
1776 virtual unsigned int get_digits() const = 0;
1778 void connect_value_changed(const Link<SpinButton&, void>& rLink) { m_aValueChangedHdl = rLink; }
1780 void connect_output(const Link<SpinButton&, void>& rLink) { m_aOutputHdl = rLink; }
1781 void connect_input(const Link<int*, bool>& rLink) { m_aInputHdl = rLink; }
1783 sal_Int64 normalize(sal_Int64 nValue) const { return (nValue * Power10(get_digits())); }
1785 sal_Int64 denormalize(sal_Int64 nValue) const;
1787 static unsigned int Power10(unsigned int n);
1790 class EntryFormatter;
1792 // Similar to a SpinButton, but input and output formatting and range/value
1793 // are managed by a more complex Formatter which can support doubles.
1794 class VCL_DLLPUBLIC FormattedSpinButton : virtual public Entry
1796 protected:
1797 Link<FormattedSpinButton&, void> m_aValueChangedHdl;
1799 void signal_value_changed() { m_aValueChangedHdl.Call(*this); }
1801 public:
1802 virtual Formatter& GetFormatter() = 0;
1803 // does not take ownership, and so must be deregistered if pFormatter
1804 // is destroyed
1805 virtual void SetFormatter(weld::EntryFormatter* pFormatter) = 0;
1807 void connect_value_changed(const Link<FormattedSpinButton&, void>& rLink)
1809 m_aValueChangedHdl = rLink;
1812 private:
1813 friend class EntryFormatter;
1814 virtual void sync_range_from_formatter() = 0;
1815 virtual void sync_value_from_formatter() = 0;
1816 virtual void sync_increments_from_formatter() = 0;
1819 class VCL_DLLPUBLIC Image : virtual public Widget
1821 public:
1822 virtual void set_from_icon_name(const OUString& rIconName) = 0;
1823 virtual void set_image(VirtualDevice* pDevice) = 0;
1824 virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) = 0;
1827 class VCL_DLLPUBLIC Calendar : virtual public Widget
1829 protected:
1830 Link<Calendar&, void> m_aSelectedHdl;
1831 Link<Calendar&, void> m_aActivatedHdl;
1833 void signal_selected() { m_aSelectedHdl.Call(*this); }
1834 void signal_activated() { m_aActivatedHdl.Call(*this); }
1836 public:
1837 void connect_selected(const Link<Calendar&, void>& rLink) { m_aSelectedHdl = rLink; }
1838 void connect_activated(const Link<Calendar&, void>& rLink) { m_aActivatedHdl = rLink; }
1840 virtual void set_date(const Date& rDate) = 0;
1841 virtual Date get_date() const = 0;
1844 // an entry + treeview pair, where the entry autocompletes from the
1845 // treeview list, and selecting something in the list sets the
1846 // entry to that text, i.e. a visually exploded ComboBox
1847 class VCL_DLLPUBLIC EntryTreeView : virtual public ComboBox
1849 private:
1850 DECL_DLLPRIVATE_LINK(ClickHdl, weld::TreeView&, void);
1851 DECL_DLLPRIVATE_LINK(ModifyHdl, weld::Entry&, void);
1852 void EntryModifyHdl(const weld::Entry& rEntry);
1854 protected:
1855 std::unique_ptr<Entry> m_xEntry;
1856 std::unique_ptr<TreeView> m_xTreeView;
1858 public:
1859 EntryTreeView(std::unique_ptr<Entry> xEntry, std::unique_ptr<TreeView> xTreeView);
1861 virtual void insert_vector(const std::vector<weld::ComboBoxEntry>& rItems,
1862 bool bKeepExisting) override
1864 m_xTreeView->freeze();
1865 if (!bKeepExisting)
1866 m_xTreeView->clear();
1867 for (const auto& rItem : rItems)
1869 m_xTreeView->insert(-1, rItem.sString, rItem.sId.isEmpty() ? nullptr : &rItem.sId,
1870 rItem.sImage.isEmpty() ? nullptr : &rItem.sImage, nullptr);
1872 m_xTreeView->thaw();
1875 virtual void insert(int pos, const OUString& rStr, const OUString* pId,
1876 const OUString* pIconName, VirtualDevice* pImageSurface) override
1878 m_xTreeView->insert(pos, rStr, pId, pIconName, pImageSurface);
1881 virtual int get_count() const override { return m_xTreeView->n_children(); }
1882 virtual void clear() override { m_xTreeView->clear(); }
1884 //by index
1885 virtual int get_active() const override { return m_xTreeView->get_selected_index(); }
1886 virtual void set_active(int pos) override
1888 m_xTreeView->set_cursor(pos);
1889 m_xTreeView->select(pos);
1890 m_xEntry->set_text(m_xTreeView->get_selected_text());
1892 virtual void remove(int pos) override { m_xTreeView->remove(pos); }
1894 //by text
1895 virtual OUString get_active_text() const override { return m_xEntry->get_text(); }
1896 virtual OUString get_text(int pos) const override { return m_xTreeView->get_text(pos); }
1897 virtual int find_text(const OUString& rStr) const override
1899 return m_xTreeView->find_text(rStr);
1902 //by id
1903 virtual OUString get_active_id() const override { return m_xTreeView->get_selected_id(); }
1904 virtual void set_active_id(const OUString& rStr) override
1906 m_xTreeView->select_id(rStr);
1907 m_xEntry->set_text(m_xTreeView->get_selected_text());
1909 virtual OUString get_id(int pos) const override { return m_xTreeView->get_id(pos); }
1910 virtual void set_id(int pos, const OUString& rId) override { m_xTreeView->set_id(pos, rId); }
1911 virtual int find_id(const OUString& rId) const override { return m_xTreeView->find_id(rId); }
1913 //entry related
1914 virtual bool has_entry() const override { return true; }
1915 virtual void set_entry_message_type(EntryMessageType eType) override
1917 m_xEntry->set_message_type(eType);
1919 virtual void set_entry_text(const OUString& rStr) override { m_xEntry->set_text(rStr); }
1920 virtual void set_entry_width_chars(int nChars) override { m_xEntry->set_width_chars(nChars); }
1921 virtual void set_entry_max_length(int nChars) override { m_xEntry->set_max_length(nChars); }
1922 virtual void select_entry_region(int nStartPos, int nEndPos) override
1924 m_xEntry->select_region(nStartPos, nEndPos);
1926 //if no text was selected, both rStartPos and rEndPos will be identical
1927 //and false will be returned
1928 virtual bool get_entry_selection_bounds(int& rStartPos, int& rEndPos) override
1930 return m_xEntry->get_selection_bounds(rStartPos, rEndPos);
1932 void connect_row_activated(const Link<TreeView&, bool>& rLink)
1934 m_xTreeView->connect_row_activated(rLink);
1937 virtual bool get_popup_shown() const override { return false; }
1939 void set_height_request_by_rows(int nRows);
1942 class VCL_DLLPUBLIC MetricSpinButton final
1944 FieldUnit m_eSrcUnit;
1945 std::unique_ptr<weld::SpinButton> m_xSpinButton;
1946 Link<MetricSpinButton&, void> m_aValueChangedHdl;
1948 DECL_LINK(spin_button_value_changed, weld::SpinButton&, void);
1949 DECL_LINK(spin_button_output, weld::SpinButton&, void);
1950 DECL_LINK(spin_button_input, int* result, bool);
1952 void signal_value_changed() { m_aValueChangedHdl.Call(*this); }
1954 sal_Int64 ConvertValue(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit) const;
1955 OUString format_number(sal_Int64 nValue) const;
1956 void update_width_chars();
1958 public:
1959 MetricSpinButton(std::unique_ptr<SpinButton> pSpinButton, FieldUnit eSrcUnit)
1960 : m_eSrcUnit(eSrcUnit)
1961 , m_xSpinButton(std::move(pSpinButton))
1963 update_width_chars();
1964 m_xSpinButton->connect_output(LINK(this, MetricSpinButton, spin_button_output));
1965 m_xSpinButton->connect_input(LINK(this, MetricSpinButton, spin_button_input));
1966 m_xSpinButton->connect_value_changed(
1967 LINK(this, MetricSpinButton, spin_button_value_changed));
1968 spin_button_output(*m_xSpinButton);
1971 static OUString MetricToString(FieldUnit rUnit);
1973 FieldUnit get_unit() const { return m_eSrcUnit; }
1975 void set_unit(FieldUnit eUnit);
1977 sal_Int64 convert_value_to(sal_Int64 nValue, FieldUnit eValueUnit) const
1979 return ConvertValue(nValue, m_eSrcUnit, eValueUnit);
1982 sal_Int64 convert_value_from(sal_Int64 nValue, FieldUnit eValueUnit) const
1984 return ConvertValue(nValue, eValueUnit, m_eSrcUnit);
1987 void set_value(sal_Int64 nValue, FieldUnit eValueUnit)
1989 m_xSpinButton->set_value(convert_value_from(nValue, eValueUnit));
1992 sal_Int64 get_value(FieldUnit eDestUnit) const
1994 return convert_value_to(m_xSpinButton->get_value(), eDestUnit);
1997 // typically you only need to call this if set_text (e.g. with "") was
1998 // previously called to display some arbitrary text instead of the
1999 // formatted value and now you want to show it as formatted again
2000 void reformat() { spin_button_output(*m_xSpinButton); }
2002 void set_range(sal_Int64 min, sal_Int64 max, FieldUnit eValueUnit)
2004 min = convert_value_from(min, eValueUnit);
2005 max = convert_value_from(max, eValueUnit);
2006 m_xSpinButton->set_range(min, max);
2007 update_width_chars();
2010 void get_range(sal_Int64& min, sal_Int64& max, FieldUnit eDestUnit) const
2012 m_xSpinButton->get_range(min, max);
2013 min = convert_value_to(min, eDestUnit);
2014 max = convert_value_to(max, eDestUnit);
2017 void set_min(sal_Int64 min, FieldUnit eValueUnit)
2019 sal_Int64 dummy, max;
2020 get_range(dummy, max, eValueUnit);
2021 set_range(min, max, eValueUnit);
2024 void set_max(sal_Int64 max, FieldUnit eValueUnit)
2026 sal_Int64 min, dummy;
2027 get_range(min, dummy, eValueUnit);
2028 set_range(min, max, eValueUnit);
2031 sal_Int64 get_min(FieldUnit eValueUnit) const
2033 sal_Int64 min, dummy;
2034 get_range(min, dummy, eValueUnit);
2035 return min;
2038 sal_Int64 get_max(FieldUnit eValueUnit) const
2040 sal_Int64 dummy, max;
2041 get_range(dummy, max, eValueUnit);
2042 return max;
2045 void set_increments(int step, int page, FieldUnit eValueUnit)
2047 step = convert_value_from(step, eValueUnit);
2048 page = convert_value_from(page, eValueUnit);
2049 m_xSpinButton->set_increments(step, page);
2052 void get_increments(int& step, int& page, FieldUnit eDestUnit) const
2054 m_xSpinButton->get_increments(step, page);
2055 step = convert_value_to(step, eDestUnit);
2056 page = convert_value_to(page, eDestUnit);
2059 void connect_value_changed(const Link<MetricSpinButton&, void>& rLink)
2061 m_aValueChangedHdl = rLink;
2064 sal_Int64 normalize(sal_Int64 nValue) const { return m_xSpinButton->normalize(nValue); }
2065 sal_Int64 denormalize(sal_Int64 nValue) const { return m_xSpinButton->denormalize(nValue); }
2066 void set_sensitive(bool sensitive) { m_xSpinButton->set_sensitive(sensitive); }
2067 bool get_sensitive() const { return m_xSpinButton->get_sensitive(); }
2068 bool get_visible() const { return m_xSpinButton->get_visible(); }
2069 void grab_focus() { m_xSpinButton->grab_focus(); }
2070 bool has_focus() const { return m_xSpinButton->has_focus(); }
2071 void show() { m_xSpinButton->show(); }
2072 void set_visible(bool bShow) { m_xSpinButton->set_visible(bShow); }
2073 void hide() { m_xSpinButton->hide(); }
2074 void set_digits(unsigned int digits);
2075 void set_accessible_name(const OUString& rName) { m_xSpinButton->set_accessible_name(rName); }
2076 unsigned int get_digits() const { return m_xSpinButton->get_digits(); }
2077 void save_value() { m_xSpinButton->save_value(); }
2078 bool get_value_changed_from_saved() const
2080 return m_xSpinButton->get_value_changed_from_saved();
2082 void set_text(const OUString& rText) { m_xSpinButton->set_text(rText); }
2083 OUString get_text() const { return m_xSpinButton->get_text(); }
2084 void set_size_request(int nWidth, int nHeight)
2086 m_xSpinButton->set_size_request(nWidth, nHeight);
2088 Size get_size_request() const { return m_xSpinButton->get_size_request(); }
2089 Size get_preferred_size() const { return m_xSpinButton->get_preferred_size(); }
2090 void connect_focus_in(const Link<Widget&, void>& rLink)
2092 m_xSpinButton->connect_focus_in(rLink);
2094 void connect_focus_out(const Link<Widget&, void>& rLink)
2096 m_xSpinButton->connect_focus_out(rLink);
2098 OString get_buildable_name() const { return m_xSpinButton->get_buildable_name(); }
2099 void set_help_id(const OString& rName) { m_xSpinButton->set_help_id(rName); }
2100 void set_position(int nCursorPos) { m_xSpinButton->set_position(nCursorPos); }
2101 // set the width of the underlying widget in characters, this setting is
2102 // invalidated when changing the units, range or digits, so to have effect
2103 // must come after changing those values
2104 void set_width_chars(int nChars) { m_xSpinButton->set_width_chars(nChars); }
2105 int get_width_chars() const { return m_xSpinButton->get_width_chars(); }
2106 weld::SpinButton& get_widget() { return *m_xSpinButton; }
2109 enum class LabelType
2111 Normal,
2112 Warning,
2113 Error,
2114 Title, // this is intended to be used against the background set by set_title_background
2117 class VCL_DLLPUBLIC Label : virtual public Widget
2119 public:
2120 virtual void set_label(const OUString& rText) = 0;
2121 virtual OUString get_label() const = 0;
2122 virtual void set_mnemonic_widget(Widget* pTarget) = 0;
2123 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
2124 virtual void set_font(const vcl::Font& rFont) = 0;
2125 virtual void set_label_type(LabelType eType) = 0;
2127 If you want to set a warning or error state, see set_label_type
2128 instead.
2130 virtual void set_font_color(const Color& rColor) = 0;
2133 class VCL_DLLPUBLIC TextView : virtual public Widget
2135 friend class ::LOKTrigger;
2137 private:
2138 OUString m_sSavedValue;
2140 protected:
2141 Link<TextView&, void> m_aChangeHdl;
2142 Link<TextView&, void> m_aVChangeHdl;
2143 Link<TextView&, void> m_aCursorPositionHdl;
2145 void signal_changed() { m_aChangeHdl.Call(*this); }
2146 void signal_cursor_position() { m_aCursorPositionHdl.Call(*this); }
2147 void signal_vadjustment_changed() { m_aVChangeHdl.Call(*this); }
2149 public:
2150 virtual void set_text(const OUString& rText) = 0;
2151 virtual OUString get_text() const = 0;
2152 // if nStartPos or nEndPos is -1 the max available text pos will be used
2153 virtual void select_region(int nStartPos, int nEndPos) = 0;
2154 // returns true if the selection has nonzero length
2155 virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) = 0;
2156 virtual void replace_selection(const OUString& rText) = 0;
2157 virtual void set_editable(bool bEditable) = 0;
2158 virtual bool get_editable() const = 0;
2159 virtual void set_monospace(bool bMonospace) = 0;
2160 // The maximum length of the entry. Use 0 for no maximum
2161 virtual void set_max_length(int nChars) = 0;
2162 int get_height_rows(int nRows) const
2164 //can improve this if needed
2165 return get_text_height() * nRows;
2168 // font size is in points, not pixels, e.g. see Window::[G]etPointFont
2169 virtual void set_font(const vcl::Font& rFont) = 0;
2172 Typically you want to avoid the temptation of customizing
2173 font colors
2175 virtual void set_font_color(const Color& rColor) = 0;
2177 void save_value() { m_sSavedValue = get_text(); }
2178 bool get_value_changed_from_saved() const { return m_sSavedValue != get_text(); }
2180 void connect_changed(const Link<TextView&, void>& rLink) { m_aChangeHdl = rLink; }
2181 virtual void connect_cursor_position(const Link<TextView&, void>& rLink)
2183 m_aCursorPositionHdl = rLink;
2186 // returns true if pressing up would move the cursor
2187 // doesn't matter if that move is to a previous line or to the start of the
2188 // current line just so long as the cursor would move
2189 virtual bool can_move_cursor_with_up() const = 0;
2191 // returns true if pressing down would move the cursor
2192 // doesn't matter if that move is to a next line or to the end of the
2193 // current line just so long as the cursor would move
2194 virtual bool can_move_cursor_with_down() const = 0;
2196 virtual void cut_clipboard() = 0;
2197 virtual void copy_clipboard() = 0;
2198 virtual void paste_clipboard() = 0;
2200 virtual void set_alignment(TxtAlign eXAlign) = 0;
2202 virtual int vadjustment_get_value() const = 0;
2203 virtual int vadjustment_get_upper() const = 0;
2204 virtual int vadjustment_get_lower() const = 0;
2205 virtual int vadjustment_get_page_size() const = 0;
2206 virtual void vadjustment_set_value(int value) = 0;
2207 void connect_vadjustment_changed(const Link<TextView&, void>& rLink) { m_aVChangeHdl = rLink; }
2210 class VCL_DLLPUBLIC Expander : virtual public Widget
2212 protected:
2213 Link<Expander&, void> m_aExpandedHdl;
2215 void signal_expanded() { m_aExpandedHdl.Call(*this); }
2217 public:
2218 virtual void set_label(const OUString& rText) = 0;
2219 virtual OUString get_label() const = 0;
2220 virtual bool get_expanded() const = 0;
2221 virtual void set_expanded(bool bExpand) = 0;
2223 void connect_expanded(const Link<Expander&, void>& rLink) { m_aExpandedHdl = rLink; }
2226 class VCL_DLLPUBLIC DrawingArea : virtual public Widget
2228 public:
2229 typedef std::pair<vcl::RenderContext&, const tools::Rectangle&> draw_args;
2231 protected:
2232 Link<draw_args, void> m_aDrawHdl;
2233 Link<Widget&, void> m_aStyleUpdatedHdl;
2234 Link<const CommandEvent&, bool> m_aCommandHdl;
2235 Link<Widget&, tools::Rectangle> m_aGetFocusRectHdl;
2236 Link<tools::Rectangle&, OUString> m_aQueryTooltipHdl;
2237 // if handler returns true, drag is disallowed
2238 Link<DrawingArea&, bool> m_aDragBeginHdl;
2239 // return position of cursor, fill OUString& with surrounding text
2240 Link<OUString&, int> m_aGetSurroundingHdl;
2241 // attempt to delete the range, return true if successful
2242 Link<const Selection&, bool> m_aDeleteSurroundingHdl;
2244 OUString signal_query_tooltip(tools::Rectangle& rHelpArea)
2246 return m_aQueryTooltipHdl.Call(rHelpArea);
2249 int signal_im_context_get_surrounding(OUString& rSurroundingText)
2251 if (!m_aGetSurroundingHdl.IsSet())
2252 return -1;
2253 return m_aGetSurroundingHdl.Call(rSurroundingText);
2256 bool signal_im_context_delete_surrounding(const Selection& rRange)
2258 return m_aDeleteSurroundingHdl.Call(rRange);
2261 public:
2262 void connect_draw(const Link<draw_args, void>& rLink) { m_aDrawHdl = rLink; }
2263 void connect_style_updated(const Link<Widget&, void>& rLink) { m_aStyleUpdatedHdl = rLink; }
2264 void connect_command(const Link<const CommandEvent&, bool>& rLink) { m_aCommandHdl = rLink; }
2265 void connect_focus_rect(const Link<Widget&, tools::Rectangle>& rLink)
2267 m_aGetFocusRectHdl = rLink;
2269 void connect_query_tooltip(const Link<tools::Rectangle&, OUString>& rLink)
2271 m_aQueryTooltipHdl = rLink;
2273 void connect_drag_begin(const Link<DrawingArea&, bool>& rLink) { m_aDragBeginHdl = rLink; }
2274 void connect_im_context_get_surrounding(const Link<OUString&, int>& rLink)
2276 m_aGetSurroundingHdl = rLink;
2278 void connect_im_context_delete_surrounding(const Link<const Selection&, bool>& rLink)
2280 m_aDeleteSurroundingHdl = rLink;
2282 virtual void queue_draw() = 0;
2283 virtual void queue_draw_area(int x, int y, int width, int height) = 0;
2285 virtual void enable_drag_source(rtl::Reference<TransferDataContainer>& rTransferrable,
2286 sal_uInt8 eDNDConstants)
2287 = 0;
2289 virtual void set_cursor(PointerStyle ePointerStyle) = 0;
2291 virtual Point get_pointer_position() const = 0;
2293 virtual void set_input_context(const InputContext& rInputContext) = 0;
2294 virtual void im_context_set_cursor_location(const tools::Rectangle& rCursorRect,
2295 int nExtTextInputWidth)
2296 = 0;
2298 // use return here just to generate matching VirtualDevices
2299 virtual OutputDevice& get_ref_device() = 0;
2301 virtual a11yref get_accessible_parent() = 0;
2302 virtual a11yrelationset get_accessible_relation_set() = 0;
2303 virtual Point get_accessible_location_on_screen() = 0;
2305 private:
2306 friend class ::LOKTrigger;
2308 virtual void click(const Point& rPos) = 0;
2311 enum class Placement
2313 Under,
2317 class VCL_DLLPUBLIC Menu
2319 protected:
2320 Link<const OString&, void> m_aActivateHdl;
2322 void signal_activate(const OString& rIdent) { m_aActivateHdl.Call(rIdent); }
2324 public:
2325 virtual OString popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect,
2326 Placement ePlace = Placement::Under)
2327 = 0;
2329 void connect_activate(const Link<const OString&, void>& rLink) { m_aActivateHdl = rLink; }
2331 virtual void set_sensitive(const OString& rIdent, bool bSensitive) = 0;
2332 virtual bool get_sensitive(const OString& rIdent) const = 0;
2333 virtual void set_label(const OString& rIdent, const OUString& rLabel) = 0;
2334 virtual OUString get_label(const OString& rIdent) const = 0;
2335 virtual void set_active(const OString& rIdent, bool bActive) = 0;
2336 virtual bool get_active(const OString& rIdent) const = 0;
2337 virtual void set_visible(const OString& rIdent, bool bVisible) = 0;
2339 virtual void insert(int pos, const OUString& rId, const OUString& rStr,
2340 const OUString* pIconName, VirtualDevice* pImageSurface,
2341 const css::uno::Reference<css::graphic::XGraphic>& rImage,
2342 TriState eCheckRadioFalse)
2343 = 0;
2345 virtual void remove(const OString& rId) = 0;
2347 virtual void clear() = 0;
2349 virtual void insert_separator(int pos, const OUString& rId) = 0;
2350 void append_separator(const OUString& rId) { insert_separator(-1, rId); }
2352 void append(const OUString& rId, const OUString& rStr)
2354 insert(-1, rId, rStr, nullptr, nullptr, nullptr, TRISTATE_INDET);
2356 void append_check(const OUString& rId, const OUString& rStr)
2358 insert(-1, rId, rStr, nullptr, nullptr, nullptr, TRISTATE_TRUE);
2360 void append_radio(const OUString& rId, const OUString& rStr)
2362 insert(-1, rId, rStr, nullptr, nullptr, nullptr, TRISTATE_FALSE);
2364 void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
2366 insert(-1, rId, rStr, &rImage, nullptr, nullptr, TRISTATE_INDET);
2368 void append(const OUString& rId, const OUString& rStr, VirtualDevice& rImage)
2370 insert(-1, rId, rStr, nullptr, &rImage, nullptr, TRISTATE_INDET);
2373 // return the number of toplevel nodes
2374 virtual int n_children() const = 0;
2376 virtual OString get_id(int pos) const = 0;
2378 virtual ~Menu() {}
2381 class VCL_DLLPUBLIC Popover : virtual public Container
2383 friend class ::LOKTrigger;
2385 private:
2386 Link<weld::Popover&, void> m_aCloseHdl;
2388 protected:
2389 void signal_closed() { m_aCloseHdl.Call(*this); }
2391 public:
2392 virtual void popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect,
2393 Placement ePlace = Placement::Under)
2394 = 0;
2395 virtual void popdown() = 0;
2397 virtual void resize_to_request() = 0;
2399 void connect_closed(const Link<weld::Popover&, void>& rLink) { m_aCloseHdl = rLink; }
2402 class VCL_DLLPUBLIC Toolbar : virtual public Widget
2404 protected:
2405 Link<const OString&, void> m_aClickHdl;
2406 Link<const OString&, void> m_aToggleMenuHdl;
2408 friend class ::LOKTrigger;
2410 void signal_clicked(const OString& rIdent) { m_aClickHdl.Call(rIdent); }
2411 void signal_toggle_menu(const OString& rIdent) { m_aToggleMenuHdl.Call(rIdent); }
2413 public:
2414 virtual void set_item_sensitive(const OString& rIdent, bool bSensitive) = 0;
2415 virtual bool get_item_sensitive(const OString& rIdent) const = 0;
2416 virtual void set_item_active(const OString& rIdent, bool bActive) = 0;
2417 virtual bool get_item_active(const OString& rIdent) const = 0;
2418 virtual void set_menu_item_active(const OString& rIdent, bool bActive) = 0;
2419 virtual bool get_menu_item_active(const OString& rIdent) const = 0;
2420 virtual void set_item_menu(const OString& rIdent, weld::Menu* pMenu) = 0;
2421 virtual void set_item_popover(const OString& rIdent, weld::Widget* pPopover) = 0;
2422 virtual void set_item_visible(const OString& rIdent, bool bVisible) = 0;
2423 virtual void set_item_help_id(const OString& rIdent, const OString& rHelpId) = 0;
2424 virtual bool get_item_visible(const OString& rIdent) const = 0;
2425 virtual void set_item_label(const OString& rIdent, const OUString& rLabel) = 0;
2426 virtual OUString get_item_label(const OString& rIdent) const = 0;
2427 virtual void set_item_tooltip_text(const OString& rIdent, const OUString& rTip) = 0;
2428 virtual OUString get_item_tooltip_text(const OString& rIdent) const = 0;
2429 virtual void set_item_icon_name(const OString& rIdent, const OUString& rIconName) = 0;
2430 virtual void set_item_image(const OString& rIdent,
2431 const css::uno::Reference<css::graphic::XGraphic>& rIcon)
2432 = 0;
2433 virtual void set_item_image(const OString& rIdent, VirtualDevice* pDevice) = 0;
2435 virtual void insert_item(int pos, const OUString& rId) = 0;
2436 virtual void insert_separator(int pos, const OUString& rId) = 0;
2437 void append_separator(const OUString& rId) { insert_separator(-1, rId); }
2439 virtual int get_n_items() const = 0;
2440 virtual OString get_item_ident(int nIndex) const = 0;
2441 virtual void set_item_ident(int nIndex, const OString& rIdent) = 0;
2442 virtual void set_item_label(int nIndex, const OUString& rLabel) = 0;
2443 virtual void set_item_image(int nIndex,
2444 const css::uno::Reference<css::graphic::XGraphic>& rIcon)
2445 = 0;
2446 virtual void set_item_tooltip_text(int nIndex, const OUString& rTip) = 0;
2448 virtual vcl::ImageType get_icon_size() const = 0;
2449 virtual void set_icon_size(vcl::ImageType eType) = 0;
2451 // return what modifiers are held
2452 virtual sal_uInt16 get_modifier_state() const = 0;
2454 // This function returns the position a new item should be inserted if dnd
2455 // is dropped at rPoint
2456 virtual int get_drop_index(const Point& rPoint) const = 0;
2458 void connect_clicked(const Link<const OString&, void>& rLink) { m_aClickHdl = rLink; }
2459 void connect_menu_toggled(const Link<const OString&, void>& rLink) { m_aToggleMenuHdl = rLink; }
2462 class VCL_DLLPUBLIC SizeGroup
2464 public:
2465 virtual void add_widget(weld::Widget* pWidget) = 0;
2466 // the default mode is VclSizeGroupMode::Horizontal
2467 virtual void set_mode(VclSizeGroupMode eMode) = 0;
2468 virtual ~SizeGroup() {}
2471 class VCL_DLLPUBLIC Builder
2473 public:
2474 virtual std::unique_ptr<MessageDialog> weld_message_dialog(const OString& id) = 0;
2475 virtual std::unique_ptr<Dialog> weld_dialog(const OString& id) = 0;
2476 virtual std::unique_ptr<Assistant> weld_assistant(const OString& id) = 0;
2477 virtual std::unique_ptr<Widget> weld_widget(const OString& id) = 0;
2478 virtual std::unique_ptr<Container> weld_container(const OString& id) = 0;
2479 virtual std::unique_ptr<Box> weld_box(const OString& id) = 0;
2480 virtual std::unique_ptr<Paned> weld_paned(const OString& id) = 0;
2481 virtual std::unique_ptr<Button> weld_button(const OString& id) = 0;
2482 virtual std::unique_ptr<MenuButton> weld_menu_button(const OString& id) = 0;
2483 virtual std::unique_ptr<MenuToggleButton> weld_menu_toggle_button(const OString& id) = 0;
2484 virtual std::unique_ptr<Frame> weld_frame(const OString& id) = 0;
2485 /* bUserManagedScrolling of true means that the automatic scrolling of the window is disabled
2486 and the owner must specifically listen to adjustment changes and react appropriately to them.
2488 virtual std::unique_ptr<ScrolledWindow> weld_scrolled_window(const OString& id,
2489 bool bUserManagedScrolling = false)
2490 = 0;
2491 virtual std::unique_ptr<Notebook> weld_notebook(const OString& id) = 0;
2492 virtual std::unique_ptr<ToggleButton> weld_toggle_button(const OString& id) = 0;
2493 virtual std::unique_ptr<RadioButton> weld_radio_button(const OString& id) = 0;
2494 virtual std::unique_ptr<CheckButton> weld_check_button(const OString& id) = 0;
2495 virtual std::unique_ptr<LinkButton> weld_link_button(const OString& id) = 0;
2496 virtual std::unique_ptr<SpinButton> weld_spin_button(const OString& id) = 0;
2497 virtual std::unique_ptr<MetricSpinButton> weld_metric_spin_button(const OString& id,
2498 FieldUnit eUnit)
2499 = 0;
2500 virtual std::unique_ptr<FormattedSpinButton> weld_formatted_spin_button(const OString& id) = 0;
2501 virtual std::unique_ptr<ComboBox> weld_combo_box(const OString& id) = 0;
2502 virtual std::unique_ptr<TreeView> weld_tree_view(const OString& id) = 0;
2503 virtual std::unique_ptr<IconView> weld_icon_view(const OString& id) = 0;
2504 virtual std::unique_ptr<Label> weld_label(const OString& id) = 0;
2505 virtual std::unique_ptr<TextView> weld_text_view(const OString& id) = 0;
2506 virtual std::unique_ptr<Expander> weld_expander(const OString& id) = 0;
2507 virtual std::unique_ptr<Entry> weld_entry(const OString& id) = 0;
2508 virtual std::unique_ptr<Scale> weld_scale(const OString& id) = 0;
2509 virtual std::unique_ptr<ProgressBar> weld_progress_bar(const OString& id) = 0;
2510 virtual std::unique_ptr<Spinner> weld_spinner(const OString& id) = 0;
2511 virtual std::unique_ptr<Image> weld_image(const OString& id) = 0;
2512 virtual std::unique_ptr<Calendar> weld_calendar(const OString& id) = 0;
2513 virtual std::unique_ptr<DrawingArea>
2514 weld_drawing_area(const OString& id, const a11yref& rA11yImpl = nullptr,
2515 FactoryFunction pUITestFactoryFunction = nullptr, void* pUserData = nullptr)
2516 = 0;
2517 virtual std::unique_ptr<EntryTreeView> weld_entry_tree_view(const OString& containerid,
2518 const OString& entryid,
2519 const OString& treeviewid)
2520 = 0;
2521 virtual std::unique_ptr<Menu> weld_menu(const OString& id) = 0;
2522 virtual std::unique_ptr<Popover> weld_popover(const OString& id) = 0;
2523 virtual std::unique_ptr<Toolbar> weld_toolbar(const OString& id) = 0;
2524 virtual std::unique_ptr<SizeGroup> create_size_group() = 0;
2525 /* return a Dialog suitable to take a screenshot of containing the contents of the .ui file.
2527 If the toplevel element is a dialog, that will be returned
2528 If the toplevel is not a dialog, a dialog will be created and the contents of the .ui
2529 inserted into it
2531 virtual std::unique_ptr<Window> create_screenshot_window() = 0;
2532 virtual ~Builder() {}
2535 class VCL_DLLPUBLIC DialogController : public std::enable_shared_from_this<DialogController>
2537 public:
2538 virtual Dialog* getDialog() = 0;
2539 const Dialog* getConstDialog() const
2541 return const_cast<DialogController*>(this)->getDialog();
2543 virtual short run() { return getDialog()->run(); }
2544 static bool runAsync(const std::shared_ptr<DialogController>& rController,
2545 const std::function<void(sal_Int32)>&);
2546 void set_title(const OUString& rTitle) { getDialog()->set_title(rTitle); }
2547 OUString get_title() const { return getConstDialog()->get_title(); }
2548 void set_help_id(const OString& rHelpId) { getDialog()->set_help_id(rHelpId); }
2549 OString get_help_id() const { return getConstDialog()->get_help_id(); }
2550 void response(int nResponse) { getDialog()->response(nResponse); }
2551 virtual ~DialogController() COVERITY_NOEXCEPT_FALSE;
2554 class VCL_DLLPUBLIC GenericDialogController : public DialogController
2556 protected:
2557 std::unique_ptr<weld::Builder> m_xBuilder;
2558 std::shared_ptr<weld::Dialog> m_xDialog;
2560 public:
2561 GenericDialogController(weld::Widget* pParent, const OUString& rUIFile,
2562 const OString& rDialogId, bool bMobile = false);
2563 virtual Dialog* getDialog() override;
2564 virtual ~GenericDialogController() COVERITY_NOEXCEPT_FALSE override;
2567 class VCL_DLLPUBLIC MessageDialogController : public DialogController
2569 protected:
2570 std::unique_ptr<weld::Builder> m_xBuilder;
2571 std::unique_ptr<weld::MessageDialog> m_xDialog;
2572 std::unique_ptr<weld::Container> m_xContentArea;
2573 std::unique_ptr<weld::Widget> m_xRelocate;
2574 std::unique_ptr<weld::Container> m_xOrigParent;
2576 public:
2577 /* @param rRelocateId - optional argument of the name of a widget in the .ui file
2578 which should be relocated into the content area of the dialog.
2580 e.g. a checkbox for a "Never show this again" option.
2582 This results in the named widget relocating to the same container
2583 as the messages. This enables aligning the extra widget with the
2584 message labels in the content area container which doesn't
2585 explicitly exist in the ui description, but is only implied.
2587 MessageDialogController(weld::Widget* pParent, const OUString& rUIFile,
2588 const OString& rDialogId, const OString& rRelocateId = OString());
2589 virtual Dialog* getDialog() override;
2590 virtual ~MessageDialogController() override;
2591 void set_primary_text(const OUString& rText) { m_xDialog->set_primary_text(rText); }
2592 OUString get_primary_text() const { return m_xDialog->get_primary_text(); }
2593 void set_default_response(int nResponse) { m_xDialog->set_default_response(nResponse); }
2596 class VCL_DLLPUBLIC AssistantController : public DialogController
2598 protected:
2599 std::unique_ptr<weld::Builder> m_xBuilder;
2600 std::unique_ptr<weld::Assistant> m_xAssistant;
2602 public:
2603 AssistantController(weld::Widget* pParent, const OUString& rUIFile, const OString& rDialogId);
2604 virtual Dialog* getDialog() override;
2605 virtual ~AssistantController() override;
2608 #endif
2610 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */