Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/weld.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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
 */
9
10
#pragma once
11
12
#include <basegfx/range/b2irange.hxx>
13
#include <rtl/ustring.hxx>
14
#include <tools/color.hxx>
15
#include <tools/date.hxx>
16
#include <tools/fldunit.hxx>
17
#include <tools/gen.hxx>
18
#include <tools/link.hxx>
19
#include <vcl/dllapi.h>
20
#include <utility>
21
#include <vcl/vclenum.hxx>
22
#include <vcl/font.hxx>
23
#include <vcl/vclptr.hxx>
24
#include <vcl/uitest/factory.hxx>
25
#include <vcl/windowstate.hxx>
26
27
#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
28
#include <com/sun/star/accessibility/XAccessible.hpp>
29
30
#include <assert.h>
31
#include <memory>
32
#include <vector>
33
34
namespace com::sun::star::awt
35
{
36
class XWindow;
37
}
38
namespace com::sun::star::datatransfer::clipboard
39
{
40
class XClipboard;
41
}
42
namespace com::sun::star::datatransfer::dnd
43
{
44
class XDropTarget;
45
}
46
namespace com::sun::star::graphic
47
{
48
class XGraphic;
49
}
50
namespace comphelper
51
{
52
class OAccessible;
53
}
54
typedef css::uno::Reference<css::accessibility::XAccessibleRelationSet> a11yrelationset;
55
enum class PointerStyle;
56
class CommandEvent;
57
class Formatter;
58
class InputContext;
59
class KeyEvent;
60
class MouseEvent;
61
class TransferDataContainer;
62
class OutputDevice;
63
class VirtualDevice;
64
struct SystemEnvData;
65
class Bitmap;
66
67
namespace vcl
68
{
69
class ILibreOfficeKitNotifier;
70
typedef OutputDevice RenderContext;
71
}
72
namespace tools
73
{
74
class JsonWriter;
75
}
76
77
class LOKTrigger;
78
79
namespace weld
80
{
81
class Container;
82
class DialogController;
83
84
class VCL_DLLPUBLIC Widget
85
{
86
    friend class ::LOKTrigger;
87
88
    int m_nBlockNotify = 0;
89
90
protected:
91
    Link<Widget&, void> m_aFocusInHdl;
92
    Link<Widget&, void> m_aFocusOutHdl;
93
    Link<Widget&, bool> m_aMnemonicActivateHdl;
94
    Link<Widget&, void> m_aStyleUpdatedHdl;
95
    Link<const Size&, void> m_aSizeAllocateHdl;
96
    Link<const KeyEvent&, bool> m_aKeyPressHdl;
97
    Link<const KeyEvent&, bool> m_aKeyReleaseHdl;
98
    Link<const MouseEvent&, bool> m_aMousePressHdl;
99
    Link<const MouseEvent&, bool> m_aMouseMotionHdl;
100
    Link<const MouseEvent&, bool> m_aMouseReleaseHdl;
101
102
0
    void disable_notify_events() { ++m_nBlockNotify; }
103
0
    bool notify_events_disabled() const { return m_nBlockNotify != 0; }
104
0
    void enable_notify_events() { --m_nBlockNotify; }
105
106
0
    void signal_focus_in() { m_aFocusInHdl.Call(*this); }
107
0
    void signal_focus_out() { m_aFocusOutHdl.Call(*this); }
108
0
    bool signal_mnemonic_activate() { return m_aMnemonicActivateHdl.Call(*this); }
109
0
    void signal_style_updated() { m_aStyleUpdatedHdl.Call(*this); }
110
0
    void signal_size_allocate(const Size& rSize) { m_aSizeAllocateHdl.Call(rSize); }
111
0
    bool signal_key_press(const KeyEvent& rKeyEvent) { return m_aKeyPressHdl.Call(rKeyEvent); }
112
0
    bool signal_key_release(const KeyEvent& rKeyEvent) { return m_aKeyReleaseHdl.Call(rKeyEvent); }
113
    bool signal_mouse_press(const MouseEvent& rMouseEvent)
114
0
    {
115
0
        return m_aMousePressHdl.Call(rMouseEvent);
116
0
    }
117
    bool signal_mouse_motion(const MouseEvent& rMouseEvent)
118
0
    {
119
0
        return m_aMouseMotionHdl.Call(rMouseEvent);
120
0
    }
121
    bool signal_mouse_release(const MouseEvent& rMouseEvent)
122
0
    {
123
0
        return m_aMouseReleaseHdl.Call(rMouseEvent);
124
0
    }
125
126
public:
127
    virtual void set_sensitive(bool sensitive) = 0;
128
    virtual bool get_sensitive() const = 0;
129
130
    /* visibility */
131
132
    virtual void show() = 0;
133
    virtual void hide() = 0;
134
135
    // This function simply calls show() or hide() but is convenient when the
136
    // visibility depends on some condition
137
    virtual void set_visible(bool visible)
138
0
    {
139
0
        if (visible)
140
0
            show();
141
0
        else
142
0
            hide();
143
0
    }
144
145
    // return if this widget's visibility is true
146
    virtual bool get_visible() const = 0;
147
148
    // return if this widget's visibility and that of all its parents is true
149
    virtual bool is_visible() const = 0;
150
151
    /* focus */
152
153
    // sets if this widget can own the keyboard focus
154
    virtual void set_can_focus(bool bCanFocus) = 0;
155
156
    // causes this widget to have the keyboard focus
157
    virtual void grab_focus() = 0;
158
159
    // returns if this widget has the keyboard focus
160
    virtual bool has_focus() const = 0;
161
162
    // if the widget that has focus is a child, which includes toplevel popup
163
    // children, of this widget. So an Entry with an active popup (or dialog)
164
    // has has_child_focus of true, but has_focus of false, while its popup is
165
    // shown
166
    virtual bool has_child_focus() const = 0;
167
168
    // return if this widget has the keyboard focus within the active window
169
    // TODO: review if this has any practical difference from has_focus()
170
    virtual bool is_active() const = 0;
171
172
    /* size */
173
    virtual void set_size_request(int nWidth, int nHeight) = 0;
174
    virtual Size get_size_request() const = 0;
175
    virtual Size get_preferred_size() const = 0;
176
177
    /* measure */
178
    virtual float get_approximate_digit_width() const = 0;
179
    virtual int get_text_height() const = 0;
180
    virtual Size get_pixel_size(const OUString& rText) const = 0;
181
182
    // The name of the widget in the GtkBuilder UI definition used to construct it.
183
    virtual OUString get_buildable_name() const = 0;
184
    /*
185
       Typically there is no need to change the buildable name at runtime, changing
186
       the id in .ui file itself is preferred.
187
188
       But for ui-testing purposes it can sometimes be useful to rename
189
       different widgets, that were loaded from the same .ui, to unique names
190
       in order to distinguish between them
191
    */
192
    virtual void set_buildable_name(const OUString& rName) = 0;
193
194
    /*
195
      The help id of the widget used to identify help for this widget.
196
197
      By default the help id of a widget is a path-like sequence of (load-time)
198
      buildable-names from the widgets UI definition ancestor to this widget,
199
      e.g. grandparent/parent/widget.
200
201
      The default can be overwritten with set_help_id
202
    */
203
    virtual OUString get_help_id() const = 0;
204
    virtual void set_help_id(const OUString& rName) = 0;
205
206
    virtual void set_hexpand(bool bExpand) = 0;
207
    virtual bool get_hexpand() const = 0;
208
    virtual void set_vexpand(bool bExpand) = 0;
209
    virtual bool get_vexpand() const = 0;
210
211
    virtual void set_margin_top(int nMargin) = 0;
212
    virtual void set_margin_bottom(int nMargin) = 0;
213
    virtual void set_margin_start(int nMargin) = 0;
214
    virtual void set_margin_end(int nMargin) = 0;
215
216
    virtual int get_margin_top() const = 0;
217
    virtual int get_margin_bottom() const = 0;
218
    virtual int get_margin_start() const = 0;
219
    virtual int get_margin_end() const = 0;
220
221
    /*
222
     * Report the extents of this widget relative to the rRelative target widget.
223
     *
224
     * To succeed, both widgets must be realized, and must share a common toplevel.
225
     *
226
     * returns false if the relative extents could not be determined, e.g. if
227
     * either widget was not realized, or there was no common ancestor.
228
     * Otherwise true.
229
     */
230
    virtual bool get_extents_relative_to(const Widget& rRelative, int& x, int& y, int& width,
231
                                         int& height) const = 0;
232
233
    virtual void set_accessible_name(const OUString& rName) = 0;
234
    virtual void set_accessible_description(const OUString& rDescription) = 0;
235
    virtual OUString get_accessible_name() const = 0;
236
237
    virtual OUString get_accessible_description() const = 0;
238
239
    virtual OUString get_accessible_id() const = 0;
240
241
    // After this call this widget is only accessibility labelled by pLabel and
242
    // pLabel only accessibility labels this widget
243
    virtual void set_accessible_relation_labeled_by(weld::Widget* pLabel) = 0;
244
245
    virtual void set_tooltip_text(const OUString& rTip) = 0;
246
    virtual OUString get_tooltip_text() const = 0;
247
248
    virtual void set_cursor_data(void* pData) = 0;
249
250
    virtual void connect_focus_in(const Link<Widget&, void>& rLink)
251
0
    {
252
0
        assert(!m_aFocusInHdl.IsSet() || !rLink.IsSet());
253
0
        m_aFocusInHdl = rLink;
254
0
    }
255
256
    virtual void connect_focus_out(const Link<Widget&, void>& rLink)
257
0
    {
258
0
        assert(!m_aFocusOutHdl.IsSet() || !rLink.IsSet());
259
0
        m_aFocusOutHdl = rLink;
260
0
    }
261
262
    // rLink is called when the mnemonic for the Widget is called.
263
    // If rLink returns true the Widget will not automatically gain
264
    // focus as normally occurs
265
    virtual void connect_mnemonic_activate(const Link<Widget&, bool>& rLink)
266
0
    {
267
0
        assert(!m_aMnemonicActivateHdl.IsSet() || !rLink.IsSet());
268
0
        m_aMnemonicActivateHdl = rLink;
269
0
    }
270
271
    virtual void connect_size_allocate(const Link<const Size&, void>& rLink)
272
0
    {
273
0
        assert(!m_aSizeAllocateHdl.IsSet() || !rLink.IsSet());
274
0
        m_aSizeAllocateHdl = rLink;
275
0
    }
276
277
    virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink)
278
0
    {
279
0
        assert(!m_aKeyPressHdl.IsSet() || !rLink.IsSet());
280
0
        m_aKeyPressHdl = rLink;
281
0
    }
282
283
    virtual void connect_key_release(const Link<const KeyEvent&, bool>& rLink)
284
0
    {
285
0
        assert(!m_aKeyReleaseHdl.IsSet() || !rLink.IsSet());
286
0
        m_aKeyReleaseHdl = rLink;
287
0
    }
288
289
    virtual void connect_mouse_press(const Link<const MouseEvent&, bool>& rLink)
290
0
    {
291
0
        assert(!m_aMousePressHdl.IsSet() || !rLink.IsSet());
292
0
        m_aMousePressHdl = rLink;
293
0
    }
294
295
    virtual void connect_mouse_move(const Link<const MouseEvent&, bool>& rLink)
296
0
    {
297
0
        assert(!m_aMouseMotionHdl.IsSet() || !rLink.IsSet());
298
0
        m_aMouseMotionHdl = rLink;
299
0
    }
300
301
    virtual void connect_mouse_release(const Link<const MouseEvent&, bool>& rLink)
302
0
    {
303
0
        assert(!m_aMouseReleaseHdl.IsSet() || !rLink.IsSet());
304
0
        m_aMouseReleaseHdl = rLink;
305
0
    }
306
307
    virtual void connect_style_updated(const Link<Widget&, void>& rLink)
308
0
    {
309
0
        assert(!m_aStyleUpdatedHdl.IsSet() || !rLink.IsSet());
310
0
        m_aStyleUpdatedHdl = rLink;
311
0
    }
312
313
    virtual void grab_mouse() = 0;
314
    virtual bool has_mouse_grab() const = 0;
315
    virtual void release_mouse() = 0;
316
317
    // font size is in points, not pixels, e.g. see Window::[G]etPointFont
318
    virtual vcl::Font get_font() = 0;
319
320
    //true for rtl, false otherwise
321
    virtual bool get_direction() const = 0;
322
    virtual void set_direction(bool bRTL) = 0;
323
324
    /* Increases the freeze count on widget.
325
326
       If the freeze count is non-zero, emission of the widget's notifications
327
       is stopped. The notifications are queued until the freeze count is
328
       decreased to zero. Duplicate notifications may be squashed together.
329
    */
330
    virtual void freeze() = 0;
331
332
    /* Reverts the effect of a previous call to freeze.
333
334
       The freeze count is decreased on the widget and when it reaches zero,
335
       queued notifications are emitted.
336
    */
337
    virtual void thaw() = 0;
338
339
    /* push/pop busy mouse cursor state
340
341
      bBusy of true to push a busy state onto the stack and false
342
      to pop it off, calls to this should balance.
343
344
      see weld::WaitObject */
345
    virtual void set_busy_cursor(bool bBusy) = 0;
346
347
    virtual void queue_resize() = 0;
348
349
    virtual std::unique_ptr<Container> weld_parent() const = 0;
350
351
    //iterate upwards through the hierarchy starting at this widgets parent,
352
    //calling func with their helpid until func returns true or we run out of
353
    //parents
354
    virtual void help_hierarchy_foreach(const std::function<bool(const OUString&)>& func) = 0;
355
356
    virtual OUString strip_mnemonic(const OUString& rLabel) const = 0;
357
358
    /* Escapes string contents which are interpreted by the UI.
359
360
       Should be overwritten by each VCL implementation to account for the
361
       string contents which are interpreted by its ui.
362
    */
363
    virtual OUString escape_ui_str(const OUString& rLabel) const = 0;
364
365
    virtual VclPtr<VirtualDevice> create_virtual_device() const = 0;
366
367
    //do something transient to attract the attention of the user to the widget
368
    virtual void call_attention_to() = 0;
369
370
    //make this widget look like a page in a notebook
371
    virtual void set_stack_background() = 0;
372
    //make this widget look like it has a highlighted background
373
    virtual void set_highlight_background() = 0;
374
    //make this widget suitable as parent for a title
375
    virtual void set_title_background() = 0;
376
    //make this widget suitable for use in a toolbar
377
    virtual void set_toolbar_background() = 0;
378
    //trying to use a custom color for a background is generally a bad idea. If your need
379
    //fits one of the above categories then that's a somewhat better choice
380
    virtual void set_background(const Color& rBackColor) = 0;
381
    // reset to default background
382
    virtual void set_background() = 0;
383
384
    virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() = 0;
385
    virtual css::uno::Reference<css::datatransfer::clipboard::XClipboard> get_clipboard() const = 0;
386
387
    virtual void connect_get_property_tree(const Link<tools::JsonWriter&, void>& rLink) = 0;
388
    virtual void get_property_tree(tools::JsonWriter& rJsonWriter) = 0;
389
390
    // render the widget to an output device
391
    virtual void draw(OutputDevice& rOutput, const Point& rPos, const Size& rSizePixel) = 0;
392
393
83
    virtual ~Widget() {}
394
};
395
396
class VCL_DLLPUBLIC Container : virtual public Widget
397
{
398
    Link<Container&, void> m_aContainerFocusChangedHdl;
399
400
protected:
401
0
    void signal_container_focus_changed() { m_aContainerFocusChangedHdl.Call(*this); }
402
403
public:
404
    // remove from old container and add to new container in one go
405
    // new container can be null to just remove from old container
406
    virtual void move(weld::Widget* pWidget, weld::Container* pNewParent) = 0;
407
    // create an XWindow as a child of this container. The XWindow is
408
    // suitable to contain css::awt::XControl items
409
    virtual css::uno::Reference<css::awt::XWindow> CreateChildFrame() = 0;
410
    // rLink is called when the focus transitions from a widget outside the container
411
    // to a widget inside the container or vice versa
412
    virtual void connect_container_focus_changed(const Link<Container&, void>& rLink)
413
0
    {
414
0
        m_aContainerFocusChangedHdl = rLink;
415
0
    }
416
    // causes a child of the container to have the keyboard focus
417
    virtual void child_grab_focus() = 0;
418
};
419
420
class VCL_DLLPUBLIC Box : virtual public Container
421
{
422
public:
423
    // Moves child to a new position in the list of children
424
    virtual void reorder_child(weld::Widget* pWidget, int position) = 0;
425
    // Sort ok/cancel etc buttons in platform order
426
    virtual void sort_native_button_order() = 0;
427
};
428
429
class VCL_DLLPUBLIC Grid : virtual public Container
430
{
431
public:
432
    virtual void set_child_left_attach(weld::Widget& rWidget, int nAttach) = 0;
433
    virtual int get_child_left_attach(weld::Widget& rWidget) const = 0;
434
    virtual void set_child_column_span(weld::Widget& rWidget, int nCols) = 0;
435
    virtual void set_child_top_attach(weld::Widget& rWidget, int nAttach) = 0;
436
    virtual int get_child_top_attach(weld::Widget& rWidget) const = 0;
437
};
438
439
class VCL_DLLPUBLIC Paned : virtual public Widget
440
{
441
public:
442
    // set pixel position of divider
443
    virtual void set_position(int nPos) = 0;
444
    // get pixel position of divider
445
    virtual int get_position() const = 0;
446
};
447
448
class VCL_DLLPUBLIC ScrolledWindow : virtual public Widget
449
{
450
    friend class ::LOKTrigger;
451
452
    Link<ScrolledWindow&, void> m_aVValueChangeHdl;
453
    Link<ScrolledWindow&, void> m_aHValueChangeHdl;
454
455
protected:
456
0
    void signal_vadjustment_value_changed() { m_aVValueChangeHdl.Call(*this); }
457
0
    void signal_hadjustment_value_changed() { m_aHValueChangeHdl.Call(*this); }
458
459
public:
460
    virtual void hadjustment_configure(int value, int upper, int step_increment, int page_increment,
461
                                       int page_size)
462
        = 0;
463
    virtual int hadjustment_get_value() const = 0;
464
    virtual void hadjustment_set_value(int value) = 0;
465
    virtual int hadjustment_get_upper() const = 0;
466
    virtual void hadjustment_set_upper(int upper) = 0;
467
    virtual int hadjustment_get_page_size() const = 0;
468
    virtual void hadjustment_set_page_size(int size) = 0;
469
    virtual void hadjustment_set_page_increment(int size) = 0;
470
    virtual void hadjustment_set_step_increment(int size) = 0;
471
    virtual void set_hpolicy(VclPolicyType eHPolicy) = 0;
472
    virtual VclPolicyType get_hpolicy() const = 0;
473
    void connect_hadjustment_value_changed(const Link<ScrolledWindow&, void>& rLink)
474
0
    {
475
0
        m_aHValueChangeHdl = rLink;
476
0
    }
477
478
    virtual void vadjustment_configure(int value, int upper, int step_increment, int page_increment,
479
                                       int page_size)
480
        = 0;
481
    virtual int vadjustment_get_value() const = 0;
482
    virtual void vadjustment_set_value(int value) = 0;
483
    virtual int vadjustment_get_upper() const = 0;
484
    virtual void vadjustment_set_upper(int upper) = 0;
485
    virtual int vadjustment_get_page_size() const = 0;
486
    virtual void vadjustment_set_page_size(int size) = 0;
487
    virtual void vadjustment_set_page_increment(int size) = 0;
488
    virtual void vadjustment_set_step_increment(int size) = 0;
489
    virtual void set_vpolicy(VclPolicyType eVPolicy) = 0;
490
    virtual VclPolicyType get_vpolicy() const = 0;
491
    void connect_vadjustment_value_changed(const Link<ScrolledWindow&, void>& rLink)
492
0
    {
493
0
        m_aVValueChangeHdl = rLink;
494
0
    }
495
    virtual int get_scroll_thickness() const = 0;
496
    virtual void set_scroll_thickness(int nThickness) = 0;
497
498
    //trying to use custom color for a scrollbar is generally a bad idea.
499
    virtual void customize_scrollbars(const Color& rBackgroundColor, const Color& rShadowColor,
500
                                      const Color& rFaceColor)
501
        = 0;
502
};
503
504
class Label;
505
506
class VCL_DLLPUBLIC Frame : virtual public Container
507
{
508
public:
509
    virtual void set_label(const OUString& rText) = 0;
510
    virtual OUString get_label() const = 0;
511
};
512
513
class VCL_DLLPUBLIC Notebook : virtual public Widget
514
{
515
    friend class ::LOKTrigger;
516
517
protected:
518
    Link<const OUString&, bool> m_aLeavePageHdl;
519
    Link<const OUString&, void> m_aEnterPageHdl;
520
521
public:
522
    virtual int get_current_page() const = 0;
523
    virtual int get_page_index(const OUString& rIdent) const = 0;
524
    virtual OUString get_page_ident(int nPage) const = 0;
525
    virtual OUString get_current_page_ident() const = 0;
526
    virtual void set_current_page(int nPage) = 0;
527
    virtual void set_current_page(const OUString& rIdent) = 0;
528
    virtual void remove_page(const OUString& rIdent) = 0;
529
    virtual void insert_page(const OUString& rIdent, const OUString& rLabel, int nPos,
530
                             const OUString* pIconName = nullptr)
531
        = 0;
532
    void append_page(const OUString& rIdent, const OUString& rLabel,
533
                     const OUString* pIconName = nullptr)
534
0
    {
535
0
        insert_page(rIdent, rLabel, -1, pIconName);
536
0
    }
537
    virtual void set_tab_label_text(const OUString& rIdent, const OUString& rLabel) = 0;
538
    virtual OUString get_tab_label_text(const OUString& rIdent) const = 0;
539
    virtual void set_show_tabs(bool bShow) = 0;
540
    virtual int get_n_pages() const = 0;
541
    virtual weld::Container* get_page(const OUString& rIdent) const = 0;
542
543
0
    void connect_leave_page(const Link<const OUString&, bool>& rLink) { m_aLeavePageHdl = rLink; }
544
0
    void connect_enter_page(const Link<const OUString&, void>& rLink) { m_aEnterPageHdl = rLink; }
545
};
546
547
class VCL_DLLPUBLIC ScreenShotEntry
548
{
549
public:
550
    ScreenShotEntry(OUString aHelpId, const basegfx::B2IRange& rB2IRange)
551
0
        : msHelpId(std::move(aHelpId))
552
0
        , maB2IRange(rB2IRange)
553
0
    {
554
0
    }
555
556
0
    const basegfx::B2IRange& getB2IRange() const { return maB2IRange; }
557
558
0
    const OUString& GetHelpId() const { return msHelpId; }
559
560
private:
561
    OUString msHelpId;
562
    basegfx::B2IRange maB2IRange;
563
};
564
565
typedef std::vector<ScreenShotEntry> ScreenShotCollection;
566
567
class VCL_DLLPUBLIC Window : virtual public Container
568
{
569
protected:
570
    Link<Widget&, bool> m_aHelpRequestHdl;
571
572
public:
573
    virtual void set_title(const OUString& rTitle) = 0;
574
    virtual OUString get_title() const = 0;
575
    virtual void window_move(int x, int y) = 0;
576
    virtual bool get_resizable() const = 0;
577
    virtual Size get_size() const = 0;
578
    virtual Point get_position() const = 0;
579
    virtual AbsoluteScreenPixelRectangle get_monitor_workarea() const = 0;
580
581
    // returns whether the widget that has focus is within this Window
582
    // (its very possible to move this to weld::Container if that becomes
583
    // desirable)
584
    virtual bool has_toplevel_focus() const = 0;
585
    virtual void present() = 0;
586
587
    virtual void set_window_state(const OUString& rStr) = 0;
588
    virtual OUString get_window_state(vcl::WindowDataMask nMask) const = 0;
589
590
    virtual css::uno::Reference<css::awt::XWindow> GetXWindow() = 0;
591
592
0
    void connect_help(const Link<Widget&, bool>& rLink) { m_aHelpRequestHdl = rLink; }
593
594
    virtual SystemEnvData get_system_data() const = 0;
595
596
    virtual void resize_to_request() = 0;
597
598
    // collect positions of widgets and their help ids for screenshot purposes
599
    virtual ScreenShotCollection collect_screenshot_data() = 0;
600
601
    // render the widget to an output device
602
    virtual VclPtr<VirtualDevice> screenshot() = 0;
603
604
    virtual const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() = 0;
605
};
606
607
class VCL_DLLPUBLIC WaitObject
608
{
609
private:
610
    weld::Widget* m_pWindow;
611
612
public:
613
    WaitObject(weld::Widget* pWindow)
614
12.9k
        : m_pWindow(pWindow)
615
12.9k
    {
616
12.9k
        if (m_pWindow)
617
0
            m_pWindow->set_busy_cursor(true);
618
12.9k
    }
619
    ~WaitObject()
620
12.9k
    {
621
12.9k
        if (m_pWindow)
622
0
            m_pWindow->set_busy_cursor(false);
623
12.9k
    }
624
};
625
626
class Button;
627
628
class VCL_DLLPUBLIC Dialog : virtual public Window
629
{
630
private:
631
    friend DialogController;
632
    virtual bool runAsync(std::shared_ptr<DialogController> const& rxOwner,
633
                          const std::function<void(sal_Int32)>& func)
634
        = 0;
635
636
public:
637
    virtual void set_modal(bool bModal) = 0;
638
    virtual bool get_modal() const = 0;
639
640
    // center dialog on its parent
641
    //
642
    // bTrackGeometryRequests set to true tries to ensure the dialog will end
643
    // up still centered on its parent windows final size, taking into account
644
    // that there may currently be pending geometry requests for the parent not
645
    // yet processed by the underlying toolkit
646
    //
647
    // for e.g gtk this will means the dialog is always centered even when
648
    // resized, calling set_centered_on_parent with false will turn this
649
    // off again.
650
    virtual void set_centered_on_parent(bool bTrackGeometryRequests) = 0;
651
652
    virtual int run() = 0;
653
    // Run async without a controller
654
    // @param self - must point to this, to enforce that the dialog was created/held by a shared_ptr
655
    virtual bool runAsync(std::shared_ptr<Dialog> const& rxSelf,
656
                          const std::function<void(sal_Int32)>& func)
657
        = 0;
658
    virtual void response(int response) = 0;
659
    virtual void add_button(const OUString& rText, int response, const OUString& rHelpId = {}) = 0;
660
    virtual std::unique_ptr<Button> weld_button_for_response(int response) = 0;
661
    virtual std::unique_ptr<weld::Container> weld_content_area() = 0;
662
663
    // with pOld of null, automatically find the old default widget and unset
664
    // it, otherwise use as hint to the old default
665
    virtual void change_default_button(weld::Button* pOld, weld::Button* pNew) = 0;
666
    virtual bool is_default_button(const weld::Button* pCandidate) const = 0;
667
668
    virtual inline void set_default_response(int nResponse);
669
670
    // shrink the dialog down to shown just these widgets
671
    virtual void collapse(weld::Widget& rEdit, weld::Widget* pButton) = 0;
672
    // undo previous dialog collapse
673
    virtual void undo_collapse() = 0;
674
675
    virtual void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink)
676
        = 0;
677
};
678
679
class VCL_DLLPUBLIC MessageDialog : virtual public Dialog
680
{
681
public:
682
    virtual void set_primary_text(const OUString& rText) = 0;
683
    virtual OUString get_primary_text() const = 0;
684
    virtual void set_secondary_text(const OUString& rText) = 0;
685
    virtual OUString get_secondary_text() const = 0;
686
    virtual std::unique_ptr<Container> weld_message_area() = 0;
687
};
688
689
class VCL_DLLPUBLIC Assistant : virtual public Dialog
690
{
691
    Link<const OUString&, bool> m_aJumpPageHdl;
692
693
protected:
694
    bool signal_jump_page(const OUString& rIdent)
695
0
    {
696
0
        if (notify_events_disabled())
697
0
            return true;
698
0
        return m_aJumpPageHdl.Call(rIdent);
699
0
    }
700
701
    virtual void do_set_current_page(int nPage) = 0;
702
    virtual void do_set_current_page(const OUString& rIdent) = 0;
703
    virtual void do_set_page_index(const OUString& rIdent, int nIndex) = 0;
704
    virtual void do_set_page_title(const OUString& rIdent, const OUString& rTitle) = 0;
705
    virtual void do_set_page_sensitive(const OUString& rIdent, bool bSensitive) = 0;
706
707
public:
708
    virtual int get_current_page() const = 0;
709
    virtual int get_n_pages() const = 0;
710
    virtual OUString get_page_ident(int nPage) const = 0;
711
    virtual OUString get_current_page_ident() const = 0;
712
713
    void set_current_page(int nPage)
714
0
    {
715
0
        disable_notify_events();
716
0
        do_set_current_page(nPage);
717
0
        enable_notify_events();
718
0
    }
719
720
    void set_current_page(const OUString& rIdent)
721
0
    {
722
0
        disable_notify_events();
723
0
        do_set_current_page(rIdent);
724
0
        enable_notify_events();
725
0
    }
726
727
    // move the page rIdent to position nIndex
728
    void set_page_index(const OUString& rIdent, int nIndex)
729
0
    {
730
0
        disable_notify_events();
731
0
        do_set_page_index(rIdent, nIndex);
732
0
        enable_notify_events();
733
0
    }
734
735
    void set_page_title(const OUString& rIdent, const OUString& rTitle)
736
0
    {
737
0
        disable_notify_events();
738
0
        do_set_page_title(rIdent, rTitle);
739
0
        enable_notify_events();
740
0
    }
741
742
    virtual OUString get_page_title(const OUString& rIdent) const = 0;
743
744
    void set_page_sensitive(const OUString& rIdent, bool bSensitive)
745
0
    {
746
0
        disable_notify_events();
747
0
        do_set_page_sensitive(rIdent, bSensitive);
748
0
        enable_notify_events();
749
0
    }
750
751
    virtual weld::Container* append_page(const OUString& rIdent) = 0;
752
753
    virtual void set_page_side_help_id(const OUString& rHelpId) = 0;
754
755
    virtual void set_page_side_image(const OUString& rImage) = 0;
756
757
0
    void connect_jump_page(const Link<const OUString&, bool>& rLink) { m_aJumpPageHdl = rLink; }
758
};
759
760
inline OUString toId(const void* pValue)
761
0
{
762
0
    return OUString::number(reinterpret_cast<sal_uIntPtr>(pValue));
763
0
}
764
765
template <typename T> T fromId(const OUString& rValue)
766
0
{
767
0
    return reinterpret_cast<T>(rValue.toUInt64());
768
0
}
Unexecuted instantiation: psp::PPDValue* weld::fromId<psp::PPDValue*>(rtl::OUString const&)
Unexecuted instantiation: psp::PPDKey* weld::fromId<psp::PPDKey*>(rtl::OUString const&)
Unexecuted instantiation: ScOrcusXMLTreeParam::EntryData* weld::fromId<ScOrcusXMLTreeParam::EntryData*>(rtl::OUString const&)
Unexecuted instantiation: RedlinData* weld::fromId<RedlinData*>(rtl::OUString const&)
Unexecuted instantiation: ScFuncDesc const* weld::fromId<ScFuncDesc const*>(rtl::OUString const&)
Unexecuted instantiation: ScCheckListMenuControl::Action* weld::fromId<ScCheckListMenuControl::Action*>(rtl::OUString const&)
Unexecuted instantiation: ScItemValue* weld::fromId<ScItemValue*>(rtl::OUString const&)
Unexecuted instantiation: ScRedlinData* weld::fromId<ScRedlinData*>(rtl::OUString const&)
Unexecuted instantiation: ScSolverOptionsString* weld::fromId<ScSolverOptionsString*>(rtl::OUString const&)
Unexecuted instantiation: formula::IFunctionCategory const* weld::fromId<formula::IFunctionCategory const*>(rtl::OUString const&)
Unexecuted instantiation: formula::IFunctionDescription const* weld::fromId<formula::IFunctionDescription const*>(rtl::OUString const&)
Unexecuted instantiation: formula::FormulaToken const* weld::fromId<formula::FormulaToken const*>(rtl::OUString const&)
Unexecuted instantiation: DocumentModelTreeHandler.cxx:(anonymous namespace)::DocumentModelTreeEntry* weld::fromId<(anonymous namespace)::DocumentModelTreeEntry*>(rtl::OUString const&)
Unexecuted instantiation: ObjectInspectorTreeHandler.cxx:(anonymous namespace)::ObjectInspectorNodeInterface* weld::fromId<(anonymous namespace)::ObjectInspectorNodeInterface*>(rtl::OUString const&)
Unexecuted instantiation: newhelp.cxx:(anonymous namespace)::ContentEntry_Impl* weld::fromId<(anonymous namespace)::ContentEntry_Impl*>(rtl::OUString const&)
Unexecuted instantiation: newhelp.cxx:(anonymous namespace)::IndexEntry_Impl* weld::fromId<(anonymous namespace)::IndexEntry_Impl*>(rtl::OUString const&)
Unexecuted instantiation: SfxVersionInfo* weld::fromId<SfxVersionInfo*>(rtl::OUString const&)
Unexecuted instantiation: RedactionTarget* weld::fromId<RedactionTarget*>(rtl::OUString const&)
Unexecuted instantiation: ColumnInfo* weld::fromId<ColumnInfo*>(rtl::OUString const&)
Unexecuted instantiation: svxform::ItemNode* weld::fromId<svxform::ItemNode*>(rtl::OUString const&)
Unexecuted instantiation: FmEntryData* weld::fromId<FmEntryData*>(rtl::OUString const&)
Unexecuted instantiation: FmFormData* weld::fromId<FmFormData*>(rtl::OUString const&)
Unexecuted instantiation: FmControlData* weld::fromId<FmControlData*>(rtl::OUString const&)
Unexecuted instantiation: textconversiondlgs::DictionaryEntry* weld::fromId<textconversiondlgs::DictionaryEntry*>(rtl::OUString const&)
Unexecuted instantiation: chart::SeriesEntry* weld::fromId<chart::SeriesEntry*>(rtl::OUString const&)
Unexecuted instantiation: Subset const* weld::fromId<Subset const*>(rtl::OUString const&)
Unexecuted instantiation: SwTypeNumber const* weld::fromId<SwTypeNumber const*>(rtl::OUString const&)
Unexecuted instantiation: SwOutlineContent const* weld::fromId<SwOutlineContent const*>(rtl::OUString const&)
Unexecuted instantiation: SwRegionContent const* weld::fromId<SwRegionContent const*>(rtl::OUString const&)
Unexecuted instantiation: SwOutlineContent* weld::fromId<SwOutlineContent*>(rtl::OUString const&)
Unexecuted instantiation: SwContent* weld::fromId<SwContent*>(rtl::OUString const&)
Unexecuted instantiation: SwContentType* weld::fromId<SwContentType*>(rtl::OUString const&)
Unexecuted instantiation: void* weld::fromId<void*>(rtl::OUString const&)
Unexecuted instantiation: SwTOXBaseContent* weld::fromId<SwTOXBaseContent*>(rtl::OUString const&)
Unexecuted instantiation: SwPostItContent* weld::fromId<SwPostItContent*>(rtl::OUString const&)
Unexecuted instantiation: SwRegionContent* weld::fromId<SwRegionContent*>(rtl::OUString const&)
Unexecuted instantiation: SwTypeNumber* weld::fromId<SwTypeNumber*>(rtl::OUString const&)
Unexecuted instantiation: SwGlblDocContent const* weld::fromId<SwGlblDocContent const*>(rtl::OUString const&)
Unexecuted instantiation: SwGlblDocContent* weld::fromId<SwGlblDocContent*>(rtl::OUString const&)
Unexecuted instantiation: SdrObject* weld::fromId<SdrObject*>(rtl::OUString const&)
Unexecuted instantiation: std::__1::shared_ptr<sd::CustomAnimationPreset>* weld::fromId<std::__1::shared_ptr<sd::CustomAnimationPreset>*>(rtl::OUString const&)
Unexecuted instantiation: sd::TransitionEntry* weld::fromId<sd::TransitionEntry*>(rtl::OUString const&)
Unexecuted instantiation: sd::CustomAnimationListEntryItem* weld::fromId<sd::CustomAnimationListEntryItem*>(rtl::OUString const&)
769
770
struct VCL_DLLPUBLIC ComboBoxEntry
771
{
772
    OUString sString;
773
    OUString sId;
774
    OUString sImage;
775
    ComboBoxEntry(OUString _aString)
776
        : sString(std::move(_aString))
777
0
    {
778
0
    }
779
    ComboBoxEntry(OUString _aString, OUString _aId)
780
        : sString(std::move(_aString))
781
        , sId(std::move(_aId))
782
0
    {
783
0
    }
784
    ComboBoxEntry(OUString _aString, OUString _aId, OUString _aImage)
785
        : sString(std::move(_aString))
786
        , sId(std::move(_aId))
787
        , sImage(std::move(_aImage))
788
0
    {
789
0
    }
790
};
791
792
enum class EntryMessageType
793
{
794
    Normal,
795
    Warning,
796
    Error,
797
};
798
799
class Menu;
800
801
/// A widget used to choose from a list of items.
802
class VCL_DLLPUBLIC ComboBox : virtual public Widget
803
{
804
private:
805
    OUString m_sSavedValue;
806
    std::vector<OUString> m_aSavedValues;
807
808
public:
809
    // OUString is the id of the row, it may be null to measure the height of a generic line
810
    typedef std::tuple<vcl::RenderContext&, const tools::Rectangle&, bool, const OUString&>
811
        render_args;
812
813
protected:
814
    Link<ComboBox&, void> m_aChangeHdl;
815
    Link<ComboBox&, void> m_aPopupToggledHdl;
816
    Link<ComboBox&, bool> m_aEntryActivateHdl;
817
    Link<OUString&, bool> m_aEntryInsertTextHdl;
818
819
    friend class ::LOKTrigger;
820
821
0
    void signal_changed() { m_aChangeHdl.Call(*this); }
822
823
0
    virtual void signal_popup_toggled() { m_aPopupToggledHdl.Call(*this); }
824
825
    Link<render_args, void> m_aRenderHdl;
826
    void signal_custom_render(vcl::RenderContext& rDevice, const tools::Rectangle& rRect,
827
                              bool bSelected, const OUString& rId)
828
0
    {
829
0
        m_aRenderHdl.Call(render_args(rDevice, rRect, bSelected, rId));
830
0
    }
831
832
    Link<vcl::RenderContext&, Size> m_aGetSizeHdl;
833
0
    Size signal_custom_get_size(vcl::RenderContext& rDevice) { return m_aGetSizeHdl.Call(rDevice); }
834
835
public:
836
    virtual void insert(int pos, const OUString& rStr, const OUString* pId,
837
                        const OUString* pIconName, VirtualDevice* pImageSurface)
838
        = 0;
839
    virtual void insert_vector(const std::vector<weld::ComboBoxEntry>& rItems, bool bKeepExisting)
840
        = 0;
841
    void insert(int pos, const weld::ComboBoxEntry& rItem)
842
0
    {
843
0
        insert(pos, rItem.sString, rItem.sId.isEmpty() ? nullptr : &rItem.sId,
844
0
               rItem.sImage.isEmpty() ? nullptr : &rItem.sImage, nullptr);
845
0
    }
846
    void insert_text(int pos, const OUString& rStr)
847
0
    {
848
0
        insert(pos, rStr, nullptr, nullptr, nullptr);
849
0
    }
850
0
    void append(const weld::ComboBoxEntry& rItem) { insert(-1, rItem); }
851
0
    void append_text(const OUString& rStr) { insert(-1, rStr, nullptr, nullptr, nullptr); }
852
    void append(const OUString& rId, const OUString& rStr)
853
0
    {
854
0
        insert(-1, rStr, &rId, nullptr, nullptr);
855
0
    }
856
    void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
857
0
    {
858
0
        insert(-1, rStr, &rId, &rImage, nullptr);
859
0
    }
860
    void append(const OUString& rId, const OUString& rStr, VirtualDevice& rImage)
861
0
    {
862
0
        insert(-1, rStr, &rId, nullptr, &rImage);
863
0
    }
864
    void append(int pos, const OUString& rId, const OUString& rStr)
865
0
    {
866
0
        insert(pos, rStr, &rId, nullptr, nullptr);
867
0
    }
868
    virtual void insert_separator(int pos, const OUString& rId) = 0;
869
0
    void append_separator(const OUString& rId) { insert_separator(-1, rId); }
870
871
    virtual int get_count() const = 0;
872
    virtual void make_sorted() = 0;
873
    virtual void clear() = 0;
874
875
    //by index, returns -1 if nothing is selected
876
    virtual int get_active() const = 0;
877
    virtual void set_active(int pos) = 0;
878
    virtual void remove(int pos) = 0;
879
880
    //by text
881
    virtual OUString get_active_text() const = 0;
882
0
    void set_active_text(const OUString& rStr) { set_active(find_text(rStr)); }
883
    virtual OUString get_text(int pos) const = 0;
884
    virtual int find_text(const OUString& rStr) const = 0;
885
0
    void remove_text(const OUString& rText) { remove(find_text(rText)); }
886
887
    //by id
888
    virtual OUString get_active_id() const = 0;
889
    virtual void set_active_id(const OUString& rStr) = 0;
890
    virtual OUString get_id(int pos) const = 0;
891
    virtual void set_id(int row, const OUString& rId) = 0;
892
    virtual int find_id(const OUString& rId) const = 0;
893
0
    void remove_id(const OUString& rId) { remove(find_id(rId)); }
894
895
    /* m_aChangeHdl is called when the active item is changed. The can be due
896
       to the user selecting a different item from the list or while typing
897
       into the entry of a combo box with an entry.
898
899
       Use changed_by_direct_pick() to discover whether an item was actually explicitly
900
       selected, e.g. from the menu.
901
     */
902
0
    void connect_changed(const Link<ComboBox&, void>& rLink) { m_aChangeHdl = rLink; }
903
904
    virtual bool changed_by_direct_pick() const = 0;
905
906
    virtual void connect_popup_toggled(const Link<ComboBox&, void>& rLink)
907
0
    {
908
0
        m_aPopupToggledHdl = rLink;
909
0
    }
910
911
    //entry related
912
    virtual bool has_entry() const = 0;
913
    virtual void set_entry_message_type(EntryMessageType eType) = 0;
914
    virtual void set_entry_text(const OUString& rStr) = 0;
915
    virtual void set_entry_width_chars(int nChars) = 0;
916
    virtual void set_entry_max_length(int nChars) = 0;
917
    virtual void select_entry_region(int nStartPos, int nEndPos) = 0;
918
    virtual bool get_entry_selection_bounds(int& rStartPos, int& rEndPos) = 0;
919
    virtual void set_entry_completion(bool bEnable, bool bCaseSensitive = false) = 0;
920
    virtual void set_entry_placeholder_text(const OUString& rText) = 0;
921
    virtual void set_entry_editable(bool bEditable) = 0;
922
    virtual void cut_entry_clipboard() = 0;
923
    virtual void copy_entry_clipboard() = 0;
924
    virtual void paste_entry_clipboard() = 0;
925
926
    // font size is in points, not pixels, e.g. see Window::[G]etPointFont
927
    virtual void set_font(const vcl::Font& rFont) = 0;
928
929
    // font size is in points, not pixels, e.g. see Window::[G]etPointFont
930
    virtual void set_entry_font(const vcl::Font& rFont) = 0;
931
    virtual vcl::Font get_entry_font() = 0;
932
933
    virtual bool get_popup_shown() const = 0;
934
935
    void connect_entry_insert_text(const Link<OUString&, bool>& rLink)
936
0
    {
937
0
        m_aEntryInsertTextHdl = rLink;
938
0
    }
939
940
    // callback returns true to indicated no further processing of activate wanted
941
0
    void connect_entry_activate(const Link<ComboBox&, bool>& rLink) { m_aEntryActivateHdl = rLink; }
942
943
0
    void save_value() { m_sSavedValue = get_active_text(); }
944
945
    void save_values_by_id(const OUString& rId)
946
0
    {
947
0
        m_aSavedValues.push_back(get_text(find_id(rId)));
948
0
    }
949
950
0
    OUString const& get_saved_value() const { return m_sSavedValue; }
951
0
    OUString const& get_saved_values(int pos) const { return m_aSavedValues[pos]; }
952
0
    bool get_value_changed_from_saved() const { return m_sSavedValue != get_active_text(); }
953
    bool get_values_changed_from_saved() const
954
0
    {
955
0
        return !m_aSavedValues.empty()
956
0
               && std::find(m_aSavedValues.begin(), m_aSavedValues.end(), get_active_text())
957
0
                      == m_aSavedValues.end();
958
0
    }
959
960
0
    void removeSavedValues() { m_aSavedValues.clear(); }
961
962
    // for custom rendering a row
963
    void connect_custom_get_size(const Link<vcl::RenderContext&, Size>& rLink)
964
0
    {
965
0
        m_aGetSizeHdl = rLink;
966
0
    }
967
0
    void connect_custom_render(const Link<render_args, void>& rLink) { m_aRenderHdl = rLink; }
968
    // call set_custom_renderer after setting custom callbacks
969
    virtual void set_custom_renderer(bool bOn) = 0;
970
    // set a sub menu for a entry, only works with custom rendering
971
    virtual void set_item_menu(const OUString& rIdent, weld::Menu* pMenu) = 0;
972
    // get the width needed to show the menu launcher in a custom row
973
    virtual int get_menu_button_width() const = 0;
974
975
    // for mru support
976
    virtual int get_max_mru_count() const = 0;
977
    virtual void set_max_mru_count(int nCount) = 0;
978
    virtual OUString get_mru_entries() const = 0;
979
    virtual void set_mru_entries(const OUString& rEntries) = 0;
980
981
    // Backwards compatibility, should be avoided to allow
982
    // UI consistency.
983
    virtual void set_max_drop_down_rows(int nRows) = 0;
984
};
985
986
enum class ColumnToggleType
987
{
988
    Check,
989
    Radio
990
};
991
992
class VCL_DLLPUBLIC TreeIter
993
{
994
private:
995
    TreeIter(const TreeIter&) = delete;
996
    TreeIter& operator=(const TreeIter&) = delete;
997
998
public:
999
0
    TreeIter() {}
1000
    virtual bool equal(const TreeIter& rOther) const = 0;
1001
0
    virtual ~TreeIter() {}
1002
};
1003
1004
/* Model column indexes are considered to begin at 0, but with special columns
1005
   before index 0. A expander image column (and an additional optional toggle
1006
   button column when enable_toggle_buttons is used). Column index -1 is
1007
   reserved to access those columns.
1008
*/
1009
class VCL_DLLPUBLIC TreeView : virtual public Widget
1010
{
1011
    friend class ::LOKTrigger;
1012
1013
public:
1014
    typedef std::pair<const TreeIter&, int> iter_col;
1015
    typedef std::pair<const TreeIter&, OUString> iter_string;
1016
    // OUString is the id of the row, it may be null to measure the height of a generic line
1017
    typedef std::pair<vcl::RenderContext&, const OUString&> get_size_args;
1018
    typedef std::tuple<vcl::RenderContext&, const tools::Rectangle&, bool, const OUString&>
1019
        render_args;
1020
1021
private:
1022
    OUString m_sSavedValue;
1023
1024
protected:
1025
    Link<TreeView&, void> m_aSelectionChangedHdl;
1026
    Link<TreeView&, bool> m_aRowActivatedHdl;
1027
    Link<int, void> m_aColumnClickedHdl;
1028
    Link<const iter_col&, void> m_aRadioToggleHdl;
1029
    Link<const TreeIter&, bool> m_aEditingStartedHdl;
1030
    Link<const iter_string&, bool> m_aEditingDoneHdl;
1031
    // if handler returns false, the expansion of the row is refused
1032
    Link<const TreeIter&, bool> m_aExpandingHdl;
1033
    // if handler returns false, the collapse of the row is refused
1034
    Link<const TreeIter&, bool> m_aCollapsingHdl;
1035
    Link<TreeView&, void> m_aVisibleRangeChangedHdl;
1036
    Link<TreeView&, void> m_aModelChangedHdl;
1037
    // if handler returns true, then menu has been show and event is consumed
1038
    Link<const CommandEvent&, bool> m_aPopupMenuHdl;
1039
    // if handler returns true, drag is disallowed, consumer can change bool
1040
    // arg to false to disable the treeview default dnd icon
1041
    Link<bool&, bool> m_aDragBeginHdl;
1042
    std::function<int(const weld::TreeIter&, const weld::TreeIter&)> m_aCustomSort;
1043
1044
protected:
1045
    void signal_selection_changed()
1046
0
    {
1047
0
        if (notify_events_disabled())
1048
0
            return;
1049
0
        m_aSelectionChangedHdl.Call(*this);
1050
0
    }
1051
1052
    bool signal_row_activated()
1053
0
    {
1054
0
        if (notify_events_disabled())
1055
0
            return true;
1056
0
        return m_aRowActivatedHdl.Call(*this);
1057
0
    }
1058
1059
0
    void signal_column_clicked(int nColumn) { m_aColumnClickedHdl.Call(nColumn); }
1060
    bool signal_expanding(const TreeIter& rIter)
1061
0
    {
1062
0
        return !m_aExpandingHdl.IsSet() || m_aExpandingHdl.Call(rIter);
1063
0
    }
1064
    bool signal_collapsing(const TreeIter& rIter)
1065
0
    {
1066
0
        return !m_aCollapsingHdl.IsSet() || m_aCollapsingHdl.Call(rIter);
1067
0
    }
1068
    void signal_visible_range_changed()
1069
0
    {
1070
0
        if (notify_events_disabled())
1071
0
            return;
1072
0
        m_aVisibleRangeChangedHdl.Call(*this);
1073
0
    }
1074
1075
    void signal_model_changed()
1076
0
    {
1077
0
        if (notify_events_disabled())
1078
0
            return;
1079
0
        m_aModelChangedHdl.Call(*this);
1080
0
    }
1081
1082
0
    void signal_toggled(const iter_col& rIterCol) { m_aRadioToggleHdl.Call(rIterCol); }
1083
1084
0
    bool signal_editing_started(const TreeIter& rIter) { return m_aEditingStartedHdl.Call(rIter); }
1085
1086
    bool signal_editing_done(const iter_string& rIterText)
1087
0
    {
1088
0
        return m_aEditingDoneHdl.Call(rIterText);
1089
0
    }
1090
1091
0
    void signal_popup_menu(const CommandEvent& rCommand) { m_aPopupMenuHdl.Call(rCommand); }
1092
1093
    Link<const TreeIter&, OUString> m_aQueryTooltipHdl;
1094
1095
    OUString signal_query_tooltip(const TreeIter& rIter)
1096
0
    {
1097
0
        if (notify_events_disabled())
1098
0
            return {};
1099
0
        return m_aQueryTooltipHdl.Call(rIter);
1100
0
    }
1101
1102
    Link<render_args, void> m_aRenderHdl;
1103
    void signal_custom_render(vcl::RenderContext& rDevice, const tools::Rectangle& rRect,
1104
                              bool bSelected, const OUString& rId)
1105
0
    {
1106
0
        m_aRenderHdl.Call(render_args(rDevice, rRect, bSelected, rId));
1107
0
    }
1108
1109
    Link<get_size_args, Size> m_aGetSizeHdl;
1110
    Size signal_custom_get_size(vcl::RenderContext& rDevice, const OUString& rId)
1111
0
    {
1112
0
        return m_aGetSizeHdl.Call(get_size_args(rDevice, rId));
1113
0
    }
1114
1115
    virtual void do_insert(const TreeIter* pParent, int pos, const OUString* pStr,
1116
                           const OUString* pId, const OUString* pIconName,
1117
                           VirtualDevice* pImageSurface, bool bChildrenOnDemand, TreeIter* pRet)
1118
        = 0;
1119
    virtual void do_insert_separator(int pos, const OUString& rId) = 0;
1120
    virtual void do_select(int pos) = 0;
1121
    virtual void do_unselect(int pos) = 0;
1122
    virtual void do_remove(int pos) = 0;
1123
    virtual void do_scroll_to_row(int row) = 0;
1124
    virtual void do_set_cursor(int pos) = 0;
1125
    virtual void do_set_cursor(const TreeIter& rIter) = 0;
1126
    virtual void do_remove(const TreeIter& rIter) = 0;
1127
    virtual void do_select(const TreeIter& rIter) = 0;
1128
    virtual void do_unselect(const TreeIter& rIter) = 0;
1129
    virtual void do_scroll_to_row(const TreeIter& rIter) = 0;
1130
    virtual void do_set_children_on_demand(const TreeIter& rIter, bool bChildrenOnDemand) = 0;
1131
    virtual void do_clear() = 0;
1132
    virtual void do_remove_selection() = 0;
1133
1134
public:
1135
    virtual void connect_query_tooltip(const Link<const TreeIter&, OUString>& rLink)
1136
0
    {
1137
0
        assert(!m_aQueryTooltipHdl.IsSet() || !rLink.IsSet());
1138
0
        m_aQueryTooltipHdl = rLink;
1139
0
    }
1140
1141
    // see 'expanding on-demand node details' for bChildrenOnDemand of true
1142
    void insert(const TreeIter* pParent, int pos, const OUString* pStr, const OUString* pId,
1143
                const OUString* pIconName, VirtualDevice* pImageSurface, bool bChildrenOnDemand,
1144
                TreeIter* pRet)
1145
0
    {
1146
0
        disable_notify_events();
1147
0
        do_insert(pParent, pos, pStr, pId, pIconName, pImageSurface, bChildrenOnDemand, pRet);
1148
0
        enable_notify_events();
1149
0
    }
1150
1151
    void insert(int nRow, TreeIter* pRet = nullptr)
1152
0
    {
1153
0
        insert(nullptr, nRow, nullptr, nullptr, nullptr, nullptr, false, pRet);
1154
0
    }
1155
1156
0
    void append(TreeIter* pRet = nullptr) { insert(-1, pRet); }
1157
1158
    void insert(int pos, const OUString& rStr, const OUString* pId, const OUString* pIconName,
1159
                VirtualDevice* pImageSurface)
1160
0
    {
1161
0
        insert(nullptr, pos, &rStr, pId, pIconName, pImageSurface, false, nullptr);
1162
0
    }
1163
    void insert_text(int pos, const OUString& rStr)
1164
0
    {
1165
0
        insert(nullptr, pos, &rStr, nullptr, nullptr, nullptr, false, nullptr);
1166
0
    }
1167
    void append_text(const OUString& rStr)
1168
0
    {
1169
0
        insert(nullptr, -1, &rStr, nullptr, nullptr, nullptr, false, nullptr);
1170
0
    }
1171
    void append(const OUString& rId, const OUString& rStr)
1172
0
    {
1173
0
        insert(nullptr, -1, &rStr, &rId, nullptr, nullptr, false, nullptr);
1174
0
    }
1175
    void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
1176
0
    {
1177
0
        insert(nullptr, -1, &rStr, &rId, &rImage, nullptr, false, nullptr);
1178
0
    }
1179
    void append(const TreeIter* pParent, const OUString& rStr)
1180
0
    {
1181
0
        insert(pParent, -1, &rStr, nullptr, nullptr, nullptr, false, nullptr);
1182
0
    }
1183
1184
    void insert_separator(int pos, const OUString& rId)
1185
0
    {
1186
0
        disable_notify_events();
1187
0
        do_insert_separator(pos, rId);
1188
0
        enable_notify_events();
1189
0
    }
1190
1191
0
    void append_separator(const OUString& rId) { insert_separator(-1, rId); }
1192
1193
    void connect_selection_changed(const Link<TreeView&, void>& rLink)
1194
0
    {
1195
0
        m_aSelectionChangedHdl = rLink;
1196
0
    }
1197
1198
    /* A row is "activated" when the user double clicks a treeview row. It may
1199
       also be emitted when a row is selected and Space or Enter is pressed.
1200
1201
       a return of "true" means the activation has been handled, a "false" propagates
1202
       the activation to the default handler which expands/collapses the row, if possible.
1203
    */
1204
0
    void connect_row_activated(const Link<TreeView&, bool>& rLink) { m_aRowActivatedHdl = rLink; }
1205
1206
    // Argument is a pair of iter, col describing the toggled node
1207
0
    void connect_toggled(const Link<const iter_col&, void>& rLink) { m_aRadioToggleHdl = rLink; }
1208
1209
0
    void connect_column_clicked(const Link<int, void>& rLink) { m_aColumnClickedHdl = rLink; }
1210
0
    void connect_model_changed(const Link<TreeView&, void>& rLink) { m_aModelChangedHdl = rLink; }
1211
1212
    virtual OUString get_selected_text() const = 0;
1213
    virtual OUString get_selected_id() const = 0;
1214
1215
    // call before inserting any content and connecting to toggle signals,
1216
    // an pre-inserted checkbutton column will exist at the start of every row
1217
    // inserted after this call which can be accessed with col index -1
1218
    virtual void enable_toggle_buttons(ColumnToggleType eType) = 0;
1219
1220
    virtual void set_clicks_to_toggle(int nToggleBehavior) = 0;
1221
1222
    //by index
1223
    virtual int get_selected_index() const = 0;
1224
    //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1225
    void select(int pos)
1226
0
    {
1227
0
        disable_notify_events();
1228
0
        do_select(pos);
1229
0
        enable_notify_events();
1230
0
    }
1231
1232
    void unselect(int pos)
1233
0
    {
1234
0
        disable_notify_events();
1235
0
        do_unselect(pos);
1236
0
        enable_notify_events();
1237
0
    }
1238
1239
    void remove(int pos)
1240
0
    {
1241
0
        disable_notify_events();
1242
0
        do_remove(pos);
1243
0
        enable_notify_events();
1244
0
    }
1245
1246
    // col index -1 gets the first text column
1247
    virtual OUString get_text(int row, int col = -1) const = 0;
1248
    // col index -1 sets the first text column
1249
    virtual void set_text(int row, const OUString& rText, int col = -1) = 0;
1250
    // col index -1 sets all columns
1251
    virtual void set_sensitive(int row, bool bSensitive, int col = -1) = 0;
1252
    virtual bool get_sensitive(int row, int col) const = 0;
1253
    virtual void set_id(int row, const OUString& rId) = 0;
1254
    // col index -1 sets the expander toggle, enable_toggle_buttons must have been called to create that column
1255
    virtual void set_toggle(int row, TriState eState, int col = -1) = 0;
1256
    // col index -1 gets the expander toggle, enable_toggle_buttons must have been called to create that column
1257
    virtual TriState get_toggle(int row, int col = -1) const = 0;
1258
    // col index -1 sets the expander image
1259
    virtual void set_image(int row, const OUString& rImage, int col = -1) = 0;
1260
    // col index -1 sets the expander image
1261
    virtual void set_image(int row, VirtualDevice& rImage, int col = -1) = 0;
1262
    // col index -1 sets the expander image
1263
    virtual void set_image(int row, const css::uno::Reference<css::graphic::XGraphic>& rImage,
1264
                           int col = -1)
1265
        = 0;
1266
    virtual void set_text_emphasis(int row, bool bOn, int col) = 0;
1267
    virtual bool get_text_emphasis(int row, int col) const = 0;
1268
    virtual void set_text_align(int row, double fAlign, int col) = 0;
1269
    virtual void swap(int pos1, int pos2) = 0;
1270
    virtual std::vector<int> get_selected_rows() const = 0;
1271
    virtual void set_font_color(int pos, const Color& rColor) = 0;
1272
1273
    // scroll to make 'row' visible, this will also expand all parent rows of 'row' as necessary to
1274
    // make 'row' visible
1275
    void scroll_to_row(int row)
1276
0
    {
1277
0
        disable_notify_events();
1278
0
        do_scroll_to_row(row);
1279
0
        enable_notify_events();
1280
0
    }
1281
1282
    virtual bool is_selected(int pos) const = 0;
1283
    virtual int get_cursor_index() const = 0;
1284
1285
    void set_cursor(int pos)
1286
0
    {
1287
0
        disable_notify_events();
1288
0
        do_set_cursor(pos);
1289
0
        enable_notify_events();
1290
0
    }
1291
1292
    //by text
1293
    virtual int find_text(const OUString& rText) const = 0;
1294
    //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1295
0
    void select_text(const OUString& rText) { select(find_text(rText)); }
1296
0
    void remove_text(const OUString& rText) { remove(find_text(rText)); }
1297
    std::vector<OUString> get_selected_rows_text() const
1298
0
    {
1299
0
        std::vector<int> aRows(get_selected_rows());
1300
0
        std::vector<OUString> aRet;
1301
0
        aRet.reserve(aRows.size());
1302
0
        for (auto a : aRows)
1303
0
            aRet.push_back(get_text(a));
1304
0
        return aRet;
1305
0
    }
1306
1307
    //by id
1308
    virtual OUString get_id(int pos) const = 0;
1309
    virtual int find_id(const OUString& rId) const = 0;
1310
    //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1311
0
    void select_id(const OUString& rId) { select(find_id(rId)); }
1312
0
    void remove_id(const OUString& rText) { remove(find_id(rText)); }
1313
1314
    //via iter
1315
    virtual std::unique_ptr<TreeIter> make_iterator(const TreeIter* pOrig = nullptr) const = 0;
1316
    virtual void copy_iterator(const TreeIter& rSource, TreeIter& rDest) const = 0;
1317
    virtual bool get_selected(TreeIter* pIter) const = 0;
1318
    virtual bool get_cursor(TreeIter* pIter) const = 0;
1319
1320
    void set_cursor(const TreeIter& rIter)
1321
0
    {
1322
0
        disable_notify_events();
1323
0
        do_set_cursor(rIter);
1324
0
        enable_notify_events();
1325
0
    }
1326
1327
    virtual bool get_iter_first(TreeIter& rIter) const = 0;
1328
    // set iter to point to next node at the current level
1329
    virtual bool iter_next_sibling(TreeIter& rIter) const = 0;
1330
    // set iter to point to previous node at the current level
1331
    virtual bool iter_previous_sibling(TreeIter& rIter) const = 0;
1332
    // set iter to point to next node, depth first, then sibling
1333
    virtual bool iter_next(TreeIter& rIter) const = 0;
1334
    // set iter to point to previous node, sibling first then depth
1335
    virtual bool iter_previous(TreeIter& rIter) const = 0;
1336
    // set iter to point to first child node
1337
    virtual bool iter_children(TreeIter& rIter) const = 0;
1338
    bool iter_nth_sibling(TreeIter& rIter, int nChild) const
1339
0
    {
1340
0
        bool bRet = true;
1341
0
        for (int i = 0; i < nChild && bRet; ++i)
1342
0
            bRet = iter_next_sibling(rIter);
1343
0
        return bRet;
1344
0
    }
1345
    bool iter_nth_child(TreeIter& rIter, int nChild) const
1346
0
    {
1347
0
        if (!iter_children(rIter))
1348
0
            return false;
1349
0
        return iter_nth_sibling(rIter, nChild);
1350
0
    }
1351
    virtual bool iter_parent(TreeIter& rIter) const = 0;
1352
    virtual int get_iter_depth(const TreeIter& rIter) const = 0;
1353
    virtual int get_iter_index_in_parent(const TreeIter& rIter) const = 0;
1354
    /* Compares two paths. If a appears before b in a tree, then -1 is returned.
1355
       If b appears before a , then 1 is returned. If the two nodes are equal,
1356
       then 0 is returned.
1357
    */
1358
    virtual int iter_compare(const TreeIter& a, const TreeIter& b) const = 0;
1359
    virtual bool iter_has_child(const TreeIter& rIter) const = 0;
1360
    // returns the number of direct children rIter has
1361
    virtual int iter_n_children(const TreeIter& rIter) const = 0;
1362
1363
    void remove(const TreeIter& rIter)
1364
0
    {
1365
0
        disable_notify_events();
1366
0
        do_remove(rIter);
1367
0
        enable_notify_events();
1368
0
    }
1369
1370
    //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1371
    void select(const TreeIter& rIter)
1372
0
    {
1373
0
        disable_notify_events();
1374
0
        do_select(rIter);
1375
0
        enable_notify_events();
1376
0
    }
1377
1378
    void unselect(const TreeIter& rIter)
1379
0
    {
1380
0
        disable_notify_events();
1381
0
        do_unselect(rIter);
1382
0
        enable_notify_events();
1383
0
    }
1384
1385
    //visually indent this row as if it was at get_iter_depth() + nIndentLevel
1386
    virtual void set_extra_row_indent(const TreeIter& rIter, int nIndentLevel) = 0;
1387
    // col index -1 sets the first text column
1388
    virtual void set_text(const TreeIter& rIter, const OUString& rStr, int col = -1) = 0;
1389
    // col index -1 sets all columns
1390
    virtual void set_sensitive(const TreeIter& rIter, bool bSensitive, int col = -1) = 0;
1391
    virtual bool get_sensitive(const TreeIter& rIter, int col) const = 0;
1392
    virtual void set_text_emphasis(const TreeIter& rIter, bool bOn, int col) = 0;
1393
    virtual bool get_text_emphasis(const TreeIter& rIter, int col) const = 0;
1394
    virtual void set_text_align(const TreeIter& rIter, double fAlign, int col) = 0;
1395
    // col index -1 sets the expander toggle, enable_toggle_buttons must have been called to create that column
1396
    virtual void set_toggle(const TreeIter& rIter, TriState bOn, int col = -1) = 0;
1397
    // col index -1 gets the expander toggle, enable_toggle_buttons must have been called to create that column
1398
    virtual TriState get_toggle(const TreeIter& rIter, int col = -1) const = 0;
1399
    // col index -1 gets the first text column
1400
    virtual OUString get_text(const TreeIter& rIter, int col = -1) const = 0;
1401
    virtual void set_id(const TreeIter& rIter, const OUString& rId) = 0;
1402
    virtual OUString get_id(const TreeIter& rIter) const = 0;
1403
    // col index -1 sets the expander image
1404
    virtual void set_image(const TreeIter& rIter, const OUString& rImage, int col = -1) = 0;
1405
    // col index -1 sets the expander image
1406
    virtual void set_image(const TreeIter& rIter, VirtualDevice& rImage, int col = -1) = 0;
1407
    // col index -1 sets the expander image
1408
    virtual void set_image(const TreeIter& rIter,
1409
                           const css::uno::Reference<css::graphic::XGraphic>& rImage, int col = -1)
1410
        = 0;
1411
    virtual void set_font_color(const TreeIter& rIter, const Color& rColor) = 0;
1412
1413
    // scroll to make rIter visible, this will also expand all parent rows of rIter as necessary to
1414
    // make rIter visible
1415
    void scroll_to_row(const TreeIter& rIter)
1416
0
    {
1417
0
        disable_notify_events();
1418
0
        do_scroll_to_row(rIter);
1419
0
        enable_notify_events();
1420
0
    }
1421
1422
    virtual bool is_selected(const TreeIter& rIter) const = 0;
1423
1424
    virtual void move_subtree(TreeIter& rNode, const TreeIter* pNewParent, int nIndexInNewParent)
1425
        = 0;
1426
1427
    // call func on each element until func returns true or we run out of elements
1428
    virtual void all_foreach(const std::function<bool(TreeIter&)>& func) = 0;
1429
    // call func on each selected element until func returns true or we run out of elements
1430
    virtual void selected_foreach(const std::function<bool(TreeIter&)>& func) = 0;
1431
    // call func on each visible element until func returns true or we run out of elements
1432
    virtual void visible_foreach(const std::function<bool(TreeIter&)>& func) = 0;
1433
    // clear the children of pParent (whole tree if nullptr),
1434
    // then add nSourceCount rows under pParent, call func on each row
1435
    // inserted with an arg of the index that this row will be when bulk insert
1436
    // ends.
1437
    //
1438
    // this enables inserting the entries backwards in models where that is faster,
1439
    //
1440
    // pFixedWidths is optional, when present each matching entry col text
1441
    // width will not be measured, and the fixed width used instead. Use
1442
    // sparingly because wider text than the fixed width is clipped and cannot
1443
    // be scrolled into view horizontally.
1444
    // @param bGoingToSetText needs to be true, if you plan to call set_text inside the insert func.
1445
    virtual void bulk_insert_for_each(int nSourceCount,
1446
                                      const std::function<void(TreeIter&, int nSourceIndex)>& func,
1447
                                      const weld::TreeIter* pParent = nullptr,
1448
                                      const std::vector<int>* pFixedWidths = nullptr,
1449
                                      bool bGoingToSetText = false)
1450
        = 0;
1451
1452
    /* expanding on-demand node details
1453
1454
    When a node is added with children-on-demand (typically via 'insert' with
1455
    bChildrenOnDemand of true), then initially in reality the
1456
    children-on-demand node is given a 'placeholder' child entry to indicate
1457
    the load-on-demand state.
1458
1459
    The 'placeholder' needs to be there for the expander indicator to be
1460
    drawn/shown even when there are no "real" entries yet. This child doesn't
1461
    exist for the purposes of any of the iterator methods, e.g. iter_has_child
1462
    on an on-demand node which hasn't been expanded yet is false. Likewise the
1463
    rest of the iterator methods skip over or otherwise ignore that node.
1464
1465
    Normal usage is the user clicks on the expander, the expansion mechanism
1466
    removes the 'placeholder' entry (set_children_on_demand(false)) and calls
1467
    any installed expanding-callback (installable via connect_expanding) which
1468
    has the opportunity to populate the node with children.
1469
1470
    If you decide to directly populate the children of an on-demand node
1471
    outside of the expanding-callback then you also need to explicitly remove
1472
    the 'placeholder' with set_children_on_demand(false) otherwise the treeview
1473
    is in an inconsistent state.  */
1474
1475
    virtual bool get_row_expanded(const TreeIter& rIter) const = 0;
1476
    // expand row will first trigger the callback set via connect_expanding before expanding
1477
    virtual void expand_row(const TreeIter& rIter) = 0;
1478
    // collapse row will first trigger the callback set via connect_collapsing before collapsing
1479
    virtual void collapse_row(const TreeIter& rIter) = 0;
1480
1481
    // set the empty node to appear as if it has children, true is equivalent
1482
    // to 'insert' with a bChildrenOnDemand of true. See notes above.
1483
    void set_children_on_demand(const TreeIter& rIter, bool bChildrenOnDemand)
1484
0
    {
1485
0
        disable_notify_events();
1486
0
        do_set_children_on_demand(rIter, bChildrenOnDemand);
1487
0
        enable_notify_events();
1488
0
    }
1489
1490
    // return if the node is configured to be populated on-demand
1491
    virtual bool get_children_on_demand(const TreeIter& rIter) const = 0;
1492
    // set if the expanders are shown or not
1493
    virtual void set_show_expanders(bool bShow) = 0;
1494
1495
0
    void connect_expanding(const Link<const TreeIter&, bool>& rLink) { m_aExpandingHdl = rLink; }
1496
0
    void connect_collapsing(const Link<const TreeIter&, bool>& rLink) { m_aCollapsingHdl = rLink; }
1497
1498
    // rStartLink returns true to allow editing, false to disallow
1499
    // rEndLink returns true to accept the edit, false to reject
1500
    virtual void connect_editing(const Link<const TreeIter&, bool>& rStartLink,
1501
                                 const Link<const iter_string&, bool>& rEndLink)
1502
0
    {
1503
0
        assert(rStartLink.IsSet() == rEndLink.IsSet() && "should be both on or both off");
1504
0
        m_aEditingStartedHdl = rStartLink;
1505
0
        m_aEditingDoneHdl = rEndLink;
1506
0
    }
1507
1508
    virtual void start_editing(const weld::TreeIter& rEntry) = 0;
1509
    virtual void end_editing() = 0;
1510
1511
    virtual void connect_visible_range_changed(const Link<TreeView&, void>& rLink)
1512
0
    {
1513
0
        assert(!m_aVisibleRangeChangedHdl.IsSet() || !rLink.IsSet());
1514
0
        m_aVisibleRangeChangedHdl = rLink;
1515
0
    }
1516
1517
    virtual void connect_popup_menu(const Link<const CommandEvent&, bool>& rLink)
1518
0
    {
1519
0
        m_aPopupMenuHdl = rLink;
1520
0
    }
1521
1522
    virtual void enable_drag_source(rtl::Reference<TransferDataContainer>& rTransferable,
1523
                                    sal_uInt8 eDNDConstants)
1524
        = 0;
1525
1526
0
    void connect_drag_begin(const Link<bool&, bool>& rLink) { m_aDragBeginHdl = rLink; }
1527
1528
    //all of them. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1529
    virtual void select_all() = 0;
1530
    virtual void unselect_all() = 0;
1531
1532
    // return the number of toplevel nodes
1533
    virtual int n_children() const = 0;
1534
1535
    // afterwards, entries will be in default ascending sort order
1536
    virtual void make_sorted() = 0;
1537
    virtual void make_unsorted() = 0;
1538
    virtual bool get_sort_order() const = 0;
1539
    virtual void set_sort_order(bool bAscending) = 0;
1540
1541
    // TRUE ascending, FALSE, descending, INDET, neither (off)
1542
    virtual void set_sort_indicator(TriState eState, int nColumn) = 0;
1543
    virtual TriState get_sort_indicator(int nColumn) const = 0;
1544
1545
    virtual int get_sort_column() const = 0;
1546
    virtual void set_sort_column(int nColumn) = 0;
1547
1548
    virtual void
1549
    set_sort_func(const std::function<int(const weld::TreeIter&, const weld::TreeIter&)>& func)
1550
0
    {
1551
0
        m_aCustomSort = func;
1552
0
    }
1553
1554
    void clear()
1555
0
    {
1556
0
        disable_notify_events();
1557
0
        do_clear();
1558
0
        enable_notify_events();
1559
0
    }
1560
1561
    virtual int get_height_rows(int nRows) const = 0;
1562
1563
    virtual void columns_autosize() = 0;
1564
    virtual void set_column_fixed_widths(const std::vector<int>& rWidths) = 0;
1565
    virtual void set_column_editables(const std::vector<bool>& rEditables) = 0;
1566
    virtual int get_column_width(int nCol) const = 0;
1567
    virtual void set_centered_column(int nCol) = 0;
1568
    virtual OUString get_column_title(int nColumn) const = 0;
1569
    virtual void set_column_title(int nColumn, const OUString& rTitle) = 0;
1570
1571
0
    int get_checkbox_column_width() const { return get_approximate_digit_width() * 3 + 6; }
1572
1573
    virtual void set_selection_mode(SelectionMode eMode) = 0;
1574
    virtual int count_selected_rows() const = 0;
1575
1576
    // remove the selected nodes
1577
    void remove_selection()
1578
0
    {
1579
0
        disable_notify_events();
1580
0
        do_remove_selection();
1581
0
        enable_notify_events();
1582
0
    }
1583
1584
    // only meaningful is call this from a "changed" callback, true if the change
1585
    // was due to mouse hovering over the entry
1586
    virtual bool changed_by_hover() const = 0;
1587
1588
    virtual void vadjustment_set_value(int value) = 0;
1589
    virtual int vadjustment_get_value() const = 0;
1590
1591
0
    void save_value() { m_sSavedValue = get_selected_text(); }
1592
0
    OUString const& get_saved_value() const { return m_sSavedValue; }
1593
0
    bool get_value_changed_from_saved() const { return m_sSavedValue != get_selected_text(); }
1594
1595
    // for custom rendering a cell
1596
0
    void connect_custom_get_size(const Link<get_size_args, Size>& rLink) { m_aGetSizeHdl = rLink; }
1597
0
    void connect_custom_render(const Link<render_args, void>& rLink) { m_aRenderHdl = rLink; }
1598
    // call set_column_custom_renderer after setting custom callbacks
1599
    virtual void set_column_custom_renderer(int nColumn, bool bEnable) = 0;
1600
    // redraw all rows, typically only useful with custom rendering to redraw due to external
1601
    // state change
1602
    virtual void queue_draw() = 0;
1603
1604
    /* with bDnDMode false simply return the row under the point
1605
     *
1606
     * with bDnDMode true:
1607
     * a) return the row which should be dropped on, which may
1608
     *    be different from the row the mouse is over in some backends where
1609
     *    positioning the mouse on the bottom half of a row indicates to drop
1610
     *    after the row
1611
     * b) dnd highlight the dest row
1612
     */
1613
    virtual bool get_dest_row_at_pos(const Point& rPos, weld::TreeIter* pResult, bool bDnDMode,
1614
                                     bool bAutoScroll = true)
1615
        = 0;
1616
    virtual void unset_drag_dest_row() = 0;
1617
    virtual tools::Rectangle get_row_area(const weld::TreeIter& rIter) const = 0;
1618
    // for dragging and dropping between TreeViews, return the active source
1619
    virtual TreeView* get_drag_source() const = 0;
1620
1621
    using Widget::set_sensitive;
1622
    using Widget::get_sensitive;
1623
};
1624
1625
typedef std::tuple<OUString&, const TreeIter&> encoded_image_query;
1626
1627
class VCL_DLLPUBLIC IconView : virtual public Widget
1628
{
1629
    friend class ::LOKTrigger;
1630
1631
private:
1632
    OUString m_sSavedValue;
1633
1634
protected:
1635
    Link<IconView&, void> m_aSelectionChangeHdl;
1636
    Link<IconView&, bool> m_aItemActivatedHdl;
1637
    Link<const CommandEvent&, bool> m_aCommandHdl;
1638
    Link<const TreeIter&, OUString> m_aQueryTooltipHdl;
1639
    Link<const encoded_image_query&, bool> m_aGetPropertyTreeElemHdl;
1640
1641
    void signal_selection_changed()
1642
0
    {
1643
0
        if (notify_events_disabled())
1644
0
            return;
1645
0
        m_aSelectionChangeHdl.Call(*this);
1646
0
    }
1647
1648
    bool signal_item_activated()
1649
0
    {
1650
0
        if (notify_events_disabled())
1651
0
            return true;
1652
0
        return m_aItemActivatedHdl.Call(*this);
1653
0
    }
1654
1655
    OUString signal_query_tooltip(const TreeIter& rIter) const
1656
0
    {
1657
0
        if (notify_events_disabled())
1658
0
            return {};
1659
0
        return m_aQueryTooltipHdl.Call(rIter);
1660
0
    }
1661
1662
    virtual void do_insert(int pos, const OUString* pStr, const OUString* pId,
1663
                           const OUString* pIconName, TreeIter* pRet)
1664
        = 0;
1665
    virtual void do_insert(int pos, const OUString* pStr, const OUString* pId, const Bitmap* pIcon,
1666
                           TreeIter* pRet)
1667
        = 0;
1668
    virtual void do_select(int pos) = 0;
1669
    virtual void do_unselect(int pos) = 0;
1670
    virtual void do_clear() = 0;
1671
    virtual void do_remove(int pos) = 0;
1672
    virtual void do_set_cursor(const TreeIter& rIter) = 0;
1673
    virtual void do_scroll_to_item(const TreeIter& rIter) = 0;
1674
1675
public:
1676
    virtual int get_item_width() const = 0;
1677
    virtual void set_item_width(int width) = 0;
1678
1679
    void insert(int pos, const OUString* pStr, const OUString* pId, const OUString* pIconName,
1680
                TreeIter* pRet)
1681
0
    {
1682
0
        disable_notify_events();
1683
0
        do_insert(pos, pStr, pId, pIconName, pRet);
1684
0
        enable_notify_events();
1685
0
    }
1686
1687
    void insert(int pos, const OUString* pStr, const OUString* pId, const Bitmap* pIcon,
1688
                TreeIter* pRet)
1689
0
    {
1690
0
        disable_notify_events();
1691
0
        do_insert(pos, pStr, pId, pIcon, pRet);
1692
0
        enable_notify_events();
1693
0
    }
1694
1695
    virtual void insert_separator(int pos, const OUString* pId) = 0;
1696
1697
    void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
1698
0
    {
1699
0
        insert(-1, &rStr, &rId, &rImage, nullptr);
1700
0
    }
1701
1702
    void append(const OUString& rId, const OUString& rStr, const Bitmap* pImage)
1703
0
    {
1704
0
        insert(-1, &rStr, &rId, pImage, nullptr);
1705
0
    }
1706
1707
0
    void append_separator(const OUString& rId) { insert_separator(-1, &rId); }
1708
1709
    void connect_selection_changed(const Link<IconView&, void>& rLink)
1710
0
    {
1711
0
        m_aSelectionChangeHdl = rLink;
1712
0
    }
1713
1714
    /* A row is "activated" when the user double clicks a treeview row. It may
1715
       also be emitted when a row is selected and Space or Enter is pressed.
1716
1717
       a return of "true" means the activation has been handled, a "false" propagates
1718
       the activation to the default handler which expands/collapses the row, if possible.
1719
    */
1720
0
    void connect_item_activated(const Link<IconView&, bool>& rLink) { m_aItemActivatedHdl = rLink; }
1721
1722
0
    void connect_command(const Link<const CommandEvent&, bool>& rLink) { m_aCommandHdl = rLink; }
1723
1724
    virtual void connect_query_tooltip(const Link<const TreeIter&, OUString>& rLink)
1725
0
    {
1726
0
        m_aQueryTooltipHdl = rLink;
1727
0
    }
1728
1729
    // 0: OUString, 1: TreeIter, returns true if supported
1730
    virtual void connect_get_image(const Link<const encoded_image_query&, bool>& rLink)
1731
0
    {
1732
0
        m_aGetPropertyTreeElemHdl = rLink;
1733
0
    }
1734
1735
    virtual OUString get_selected_id() const = 0;
1736
1737
    void clear()
1738
0
    {
1739
0
        disable_notify_events();
1740
0
        do_clear();
1741
0
        enable_notify_events();
1742
0
    }
1743
1744
    virtual int count_selected_items() const = 0;
1745
1746
    virtual OUString get_selected_text() const = 0;
1747
1748
    //by index. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1749
    virtual OUString get_id(int pos) const = 0;
1750
1751
    void select(int pos)
1752
0
    {
1753
0
        disable_notify_events();
1754
0
        do_select(pos);
1755
0
        enable_notify_events();
1756
0
    }
1757
1758
    void unselect(int pos)
1759
0
    {
1760
0
        disable_notify_events();
1761
0
        do_unselect(pos);
1762
0
        enable_notify_events();
1763
0
    }
1764
1765
    virtual void set_image(int pos, VirtualDevice& rDevice) = 0;
1766
    virtual void set_text(int pos, const OUString& rText) = 0;
1767
    virtual void set_id(int pos, const OUString& rId) = 0;
1768
    virtual void set_item_accessible_name(int pos, const OUString& rName) = 0;
1769
1770
    void remove(int pos)
1771
0
    {
1772
0
        disable_notify_events();
1773
0
        do_remove(pos);
1774
0
        enable_notify_events();
1775
0
    }
1776
1777
    virtual tools::Rectangle get_rect(int pos) const = 0;
1778
1779
    //via iter
1780
    virtual std::unique_ptr<TreeIter> make_iterator(const TreeIter* pOrig = nullptr) const = 0;
1781
    virtual bool get_selected(TreeIter* pIter) const = 0;
1782
    virtual bool get_cursor(TreeIter* pIter) const = 0;
1783
1784
    void set_cursor(const TreeIter& rIter)
1785
0
    {
1786
0
        disable_notify_events();
1787
0
        do_set_cursor(rIter);
1788
0
        enable_notify_events();
1789
0
    }
1790
1791
    virtual bool get_iter_first(TreeIter& rIter) const = 0;
1792
    virtual OUString get_id(const TreeIter& rIter) const = 0;
1793
    virtual OUString get_text(const TreeIter& rIter) const = 0;
1794
    virtual bool iter_next_sibling(TreeIter& rIter) const = 0;
1795
1796
    void scroll_to_item(const TreeIter& rIter)
1797
0
    {
1798
0
        disable_notify_events();
1799
0
        do_scroll_to_item(rIter);
1800
0
        enable_notify_events();
1801
0
    }
1802
1803
    // call func on each selected element until func returns true or we run out of elements
1804
    virtual void selected_foreach(const std::function<bool(TreeIter&)>& func) = 0;
1805
1806
    //all of them. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze.
1807
    virtual void select_all() = 0;
1808
    virtual void unselect_all() = 0;
1809
1810
    // return the number of toplevel nodes
1811
    virtual int n_children() const = 0;
1812
1813
0
    void save_value() { m_sSavedValue = get_selected_text(); }
1814
0
    OUString const& get_saved_value() const { return m_sSavedValue; }
1815
0
    bool get_value_changed_from_saved() const { return m_sSavedValue != get_selected_text(); }
1816
};
1817
1818
class VCL_DLLPUBLIC Button : virtual public Widget
1819
{
1820
    friend class ::LOKTrigger;
1821
1822
protected:
1823
    Link<Button&, void> m_aClickHdl;
1824
1825
0
    void signal_clicked() { m_aClickHdl.Call(*this); }
1826
1827
public:
1828
    virtual void set_label(const OUString& rText) = 0;
1829
    // pDevice, the image for the button, or nullptr to unset
1830
    virtual void set_image(VirtualDevice* pDevice) = 0;
1831
    virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) = 0;
1832
    virtual void set_from_icon_name(const OUString& rIconName) = 0;
1833
    virtual OUString get_label() const = 0;
1834
0
    void clicked() { signal_clicked(); }
1835
0
    bool is_custom_handler_set() { return m_aClickHdl.IsSet(); }
1836
1837
    // font size is in points, not pixels, e.g. see Window::[G]etPointFont
1838
    virtual void set_font(const vcl::Font& rFont) = 0;
1839
1840
    /* Sometimes, a widget should behave like a button (activate on click,
1841
       accept keyboard focus, etc), but look entirely different.
1842
1843
       pDevice, the custom look to use, or nullptr to unset.
1844
1845
       Typically doing this is ill advised. Consider using
1846
       set_accessible_name if you do. */
1847
    virtual void set_custom_button(VirtualDevice* pDevice) = 0;
1848
1849
0
    virtual void connect_clicked(const Link<Button&, void>& rLink) { m_aClickHdl = rLink; }
1850
};
1851
1852
class VCL_DLLPUBLIC Toggleable : virtual public Widget
1853
{
1854
    friend class ::LOKTrigger;
1855
1856
protected:
1857
    Link<Toggleable&, void> m_aToggleHdl;
1858
    TriState m_eSavedValue = TRISTATE_FALSE;
1859
1860
    void signal_toggled()
1861
0
    {
1862
0
        if (notify_events_disabled())
1863
0
            return;
1864
0
        m_aToggleHdl.Call(*this);
1865
0
    }
1866
1867
    virtual void do_set_active(bool active) = 0;
1868
1869
public:
1870
    void set_active(bool active)
1871
0
    {
1872
0
        disable_notify_events();
1873
0
        do_set_active(active);
1874
0
        enable_notify_events();
1875
0
    }
1876
1877
    virtual bool get_active() const = 0;
1878
1879
    virtual TriState get_state() const
1880
0
    {
1881
0
        if (get_active())
1882
0
            return TRISTATE_TRUE;
1883
0
        return TRISTATE_FALSE;
1884
0
    }
1885
1886
0
    void save_state() { m_eSavedValue = get_state(); }
1887
0
    TriState get_saved_state() const { return m_eSavedValue; }
1888
0
    bool get_state_changed_from_saved() const { return m_eSavedValue != get_state(); }
1889
1890
0
    virtual void connect_toggled(const Link<Toggleable&, void>& rLink) { m_aToggleHdl = rLink; }
1891
};
1892
1893
class VCL_DLLPUBLIC ToggleButton : virtual public Button, virtual public Toggleable
1894
{
1895
    friend class ::LOKTrigger;
1896
};
1897
1898
class VCL_DLLPUBLIC MenuButton : virtual public ToggleButton
1899
{
1900
    friend class ::LOKTrigger;
1901
1902
    Link<const OUString&, void> m_aSelectHdl;
1903
1904
protected:
1905
0
    void signal_selected(const OUString& rIdent) { m_aSelectHdl.Call(rIdent); }
1906
1907
public:
1908
0
    void connect_selected(const Link<const OUString&, void>& rLink) { m_aSelectHdl = rLink; }
1909
1910
    virtual void insert_item(int pos, const OUString& rId, const OUString& rStr,
1911
                             const OUString* pIconName, VirtualDevice* pImageSurface,
1912
                             TriState eCheckRadioFalse)
1913
        = 0;
1914
    void append_item(const OUString& rId, const OUString& rStr)
1915
0
    {
1916
0
        insert_item(-1, rId, rStr, nullptr, nullptr, TRISTATE_INDET);
1917
0
    }
1918
    void append_item_check(const OUString& rId, const OUString& rStr)
1919
0
    {
1920
0
        insert_item(-1, rId, rStr, nullptr, nullptr, TRISTATE_TRUE);
1921
0
    }
1922
    void append_item_radio(const OUString& rId, const OUString& rStr)
1923
0
    {
1924
0
        insert_item(-1, rId, rStr, nullptr, nullptr, TRISTATE_FALSE);
1925
0
    }
1926
    void append_item(const OUString& rId, const OUString& rStr, const OUString& rImage)
1927
0
    {
1928
0
        insert_item(-1, rId, rStr, &rImage, nullptr, TRISTATE_INDET);
1929
0
    }
1930
    void append_item(const OUString& rId, const OUString& rStr, VirtualDevice& rImage)
1931
0
    {
1932
0
        insert_item(-1, rId, rStr, nullptr, &rImage, TRISTATE_INDET);
1933
0
    }
1934
    virtual void insert_separator(int pos, const OUString& rId) = 0;
1935
0
    void append_separator(const OUString& rId) { insert_separator(-1, rId); }
1936
    virtual void remove_item(const OUString& rId) = 0;
1937
    virtual void clear() = 0;
1938
    virtual void set_item_sensitive(const OUString& rIdent, bool bSensitive) = 0;
1939
    virtual void set_item_active(const OUString& rIdent, bool bActive) = 0;
1940
    virtual void set_item_label(const OUString& rIdent, const OUString& rLabel) = 0;
1941
    virtual OUString get_item_label(const OUString& rIdent) const = 0;
1942
    virtual void set_item_visible(const OUString& rIdent, bool bVisible) = 0;
1943
1944
    virtual void set_popover(weld::Widget* pPopover) = 0;
1945
};
1946
1947
class VCL_DLLPUBLIC CheckButton : virtual public Toggleable
1948
{
1949
protected:
1950
    virtual void do_set_state(TriState eState) = 0;
1951
1952
public:
1953
    // must override Toggleable::get_state to support TRISTATE_INDET
1954
    virtual TriState get_state() const override = 0;
1955
1956
    void set_state(TriState eState)
1957
0
    {
1958
0
        disable_notify_events();
1959
0
        do_set_state(eState);
1960
0
        enable_notify_events();
1961
0
    }
1962
1963
    virtual void do_set_active(bool bActive) override final
1964
0
    {
1965
0
        do_set_state(bActive ? TRISTATE_TRUE : TRISTATE_FALSE);
1966
0
    }
1967
1968
0
    virtual bool get_active() const override final { return get_state() == TRISTATE_TRUE; }
1969
1970
    virtual void set_label(const OUString& rText) = 0;
1971
    virtual OUString get_label() const = 0;
1972
    virtual void set_label_wrap(bool wrap) = 0;
1973
};
1974
1975
struct VCL_DLLPUBLIC TriStateEnabled
1976
{
1977
    TriState eState;
1978
    bool bTriStateEnabled;
1979
    TriStateEnabled()
1980
        : eState(TRISTATE_INDET)
1981
        , bTriStateEnabled(true)
1982
0
    {
1983
0
    }
1984
    void CheckButtonToggled(CheckButton& rToggle);
1985
};
1986
1987
class VCL_DLLPUBLIC RadioButton : virtual public Toggleable
1988
{
1989
public:
1990
    virtual void set_label(const OUString& rText) = 0;
1991
    virtual OUString get_label() const = 0;
1992
    virtual void set_label_wrap(bool wrap) = 0;
1993
};
1994
1995
class VCL_DLLPUBLIC LinkButton : virtual public Widget
1996
{
1997
    friend class ::LOKTrigger;
1998
1999
    Link<LinkButton&, bool> m_aActivateLinkHdl;
2000
2001
protected:
2002
0
    bool signal_activate_link() { return m_aActivateLinkHdl.Call(*this); }
2003
2004
public:
2005
    virtual void set_label(const OUString& rText) = 0;
2006
    virtual OUString get_label() const = 0;
2007
    virtual void set_label_wrap(bool wrap) = 0;
2008
    virtual void set_uri(const OUString& rUri) = 0;
2009
    virtual OUString get_uri() const = 0;
2010
2011
0
    void connect_activate_link(const Link<LinkButton&, bool>& rLink) { m_aActivateLinkHdl = rLink; }
2012
};
2013
2014
class VCL_DLLPUBLIC Scale : virtual public Widget
2015
{
2016
    Link<Scale&, void> m_aValueChangedHdl;
2017
2018
protected:
2019
0
    void signal_value_changed() { m_aValueChangedHdl.Call(*this); }
2020
2021
public:
2022
    virtual void set_value(int value) = 0;
2023
    virtual int get_value() const = 0;
2024
    virtual void set_range(int min, int max) = 0;
2025
2026
    virtual void set_increments(int step, int page) = 0;
2027
    virtual void get_increments(int& step, int& page) const = 0;
2028
2029
0
    void connect_value_changed(const Link<Scale&, void>& rLink) { m_aValueChangedHdl = rLink; }
2030
};
2031
2032
class VCL_DLLPUBLIC Spinner : virtual public Widget
2033
{
2034
public:
2035
    virtual void start() = 0;
2036
    virtual void stop() = 0;
2037
};
2038
2039
class VCL_DLLPUBLIC ProgressBar : virtual public Widget
2040
{
2041
public:
2042
    //0-100
2043
    virtual void set_percentage(int value) = 0;
2044
    virtual OUString get_text() const = 0;
2045
    virtual void set_text(const OUString& rText) = 0;
2046
};
2047
2048
class VCL_DLLPUBLIC LevelBar : virtual public Widget
2049
{
2050
public:
2051
    /// Sets LevelBar fill percentage.
2052
    /// @param fPercentage bar's fill percentage, [0.0, 100.0]
2053
    virtual void set_percentage(double fPercentage) = 0;
2054
};
2055
2056
class VCL_DLLPUBLIC Entry : virtual public Widget
2057
{
2058
private:
2059
    OUString m_sSavedValue;
2060
2061
protected:
2062
    Link<Entry&, void> m_aChangeHdl;
2063
    Link<OUString&, bool> m_aInsertTextHdl;
2064
    Link<Entry&, void> m_aCursorPositionHdl;
2065
    Link<Entry&, bool> m_aActivateHdl;
2066
2067
    friend class ::LOKTrigger;
2068
2069
    void signal_changed()
2070
0
    {
2071
0
        if (notify_events_disabled())
2072
0
            return;
2073
0
        m_aChangeHdl.Call(*this);
2074
0
    }
2075
2076
    void signal_activated()
2077
0
    {
2078
0
        if (notify_events_disabled())
2079
0
            return;
2080
0
        m_aActivateHdl.Call(*this);
2081
0
    }
2082
2083
    void signal_cursor_position()
2084
0
    {
2085
0
        if (notify_events_disabled())
2086
0
            return;
2087
0
        m_aCursorPositionHdl.Call(*this);
2088
0
    }
2089
2090
    virtual void do_set_text(const OUString& rText) = 0;
2091
    virtual void do_select_region(int nStartPos, int nEndPos) = 0;
2092
    virtual void do_set_position(int nCursorPos) = 0;
2093
2094
public:
2095
    void set_text(const OUString& rText)
2096
0
    {
2097
0
        disable_notify_events();
2098
0
        do_set_text(rText);
2099
0
        enable_notify_events();
2100
0
    }
2101
2102
    virtual OUString get_text() const = 0;
2103
    virtual void set_width_chars(int nChars) = 0;
2104
    virtual int get_width_chars() const = 0;
2105
    // The maximum length of the entry. Use 0 for no maximum
2106
    virtual void set_max_length(int nChars) = 0;
2107
2108
    // nEndPos can be -1 in order to select all text
2109
    void select_region(int nStartPos, int nEndPos)
2110
0
    {
2111
0
        disable_notify_events();
2112
0
        do_select_region(nStartPos, nEndPos);
2113
0
        enable_notify_events();
2114
0
    }
2115
2116
    // returns true if the selection has nonzero length
2117
    virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) = 0;
2118
    virtual void replace_selection(const OUString& rText) = 0;
2119
2120
    // nCursorPos can be -1 to set to the end
2121
    void set_position(int nCursorPos)
2122
0
    {
2123
0
        disable_notify_events();
2124
0
        do_set_position(nCursorPos);
2125
0
        enable_notify_events();
2126
0
    }
2127
2128
    virtual int get_position() const = 0;
2129
    virtual void set_editable(bool bEditable) = 0;
2130
    virtual bool get_editable() const = 0;
2131
    virtual void set_visibility(bool bVisible) = 0;
2132
    virtual void set_message_type(EntryMessageType eType) = 0;
2133
    virtual void set_placeholder_text(const OUString& rText) = 0;
2134
2135
    virtual void set_overwrite_mode(bool bOn) = 0;
2136
    virtual bool get_overwrite_mode() const = 0;
2137
2138
    // font size is in points, not pixels, e.g. see Window::[G]etPointFont
2139
    virtual void set_font(const vcl::Font& rFont) = 0;
2140
2141
    /*
2142
       If you want to set a warning or error state, see set_message_type
2143
       instead where, if the toolkit supports it, a specific warning/error
2144
       indicator is shown.
2145
2146
       This explicit text color method exists to support rendering the
2147
       SvNumberformat color feature.
2148
    */
2149
    virtual void set_font_color(const Color& rColor) = 0;
2150
2151
0
    virtual void connect_changed(const Link<Entry&, void>& rLink) { m_aChangeHdl = rLink; }
2152
0
    void connect_insert_text(const Link<OUString&, bool>& rLink) { m_aInsertTextHdl = rLink; }
2153
    // callback returns true to indicated no further processing of activate wanted
2154
0
    void connect_activate(const Link<Entry&, bool>& rLink) { m_aActivateHdl = rLink; }
2155
    virtual void connect_cursor_position(const Link<Entry&, void>& rLink)
2156
0
    {
2157
0
        m_aCursorPositionHdl = rLink;
2158
0
    }
2159
2160
    virtual void cut_clipboard() = 0;
2161
    virtual void copy_clipboard() = 0;
2162
    virtual void paste_clipboard() = 0;
2163
2164
    virtual void set_alignment(TxtAlign eXAlign) = 0;
2165
2166
0
    void save_value() { m_sSavedValue = get_text(); }
2167
0
    OUString const& get_saved_value() const { return m_sSavedValue; }
2168
0
    bool get_value_changed_from_saved() const { return m_sSavedValue != get_text(); }
2169
};
2170
2171
class VCL_DLLPUBLIC SpinButton : virtual public Entry
2172
{
2173
    friend class ::LOKTrigger;
2174
2175
    Link<SpinButton&, void> m_aValueChangedHdl;
2176
    Link<sal_Int64, OUString> m_aFormatValueHdl;
2177
    Link<const OUString&, std::optional<int>> m_aParseTextHdl;
2178
2179
    // helper methods to convert between sal_Int64 value and
2180
    // floating point number it represents (depending on get_digits())
2181
    double convert_value_to_double(sal_Int64 nValue) const
2182
0
    {
2183
0
        return static_cast<double>(nValue) / Power10(get_digits());
2184
0
    }
2185
    sal_Int64 convert_double_to_value(double fDouble) const
2186
0
    {
2187
0
        return basegfx::fround64(fDouble * Power10(get_digits()));
2188
0
    }
2189
2190
protected:
2191
0
    void signal_value_changed() { m_aValueChangedHdl.Call(*this); }
2192
2193
    /** If a custom value formatter was set via <a>set_value_formatter</a>,
2194
     *  that one gets called to create a text representation of the value
2195
     *  and that one gets returned.
2196
     *  Otherwise, an empty std::optional is returned.
2197
     */
2198
    std::optional<OUString> format_floating_point_value(double fValue)
2199
0
    {
2200
0
        if (!m_aFormatValueHdl.IsSet())
2201
0
            return {};
2202
0
        const OUString sText = m_aFormatValueHdl.Call(convert_double_to_value(fValue));
2203
0
        return sText;
2204
0
    }
2205
2206
    /** If a custom text parser (which parses a value from the given text)
2207
     *  is set and the text can be parsed, this method sets that value
2208
     *  in <a>result</a> and returns <a>TRISTATE_TRUE</a>.
2209
     *  Returns <a>TRISTATE_FALSE</a> if a custom handler is set, but the text
2210
     *  cannot be parsed.
2211
     *  Returns <a>TRISTATE_INDET</a> if no custom input handler is set.
2212
     */
2213
    TriState parse_text(const OUString& rText, double* pResult)
2214
0
    {
2215
0
        if (!m_aParseTextHdl.IsSet())
2216
0
            return TRISTATE_INDET;
2217
0
        std::optional<int> aValue = m_aParseTextHdl.Call(rText);
2218
0
        if (!aValue.has_value())
2219
0
            return TRISTATE_FALSE;
2220
2221
0
        *pResult = convert_value_to_double(aValue.value());
2222
0
        return TRISTATE_TRUE;
2223
0
    }
2224
2225
    // methods to implement in subclasses which use floating point values directly;
2226
    // public methods using sal_Int64 values whose floating point value depends on get_digits()
2227
    // take care of conversion
2228
    virtual void set_floating_point_value(double fValue) = 0;
2229
    virtual double get_floating_point_value() const = 0;
2230
    virtual void set_floating_point_range(double fMin, double fMax) = 0;
2231
    virtual void get_floating_point_range(double& rMin, double& rMax) const = 0;
2232
    virtual void set_floating_point_increments(double fStep, double fPage) = 0;
2233
    virtual void get_floating_point_increments(double& rStep, double& rPage) const = 0;
2234
2235
public:
2236
0
    void set_value(sal_Int64 value) { set_floating_point_value(convert_value_to_double(value)); }
2237
2238
0
    sal_Int64 get_value() const { return convert_double_to_value(get_floating_point_value()); }
2239
2240
    void set_range(sal_Int64 min, sal_Int64 max)
2241
0
    {
2242
0
        set_floating_point_range(convert_value_to_double(min), convert_value_to_double(max));
2243
0
    }
2244
2245
    void get_range(sal_Int64& min, sal_Int64& max) const
2246
0
    {
2247
0
        double fMin = 0;
2248
0
        double fMax = 0;
2249
0
        get_floating_point_range(fMin, fMax);
2250
0
        min = convert_double_to_value(fMin);
2251
0
        max = convert_double_to_value(fMax);
2252
0
    }
2253
2254
    void set_min(sal_Int64 min)
2255
0
    {
2256
0
        sal_Int64 dummy, max;
2257
0
        get_range(dummy, max);
2258
0
        set_range(min, max);
2259
0
    }
2260
    void set_max(sal_Int64 max)
2261
0
    {
2262
0
        sal_Int64 min, dummy;
2263
0
        get_range(min, dummy);
2264
0
        set_range(min, max);
2265
0
    }
2266
    sal_Int64 get_min() const
2267
0
    {
2268
0
        sal_Int64 min, dummy;
2269
0
        get_range(min, dummy);
2270
0
        return min;
2271
0
    }
2272
    sal_Int64 get_max() const
2273
0
    {
2274
0
        sal_Int64 dummy, max;
2275
0
        get_range(dummy, max);
2276
0
        return max;
2277
0
    }
2278
2279
    void set_increments(sal_Int64 step, sal_Int64 page)
2280
0
    {
2281
0
        set_floating_point_increments(convert_value_to_double(step), convert_value_to_double(page));
2282
0
    }
2283
2284
    void get_increments(sal_Int64& step, sal_Int64& page) const
2285
0
    {
2286
0
        double fStep = 0;
2287
0
        double fPage = 0;
2288
0
        get_floating_point_increments(fStep, fPage);
2289
0
        step = convert_double_to_value(fStep);
2290
0
        page = convert_double_to_value(fPage);
2291
0
    }
2292
2293
    virtual void set_digits(unsigned int digits) = 0;
2294
    virtual unsigned int get_digits() const = 0;
2295
2296
0
    void connect_value_changed(const Link<SpinButton&, void>& rLink) { m_aValueChangedHdl = rLink; }
2297
2298
    /** Set a value formatter that receives the value as a parameter and returns the
2299
     *  text representation to display in the SpinButton.
2300
     */
2301
0
    void set_value_formatter(const Link<sal_Int64, OUString>& rLink) { m_aFormatValueHdl = rLink; }
2302
2303
    /** Set a parser that receives the text as a parameter and returns the value
2304
     *  parsed from the text, or an empty std::optional if a value cannot be
2305
     *  parsed from the text.
2306
     */
2307
    void set_text_parser(const Link<const OUString&, std::optional<int>>& rLink)
2308
0
    {
2309
0
        m_aParseTextHdl = rLink;
2310
0
    }
2311
2312
0
    sal_Int64 normalize(sal_Int64 nValue) const { return (nValue * Power10(get_digits())); }
2313
2314
    sal_Int64 denormalize(sal_Int64 nValue) const;
2315
2316
    static unsigned int Power10(unsigned int n);
2317
};
2318
2319
class EntryFormatter;
2320
2321
// Similar to a SpinButton, but input and output formatting and range/value
2322
// are managed by a more complex Formatter which can support doubles.
2323
class VCL_DLLPUBLIC FormattedSpinButton : virtual public Entry
2324
{
2325
    friend class ::LOKTrigger;
2326
2327
    Link<FormattedSpinButton&, void> m_aValueChangedHdl;
2328
2329
protected:
2330
0
    void signal_value_changed() { m_aValueChangedHdl.Call(*this); }
2331
2332
public:
2333
    virtual Formatter& GetFormatter() = 0;
2334
    // does not take ownership, and so must be deregistered if pFormatter
2335
    // is destroyed
2336
    virtual void SetFormatter(weld::EntryFormatter* pFormatter) = 0;
2337
2338
    void connect_value_changed(const Link<FormattedSpinButton&, void>& rLink)
2339
0
    {
2340
0
        m_aValueChangedHdl = rLink;
2341
0
    }
2342
2343
private:
2344
    friend class EntryFormatter;
2345
    virtual void sync_range_from_formatter() = 0;
2346
    virtual void sync_value_from_formatter() = 0;
2347
    virtual void sync_increments_from_formatter() = 0;
2348
};
2349
2350
class VCL_DLLPUBLIC Image : virtual public Widget
2351
{
2352
public:
2353
    virtual void set_from_icon_name(const OUString& rIconName) = 0;
2354
    virtual void set_image(VirtualDevice* pDevice) = 0;
2355
    virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) = 0;
2356
};
2357
2358
class VCL_DLLPUBLIC Calendar : virtual public Widget
2359
{
2360
    friend class ::LOKTrigger;
2361
2362
    Link<Calendar&, void> m_aSelectedHdl;
2363
    Link<Calendar&, void> m_aActivatedHdl;
2364
2365
protected:
2366
    void signal_selected()
2367
0
    {
2368
0
        if (notify_events_disabled())
2369
0
            return;
2370
0
        m_aSelectedHdl.Call(*this);
2371
0
    }
2372
2373
    void signal_activated()
2374
0
    {
2375
0
        if (notify_events_disabled())
2376
0
            return;
2377
0
        m_aActivatedHdl.Call(*this);
2378
0
    }
2379
2380
public:
2381
0
    void connect_selected(const Link<Calendar&, void>& rLink) { m_aSelectedHdl = rLink; }
2382
0
    void connect_activated(const Link<Calendar&, void>& rLink) { m_aActivatedHdl = rLink; }
2383
2384
    virtual void set_date(const Date& rDate) = 0;
2385
    virtual Date get_date() const = 0;
2386
};
2387
2388
// an entry + treeview pair, where the entry autocompletes from the
2389
// treeview list, and selecting something in the list sets the
2390
// entry to that text, i.e. a visually exploded ComboBox
2391
class VCL_DLLPUBLIC EntryTreeView : virtual public ComboBox
2392
{
2393
private:
2394
    DECL_DLLPRIVATE_LINK(ClickHdl, weld::TreeView&, void);
2395
    DECL_DLLPRIVATE_LINK(ModifyHdl, weld::Entry&, void);
2396
2397
protected:
2398
    std::unique_ptr<Entry> m_xEntry;
2399
    std::unique_ptr<TreeView> m_xTreeView;
2400
2401
public:
2402
    EntryTreeView(std::unique_ptr<Entry> xEntry, std::unique_ptr<TreeView> xTreeView);
2403
2404
    virtual void insert_vector(const std::vector<weld::ComboBoxEntry>& rItems,
2405
                               bool bKeepExisting) override
2406
0
    {
2407
0
        m_xTreeView->freeze();
2408
0
        if (!bKeepExisting)
2409
0
            m_xTreeView->clear();
2410
0
        for (const auto& rItem : rItems)
2411
0
            append(rItem);
2412
0
        m_xTreeView->thaw();
2413
0
    }
2414
2415
    virtual void insert(int pos, const OUString& rStr, const OUString* pId,
2416
                        const OUString* pIconName, VirtualDevice* pImageSurface) override
2417
0
    {
2418
0
        m_xTreeView->insert(pos, rStr, pId, pIconName, pImageSurface);
2419
0
    }
2420
2421
0
    virtual int get_count() const override { return m_xTreeView->n_children(); }
2422
0
    virtual void clear() override { m_xTreeView->clear(); }
2423
2424
    //by index
2425
0
    virtual int get_active() const override { return m_xTreeView->get_selected_index(); }
2426
    virtual void set_active(int pos) override
2427
0
    {
2428
0
        m_xTreeView->set_cursor(pos);
2429
0
        m_xTreeView->select(pos);
2430
0
        m_xEntry->set_text(m_xTreeView->get_selected_text());
2431
0
    }
2432
0
    virtual void remove(int pos) override { m_xTreeView->remove(pos); }
2433
2434
    //by text
2435
0
    virtual OUString get_active_text() const override { return m_xEntry->get_text(); }
2436
0
    virtual OUString get_text(int pos) const override { return m_xTreeView->get_text(pos); }
2437
    virtual int find_text(const OUString& rStr) const override
2438
0
    {
2439
0
        return m_xTreeView->find_text(rStr);
2440
0
    }
2441
2442
    //by id
2443
0
    virtual OUString get_active_id() const override { return m_xTreeView->get_selected_id(); }
2444
    virtual void set_active_id(const OUString& rStr) override
2445
0
    {
2446
0
        m_xTreeView->select_id(rStr);
2447
0
        m_xEntry->set_text(m_xTreeView->get_selected_text());
2448
0
    }
2449
0
    virtual OUString get_id(int pos) const override { return m_xTreeView->get_id(pos); }
2450
0
    virtual void set_id(int pos, const OUString& rId) override { m_xTreeView->set_id(pos, rId); }
2451
0
    virtual int find_id(const OUString& rId) const override { return m_xTreeView->find_id(rId); }
2452
2453
    //entry related
2454
0
    virtual bool has_entry() const override { return true; }
2455
    virtual void set_entry_message_type(EntryMessageType eType) override
2456
0
    {
2457
0
        m_xEntry->set_message_type(eType);
2458
0
    }
2459
0
    virtual void set_entry_text(const OUString& rStr) override { m_xEntry->set_text(rStr); }
2460
0
    virtual void set_entry_width_chars(int nChars) override { m_xEntry->set_width_chars(nChars); }
2461
0
    virtual void set_entry_max_length(int nChars) override { m_xEntry->set_max_length(nChars); }
2462
    virtual void select_entry_region(int nStartPos, int nEndPos) override
2463
0
    {
2464
0
        m_xEntry->select_region(nStartPos, nEndPos);
2465
0
    }
2466
    //if no text was selected, both rStartPos and rEndPos will be identical
2467
    //and false will be returned
2468
    virtual bool get_entry_selection_bounds(int& rStartPos, int& rEndPos) override
2469
0
    {
2470
0
        return m_xEntry->get_selection_bounds(rStartPos, rEndPos);
2471
0
    }
2472
2473
    virtual void set_entry_placeholder_text(const OUString& rText) override
2474
0
    {
2475
0
        m_xEntry->set_placeholder_text(rText);
2476
0
    }
2477
2478
0
    virtual void set_entry_editable(bool bEditable) override { m_xEntry->set_editable(bEditable); }
2479
2480
0
    virtual void cut_entry_clipboard() override { m_xEntry->cut_clipboard(); }
2481
2482
0
    virtual void copy_entry_clipboard() override { m_xEntry->copy_clipboard(); }
2483
2484
0
    virtual void paste_entry_clipboard() override { m_xEntry->paste_clipboard(); }
2485
2486
0
    virtual void set_entry_font(const vcl::Font& rFont) override { m_xEntry->set_font(rFont); }
2487
2488
0
    virtual vcl::Font get_entry_font() override { return m_xEntry->get_font(); }
2489
2490
    void connect_row_activated(const Link<TreeView&, bool>& rLink)
2491
0
    {
2492
0
        m_xTreeView->connect_row_activated(rLink);
2493
0
    }
2494
2495
0
    virtual bool get_popup_shown() const override { return false; }
2496
2497
    void set_height_request_by_rows(int nRows);
2498
2499
    // Methods from weld::ComboBox subclass API that are not actually implemented/used
2500
    virtual void insert_separator(int /*pos*/, const OUString& /*rId*/) override final
2501
0
    {
2502
0
        assert(false && "not implemented");
2503
0
    }
2504
2505
0
    virtual void set_font(const vcl::Font&) override final { assert(false && "not implemented"); }
2506
2507
    virtual void set_custom_renderer(bool /*bOn*/) override final
2508
0
    {
2509
0
        assert(false && "not implemented");
2510
0
    }
2511
2512
    virtual int get_max_mru_count() const override final
2513
0
    {
2514
0
        assert(false && "not implemented");
2515
0
        return 0;
2516
0
    }
2517
2518
0
    virtual void set_max_mru_count(int) override final { assert(false && "not implemented"); }
2519
2520
    virtual OUString get_mru_entries() const override final
2521
0
    {
2522
0
        assert(false && "not implemented");
2523
0
        return OUString();
2524
0
    }
2525
2526
    virtual void set_mru_entries(const OUString&) override final
2527
0
    {
2528
0
        assert(false && "not implemented");
2529
0
    }
2530
2531
0
    virtual void set_max_drop_down_rows(int) override final { assert(false && "not implemented"); }
2532
2533
    virtual void set_item_menu(const OUString&, weld::Menu*) override final
2534
0
    {
2535
0
        assert(false && "not implemented");
2536
0
    }
2537
2538
    int get_menu_button_width() const override final
2539
0
    {
2540
0
        assert(false && "not implemented");
2541
0
        return 0;
2542
0
    }
2543
};
2544
2545
class VCL_DLLPUBLIC MetricSpinButton final
2546
{
2547
    FieldUnit m_eSrcUnit;
2548
    std::unique_ptr<weld::SpinButton> m_xSpinButton;
2549
    Link<MetricSpinButton&, void> m_aValueChangedHdl;
2550
2551
    DECL_LINK(spin_button_value_changed, weld::SpinButton&, void);
2552
    DECL_LINK(spin_button_output, sal_Int64, OUString);
2553
    DECL_LINK(spin_button_input, const OUString&, std::optional<int>);
2554
2555
0
    void signal_value_changed() { m_aValueChangedHdl.Call(*this); }
2556
2557
    sal_Int64 ConvertValue(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit) const;
2558
    OUString format_number(sal_Int64 nValue) const;
2559
    void update_width_chars();
2560
2561
public:
2562
    MetricSpinButton(std::unique_ptr<SpinButton> pSpinButton, FieldUnit eSrcUnit)
2563
0
        : m_eSrcUnit(eSrcUnit)
2564
0
        , m_xSpinButton(std::move(pSpinButton))
2565
0
    {
2566
0
        update_width_chars();
2567
0
        m_xSpinButton->set_value_formatter(LINK(this, MetricSpinButton, spin_button_output));
2568
0
        m_xSpinButton->set_text_parser(LINK(this, MetricSpinButton, spin_button_input));
2569
0
        m_xSpinButton->connect_value_changed(
2570
0
            LINK(this, MetricSpinButton, spin_button_value_changed));
2571
0
        m_xSpinButton->set_text(format_number(m_xSpinButton->get_value()));
2572
0
    }
2573
2574
    static OUString MetricToString(FieldUnit rUnit);
2575
2576
0
    FieldUnit get_unit() const { return m_eSrcUnit; }
2577
2578
    void set_unit(FieldUnit eUnit);
2579
2580
    sal_Int64 convert_value_to(sal_Int64 nValue, FieldUnit eValueUnit) const
2581
0
    {
2582
0
        return ConvertValue(nValue, m_eSrcUnit, eValueUnit);
2583
0
    }
2584
2585
    sal_Int64 convert_value_from(sal_Int64 nValue, FieldUnit eValueUnit) const
2586
0
    {
2587
0
        return ConvertValue(nValue, eValueUnit, m_eSrcUnit);
2588
0
    }
2589
2590
    void set_value(sal_Int64 nValue, FieldUnit eValueUnit)
2591
0
    {
2592
0
        m_xSpinButton->set_value(convert_value_from(nValue, eValueUnit));
2593
0
    }
2594
2595
    sal_Int64 get_value(FieldUnit eDestUnit) const
2596
0
    {
2597
0
        return convert_value_to(m_xSpinButton->get_value(), eDestUnit);
2598
0
    }
2599
2600
    // typically you only need to call this if set_text (e.g. with "") was
2601
    // previously called to display some arbitrary text instead of the
2602
    // formatted value and now you want to show it as formatted again
2603
    void reformat()
2604
0
    {
2605
0
        const OUString sText = format_number(m_xSpinButton->get_value());
2606
0
        m_xSpinButton->set_text(sText);
2607
0
    }
2608
2609
    void set_range(sal_Int64 min, sal_Int64 max, FieldUnit eValueUnit)
2610
0
    {
2611
0
        min = convert_value_from(min, eValueUnit);
2612
0
        max = convert_value_from(max, eValueUnit);
2613
0
        m_xSpinButton->set_range(min, max);
2614
0
        update_width_chars();
2615
0
    }
2616
2617
    void get_range(sal_Int64& min, sal_Int64& max, FieldUnit eDestUnit) const
2618
0
    {
2619
0
        m_xSpinButton->get_range(min, max);
2620
0
        min = convert_value_to(min, eDestUnit);
2621
0
        max = convert_value_to(max, eDestUnit);
2622
0
    }
2623
2624
    void set_min(sal_Int64 min, FieldUnit eValueUnit)
2625
0
    {
2626
0
        sal_Int64 dummy, max;
2627
0
        get_range(dummy, max, eValueUnit);
2628
0
        set_range(min, max, eValueUnit);
2629
0
    }
2630
2631
    void set_max(sal_Int64 max, FieldUnit eValueUnit)
2632
0
    {
2633
0
        sal_Int64 min, dummy;
2634
0
        get_range(min, dummy, eValueUnit);
2635
0
        set_range(min, max, eValueUnit);
2636
0
    }
2637
2638
    sal_Int64 get_min(FieldUnit eValueUnit) const
2639
0
    {
2640
0
        sal_Int64 min, dummy;
2641
0
        get_range(min, dummy, eValueUnit);
2642
0
        return min;
2643
0
    }
2644
2645
    sal_Int64 get_max(FieldUnit eValueUnit) const
2646
0
    {
2647
0
        sal_Int64 dummy, max;
2648
0
        get_range(dummy, max, eValueUnit);
2649
0
        return max;
2650
0
    }
2651
2652
    void set_increments(sal_Int64 step, sal_Int64 page, FieldUnit eValueUnit)
2653
0
    {
2654
0
        step = convert_value_from(step, eValueUnit);
2655
0
        page = convert_value_from(page, eValueUnit);
2656
0
        m_xSpinButton->set_increments(step, page);
2657
0
    }
2658
2659
    void get_increments(sal_Int64& step, sal_Int64& page, FieldUnit eDestUnit) const
2660
0
    {
2661
0
        m_xSpinButton->get_increments(step, page);
2662
0
        step = convert_value_to(step, eDestUnit);
2663
0
        page = convert_value_to(page, eDestUnit);
2664
0
    }
2665
2666
    void connect_value_changed(const Link<MetricSpinButton&, void>& rLink)
2667
0
    {
2668
0
        m_aValueChangedHdl = rLink;
2669
0
    }
2670
2671
0
    sal_Int64 normalize(sal_Int64 nValue) const { return m_xSpinButton->normalize(nValue); }
2672
0
    sal_Int64 denormalize(sal_Int64 nValue) const { return m_xSpinButton->denormalize(nValue); }
2673
0
    void set_sensitive(bool sensitive) { m_xSpinButton->set_sensitive(sensitive); }
2674
0
    bool get_sensitive() const { return m_xSpinButton->get_sensitive(); }
2675
0
    bool get_visible() const { return m_xSpinButton->get_visible(); }
2676
0
    void grab_focus() { m_xSpinButton->grab_focus(); }
2677
0
    bool has_focus() const { return m_xSpinButton->has_focus(); }
2678
0
    void show() { m_xSpinButton->show(); }
2679
0
    void set_visible(bool bShow) { m_xSpinButton->set_visible(bShow); }
2680
0
    void hide() { m_xSpinButton->hide(); }
2681
    void set_digits(unsigned int digits);
2682
0
    void set_accessible_name(const OUString& rName) { m_xSpinButton->set_accessible_name(rName); }
2683
0
    unsigned int get_digits() const { return m_xSpinButton->get_digits(); }
2684
0
    void save_value() { m_xSpinButton->save_value(); }
2685
    bool get_value_changed_from_saved() const
2686
0
    {
2687
0
        return m_xSpinButton->get_value_changed_from_saved();
2688
0
    }
2689
0
    void set_text(const OUString& rText) { m_xSpinButton->set_text(rText); }
2690
0
    OUString get_text() const { return m_xSpinButton->get_text(); }
2691
    void set_size_request(int nWidth, int nHeight)
2692
0
    {
2693
0
        m_xSpinButton->set_size_request(nWidth, nHeight);
2694
0
    }
2695
0
    Size get_size_request() const { return m_xSpinButton->get_size_request(); }
2696
0
    Size get_preferred_size() const { return m_xSpinButton->get_preferred_size(); }
2697
    void connect_focus_in(const Link<Widget&, void>& rLink)
2698
0
    {
2699
0
        m_xSpinButton->connect_focus_in(rLink);
2700
0
    }
2701
    void connect_focus_out(const Link<Widget&, void>& rLink)
2702
0
    {
2703
0
        m_xSpinButton->connect_focus_out(rLink);
2704
0
    }
2705
0
    OUString get_buildable_name() const { return m_xSpinButton->get_buildable_name(); }
2706
0
    void set_help_id(const OUString& rName) { m_xSpinButton->set_help_id(rName); }
2707
0
    void set_position(int nCursorPos) { m_xSpinButton->set_position(nCursorPos); }
2708
    // set the width of the underlying widget in characters, this setting is
2709
    // invalidated when changing the units, range or digits, so to have effect
2710
    // must come after changing those values
2711
0
    void set_width_chars(int nChars) { m_xSpinButton->set_width_chars(nChars); }
2712
0
    int get_width_chars() const { return m_xSpinButton->get_width_chars(); }
2713
0
    weld::SpinButton& get_widget() { return *m_xSpinButton; }
2714
};
2715
2716
enum class LabelType
2717
{
2718
    Normal,
2719
    Warning,
2720
    Error,
2721
    Title, // this is intended to be used against the background set by set_title_background
2722
};
2723
2724
class VCL_DLLPUBLIC Label : virtual public Widget
2725
{
2726
public:
2727
    virtual void set_label(const OUString& rText) = 0;
2728
    virtual OUString get_label() const = 0;
2729
    virtual void set_mnemonic_widget(Widget* pTarget) = 0;
2730
    // font size is in points, not pixels, e.g. see Window::[G]etPointFont
2731
    virtual void set_font(const vcl::Font& rFont) = 0;
2732
    virtual void set_label_type(LabelType eType) = 0;
2733
    /*
2734
       If you want to set a warning or error state, see set_label_type
2735
       instead.
2736
    */
2737
    virtual void set_font_color(const Color& rColor) = 0;
2738
};
2739
2740
class VCL_DLLPUBLIC TextView : virtual public Widget
2741
{
2742
    friend class ::LOKTrigger;
2743
2744
private:
2745
    OUString m_sSavedValue;
2746
2747
protected:
2748
    Link<TextView&, void> m_aChangeHdl;
2749
    Link<TextView&, void> m_aVValueChangeHdl;
2750
    Link<TextView&, void> m_aCursorPositionHdl;
2751
2752
0
    void signal_changed() { m_aChangeHdl.Call(*this); }
2753
2754
    void signal_cursor_position()
2755
0
    {
2756
0
        if (notify_events_disabled())
2757
0
            return;
2758
0
        m_aCursorPositionHdl.Call(*this);
2759
0
    }
2760
2761
0
    void signal_vadjustment_value_changed() { m_aVValueChangeHdl.Call(*this); }
2762
2763
    virtual void do_set_text(const OUString& rText) = 0;
2764
    virtual void do_select_region(int nStartPos, int nEndPos) = 0;
2765
    virtual void do_replace_selection(const OUString& rText) = 0;
2766
2767
public:
2768
    void set_text(const OUString& rText)
2769
0
    {
2770
0
        disable_notify_events();
2771
0
        do_set_text(rText);
2772
0
        enable_notify_events();
2773
0
    }
2774
2775
    virtual OUString get_text() const = 0;
2776
2777
    // if nStartPos or nEndPos is -1 the max available text pos will be used
2778
    void select_region(int nStartPos, int nEndPos)
2779
0
    {
2780
0
        disable_notify_events();
2781
0
        do_select_region(nStartPos, nEndPos);
2782
0
        enable_notify_events();
2783
0
    }
2784
2785
    // returns true if the selection has nonzero length
2786
    virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) = 0;
2787
2788
    void replace_selection(const OUString& rText)
2789
0
    {
2790
0
        disable_notify_events();
2791
0
        do_replace_selection(rText);
2792
0
        enable_notify_events();
2793
0
    }
2794
2795
    virtual void set_editable(bool bEditable) = 0;
2796
    virtual bool get_editable() const = 0;
2797
    virtual void set_monospace(bool bMonospace) = 0;
2798
    // The maximum length of the entry. Use 0 for no maximum
2799
    virtual void set_max_length(int nChars) = 0;
2800
    int get_height_rows(int nRows) const
2801
0
    {
2802
0
        //can improve this if needed
2803
0
        return get_text_height() * nRows;
2804
0
    }
2805
2806
    // font size is in points, not pixels, e.g. see Window::[G]etPointFont
2807
    virtual void set_font(const vcl::Font& rFont) = 0;
2808
2809
    /*
2810
       Typically you want to avoid the temptation of customizing
2811
       font colors
2812
    */
2813
    virtual void set_font_color(const Color& rColor) = 0;
2814
2815
0
    void save_value() { m_sSavedValue = get_text(); }
2816
0
    bool get_value_changed_from_saved() const { return m_sSavedValue != get_text(); }
2817
2818
0
    void connect_changed(const Link<TextView&, void>& rLink) { m_aChangeHdl = rLink; }
2819
    virtual void connect_cursor_position(const Link<TextView&, void>& rLink)
2820
0
    {
2821
0
        m_aCursorPositionHdl = rLink;
2822
0
    }
2823
2824
    // returns true if pressing up would move the cursor
2825
    // doesn't matter if that move is to a previous line or to the start of the
2826
    // current line just so long as the cursor would move
2827
    virtual bool can_move_cursor_with_up() const = 0;
2828
2829
    // returns true if pressing down would move the cursor
2830
    // doesn't matter if that move is to a next line or to the end of the
2831
    // current line just so long as the cursor would move
2832
    virtual bool can_move_cursor_with_down() const = 0;
2833
2834
    virtual void cut_clipboard() = 0;
2835
    virtual void copy_clipboard() = 0;
2836
    virtual void paste_clipboard() = 0;
2837
2838
    virtual void set_alignment(TxtAlign eXAlign) = 0;
2839
2840
    virtual int vadjustment_get_value() const = 0;
2841
    virtual int vadjustment_get_upper() const = 0;
2842
    virtual int vadjustment_get_page_size() const = 0;
2843
    virtual void vadjustment_set_value(int value) = 0;
2844
    void connect_vadjustment_value_changed(const Link<TextView&, void>& rLink)
2845
0
    {
2846
0
        m_aVValueChangeHdl = rLink;
2847
0
    }
2848
};
2849
2850
class VCL_DLLPUBLIC Expander : virtual public Widget
2851
{
2852
    Link<Expander&, void> m_aExpandedHdl;
2853
2854
protected:
2855
0
    void signal_expanded() { m_aExpandedHdl.Call(*this); }
2856
2857
public:
2858
    virtual void set_label(const OUString& rText) = 0;
2859
    virtual OUString get_label() const = 0;
2860
    virtual bool get_expanded() const = 0;
2861
    virtual void set_expanded(bool bExpand) = 0;
2862
2863
0
    void connect_expanded(const Link<Expander&, void>& rLink) { m_aExpandedHdl = rLink; }
2864
};
2865
2866
class VCL_DLLPUBLIC DrawingArea : virtual public Widget
2867
{
2868
public:
2869
    typedef std::pair<vcl::RenderContext&, const tools::Rectangle&> draw_args;
2870
2871
protected:
2872
    Link<draw_args, void> m_aDrawHdl;
2873
    Link<const CommandEvent&, bool> m_aCommandHdl;
2874
    Link<Widget&, tools::Rectangle> m_aGetFocusRectHdl;
2875
    Link<tools::Rectangle&, OUString> m_aQueryTooltipHdl;
2876
    // if handler returns true, drag is disallowed
2877
    Link<DrawingArea&, bool> m_aDragBeginHdl;
2878
    // return position of cursor, fill OUString& with surrounding text
2879
    Link<OUString&, int> m_aGetSurroundingHdl;
2880
    // attempt to delete the range, return true if successful
2881
    Link<const Selection&, bool> m_aDeleteSurroundingHdl;
2882
2883
    OUString signal_query_tooltip(tools::Rectangle& rHelpArea)
2884
0
    {
2885
0
        return m_aQueryTooltipHdl.Call(rHelpArea);
2886
0
    }
2887
2888
    int signal_im_context_get_surrounding(OUString& rSurroundingText)
2889
0
    {
2890
0
        if (!m_aGetSurroundingHdl.IsSet())
2891
0
            return -1;
2892
0
        return m_aGetSurroundingHdl.Call(rSurroundingText);
2893
0
    }
2894
2895
    bool signal_im_context_delete_surrounding(const Selection& rRange)
2896
0
    {
2897
0
        return m_aDeleteSurroundingHdl.Call(rRange);
2898
0
    }
2899
2900
public:
2901
0
    void connect_draw(const Link<draw_args, void>& rLink) { m_aDrawHdl = rLink; }
2902
0
    void connect_command(const Link<const CommandEvent&, bool>& rLink) { m_aCommandHdl = rLink; }
2903
    void connect_focus_rect(const Link<Widget&, tools::Rectangle>& rLink)
2904
0
    {
2905
0
        m_aGetFocusRectHdl = rLink;
2906
0
    }
2907
    void connect_query_tooltip(const Link<tools::Rectangle&, OUString>& rLink)
2908
0
    {
2909
0
        m_aQueryTooltipHdl = rLink;
2910
0
    }
2911
0
    void connect_drag_begin(const Link<DrawingArea&, bool>& rLink) { m_aDragBeginHdl = rLink; }
2912
    void connect_im_context_get_surrounding(const Link<OUString&, int>& rLink)
2913
0
    {
2914
0
        m_aGetSurroundingHdl = rLink;
2915
0
    }
2916
    void connect_im_context_delete_surrounding(const Link<const Selection&, bool>& rLink)
2917
0
    {
2918
0
        m_aDeleteSurroundingHdl = rLink;
2919
0
    }
2920
    virtual void queue_draw() = 0;
2921
    virtual void queue_draw_area(int x, int y, int width, int height) = 0;
2922
2923
    virtual void enable_drag_source(rtl::Reference<TransferDataContainer>& rTransferable,
2924
                                    sal_uInt8 eDNDConstants)
2925
        = 0;
2926
2927
    virtual void set_cursor(PointerStyle ePointerStyle) = 0;
2928
2929
    virtual Point get_pointer_position() const = 0;
2930
2931
    virtual void set_input_context(const InputContext& rInputContext) = 0;
2932
    virtual void im_context_set_cursor_location(const tools::Rectangle& rCursorRect,
2933
                                                int nExtTextInputWidth)
2934
        = 0;
2935
2936
    // use return here just to generate matching VirtualDevices
2937
    virtual OutputDevice& get_ref_device() = 0;
2938
2939
    virtual rtl::Reference<comphelper::OAccessible> get_accessible_parent() = 0;
2940
    virtual a11yrelationset get_accessible_relation_set() = 0;
2941
    virtual AbsoluteScreenPixelPoint get_accessible_location_on_screen() = 0;
2942
2943
private:
2944
    friend class ::LOKTrigger;
2945
2946
    virtual void click(const Point&) = 0;
2947
2948
0
    virtual void dblclick(const Point&){};
2949
2950
0
    virtual void mouse_up(const Point&){};
2951
2952
0
    virtual void mouse_down(const Point&){};
2953
2954
0
    virtual void mouse_move(const Point&){};
2955
};
2956
2957
enum class Placement
2958
{
2959
    Under,
2960
    End
2961
};
2962
2963
class VCL_DLLPUBLIC Menu
2964
{
2965
    friend class ::LOKTrigger;
2966
2967
    Link<const OUString&, void> m_aActivateHdl;
2968
2969
protected:
2970
0
    void signal_activate(const OUString& rIdent) { m_aActivateHdl.Call(rIdent); }
2971
2972
public:
2973
    virtual OUString popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect,
2974
                                   Placement ePlace = Placement::Under)
