1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 #include <vcl/weld.hxx>
12 #include <vcl/svapp.hxx>
13 #include <vcl/syswin.hxx>
14 #include <vcl/settings.hxx>
15 #include <vcl/virdev.hxx>
16 #include <vcl/ctrl.hxx>
17 #include <vcl/toolkit/edit.hxx>
18 #include <vcl/formatter.hxx>
19 #include <vcl/toolkit/spinfld.hxx>
20 #include <vcl/toolkit/fixed.hxx>
21 #include <vcl/toolkit/lstbox.hxx>
22 #include <vcl/toolkit/menubtn.hxx>
23 #include <vcl/toolkit/combobox.hxx>
24 #include <vcl/tabctrl.hxx>
25 #include <vcl/layout.hxx>
26 #include <vcl/toolkit/svtabbx.hxx>
27 #include <vcl/toolkit/svlbitm.hxx>
28 #include <o3tl/sorted_vector.hxx>
29 #include "iconview.hxx"
30 #include "listbox.hxx"
31 #include "messagedialog.hxx"
33 class SalInstanceBuilder
: public weld::Builder
36 std::unique_ptr
<VclBuilder
> m_xBuilder
;
37 VclPtr
<vcl::Window
> m_aOwnedToplevel
;
40 SalInstanceBuilder(vcl::Window
* pParent
, const OUString
& rUIRoot
, const OUString
& rUIFile
,
41 const css::uno::Reference
<css::frame::XFrame
>& rFrame
42 = css::uno::Reference
<css::frame::XFrame
>());
44 virtual std::unique_ptr
<weld::MessageDialog
> weld_message_dialog(const OString
& id
) override
;
46 virtual std::unique_ptr
<weld::Dialog
> weld_dialog(const OString
& id
) override
;
48 virtual std::unique_ptr
<weld::Assistant
> weld_assistant(const OString
& id
) override
;
50 virtual std::unique_ptr
<weld::Window
> create_screenshot_window() override
;
52 virtual std::unique_ptr
<weld::Widget
> weld_widget(const OString
& id
) override
;
54 virtual std::unique_ptr
<weld::Container
> weld_container(const OString
& id
) override
;
56 virtual std::unique_ptr
<weld::Box
> weld_box(const OString
& id
) override
;
58 virtual std::unique_ptr
<weld::Paned
> weld_paned(const OString
& id
) override
;
60 virtual std::unique_ptr
<weld::Frame
> weld_frame(const OString
& id
) override
;
62 virtual std::unique_ptr
<weld::ScrolledWindow
>
63 weld_scrolled_window(const OString
& id
, bool bUserManagedScrolling
= false) override
;
65 virtual std::unique_ptr
<weld::Notebook
> weld_notebook(const OString
& id
) override
;
67 virtual std::unique_ptr
<weld::Button
> weld_button(const OString
& id
) override
;
69 virtual std::unique_ptr
<weld::MenuButton
> weld_menu_button(const OString
& id
) override
;
71 virtual std::unique_ptr
<weld::MenuToggleButton
>
72 weld_menu_toggle_button(const OString
& id
) override
;
74 virtual std::unique_ptr
<weld::LinkButton
> weld_link_button(const OString
& id
) override
;
76 virtual std::unique_ptr
<weld::ToggleButton
> weld_toggle_button(const OString
& id
) override
;
78 virtual std::unique_ptr
<weld::RadioButton
> weld_radio_button(const OString
& id
) override
;
80 virtual std::unique_ptr
<weld::CheckButton
> weld_check_button(const OString
& id
) override
;
82 virtual std::unique_ptr
<weld::Scale
> weld_scale(const OString
& id
) override
;
84 virtual std::unique_ptr
<weld::ProgressBar
> weld_progress_bar(const OString
& id
) override
;
86 virtual std::unique_ptr
<weld::Spinner
> weld_spinner(const OString
& id
) override
;
88 virtual std::unique_ptr
<weld::Image
> weld_image(const OString
& id
) override
;
90 virtual std::unique_ptr
<weld::Calendar
> weld_calendar(const OString
& id
) override
;
92 virtual std::unique_ptr
<weld::Entry
> weld_entry(const OString
& id
) override
;
94 virtual std::unique_ptr
<weld::SpinButton
> weld_spin_button(const OString
& id
) override
;
96 virtual std::unique_ptr
<weld::MetricSpinButton
>
97 weld_metric_spin_button(const OString
& id
, FieldUnit eUnit
) override
;
99 virtual std::unique_ptr
<weld::FormattedSpinButton
>
100 weld_formatted_spin_button(const OString
& id
) override
;
102 virtual std::unique_ptr
<weld::ComboBox
> weld_combo_box(const OString
& id
) override
;
104 virtual std::unique_ptr
<weld::EntryTreeView
>
105 weld_entry_tree_view(const OString
& containerid
, const OString
& entryid
,
106 const OString
& treeviewid
) override
;
108 virtual std::unique_ptr
<weld::TreeView
> weld_tree_view(const OString
& id
) override
;
110 virtual std::unique_ptr
<weld::IconView
> weld_icon_view(const OString
& id
) override
;
112 virtual std::unique_ptr
<weld::Label
> weld_label(const OString
& id
) override
;
114 virtual std::unique_ptr
<weld::TextView
> weld_text_view(const OString
& id
) override
;
116 virtual std::unique_ptr
<weld::Expander
> weld_expander(const OString
& id
) override
;
118 virtual std::unique_ptr
<weld::DrawingArea
>
119 weld_drawing_area(const OString
& id
, const a11yref
& rA11yImpl
= nullptr,
120 FactoryFunction pUITestFactoryFunction
= nullptr,
121 void* pUserData
= nullptr) override
;
123 virtual std::unique_ptr
<weld::Menu
> weld_menu(const OString
& id
) override
;
125 virtual std::unique_ptr
<weld::Popover
> weld_popover(const OString
& id
) override
;
127 virtual std::unique_ptr
<weld::Toolbar
> weld_toolbar(const OString
& id
) override
;
129 virtual std::unique_ptr
<weld::SizeGroup
> create_size_group() override
;
131 OString
get_current_page_help_id() const;
133 virtual ~SalInstanceBuilder() override
;
136 class SAL_DLLPUBLIC_RTTI SalInstanceMenu
: public weld::Menu
139 VclPtr
<PopupMenu
> m_xMenu
;
141 bool m_bTakeOwnership
;
142 sal_uInt16 m_nLastId
;
144 DECL_LINK(SelectMenuHdl
, ::Menu
*, bool);
147 SalInstanceMenu(PopupMenu
* pMenu
, bool bTakeOwnership
);
148 virtual OString
popup_at_rect(weld::Widget
* pParent
, const tools::Rectangle
& rRect
) override
;
149 virtual void set_sensitive(const OString
& rIdent
, bool bSensitive
) override
;
150 virtual bool get_sensitive(const OString
& rIdent
) const override
;
151 virtual void set_active(const OString
& rIdent
, bool bActive
) override
;
152 virtual bool get_active(const OString
& rIdent
) const override
;
153 virtual void set_label(const OString
& rIdent
, const OUString
& rLabel
) override
;
154 virtual OUString
get_label(const OString
& rIdent
) const override
;
155 virtual void set_visible(const OString
& rIdent
, bool bShow
) override
;
156 virtual void clear() override
;
157 virtual void insert(int pos
, const OUString
& rId
, const OUString
& rStr
,
158 const OUString
* pIconName
, VirtualDevice
* pImageSurface
,
159 const css::uno::Reference
<css::graphic::XGraphic
>& rImage
,
160 TriState eCheckRadioFalse
) override
;
161 virtual void insert_separator(int pos
, const OUString
& rId
) override
;
162 virtual void remove(const OString
& rId
) override
;
163 virtual OString
get_id(int pos
) const override
;
164 virtual int n_children() const override
;
165 PopupMenu
* getMenu() const;
166 virtual ~SalInstanceMenu() override
;
169 class SalInstanceWidget
: public virtual weld::Widget
172 VclPtr
<vcl::Window
> m_xWidget
;
173 SalInstanceBuilder
* m_pBuilder
;
176 DECL_LINK(EventListener
, VclWindowEvent
&, void);
177 DECL_LINK(KeyEventListener
, VclWindowEvent
&, bool);
178 DECL_LINK(MouseEventListener
, VclWindowEvent
&, void);
179 DECL_LINK(MnemonicActivateHdl
, vcl::Window
&, bool);
181 static void DoRecursivePaint(vcl::Window
* pWindow
, const Point
& rPos
, OutputDevice
& rOutput
);
183 const bool m_bTakeOwnership
;
184 bool m_bEventListener
;
185 bool m_bKeyEventListener
;
186 bool m_bMouseEventListener
;
191 void ensure_event_listener();
193 // we want the ability to mark key events as handled, so use this variant
194 // for those, we get all keystrokes in this case, so we will need to filter
196 void ensure_key_listener();
198 // we want the ability to know about mouse events that happen in our children
199 // so use this variant, we will need to filter them later
200 void ensure_mouse_listener();
202 bool IsFirstFreeze() const { return m_nFreezeCount
== 0; }
203 bool IsLastThaw() const { return m_nFreezeCount
== 1; }
205 virtual void HandleEventListener(VclWindowEvent
& rEvent
);
206 virtual bool HandleKeyEventListener(VclWindowEvent
& rEvent
);
207 virtual void HandleMouseEventListener(VclWindowEvent
& rEvent
);
210 SalInstanceWidget(vcl::Window
* pWidget
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
);
212 virtual void set_sensitive(bool sensitive
) override
;
214 virtual bool get_sensitive() const override
;
216 virtual bool get_visible() const override
;
218 virtual bool is_visible() const override
;
220 virtual void set_can_focus(bool bCanFocus
) override
;
222 virtual void grab_focus() override
;
224 virtual bool has_focus() const override
;
226 virtual bool is_active() const override
;
228 virtual bool has_child_focus() const override
;
230 virtual void set_has_default(bool has_default
) override
;
232 virtual bool get_has_default() const override
;
234 virtual void show() override
;
236 virtual void hide() override
;
238 virtual void set_size_request(int nWidth
, int nHeight
) override
;
240 virtual Size
get_size_request() const override
;
242 virtual Size
get_preferred_size() const override
;
244 virtual float get_approximate_digit_width() const override
;
246 virtual int get_text_height() const override
;
248 virtual Size
get_pixel_size(const OUString
& rText
) const override
;
250 virtual vcl::Font
get_font() override
;
252 virtual OString
get_buildable_name() const override
;
254 virtual void set_buildable_name(const OString
& rId
) override
;
256 virtual void set_help_id(const OString
& rId
) override
;
258 virtual OString
get_help_id() const override
;
260 virtual void set_grid_left_attach(int nAttach
) override
;
262 virtual int get_grid_left_attach() const override
;
264 virtual void set_grid_width(int nCols
) override
;
266 virtual void set_grid_top_attach(int nAttach
) override
;
268 virtual int get_grid_top_attach() const override
;
270 virtual void set_hexpand(bool bExpand
) override
;
272 virtual bool get_hexpand() const override
;
274 virtual void set_vexpand(bool bExpand
) override
;
276 virtual bool get_vexpand() const override
;
278 virtual void set_margin_top(int nMargin
) override
;
280 virtual void set_margin_bottom(int nMargin
) override
;
282 virtual void set_margin_start(int nMargin
) override
;
284 virtual void set_margin_end(int nMargin
) override
;
286 virtual int get_margin_top() const override
;
288 virtual int get_margin_bottom() const override
;
290 virtual int get_margin_start() const override
;
292 virtual int get_margin_end() const override
;
294 virtual void set_accessible_name(const OUString
& rName
) override
;
296 virtual void set_accessible_description(const OUString
& rDescription
) override
;
298 virtual OUString
get_accessible_name() const override
;
300 virtual OUString
get_accessible_description() const override
;
302 virtual void set_accessible_relation_labeled_by(weld::Widget
* pLabel
) override
;
304 virtual void set_accessible_relation_label_for(weld::Widget
* pLabeled
) override
;
306 virtual void set_tooltip_text(const OUString
& rTip
) override
;
308 virtual OUString
get_tooltip_text() const override
;
310 virtual void connect_focus_in(const Link
<Widget
&, void>& rLink
) override
;
312 virtual void connect_mnemonic_activate(const Link
<Widget
&, bool>& rLink
) override
;
314 virtual void connect_focus_out(const Link
<Widget
&, void>& rLink
) override
;
316 virtual void connect_size_allocate(const Link
<const Size
&, void>& rLink
) override
;
318 virtual void connect_mouse_press(const Link
<const MouseEvent
&, bool>& rLink
) override
;
320 virtual void connect_mouse_move(const Link
<const MouseEvent
&, bool>& rLink
) override
;
322 virtual void connect_mouse_release(const Link
<const MouseEvent
&, bool>& rLink
) override
;
324 virtual void connect_key_press(const Link
<const KeyEvent
&, bool>& rLink
) override
;
326 virtual void connect_key_release(const Link
<const KeyEvent
&, bool>& rLink
) override
;
328 virtual bool get_extents_relative_to(const Widget
& rRelative
, int& x
, int& y
, int& width
,
329 int& height
) const override
;
331 virtual void grab_add() override
;
333 virtual bool has_grab() const override
;
335 virtual void grab_remove() override
;
337 virtual bool get_direction() const override
;
339 virtual void set_direction(bool bRTL
) override
;
341 virtual void freeze() override
;
343 virtual void thaw() override
;
345 virtual void set_busy_cursor(bool bBusy
) override
;
347 virtual std::unique_ptr
<weld::Container
> weld_parent() const override
;
349 virtual ~SalInstanceWidget() override
;
351 vcl::Window
* getWidget() const;
353 void disable_notify_events();
355 bool notify_events_disabled();
357 void enable_notify_events();
359 virtual void queue_resize() override
;
361 virtual void help_hierarchy_foreach(const std::function
<bool(const OString
&)>& func
) override
;
363 virtual OUString
strip_mnemonic(const OUString
& rLabel
) const override
;
365 virtual VclPtr
<VirtualDevice
> create_virtual_device() const override
;
367 virtual css::uno::Reference
<css::datatransfer::dnd::XDropTarget
> get_drop_target() override
;
368 virtual css::uno::Reference
<css::datatransfer::clipboard::XClipboard
>
369 get_clipboard() const override
;
371 virtual void connect_get_property_tree(const Link
<tools::JsonWriter
&, void>& rLink
) override
;
373 virtual void get_property_tree(tools::JsonWriter
& rJsonWriter
) override
;
375 virtual void set_stack_background() override
;
377 virtual void set_title_background() override
;
379 virtual void set_toolbar_background() override
;
381 virtual void set_highlight_background() override
;
383 virtual void set_background(const Color
& rColor
) override
;
385 virtual void draw(OutputDevice
& rOutput
, const Point
& rPos
, const Size
& rSizePixel
) override
;
387 SystemWindow
* getSystemWindow();
390 class SalInstanceLabel
: public SalInstanceWidget
, public virtual weld::Label
393 // Control instead of FixedText so we can also use this for
394 // SelectableFixedText which is derived from Edit. We just typically need
395 // [G|S]etText which exists in their shared baseclass
396 VclPtr
<Control
> m_xLabel
;
399 SalInstanceLabel(Control
* pLabel
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
);
401 virtual void set_label(const OUString
& rText
) override
;
403 virtual OUString
get_label() const override
;
405 virtual void set_mnemonic_widget(Widget
* pTarget
) override
;
407 virtual void set_label_type(weld::LabelType eType
) override
;
409 virtual void set_font(const vcl::Font
& rFont
) override
;
411 virtual void set_font_color(const Color
& rColor
) override
;
414 class SalInstanceContainer
: public SalInstanceWidget
, public virtual weld::Container
417 VclPtr
<vcl::Window
> m_xContainer
;
420 void implResetDefault(const vcl::Window
* _pWindow
);
423 SalInstanceContainer(vcl::Window
* pContainer
, SalInstanceBuilder
* pBuilder
,
424 bool bTakeOwnership
);
425 virtual void HandleEventListener(VclWindowEvent
& rEvent
) override
;
426 virtual void connect_container_focus_changed(const Link
<Container
&, void>& rLink
) override
;
427 virtual void child_grab_focus() override
;
428 virtual void move(weld::Widget
* pWidget
, weld::Container
* pNewParent
) override
;
429 virtual void recursively_unset_default_buttons() override
;
430 virtual css::uno::Reference
<css::awt::XWindow
> CreateChildFrame() override
;
433 class SalInstanceWindow
: public SalInstanceContainer
, public virtual weld::Window
436 VclPtr
<vcl::Window
> m_xWindow
;
438 DECL_LINK(HelpHdl
, vcl::Window
&, bool);
440 void override_child_help(vcl::Window
* pParent
);
442 void clear_child_help(vcl::Window
* pParent
);
445 SalInstanceWindow(vcl::Window
* pWindow
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
);
447 virtual void set_title(const OUString
& rTitle
) override
;
449 virtual OUString
get_title() const override
;
453 virtual css::uno::Reference
<css::awt::XWindow
> GetXWindow() override
;
455 virtual void resize_to_request() override
;
457 virtual void set_modal(bool bModal
) override
;
459 virtual bool get_modal() const override
;
461 virtual void window_move(int x
, int y
) override
;
463 virtual Size
get_size() const override
;
465 virtual Point
get_position() const override
;
467 virtual tools::Rectangle
get_monitor_workarea() const override
;
469 virtual void set_centered_on_parent(bool /*bTrackGeometryRequests*/) override
;
471 virtual bool get_resizable() const override
;
473 virtual bool has_toplevel_focus() const override
;
475 virtual void present() override
;
477 virtual void set_window_state(const OString
& rStr
) override
;
479 virtual OString
get_window_state(WindowStateMask nMask
) const override
;
481 virtual SystemEnvData
get_system_data() const override
;
483 virtual weld::ScreenShotCollection
collect_screenshot_data() override
;
485 virtual VclPtr
<VirtualDevice
> screenshot() override
;
487 virtual ~SalInstanceWindow() override
;
490 class SalInstanceDialog
: public SalInstanceWindow
, public virtual weld::Dialog
493 VclPtr
<::Dialog
> m_xDialog
;
495 // for calc ref dialog that shrink to range selection widgets and resize back
496 VclPtr
<vcl::Window
> m_xRefEdit
;
497 std::vector
<VclPtr
<vcl::Window
>> m_aHiddenWidgets
; // vector of hidden Controls
498 tools::Long m_nOldEditWidthReq
; // Original width request of the input field
499 sal_Int32 m_nOldBorderWidth
; // border width for expanded dialog
501 DECL_LINK(PopupScreenShotMenuHdl
, const CommandEvent
&, bool);
504 SalInstanceDialog(::Dialog
* pDialog
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
);
506 virtual bool runAsync(std::shared_ptr
<weld::DialogController
> aOwner
,
507 const std::function
<void(sal_Int32
)>& rEndDialogFn
) override
;
509 virtual bool runAsync(std::shared_ptr
<Dialog
> const& rxSelf
,
510 const std::function
<void(sal_Int32
)>& rEndDialogFn
) override
;
512 virtual void collapse(weld::Widget
* pEdit
, weld::Widget
* pButton
) override
;
514 virtual void undo_collapse() override
;
517 SetInstallLOKNotifierHdl(const Link
<void*, vcl::ILibreOfficeKitNotifier
*>& rLink
) override
;
519 virtual int run() override
;
521 virtual void response(int nResponse
) override
;
523 virtual void add_button(const OUString
& rText
, int nResponse
,
524 const OString
& rHelpId
= OString()) override
;
526 virtual void set_modal(bool bModal
) override
;
528 virtual bool get_modal() const override
;
530 virtual weld::Button
* weld_widget_for_response(int nResponse
) override
;
532 virtual void set_default_response(int nResponse
) override
;
534 virtual weld::Container
* weld_content_area() override
;
537 class WeldTextFilter final
: public TextFilter
540 Link
<OUString
&, bool>& m_rInsertTextHdl
;
543 WeldTextFilter(Link
<OUString
&, bool>& rInsertTextHdl
);
545 virtual OUString
filter(const OUString
& rText
) override
;
548 class SalInstanceEntry
: public SalInstanceWidget
, public virtual weld::Entry
551 VclPtr
<::Edit
> m_xEntry
;
553 DECL_LINK(ChangeHdl
, Edit
&, void);
554 DECL_LINK(CursorListener
, VclWindowEvent
&, void);
555 DECL_LINK(ActivateHdl
, Edit
&, bool);
557 WeldTextFilter m_aTextFilter
;
560 SalInstanceEntry(::Edit
* pEntry
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
);
562 virtual void set_text(const OUString
& rText
) override
;
564 virtual OUString
get_text() const override
;
566 virtual void set_width_chars(int nChars
) override
;
568 virtual int get_width_chars() const override
;
570 virtual void set_max_length(int nChars
) override
;
572 virtual void select_region(int nStartPos
, int nEndPos
) override
;
574 bool get_selection_bounds(int& rStartPos
, int& rEndPos
) override
;
576 virtual void replace_selection(const OUString
& rText
) override
;
578 virtual void set_position(int nCursorPos
) override
;
580 virtual int get_position() const override
;
582 virtual void set_editable(bool bEditable
) override
;
584 virtual bool get_editable() const override
;
586 virtual void set_overwrite_mode(bool bOn
) override
;
588 virtual bool get_overwrite_mode() const override
;
590 virtual void set_message_type(weld::EntryMessageType eType
) override
;
592 virtual void set_font(const vcl::Font
& rFont
) override
;
594 virtual void set_font_color(const Color
& rColor
) override
;
596 virtual void connect_cursor_position(const Link
<Entry
&, void>& rLink
) override
;
598 virtual void set_placeholder_text(const OUString
& rText
) override
;
602 void fire_signal_changed();
604 virtual void cut_clipboard() override
;
606 virtual void copy_clipboard() override
;
608 virtual void paste_clipboard() override
;
610 virtual void set_alignment(TxtAlign eXAlign
) override
;
612 virtual ~SalInstanceEntry() override
;
615 class SalInstanceSpinButton
: public SalInstanceEntry
, public virtual weld::SpinButton
618 VclPtr
<FormattedField
> m_xButton
;
619 Formatter
& m_rFormatter
;
621 DECL_LINK(UpDownHdl
, SpinField
&, void);
622 DECL_LINK(LoseFocusHdl
, Control
&, void);
623 DECL_LINK(OutputHdl
, LinkParamNone
*, bool);
624 DECL_LINK(InputHdl
, sal_Int64
*, TriState
);
625 DECL_LINK(ActivateHdl
, Edit
&, bool);
627 double toField(int nValue
) const;
629 int fromField(double fValue
) const;
632 SalInstanceSpinButton(FormattedField
* pButton
, SalInstanceBuilder
* pBuilder
,
633 bool bTakeOwnership
);
635 virtual int get_value() const override
;
637 virtual void set_value(int value
) override
;
639 virtual void set_range(int min
, int max
) override
;
641 virtual void get_range(int& min
, int& max
) const override
;
643 virtual void set_increments(int step
, int /*page*/) override
;
645 virtual void get_increments(int& step
, int& page
) const override
;
647 virtual void set_digits(unsigned int digits
) override
;
649 // SpinButton may be comprised of multiple subwidgets, consider the lot as
650 // one thing for focus
651 virtual bool has_focus() const override
;
653 //off by default for direct SpinButtons, MetricSpinButton enables it
654 void SetUseThousandSep();
656 virtual unsigned int get_digits() const override
;
658 virtual ~SalInstanceSpinButton() override
;
661 //ComboBox and ListBox have similar apis, ComboBoxes in LibreOffice have an edit box and ListBoxes
662 //don't. This distinction isn't there in Gtk. Use a template to sort this problem out.
663 template <class vcl_type
>
664 class SalInstanceComboBox
: public SalInstanceWidget
, public virtual weld::ComboBox
667 // owner for ListBox/ComboBox UserData
668 std::vector
<std::shared_ptr
<OUString
>> m_aUserData
;
669 VclPtr
<vcl_type
> m_xComboBox
;
670 ScopedVclPtr
<MenuButton
> m_xMenuButton
;
671 OUString m_sMenuButtonRow
;
674 SalInstanceComboBox(vcl_type
* pComboBox
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
)
675 : SalInstanceWidget(pComboBox
, pBuilder
, bTakeOwnership
)
676 , m_xComboBox(pComboBox
)
680 virtual int get_active() const override
682 const sal_Int32 nRet
= m_xComboBox
->GetSelectedEntryPos();
683 if (nRet
== LISTBOX_ENTRY_NOTFOUND
)
688 const OUString
* getEntryData(int index
) const
690 return static_cast<const OUString
*>(m_xComboBox
->GetEntryData(index
));
693 // ComboBoxes are comprised of multiple subwidgets, consider the lot as
694 // one thing for focus
695 virtual bool has_focus() const override
697 return m_xWidget
->HasChildPathFocus()
698 || (m_xMenuButton
&& (m_xMenuButton
->HasFocus() || m_xMenuButton
->InPopupMode()));
701 virtual OUString
get_active_id() const override
703 sal_Int32 nPos
= m_xComboBox
->GetSelectedEntryPos();
704 const OUString
* pRet
;
705 if (nPos
!= LISTBOX_ENTRY_NOTFOUND
)
706 pRet
= getEntryData(m_xComboBox
->GetSelectedEntryPos());
714 virtual void set_active_id(const OUString
& rStr
) override
716 for (int i
= 0; i
< get_count(); ++i
)
718 const OUString
* pId
= getEntryData(i
);
722 m_xComboBox
->SelectEntryPos(i
);
726 virtual void set_active(int pos
) override
730 m_xComboBox
->SetNoSelection();
733 m_xComboBox
->SelectEntryPos(pos
);
736 virtual OUString
get_text(int pos
) const override
{ return m_xComboBox
->GetEntry(pos
); }
738 virtual OUString
get_id(int pos
) const override
740 const OUString
* pRet
= getEntryData(pos
);
746 virtual void set_id(int row
, const OUString
& rId
) override
748 m_aUserData
.emplace_back(std::make_unique
<OUString
>(rId
));
749 m_xComboBox
->SetEntryData(row
, m_aUserData
.back().get());
752 virtual void insert_vector(const std::vector
<weld::ComboBoxEntry
>& rItems
,
753 bool bKeepExisting
) override
758 for (const auto& rItem
: rItems
)
760 insert(-1, rItem
.sString
, rItem
.sId
.isEmpty() ? nullptr : &rItem
.sId
,
761 rItem
.sImage
.isEmpty() ? nullptr : &rItem
.sImage
, nullptr);
766 virtual int get_count() const override
{ return m_xComboBox
->GetEntryCount(); }
768 virtual int find_text(const OUString
& rStr
) const override
770 const sal_Int32 nRet
= m_xComboBox
->GetEntryPos(rStr
);
771 if (nRet
== LISTBOX_ENTRY_NOTFOUND
)
776 virtual int find_id(const OUString
& rStr
) const override
778 for (int i
= 0; i
< get_count(); ++i
)
780 const OUString
* pId
= getEntryData(i
);
789 virtual void clear() override
791 m_xComboBox
->Clear();
795 virtual void make_sorted() override
797 m_xComboBox
->SetStyle(m_xComboBox
->GetStyle() | WB_SORT
);
800 virtual bool get_popup_shown() const override
{ return m_xComboBox
->IsInDropDown(); }
802 virtual void connect_popup_toggled(const Link
<ComboBox
&, void>& rLink
) override
804 weld::ComboBox::connect_popup_toggled(rLink
);
805 ensure_event_listener();
808 void call_signal_custom_render(UserDrawEvent
* pEvent
)
810 vcl::RenderContext
* pRenderContext
= pEvent
->GetRenderContext();
811 auto nPos
= pEvent
->GetItemId();
812 const tools::Rectangle
& rRect
= pEvent
->GetRect();
813 const OUString sId
= get_id(nPos
);
814 signal_custom_render(*pRenderContext
, rRect
, pEvent
->IsSelected(), sId
);
815 m_xComboBox
->DrawEntry(*pEvent
); // draw separator
817 if (m_xMenuButton
&& m_xMenuButton
->IsVisible() && m_sMenuButtonRow
== sId
)
819 vcl::Window
* pEventWindow
= m_xComboBox
->GetMainWindow();
820 if (m_xMenuButton
->GetParent() != pEventWindow
)
821 m_xMenuButton
->SetParent(pEventWindow
);
822 int nButtonWidth
= get_menu_button_width();
823 m_xMenuButton
->SetSizePixel(Size(nButtonWidth
, rRect
.GetHeight()));
824 m_xMenuButton
->SetPosPixel(Point(rRect
.GetWidth() - nButtonWidth
, rRect
.getY()));
828 VclPtr
<VirtualDevice
> create_render_virtual_device() const override
830 auto xRet
= VclPtr
<VirtualDevice
>::Create();
831 xRet
->SetBackground(Application::GetSettings().GetStyleSettings().GetFieldColor());
835 virtual void set_item_menu(const OString
& rIdent
, weld::Menu
* pMenu
) override
837 SalInstanceMenu
* pInstanceMenu
= dynamic_cast<SalInstanceMenu
*>(pMenu
);
839 PopupMenu
* pPopup
= pInstanceMenu
? pInstanceMenu
->getMenu() : nullptr;
843 = VclPtr
<MenuButton
>::Create(m_xComboBox
, WB_FLATBUTTON
| WB_NOPOINTERFOCUS
);
845 m_xMenuButton
->SetPopupMenu(pPopup
);
846 m_xMenuButton
->Show(pPopup
!= nullptr);
847 m_sMenuButtonRow
= OUString::fromUtf8(rIdent
);
850 int get_menu_button_width() const override
852 OutputDevice
* pDefault
= Application::GetDefaultDevice();
853 return 20 * (pDefault
? pDefault
->GetDPIScaleFactor() : 1.0);
856 void CallHandleEventListener(VclWindowEvent
& rEvent
)
858 if (rEvent
.GetId() == VclEventId::DropdownPreOpen
859 || rEvent
.GetId() == VclEventId::DropdownClose
)
861 signal_popup_toggled();
864 SalInstanceWidget::HandleEventListener(rEvent
);
868 class SalInstanceComboBoxWithoutEdit
: public SalInstanceComboBox
<ListBox
>
871 DECL_LINK(SelectHdl
, ListBox
&, void);
874 SalInstanceComboBoxWithoutEdit(ListBox
* pListBox
, SalInstanceBuilder
* pBuilder
,
875 bool bTakeOwnership
);
877 virtual OUString
get_active_text() const override
;
879 virtual void remove(int pos
) override
;
881 virtual void insert(int pos
, const OUString
& rStr
, const OUString
* pId
,
882 const OUString
* pIconName
, VirtualDevice
* pImageSurface
) override
;
884 virtual void insert_separator(int pos
, const OUString
& /*rId*/) override
;
886 virtual bool has_entry() const override
;
888 virtual bool changed_by_direct_pick() const override
;
890 virtual void set_entry_message_type(weld::EntryMessageType
/*eType*/) override
;
892 virtual void set_entry_text(const OUString
& /*rText*/) override
;
894 virtual void select_entry_region(int /*nStartPos*/, int /*nEndPos*/) override
;
896 virtual bool get_entry_selection_bounds(int& /*rStartPos*/, int& /*rEndPos*/) override
;
898 virtual void set_entry_width_chars(int /*nChars*/) override
;
900 virtual void set_entry_max_length(int /*nChars*/) override
;
902 virtual void set_entry_completion(bool, bool bCaseSensitive
= false) override
;
904 virtual void set_entry_placeholder_text(const OUString
&) override
;
906 virtual void set_entry_editable(bool bEditable
) override
;
908 virtual void cut_entry_clipboard() override
;
910 virtual void copy_entry_clipboard() override
;
912 virtual void paste_entry_clipboard() override
;
914 virtual void set_font(const vcl::Font
& rFont
) override
;
916 virtual void set_entry_font(const vcl::Font
&) override
;
918 virtual vcl::Font
get_entry_font() override
;
920 virtual void set_custom_renderer(bool bOn
) override
;
922 virtual int get_max_mru_count() const override
;
924 virtual void set_max_mru_count(int) override
;
926 virtual OUString
get_mru_entries() const override
;
928 virtual void set_mru_entries(const OUString
&) override
;
930 virtual void HandleEventListener(VclWindowEvent
& rEvent
) override
;
932 virtual ~SalInstanceComboBoxWithoutEdit() override
;
935 class SalInstanceComboBoxWithEdit
: public SalInstanceComboBox
<ComboBox
>
938 DECL_LINK(ChangeHdl
, Edit
&, void);
939 DECL_LINK(EntryActivateHdl
, Edit
&, bool);
940 DECL_LINK(SelectHdl
, ::ComboBox
&, void);
941 DECL_LINK(UserDrawHdl
, UserDrawEvent
*, void);
942 WeldTextFilter m_aTextFilter
;
946 SalInstanceComboBoxWithEdit(::ComboBox
* pComboBox
, SalInstanceBuilder
* pBuilder
,
947 bool bTakeOwnership
);
949 virtual bool has_entry() const override
;
951 virtual bool changed_by_direct_pick() const override
;
953 virtual void set_entry_message_type(weld::EntryMessageType eType
) override
;
955 virtual OUString
get_active_text() const override
;
957 virtual void remove(int pos
) override
;
959 virtual void insert(int pos
, const OUString
& rStr
, const OUString
* pId
,
960 const OUString
* pIconName
, VirtualDevice
* pImageSurface
) override
;
962 virtual void insert_separator(int pos
, const OUString
& /*rId*/) override
;
964 virtual void set_entry_text(const OUString
& rText
) override
;
966 virtual void set_entry_width_chars(int nChars
) override
;
968 virtual void set_entry_max_length(int nChars
) override
;
970 virtual void set_entry_completion(bool bEnable
, bool bCaseSensitive
= false) override
;
972 virtual void set_entry_placeholder_text(const OUString
& rText
) override
;
974 virtual void set_entry_editable(bool bEditable
) override
;
976 virtual void cut_entry_clipboard() override
;
978 virtual void copy_entry_clipboard() override
;
980 virtual void paste_entry_clipboard() override
;
982 virtual void select_entry_region(int nStartPos
, int nEndPos
) override
;
984 virtual bool get_entry_selection_bounds(int& rStartPos
, int& rEndPos
) override
;
986 virtual void set_font(const vcl::Font
& rFont
) override
;
988 virtual void set_entry_font(const vcl::Font
& rFont
) override
;
990 virtual vcl::Font
get_entry_font() override
;
992 virtual void set_custom_renderer(bool bOn
) override
;
994 virtual int get_max_mru_count() const override
;
996 virtual void set_max_mru_count(int nCount
) override
;
998 virtual OUString
get_mru_entries() const override
;
1000 virtual void set_mru_entries(const OUString
& rEntries
) override
;
1002 virtual void HandleEventListener(VclWindowEvent
& rEvent
) override
;
1004 virtual ~SalInstanceComboBoxWithEdit() override
;
1007 class SalInstanceButton
: public SalInstanceWidget
, public virtual weld::Button
1010 VclPtr
<::Button
> m_xButton
;
1011 Link
<::Button
*, void> const m_aOldClickHdl
;
1013 DECL_LINK(ClickHdl
, ::Button
*, void);
1016 void set_label_wrap(bool bWrap
);
1019 SalInstanceButton(::Button
* pButton
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
);
1021 virtual void set_label(const OUString
& rText
) override
;
1023 virtual void set_image(VirtualDevice
* pDevice
) override
;
1025 virtual void set_image(const css::uno::Reference
<css::graphic::XGraphic
>& rImage
) override
;
1027 virtual void set_from_icon_name(const OUString
& rIconName
) override
;
1029 virtual OUString
get_label() const override
;
1031 virtual void set_font(const vcl::Font
& rFont
) override
;
1033 virtual void set_custom_button(VirtualDevice
* pDevice
) override
;
1035 virtual ~SalInstanceButton() override
;
1038 class SalInstanceNotebook
: public SalInstanceWidget
, public virtual weld::Notebook
1041 VclPtr
<TabControl
> m_xNotebook
;
1042 mutable std::vector
<std::shared_ptr
<SalInstanceContainer
>> m_aPages
;
1043 std::map
<OString
, std::pair
<VclPtr
<TabPage
>, VclPtr
<VclGrid
>>> m_aAddedPages
;
1045 DECL_LINK(DeactivatePageHdl
, TabControl
*, bool);
1046 DECL_LINK(ActivatePageHdl
, TabControl
*, void);
1049 SalInstanceNotebook(TabControl
* pNotebook
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
);
1051 virtual int get_current_page() const override
;
1053 virtual int get_page_index(const OString
& rIdent
) const override
;
1055 virtual OString
get_page_ident(int nPage
) const override
;
1057 virtual OString
get_current_page_ident() const override
;
1059 virtual weld::Container
* get_page(const OString
& rIdent
) const override
;
1061 virtual void set_current_page(int nPage
) override
;
1063 virtual void set_current_page(const OString
& rIdent
) override
;
1065 virtual void remove_page(const OString
& rIdent
) override
;
1067 virtual void insert_page(const OString
& rIdent
, const OUString
& rLabel
, int nPos
) override
;
1069 virtual int get_n_pages() const override
;
1071 virtual OUString
get_tab_label_text(const OString
& rIdent
) const override
;
1073 virtual void set_tab_label_text(const OString
& rIdent
, const OUString
& rText
) override
;
1075 virtual ~SalInstanceNotebook() override
;
1078 class SalInstanceMessageDialog
: public SalInstanceDialog
, public virtual weld::MessageDialog
1081 VclPtr
<::MessageDialog
> m_xMessageDialog
;
1084 SalInstanceMessageDialog(::MessageDialog
* pDialog
, SalInstanceBuilder
* pBuilder
,
1085 bool bTakeOwnership
);
1087 virtual void set_primary_text(const OUString
& rText
) override
;
1089 virtual OUString
get_primary_text() const override
;
1091 virtual void set_secondary_text(const OUString
& rText
) override
;
1093 virtual OUString
get_secondary_text() const override
;
1095 virtual weld::Container
* weld_message_area() override
;
1098 class SalInstanceCheckButton
: public SalInstanceButton
, public virtual weld::CheckButton
1101 VclPtr
<CheckBox
> m_xCheckButton
;
1103 DECL_LINK(ToggleHdl
, CheckBox
&, void);
1106 SalInstanceCheckButton(CheckBox
* pButton
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
);
1108 virtual void set_active(bool active
) override
;
1110 virtual bool get_active() const override
;
1112 virtual void set_inconsistent(bool inconsistent
) override
;
1114 virtual bool get_inconsistent() const override
;
1116 virtual void set_label(const OUString
& rText
) override
{ SalInstanceButton::set_label(rText
); }
1118 virtual OUString
get_label() const override
{ return SalInstanceButton::get_label(); }
1120 virtual void set_label_wrap(bool wrap
) override
{ SalInstanceButton::set_label_wrap(wrap
); }
1122 virtual ~SalInstanceCheckButton() override
;
1125 class SalInstanceDrawingArea
: public SalInstanceWidget
, public virtual weld::DrawingArea
1128 VclPtr
<VclDrawingArea
> m_xDrawingArea
;
1130 typedef std::pair
<vcl::RenderContext
&, const tools::Rectangle
&> target_and_area
;
1131 DECL_LINK(PaintHdl
, target_and_area
, void);
1132 DECL_LINK(ResizeHdl
, const Size
&, void);
1133 DECL_LINK(MousePressHdl
, const MouseEvent
&, bool);
1134 DECL_LINK(MouseMoveHdl
, const MouseEvent
&, bool);
1135 DECL_LINK(MouseReleaseHdl
, const MouseEvent
&, bool);
1136 DECL_LINK(KeyPressHdl
, const KeyEvent
&, bool);
1137 DECL_LINK(KeyReleaseHdl
, const KeyEvent
&, bool);
1138 DECL_LINK(StyleUpdatedHdl
, VclDrawingArea
&, void);
1139 DECL_LINK(CommandHdl
, const CommandEvent
&, bool);
1140 DECL_LINK(QueryTooltipHdl
, tools::Rectangle
&, OUString
);
1141 DECL_LINK(GetSurroundingHdl
, OUString
&, int);
1142 DECL_LINK(DeleteSurroundingHdl
, const Selection
&, bool);
1143 DECL_LINK(StartDragHdl
, VclDrawingArea
*, bool);
1145 // SalInstanceWidget has a generic listener for all these
1146 // events, ignore the ones we have specializations for
1147 // in VclDrawingArea
1148 virtual void HandleEventListener(VclWindowEvent
& rEvent
) override
;
1150 virtual void HandleMouseEventListener(VclWindowEvent
& rEvent
) override
;
1152 virtual bool HandleKeyEventListener(VclWindowEvent
& /*rEvent*/) override
;
1155 SalInstanceDrawingArea(VclDrawingArea
* pDrawingArea
, SalInstanceBuilder
* pBuilder
,
1156 const a11yref
& rAlly
, FactoryFunction pUITestFactoryFunction
,
1157 void* pUserData
, bool bTakeOwnership
);
1159 virtual void queue_draw() override
;
1161 virtual void queue_draw_area(int x
, int y
, int width
, int height
) override
;
1163 virtual void connect_size_allocate(const Link
<const Size
&, void>& rLink
) override
;
1165 virtual void connect_key_press(const Link
<const KeyEvent
&, bool>& rLink
) override
;
1167 virtual void connect_key_release(const Link
<const KeyEvent
&, bool>& rLink
) override
;
1169 virtual void set_cursor(PointerStyle ePointerStyle
) override
;
1171 virtual Point
get_pointer_position() const override
;
1173 virtual void set_input_context(const InputContext
& rInputContext
) override
;
1175 virtual void im_context_set_cursor_location(const tools::Rectangle
& rCursorRect
,
1176 int nExtTextInputWidth
) override
;
1178 virtual a11yref
get_accessible_parent() override
;
1180 virtual a11yrelationset
get_accessible_relation_set() override
;
1182 virtual Point
get_accessible_location_on_screen() override
;
1184 virtual void enable_drag_source(rtl::Reference
<TransferDataContainer
>& rHelper
,
1185 sal_uInt8 eDNDConstants
) override
;
1187 virtual ~SalInstanceDrawingArea() override
;
1189 virtual OutputDevice
& get_ref_device() override
;
1191 virtual void click(const Point
& rPos
) override
;
1194 class SalInstanceToolbar
: public SalInstanceWidget
, public virtual weld::Toolbar
1197 VclPtr
<ToolBox
> m_xToolBox
;
1198 std::map
<ToolBoxItemId
, VclPtr
<vcl::Window
>> m_aFloats
;
1199 std::map
<ToolBoxItemId
, VclPtr
<PopupMenu
>> m_aMenus
;
1201 OString m_sStartShowIdent
;
1203 DECL_LINK(ClickHdl
, ToolBox
*, void);
1204 DECL_LINK(DropdownClick
, ToolBox
*, void);
1205 DECL_LINK(MenuToggleListener
, VclWindowEvent
&, void);
1208 SalInstanceToolbar(ToolBox
* pToolBox
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
);
1210 virtual void set_item_sensitive(const OString
& rIdent
, bool bSensitive
) override
;
1212 virtual bool get_item_sensitive(const OString
& rIdent
) const override
;
1214 virtual void set_item_visible(const OString
& rIdent
, bool bVisible
) override
;
1216 virtual void set_item_help_id(const OString
& rIdent
, const OString
& rHelpId
) override
;
1218 virtual bool get_item_visible(const OString
& rIdent
) const override
;
1220 virtual void set_item_active(const OString
& rIdent
, bool bActive
) override
;
1222 virtual bool get_item_active(const OString
& rIdent
) const override
;
1224 void set_menu_item_active(const OString
& rIdent
, bool bActive
) override
;
1226 bool get_menu_item_active(const OString
& rIdent
) const override
;
1228 virtual void set_item_popover(const OString
& rIdent
, weld::Widget
* pPopover
) override
;
1230 virtual void set_item_menu(const OString
& rIdent
, weld::Menu
* pMenu
) override
;
1232 virtual void insert_item(int pos
, const OUString
& rId
) override
;
1234 virtual void insert_separator(int pos
, const OUString
& /*rId*/) override
;
1236 virtual int get_n_items() const override
;
1238 virtual OString
get_item_ident(int nIndex
) const override
;
1240 virtual void set_item_ident(int nIndex
, const OString
& rIdent
) override
;
1242 virtual void set_item_label(int nIndex
, const OUString
& rLabel
) override
;
1244 virtual OUString
get_item_label(const OString
& rIdent
) const override
;
1246 virtual void set_item_label(const OString
& rIdent
, const OUString
& rLabel
) override
;
1248 virtual void set_item_icon_name(const OString
& rIdent
, const OUString
& rIconName
) override
;
1250 virtual void set_item_image(const OString
& rIdent
,
1251 const css::uno::Reference
<css::graphic::XGraphic
>& rIcon
) override
;
1253 virtual void set_item_image(const OString
& rIdent
, VirtualDevice
* pDevice
) override
;
1255 virtual void set_item_image(int nIndex
,
1256 const css::uno::Reference
<css::graphic::XGraphic
>& rIcon
) override
;
1258 virtual void set_item_tooltip_text(int nIndex
, const OUString
& rTip
) override
;
1260 virtual void set_item_tooltip_text(const OString
& rIdent
, const OUString
& rTip
) override
;
1262 virtual OUString
get_item_tooltip_text(const OString
& rIdent
) const override
;
1264 virtual vcl::ImageType
get_icon_size() const override
;
1266 virtual void set_icon_size(vcl::ImageType eType
) override
;
1268 virtual sal_uInt16
get_modifier_state() const override
;
1270 int get_drop_index(const Point
& rPoint
) const override
;
1272 virtual ~SalInstanceToolbar() override
;
1275 class SalInstanceTextView
: public SalInstanceWidget
, public virtual weld::TextView
1278 VclPtr
<VclMultiLineEdit
> m_xTextView
;
1279 Link
<ScrollBar
*, void> m_aOrigVScrollHdl
;
1281 DECL_LINK(ChangeHdl
, Edit
&, void);
1282 DECL_LINK(VscrollHdl
, ScrollBar
*, void);
1283 DECL_LINK(CursorListener
, VclWindowEvent
&, void);
1286 SalInstanceTextView(VclMultiLineEdit
* pTextView
, SalInstanceBuilder
* pBuilder
,
1287 bool bTakeOwnership
);
1289 virtual void set_text(const OUString
& rText
) override
;
1291 virtual void replace_selection(const OUString
& rText
) override
;
1293 virtual OUString
get_text() const override
;
1295 bool get_selection_bounds(int& rStartPos
, int& rEndPos
) override
;
1297 virtual void select_region(int nStartPos
, int nEndPos
) override
;
1299 virtual void set_editable(bool bEditable
) override
;
1300 virtual bool get_editable() const override
;
1301 virtual void set_max_length(int nChars
) override
;
1303 virtual void set_monospace(bool bMonospace
) override
;
1305 virtual void set_font(const vcl::Font
& rFont
) override
;
1307 virtual void set_font_color(const Color
& rColor
) override
;
1309 virtual void connect_cursor_position(const Link
<TextView
&, void>& rLink
) override
;
1311 virtual bool can_move_cursor_with_up() const override
;
1313 virtual bool can_move_cursor_with_down() const override
;
1315 virtual void cut_clipboard() override
;
1317 virtual void copy_clipboard() override
;
1319 virtual void paste_clipboard() override
;
1321 virtual void set_alignment(TxtAlign eXAlign
) override
;
1323 virtual int vadjustment_get_value() const override
;
1325 virtual void vadjustment_set_value(int value
) override
;
1327 virtual int vadjustment_get_upper() const override
;
1329 virtual int vadjustment_get_lower() const override
;
1331 virtual int vadjustment_get_page_size() const override
;
1333 virtual bool has_focus() const override
;
1335 virtual ~SalInstanceTextView() override
;
1338 struct SalInstanceTreeIter
: public weld::TreeIter
1340 SalInstanceTreeIter(const SalInstanceTreeIter
* pOrig
)
1341 : iter(pOrig
? pOrig
->iter
: nullptr)
1344 SalInstanceTreeIter(SvTreeListEntry
* pIter
)
1348 virtual bool equal(const TreeIter
& rOther
) const override
1350 return iter
== static_cast<const SalInstanceTreeIter
&>(rOther
).iter
;
1352 SvTreeListEntry
* iter
;
1355 class SalInstanceTreeView
: public SalInstanceWidget
, public virtual weld::TreeView
1358 // owner for UserData
1359 std::vector
<std::unique_ptr
<OUString
>> m_aUserData
;
1360 VclPtr
<SvTabListBox
> m_xTreeView
;
1361 SvLBoxButtonData m_aCheckButtonData
;
1362 SvLBoxButtonData m_aRadioButtonData
;
1363 // currently expanding parent that logically, but not currently physically,
1364 // contain placeholders
1365 o3tl::sorted_vector
<SvTreeListEntry
*> m_aExpandingPlaceHolderParents
;
1366 // which columns should be custom rendered
1367 o3tl::sorted_vector
<int> m_aCustomRenders
;
1368 bool m_bTogglesAsRadio
;
1371 DECL_LINK(SelectHdl
, SvTreeListBox
*, void);
1372 DECL_LINK(DeSelectHdl
, SvTreeListBox
*, void);
1373 DECL_LINK(DoubleClickHdl
, SvTreeListBox
*, bool);
1374 DECL_LINK(ExpandingHdl
, SvTreeListBox
*, bool);
1375 DECL_LINK(EndDragHdl
, HeaderBar
*, void);
1376 DECL_LINK(HeaderBarClickedHdl
, HeaderBar
*, void);
1377 DECL_LINK(ToggleHdl
, SvLBoxButtonData
*, void);
1378 DECL_LINK(ModelChangedHdl
, SvTreeListBox
*, void);
1379 DECL_LINK(StartDragHdl
, SvTreeListBox
*, bool);
1380 DECL_STATIC_LINK(SalInstanceTreeView
, FinishDragHdl
, SvTreeListBox
*, void);
1381 DECL_LINK(EditingEntryHdl
, SvTreeListEntry
*, bool);
1382 typedef std::pair
<SvTreeListEntry
*, OUString
> IterString
;
1383 DECL_LINK(EditedEntryHdl
, IterString
, bool);
1384 DECL_LINK(VisibleRangeChangedHdl
, SvTreeListBox
*, void);
1385 DECL_LINK(CompareHdl
, const SvSortData
&, sal_Int32
);
1386 DECL_LINK(PopupMenuHdl
, const CommandEvent
&, bool);
1387 DECL_LINK(TooltipHdl
, const HelpEvent
&, bool);
1388 DECL_LINK(CustomRenderHdl
, svtree_render_args
, void);
1389 DECL_LINK(CustomMeasureHdl
, svtree_measure_args
, Size
);
1391 // Each row has a cell for the expander image, (and an optional cell for a
1392 // checkbutton if enable_toggle_buttons has been called) which precede
1394 int to_internal_model(int col
) const;
1396 int to_external_model(int col
) const;
1398 bool IsDummyEntry(SvTreeListEntry
* pEntry
) const;
1400 SvTreeListEntry
* GetPlaceHolderChild(SvTreeListEntry
* pEntry
) const;
1402 static void set_font_color(SvTreeListEntry
* pEntry
, const Color
& rColor
);
1404 void AddStringItem(SvTreeListEntry
* pEntry
, const OUString
& rStr
, int nCol
);
1406 void do_insert(const weld::TreeIter
* pParent
, int pos
, const OUString
* pStr
,
1407 const OUString
* pId
, const OUString
* pIconName
,
1408 const VirtualDevice
* pImageSurface
, bool bChildrenOnDemand
, weld::TreeIter
* pRet
,
1411 void update_checkbutton_column_width(SvTreeListEntry
* pEntry
);
1413 void InvalidateModelEntry(SvTreeListEntry
* pEntry
);
1415 void do_set_toggle(SvTreeListEntry
* pEntry
, TriState eState
, int col
);
1417 static TriState
do_get_toggle(SvTreeListEntry
* pEntry
, int col
);
1419 TriState
get_toggle(SvTreeListEntry
* pEntry
, int col
) const;
1421 void set_toggle(SvTreeListEntry
* pEntry
, TriState eState
, int col
);
1423 bool get_text_emphasis(SvTreeListEntry
* pEntry
, int col
) const;
1425 void set_header_item_width(const std::vector
<int>& rWidths
);
1428 SalInstanceTreeView(SvTabListBox
* pTreeView
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
);
1430 virtual void connect_query_tooltip(const Link
<const weld::TreeIter
&, OUString
>& rLink
) override
;
1432 virtual void columns_autosize() override
;
1434 virtual void freeze() override
;
1436 virtual void thaw() override
;
1438 virtual void set_column_fixed_widths(const std::vector
<int>& rWidths
) override
;
1440 virtual void set_column_editables(const std::vector
<bool>& rEditables
) override
;
1442 virtual void set_centered_column(int nCol
) override
;
1444 virtual int get_column_width(int nColumn
) const override
;
1446 virtual OUString
get_column_title(int nColumn
) const override
;
1448 virtual void set_column_title(int nColumn
, const OUString
& rTitle
) override
;
1450 virtual void set_column_custom_renderer(int nColumn
, bool bEnable
) override
;
1452 virtual void queue_draw() override
;
1454 virtual void show() override
;
1456 virtual void hide() override
;
1458 virtual void insert(const weld::TreeIter
* pParent
, int pos
, const OUString
* pStr
,
1459 const OUString
* pId
, const OUString
* pIconName
,
1460 VirtualDevice
* pImageSurface
, bool bChildrenOnDemand
,
1461 weld::TreeIter
* pRet
) override
;
1463 virtual void insert_separator(int pos
, const OUString
& /*rId*/) override
;
1466 bulk_insert_for_each(int nSourceCount
,
1467 const std::function
<void(weld::TreeIter
&, int nSourceIndex
)>& func
,
1468 const weld::TreeIter
* pParent
= nullptr,
1469 const std::vector
<int>* pFixedWidths
= nullptr) override
;
1471 virtual void set_font_color(int pos
, const Color
& rColor
) override
;
1473 virtual void set_font_color(const weld::TreeIter
& rIter
, const Color
& rColor
) override
;
1475 virtual void remove(int pos
) override
;
1477 virtual int find_text(const OUString
& rText
) const override
;
1479 virtual int find_id(const OUString
& rId
) const override
;
1481 virtual void swap(int pos1
, int pos2
) override
;
1483 virtual void clear() override
;
1485 virtual int n_children() const override
;
1487 virtual int iter_n_children(const weld::TreeIter
& rIter
) const override
;
1489 virtual void select(int pos
) override
;
1491 virtual int get_cursor_index() const override
;
1493 virtual void set_cursor(int pos
) override
;
1495 virtual void scroll_to_row(int pos
) override
;
1497 virtual bool is_selected(int pos
) const override
;
1499 virtual void unselect(int pos
) override
;
1501 virtual std::vector
<int> get_selected_rows() const override
;
1503 OUString
get_text(SvTreeListEntry
* pEntry
, int col
) const;
1505 virtual OUString
get_text(int pos
, int col
= -1) const override
;
1507 void set_text(SvTreeListEntry
* pEntry
, const OUString
& rText
, int col
);
1509 virtual void set_text(int pos
, const OUString
& rText
, int col
= -1) override
;
1511 void set_sensitive(SvTreeListEntry
* pEntry
, bool bSensitive
, int col
);
1513 using SalInstanceWidget::set_sensitive
;
1515 virtual void set_sensitive(int pos
, bool bSensitive
, int col
= -1) override
;
1517 virtual void set_sensitive(const weld::TreeIter
& rIter
, bool bSensitive
, int col
= -1) override
;
1519 virtual TriState
get_toggle(int pos
, int col
= -1) const override
;
1521 virtual TriState
get_toggle(const weld::TreeIter
& rIter
, int col
= -1) const override
;
1523 virtual void enable_toggle_buttons(weld::ColumnToggleType eType
) override
;
1525 virtual void set_toggle(int pos
, TriState eState
, int col
= -1) override
;
1527 virtual void set_toggle(const weld::TreeIter
& rIter
, TriState eState
, int col
= -1) override
;
1529 virtual void set_clicks_to_toggle(int nToggleBehavior
) override
;
1531 virtual void set_extra_row_indent(const weld::TreeIter
& rIter
, int nIndentLevel
) override
;
1533 void set_text_emphasis(SvTreeListEntry
* pEntry
, bool bOn
, int col
= -1);
1535 virtual void set_text_emphasis(const weld::TreeIter
& rIter
, bool bOn
, int col
) override
;
1537 virtual void set_text_emphasis(int pos
, bool bOn
, int col
) override
;
1539 virtual bool get_text_emphasis(const weld::TreeIter
& rIter
, int col
) const override
;
1541 virtual bool get_text_emphasis(int pos
, int col
) const override
;
1543 void set_text_align(SvTreeListEntry
* pEntry
, double fAlign
, int col
);
1545 virtual void set_text_align(const weld::TreeIter
& rIter
, double fAlign
, int col
) override
;
1547 virtual void set_text_align(int pos
, double fAlign
, int col
) override
;
1549 virtual void connect_editing(const Link
<const weld::TreeIter
&, bool>& rStartLink
,
1550 const Link
<const iter_string
&, bool>& rEndLink
) override
;
1552 virtual void start_editing(const weld::TreeIter
& rIter
) override
;
1554 virtual void end_editing() override
;
1556 void set_image(SvTreeListEntry
* pEntry
, const Image
& rImage
, int col
);
1558 virtual void set_image(int pos
, const OUString
& rImage
, int col
= -1) override
;
1560 virtual void set_image(int pos
, const css::uno::Reference
<css::graphic::XGraphic
>& rImage
,
1561 int col
= -1) override
;
1563 virtual void set_image(int pos
, VirtualDevice
& rImage
, int col
= -1) override
;
1565 virtual void set_image(const weld::TreeIter
& rIter
, const OUString
& rImage
,
1566 int col
= -1) override
;
1568 virtual void set_image(const weld::TreeIter
& rIter
,
1569 const css::uno::Reference
<css::graphic::XGraphic
>& rImage
,
1570 int col
= -1) override
;
1572 virtual void set_image(const weld::TreeIter
& rIter
, VirtualDevice
& rImage
,
1573 int col
= -1) override
;
1575 const OUString
* getEntryData(int index
) const;
1577 virtual OUString
get_id(int pos
) const override
;
1579 void set_id(SvTreeListEntry
* pEntry
, const OUString
& rId
);
1581 virtual void set_id(int pos
, const OUString
& rId
) override
;
1583 virtual int get_selected_index() const override
;
1585 virtual OUString
get_selected_text() const override
;
1587 virtual OUString
get_selected_id() const override
;
1589 virtual std::unique_ptr
<weld::TreeIter
> make_iterator(const weld::TreeIter
* pOrig
1590 = nullptr) const override
;
1592 virtual void copy_iterator(const weld::TreeIter
& rSource
, weld::TreeIter
& rDest
) const override
;
1594 virtual bool get_selected(weld::TreeIter
* pIter
) const override
;
1596 virtual bool get_cursor(weld::TreeIter
* pIter
) const override
;
1598 virtual void set_cursor(const weld::TreeIter
& rIter
) override
;
1600 virtual bool get_iter_first(weld::TreeIter
& rIter
) const override
;
1602 virtual bool get_iter_abs_pos(weld::TreeIter
& rIter
, int nPos
) const;
1604 virtual bool iter_next_sibling(weld::TreeIter
& rIter
) const override
;
1606 virtual bool iter_previous_sibling(weld::TreeIter
& rIter
) const override
;
1608 virtual bool iter_next(weld::TreeIter
& rIter
) const override
;
1610 virtual bool iter_previous(weld::TreeIter
& rIter
) const override
;
1612 virtual bool iter_children(weld::TreeIter
& rIter
) const override
;
1614 virtual bool iter_parent(weld::TreeIter
& rIter
) const override
;
1616 virtual void remove(const weld::TreeIter
& rIter
) override
;
1618 virtual void select(const weld::TreeIter
& rIter
) override
;
1620 virtual void scroll_to_row(const weld::TreeIter
& rIter
) override
;
1622 virtual void unselect(const weld::TreeIter
& rIter
) override
;
1624 virtual int get_iter_depth(const weld::TreeIter
& rIter
) const override
;
1626 virtual bool iter_has_child(const weld::TreeIter
& rIter
) const override
;
1628 virtual bool get_row_expanded(const weld::TreeIter
& rIter
) const override
;
1630 virtual bool get_children_on_demand(const weld::TreeIter
& rIter
) const override
;
1632 virtual void set_children_on_demand(const weld::TreeIter
& rIter
,
1633 bool bChildrenOnDemand
) override
;
1635 virtual void expand_row(const weld::TreeIter
& rIter
) override
;
1637 virtual void collapse_row(const weld::TreeIter
& rIter
) override
;
1639 virtual OUString
get_text(const weld::TreeIter
& rIter
, int col
= -1) const override
;
1641 virtual void set_text(const weld::TreeIter
& rIter
, const OUString
& rText
,
1642 int col
= -1) override
;
1644 virtual OUString
get_id(const weld::TreeIter
& rIter
) const override
;
1646 virtual void set_id(const weld::TreeIter
& rIter
, const OUString
& rId
) override
;
1648 virtual void enable_drag_source(rtl::Reference
<TransferDataContainer
>& rHelper
,
1649 sal_uInt8 eDNDConstants
) override
;
1651 virtual void set_selection_mode(SelectionMode eMode
) override
;
1653 virtual void all_foreach(const std::function
<bool(weld::TreeIter
&)>& func
) override
;
1655 virtual void selected_foreach(const std::function
<bool(weld::TreeIter
&)>& func
) override
;
1657 virtual void visible_foreach(const std::function
<bool(weld::TreeIter
&)>& func
) override
;
1659 virtual void connect_visible_range_changed(const Link
<weld::TreeView
&, void>& rLink
) override
;
1661 virtual void remove_selection() override
;
1663 virtual bool is_selected(const weld::TreeIter
& rIter
) const override
;
1665 virtual int get_iter_index_in_parent(const weld::TreeIter
& rIter
) const override
;
1667 virtual int iter_compare(const weld::TreeIter
& a
, const weld::TreeIter
& b
) const override
;
1669 virtual void move_subtree(weld::TreeIter
& rNode
, const weld::TreeIter
* pNewParent
,
1670 int nIndexInNewParent
) override
;
1672 virtual int count_selected_rows() const override
;
1674 virtual int get_height_rows(int nRows
) const override
;
1676 virtual void make_sorted() override
;
1678 virtual void set_sort_func(
1679 const std::function
<int(const weld::TreeIter
&, const weld::TreeIter
&)>& func
) override
;
1681 virtual void make_unsorted() override
;
1683 virtual void set_sort_order(bool bAscending
) override
;
1685 virtual bool get_sort_order() const override
;
1687 virtual void set_sort_indicator(TriState eState
, int col
) override
;
1689 virtual TriState
get_sort_indicator(int col
) const override
;
1691 virtual int get_sort_column() const override
;
1693 virtual void set_sort_column(int nColumn
) override
;
1695 SvTabListBox
& getTreeView();
1697 virtual bool get_dest_row_at_pos(const Point
& rPos
, weld::TreeIter
* pResult
,
1698 bool bDnDMode
) override
;
1700 virtual void unset_drag_dest_row() override
;
1702 virtual tools::Rectangle
get_row_area(const weld::TreeIter
& rIter
) const override
;
1704 virtual TreeView
* get_drag_source() const override
;
1706 virtual int vadjustment_get_value() const override
;
1708 virtual void vadjustment_set_value(int nValue
) override
;
1710 void set_show_expanders(bool bShow
) override
;
1712 virtual ~SalInstanceTreeView() override
;
1715 class SalInstanceExpander
: public SalInstanceWidget
, public virtual weld::Expander
1718 VclPtr
<VclExpander
> m_xExpander
;
1720 DECL_LINK(ExpandedHdl
, VclExpander
&, void);
1723 SalInstanceExpander(VclExpander
* pExpander
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
);
1725 virtual void set_label(const OUString
& rText
) override
;
1727 virtual OUString
get_label() const override
;
1729 virtual bool get_expanded() const override
;
1731 virtual void set_expanded(bool bExpand
) override
;
1733 virtual bool has_focus() const override
;
1735 virtual void grab_focus() override
;
1737 virtual ~SalInstanceExpander() override
;
1740 class SalInstanceIconView
: public SalInstanceWidget
, public virtual weld::IconView
1743 // owner for UserData
1744 std::vector
<std::unique_ptr
<OUString
>> m_aUserData
;
1745 VclPtr
<::IconView
> m_xIconView
;
1747 DECL_LINK(SelectHdl
, SvTreeListBox
*, void);
1748 DECL_LINK(DeSelectHdl
, SvTreeListBox
*, void);
1749 DECL_LINK(DoubleClickHdl
, SvTreeListBox
*, bool);
1750 DECL_LINK(CommandHdl
, const CommandEvent
&, bool);
1753 SalInstanceIconView(::IconView
* pIconView
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
);
1755 virtual void freeze() override
;
1757 virtual void thaw() override
;
1759 virtual void insert(int pos
, const OUString
* pStr
, const OUString
* pId
,
1760 const OUString
* pIconName
, weld::TreeIter
* pRet
) override
;
1762 virtual void insert(int pos
, const OUString
* pStr
, const OUString
* pId
,
1763 const VirtualDevice
* pIcon
, weld::TreeIter
* pRet
) override
;
1765 virtual OUString
get_selected_id() const override
;
1767 virtual OUString
get_selected_text() const override
;
1769 virtual int count_selected_items() const override
;
1771 virtual void select(int pos
) override
;
1773 virtual void unselect(int pos
) override
;
1775 virtual int n_children() const override
;
1777 virtual std::unique_ptr
<weld::TreeIter
> make_iterator(const weld::TreeIter
* pOrig
1778 = nullptr) const override
;
1780 virtual bool get_selected(weld::TreeIter
* pIter
) const override
;
1782 virtual bool get_cursor(weld::TreeIter
* pIter
) const override
;
1784 virtual void set_cursor(const weld::TreeIter
& rIter
) override
;
1786 virtual bool get_iter_first(weld::TreeIter
& rIter
) const override
;
1788 virtual void scroll_to_item(const weld::TreeIter
& rIter
) override
;
1790 virtual void selected_foreach(const std::function
<bool(weld::TreeIter
&)>& func
) override
;
1792 virtual OUString
get_id(const weld::TreeIter
& rIter
) const override
;
1794 virtual void clear() override
;
1796 virtual ~SalInstanceIconView() override
;
1799 class SalInstanceRadioButton
: public SalInstanceButton
, public virtual weld::RadioButton
1802 VclPtr
<::RadioButton
> m_xRadioButton
;
1804 DECL_LINK(ToggleHdl
, ::RadioButton
&, void);
1807 SalInstanceRadioButton(::RadioButton
* pButton
, SalInstanceBuilder
* pBuilder
,
1808 bool bTakeOwnership
);
1810 virtual void set_active(bool active
) override
;
1812 virtual bool get_active() const override
;
1814 virtual void set_image(VirtualDevice
* pDevice
) override
;
1816 virtual void set_image(const css::uno::Reference
<css::graphic::XGraphic
>& rImage
) override
;
1818 virtual void set_from_icon_name(const OUString
& rIconName
) override
;
1820 virtual void set_inconsistent(bool /*inconsistent*/) override
;
1822 virtual bool get_inconsistent() const override
;
1824 virtual void set_label(const OUString
& rText
) override
{ SalInstanceButton::set_label(rText
); }
1826 virtual OUString
get_label() const override
{ return SalInstanceButton::get_label(); }
1828 virtual void set_label_wrap(bool wrap
) override
{ SalInstanceButton::set_label_wrap(wrap
); }
1830 virtual ~SalInstanceRadioButton() override
;
1833 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */