/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef INCLUDED_VCL_WELD_HXX #define INCLUDED_VCL_WELD_HXX #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace com::sun::star::awt { class XWindow; } namespace com::sun::star::datatransfer::dnd { class XDropTarget; } namespace com::sun::star::graphic { class XGraphic; } typedef css::uno::Reference a11yref; typedef css::uno::Reference a11yrelationset; enum class PointerStyle; class CommandEvent; class Formatter; class InputContext; class KeyEvent; class MouseEvent; class SvNumberFormatter; class TransferDataContainer; class OutputDevice; class VirtualDevice; struct SystemEnvData; namespace vcl { class ILibreOfficeKitNotifier; typedef OutputDevice RenderContext; } namespace tools { class JsonWriter; } class LOKTrigger; namespace weld { class Container; class DialogController; class VCL_DLLPUBLIC Widget { protected: Link m_aFocusInHdl; Link m_aFocusOutHdl; Link m_aMnemonicActivateHdl; Link m_aSizeAllocateHdl; Link m_aKeyPressHdl; Link m_aKeyReleaseHdl; Link m_aMousePressHdl; Link m_aMouseMotionHdl; Link m_aMouseReleaseHdl; public: virtual void set_sensitive(bool sensitive) = 0; virtual bool get_sensitive() const = 0; /* visibility */ virtual void show() = 0; virtual void hide() = 0; // This function simply calls show() or hide() but is convenient when the // visibility depends on some condition virtual void set_visible(bool visible) { if (visible) show(); else hide(); } // return if this widget's visibility is true virtual bool get_visible() const = 0; // return if this widget's visibility and that of all its parents is true virtual bool is_visible() const = 0; /* focus */ // sets if this widget can own the keyboard focus virtual void set_can_focus(bool bCanFocus) = 0; // causes this widget to have the keyboard focus virtual void grab_focus() = 0; // returns if this widget has the keyboard focus virtual bool has_focus() const = 0; // if the widget that has focus is a child, which includes toplevel popup // children, of this widget. So an Entry with an active popup (or dialog) // has has_child_focus of true, but has_focus of false, while its popup is // shown virtual bool has_child_focus() const = 0; // return if this widget has the keyboard focus within the active window // TODO: review if this has any practical difference from has_focus() virtual bool is_active() const = 0; virtual void set_has_default(bool has_default) = 0; virtual bool get_has_default() const = 0; /* size */ virtual void set_size_request(int nWidth, int nHeight) = 0; virtual Size get_size_request() const = 0; virtual Size get_preferred_size() const = 0; /* measure */ virtual float get_approximate_digit_width() const = 0; virtual int get_text_height() const = 0; virtual Size get_pixel_size(const OUString& rText) const = 0; // The name of the widget in the GtkBuilder UI definition used to construct it. virtual OString get_buildable_name() const = 0; /* The help id of the widget used to identify help for this widget. * * By default the help id of a widget is a path-like sequence of * buildable-names from the widgets UI definition ancestor to this * widget, e.g. grandparent/parent/widget. * * The default can be overwritten with set_help_id */ virtual OString get_help_id() const = 0; virtual void set_help_id(const OString& rName) = 0; virtual void set_grid_left_attach(int nAttach) = 0; virtual int get_grid_left_attach() const = 0; virtual void set_grid_width(int nCols) = 0; virtual void set_grid_top_attach(int nAttach) = 0; virtual int get_grid_top_attach() const = 0; virtual void set_hexpand(bool bExpand) = 0; virtual bool get_hexpand() const = 0; virtual void set_vexpand(bool bExpand) = 0; virtual bool get_vexpand() const = 0; virtual void set_secondary(bool bSecondary) = 0; virtual void set_margin_top(int nMargin) = 0; virtual void set_margin_bottom(int nMargin) = 0; virtual void set_margin_left(int nMargin) = 0; virtual void set_margin_right(int nMargin) = 0; virtual int get_margin_top() const = 0; virtual int get_margin_bottom() const = 0; virtual int get_margin_left() const = 0; virtual int get_margin_right() const = 0; /* * Report the extents of this widget relative to the rRelative target widget. * * To succeed, both widgets must be realized, and must share a common toplevel. * * returns false if the relative extents could not be determined, e.g. if * either widget was not realized, or there was no common ancestor. * Otherwise true. */ virtual bool get_extents_relative_to(const Widget& rRelative, int& x, int& y, int& width, int& height) const = 0; virtual void set_accessible_name(const OUString& rName) = 0; virtual void set_accessible_description(const OUString& rDescription) = 0; virtual OUString get_accessible_name() const = 0; virtual OUString get_accessible_description() const = 0; virtual void set_accessible_relation_labeled_by(weld::Widget* pLabel) = 0; virtual void set_accessible_relation_label_for(weld::Widget* pLabeled) = 0; virtual void set_tooltip_text(const OUString& rTip) = 0; virtual OUString get_tooltip_text() const = 0; virtual void connect_focus_in(const Link& rLink) { assert(!m_aFocusInHdl.IsSet() || !rLink.IsSet()); m_aFocusInHdl = rLink; } virtual void connect_focus_out(const Link& rLink) { assert(!m_aFocusOutHdl.IsSet() || !rLink.IsSet()); m_aFocusOutHdl = rLink; } // rLink is called when the mnemonic for the Widget is called. // If rLink returns true the Widget will not automatically gain // focus as normally occurs virtual void connect_mnemonic_activate(const Link& rLink) { assert(!m_aMnemonicActivateHdl.IsSet() || !rLink.IsSet()); m_aMnemonicActivateHdl = rLink; } virtual void connect_size_allocate(const Link& rLink) { assert(!m_aSizeAllocateHdl.IsSet() || !rLink.IsSet()); m_aSizeAllocateHdl = rLink; } virtual void connect_key_press(const Link& rLink) { assert(!m_aKeyPressHdl.IsSet() || !rLink.IsSet()); m_aKeyPressHdl = rLink; } virtual void connect_key_release(const Link& rLink) { assert(!m_aKeyReleaseHdl.IsSet() || !rLink.IsSet()); m_aKeyReleaseHdl = rLink; } virtual void connect_mouse_press(const Link& rLink) { assert(!m_aMousePressHdl.IsSet() || !rLink.IsSet()); m_aMousePressHdl = rLink; } virtual void connect_mouse_move(const Link& rLink) { assert(!m_aMouseMotionHdl.IsSet() || !rLink.IsSet()); m_aMouseMotionHdl = rLink; } virtual void connect_mouse_release(const Link& rLink) { assert(!m_aMouseReleaseHdl.IsSet() || !rLink.IsSet()); m_aMouseReleaseHdl = rLink; } virtual void grab_add() = 0; virtual bool has_grab() const = 0; virtual void grab_remove() = 0; // font size is in points, not pixels, e.g. see Window::[G]etPointFont virtual vcl::Font get_font() = 0; //true for rtl, false otherwise virtual bool get_direction() const = 0; virtual void set_direction(bool bRTL) = 0; virtual void freeze() = 0; virtual void thaw() = 0; virtual void set_busy_cursor(bool bBusy) = 0; virtual void queue_resize() = 0; virtual std::unique_ptr weld_parent() const = 0; //iterate upwards through the hierarchy starting at this widgets parent, //calling func with their helpid until func returns true or we run out of //parents virtual void help_hierarchy_foreach(const std::function& func) = 0; virtual OUString strip_mnemonic(const OUString& rLabel) const = 0; virtual VclPtr create_virtual_device() const = 0; //make this widget look like a page in a notebook virtual void set_stack_background() = 0; //make this widget look like it has a highlighted background virtual void set_highlight_background() = 0; //make this widget suitable as parent for a title virtual void set_title_background() = 0; //make this widget suitable for use in a toolbar virtual void set_toolbar_background() = 0; //trying to use a custom color for a background is generally a bad idea. If your need //fits one of the above categories then that's a somewhat better choice virtual void set_background(const Color& rBackColor) = 0; virtual css::uno::Reference get_drop_target() = 0; virtual void connect_get_property_tree(const Link& rLink) = 0; virtual void get_property_tree(tools::JsonWriter& rJsonWriter) = 0; // render the widget to an output device virtual void draw(OutputDevice& rOutput, const tools::Rectangle& rRect) = 0; virtual ~Widget() {} }; class VCL_DLLPUBLIC Container : virtual public Widget { protected: Link m_aContainerFocusChangedHdl; void signal_container_focus_changed() { m_aContainerFocusChangedHdl.Call(*this); } public: // remove and add in one go virtual void move(weld::Widget* pWidget, weld::Container* pNewParent) = 0; // recursively unset has-default on any buttons in the widget hierarchy virtual void recursively_unset_default_buttons() = 0; // create an XWindow as a child of this container. The XWindow is // suitable to contain css::awt::XControl items virtual css::uno::Reference CreateChildFrame() = 0; // rLink is called when the focus transitions from a widget outside the container // to a widget inside the container or vice versa virtual void connect_container_focus_changed(const Link& rLink) { m_aContainerFocusChangedHdl = rLink; } // causes a child of the container to have the keyboard focus virtual void child_grab_focus() = 0; }; class VCL_DLLPUBLIC Box : virtual public Container { public: // Moves child to a new position in the list of children virtual void reorder_child(weld::Widget* pWidget, int position) = 0; // Sort ok/cancel etc buttons in platform order virtual void sort_native_button_order() = 0; }; class VCL_DLLPUBLIC Paned : virtual public Container { public: // set pixel position of divider virtual void set_position(int nPos) = 0; // get pixel position of divider virtual int get_position() const = 0; }; class VCL_DLLPUBLIC ScrolledWindow : virtual public Container { protected: Link m_aVChangeHdl; Link m_aHChangeHdl; void signal_vadjustment_changed() { m_aVChangeHdl.Call(*this); } void signal_hadjustment_changed() { m_aHChangeHdl.Call(*this); } public: virtual void hadjustment_configure(int value, int lower, int upper, int step_increment, int page_increment, int page_size) = 0; virtual int hadjustment_get_value() const = 0; virtual void hadjustment_set_value(int value) = 0; virtual int hadjustment_get_upper() const = 0; virtual void hadjustment_set_upper(int upper) = 0; virtual int hadjustment_get_page_size() const = 0; virtual void hadjustment_set_page_size(int size) = 0; virtual void hadjustment_set_page_increment(int size) = 0; virtual void hadjustment_set_step_increment(int size) = 0; virtual void set_hpolicy(VclPolicyType eHPolicy) = 0; virtual VclPolicyType get_hpolicy() const = 0; void connect_hadjustment_changed(const Link& rLink) { m_aHChangeHdl = rLink; } virtual int get_hscroll_height() const = 0; virtual void vadjustment_configure(int value, int lower, int upper, int step_increment, int page_increment, int page_size) = 0; virtual int vadjustment_get_value() const = 0; virtual void vadjustment_set_value(int value) = 0; virtual int vadjustment_get_upper() const = 0; virtual void vadjustment_set_upper(int upper) = 0; virtual int vadjustment_get_page_size() const = 0; virtual void vadjustment_set_page_size(int size) = 0; virtual void vadjustment_set_page_increment(int size) = 0; virtual void vadjustment_set_step_increment(int size) = 0; virtual int vadjustment_get_lower() const = 0; virtual void vadjustment_set_lower(int upper) = 0; virtual void set_vpolicy(VclPolicyType eVPolicy) = 0; virtual VclPolicyType get_vpolicy() const = 0; void connect_vadjustment_changed(const Link& rLink) { m_aVChangeHdl = rLink; } virtual int get_scroll_thickness() const = 0; virtual void set_scroll_thickness(int nThickness) = 0; //trying to use custom color for a scrollbar is generally a bad idea. virtual void customize_scrollbars(const Color& rBackgroundColor, const Color& rShadowColor, const Color& rFaceColor) = 0; }; class Label; class VCL_DLLPUBLIC Frame : virtual public Container { public: virtual void set_label(const OUString& rText) = 0; virtual OUString get_label() const = 0; virtual std::unique_ptr