2975
        = 0;
2976
2977
0
    void connect_activate(const Link<const OUString&, void>& rLink) { m_aActivateHdl = rLink; }
2978
2979
    virtual void set_sensitive(const OUString& rIdent, bool bSensitive) = 0;
2980
    virtual bool get_sensitive(const OUString& rIdent) const = 0;
2981
    virtual void set_label(const OUString& rIdent, const OUString& rLabel) = 0;
2982
    virtual OUString get_label(const OUString& rIdent) const = 0;
2983
    virtual void set_active(const OUString& rIdent, bool bActive) = 0;
2984
    virtual bool get_active(const OUString& rIdent) const = 0;
2985
    virtual void set_visible(const OUString& rIdent, bool bVisible) = 0;
2986
2987
    virtual void insert(int pos, const OUString& rId, const OUString& rStr,
2988
                        const OUString* pIconName, VirtualDevice* pImageSurface,
2989
                        const css::uno::Reference<css::graphic::XGraphic>& rImage,
2990
                        TriState eCheckRadioFalse)
2991
        = 0;
2992
2993
    virtual void set_item_help_id(const OUString& rIdent, const OUString& rHelpId) = 0;
2994
    virtual void remove(const OUString& rId) = 0;
2995
2996
    virtual void clear() = 0;
2997
2998
    virtual void insert_separator(int pos, const OUString& rId) = 0;
2999
0
    void append_separator(const OUString& rId) { insert_separator(-1, rId); }
3000
3001
    void append(const OUString& rId, const OUString& rStr)
3002
0
    {
3003
0
        insert(-1, rId, rStr, nullptr, nullptr, nullptr, TRISTATE_INDET);
3004
0
    }
3005
    void append_check(const OUString& rId, const OUString& rStr)
3006
0
    {
3007
0
        insert(-1, rId, rStr, nullptr, nullptr, nullptr, TRISTATE_TRUE);
3008
0
    }
3009
    void append_radio(const OUString& rId, const OUString& rStr)
3010
0
    {
3011
0
        insert(-1, rId, rStr, nullptr, nullptr, nullptr, TRISTATE_FALSE);
3012
0
    }
3013
    void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
3014
0
    {
3015
0
        insert(-1, rId, rStr, &rImage, nullptr, nullptr, TRISTATE_INDET);
3016
0
    }
3017
    void append(const OUString& rId, const OUString& rStr, VirtualDevice& rImage)
3018
0
    {
3019
0
        insert(-1, rId, rStr, nullptr, &rImage, nullptr, TRISTATE_INDET);
3020
0
    }
3021
3022
    // return the number of toplevel nodes
3023
    virtual int n_children() const = 0;
3024
3025
    virtual OUString get_id(int pos) const = 0;
3026
3027
0
    virtual ~Menu() {}
3028
};
3029
3030
class VCL_DLLPUBLIC Popover : virtual public Container
3031
{
3032
    friend class ::LOKTrigger;
3033
3034
private:
3035
    Link<weld::Popover&, void> m_aCloseHdl;
3036
3037
protected:
3038
0
    void signal_closed() { m_aCloseHdl.Call(*this); }
3039
3040
public:
3041
    virtual void popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect,
3042
                               Placement ePlace = Placement::Under)
3043
        = 0;
3044
    virtual void popdown() = 0;
3045
3046
    virtual void resize_to_request() = 0;
3047
3048
0
    void connect_closed(const Link<weld::Popover&, void>& rLink) { m_aCloseHdl = rLink; }
3049
};
3050
3051
class VCL_DLLPUBLIC Toolbar : virtual public Widget
3052
{
3053
    Link<const OUString&, void> m_aClickHdl;
3054
    Link<const OUString&, void> m_aToggleMenuHdl;
3055
3056
protected:
3057
    friend class ::LOKTrigger;
3058
3059
0
    void signal_clicked(const OUString& rIdent) { m_aClickHdl.Call(rIdent); }
3060
0
    void signal_toggle_menu(const OUString& rIdent) { m_aToggleMenuHdl.Call(rIdent); }
3061
3062
public:
3063
    virtual void set_item_sensitive(const OUString& rIdent, bool bSensitive) = 0;
3064
    virtual bool get_item_sensitive(const OUString& rIdent) const = 0;
3065
    virtual void set_item_active(const OUString& rIdent, bool bActive) = 0;
3066
    virtual bool get_item_active(const OUString& rIdent) const = 0;
3067
    virtual void set_menu_item_active(const OUString& rIdent, bool bActive) = 0;
3068
    virtual bool get_menu_item_active(const OUString& rIdent) const = 0;
3069
    virtual void set_item_menu(const OUString& rIdent, weld::Menu* pMenu) = 0;
3070
    virtual void set_item_popover(const OUString& rIdent, weld::Widget* pPopover) = 0;
3071
    virtual void set_item_visible(const OUString& rIdent, bool bVisible) = 0;
3072
    virtual void set_item_help_id(const OUString& rIdent, const OUString& rHelpId) = 0;
3073
    virtual bool get_item_visible(const OUString& rIdent) const = 0;
3074
    virtual void set_item_label(const OUString& rIdent, const OUString& rLabel) = 0;
3075
    virtual OUString get_item_label(const OUString& rIdent) const = 0;
3076
    virtual void set_item_tooltip_text(const OUString& rIdent, const OUString& rTip) = 0;
3077
    virtual OUString get_item_tooltip_text(const OUString& rIdent) const = 0;
3078
    virtual void set_item_icon_name(const OUString& rIdent, const OUString& rIconName) = 0;
3079
    virtual void set_item_image_mirrored(const OUString& rIdent, bool bMirrored) = 0;
3080
    virtual void set_item_image(const OUString& rIdent,
3081
                                const css::uno::Reference<css::graphic::XGraphic>& rIcon)
3082
        = 0;
3083
    virtual void set_item_image(const OUString& rIdent, VirtualDevice* pDevice) = 0;
3084
3085
    virtual void insert_item(int pos, const OUString& rId) = 0;
3086
    virtual void insert_separator(int pos, const OUString& rId) = 0;
3087
0
    void append_separator(const OUString& rId) { insert_separator(-1, rId); }
3088
3089
    virtual int get_n_items() const = 0;
3090
    virtual OUString get_item_ident(int nIndex) const = 0;
3091
    virtual void set_item_ident(int nIndex, const OUString& rIdent) = 0;
3092
    virtual void set_item_label(int nIndex, const OUString& rLabel) = 0;
3093
    virtual void set_item_image(int nIndex,
3094
                                const css::uno::Reference<css::graphic::XGraphic>& rIcon)
3095
        = 0;
3096
    virtual void set_item_tooltip_text(int nIndex, const OUString& rTip) = 0;
3097
    virtual void set_item_accessible_name(int nIndex, const OUString& rName) = 0;
3098
    virtual void set_item_accessible_name(const OUString& rIdent, const OUString& rName) = 0;
3099
3100
    virtual vcl::ImageType get_icon_size() const = 0;
3101
    virtual void set_icon_size(vcl::ImageType eType) = 0;
3102
3103
    // return what modifiers are held
3104
    virtual sal_uInt16 get_modifier_state() const = 0;
3105
3106
    // This function returns the position a new item should be inserted if dnd
3107
    // is dropped at rPoint
3108
    virtual int get_drop_index(const Point& rPoint) const = 0;
3109
3110
0
    void connect_clicked(const Link<const OUString&, void>& rLink) { m_aClickHdl = rLink; }
3111
    void connect_menu_toggled(const Link<const OUString&, void>& rLink)
3112
0
    {
3113
0
        m_aToggleMenuHdl = rLink;
3114
0
    }
3115
};
3116
3117
class VCL_DLLPUBLIC Scrollbar : virtual public Widget
3118
{
3119
    Link<Scrollbar&, void> m_aValueChangeHdl;
3120
3121
protected:
3122
0
    void signal_adjustment_value_changed() { m_aValueChangeHdl.Call(*this); }
3123
3124
public:
3125
    virtual void adjustment_configure(int value, int lower, int upper, int step_increment,
3126
                                      int page_increment, int page_size)
3127
        = 0;
3128
    virtual int adjustment_get_value() const = 0;
3129
    virtual void adjustment_set_value(int value) = 0;
3130
    virtual int adjustment_get_upper() const = 0;
3131
    virtual void adjustment_set_upper(int upper) = 0;
3132
    virtual int adjustment_get_page_size() const = 0;
3133
    virtual void adjustment_set_page_size(int size) = 0;
3134
    virtual int adjustment_get_page_increment() const = 0;
3135
    virtual void adjustment_set_page_increment(int size) = 0;
3136
    virtual int adjustment_get_step_increment() const = 0;
3137
    virtual void adjustment_set_step_increment(int size) = 0;
3138
    virtual int adjustment_get_lower() const = 0;
3139
    virtual void adjustment_set_lower(int lower) = 0;
3140
3141
    virtual int get_scroll_thickness() const = 0;
3142
    virtual void set_scroll_thickness(int nThickness) = 0;
3143
    virtual void set_scroll_swap_arrows(bool bSwap) = 0;
3144
3145
    virtual ScrollType get_scroll_type() const = 0;
3146
3147
    void connect_adjustment_value_changed(const Link<Scrollbar&, void>& rLink)
3148
0
    {
3149
0
        m_aValueChangeHdl = rLink;
3150
0
    }
3151
};
3152
3153
class VCL_DLLPUBLIC ColorChooserDialog : virtual public Dialog
3154
{
3155
public:
3156
    virtual void set_color(const Color& rColor) = 0;
3157
    virtual Color get_color() const = 0;
3158
};
3159
3160
class VCL_DLLPUBLIC SizeGroup
3161
{
3162
public:
3163
    virtual void add_widget(weld::Widget* pWidget) = 0;
3164
    // the default mode is VclSizeGroupMode::Horizontal
3165
    virtual void set_mode(VclSizeGroupMode eMode) = 0;
3166
0
    virtual ~SizeGroup() {}
3167
};
3168
3169
class VCL_DLLPUBLIC Builder
3170
{
3171
public:
3172
    virtual std::unique_ptr<MessageDialog> weld_message_dialog(const OUString& id) = 0;
3173
    virtual std::unique_ptr<Dialog> weld_dialog(const OUString& id) = 0;
3174
    virtual std::unique_ptr<Assistant> weld_assistant(const OUString& id) = 0;
3175
    virtual std::unique_ptr<Widget> weld_widget(const OUString& id) = 0;
3176
    virtual std::unique_ptr<Container> weld_container(const OUString& id) = 0;
3177
    virtual std::unique_ptr<Box> weld_box(const OUString& id) = 0;
3178
    virtual std::unique_ptr<Grid> weld_grid(const OUString& id) = 0;
3179
    virtual std::unique_ptr<Paned> weld_paned(const OUString& id) = 0;
3180
    virtual std::unique_ptr<Button> weld_button(const OUString& id) = 0;
3181
    virtual std::unique_ptr<MenuButton> weld_menu_button(const OUString& id) = 0;
3182
    virtual std::unique_ptr<Frame> weld_frame(const OUString& id) = 0;
3183
    /* bUserManagedScrolling of true means that the automatic scrolling of the window is disabled
3184
       and the owner must specifically listen to adjustment changes and react appropriately to them.
3185
    */
3186
    virtual std::unique_ptr<ScrolledWindow> weld_scrolled_window(const OUString& id,
3187
                                                                 bool bUserManagedScrolling = false)
3188
        = 0;
3189
    virtual std::unique_ptr<Notebook> weld_notebook(const OUString& id) = 0;
3190
    virtual std::unique_ptr<ToggleButton> weld_toggle_button(const OUString& id) = 0;
3191
    virtual std::unique_ptr<RadioButton> weld_radio_button(const OUString& id) = 0;
3192
    virtual std::unique_ptr<CheckButton> weld_check_button(const OUString& id) = 0;
3193
    virtual std::unique_ptr<LinkButton> weld_link_button(const OUString& id) = 0;
3194
    virtual std::unique_ptr<SpinButton> weld_spin_button(const OUString& id) = 0;
3195
    virtual std::unique_ptr<MetricSpinButton> weld_metric_spin_button(const OUString& id,
3196
                                                                      FieldUnit eUnit)
3197
        = 0;
3198
    virtual std::unique_ptr<FormattedSpinButton> weld_formatted_spin_button(const OUString& id) = 0;
3199
    virtual std::unique_ptr<ComboBox> weld_combo_box(const OUString& id) = 0;
3200
    virtual std::unique_ptr<TreeView> weld_tree_view(const OUString& id) = 0;
3201
    virtual std::unique_ptr<IconView> weld_icon_view(const OUString& id) = 0;
3202
    virtual std::unique_ptr<Label> weld_label(const OUString& id) = 0;
3203
    virtual std::unique_ptr<TextView> weld_text_view(const OUString& id) = 0;
3204
    virtual std::unique_ptr<Expander> weld_expander(const OUString& id) = 0;
3205
    virtual std::unique_ptr<Entry> weld_entry(const OUString& id) = 0;
3206
    virtual std::unique_ptr<Scale> weld_scale(const OUString& id) = 0;
3207
    virtual std::unique_ptr<ProgressBar> weld_progress_bar(const OUString& id) = 0;
3208
    virtual std::unique_ptr<LevelBar> weld_level_bar(const OUString& id) = 0;
3209
    virtual std::unique_ptr<Spinner> weld_spinner(const OUString& id) = 0;
3210
    virtual std::unique_ptr<Image> weld_image(const OUString& id) = 0;
3211
    virtual std::unique_ptr<Calendar> weld_calendar(const OUString& id) = 0;
3212
    virtual std::unique_ptr<DrawingArea>
3213
    weld_drawing_area(const OUString& id,
3214
                      const rtl::Reference<comphelper::OAccessible>& rA11yImpl = nullptr,
3215
                      FactoryFunction pUITestFactoryFunction = nullptr, void* pUserData = nullptr)
3216
        = 0;
3217
    virtual std::unique_ptr<EntryTreeView> weld_entry_tree_view(const OUString& containerid,
3218
                                                                const OUString& entryid,
3219
                                                                const OUString& treeviewid)
3220
        = 0;
3221
    virtual std::unique_ptr<Menu> weld_menu(const OUString& id) = 0;
3222
    virtual std::unique_ptr<Popover> weld_popover(const OUString& id) = 0;
3223
    virtual std::unique_ptr<Toolbar> weld_toolbar(const OUString& id) = 0;
3224
    virtual std::unique_ptr<Scrollbar> weld_scrollbar(const OUString& id) = 0;
3225
    virtual std::unique_ptr<SizeGroup> create_size_group() = 0;
3226
    /* return a Dialog suitable to take a screenshot of containing the contents of the .ui file.
3227
3228
       If the toplevel element is a dialog, that will be returned
3229
       If the toplevel is not a dialog, a dialog will be created and the contents of the .ui
3230
       inserted into it
3231
    */
3232
    virtual std::unique_ptr<Window> create_screenshot_window() = 0;
3233
0
    virtual ~Builder() {}
3234
};
3235
3236
class VCL_DLLPUBLIC DialogController : public std::enable_shared_from_this<DialogController>
3237
{
3238
public:
3239
    virtual Dialog* getDialog() = 0;
3240
    const Dialog* getConstDialog() const
3241
0
    {
3242
0
        return const_cast<DialogController*>(this)->getDialog();
3243
0
    }
3244
0
    virtual short run() { return getDialog()->run(); }
3245
    static bool runAsync(const std::shared_ptr<DialogController>& rController,
3246
                         const std::function<void(sal_Int32)>&);
3247
0
    void set_title(const OUString& rTitle) { getDialog()->set_title(rTitle); }
3248
0
    OUString get_title() const { return getConstDialog()->get_title(); }
3249
0
    void set_help_id(const OUString& rHelpId) { getDialog()->set_help_id(rHelpId); }
3250
0
    OUString get_help_id() const { return getConstDialog()->get_help_id(); }
3251
0
    void response(int nResponse) { getDialog()->response(nResponse); }
3252
    virtual ~DialogController();
3253
};
3254
3255
class VCL_DLLPUBLIC GenericDialogController : public DialogController
3256
{
3257
protected:
3258
    std::unique_ptr<weld::Builder> m_xBuilder;
3259
    std::shared_ptr<weld::Dialog> m_xDialog;
3260
3261
public:
3262
    GenericDialogController(weld::Widget* pParent, const OUString& rUIFile,
3263
                            const OUString& rDialogId, bool bMobile = false);
3264
    virtual Dialog* getDialog() override;
3265
    virtual ~GenericDialogController() override;
3266
};
3267
3268
class VCL_DLLPUBLIC MessageDialogController : public DialogController
3269
{
3270
protected:
3271
    std::unique_ptr<weld::Builder> m_xBuilder;
3272
    std::unique_ptr<weld::MessageDialog> m_xDialog;
3273
    std::unique_ptr<weld::Container> m_xContentArea;
3274
    std::unique_ptr<weld::Widget> m_xRelocate;
3275
    std::unique_ptr<weld::Container> m_xOrigParent;
3276
3277
public:
3278
    /* @param rRelocateId - optional argument of the name of a widget in the .ui file
3279
                            which should be relocated into the content area of the dialog.
3280
3281
                            e.g. a checkbox for a "Never show this again" option.
3282
3283
                            This results in the named widget relocating to the same container
3284
                            as the messages.  This enables aligning the extra widget with the
3285
                            message labels in the content area container which doesn't
3286
                            explicitly exist in the ui description, but is only implied.
3287
    */
3288
    MessageDialogController(weld::Widget* pParent, const OUString& rUIFile,
3289
                            const OUString& rDialogId, const OUString& rRelocateId = {});
3290
    virtual Dialog* getDialog() override;
3291
    virtual ~MessageDialogController() override;
3292
0
    void set_primary_text(const OUString& rText) { m_xDialog->set_primary_text(rText); }
3293
0
    OUString get_primary_text() const { return m_xDialog->get_primary_text(); }
3294
0
    void set_secondary_text(const OUString& rText) { m_xDialog->set_secondary_text(rText); }
3295
0
    OUString get_secondary_text() const { return m_xDialog->get_secondary_text(); }
3296
0
    void set_default_response(int nResponse) { m_xDialog->set_default_response(nResponse); }
3297
};
3298
3299
class VCL_DLLPUBLIC AssistantController : public DialogController
3300
{
3301
protected:
3302
    std::unique_ptr<weld::Builder> m_xBuilder;
3303
    std::unique_ptr<weld::Assistant> m_xAssistant;
3304
3305
public:
3306
    SAL_DLLPRIVATE AssistantController(weld::Widget* pParent, const OUString& rUIFile,
3307
                                       const OUString& rDialogId);
3308
    virtual Dialog* getDialog() override;
3309
    SAL_DLLPRIVATE virtual ~AssistantController() override;
3310
};
3311
3312
void Dialog::set_default_response(int nResponse)
3313
0
{
3314
0
    std::unique_ptr<weld::Button> pButton = weld_button_for_response(nResponse);
3315
0
    change_default_button(nullptr, pButton.get());
3316
0
}
3317
}
3318
3319
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */