gtkmm 4.17.0
|
Abstract Widget (Base class for all widgets) More...
#include <gtkmm/widget.h>
Classes | |
struct | Measurements |
Structure returned by the non-output-parameter overload of measure(). More... | |
struct | MinimumNatural |
Structure holding the minimum and natural sizes of a widget, in some type. More... | |
Public Member Functions | |
Widget (Widget &&src) noexcept | |
Widget & | operator= (Widget &&src) noexcept |
Widget (const Widget &)=delete | |
Widget & | operator= (const Widget &)=delete |
~Widget () noexcept override | |
Destroys the widget. | |
GtkWidget * | gobj () |
Provides access to the underlying C GObject. | |
const GtkWidget * | gobj () const |
Provides access to the underlying C GObject. | |
Glib::RefPtr< ConstraintTarget > | make_refptr_constrainttarget () |
Converts this widget to a reference counted Gtk::ConstraintTarget. | |
Glib::RefPtr< const ConstraintTarget > | make_refptr_constrainttarget () const |
Converts this widget to a reference counted Gtk::ConstraintTarget. | |
void | show () |
Flags a widget to be displayed. | |
void | hide () |
Reverses the effects of [method.Gtk.Widget.show]. | |
void | queue_draw () |
Schedules this widget to be redrawn. | |
void | queue_resize () |
Flags a widget to have its size renegotiated. | |
void | queue_allocate () |
Flags the widget for a rerun of the size_allocate_vfunc() function. | |
void | size_allocate (const Allocation &allocation, int baseline) |
Allocates widget with a transformation that translates the origin to the position in allocation. | |
SizeRequestMode | get_request_mode () const |
Gets whether the widget prefers a height-for-width layout or a width-for-height layout. | |
void | measure (Orientation orientation, int for_size, int & minimum, int & natural, int &minimum_baseline, int &natural_baseline) const |
Measures widget in the orientation orientation and for the given for_size. | |
Measurements | measure (Orientation orientation, int for_size=-1) const |
Like the other overload of measure() but returns a structure holding the sizes/baselines instead of using output parameters. | |
void | get_preferred_size (Requisition &minimum_size, Requisition &natural_size) const |
Retrieves the minimum and natural size of a widget, taking into account the widget’s preference for height-for-width management. | |
PreferredSize | get_preferred_size () const |
Like the other overload of get_preferred_size() but returns a structure holding the sizes instead of using output parameters. | |
void | set_layout_manager (const Glib::RefPtr< LayoutManager > &layout_manager) |
Sets the layout manager to use for measuring and allocating children of the widget. | |
void | unset_layout_manager () |
Undoes the effect of a previous call to set_layout_manager(). | |
Glib::RefPtr< LayoutManager > | get_layout_manager () |
Retrieves the layout manager of the widget. | |
Glib::RefPtr< const LayoutManager > | get_layout_manager () const |
Retrieves the layout manager of the widget. | |
bool | mnemonic_activate (bool group_cycling) |
Emits the signal_mnemonic_activate() signal. | |
bool | activate () |
For widgets that can be “activated” (buttons, menu items, etc.) this function activates them. | |
void | set_can_focus (bool can_focus=true) |
Sets whether the input focus can enter the widget or any of its children. | |
bool | get_can_focus () const |
Determines whether the input focus can enter the widget or any of its children. | |
void | set_focusable (bool focusable=true) |
Sets whether the widget can own the input focus. | |
bool | get_focusable () const |
Determines whether the widget can own the input focus. | |
bool | has_focus () const |
Determines if the widget has the global input focus. | |
bool | is_focus () const |
Determines if the widget is the focus widget within its toplevel. | |
bool | has_visible_focus () const |
Determines if the widget should show a visible indication that it has the global input focus. | |
bool | grab_focus () |
Causes widget to have the keyboard focus for the window that it belongs to. | |
void | set_focus_on_click (bool focus_on_click=true) |
Sets whether the widget should grab focus when it is clicked with the mouse. | |
bool | get_focus_on_click () const |
Returns whether the widget should grab focus when it is clicked with the mouse. | |
void | set_can_target (bool can_target=true) |
Sets whether the widget can be the target of pointer events. | |
bool | get_can_target () const |
Queries whether the widget can be the target of pointer events. | |
bool | has_default () const |
Determines whether the widget is the current default widget within its toplevel. | |
void | set_receives_default (bool receives_default=true) |
Sets whether the widget will be treated as the default widget within its toplevel when it has the focus, even if another widget is the default. | |
bool | get_receives_default () const |
Determines whether the widget is always treated as the default widget within its toplevel when it has the focus, even if another widget is the default. | |
void | set_name (const Glib::ustring & name) |
Sets a widgets name. | |
void | unset_name () |
Glib::ustring | get_name () const |
Retrieves the name of a widget. | |
void | set_state_flags (StateFlags flags, bool clear=true) |
Turns on flag values in the current widget state. | |
void | unset_state_flags (StateFlags flags) |
Turns off flag values for the current widget state. | |
StateFlags | get_state_flags () const |
Returns the widget state as a flag set. | |
void | set_sensitive (bool sensitive=true) |
Sets the sensitivity of the widget. | |
bool | get_sensitive () const |
Returns the widget’s sensitivity. | |
bool | is_sensitive () const |
Returns the widget’s effective sensitivity. | |
void | set_visible (bool visible=true) |
Sets the visibility state of widget. | |
bool | get_visible () const |
Determines whether the widget is visible. | |
bool | is_visible () const |
Determines whether the widget and all its parents are marked as visible. | |
bool | is_drawable () const |
Determines whether the widget can be drawn to. | |
bool | get_realized () const |
Determines whether the widget is realized. | |
bool | get_mapped () const |
Returns whether the widget is mapped. | |
void | set_child_visible (bool visible=true) |
Sets whether the widget should be mapped along with its parent. | |
bool | get_child_visible () const |
Gets the value set with set_child_visible(). | |
int | get_allocated_width () const |
Returns the width that has currently been allocated to the widget. | |
int | get_allocated_height () const |
Returns the height that has currently been allocated to the widget. | |
int | get_allocated_baseline () const |
Returns the baseline that has currently been allocated to the widget. | |
Allocation | get_allocation () const |
Retrieves the widget’s location. | |
std::optional< Gdk::Graphene::Rect > | compute_bounds (const Widget & target) const |
Computes the bounds for the widget in the coordinate space of target. | |
std::optional< Gdk::Graphene::Point > | compute_point (const Widget & target, const Gdk::Graphene::Point &point) const |
Translates the given point in the widget's coordinates to coordinates relative to target’s coordinate system. | |
int | get_width () const |
Returns the content width of the widget. | |
int | get_height () const |
Returns the content height of the widget. | |
int | get_baseline () const |
Returns the baseline that has currently been allocated to the widget. | |
int | get_size (Orientation orientation) const |
Returns the content width or height of the widget. | |
Widget * | get_parent () |
Returns the parent widget of the widget. | |
const Widget * | get_parent () const |
Returns the parent widget of the widget. | |
Root * | get_root () |
Returns the Gtk::Root widget of the widget. | |
const Root * | get_root () const |
Returns the Gtk::Root widget of the widget. | |
Native * | get_native () |
Returns the nearest Gtk::Native ancestor of the widget. | |
const Native * | get_native () const |
Returns the nearest Gtk::Native ancestor of the widget. | |
bool | child_focus (DirectionType direction) |
Called by widgets as the user moves around the window using keyboard shortcuts. | |
bool | keynav_failed (DirectionType direction) |
Emits the signal_keynav_failed() signal on the widget. | |
void | error_bell () |
Notifies the user about an input-related error on the widget. | |
void | set_size_request (int width=-1, int height=-1) |
Sets the minimum size of the widget. | |
void | get_size_request (int & width, int &height) const |
Gets the size request that was explicitly set for the widget. | |
Requisition | get_size_request () const |
Like the other overload of get_size_request() but returns a structure holding the sizes instead of using output parameters. | |
void | set_opacity (double opacity) |
Requests the widget to be rendered partially transparent. | |
double | get_opacity () const |
Fetches the requested opacity for the widget. | |
void | set_overflow (Overflow overflow) |
Sets how the widget treats content that is drawn outside the it's content area. | |
Overflow | get_overflow () const |
Returns the widget’s overflow value. | |
Widget * | get_ancestor (GType widget_type) |
Gets the first ancestor of the widget with type widget_type. | |
const Widget * | get_ancestor (GType widget_type) const |
Gets the first ancestor of the widget with type widget_type. | |
int | get_scale_factor () const |
Retrieves the internal scale factor that maps from window coordinates to the actual device pixels. | |
Glib::RefPtr< Gdk::Display > | get_display () |
Get the display for the window that the widget belongs to. | |
Glib::RefPtr< const Gdk::Display > | get_display () const |
Get the display for the window that the widget belongs to. | |
Glib::RefPtr< Settings > | get_settings () |
Gets the settings object holding the settings used for the widget. | |
Glib::RefPtr< Gdk::Clipboard > | get_clipboard () |
Gets the clipboard object for the widget. | |
Glib::RefPtr< const Gdk::Clipboard > | get_clipboard () const |
Gets the clipboard object for the widget. | |
Glib::RefPtr< Gdk::Clipboard > | get_primary_clipboard () |
Gets the primary clipboard of the widget. | |
Glib::RefPtr< const Gdk::Clipboard > | get_primary_clipboard () const |
Gets the primary clipboard of the widget. | |
bool | get_hexpand () const |
Gets whether the widget would like any available extra horizontal space. | |
void | set_hexpand (bool expand=true) |
Sets whether the widget would like any available extra horizontal space. | |
bool | get_hexpand_set () const |
Gets whether the hexpand flag has been explicitly set. | |
void | set_hexpand_set (bool set=true) |
Sets whether the hexpand flag will be used. | |
bool | get_vexpand () const |
Gets whether the widget would like any available extra vertical space. | |
void | set_vexpand (bool expand=true) |
Sets whether the widget would like any available extra vertical space. | |
bool | get_vexpand_set () const |
Gets whether the vexpand flag has been explicitly set. | |
void | set_vexpand_set (bool set=true) |
Sets whether the vexpand flag will be used. | |
bool | compute_expand (Orientation orientation) |
Computes whether a parent widget should give this widget extra space when possible. | |
void | set_expand (bool expand=true) |
Sets whether the widget would like any available extra space in both directions. | |
Align | get_halign () const |
Gets the horizontal alignment of the widget. | |
void | set_halign (Align align) |
Sets the horizontal alignment of the widget. | |
Align | get_valign () const |
Gets the vertical alignment of the widget. | |
void | set_valign (Align align) |
Sets the vertical alignment of the widget. | |
int | get_margin_start () const |
Gets the start margin of the widget. | |
void | set_margin_start (int margin) |
Sets the start margin of the widget. | |
int | get_margin_end () const |
Gets the end margin of the widget. | |
void | set_margin_end (int margin) |
Sets the end margin of the widget. | |
int | get_margin_top () const |
Gets the top margin of the widget. | |
void | set_margin_top (int margin) |
Sets the top margin of the widget. | |
int | get_margin_bottom () const |
Gets the bottom margin of the widget. | |
void | set_margin_bottom (int margin) |
Sets the bottom margin of the widget. | |
void | set_margin (int margin) |
Set all 4 margins to the same value. | |
bool | is_ancestor (Widget &ancestor) const |
Determines whether the widget is a descendent of ancestor. | |
bool | translate_coordinates (Widget &dest_widget, double src_x, double src_y, double &dest_x, double &dest_y) |
Translates coordinates relative to src_widget’s allocation to coordinates relative to dest_widget’s allocations. | |
bool | contains (double x, double y) const |
Tests if a given point is contained in the widget. | |
Widget * | pick (double x, double y, PickFlags flags=PickFlags::DEFAULT) |
Finds the descendant of the widget closest to a point. | |
const Widget * | pick (double x, double y, PickFlags flags=PickFlags::DEFAULT) const |
Finds the descendant of the widget closest to a point. | |
void | add_controller (const Glib::RefPtr< EventController > &controller) |
Adds an event controller to the widget. | |
void | remove_controller (const Glib::RefPtr< EventController > &controller) |
Removes an event controller from the widget. | |
Glib::RefPtr< Pango::Context > | create_pango_context () |
Creates a new Pango::Context that is configured for the widget. | |
Glib::RefPtr< Pango::Context > | get_pango_context () |
Gets a Pango::Context that is configured for the widget. | |
void | set_font_options (const Cairo::FontOptions &options) |
Sets the cairo_font_options_t used for text rendering in the widget. | |
void | unset_font_options () |
Undoes the effect of previous calls to set_font_options(). | |
Cairo::FontOptions | get_font_options () const |
Returns the cairo_font_options_t of the widget. | |
Glib::RefPtr< Pango::Layout > | create_pango_layout (const Glib::ustring &text) |
Creates a new Pango::Layout that is configured for the widget. | |
void | set_direction (TextDirection dir) |
Sets the reading direction on the widget. | |
TextDirection | get_direction () const |
Gets the reading direction for the widget. | |
void | set_cursor (const Glib::RefPtr< Gdk::Cursor > &cursor) |
Sets the cursor to be shown when the pointer hovers over the widget. | |
void | set_cursor (const Glib::ustring & name={}) |
Sets a named cursor to be shown when pointer devices point towards the widget. | |
Glib::RefPtr< Gdk::Cursor > | get_cursor () |
Gets the cursor set on the widget. | |
Glib::RefPtr< const Gdk::Cursor > | get_cursor () const |
Gets the cursor set on the widget. | |
std::vector< Widget * > | list_mnemonic_labels () |
Returns the widgets for which this widget is the target of a mnemonic. | |
std::vector< const Widget * > | list_mnemonic_labels () const |
Returns the widgets for which this widget is the target of a mnemonic. | |
void | add_mnemonic_label (Widget &label) |
Adds a widget to the list of mnemonic labels for this widget. | |
void | remove_mnemonic_label (Widget &label) |
Removes a widget from the list of mnemonic labels for this widget. | |
bool | drag_check_threshold (int start_x, int start_y, int current_x, int current_y) |
Checks to see if a drag movement has passed the GTK drag threshold. | |
Glib::RefPtr< Gdk::FrameClock > | get_frame_clock () |
Obtains the frame clock for a widget. | |
Glib::RefPtr< const Gdk::FrameClock > | get_frame_clock () const |
Obtains the frame clock for a widget. | |
void | set_parent (Widget & parent) |
Sets the parent widget of the widget. | |
void | unparent () |
Removes widget from its parent. | |
void | map () |
Causes a widget to be mapped if it isn’t already. | |
void | unmap () |
Causes a widget to be unmapped if it’s currently mapped. | |
void | trigger_tooltip_query () |
Triggers a tooltip query on the display of the widget. | |
void | set_tooltip_text (const Glib::ustring &text) |
Sets the contents of the tooltip for the widget. | |
Glib::ustring | get_tooltip_text () const |
Gets the contents of the tooltip for the widget. | |
void | set_tooltip_markup (const Glib::ustring &markup) |
Sets the contents of the tooltip for widget. | |
Glib::ustring | get_tooltip_markup () const |
Gets the contents of the tooltip for the widget. | |
void | set_has_tooltip (bool has_tooltip=TRUE) |
Sets the has-tooltip property on the widget. | |
bool | get_has_tooltip () const |
Returns the current value of the has-tooltip property. | |
bool | in_destruction () const |
Returns whether the widget is currently being destroyed. | |
Glib::RefPtr< StyleContext > | get_style_context () |
Returns the style context associated to the widget. | |
Glib::RefPtr< const StyleContext > | get_style_context () const |
Returns the style context associated to the widget. | |
guint | add_tick_callback (const SlotTick & slot) |
Queues an animation frame update and adds a callback to be called before each frame. | |
void | remove_tick_callback (guint id) |
Removes a tick callback previously registered with add_tick_callback(). | |
void | insert_action_group (const Glib::ustring & name, const Glib::RefPtr< Gio::ActionGroup > & group) |
Inserts an action group into the widget's actions. | |
void | remove_action_group (const Glib::ustring & name) |
Removes a group from the widget. | |
bool | activate_action (const Glib::ustring & name, const Glib::VariantBase &args={}) |
Looks up the action in the action groups associated with the widget and its ancestors, and activates it. | |
void | activate_default () |
Activates the default.activate action for the widget. | |
void | set_font_map (const Glib::RefPtr< Pango::FontMap > &font_map) |
Sets the font map to use for text rendering in the widget. | |
Glib::RefPtr< Pango::FontMap > | get_font_map () |
Gets the font map of the widget. | |
Glib::RefPtr< const Pango::FontMap > | get_font_map () const |
Gets the font map of the widget. | |
Widget * | get_first_child () |
Returns the widget’s first child. | |
const Widget * | get_first_child () const |
Returns the widget’s first child. | |
Widget * | get_last_child () |
Returns the widget’s last child. | |
const Widget * | get_last_child () const |
Returns the widget’s last child. | |
Widget * | get_next_sibling () |
Returns the widget’s next sibling. | |
const Widget * | get_next_sibling () const |
Returns the widget’s next sibling. | |
Widget * | get_prev_sibling () |
Returns the widget’s previous sibling. | |
const Widget * | get_prev_sibling () const |
Returns the widget’s previous sibling. | |
std::vector< Widget * > | get_children () |
Gets a vector of the widgetʼs current children, from first child to last. | |
std::vector< const Widget * > | get_children () const |
Gets a vector of the widgetʼs current children, from first child to last. | |
Glib::RefPtr< Gio::ListModel > | observe_children () |
Returns a list model to track the children of the widget. | |
Glib::RefPtr< const Gio::ListModel > | observe_children () const |
Returns a list model to track the children of the widget. | |
Glib::RefPtr< Gio::ListModel > | observe_controllers () |
Returns a list model to track the event controllers of the widget. | |
Glib::RefPtr< const Gio::ListModel > | observe_controllers () const |
Returns a list model to track the event controllers of the widget. | |
void | insert_after (Widget & parent, const Widget &previous_sibling) |
Inserts the Widget into the child widget list of parent after previous_sibling. | |
void | insert_before (Widget & parent, const Widget & next_sibling) |
Inserts the Widget into the child widget list of parent before next_sibling. | |
void | insert_at_start (Widget & parent) |
Inserts the Widget at the beginning of the child widget list of parent. | |
void | insert_at_end (Widget & parent) |
Inserts the Widget at the end of the child widget list of parent. | |
void | snapshot_child (Widget &child, const Glib::RefPtr< Gtk::Snapshot > & snapshot) |
Snapshots a child of the widget. | |
bool | should_layout () const |
Returns whether the widget should contribute to the measuring and allocation of its parent. | |
Glib::ustring | get_css_name () const |
Returns the CSS name of the widget. | |
void | add_css_class (const Glib::ustring &css_class) |
Adds a style class to the widget. | |
void | remove_css_class (const Glib::ustring &css_class) |
Removes a style from the widget. | |
bool | has_css_class (const Glib::ustring &css_class) const |
Returns whether a style class is currently applied to the widget. | |
std::vector< Glib::ustring > | get_css_classes () const |
Returns the list of style classes applied to the widget. | |
void | set_css_classes (const std::vector< Glib::ustring > &classes) |
Replaces the current style classes of the widget with classes. | |
Gdk::RGBA | get_color () const |
Gets the current foreground color for the widget's CSS style. | |
Glib::SignalProxy< void()> | signal_show () |
Glib::SignalProxy< void()> | signal_hide () |
Glib::SignalProxy< void()> | signal_map () |
Emitted on mapping of a widget to the screen. | |
Glib::SignalProxy< void()> | signal_unmap () |
Glib::SignalProxy< void()> | signal_realize () |
Emitted on realization of a widget. | |
Glib::SignalProxy< void()> | signal_unrealize () |
Glib::SignalProxy< void(Gtk::StateFlags)> | signal_state_flags_changed () |
Glib::SignalProxy< void(TextDirection)> | signal_direction_changed () |
Glib::SignalProxy< bool(bool)> | signal_mnemonic_activate () |
Glib::SignalProxy< void()> | signal_destroy () |
Emitted during the dispose phase. | |
Glib::SignalProxy< bool(int, int, bool, const Glib::RefPtr< Tooltip > &)> | signal_query_tooltip () |
Glib::PropertyProxy< Glib::ustring > | property_name () |
The name of the widget. | |
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_name () const |
The name of the widget. | |
Glib::PropertyProxy_ReadOnly< Widget * > | property_parent () const |
The parent widget of this widget. | |
Glib::PropertyProxy_ReadOnly< Root * > | property_root () const |
The Gtk::Root widget of the widget tree containing this widget. | |
Glib::PropertyProxy< int > | property_width_request () |
Overrides for width request of the widget. | |
Glib::PropertyProxy_ReadOnly< int > | property_width_request () const |
Overrides for width request of the widget. | |
Glib::PropertyProxy< int > | property_height_request () |
Overrides for height request of the widget. | |
Glib::PropertyProxy_ReadOnly< int > | property_height_request () const |
Overrides for height request of the widget. | |
Glib::PropertyProxy< bool > | property_visible () |
Whether the widget is visible. | |
Glib::PropertyProxy_ReadOnly< bool > | property_visible () const |
Whether the widget is visible. | |
Glib::PropertyProxy< bool > | property_sensitive () |
Whether the widget responds to input. | |
Glib::PropertyProxy_ReadOnly< bool > | property_sensitive () const |
Whether the widget responds to input. | |
Glib::PropertyProxy< bool > | property_can_focus () |
Whether the widget or any of its descendents can accept the input focus. | |
Glib::PropertyProxy_ReadOnly< bool > | property_can_focus () const |
Whether the widget or any of its descendents can accept the input focus. | |
Glib::PropertyProxy_ReadOnly< bool > | property_has_focus () const |
Whether the widget has the input focus. | |
Glib::PropertyProxy< bool > | property_can_target () |
Whether the widget can receive pointer events. | |
Glib::PropertyProxy_ReadOnly< bool > | property_can_target () const |
Whether the widget can receive pointer events. | |
Glib::PropertyProxy< bool > | property_focus_on_click () |
Whether the widget should grab focus when it is clicked with the mouse. | |
Glib::PropertyProxy_ReadOnly< bool > | property_focus_on_click () const |
Whether the widget should grab focus when it is clicked with the mouse. | |
Glib::PropertyProxy< bool > | property_focusable () |
Whether this widget itself will accept the input focus. | |
Glib::PropertyProxy_ReadOnly< bool > | property_focusable () const |
Whether this widget itself will accept the input focus. | |
Glib::PropertyProxy_ReadOnly< bool > | property_has_default () const |
Whether the widget is the default widget. | |
Glib::PropertyProxy< bool > | property_receives_default () |
Whether the widget will receive the default action when it is focused. | |
Glib::PropertyProxy_ReadOnly< bool > | property_receives_default () const |
Whether the widget will receive the default action when it is focused. | |
Glib::PropertyProxy< Glib::RefPtr< Gdk::Cursor > > | property_cursor () |
The cursor used by widget. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gdk::Cursor > > | property_cursor () const |
The cursor used by widget. | |
Glib::PropertyProxy< bool > | property_has_tooltip () |
Enables or disables the emission of the signal_query_tooltip() signal on widget. | |
Glib::PropertyProxy_ReadOnly< bool > | property_has_tooltip () const |
Enables or disables the emission of the signal_query_tooltip() signal on widget. | |
Glib::PropertyProxy< Glib::ustring > | property_tooltip_markup () |
Sets the text of tooltip to be the given string, which is marked up with Pango markup. | |
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_tooltip_markup () const |
Sets the text of tooltip to be the given string, which is marked up with Pango markup. | |
Glib::PropertyProxy< Glib::ustring > | property_tooltip_text () |
Sets the text of tooltip to be the given string. | |
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_tooltip_text () const |
Sets the text of tooltip to be the given string. | |
Glib::PropertyProxy< Align > | property_halign () |
How to distribute horizontal space if widget gets extra space. | |
Glib::PropertyProxy_ReadOnly< Align > | property_halign () const |
How to distribute horizontal space if widget gets extra space. | |
Glib::PropertyProxy< Align > | property_valign () |
How to distribute vertical space if widget gets extra space. | |
Glib::PropertyProxy_ReadOnly< Align > | property_valign () const |
How to distribute vertical space if widget gets extra space. | |
Glib::PropertyProxy< int > | property_margin_start () |
Margin on start of widget, horizontally. | |
Glib::PropertyProxy_ReadOnly< int > | property_margin_start () const |
Margin on start of widget, horizontally. | |
Glib::PropertyProxy< int > | property_margin_end () |
Margin on end of widget, horizontally. | |
Glib::PropertyProxy_ReadOnly< int > | property_margin_end () const |
Margin on end of widget, horizontally. | |
Glib::PropertyProxy< int > | property_margin_top () |
Margin on top side of widget. | |
Glib::PropertyProxy_ReadOnly< int > | property_margin_top () const |
Margin on top side of widget. | |
Glib::PropertyProxy< int > | property_margin_bottom () |
Margin on bottom side of widget. | |
Glib::PropertyProxy_ReadOnly< int > | property_margin_bottom () const |
Margin on bottom side of widget. | |
Glib::PropertyProxy< bool > | property_hexpand () |
Whether to expand horizontally. | |
Glib::PropertyProxy_ReadOnly< bool > | property_hexpand () const |
Whether to expand horizontally. | |
Glib::PropertyProxy< bool > | property_hexpand_set () |
Whether to use the hexpand property. | |
Glib::PropertyProxy_ReadOnly< bool > | property_hexpand_set () const |
Whether to use the hexpand property. | |
Glib::PropertyProxy< bool > | property_vexpand () |
Whether to expand vertically. | |
Glib::PropertyProxy_ReadOnly< bool > | property_vexpand () const |
Whether to expand vertically. | |
Glib::PropertyProxy< bool > | property_vexpand_set () |
Whether to use the vexpand property. | |
Glib::PropertyProxy_ReadOnly< bool > | property_vexpand_set () const |
Whether to use the vexpand property. | |
Glib::PropertyProxy< double > | property_opacity () |
The requested opacity of the widget. | |
Glib::PropertyProxy_ReadOnly< double > | property_opacity () const |
The requested opacity of the widget. | |
Glib::PropertyProxy< Overflow > | property_overflow () |
How content outside the widget's content area is treated. | |
Glib::PropertyProxy_ReadOnly< Overflow > | property_overflow () const |
How content outside the widget's content area is treated. | |
Glib::PropertyProxy_ReadOnly< int > | property_scale_factor () const |
The scale factor of the widget. | |
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_css_name () const |
The name of this widget in the CSS tree. | |
Glib::PropertyProxy< std::vector< Glib::ustring > > | property_css_classes () |
A list of css classes applied to this widget. | |
Glib::PropertyProxy_ReadOnly< std::vector< Glib::ustring > > | property_css_classes () const |
A list of css classes applied to this widget. | |
Glib::PropertyProxy< Glib::RefPtr< LayoutManager > > | property_layout_manager () |
The Gtk::LayoutManager instance to use to compute the preferred size of the widget, and allocate its children. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< LayoutManager > > | property_layout_manager () const |
The Gtk::LayoutManager instance to use to compute the preferred size of the widget, and allocate its children. | |
![]() | |
Object (Object &&src) noexcept | |
Object & | operator= (Object &&src) noexcept |
~Object () noexcept override | |
![]() | |
Object (const Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&src) noexcept | |
Object & | operator= (Object &&src) noexcept |
void * | get_data (const QueryQuark &key) |
void | set_data (const Quark &key, void *data) |
void | set_data_with_c_callback (const Quark &key, void *data, GDestroyNotify notify) |
void | set_data (const Quark &key, void *data, DestroyNotify notify) |
void | remove_data (const QueryQuark &quark) |
void * | steal_data (const QueryQuark &quark) |
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false) |
![]() | |
ObjectBase (const ObjectBase &)=delete | |
ObjectBase & | operator= (const ObjectBase &)=delete |
void | set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value) |
void | get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const |
void | set_property (const Glib::ustring &property_name, const PropertyType &value) |
void | get_property (const Glib::ustring &property_name, PropertyType &value) const |
PropertyType | get_property (const Glib::ustring &property_name) const |
sigc::connection | connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot) |
sigc::connection | connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot) |
void | freeze_notify () |
void | thaw_notify () |
virtual void | reference () const |
virtual void | unreference () const |
GObject * | gobj () |
const GObject * | gobj () const |
GObject * | gobj_copy () const |
![]() | |
trackable () noexcept | |
trackable (const trackable &src) noexcept | |
trackable (trackable &&src) noexcept | |
~trackable () | |
void | add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const |
void | notify_callbacks () |
trackable & | operator= (const trackable &src) |
trackable & | operator= (trackable &&src) noexcept |
void | remove_destroy_notify_callback (notifiable *data) const |
![]() | |
Accessible (Accessible &&src) noexcept | |
Accessible & | operator= (Accessible &&src) noexcept |
~Accessible () noexcept override | |
GtkAccessible * | gobj () |
Provides access to the underlying C GObject. | |
const GtkAccessible * | gobj () const |
Provides access to the underlying C GObject. | |
Glib::RefPtr< ATContext > | get_at_context () |
Retrieves the implementation for the given accessible object. | |
Glib::RefPtr< const ATContext > | get_at_context () const |
Retrieves the implementation for the given accessible object. | |
bool | get_platform_state (PlatformState state) const |
Queries a platform state, such as focus. | |
Glib::RefPtr< Accessible > | get_accessible_parent () |
Retrieves the accessible parent for an accessible object. | |
Glib::RefPtr< const Accessible > | get_accessible_parent () const |
Retrieves the accessible parent for an accessible object. | |
void | set_accessible_parent (const Glib::RefPtr< Accessible > & parent, const Glib::RefPtr< Accessible > & next_sibling) |
Sets the parent and sibling of an accessible object. | |
Glib::RefPtr< Accessible > | get_first_accessible_child () |
Retrieves the first accessible child of an accessible object. | |
Glib::RefPtr< const Accessible > | get_first_accessible_child () const |
Retrieves the first accessible child of an accessible object. | |
Glib::RefPtr< Accessible > | get_next_accessible_sibling () |
Retrieves the next accessible sibling of an accessible object. | |
Glib::RefPtr< const Accessible > | get_next_accessible_sibling () const |
Retrieves the next accessible sibling of an accessible object. | |
void | update_next_accessible_sibling (const Glib::RefPtr< Accessible > &new_sibling) |
Updates the next accessible sibling. | |
bool | get_bounds (int &x, int &y, int & width, int &height) const |
Queries the coordinates and dimensions of this accessible. | |
Role | get_accessible_role () const |
Retrieves the accessible role of an accessible object. | |
void | update_state (State state, const Glib::ValueBase & value) |
Updates an accessible state. | |
void | update_property (Property property, const Glib::ValueBase & value) |
Updates an accessible property. | |
void | update_relation (Relation relation, const Glib::ValueBase & value) |
Updates an accessible relation. | |
void | reset_state (State state) |
Resets the accessible state to its default value. | |
void | reset_property (Property property) |
Resets the accessible property to its default value. | |
void | reset_relation (Relation relation) |
Resets the accessible relation to its default value. | |
void | announce (const Glib::ustring & message, AnnouncementPriority priority) |
Requests the user's screen reader to announce the given message. | |
Glib::PropertyProxy< Role > | property_accessible_role () |
The accessible role of the given Gtk::Accessible implementation. | |
Glib::PropertyProxy_ReadOnly< Role > | property_accessible_role () const |
The accessible role of the given Gtk::Accessible implementation. | |
![]() | |
Interface () | |
Interface (Interface &&src) noexcept | |
Interface & | operator= (Interface &&src) noexcept |
Interface (const Glib::Interface_Class &interface_class) | |
Interface (GObject *castitem) | |
~Interface () noexcept override | |
Interface (const Interface &)=delete | |
Interface & | operator= (const Interface &)=delete |
GObject * | gobj () |
const GObject * | gobj () const |
![]() | |
Buildable (Buildable &&src) noexcept | |
Buildable & | operator= (Buildable &&src) noexcept |
~Buildable () noexcept override | |
GtkBuildable * | gobj () |
Provides access to the underlying C GObject. | |
const GtkBuildable * | gobj () const |
Provides access to the underlying C GObject. | |
Glib::ustring | get_buildable_id () const |
Gets the ID of the buildable object. | |
![]() | |
ConstraintTarget (ConstraintTarget &&src) noexcept | |
ConstraintTarget & | operator= (ConstraintTarget &&src) noexcept |
~ConstraintTarget () noexcept override | |
GtkConstraintTarget * | gobj () |
Provides access to the underlying C GObject. | |
const GtkConstraintTarget * | gobj () const |
Provides access to the underlying C GObject. | |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
static void | set_default_direction (TextDirection dir) |
Sets the default reading direction for widgets. | |
static TextDirection | get_default_direction () |
Obtains the default reading direction. | |
![]() | |
static void | add_interface (GType gtype_implementer) |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
![]() | |
static void | add_interface (GType gtype_implementer) |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
![]() | |
static void | add_interface (GType gtype_implementer) |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Related Symbols | |
(Note that these are not member symbols.) | |
Gtk::Widget * | wrap (GtkWidget *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
![]() | |
Glib::RefPtr< Gtk::Accessible > | wrap (GtkAccessible *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
![]() | |
Glib::RefPtr< Gtk::Buildable > | wrap (GtkBuildable *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
![]() | |
Glib::RefPtr< Gtk::ConstraintTarget > | wrap (GtkConstraintTarget *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Abstract Widget (Base class for all widgets)
As the base class of all widgets this contains all of the properties and methods common to all widgets. It manages the widget lifecycle, layout, states and style. It is an abstract class that cannot be instantiated.
An important part of widgets are events that can be trapped by adding event controllers with add_controller(). Those are events coming directly from GDK. By using event controllers you can trap everything a widget can ever do. The Event Controllers and Gestures group lists the event controller classes.
Most widgets are added as children to a container widget, such as a Box, Grid or Window. A child widget can be managed or non-managed. A managed widget is created with the Gtk::make_managed() template function. Such a widget is deleted when its parent container is deleted. By default widgets are non-managed. This is fine for widgets declared as data members of a class. They are not deleted when their parent is deleted, but when the containing class instance is deleted. Memory management of widgets is described in more detail in the Memory management chapter in the Programming with gtkmm book.
Structure returned by the non-output-parameter overload of get_preferred_size().
using Gtk::Widget::SlotTick = sigc::slot<bool(const Glib::RefPtr<Gdk::FrameClock>&)> |
Callback type for adding a function to update animations.
See add_tick_callback().
For instance:
frame_clock | The frame clock for the widget (same as calling get_frame_clock()). |
true
if the tick callback should continue to be called, false
if the tick callback should be removed.
|
noexcept |
|
overridenoexcept |
Destroys the widget.
Except: if the widget has a parent, only the C++ wrapper is destroyed, not the C instance; please see the “Memory management” chapter in the Programming with gtkmm book as linked in the intro.
|
protected |
bool Gtk::Widget::activate | ( | ) |
For widgets that can be “activated” (buttons, menu items, etc.) this function activates them.
The activation will emit the signal set using gtk_widget_class_set_activate_signal() during class initialization.
Activation is what happens when you press Enter on a widget during key navigation.
If you wish to handle the activation keybinding yourself, it is recommended to use gtk_widget_class_add_shortcut() with an action created with Gtk::SignalAction::create().
true
if the widget was activatable, else false
. bool Gtk::Widget::activate_action | ( | const Glib::ustring & | name, |
const Glib::VariantBase & | args = {} |
||
) |
Looks up the action in the action groups associated with the widget and its ancestors, and activates it.
If the action is in an action group added with insert_action_group(), the name is expected to be prefixed with the prefix that was used when the group was inserted.
The arguments must match the action's expected parameter type, as returned by Gio::Action::get_parameter_type().
name | The name of the action to activate. |
args | Parameters to use, or an empty (invalid) Glib::VariantBase if the action does not expect parameters. |
true
if the action was activated, false
if the action does not exist. void Gtk::Widget::activate_default | ( | ) |
Activates the default.activate
action for the widget.
The action is looked up in the same was as for activate_action().
void Gtk::Widget::add_controller | ( | const Glib::RefPtr< EventController > & | controller | ) |
Adds an event controller to the widget.
The event controllers of a widget handle the events that are propagated to the widget.
You will usually want to call this function right after creating any kind of Gtk::EventController.
controller | An event controller that hasn't been added to a widget yet. |
void Gtk::Widget::add_css_class | ( | const Glib::ustring & | css_class | ) |
Adds a style class to the widget.
After calling this function, the widget’s style will match for css_class, according to CSS matching rules.
Use remove_css_class() to remove the style again.
css_class | Style class to add to widget, without the leading period. |
Adds a widget to the list of mnemonic labels for this widget.
Note that the list of mnemonic labels for the widget is cleared when the widget is destroyed, so the caller must make sure to update its internal state at this point as well.
label | A widget that acts as a mnemonic label for widget. |
Queues an animation frame update and adds a callback to be called before each frame.
Until the tick callback is removed, it will be called frequently (usually at the frame rate of the output device or as quickly as the application can be repainted, whichever is slower). For this reason, is most suitable for handling graphics that change every frame or every few frames. The tick callback does not automatically imply a relayout or repaint. If you want a repaint or relayout, and aren’t changing widget properties that would trigger that (for example, changing the text of a Gtk::Label), then you will have to call queue_resize() or queue_draw_area() yourself.
Gdk::FrameClock::get_frame_time() should generally be used for timing continuous animations and Gdk::FrameTimings::get_predicted_presentation_time() if you are trying to display isolated frames at particular times.
This is a more convenient alternative to connecting directly to the Gdk::FrameClock::signal_update() signal of Gdk::FrameClock, since you don't have to worry about when a Gdk::FrameClock is assigned to a widget.
slot | Slot to call for updating animations. |
bool Gtk::Widget::child_focus | ( | DirectionType | direction | ) |
Called by widgets as the user moves around the window using keyboard shortcuts.
The direction argument indicates what kind of motion is taking place (up, down, left, right, tab forward, tab backward).
This function calls the focus_vfunc() virtual function; widgets can override the virtual function in order to implement appropriate focus behavior.
The default focus()
virtual function for a widget should return true if moving in direction left the focus on a focusable location inside that widget, and false if moving in direction moved the focus outside the widget. When returning true, widgets normally call grab_focus() to place the focus accordingly; when returning false, they don’t modify the current focus location.
This function is used by custom widget implementations; if you're writing an app, you’d use grab_focus() to move the focus to a particular widget.
direction | Direction of focus movement. |
std::optional< Gdk::Graphene::Rect > Gtk::Widget::compute_bounds | ( | const Widget & | target | ) | const |
Computes the bounds for the widget in the coordinate space of target.
The bounds of widget are (the bounding box of) the region that it is expected to draw in.
If the operation is successful, a std::optional<Gdk::Graphene::Rect> that contains a value is returned. If the widget has no bounds or the bounds cannot be expressed in target's coordinate space (for example if both widgets are in different windows), the returned std::optional is empty.
It is valid for the widget and target to be the same widget.
target | The Gtk::Widget . |
bool Gtk::Widget::compute_expand | ( | Orientation | orientation | ) |
Computes whether a parent widget should give this widget extra space when possible.
Widgets with children should check this, rather than looking at get_hexpand() or get_vexpand().
This function already checks whether the widget is visible, so visibility does not need to be checked separately. Non-visible widgets are not expanded.
The computed expand value uses either the expand setting explicitly set on the widget itself, or, if none has been explicitly set, the widget may expand if some of its children do.
orientation | Expand direction. |
|
protectedvirtual |
std::optional< Gdk::Graphene::Point > Gtk::Widget::compute_point | ( | const Widget & | target, |
const Gdk::Graphene::Point & | point | ||
) | const |
Translates the given point in the widget's coordinates to coordinates relative to target’s coordinate system.
In order to perform this operation, both widgets must share a common ancestor.
target | The Gtk::Widget to transform into. |
point | A point in the widget's coordinate system. |
Tests if a given point is contained in the widget.
The coordinates for (x, y) must be in widget coordinates, so (0, 0) is assumed to be the top left of widget's content area.
x | X coordinate to test, relative to widget's origin. |
y | Y coordinate to test, relative to widget's origin. |
Glib::RefPtr< Pango::Context > Gtk::Widget::create_pango_context | ( | ) |
Creates a new Pango::Context
that is configured for the widget.
The Pango::Context
will have the appropriate font map, font options, font description, and base direction set.
See also get_pango_context().
Pango::Context
. Glib::RefPtr< Pango::Layout > Gtk::Widget::create_pango_layout | ( | const Glib::ustring & | text | ) |
Creates a new Pango::Layout
that is configured for the widget.
The Pango::Layout
will have the appropriate font map, font description, and base direction set.
If you keep a Pango::Layout
created in this way around, you need to re-create it when the widgets Pango::Context
is replaced. This can be tracked by listening to changes of the property_root() property on the widget.
text | Text to set on the layout. |
Pango::Layout
. bool Gtk::Widget::drag_check_threshold | ( | int | start_x, |
int | start_y, | ||
int | current_x, | ||
int | current_y | ||
) |
Checks to see if a drag movement has passed the GTK drag threshold.
start_x | X coordinate of start of drag. |
start_y | Y coordinate of start of drag. |
current_x | Current X coordinate. |
current_y | Current Y coordinate. |
void Gtk::Widget::error_bell | ( | ) |
Notifies the user about an input-related error on the widget.
If the Gtk::Settings::property_gtk_error_bell() setting is true, it calls Gdk::Surface::beep(), otherwise it does nothing.
Note that the effect of Gdk::Surface::beep() can be configured in many ways, depending on the windowing backend and the desktop environment or window manager that is used.
int Gtk::Widget::get_allocated_baseline | ( | ) | const |
Returns the baseline that has currently been allocated to the widget.
This function is intended to be used when implementing handlers for the Gtk::Widget
Class.snapshot() function, and when allocating child widgets in Gtk::Widget
Class.size_allocate().
Deprecated: 4.12: Use get_baseline() instead
int Gtk::Widget::get_allocated_height | ( | ) | const |
Returns the height that has currently been allocated to the widget.
To learn more about widget sizes, see the coordinate system overview.
Deprecated: 4.12: Use get_height() instead
int Gtk::Widget::get_allocated_width | ( | ) | const |
Returns the width that has currently been allocated to the widget.
To learn more about widget sizes, see the coordinate system overview.
Deprecated: 4.12: Use get_width() instead
Allocation Gtk::Widget::get_allocation | ( | ) | const |
Retrieves the widget’s location.
Note, when implementing a layout container: a widget’s allocation will be its “adjusted” allocation, that is, the widget’s parent container typically calls size_allocate() with an allocation, and that allocation is then adjusted (to handle margin and alignment for example) before assignment to the widget. get_allocation() returns the adjusted allocation that was actually assigned to the widget. The adjusted allocation is guaranteed to be completely contained within the size_allocate() allocation, however.
So a layout container is guaranteed that its children stay inside the assigned bounds, but not that they have exactly the bounds the container assigned.
Widget * Gtk::Widget::get_ancestor | ( | GType | widget_type | ) |
Gets the first ancestor of the widget with type widget_type.
For example, gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)
gets the first Gtk::Box
that’s an ancestor of widget. No reference will be added to the returned widget; it should not be unreferenced.
Note that unlike is_ancestor(), this function considers widget to be an ancestor of itself.
widget_type | Ancestor type. |
Gets the first ancestor of the widget with type widget_type.
For example, gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)
gets the first Gtk::Box
that’s an ancestor of widget. No reference will be added to the returned widget; it should not be unreferenced.
Note that unlike is_ancestor(), this function considers widget to be an ancestor of itself.
widget_type | Ancestor type. |
int Gtk::Widget::get_baseline | ( | ) | const |
Returns the baseline that has currently been allocated to the widget.
This function is intended to be used when implementing handlers for the GtkWidgetClass.snapshot()
function, and when allocating child widgets in GtkWidgetClass.size_allocate()
.
bool Gtk::Widget::get_can_focus | ( | ) | const |
Determines whether the input focus can enter the widget or any of its children.
See set_can_focus().
bool Gtk::Widget::get_can_target | ( | ) | const |
Queries whether the widget can be the target of pointer events.
bool Gtk::Widget::get_child_visible | ( | ) | const |
Gets the value set with set_child_visible().
If you feel a need to use this function, your code probably needs reorganization.
This function is only useful for widget implementations and should never be called by an application.
std::vector< Widget * > Gtk::Widget::get_children | ( | ) |
Gets a vector of the widgetʼs current children, from first child to last.
Unlike observe_children(), this does not incur extra bookkeeping to track children, update or emit signal when they change, etc. – so it is faster.
std::vector< const Widget * > Gtk::Widget::get_children | ( | ) | const |
Gets a vector of the widgetʼs current children, from first child to last.
Unlike observe_children(), this does not incur extra bookkeeping to track children, update or emit signal when they change, etc. – so it is faster.
Glib::RefPtr< Gdk::Clipboard > Gtk::Widget::get_clipboard | ( | ) |
Gets the clipboard object for the widget.
This is a utility function to get the clipboard object for the display that widget is using.
Note that this function always works, even when widget is not realized yet.
Glib::RefPtr< const Gdk::Clipboard > Gtk::Widget::get_clipboard | ( | ) | const |
Gets the clipboard object for the widget.
This is a utility function to get the clipboard object for the display that widget is using.
Note that this function always works, even when widget is not realized yet.
Gdk::RGBA Gtk::Widget::get_color | ( | ) | const |
Gets the current foreground color for the widget's CSS style.
This function should only be used in snapshot implementations that need to do custom drawing with the foreground color.
std::vector< Glib::ustring > Gtk::Widget::get_css_classes | ( | ) | const |
Returns the list of style classes applied to the widget.
nullptr
-terminated list of css classes currently applied to widget. Glib::ustring Gtk::Widget::get_css_name | ( | ) | const |
Returns the CSS name of the widget.
Glib::RefPtr< Gdk::Cursor > Gtk::Widget::get_cursor | ( | ) |
Gets the cursor set on the widget.
See set_cursor() for details.
Glib::RefPtr< const Gdk::Cursor > Gtk::Widget::get_cursor | ( | ) | const |
Gets the cursor set on the widget.
See set_cursor() for details.
|
static |
Obtains the default reading direction.
TextDirection Gtk::Widget::get_direction | ( | ) | const |
Gets the reading direction for the widget.
See set_direction().
Glib::RefPtr< Gdk::Display > Gtk::Widget::get_display | ( | ) |
Get the display for the window that the widget belongs to.
This function can only be called after the widget has been added to a widget hierarchy with a Gtk::Root
at the top.
In general, you should only create display-specific resources when a widget has been realized, and you should free those resources when the widget is unrealized.
Glib::RefPtr< const Gdk::Display > Gtk::Widget::get_display | ( | ) | const |
Get the display for the window that the widget belongs to.
This function can only be called after the widget has been added to a widget hierarchy with a Gtk::Root
at the top.
In general, you should only create display-specific resources when a widget has been realized, and you should free those resources when the widget is unrealized.
Widget * Gtk::Widget::get_first_child | ( | ) |
Returns the widget’s first child.
This function is primarily meant for widget implementations.
Returns the widget’s first child.
This function is primarily meant for widget implementations.
|
protected |
Returns the focus child of the widget.
Returns the focus child of the widget.
bool Gtk::Widget::get_focus_on_click | ( | ) | const |
Returns whether the widget should grab focus when it is clicked with the mouse.
See set_focus_on_click().
bool Gtk::Widget::get_focusable | ( | ) | const |
Determines whether the widget can own the input focus.
See set_focusable().
Glib::RefPtr< Pango::FontMap > Gtk::Widget::get_font_map | ( | ) |
Glib::RefPtr< const Pango::FontMap > Gtk::Widget::get_font_map | ( | ) | const |
Cairo::FontOptions Gtk::Widget::get_font_options | ( | ) | const |
Returns the cairo_font_options_t
of the widget.
Seee set_font_options().
Deprecated: 4.16
cairo_font_options_t
of widget. Glib::RefPtr< Gdk::FrameClock > Gtk::Widget::get_frame_clock | ( | ) |
Obtains the frame clock for a widget.
The frame clock is a global “ticker” that can be used to drive animations and repaints. The most common reason to get the frame clock is to call Gdk::FrameClock::get_frame_time(), in order to get a time to use for animating. For example you might record the start of the animation with an initial value from Gdk::FrameClock::get_frame_time(), and then update the animation by calling Gdk::FrameClock::get_frame_time() again during each repaint.
Gdk::FrameClock::request_phase() will result in a new frame on the clock, but won’t necessarily repaint any widgets. To repaint a widget, you have to use queue_draw() which invalidates the widget (thus scheduling it to receive a draw on the next frame). queue_draw() will also end up requesting a frame on the appropriate frame clock.
A widget’s frame clock will not change while the widget is mapped. Reparenting a widget (which implies a temporary unmap) can change the widget’s frame clock.
Unrealized widgets do not have a frame clock.
Glib::RefPtr< const Gdk::FrameClock > Gtk::Widget::get_frame_clock | ( | ) | const |
Obtains the frame clock for a widget.
The frame clock is a global “ticker” that can be used to drive animations and repaints. The most common reason to get the frame clock is to call Gdk::FrameClock::get_frame_time(), in order to get a time to use for animating. For example you might record the start of the animation with an initial value from Gdk::FrameClock::get_frame_time(), and then update the animation by calling Gdk::FrameClock::get_frame_time() again during each repaint.
Gdk::FrameClock::request_phase() will result in a new frame on the clock, but won’t necessarily repaint any widgets. To repaint a widget, you have to use queue_draw() which invalidates the widget (thus scheduling it to receive a draw on the next frame). queue_draw() will also end up requesting a frame on the appropriate frame clock.
A widget’s frame clock will not change while the widget is mapped. Reparenting a widget (which implies a temporary unmap) can change the widget’s frame clock.
Unrealized widgets do not have a frame clock.
Align Gtk::Widget::get_halign | ( | ) | const |
Gets the horizontal alignment of the widget.
For backwards compatibility reasons this method will never return one of the baseline alignments, but instead it will convert it to [enum@.nosp@m.Gtk..nosp@m.Align.nosp@m..fil.nosp@m.l] or [enum@.nosp@m.Gtk..nosp@m.Align.nosp@m..cen.nosp@m.ter].
Baselines are not supported for horizontal alignment.
bool Gtk::Widget::get_has_tooltip | ( | ) | const |
Returns the current value of the has-tooltip
property.
has-tooltip
on widget. int Gtk::Widget::get_height | ( | ) | const |
Returns the content height of the widget.
This function returns the height passed to its size-allocate implementation, which is the height you should be using in snapshot_vfunc().
For pointer events, see contains().
To learn more about widget sizes, see the coordinate system overview.
bool Gtk::Widget::get_hexpand | ( | ) | const |
Gets whether the widget would like any available extra horizontal space.
When a user resizes a window, widgets with expand set to true generally receive the extra space. For example, a list or scrollable area or document in your window would often be set to expand.
Widgets with children should use compute_expand() rather than this function, to see whether any of its children, has the expand flag set. If any child of a widget wants to expand, the parent may ask to expand also.
This function only looks at the widget’s own hexpand flag, rather than computing whether the entire widget tree rooted at this widget wants to expand.
bool Gtk::Widget::get_hexpand_set | ( | ) | const |
Gets whether the hexpand
flag has been explicitly set.
If property_hexpand() property is set, then it overrides any computed expand value based on child widgets. If hexpand
is not set, then the expand value depends on whether any children of the widget would like to expand.
There are few reasons to use this function, but it’s here for completeness and consistency.
Widget * Gtk::Widget::get_last_child | ( | ) |
Returns the widget’s last child.
This function is primarily meant for widget implementations.
Returns the widget’s last child.
This function is primarily meant for widget implementations.
Glib::RefPtr< LayoutManager > Gtk::Widget::get_layout_manager | ( | ) |
Retrieves the layout manager of the widget.
See set_layout_manager().
Glib::RefPtr< const LayoutManager > Gtk::Widget::get_layout_manager | ( | ) | const |
Retrieves the layout manager of the widget.
See set_layout_manager().
bool Gtk::Widget::get_mapped | ( | ) | const |
Returns whether the widget is mapped.
int Gtk::Widget::get_margin_bottom | ( | ) | const |
Gets the bottom margin of the widget.
int Gtk::Widget::get_margin_end | ( | ) | const |
Gets the end margin of the widget.
int Gtk::Widget::get_margin_start | ( | ) | const |
Gets the start margin of the widget.
int Gtk::Widget::get_margin_top | ( | ) | const |
Gets the top margin of the widget.
Glib::ustring Gtk::Widget::get_name | ( | ) | const |
Retrieves the name of a widget.
See set_name() for the significance of widget names.
Native * Gtk::Widget::get_native | ( | ) |
Returns the nearest Gtk::Native
ancestor of the widget.
This function will return nullptr
if the widget is not contained inside a widget tree with a native ancestor.
Gtk::Native
widgets will return themselves here.
Gtk::Native
ancestor of widget. Returns the nearest Gtk::Native
ancestor of the widget.
This function will return nullptr
if the widget is not contained inside a widget tree with a native ancestor.
Gtk::Native
widgets will return themselves here.
Gtk::Native
ancestor of widget. Widget * Gtk::Widget::get_next_sibling | ( | ) |
Returns the widget’s next sibling.
This function is primarily meant for widget implementations.
Returns the widget’s next sibling.
This function is primarily meant for widget implementations.
double Gtk::Widget::get_opacity | ( | ) | const |
Fetches the requested opacity for the widget.
See set_opacity().
Overflow Gtk::Widget::get_overflow | ( | ) | const |
Glib::RefPtr< Pango::Context > Gtk::Widget::get_pango_context | ( | ) |
Gets a Pango::Context
that is configured for the widget.
The Pango::Context
will have the appropriate font map, font description, and base direction set.
Unlike the context returned by create_pango_context(), this context is owned by the widget (it can be used until the screen for the widget changes or the widget is removed from its toplevel), and will be updated to match any changes to the widget’s attributes. This can be tracked by listening to changes of the property_root() property on the widget.
Pango::Context
for the widget. Widget * Gtk::Widget::get_parent | ( | ) |
Returns the parent widget of the widget.
Returns the parent widget of the widget.
PreferredSize Gtk::Widget::get_preferred_size | ( | ) | const |
Like the other overload of get_preferred_size() but returns a structure holding the sizes instead of using output parameters.
void Gtk::Widget::get_preferred_size | ( | Requisition & | minimum_size, |
Requisition & | natural_size | ||
) | const |
Retrieves the minimum and natural size of a widget, taking into account the widget’s preference for height-for-width management.
This is used to retrieve a suitable size by container widgets which do not impose any restrictions on the child placement. It can be used to deduce toplevel window and menu sizes as well as child widgets in free-form containers such as Gtk::Fixed
.
Handle with care. Note that the natural height of a height-for-width widget will generally be a smaller size than the minimum height, since the required height for the natural width is generally smaller than the required height for the minimum width.
Use measure() if you want to support baseline alignment.
minimum_size | Location for storing the minimum size. |
natural_size | Location for storing the natural size. |
Widget * Gtk::Widget::get_prev_sibling | ( | ) |
Returns the widget’s previous sibling.
This function is primarily meant for widget implementations.
Returns the widget’s previous sibling.
This function is primarily meant for widget implementations.
Glib::RefPtr< Gdk::Clipboard > Gtk::Widget::get_primary_clipboard | ( | ) |
Gets the primary clipboard of the widget.
This is a utility function to get the primary clipboard object for the display that widget is using.
Note that this function always works, even when widget is not realized yet.
Glib::RefPtr< const Gdk::Clipboard > Gtk::Widget::get_primary_clipboard | ( | ) | const |
Gets the primary clipboard of the widget.
This is a utility function to get the primary clipboard object for the display that widget is using.
Note that this function always works, even when widget is not realized yet.
bool Gtk::Widget::get_realized | ( | ) | const |
Determines whether the widget is realized.
bool Gtk::Widget::get_receives_default | ( | ) | const |
Determines whether the widget is always treated as the default widget within its toplevel when it has the focus, even if another widget is the default.
SizeRequestMode Gtk::Widget::get_request_mode | ( | ) | const |
Gets whether the widget prefers a height-for-width layout or a width-for-height layout.
Single-child widgets generally propagate the preference of their child, more complex widgets need to request something either in context of their children or in context of their allocation capabilities.
Gtk::SizeRequestMode
preferred by widget.
|
protectedvirtual |
Root * Gtk::Widget::get_root | ( | ) |
int Gtk::Widget::get_scale_factor | ( | ) | const |
Retrieves the internal scale factor that maps from window coordinates to the actual device pixels.
On traditional systems this is 1, on high density outputs, it can be a higher value (typically 2).
See Gdk::Surface::get_scale_factor().
Note that modern systems may support fractional scaling, where the scale factor is not an integer. On such systems, this function will return the next higher integer value, but you probably want to use Gdk::Surface::get_scale() to get the fractional scale value.
bool Gtk::Widget::get_sensitive | ( | ) | const |
Returns the widget’s sensitivity.
This function returns the value that has been set using set_sensitive()).
The effective sensitivity of a widget is however determined by both its own and its parent widget’s sensitivity. See is_sensitive().
Glib::RefPtr< Settings > Gtk::Widget::get_settings | ( | ) |
Gets the settings object holding the settings used for the widget.
Note that this function can only be called when the Gtk::Widget
is attached to a toplevel, since the settings object is specific to a particular display. If you want to monitor the widget for changes in its settings, connect to the notify::display
signal.
int Gtk::Widget::get_size | ( | Orientation | orientation | ) | const |
Returns the content width or height of the widget.
Which dimension is returned depends on orientation.
This is equivalent to calling get_width() for [enum@.nosp@m.Gtk..nosp@m.Orien.nosp@m.tati.nosp@m.on.ho.nosp@m.rizo.nosp@m.ntal] or get_height() for [enum@.nosp@m.Gtk..nosp@m.Orien.nosp@m.tati.nosp@m.on.ve.nosp@m.rtic.nosp@m.al], but can be used when writing orientation-independent code, such as when implementing Gtk::Orientable widgets.
To learn more about widget sizes, see the coordinate system overview.
orientation | The orientation to query. |
Requisition Gtk::Widget::get_size_request | ( | ) | const |
Like the other overload of get_size_request() but returns a structure holding the sizes instead of using output parameters.
void Gtk::Widget::get_size_request | ( | int & | width, |
int & | height | ||
) | const |
Gets the size request that was explicitly set for the widget.
A value of -1 stored in width or height indicates that that dimension has not been set explicitly and the natural requisition of the widget will be used instead.
See set_size_request().
To get the size a widget will actually request, call measure() instead of this function.
width | Return location for width. |
height | Return location for height. |
StateFlags Gtk::Widget::get_state_flags | ( | ) | const |
Returns the widget state as a flag set.
It is worth mentioning that the effective [flags.nosp@m.@Gtk.nosp@m..Stat.nosp@m.eFla.nosp@m.gs.in.nosp@m.sens.nosp@m.itive] state will be returned, that is, also based on parent insensitivity, even if widget itself is sensitive.
Also note that if you are looking for a way to obtain the Gtk::StateFlags to pass to a Gtk::StyleContext method, you should look at Gtk::StyleContext::get_state().
Glib::RefPtr< StyleContext > Gtk::Widget::get_style_context | ( | ) |
Returns the style context associated to the widget.
The returned object is guaranteed to be the same for the lifetime of widget.
Deprecated: 4.10: Style contexts will be removed in GTK 5
Glib::RefPtr< const StyleContext > Gtk::Widget::get_style_context | ( | ) | const |
Returns the style context associated to the widget.
The returned object is guaranteed to be the same for the lifetime of widget.
Deprecated: 4.10: Style contexts will be removed in GTK 5
Glib::ustring Gtk::Widget::get_tooltip_markup | ( | ) | const |
Gets the contents of the tooltip for the widget.
If the tooltip has not been set using set_tooltip_markup(), this function returns nullptr
.
Glib::ustring Gtk::Widget::get_tooltip_text | ( | ) | const |
Gets the contents of the tooltip for the widget.
If the widget's tooltip was set using set_tooltip_markup(), this function will return the escaped text.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
Align Gtk::Widget::get_valign | ( | ) | const |
Gets the vertical alignment of the widget.
bool Gtk::Widget::get_vexpand | ( | ) | const |
Gets whether the widget would like any available extra vertical space.
See get_hexpand() for more detail.
bool Gtk::Widget::get_vexpand_set | ( | ) | const |
Gets whether the vexpand
flag has been explicitly set.
See get_hexpand_set() for more detail.
bool Gtk::Widget::get_visible | ( | ) | const |
Determines whether the widget is visible.
If you want to take into account whether the widget’s parent is also marked as visible, use is_visible() instead.
This function does not check if the widget is obscured in any way.
See set_visible().
int Gtk::Widget::get_width | ( | ) | const |
Returns the content width of the widget.
This function returns the width passed to its size-allocate implementation, which is the width you should be using in snapshot_vfunc().
For pointer events, see contains().
To learn more about widget sizes, see the coordinate system overview.
|
inline |
Provides access to the underlying C GObject.
bool Gtk::Widget::grab_focus | ( | ) |
Causes widget to have the keyboard focus for the window that it belongs to.
If widget is not focusable, or its grab_focus_vfunc() implementation cannot transfer the focus to a descendant of widget that is focusable, it will not take focus and false will be returned.
Calling grab_focus() on an already focused widget is allowed, should not have an effect, and return true.
|
protectedvirtual |
bool Gtk::Widget::has_css_class | ( | const Glib::ustring & | css_class | ) | const |
Returns whether a style class is currently applied to the widget.
css_class | Style class, without the leading period. |
bool Gtk::Widget::has_default | ( | ) | const |
Determines whether the widget is the current default widget within its toplevel.
bool Gtk::Widget::has_focus | ( | ) | const |
Determines if the widget has the global input focus.
See is_focus() for the difference between having the global input focus, and only having the focus within a toplevel.
bool Gtk::Widget::has_visible_focus | ( | ) | const |
Determines if the widget should show a visible indication that it has the global input focus.
This is a convenience function that takes into account whether focus indication should currently be shown in the toplevel window of widget. See Gtk::Window::get_focus_visible() for more information about focus indication.
To find out if the widget has the global input focus, use has_focus().
void Gtk::Widget::hide | ( | ) |
Reverses the effects of [method.Gtk.Widget.show].
This is causing the widget to be hidden (invisible to the user).
Deprecated: 4.10: Use set_visible() instead
bool Gtk::Widget::in_destruction | ( | ) | const |
Returns whether the widget is currently being destroyed.
This information can sometimes be used to avoid doing unnecessary work.
void Gtk::Widget::insert_action_group | ( | const Glib::ustring & | name, |
const Glib::RefPtr< Gio::ActionGroup > & | group | ||
) |
Inserts an action group into the widget's actions.
Children of widget that implement Gtk::Actionable can then be associated with actions in group by setting their “action-name” to prefix.`action-name`.
Note that inheritance is defined for individual actions. I.e. even if you insert a group with prefix prefix, actions with the same prefix will still be inherited from the parent, unless the group contains an action with the same name.
If group is nullptr
, a previously inserted group for name is removed from widget.
name | The prefix for actions in group. |
group | An action group. |
Inserts the Widget into the child widget list of parent after previous_sibling.
After calling this function, get_prev_sibling() will return previous_sibling.
If parent is already set as the parent widget of the Widget, this function can also be used to reorder the Widget in the child widget list of parent.
parent | The parent Gtk::Widget to insert the Widget into. |
previous_sibling | The new previous sibling of the Widget. |
Inserts the Widget at the end of the child widget list of parent.
After calling this function, get_next_sibling() will return nullptr
.
If parent is already set as the parent of the Widget, this function can also be used to reorder the Widget in the child widget list of parent.
parent | The parent Gtk::Widget to insert the Widget into. |
Inserts the Widget at the beginning of the child widget list of parent.
After calling this function, get_prev_sibling() will return nullptr
.
If parent is already set as the parent of the Widget, this function can also be used to reorder the Widget in the child widget list of parent.
parent | The parent Gtk::Widget to insert the Widget into. |
Inserts the Widget into the child widget list of parent before next_sibling.
After calling this function, get_next_sibling() will return next_sibling.
If parent is already set as the parent widget of the Widget, this function can also be used to reorder the Widget in the child widget list of parent.
parent | The parent Gtk::Widget to insert the Widget into. |
next_sibling | The new next sibling of the Widget. |
bool Gtk::Widget::is_ancestor | ( | Widget & | ancestor | ) | const |
Determines whether the widget is a descendent of ancestor.
ancestor | Another Gtk::Widget . |
bool Gtk::Widget::is_drawable | ( | ) | const |
Determines whether the widget can be drawn to.
A widget can be drawn if it is mapped and visible.
bool Gtk::Widget::is_focus | ( | ) | const |
Determines if the widget is the focus widget within its toplevel.
This does not mean that the property_has_focus() property is necessarily set; property_has_focus() will only be set if the toplevel widget additionally has the global input focus.
bool Gtk::Widget::is_sensitive | ( | ) | const |
Returns the widget’s effective sensitivity.
This means it is sensitive itself and also its parent widget is sensitive.
bool Gtk::Widget::is_visible | ( | ) | const |
Determines whether the widget and all its parents are marked as visible.
This function does not check if the widget is obscured in any way.
See also get_visible() and set_visible().
bool Gtk::Widget::keynav_failed | ( | DirectionType | direction | ) |
Emits the signal_keynav_failed() signal on the widget.
This function should be called whenever keyboard navigation within a single widget hits a boundary.
The return value of this function should be interpreted in a way similar to the return value of child_focus(). When true is returned, stay in the widget, the failed keyboard navigation is ok and/or there is nowhere we can/should move the focus to. When false is returned, the caller should continue with keyboard navigation outside the widget, e.g. by calling child_focus() on the widget’s toplevel.
The default signal_keynav_failed() handler returns false for [enum@.nosp@m.Gtk..nosp@m.Direc.nosp@m.tion.nosp@m.Type..nosp@m.tab-.nosp@m.forwa.nosp@m.rd] and [enum@.nosp@m.Gtk..nosp@m.Direc.nosp@m.tion.nosp@m.Type..nosp@m.tab-.nosp@m.backw.nosp@m.ard]. For the other values of Gtk::DirectionType it returns true.
Whenever the default handler returns true, it also calls error_bell() to notify the user of the failed keyboard navigation.
A use case for providing an own implementation of keynav-failed
(either by connecting to it or by overriding it) would be a row of Gtk::Entry widgets where the user should be able to navigate the entire row with the cursor keys, as e.g. known from user interfaces that require entering license keys.
direction | Direction of focus movement. |
std::vector< Widget * > Gtk::Widget::list_mnemonic_labels | ( | ) |
Returns the widgets for which this widget is the target of a mnemonic.
Typically, these widgets will be labels. See, for example, Gtk::Label::set_mnemonic_widget().
The widgets in the list are not individually referenced. If you want to iterate through the list and perform actions involving callbacks that might destroy the widgets, you must call g_list_foreach (result, (GFunc)g_object_ref, <tt>nullptr</tt>)
first, and then unref all the widgets afterwards.
std::vector< const Widget * > Gtk::Widget::list_mnemonic_labels | ( | ) | const |
Returns the widgets for which this widget is the target of a mnemonic.
Typically, these widgets will be labels. See, for example, Gtk::Label::set_mnemonic_widget().
The widgets in the list are not individually referenced. If you want to iterate through the list and perform actions involving callbacks that might destroy the widgets, you must call g_list_foreach (result, (GFunc)g_object_ref, <tt>nullptr</tt>)
first, and then unref all the widgets afterwards.
Glib::RefPtr< ConstraintTarget > Gtk::Widget::make_refptr_constrainttarget | ( | ) |
Converts this widget to a reference counted Gtk::ConstraintTarget.
Useful in calls to Gtk::Constraint::create().
Glib::RefPtr< const ConstraintTarget > Gtk::Widget::make_refptr_constrainttarget | ( | ) | const |
Converts this widget to a reference counted Gtk::ConstraintTarget.
void Gtk::Widget::map | ( | ) |
Causes a widget to be mapped if it isn’t already.
This function is only for use in widget implementations.
void Gtk::Widget::measure | ( | Orientation | orientation, |
int | for_size, | ||
int & | minimum, | ||
int & | natural, | ||
int & | minimum_baseline, | ||
int & | natural_baseline | ||
) | const |
Measures widget in the orientation orientation and for the given for_size.
As an example, if orientation is Gtk::Orientation::HORIZONTAL and for_size is 300, this functions will compute the minimum and natural width of widget if it is allocated at a height of 300 pixels.
See GtkWidget’s geometry management section for a more details on implementing GtkWidgetClass.measure()
.
orientation | The orientation to measure. |
for_size | Size for the opposite of orientation, i.e. if orientation is Gtk::Orientation::HORIZONTAL, this is the height the widget should be measured with. The Gtk::Orientation::VERTICAL case is analogous. This way, both height-for-width and width-for-height requests can be implemented. If no size is known, -1 can be passed. |
minimum | Location to store the minimum size. |
natural | Location to store the natural size. |
minimum_baseline | Location to store the baseline position for the minimum size, or -1 to report no baseline. |
natural_baseline | Location to store the baseline position for the natural size, or -1 to report no baseline. |
Measurements Gtk::Widget::measure | ( | Orientation | orientation, |
int | for_size = -1 |
||
) | const |
Like the other overload of measure() but returns a structure holding the sizes/baselines instead of using output parameters.
|
protectedvirtual |
bool Gtk::Widget::mnemonic_activate | ( | bool | group_cycling | ) |
Emits the signal_mnemonic_activate() signal.
group_cycling | True if there are other widgets with the same mnemonic. |
Glib::RefPtr< Gio::ListModel > Gtk::Widget::observe_children | ( | ) |
Returns a list model to track the children of the widget.
Calling this function will enable extra internal bookkeeping to track children and emit signals on the returned listmodel. It may slow down operations a lot.
Applications should try hard to avoid calling this function because of the slowdowns.
Glib::RefPtr< const Gio::ListModel > Gtk::Widget::observe_children | ( | ) | const |
Returns a list model to track the children of the widget.
Calling this function will enable extra internal bookkeeping to track children and emit signals on the returned listmodel. It may slow down operations a lot.
Applications should try hard to avoid calling this function because of the slowdowns.
Glib::RefPtr< Gio::ListModel > Gtk::Widget::observe_controllers | ( | ) |
Returns a list model to track the event controllers of the widget.
Calling this function will enable extra internal bookkeeping to track controllers and emit signals on the returned listmodel. It may slow down operations a lot.
Applications should try hard to avoid calling this function because of the slowdowns.
Glib::RefPtr< const Gio::ListModel > Gtk::Widget::observe_controllers | ( | ) | const |
Returns a list model to track the event controllers of the widget.
Calling this function will enable extra internal bookkeeping to track controllers and emit signals on the returned listmodel. It may slow down operations a lot.
Applications should try hard to avoid calling this function because of the slowdowns.
|
protectedvirtual |
This is a default handler for the signal signal_direction_changed().
This is a default handler for the signal signal_hide().
This is a default handler for the signal signal_map().
|
protectedvirtual |
This is a default handler for the signal signal_mnemonic_activate().
|
protectedvirtual |
This is a default handler for the signal signal_query_tooltip().
This is a default handler for the signal signal_realize().
This is a default handler for the signal signal_show().
|
protectedvirtual |
This is a default handler for the signal signal_state_flags_changed().
This is a default handler for the signal signal_unmap().
This is a default handler for the signal signal_unrealize().
Widget * Gtk::Widget::pick | ( | double | x, |
double | y, | ||
PickFlags | flags = PickFlags::DEFAULT |
||
) |
Finds the descendant of the widget closest to a point.
The point (x, y) must be given in widget coordinates, so (0, 0) is assumed to be the top left of widget's content area.
Usually widgets will return nullptr
if the given coordinate is not contained in widget checked via contains(). Otherwise they will recursively try to find a child that does not return nullptr
. Widgets are however free to customize their picking algorithm.
This function is used on the toplevel to determine the widget below the mouse cursor for purposes of hover highlighting and delivering events.
x | X coordinate to test, relative to widget's origin. |
y | Y coordinate to test, relative to widget's origin. |
flags | Flags to influence what is picked. |
Finds the descendant of the widget closest to a point.
The point (x, y) must be given in widget coordinates, so (0, 0) is assumed to be the top left of widget's content area.
Usually widgets will return nullptr
if the given coordinate is not contained in widget checked via contains(). Otherwise they will recursively try to find a child that does not return nullptr
. Widgets are however free to customize their picking algorithm.
This function is used on the toplevel to determine the widget below the mouse cursor for purposes of hover highlighting and delivering events.
x | X coordinate to test, relative to widget's origin. |
y | Y coordinate to test, relative to widget's origin. |
flags | Flags to influence what is picked. |
Glib::PropertyProxy< bool > Gtk::Widget::property_can_focus | ( | ) |
Whether the widget or any of its descendents can accept the input focus.
This property is meant to be set by widget implementations, typically in their instance init function.
Default value: true
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_can_focus | ( | ) | const |
Whether the widget or any of its descendents can accept the input focus.
This property is meant to be set by widget implementations, typically in their instance init function.
Default value: true
Glib::PropertyProxy< bool > Gtk::Widget::property_can_target | ( | ) |
Whether the widget can receive pointer events.
Default value: true
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_can_target | ( | ) | const |
Whether the widget can receive pointer events.
Default value: true
Glib::PropertyProxy< std::vector< Glib::ustring > > Gtk::Widget::property_css_classes | ( | ) |
A list of css classes applied to this widget.
Glib::PropertyProxy_ReadOnly< std::vector< Glib::ustring > > Gtk::Widget::property_css_classes | ( | ) | const |
A list of css classes applied to this widget.
Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::Widget::property_css_name | ( | ) | const |
The name of this widget in the CSS tree.
This property is meant to be set by widget implementations, typically in their instance init function.
Default value: ""
Glib::PropertyProxy< Glib::RefPtr< Gdk::Cursor > > Gtk::Widget::property_cursor | ( | ) |
The cursor used by widget.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gdk::Cursor > > Gtk::Widget::property_cursor | ( | ) | const |
The cursor used by widget.
Glib::PropertyProxy< bool > Gtk::Widget::property_focus_on_click | ( | ) |
Whether the widget should grab focus when it is clicked with the mouse.
This property is only relevant for widgets that can take focus.
Default value: true
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_focus_on_click | ( | ) | const |
Whether the widget should grab focus when it is clicked with the mouse.
This property is only relevant for widgets that can take focus.
Default value: true
Glib::PropertyProxy< bool > Gtk::Widget::property_focusable | ( | ) |
Whether this widget itself will accept the input focus.
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_focusable | ( | ) | const |
Whether this widget itself will accept the input focus.
Default value: false
Glib::PropertyProxy< Align > Gtk::Widget::property_halign | ( | ) |
How to distribute horizontal space if widget gets extra space.
Default value: Gtk::Align::FILL
Glib::PropertyProxy_ReadOnly< Align > Gtk::Widget::property_halign | ( | ) | const |
How to distribute horizontal space if widget gets extra space.
Default value: Gtk::Align::FILL
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_has_default | ( | ) | const |
Whether the widget is the default widget.
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_has_focus | ( | ) | const |
Whether the widget has the input focus.
Default value: false
Glib::PropertyProxy< bool > Gtk::Widget::property_has_tooltip | ( | ) |
Enables or disables the emission of the signal_query_tooltip() signal on widget.
A true value indicates that widget can have a tooltip, in this case the widget will be queried using signal_query_tooltip() to determine whether it will provide a tooltip or not.
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_has_tooltip | ( | ) | const |
Enables or disables the emission of the signal_query_tooltip() signal on widget.
A true value indicates that widget can have a tooltip, in this case the widget will be queried using signal_query_tooltip() to determine whether it will provide a tooltip or not.
Default value: false
Glib::PropertyProxy< int > Gtk::Widget::property_height_request | ( | ) |
Overrides for height request of the widget.
If this is -1, the natural request will be used.
Default value: -1
Glib::PropertyProxy_ReadOnly< int > Gtk::Widget::property_height_request | ( | ) | const |
Overrides for height request of the widget.
If this is -1, the natural request will be used.
Default value: -1
Glib::PropertyProxy< bool > Gtk::Widget::property_hexpand | ( | ) |
Whether to expand horizontally.
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_hexpand | ( | ) | const |
Whether to expand horizontally.
Default value: false
Glib::PropertyProxy< bool > Gtk::Widget::property_hexpand_set | ( | ) |
Whether to use the hexpand
property.
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_hexpand_set | ( | ) | const |
Whether to use the hexpand
property.
Default value: false
Glib::PropertyProxy< Glib::RefPtr< LayoutManager > > Gtk::Widget::property_layout_manager | ( | ) |
The Gtk::LayoutManager instance to use to compute the preferred size of the widget, and allocate its children.
This property is meant to be set by widget implementations, typically in their instance init function.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< LayoutManager > > Gtk::Widget::property_layout_manager | ( | ) | const |
The Gtk::LayoutManager instance to use to compute the preferred size of the widget, and allocate its children.
This property is meant to be set by widget implementations, typically in their instance init function.
Glib::PropertyProxy< int > Gtk::Widget::property_margin_bottom | ( | ) |
Margin on bottom side of widget.
This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from Gtk::Widget::set_size_request() for example.
Default value: 0
Glib::PropertyProxy_ReadOnly< int > Gtk::Widget::property_margin_bottom | ( | ) | const |
Margin on bottom side of widget.
This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from Gtk::Widget::set_size_request() for example.
Default value: 0
Glib::PropertyProxy< int > Gtk::Widget::property_margin_end | ( | ) |
Margin on end of widget, horizontally.
This property supports left-to-right and right-to-left text directions.
This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from Gtk::Widget::set_size_request() for example.
Default value: 0
Glib::PropertyProxy_ReadOnly< int > Gtk::Widget::property_margin_end | ( | ) | const |
Margin on end of widget, horizontally.
This property supports left-to-right and right-to-left text directions.
This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from Gtk::Widget::set_size_request() for example.
Default value: 0
Glib::PropertyProxy< int > Gtk::Widget::property_margin_start | ( | ) |
Margin on start of widget, horizontally.
This property supports left-to-right and right-to-left text directions.
This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from Gtk::Widget::set_size_request() for example.
Default value: 0
Glib::PropertyProxy_ReadOnly< int > Gtk::Widget::property_margin_start | ( | ) | const |
Margin on start of widget, horizontally.
This property supports left-to-right and right-to-left text directions.
This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from Gtk::Widget::set_size_request() for example.
Default value: 0
Glib::PropertyProxy< int > Gtk::Widget::property_margin_top | ( | ) |
Margin on top side of widget.
This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from Gtk::Widget::set_size_request() for example.
Default value: 0
Glib::PropertyProxy_ReadOnly< int > Gtk::Widget::property_margin_top | ( | ) | const |
Margin on top side of widget.
This property adds margin outside of the widget's normal size request, the margin will be added in addition to the size from Gtk::Widget::set_size_request() for example.
Default value: 0
Glib::PropertyProxy< Glib::ustring > Gtk::Widget::property_name | ( | ) |
The name of the widget.
Default value: ""
Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::Widget::property_name | ( | ) | const |
The name of the widget.
Default value: ""
Glib::PropertyProxy< double > Gtk::Widget::property_opacity | ( | ) |
The requested opacity of the widget.
Default value: 1
Glib::PropertyProxy_ReadOnly< double > Gtk::Widget::property_opacity | ( | ) | const |
The requested opacity of the widget.
Default value: 1
Glib::PropertyProxy< Overflow > Gtk::Widget::property_overflow | ( | ) |
How content outside the widget's content area is treated.
This property is meant to be set by widget implementations, typically in their instance init function.
Default value: Gtk::Overflow::VISIBLE
Glib::PropertyProxy_ReadOnly< Overflow > Gtk::Widget::property_overflow | ( | ) | const |
How content outside the widget's content area is treated.
This property is meant to be set by widget implementations, typically in their instance init function.
Default value: Gtk::Overflow::VISIBLE
Glib::PropertyProxy_ReadOnly< Widget * > Gtk::Widget::property_parent | ( | ) | const |
The parent widget of this widget.
Glib::PropertyProxy< bool > Gtk::Widget::property_receives_default | ( | ) |
Whether the widget will receive the default action when it is focused.
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_receives_default | ( | ) | const |
Whether the widget will receive the default action when it is focused.
Default value: false
Glib::PropertyProxy_ReadOnly< Root * > Gtk::Widget::property_root | ( | ) | const |
The Gtk::Root
widget of the widget tree containing this widget.
This will be nullptr
if the widget is not contained in a root widget.
Glib::PropertyProxy_ReadOnly< int > Gtk::Widget::property_scale_factor | ( | ) | const |
The scale factor of the widget.
Default value: 1
Glib::PropertyProxy< bool > Gtk::Widget::property_sensitive | ( | ) |
Whether the widget responds to input.
Default value: true
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_sensitive | ( | ) | const |
Whether the widget responds to input.
Default value: true
Glib::PropertyProxy< Glib::ustring > Gtk::Widget::property_tooltip_markup | ( | ) |
Sets the text of tooltip to be the given string, which is marked up with Pango markup.
Also see Gtk::Tooltip::set_markup().
This is a convenience property which will take care of getting the tooltip shown if the given string is not nullptr
: property_has_tooltip() will automatically be set to true and there will be taken care of signal_query_tooltip() in the default signal handler.
Note that if both property_tooltip_text() and property_tooltip_markup() are set, the last one wins.
Default value: ""
Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::Widget::property_tooltip_markup | ( | ) | const |
Sets the text of tooltip to be the given string, which is marked up with Pango markup.
Also see Gtk::Tooltip::set_markup().
This is a convenience property which will take care of getting the tooltip shown if the given string is not nullptr
: property_has_tooltip() will automatically be set to true and there will be taken care of signal_query_tooltip() in the default signal handler.
Note that if both property_tooltip_text() and property_tooltip_markup() are set, the last one wins.
Default value: ""
Glib::PropertyProxy< Glib::ustring > Gtk::Widget::property_tooltip_text | ( | ) |
Sets the text of tooltip to be the given string.
Also see Gtk::Tooltip::set_text().
This is a convenience property which will take care of getting the tooltip shown if the given string is not nullptr
: property_has_tooltip() will automatically be set to true and there will be taken care of signal_query_tooltip() in the default signal handler.
Note that if both property_tooltip_text() and property_tooltip_markup() are set, the last one wins.
Default value: ""
Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::Widget::property_tooltip_text | ( | ) | const |
Sets the text of tooltip to be the given string.
Also see Gtk::Tooltip::set_text().
This is a convenience property which will take care of getting the tooltip shown if the given string is not nullptr
: property_has_tooltip() will automatically be set to true and there will be taken care of signal_query_tooltip() in the default signal handler.
Note that if both property_tooltip_text() and property_tooltip_markup() are set, the last one wins.
Default value: ""
Glib::PropertyProxy< Align > Gtk::Widget::property_valign | ( | ) |
How to distribute vertical space if widget gets extra space.
Default value: Gtk::Align::FILL
Glib::PropertyProxy_ReadOnly< Align > Gtk::Widget::property_valign | ( | ) | const |
How to distribute vertical space if widget gets extra space.
Default value: Gtk::Align::FILL
Glib::PropertyProxy< bool > Gtk::Widget::property_vexpand | ( | ) |
Whether to expand vertically.
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_vexpand | ( | ) | const |
Whether to expand vertically.
Default value: false
Glib::PropertyProxy< bool > Gtk::Widget::property_vexpand_set | ( | ) |
Whether to use the vexpand
property.
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_vexpand_set | ( | ) | const |
Whether to use the vexpand
property.
Default value: false
Glib::PropertyProxy< bool > Gtk::Widget::property_visible | ( | ) |
Whether the widget is visible.
Default value: true
Glib::PropertyProxy_ReadOnly< bool > Gtk::Widget::property_visible | ( | ) | const |
Whether the widget is visible.
Default value: true
Glib::PropertyProxy< int > Gtk::Widget::property_width_request | ( | ) |
Overrides for width request of the widget.
If this is -1, the natural request will be used.
Default value: -1
Glib::PropertyProxy_ReadOnly< int > Gtk::Widget::property_width_request | ( | ) | const |
Overrides for width request of the widget.
If this is -1, the natural request will be used.
Default value: -1
void Gtk::Widget::queue_allocate | ( | ) |
Flags the widget for a rerun of the size_allocate_vfunc() function.
Use this function instead of queue_resize() when the widget's size request didn't change but it wants to reposition its contents.
An example user of this function is set_halign().
This function is only for use in widget implementations.
void Gtk::Widget::queue_draw | ( | ) |
Schedules this widget to be redrawn.
The redraw will happen in the paint phase of the current or the next frame.
This means widget's snapshot_vfunc() implementation will be called.
void Gtk::Widget::queue_resize | ( | ) |
Flags a widget to have its size renegotiated.
This should be called when a widget for some reason has a new size request. For example, when you change the text in a Gtk::Label, the label queues a resize to ensure there’s enough space for the new text.
Note that you cannot call queue_resize() on a widget from inside its implementation of the size_allocate_vfunc() virtual method. Calls to queue_resize() from inside size_allocate_vfunc() will be silently ignored.
This function is only for use in widget implementations.
|
protected |
Creates the GDK resources associated with a widget.
Normally realization happens implicitly; if you show a widget and all its parent containers, then the widget will be realized and mapped automatically.
Realizing a widget requires all the widget’s parent widgets to be realized; calling this function realizes the widget’s parents in addition to widget itself. If a widget is not yet inside a toplevel window when you realize it, bad things will happen.
This function is primarily used in widget implementations, and isn’t very useful otherwise. Many times when you think you might need it, a better approach is to connect to a signal that will be called after the widget is realized automatically, such as signal_realize().
|
protected |
void Gtk::Widget::remove_action_group | ( | const Glib::ustring & | name | ) |
Removes a group from the widget.
name | The prefix for actions. |
void Gtk::Widget::remove_controller | ( | const Glib::RefPtr< EventController > & | controller | ) |
Removes an event controller from the widget.
The removed event controller will not receive any more events, and should not be used again.
Widgets will remove all event controllers automatically when they are destroyed, there is normally no need to call this function.
controller | An event controller. |
void Gtk::Widget::remove_css_class | ( | const Glib::ustring & | css_class | ) |
Removes a style from the widget.
After this, the style of widget will stop matching for css_class.
css_class | Style class to remove from widget, without the leading period. |
Removes a widget from the list of mnemonic labels for this widget.
The widget must have previously been added to the list with add_mnemonic_label().
label | A widget that is a mnemonic label for widget. |
void Gtk::Widget::remove_tick_callback | ( | guint | id | ) |
Removes a tick callback previously registered with add_tick_callback().
id | An ID returned by add_tick_callback(). |
Sets whether the input focus can enter the widget or any of its children.
Applications should set can_focus to false to mark a widget as for pointer/touch use only.
Note that having can_focus be true is only one of the necessary conditions for being focusable. A widget must also be sensitive and focusable and not have an ancestor that is marked as not can-focus in order to receive input focus.
See grab_focus() for actually setting the input focus on a widget.
can_focus | Whether the input focus can enter the widget or any of its children. |
Sets whether the widget can be the target of pointer events.
can_target | Whether this widget should be able to receive pointer events. |
Sets whether the widget should be mapped along with its parent.
The child visibility can be set for widget before it is added to a container with set_parent(), to avoid mapping children unnecessary before immediately unmapping them. However it will be reset to its default state of true when the widget is removed from a container.
Note that changing the child visibility of a widget does not queue a resize on the widget. Most of the time, the size of a widget is computed from all visible children, whether or not they are mapped. If this is not the case, the container can queue a resize itself.
This function is only useful for widget implementations and should never be called by an application.
visible | Whether widget should be mapped along with its parent. |
void Gtk::Widget::set_css_classes | ( | const std::vector< Glib::ustring > & | classes | ) |
Replaces the current style classes of the widget with classes.
classes | nullptr -terminated list of style classes. |
void Gtk::Widget::set_cursor | ( | const Glib::RefPtr< Gdk::Cursor > & | cursor | ) |
Sets the cursor to be shown when the pointer hovers over the widget.
If the cursor is nullptr
, widget will use the cursor inherited from its parent.
cursor | The new cursor. |
void Gtk::Widget::set_cursor | ( | const Glib::ustring & | name = {} | ) |
Sets a named cursor to be shown when pointer devices point towards the widget.
This is a utility function that creates a cursor and then sets it on the widget.
If the name is an empty string, the widget will use the cursor specified via CSS or the parent widget. If neither specifies a cursor, the default cursor will be shown. This is the default behavior.
name | The name of the cursor, or an empty string to use the default cursor. |
|
static |
Sets the default reading direction for widgets.
See set_direction().
dir | The new default direction, either [enum@.nosp@m.Gtk..nosp@m.TextD.nosp@m.irec.nosp@m.tion..nosp@m.ltr] or [enum@.nosp@m.Gtk..nosp@m.TextD.nosp@m.irec.nosp@m.tion..nosp@m.rtl]. |
void Gtk::Widget::set_direction | ( | TextDirection | dir | ) |
Sets the reading direction on the widget.
This direction controls the primary direction for widgets containing text, and also the direction in which the children of a container are packed. The ability to set the direction is present in order so that correct localization into languages with right-to-left reading directions can be done.
Generally, applications will let the default reading direction prevail, except for widgets where the children are arranged in an order that is explicitly visual rather than logical (such as buttons for text justification).
If the direction is set to [enum@.nosp@m.Gtk..nosp@m.TextD.nosp@m.irec.nosp@m.tion..nosp@m.none], then the value set by set_default_direction() will be used.
dir | The new direction. |
Sets whether the widget would like any available extra space in both directions.
expand | Whether to expand in horizontal and vertical direction. |
Set the focus child of the widget.
This function is only suitable for widget implementations. If you want a certain widget to get the input focus, call grab_focus() on it.
child | A direct child widget of widget or nullptr to unset the focus child. |
Sets the focused child of widget.
child | The child widget. |
Sets whether the widget should grab focus when it is clicked with the mouse.
Making mouse clicks not grab focus is useful in places like toolbars where you don’t want the keyboard focus removed from the main area of the application.
focus_on_click | Whether the widget should grab focus when clicked with the mouse. |
Sets whether the widget can own the input focus.
Widget implementations should set focusable to true in their init() function if they want to receive keyboard input.
Note that having focusable be true is only one of the necessary conditions for being focusable. A widget must also be sensitive and can-focus and not have an ancestor that is marked as not can-focus in order to receive input focus.
See grab_focus() for actually setting the input focus on a widget.
focusable | Whether or not widget can own the input focus. |
void Gtk::Widget::set_font_map | ( | const Glib::RefPtr< Pango::FontMap > & | font_map | ) |
Sets the font map to use for text rendering in the widget.
The font map is the object that is used to look up fonts. Setting a custom font map can be useful in special situations, e.g. when you need to add application-specific fonts to the set of available fonts.
When not set, the widget will inherit the font map from its parent.
font_map | A Pango::FontMap . |
Sets the cairo_font_options_t
used for text rendering in the widget.
When not set, the default font options for the Gdk::Display
will be used.
Deprecated: 4.16
options | A cairo_font_options_t struct to unset any previously set default font options. |
Sets the horizontal alignment of the widget.
align | The horizontal alignment. |
Sets the has-tooltip
property on the widget.
has_tooltip | Whether or not widget has a tooltip. |
Sets whether the widget would like any available extra horizontal space.
When a user resizes a window, widgets with expand set to true generally receive the extra space. For example, a list or scrollable area or document in your window would often be set to expand.
Call this function to set the expand flag if you would like your widget to become larger horizontally when the window has extra room.
By default, widgets automatically expand if any of their children want to expand. (To see if a widget will automatically expand given its current children and state, call compute_expand(). A widget can decide how the expandability of children affects its own expansion by overriding the compute_expand
virtual method on Gtk::Widget
.).
Setting hexpand explicitly with this function will override the automatic expand behavior.
This function forces the widget to expand or not to expand, regardless of children. The override occurs because set_hexpand() sets the hexpand-set property (see set_hexpand_set()) which causes the widget’s hexpand value to be used, rather than looking at children and widget state.
expand | Whether to expand. |
Sets whether the hexpand flag will be used.
The property_hexpand_set() property will be set automatically when you call set_hexpand() to set hexpand, so the most likely reason to use this function would be to unset an explicit expand flag.
If hexpand is set, then it overrides any computed expand value based on child widgets. If hexpand is not set, then the expand value depends on whether any children of the widget would like to expand.
There are few reasons to use this function, but it’s here for completeness and consistency.
set | Value for hexpand-set property. |
void Gtk::Widget::set_layout_manager | ( | const Glib::RefPtr< LayoutManager > & | layout_manager | ) |
Sets the layout manager to use for measuring and allocating children of the widget.
layout_manager | A layout manager. |
void Gtk::Widget::set_margin | ( | int | margin | ) |
Set all 4 margins to the same value.
margin | The start, end, top, and bottom margin. |
void Gtk::Widget::set_margin_bottom | ( | int | margin | ) |
Sets the bottom margin of the widget.
margin | The bottom margin. |
void Gtk::Widget::set_margin_end | ( | int | margin | ) |
Sets the end margin of the widget.
margin | The end margin. |
void Gtk::Widget::set_margin_start | ( | int | margin | ) |
Sets the start margin of the widget.
margin | The start margin. |
void Gtk::Widget::set_margin_top | ( | int | margin | ) |
Sets the top margin of the widget.
margin | The top margin. |
void Gtk::Widget::set_name | ( | const Glib::ustring & | name | ) |
Sets a widgets name.
Setting a name allows you to refer to the widget from a CSS file. You can apply a style to widgets with a particular name in the CSS file. See the documentation for the CSS syntax (on the same page as the docs for Gtk::StyleContext.
Note that the CSS syntax has certain special characters to delimit and represent elements in a selector (period, #, >, *...), so using these will make your widget impossible to match by name. Any combination of alphanumeric symbols, dashes and underscores will suffice.
name | Name for the widget. |
Requests the widget to be rendered partially transparent.
An opacity of 0 is fully transparent and an opacity of 1 is fully opaque.
Opacity works on both toplevel widgets and child widgets, although there are some limitations: For toplevel widgets, applying opacity depends on the capabilities of the windowing system. On X11, this has any effect only on X displays with a compositing manager, see Gdk::Display::is_composited(). On Windows and Wayland it will always work, although setting a window’s opacity after the window has been shown may cause some flicker.
Note that the opacity is inherited through inclusion — if you set a toplevel to be partially translucent, all of its content will appear translucent, since it is ultimatively rendered on that toplevel. The opacity value itself is not inherited by child widgets (since that would make widgets deeper in the hierarchy progressively more translucent). As a consequence, Gtk::Popover instances and other Gtk::Native widgets with their own surface will use their own opacity value, and thus by default appear non-translucent, even if they are attached to a toplevel that is translucent.
opacity | Desired opacity, between 0 and 1. |
Sets how the widget treats content that is drawn outside the it's content area.
See the definition of Gtk::Overflow for details.
This setting is provided for widget implementations and should not be used by application code.
The default value is [enum@.nosp@m.Gtk..nosp@m.Overf.nosp@m.low..nosp@m.visib.nosp@m.le].
overflow | Desired overflow value. |
Sets the parent widget of the widget.
This takes care of details such as updating the state and style of the child to reflect its new location and resizing the parent. The opposite function is unparent().
This function is useful only when implementing subclasses of Gtk::Widget
.
parent | Parent widget. |
Sets whether the widget will be treated as the default widget within its toplevel when it has the focus, even if another widget is the default.
receives_default | Whether or not widget can be a default widget. |
Sets the sensitivity of the widget.
A widget is sensitive if the user can interact with it. Insensitive widgets are “grayed out” and the user can’t interact with them. Insensitive widgets are known as “inactive”, “disabled”, or “ghosted” in some other toolkits.
sensitive | True to make the widget sensitive. |
void Gtk::Widget::set_size_request | ( | int | width = -1 , |
int | height = -1 |
||
) |
Sets the minimum size of the widget.
That is, the widget’s size request will be at least width by height. You can use this function to force a widget to be larger than it normally would be.
In most cases, Gtk::Window::set_default_size() is a better choice for toplevel windows than this function; setting the default size will still allow users to shrink the window. Setting the size request will force them to leave the window at least as large as the size request.
Note the inherent danger of setting any fixed size - themes, translations into other languages, different fonts, and user action can all change the appropriate size for a given widget. So, it is basically impossible to hardcode a size that will always work.
The size request of a widget is the smallest size a widget can accept while still functioning well and drawing itself correctly. However in some strange cases a widget may be allocated less than its requested size, and in many cases a widget may be allocated more space than it requested.
If the size request in a given direction is -1 (unset), then the “natural” size request of the widget will be used instead.
The size request set here does not include any margin from the properties property_margin_start(), property_margin_end(), property_margin_top(), and property_margin_bottom(), but it does include pretty much all other padding or border properties set by any subclass of Gtk::Widget
.
width | Width widget should request, or -1 to unset. |
height | Height widget should request, or -1 to unset. |
void Gtk::Widget::set_state_flags | ( | StateFlags | flags, |
bool | clear = true |
||
) |
Turns on flag values in the current widget state.
Typical widget states are insensitive, prelighted, etc.
This function accepts the values [flags.nosp@m.@Gtk.nosp@m..Stat.nosp@m.eFla.nosp@m.gs.di.nosp@m.r-lt.nosp@m.r] and [flags.nosp@m.@Gtk.nosp@m..Stat.nosp@m.eFla.nosp@m.gs.di.nosp@m.r-rt.nosp@m.l] but ignores them. If you want to set the widget's direction, use set_direction().
This function is for use in widget implementations.
flags | State flags to turn on. |
clear | Whether to clear state before turning on flags. |
void Gtk::Widget::set_tooltip_markup | ( | const Glib::ustring & | markup | ) |
Sets the contents of the tooltip for widget.
markup must contain Pango markup.
This function will take care of setting the property_has_tooltip() as a side effect, and of the default handler for the signal_query_tooltip() signal.
See also Gtk::Tooltip::set_markup().
markup | The contents of the tooltip for widget. |
void Gtk::Widget::set_tooltip_text | ( | const Glib::ustring & | text | ) |
Sets the contents of the tooltip for the widget.
If text contains any markup, it will be escaped.
This function will take care of setting property_has_tooltip() as a side effect, and of the default handler for the signal_query_tooltip() signal.
See also Gtk::Tooltip::set_text().
text | The contents of the tooltip for widget. |
Sets the vertical alignment of the widget.
align | The vertical alignment. |
Sets whether the widget would like any available extra vertical space.
See set_hexpand() for more detail.
expand | Whether to expand. |
Sets whether the vexpand flag will be used.
See set_hexpand_set() for more detail.
set | Value for vexpand-set property. |
Sets the visibility state of widget.
Note that setting this to true doesn’t mean the widget is actually viewable, see get_visible().
visible | Whether the widget should be shown or not. |
bool Gtk::Widget::should_layout | ( | ) | const |
Returns whether the widget should contribute to the measuring and allocation of its parent.
This is false for invisible children, but also for children that have their own surface, such as Gtk::Popover instances.
void Gtk::Widget::show | ( | ) |
Flags a widget to be displayed.
Any widget that isn’t shown will not appear on the screen.
Remember that you have to show the containers containing a widget, in addition to the widget itself, before it will appear onscreen.
When a toplevel widget is shown, it is immediately realized and mapped; other shown widgets are realized and mapped when their toplevel widget is realized and mapped.
Deprecated: 4.10: Use set_visible() instead
Glib::SignalProxy< void()> Gtk::Widget::signal_destroy | ( | ) |
Emitted during the dispose phase.
You need to connect to this signal only if you are implementing a widget, which
The children of the object need to be unparented both from the handler of this signal and from the destructor. Reason: when your class is used as a managed object, then the C++ destructor is called too late, but when your class is managed via the standard C++ manner, then this signal is not emitted at all.
When your class inherits from a container widget, such as Gtk::Box, you do not need to handle this signal. When your widget does not have child widgets, then you also do not need to handle this signal.
This signal is emitted by Gtk::Widget during the dispose phase of object destruction. See the Reference count section in the GObject concepts documentation for the specification of the dispose and the finalize phases of object destruction. After dispose, the object is not supposed to hold any reference to other member objects.
Dispose may be called multiple times, so your implementation of this signal must tolerate that.
void on_my_destroy()
Flags: Run Cleanup, No Recurse, No Hooks
Signals that all holders of a reference to the widget should release the reference that they hold.
May result in finalization of the widget if all references are released.
This signal is not suitable for saving widget state.
Glib::SignalProxy< void(TextDirection)> Gtk::Widget::signal_direction_changed | ( | ) |
void on_my_direction_changed(TextDirection direction)
Flags: Run First
Emitted when the text direction of a widget changes.
direction | The previous text direction. |
Glib::SignalProxy< void()> Gtk::Widget::signal_hide | ( | ) |
void on_my_hide()
Flags: Run First
Emitted when widget is hidden.
Glib::SignalProxy< void()> Gtk::Widget::signal_map | ( | ) |
Emitted on mapping of a widget to the screen.
void on_my_map()
Flags: Run First
Emitted when widget is going to be mapped.
A widget is mapped when the widget is visible (which is controlled with property_visible()) and all its parents up to the toplevel widget are also visible.
The map
signal can be used to determine whether a widget will be drawn, for instance it can resume an animation that was stopped during the emission of signal_unmap().
Glib::SignalProxy< bool(bool)> Gtk::Widget::signal_mnemonic_activate | ( | ) |
bool on_my_mnemonic_activate(bool group_cycling)
Flags: Run Last
Emitted when a widget is activated via a mnemonic.
The default handler for this signal activates widget if group_cycling is false, or just makes widget grab focus if group_cycling is true.
group_cycling | True if there are other widgets with the same mnemonic. |
Glib::SignalProxy< bool(int, int, bool, const Glib::RefPtr< Tooltip > &)> Gtk::Widget::signal_query_tooltip | ( | ) |
bool on_my_query_tooltip(int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Tooltip>& tooltip)
Flags: Run Last
Emitted when the widget’s tooltip is about to be shown.
This happens when the property_has_tooltip() property is true and the hover timeout has expired with the cursor hovering above widget; or emitted when widget got focus in keyboard mode.
Using the given coordinates, the signal handler should determine whether a tooltip should be shown for widget. If this is the case true should be returned, false otherwise. Note that if keyboard_tooltip is true, the values of x and y are undefined and should not be used.
The signal handler is free to manipulate tooltip with the therefore destined function calls.
x | The x coordinate of the cursor position in widget coordinates. |
y | The y coordinate of the cursor position in widget coordinates. |
keyboard_tooltip | True if the tooltip was triggered using the keyboard. |
tooltip | A Gtk::Tooltip . |
Glib::SignalProxy< void()> Gtk::Widget::signal_realize | ( | ) |
Emitted on realization of a widget.
void on_my_realize()
Flags: Run First
Emitted when widget is associated with a Gdk::Surface
.
This means that Gtk::Widget::realize() has been called or the widget has been mapped (that is, it is going to be drawn).
Glib::SignalProxy< void()> Gtk::Widget::signal_show | ( | ) |
void on_my_show()
Flags: Run First
Emitted when widget is shown.
Glib::SignalProxy< void(Gtk::StateFlags)> Gtk::Widget::signal_state_flags_changed | ( | ) |
void on_my_state_flags_changed(Gtk::StateFlags previous_state_flags)
Flags: Run First
Emitted when the widget state changes.
See Gtk::Widget::get_state_flags().
previous_state_flags | The previous state flags. |
Glib::SignalProxy< void()> Gtk::Widget::signal_unmap | ( | ) |
void on_my_unmap()
Flags: Run First
Emitted when widget is going to be unmapped.
A widget is unmapped when either it or any of its parents up to the toplevel widget have been set as hidden.
As unmap
indicates that a widget will not be shown any longer, it can be used to, for example, stop an animation on the widget.
Glib::SignalProxy< void()> Gtk::Widget::signal_unrealize | ( | ) |
void on_my_unrealize()
Flags: Run Last
Emitted when the Gdk::Surface
associated with widget is destroyed.
This means that Gtk::Widget::unrealize() has been called or the widget has been unmapped (that is, it is going to be hidden).
void Gtk::Widget::size_allocate | ( | const Allocation & | allocation, |
int | baseline | ||
) |
Allocates widget with a transformation that translates the origin to the position in allocation.
This is a simple form of allocate().
allocation | Position and size to be allocated to widget. |
baseline | The baseline of the child, or -1. |
|
protectedvirtual |
void Gtk::Widget::snapshot_child | ( | Widget & | child, |
const Glib::RefPtr< Gtk::Snapshot > & | snapshot | ||
) |
Snapshots a child of the widget.
When a widget receives a call to the snapshot function, it must send synthetic snapshot_vfunc() calls to all children. This function provides a convenient way of doing this. A widget, when it receives a call to its snapshot_vfunc() function, calls snapshot_child() once for each child, passing in the snapshot the widget received.
This function takes care of translating the origin of snapshot, and deciding whether the child needs to be snapshot.
It does nothing for children that implement Gtk::Native
.
child | A child of widget. |
snapshot | Snapshot as passed to the widget. In particular, no calls to Gtk::Snapshot::translate() or other transform calls should have been made. |
|
protectedvirtual |
bool Gtk::Widget::translate_coordinates | ( | Widget & | dest_widget, |
double | src_x, | ||
double | src_y, | ||
double & | dest_x, | ||
double & | dest_y | ||
) |
Translates coordinates relative to src_widget’s allocation to coordinates relative to dest_widget’s allocations.
In order to perform this operation, both widget must share a common ancestor. If that is not the case, dest_x and dest_y are set to 0 and false is returned.
Deprecated: 4.12: Use compute_point() instead
dest_widget | Another widget. |
src_x | X position in widget coordinates of src_widget. |
src_y | Y position in widget coordinates of src_widget. |
dest_x | Location to store X position in widget coordinates of dest_widget. |
dest_y | Location to store Y position in widget coordinates of dest_widget. |
void Gtk::Widget::trigger_tooltip_query | ( | ) |
Triggers a tooltip query on the display of the widget.
void Gtk::Widget::unmap | ( | ) |
Causes a widget to be unmapped if it’s currently mapped.
This function is only for use in widget implementations.
void Gtk::Widget::unparent | ( | ) |
Removes widget from its parent.
This function is only for use in widget implementations, typically in dispose.
|
protected |
Causes a widget to be unrealized.
This frees all GDK resources associated with the widget.
This function is only useful in widget implementations.
|
protected |
Unsets the focus child of the widget.
The previous focus child will be unset.
This function is only suitable for widget implementations.
void Gtk::Widget::unset_font_options | ( | ) |
Undoes the effect of previous calls to set_font_options().
void Gtk::Widget::unset_layout_manager | ( | ) |
Undoes the effect of a previous call to set_layout_manager().
void Gtk::Widget::unset_name | ( | ) |
void Gtk::Widget::unset_state_flags | ( | StateFlags | flags | ) |
Turns off flag values for the current widget state.
See set_state_flags().
This function is for use in widget implementations.
flags | State flags to turn off. |
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |