gtkmm 4.16.0
Public Member Functions | Static Public Member Functions | Related Symbols | List of all members
Gtk::Label Class Reference

A widget that displays a small to medium amount of text. More...

#include <gtkmm/label.h>

Inheritance diagram for Gtk::Label:
Inheritance graph
[legend]

Public Member Functions

 Label (Label &&src) noexcept
 
Labeloperator= (Label &&src) noexcept
 
 Label (const Label &)=delete
 
Labeloperator= (const Label &)=delete
 
 ~Label () noexcept override
 
GtkLabelgobj ()
 Provides access to the underlying C GObject.
 
const GtkLabelgobj () const
 Provides access to the underlying C GObject.
 
 Label ()
 
 Label (const Glib::ustring &label, bool mnemonic=false)
 
 Label (const Glib::ustring &label, Align halign, Align valign=Align::CENTER, bool mnemonic=false)
 This constructor is a shortcut to create a Label with Widget alignment properties different from the default Align::FILL.
 
void set_text (const Glib::ustring & str)
 Sets the text within the Gtk::Label widget.
 
Glib::ustring get_text () const
 Fetches the text from a label.
 
void set_attributes (Pango::AttrList &attrs)
 Apply attributes to the label text.
 
Pango::AttrList get_attributes () const
 Gets the label's attribute list.
 
void set_label (const Glib::ustring & str)
 Sets the text of the label.
 
Glib::ustring get_label () const
 Fetches the text from a label.
 
void set_markup (const Glib::ustring & str)
 Sets the labels text and attributes from markup.
 
void set_use_markup (bool setting=true)
 Sets whether the text of the label contains markup.
 
bool get_use_markup () const
 Returns whether the label’s text is interpreted as Pango markup.
 
void set_use_underline (bool setting=true)
 Sets whether underlines in the text indicate mnemonics.
 
bool get_use_underline () const
 Returns whether an embedded underlines in the label indicate mnemonics.
 
void set_markup_with_mnemonic (const Glib::ustring & str)
 Sets the labels text, attributes and mnemonic from markup.
 
guint get_mnemonic_keyval () const
 Return the mnemonic accelerator.
 
void set_mnemonic_widget (Widget &widget)
 Associate the label with its mnemonic target.
 
Widgetget_mnemonic_widget ()
 Retrieves the target of the mnemonic (keyboard shortcut) of this label.
 
const Widgetget_mnemonic_widget () const
 Retrieves the target of the mnemonic (keyboard shortcut) of this label.
 
void set_text_with_mnemonic (const Glib::ustring & str)
 Sets the label’s text from the string str.
 
void set_justify (Justification jtype)
 Sets the alignment of the lines in the text of the label relative to each other.
 
Justification get_justify () const
 Returns the justification of the label.
 
void set_ellipsize (Pango::EllipsizeMode mode)
 Sets the mode used to ellipsize the text.
 
Pango::EllipsizeMode get_ellipsize () const
 Returns the ellipsizing position of the label.
 
void set_width_chars (int n_chars)
 Sets the desired width in characters of label to n_chars.
 
int get_width_chars () const
 Retrieves the desired width of label, in characters.
 
void set_max_width_chars (int n_chars)
 Sets the desired maximum width in characters of label to n_chars.
 
int get_max_width_chars () const
 Retrieves the desired maximum width of label, in characters.
 
void set_lines (int lines)
 Sets the number of lines to which an ellipsized, wrapping label should be limited.
 
int get_lines () const
 Gets the number of lines to which an ellipsized, wrapping label should be limited.
 
void set_wrap (bool wrap=true)
 Toggles line wrapping within the Gtk::Label widget.
 
bool get_wrap () const
 Returns whether lines in the label are automatically wrapped.
 
void set_wrap_mode (Pango::WrapMode wrap_mode)
 Controls how line wrapping is done.
 
Pango::WrapMode get_wrap_mode () const
 Returns line wrap mode used by the label.
 
void set_natural_wrap_mode (NaturalWrapMode wrap_mode)
 Select the line wrapping for the natural size request.
 
NaturalWrapMode get_natural_wrap_mode () const
 Returns line wrap mode used by the label.
 
void set_selectable (bool setting=true)
 Makes text in the label selectable.
 
bool get_selectable () const
 Returns whether the label is selectable.
 
void select_region (int start_offset, int end_offset)
 Selects a range of characters in the label, if the label is selectable.
 
void select_region (int start_offset)
 Selects a range of characters in the label, from start_offset to the end, if the label is selectable.
 
bool get_selection_bounds (int &start, int &end) const
 Gets the selected range of characters in the label.
 
Glib::RefPtr< Pango::Layout > get_layout ()
 Gets the Pango::Layout used to display the label.
 
Glib::RefPtr< const Pango::Layout > get_layout () const
 Gets the Pango::Layout used to display the label.
 
void get_layout_offsets (int &x, int &y) const
 Obtains the coordinates where the label will draw its Pango::Layout.
 
void set_single_line_mode (bool single_line_mode=true)
 Sets whether the label is in single line mode.
 
bool get_single_line_mode () const
 Returns whether the label is in single line mode.
 
Glib::ustring get_current_uri () const
 Returns the URI for the currently active link in the label.
 
void set_xalign (float xalign)
 Sets the xalign of the label.
 
float get_xalign () const
 Gets the xalign of the label.
 
void set_yalign (float yalign)
 Sets the yalign of the label.
 
float get_yalign () const
 Gets the yalign of the label.
 
void set_extra_menu (const Glib::RefPtr< Gio::MenuModel > &model)
 Sets a menu model to add when constructing the context menu for label.
 
Glib::RefPtr< Gio::MenuModel > get_extra_menu ()
 Gets the extra menu model of label.
 
Glib::RefPtr< const Gio::MenuModel > get_extra_menu () const
 Gets the extra menu model of label.
 
void set_tabs (const Pango::TabArray &tabs)
 Sets the default tab stops for paragraphs in self.
 
Pango::TabArray get_tabs () const
 Gets the tabs for self.
 
Glib::SignalProxy< bool(const Glib::ustring &)> signal_activate_link ()
 
Glib::PropertyProxy< Glib::ustring > property_label ()
 The contents of the label.
 
Glib::PropertyProxy_ReadOnly< Glib::ustring > property_label () const
 The contents of the label.
 
Glib::PropertyProxy< Pango::AttrList > property_attributes ()
 A list of style attributes to apply to the text of the label.
 
Glib::PropertyProxy_ReadOnly< Pango::AttrList > property_attributes () const
 A list of style attributes to apply to the text of the label.
 
Glib::PropertyProxy< bool > property_use_markup ()
 true if the text of the label includes Pango markup.
 
Glib::PropertyProxy_ReadOnly< bool > property_use_markup () const
 true if the text of the label includes Pango markup.
 
Glib::PropertyProxy< bool > property_use_underline ()
 true if the text of the label indicates a mnemonic with an _ before the mnemonic character.
 
Glib::PropertyProxy_ReadOnly< bool > property_use_underline () const
 true if the text of the label indicates a mnemonic with an _ before the mnemonic character.
 
Glib::PropertyProxy< Justificationproperty_justify ()
 The alignment of the lines in the text of the label, relative to each other.
 
Glib::PropertyProxy_ReadOnly< Justificationproperty_justify () const
 The alignment of the lines in the text of the label, relative to each other.
 
Glib::PropertyProxy< bool > property_wrap ()
 true if the label text will wrap if it gets too wide.
 
Glib::PropertyProxy_ReadOnly< bool > property_wrap () const
 true if the label text will wrap if it gets too wide.
 
Glib::PropertyProxy< Pango::WrapMode > property_wrap_mode ()
 Controls how the line wrapping is done.
 
Glib::PropertyProxy_ReadOnly< Pango::WrapMode > property_wrap_mode () const
 Controls how the line wrapping is done.
 
Glib::PropertyProxy< NaturalWrapModeproperty_natural_wrap_mode ()
 Select the line wrapping for the natural size request.
 
Glib::PropertyProxy_ReadOnly< NaturalWrapModeproperty_natural_wrap_mode () const
 Select the line wrapping for the natural size request.
 
Glib::PropertyProxy< bool > property_selectable ()
 Whether the label text can be selected with the mouse.
 
Glib::PropertyProxy_ReadOnly< bool > property_selectable () const
 Whether the label text can be selected with the mouse.
 
Glib::PropertyProxy_ReadOnly< guint > property_mnemonic_keyval () const
 The mnemonic accelerator key for the label.
 
Glib::PropertyProxy< Widget * > property_mnemonic_widget ()
 The widget to be activated when the labels mnemonic key is pressed.
 
Glib::PropertyProxy_ReadOnly< Widget * > property_mnemonic_widget () const
 The widget to be activated when the labels mnemonic key is pressed.
 
Glib::PropertyProxy< Pango::EllipsizeMode > property_ellipsize ()
 The preferred place to ellipsize the string, if the label does not have enough room to display the entire string.
 
Glib::PropertyProxy_ReadOnly< Pango::EllipsizeMode > property_ellipsize () const
 The preferred place to ellipsize the string, if the label does not have enough room to display the entire string.
 
Glib::PropertyProxy< int > property_width_chars ()
 The desired width of the label, in characters.
 
Glib::PropertyProxy_ReadOnly< int > property_width_chars () const
 The desired width of the label, in characters.
 
Glib::PropertyProxy< bool > property_single_line_mode ()
 Whether the label is in single line mode.
 
Glib::PropertyProxy_ReadOnly< bool > property_single_line_mode () const
 Whether the label is in single line mode.
 
Glib::PropertyProxy< int > property_max_width_chars ()
 The desired maximum width of the label, in characters.
 
Glib::PropertyProxy_ReadOnly< int > property_max_width_chars () const
 The desired maximum width of the label, in characters.
 
Glib::PropertyProxy< int > property_lines ()
 The number of lines to which an ellipsized, wrapping label should be limited.
 
Glib::PropertyProxy_ReadOnly< int > property_lines () const
 The number of lines to which an ellipsized, wrapping label should be limited.
 
Glib::PropertyProxy< floatproperty_xalign ()
 The horizontal alignment of the label text inside its size allocation.
 
Glib::PropertyProxy_ReadOnly< floatproperty_xalign () const
 The horizontal alignment of the label text inside its size allocation.
 
Glib::PropertyProxy< floatproperty_yalign ()
 The vertical alignment of the label text inside its size allocation.
 
Glib::PropertyProxy_ReadOnly< floatproperty_yalign () const
 The vertical alignment of the label text inside its size allocation.
 
Glib::PropertyProxy< Glib::RefPtr< Gio::MenuModel > > property_extra_menu ()
 A menu model whose contents will be appended to the context menu.
 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::MenuModel > > property_extra_menu () const
 A menu model whose contents will be appended to the context menu.
 
Glib::PropertyProxy< Pango::TabArray > property_tabs ()
 Custom tabs for this label.
 
Glib::PropertyProxy_ReadOnly< Pango::TabArray > property_tabs () const
 Custom tabs for this label.
 
- Public Member Functions inherited from Gtk::Widget
 Widget (Widget &&src) noexcept
 
Widgetoperator= (Widget &&src) noexcept
 
 Widget (const Widget &)=delete
 
Widgetoperator= (const Widget &)=delete
 
 ~Widget () noexcept override
 Destroys the widget.
 
GtkWidgetgobj ()
 Provides access to the underlying C GObject.
 
const GtkWidgetgobj () const
 Provides access to the underlying C GObject.
 
Glib::RefPtr< ConstraintTargetmake_refptr_constrainttarget ()
 Converts this widget to a reference counted Gtk::ConstraintTarget.
 
Glib::RefPtr< const ConstraintTargetmake_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 show().
 
void queue_draw ()
 Schedules this widget to be redrawn in the paint phase of the current or the next frame.
 
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 delegate instance that provides an implementation for measuring and allocating the children of widget.
 
void unset_layout_manager ()
 Undoes the effect of a previous call to set_layout_manager().
 
Glib::RefPtr< LayoutManagerget_layout_manager ()
 Retrieves the layout manager used by widget.
 
Glib::RefPtr< const LayoutManagerget_layout_manager () const
 Retrieves the layout manager used by 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)
 Specifies 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 widget or any of its children.
 
void set_focusable (bool focusable=true)
 Specifies whether widget can own the input focus.
 
bool get_focusable () const
 Determines whether 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 Gtk::Window it's inside.
 
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 widget can be the target of pointer events.
 
bool get_can_target () const
 Queries whether widget can be the target of pointer events.
 
bool has_default () const
 Determines whether widget is the current default widget within its toplevel.
 
void set_receives_default (bool receives_default=true)
 Specifies whether 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 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 a 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 widget can be drawn to.
 
bool get_realized () const
 Determines whether widget is realized.
 
bool get_mapped () const
 Whether the widget is mapped.
 
void set_child_visible (bool visible=true)
 Sets whether 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 widget.
 
int get_allocated_height () const
 Returns the height that has currently been allocated to widget.
 
int get_allocated_baseline () const
 Returns the baseline that has currently been allocated to widget.
 
Allocation get_allocation () const
 Retrieves the widget’s location.
 
std::optional< Gdk::Graphene::Rectcompute_bounds (const Widget & target) const
 Computes the bounds for the widget in the coordinate space of target.
 
std::optional< Gdk::Graphene::Pointcompute_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 widget.
 
int get_size (Orientation orientation) const
 Returns the content width or height of the widget.
 
Widgetget_parent ()
 Returns the parent widget of widget.
 
const Widgetget_parent () const
 Returns the parent widget of widget.
 
Rootget_root ()
 Returns the Gtk::Root widget of widget.
 
const Rootget_root () const
 Returns the Gtk::Root widget of widget.
 
Nativeget_native ()
 Returns the nearest Gtk::Native ancestor of widget.
 
const Nativeget_native () const
 Returns the nearest Gtk::Native ancestor of 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 keynav-failed signal on the widget.
 
void error_bell ()
 Notifies the user about an input-related error on this widget.
 
void set_size_request (int width=-1, int height=-1)
 Sets the minimum size of a widget.
 
void get_size_request (int & width, int &height) const
 Gets the size request that was explicitly set for the widget using set_size_request().
 
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)
 Request the widget to be rendered partially transparent.
 
double get_opacity () const
 Fetches the requested opacity for this widget.
 
void set_overflow (Overflow overflow)
 Sets how widget treats content that is drawn outside the widget's content area.
 
Overflow get_overflow () const
 Returns the widget’s overflow value.
 
Widgetget_ancestor (GType widget_type)
 Gets the first ancestor of widget with type widget_type.
 
const Widgetget_ancestor (GType widget_type) const
 Gets the first ancestor of 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::Displayget_display ()
 Get the Gdk::Display for the toplevel window associated with this widget.
 
Glib::RefPtr< const Gdk::Displayget_display () const
 Get the Gdk::Display for the toplevel window associated with this widget.
 
Glib::RefPtr< Settingsget_settings ()
 Gets the settings object holding the settings used for this widget.
 
Glib::RefPtr< Gdk::Clipboardget_clipboard ()
 Gets the clipboard object for widget.
 
Glib::RefPtr< const Gdk::Clipboardget_clipboard () const
 Gets the clipboard object for widget.
 
Glib::RefPtr< Gdk::Clipboardget_primary_clipboard ()
 Gets the primary clipboard of widget.
 
Glib::RefPtr< const Gdk::Clipboardget_primary_clipboard () const
 Gets the primary clipboard of 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 set_hexpand() has been used to explicitly set the expand flag on this widget.
 
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 set_vexpand() has been used to explicitly set the expand flag on this widget.
 
void set_vexpand_set (bool set=true)
 Sets whether the vexpand flag will be used.
 
bool compute_expand (Orientation orientation)
 Computes whether a container 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 widget.
 
void set_halign (Align align)
 Sets the horizontal alignment of widget.
 
Align get_valign () const
 Gets the vertical alignment of widget.
 
void set_valign (Align align)
 Sets the vertical alignment of widget.
 
int get_margin_start () const
 Gets the start margin of widget.
 
void set_margin_start (int margin)
 Sets the start margin of widget.
 
int get_margin_end () const
 Gets the end margin of widget.
 
void set_margin_end (int margin)
 Sets the end margin of widget.
 
int get_margin_top () const
 Gets the top margin of widget.
 
void set_margin_top (int margin)
 Sets the top margin of widget.
 
int get_margin_bottom () const
 Gets the bottom margin of widget.
 
void set_margin_bottom (int margin)
 Sets the bottom margin of widget.
 
void set_margin (int margin)
 Set all 4 margins to the same value.
 
bool is_ancestor (Widget &ancestor) const
 Determines whether widget is somewhere inside ancestor, possibly with intermediate containers.
 
bool translate_coordinates (Widget &dest_widget, double src_x, double src_y, double &dest_x, double &dest_y)
 Translate coordinates relative to src_widget’s allocation to coordinates relative to dest_widget’s allocations.
 
bool contains (double x, double y) const
 Tests if the point at ( x, y) is contained in widget.
 
Widgetpick (double x, double y, PickFlags flags=PickFlags::DEFAULT)
 Finds the descendant of widget closest to the point ( x, y).
 
const Widgetpick (double x, double y, PickFlags flags=PickFlags::DEFAULT) const
 Finds the descendant of widget closest to the point ( x, y).
 
void add_controller (const Glib::RefPtr< EventController > &controller)
 Adds controller to widget so that it will receive events.
 
void remove_controller (const Glib::RefPtr< EventController > &controller)
 Removes controller from widget, so that it doesn't process events anymore.
 
Glib::RefPtr< Pango::Context > create_pango_context ()
 Creates a new Pango::Context with the appropriate font map, font options, font description, and base direction for drawing text for this widget.
 
Glib::RefPtr< Pango::Context > get_pango_context ()
 Gets a Pango::Context with the appropriate font map, font description, and base direction for this widget.
 
void set_font_options (const Cairo::FontOptions &options)
 Sets the cairo_font_options_t used for Pango rendering in this 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 widget.
 
Glib::RefPtr< Pango::Layout > create_pango_layout (const Glib::ustring &text)
 Creates a new Pango::Layout with the appropriate font map, font description, and base direction for drawing text for this widget.
 
void set_direction (TextDirection dir)
 Sets the reading direction on a particular widget.
 
TextDirection get_direction () const
 Gets the reading direction for a particular widget.
 
void set_cursor (const Glib::RefPtr< Gdk::Cursor > &cursor)
 Sets the cursor to be shown when pointer devices point towards 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::Cursorget_cursor ()
 Queries the cursor set on widget.
 
Glib::RefPtr< const Gdk::Cursorget_cursor () const
 Queries the cursor set on 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::FrameClockget_frame_clock ()
 Obtains the frame clock for a widget.
 
Glib::RefPtr< const Gdk::FrameClockget_frame_clock () const
 Obtains the frame clock for a widget.
 
void set_parent (Widget & parent)
 Sets parent as the parent widget of widget.
 
void unparent ()
 Dissociate 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 where the toplevel of widget is located.
 
void set_tooltip_text (const Glib::ustring &text)
 Sets text as the contents of the tooltip.
 
Glib::ustring get_tooltip_text () const
 Gets the contents of the tooltip for widget.
 
void set_tooltip_markup (const Glib::ustring &markup)
 Sets markup as the contents of the tooltip, which is marked up with Pango markup.
 
Glib::ustring get_tooltip_markup () const
 Gets the contents of the tooltip for widget.
 
void set_has_tooltip (bool has_tooltip=TRUE)
 Sets the has-tooltip property on widget to has_tooltip.
 
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< StyleContextget_style_context ()
 Returns the style context associated to widget.
 
Glib::RefPtr< const StyleContextget_style_context () const
 Returns the style context associated to 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 group into widget.
 
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 from widget.
 
void set_font_map (const Glib::RefPtr< Pango::FontMap > &font_map)
 Sets the font map to use for Pango rendering.
 
Glib::RefPtr< Pango::FontMap > get_font_map ()
 Gets the font map of widget.
 
Glib::RefPtr< const Pango::FontMap > get_font_map () const
 Gets the font map of widget.
 
Widgetget_first_child ()
 Returns the widget’s first child.
 
const Widgetget_first_child () const
 Returns the widget’s first child.
 
Widgetget_last_child ()
 Returns the widget’s last child.
 
const Widgetget_last_child () const
 Returns the widget’s last child.
 
Widgetget_next_sibling ()
 Returns the widget’s next sibling.
 
const Widgetget_next_sibling () const
 Returns the widget’s next sibling.
 
Widgetget_prev_sibling ()
 Returns the widget’s previous sibling.
 
const Widgetget_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 Gio::ListModel to track the children of widget.
 
Glib::RefPtr< const Gio::ListModel > observe_children () const
 Returns a Gio::ListModel to track the children of widget.
 
Glib::RefPtr< Gio::ListModel > observe_controllers ()
 Returns a Gio::ListModel to track the Gtk::EventControllers of widget.
 
Glib::RefPtr< const Gio::ListModel > observe_controllers () const
 Returns a Gio::ListModel to track the Gtk::EventControllers of 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)
 Snapshot the a child of widget.
 
bool should_layout () const
 Returns whether widget should contribute to the measuring and allocation of its parent.
 
Glib::ustring get_css_name () const
 Returns the CSS name that is used for self.
 
void add_css_class (const Glib::ustring &css_class)
 Adds a style class to widget.
 
void remove_css_class (const Glib::ustring &css_class)
 Removes a style from widget.
 
bool has_css_class (const Glib::ustring &css_class) const
 Returns whether css_class is currently applied to widget.
 
std::vector< Glib::ustring > get_css_classes () const
 Returns the list of style classes applied to widget.
 
void set_css_classes (const std::vector< Glib::ustring > &classes)
 Clear all style classes applied to widget and replace them 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 ()
 Override for width request of the widget.
 
Glib::PropertyProxy_ReadOnly< int > property_width_request () const
 Override for width request of the widget.
 
Glib::PropertyProxy< int > property_height_request ()
 Override for height request of the widget.
 
Glib::PropertyProxy_ReadOnly< int > property_height_request () const
 Override 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< Alignproperty_halign ()
 How to distribute horizontal space if widget gets extra space.
 
Glib::PropertyProxy_ReadOnly< Alignproperty_halign () const
 How to distribute horizontal space if widget gets extra space.
 
Glib::PropertyProxy< Alignproperty_valign ()
 How to distribute vertical space if widget gets extra space.
 
Glib::PropertyProxy_ReadOnly< Alignproperty_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< doubleproperty_opacity ()
 The requested opacity of the widget.
 
Glib::PropertyProxy_ReadOnly< doubleproperty_opacity () const
 The requested opacity of the widget.
 
Glib::PropertyProxy< Overflowproperty_overflow ()
 How content outside the widget's content area is treated.
 
Glib::PropertyProxy_ReadOnly< Overflowproperty_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.
 
- Public Member Functions inherited from Gtk::Object
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
 ~Object () noexcept override
 
- Public Member Functions inherited from Gtk::Accessible
 Accessible (Accessible &&src) noexcept
 
Accessibleoperator= (Accessible &&src) noexcept
 
 ~Accessible () noexcept override
 
GtkAccessiblegobj ()
 Provides access to the underlying C GObject.
 
const GtkAccessiblegobj () const
 Provides access to the underlying C GObject.
 
Glib::RefPtr< ATContextget_at_context ()
 Retrieves the accessible implementation for the given Gtk::Accessible.
 
Glib::RefPtr< const ATContextget_at_context () const
 Retrieves the accessible implementation for the given Gtk::Accessible.
 
bool get_platform_state (PlatformState state) const
 Query a platform state, such as focus.
 
Glib::RefPtr< Accessibleget_accessible_parent ()
 Retrieves the accessible parent for an accessible object.
 
Glib::RefPtr< const Accessibleget_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< Accessibleget_first_accessible_child ()
 Retrieves the first accessible child of an accessible object.
 
Glib::RefPtr< const Accessibleget_first_accessible_child () const
 Retrieves the first accessible child of an accessible object.
 
Glib::RefPtr< Accessibleget_next_accessible_sibling ()
 Retrieves the next accessible sibling of an accessible object.
 
Glib::RefPtr< const Accessibleget_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 of self.
 
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< Roleproperty_accessible_role ()
 The accessible role of the given Gtk::Accessible implementation.
 
Glib::PropertyProxy_ReadOnly< Roleproperty_accessible_role () const
 The accessible role of the given Gtk::Accessible implementation.
 
- Public Member Functions inherited from Gtk::Buildable
 Buildable (Buildable &&src) noexcept
 
Buildableoperator= (Buildable &&src) noexcept
 
 ~Buildable () noexcept override
 
GtkBuildablegobj ()
 Provides access to the underlying C GObject.
 
const GtkBuildablegobj () const
 Provides access to the underlying C GObject.
 
Glib::ustring get_buildable_id () const
 Gets the ID of the buildable object.
 
- Public Member Functions inherited from Gtk::ConstraintTarget
 ConstraintTarget (ConstraintTarget &&src) noexcept
 
ConstraintTargetoperator= (ConstraintTarget &&src) noexcept
 
 ~ConstraintTarget () noexcept override
 
GtkConstraintTargetgobj ()
 Provides access to the underlying C GObject.
 
const GtkConstraintTargetgobj () 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 Public Member Functions inherited from Gtk::Widget
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 current default reading direction.
 
- Static Public Member Functions inherited from Gtk::Accessible
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 Public Member Functions inherited from Gtk::Buildable
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 Public Member Functions inherited from Gtk::ConstraintTarget
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::Labelwrap (GtkLabel *object, bool take_copy=false)
 A Glib::wrap() method for this object.
 

Additional Inherited Members

- Public Types inherited from Gtk::Widget
using PreferredSize = MinimumNatural< Requisition >
 Structure returned by the non-output-parameter overload of get_preferred_size().
 
using SlotTick = sigc::slot< bool(const Glib::RefPtr< Gdk::FrameClock > &)>
 Callback type for adding a function to update animations.
 
- Public Types inherited from Gtk::Accessible
enum class  Role {
  ALERT ,
  ALERT_DIALOG ,
  BANNER ,
  BUTTON ,
  CAPTION ,
  CELL ,
  CHECKBOX ,
  COLUMN_HEADER ,
  COMBO_BOX ,
  COMMAND ,
  COMPOSITE ,
  DIALOG ,
  DOCUMENT ,
  FEED ,
  FORM ,
  GENERIC ,
  GRID ,
  GRID_CELL ,
  GROUP ,
  HEADING ,
  IMG ,
  INPUT ,
  LABEL ,
  LANDMARK ,
  LEGEND ,
  LINK ,
  LIST ,
  LIST_BOX ,
  LIST_ITEM ,
  LOG ,
  MAIN ,
  MARQUEE ,
  MATH ,
  METER ,
  MENU ,
  MENU_BAR ,
  MENU_ITEM ,
  MENU_ITEM_CHECKBOX ,
  MENU_ITEM_RADIO ,
  NAVIGATION ,
  NONE ,
  NOTE ,
  OPTION ,
  PRESENTATION ,
  PROGRESS_BAR ,
  RADIO ,
  RADIO_GROUP ,
  RANGE ,
  REGION ,
  ROW ,
  ROW_GROUP ,
  ROW_HEADER ,
  SCROLLBAR ,
  SEARCH ,
  SEARCH_BOX ,
  SECTION ,
  SECTION_HEAD ,
  SELECT ,
  SEPARATOR ,
  SLIDER ,
  SPIN_BUTTON ,
  STATUS ,
  STRUCTURE ,
  SWITCH ,
  TAB ,
  TABLE ,
  TAB_LIST ,
  TAB_PANEL ,
  TEXT_BOX ,
  TIME ,
  TIMER ,
  TOOLBAR ,
  TOOLTIP ,
  TREE ,
  TREE_GRID ,
  TREE_ITEM ,
  WIDGET ,
  WINDOW ,
  TOGGLE_BUTTON ,
  APPLICATION ,
  PARAGRAPH ,
  BLOCK_QUOTE ,
  ARTICLE ,
  COMMENT ,
  TERMINAL
}
 
enum class  State {
  BUSY ,
  CHECKED ,
  DISABLED ,
  EXPANDED ,
  HIDDEN ,
  INVALID ,
  PRESSED ,
  SELECTED ,
  VISITED
}
 
enum class  Property {
  AUTOCOMPLETE ,
  DESCRIPTION ,
  HAS_POPUP ,
  KEY_SHORTCUTS ,
  LABEL ,
  LEVEL ,
  MODAL ,
  MULTI_LINE ,
  MULTI_SELECTABLE ,
  ORIENTATION ,
  PLACEHOLDER ,
  READ_ONLY ,
  REQUIRED ,
  ROLE_DESCRIPTION ,
  SORT ,
  VALUE_MAX ,
  VALUE_MIN ,
  VALUE_NOW ,
  VALUE_TEXT ,
  HELP_TEXT
}
 
enum class  Relation {
  ACTIVE_DESCENDANT ,
  COL_COUNT ,
  COL_INDEX ,
  COL_INDEX_TEXT ,
  COL_SPAN ,
  CONTROLS ,
  DESCRIBED_BY ,
  DETAILS ,
  ERROR_MESSAGE ,
  FLOW_TO ,
  LABELLED_BY ,
  OWNS ,
  POS_IN_SET ,
  ROW_COUNT ,
  ROW_INDEX ,
  ROW_INDEX_TEXT ,
  ROW_SPAN ,
  SET_SIZE
}
 
enum class  PlatformState {
  FOCUSABLE ,
  FOCUSED ,
  ACTIVE
}
 
enum class  AnnouncementPriority {
  LOW ,
  MEDIUM ,
  HIGH
}
 
- Protected Member Functions inherited from Gtk::Widget
virtual void root_vfunc ()
 
virtual void unroot_vfunc ()
 
virtual void size_allocate_vfunc (int width, int height, int baseline)
 
virtual SizeRequestMode get_request_mode_vfunc () const
 
virtual void measure_vfunc (Orientation orientation, int for_size, int & minimum, int & natural, int &minimum_baseline, int &natural_baseline) const
 
virtual bool grab_focus_vfunc ()
 
virtual void set_focus_child_vfunc (Widget *child)
 Sets the focused child of widget.
 
virtual void compute_expand_vfunc (bool &hexpand_p, bool &vexpand_p)
 
virtual bool contains_vfunc (double x, double y) const
 
virtual void snapshot_vfunc (const Glib::RefPtr< Gtk::Snapshot > & snapshot)
 
 Widget ()
 
void realize ()
 Creates the GDK resources associated with a widget.
 
void unrealize ()
 Causes a widget to be unrealized (frees all GDK resources associated with the widget).
 
void realize_if_needed ()
 
void set_focus_child (Widget &child)
 Set child as the current focus child of widget.
 
void unset_focus_child ()
 Unsets the focus child of the widget.
 
Widgetget_focus_child ()
 Returns the current focus child of widget.
 
const Widgetget_focus_child () const
 Returns the current focus child of widget.
 
virtual void on_show ()
 This is a default handler for the signal signal_show().
 
virtual void on_hide ()
 This is a default handler for the signal signal_hide().
 
virtual void on_map ()
 This is a default handler for the signal signal_map().
 
virtual void on_unmap ()
 This is a default handler for the signal signal_unmap().
 
virtual void on_realize ()
 This is a default handler for the signal signal_realize().
 
virtual void on_unrealize ()
 This is a default handler for the signal signal_unrealize().
 
virtual void on_state_flags_changed (Gtk::StateFlags previous_state_flags)
 This is a default handler for the signal signal_state_flags_changed().
 
virtual void on_direction_changed (TextDirection direction)
 This is a default handler for the signal signal_direction_changed().
 
virtual bool on_mnemonic_activate (bool group_cycling)
 This is a default handler for the signal signal_mnemonic_activate().
 
virtual bool on_query_tooltip (int x, int y, bool keyboard_tooltip, const Glib::RefPtr< Tooltip > &tooltip)
 This is a default handler for the signal signal_query_tooltip().
 
- Protected Member Functions inherited from Gtk::Accessible
 Accessible ()
 You should derive from this class to use it.
 
- Protected Member Functions inherited from Gtk::Buildable
 Buildable ()
 You should derive from this class to use it.
 
- Protected Member Functions inherited from Gtk::ConstraintTarget
 ConstraintTarget ()
 You should derive from this class to use it.
 

Detailed Description

A widget that displays a small to medium amount of text.

A simple setable widget for holding a Glib::ustring.

Key values are the codes which are sent whenever a key is pressed or released. The complete list of key values can be found in the gdk/gdkkeysyms.h header file. They are prefixed with GDK_KEY_.

The Label widget looks like this:

Constructor & Destructor Documentation

◆ Label() [1/5]

Gtk::Label::Label ( Label &&  src)
noexcept

◆ Label() [2/5]

Gtk::Label::Label ( const Label )
delete

◆ ~Label()

Gtk::Label::~Label ( )
overridenoexcept

◆ Label() [3/5]

Gtk::Label::Label ( )

◆ Label() [4/5]

Gtk::Label::Label ( const Glib::ustring &  label,
bool  mnemonic = false 
)
explicit

◆ Label() [5/5]

Gtk::Label::Label ( const Glib::ustring &  label,
Align  halign,
Align  valign = Align::CENTER,
bool  mnemonic = false 
)

This constructor is a shortcut to create a Label with Widget alignment properties different from the default Align::FILL.

Gtk::Label label(text, h, v, mnemonic);
A widget that displays a small to medium amount of text.
Definition label.h:66

is equivalent to:

Gtk::Label label(text, mnemonic);
label.set_halign(h);
label.set_valign(v);

Member Function Documentation

◆ get_attributes()

Pango::AttrList Gtk::Label::get_attributes ( ) const

Gets the label's attribute list.

This is the Pango::AttrList that was set on the label using set_attributes(), if any. This function does not reflect attributes that come from the label's markup (see set_markup()). If you want to get the effective attributes for the label, use pango_layout_get_attributes (gtk_label_get_layout (self)).

Returns
The attribute list.

◆ get_current_uri()

Glib::ustring Gtk::Label::get_current_uri ( ) const

Returns the URI for the currently active link in the label.

The active link is the one under the mouse pointer or, in a selectable label, the link in which the text cursor is currently positioned.

This function is intended for use in a signal_activate_link() handler or for use in a Gtk::Widget::signal_query_tooltip() handler.

Returns
The currently active URI.

◆ get_ellipsize()

Pango::EllipsizeMode Gtk::Label::get_ellipsize ( ) const

Returns the ellipsizing position of the label.

See set_ellipsize().

Returns
Pango::EllipsizeMode.

◆ get_extra_menu() [1/2]

Glib::RefPtr< Gio::MenuModel > Gtk::Label::get_extra_menu ( )

Gets the extra menu model of label.

See set_extra_menu().

Returns
The menu model.

◆ get_extra_menu() [2/2]

Glib::RefPtr< const Gio::MenuModel > Gtk::Label::get_extra_menu ( ) const

Gets the extra menu model of label.

See set_extra_menu().

Returns
The menu model.

◆ get_justify()

Justification Gtk::Label::get_justify ( ) const

Returns the justification of the label.

See set_justify().

Returns
Gtk::Justification.

◆ get_label()

Glib::ustring Gtk::Label::get_label ( ) const

Fetches the text from a label.

The returned text includes any embedded underlines indicating mnemonics and Pango markup. (See get_text()).

Returns
The text of the label widget.

◆ get_layout() [1/2]

Glib::RefPtr< Pango::Layout > Gtk::Label::get_layout ( )

Gets the Pango::Layout used to display the label.

The layout is useful to e.g. convert text positions to pixel positions, in combination with get_layout_offsets().

Returns
The Pango::Layout for this label.

◆ get_layout() [2/2]

Glib::RefPtr< const Pango::Layout > Gtk::Label::get_layout ( ) const

Gets the Pango::Layout used to display the label.

The layout is useful to e.g. convert text positions to pixel positions, in combination with get_layout_offsets().

Returns
The Pango::Layout for this label.

◆ get_layout_offsets()

void Gtk::Label::get_layout_offsets ( int &  x,
int &  y 
) const

Obtains the coordinates where the label will draw its Pango::Layout.

The coordinates are useful to convert mouse events into coordinates inside the Pango::Layout, e.g. to take some action if some part of the label is clicked. Remember when using the Pango::Layout functions you need to convert to and from pixels using PANGO_PIXELS() or [const.nosp@m.@Pan.nosp@m.go.SC.nosp@m.ALE].

Parameters
xLocation to store X offset of layout.
yLocation to store Y offset of layout.

◆ get_lines()

int Gtk::Label::get_lines ( ) const

Gets the number of lines to which an ellipsized, wrapping label should be limited.

See set_lines().

Returns
The number of lines.

◆ get_max_width_chars()

int Gtk::Label::get_max_width_chars ( ) const

Retrieves the desired maximum width of label, in characters.

See set_width_chars().

Returns
The maximum width of the label in characters.

◆ get_mnemonic_keyval()

guint Gtk::Label::get_mnemonic_keyval ( ) const

Return the mnemonic accelerator.

If the label has been set so that it has a mnemonic key this function returns the keyval used for the mnemonic accelerator. If there is no mnemonic set up it returns GDK_KEY_VoidSymbol.

Returns
GDK keyval usable for accelerators, or GDK_KEY_VoidSymbol.

◆ get_mnemonic_widget() [1/2]

Widget * Gtk::Label::get_mnemonic_widget ( )

Retrieves the target of the mnemonic (keyboard shortcut) of this label.

See set_mnemonic_widget().

Returns
The target of the label’s mnemonic, or nullptr if none has been set and the default algorithm will be used.

◆ get_mnemonic_widget() [2/2]

const Widget * Gtk::Label::get_mnemonic_widget ( ) const

Retrieves the target of the mnemonic (keyboard shortcut) of this label.

See set_mnemonic_widget().

Returns
The target of the label’s mnemonic, or nullptr if none has been set and the default algorithm will be used.

◆ get_natural_wrap_mode()

NaturalWrapMode Gtk::Label::get_natural_wrap_mode ( ) const

Returns line wrap mode used by the label.

See set_natural_wrap_mode().

Since gtkmm 4.6:
Returns
The natural line wrap mode.

◆ get_selectable()

bool Gtk::Label::get_selectable ( ) const

Returns whether the label is selectable.

Returns
true if the user can copy text from the label.

◆ get_selection_bounds()

bool Gtk::Label::get_selection_bounds ( int &  start,
int &  end 
) const

Gets the selected range of characters in the label.

Parameters
startReturn location for start of selection, as a character offset.
endReturn location for end of selection, as a character offset.
Returns
true if selection is non-empty.

◆ get_single_line_mode()

bool Gtk::Label::get_single_line_mode ( ) const

Returns whether the label is in single line mode.

Returns
true when the label is in single line mode.

◆ get_tabs()

Pango::TabArray Gtk::Label::get_tabs ( ) const

Gets the tabs for self.

The returned array will be nullptr if “standard” (8-space) tabs are used. Free the return value with Pango::TabArray::free().

Since gtkmm 4.8:
Returns
Copy of default tab array, or nullptr if standard tabs are used; must be freed with Pango::TabArray::free().

◆ get_text()

Glib::ustring Gtk::Label::get_text ( ) const

Fetches the text from a label.

The returned text is as it appears on screen. This does not include any embedded underlines indicating mnemonics or Pango markup. (See get_label())

Returns
The text in the label widget.

◆ get_type()

static GType Gtk::Label::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ get_use_markup()

bool Gtk::Label::get_use_markup ( ) const

Returns whether the label’s text is interpreted as Pango markup.

See set_use_markup().

Returns
true if the label’s text will be parsed for markup.

◆ get_use_underline()

bool Gtk::Label::get_use_underline ( ) const

Returns whether an embedded underlines in the label indicate mnemonics.

See set_use_underline().

Returns
true whether an embedded underline in the label indicates the mnemonic accelerator keys.

◆ get_width_chars()

int Gtk::Label::get_width_chars ( ) const

Retrieves the desired width of label, in characters.

See set_width_chars().

Returns
The width of the label in characters.

◆ get_wrap()

bool Gtk::Label::get_wrap ( ) const

Returns whether lines in the label are automatically wrapped.

See set_wrap().

Returns
true if the lines of the label are automatically wrapped.

◆ get_wrap_mode()

Pango::WrapMode Gtk::Label::get_wrap_mode ( ) const

Returns line wrap mode used by the label.

See set_wrap_mode().

Returns
The line wrap mode.

◆ get_xalign()

float Gtk::Label::get_xalign ( ) const

Gets the xalign of the label.

See the property_xalign() property.

Returns
The xalign property.

◆ get_yalign()

float Gtk::Label::get_yalign ( ) const

Gets the yalign of the label.

See the property_yalign() property.

Returns
The yalign property.

◆ gobj() [1/2]

GtkLabel * Gtk::Label::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GtkLabel * Gtk::Label::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ operator=() [1/2]

Label & Gtk::Label::operator= ( const Label )
delete

◆ operator=() [2/2]

Label & Gtk::Label::operator= ( Label &&  src)
noexcept

◆ property_attributes() [1/2]

Glib::PropertyProxy< Pango::AttrList > Gtk::Label::property_attributes ( )

A list of style attributes to apply to the text of the label.

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_attributes() [2/2]

Glib::PropertyProxy_ReadOnly< Pango::AttrList > Gtk::Label::property_attributes ( ) const

A list of style attributes to apply to the text of the label.

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_ellipsize() [1/2]

Glib::PropertyProxy< Pango::EllipsizeMode > Gtk::Label::property_ellipsize ( )

The preferred place to ellipsize the string, if the label does not have enough room to display the entire string.

Note that setting this property to a value other than Pango::EllipsizeMode::NONE has the side-effect that the label requests only enough space to display the ellipsis "...". In particular, this means that ellipsizing labels do not work well in notebook tabs, unless the Gtk::NotebookPage::property_tab_expand() child property is set to true. Other ways to set a label's width are Gtk::Widget::set_size_request() and Gtk::Label::set_width_chars().

Default value: Pango::EllipsizeMode::NONE

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_ellipsize() [2/2]

Glib::PropertyProxy_ReadOnly< Pango::EllipsizeMode > Gtk::Label::property_ellipsize ( ) const

The preferred place to ellipsize the string, if the label does not have enough room to display the entire string.

Note that setting this property to a value other than Pango::EllipsizeMode::NONE has the side-effect that the label requests only enough space to display the ellipsis "...". In particular, this means that ellipsizing labels do not work well in notebook tabs, unless the Gtk::NotebookPage::property_tab_expand() child property is set to true. Other ways to set a label's width are Gtk::Widget::set_size_request() and Gtk::Label::set_width_chars().

Default value: Pango::EllipsizeMode::NONE

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_extra_menu() [1/2]

Glib::PropertyProxy< Glib::RefPtr< Gio::MenuModel > > Gtk::Label::property_extra_menu ( )

A menu model whose contents will be appended to the context menu.

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_extra_menu() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::MenuModel > > Gtk::Label::property_extra_menu ( ) const

A menu model whose contents will be appended to the context menu.

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_justify() [1/2]

Glib::PropertyProxy< Justification > Gtk::Label::property_justify ( )

The alignment of the lines in the text of the label, relative to each other.

This does not affect the alignment of the label within its allocation. See property_xalign() for that.

Default value: Gtk::Justification::LEFT

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_justify() [2/2]

Glib::PropertyProxy_ReadOnly< Justification > Gtk::Label::property_justify ( ) const

The alignment of the lines in the text of the label, relative to each other.

This does not affect the alignment of the label within its allocation. See property_xalign() for that.

Default value: Gtk::Justification::LEFT

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_label() [1/2]

Glib::PropertyProxy< Glib::ustring > Gtk::Label::property_label ( )

The contents of the label.

If the string contains Pango markup (see pango_parse_markup()), you will have to set the property_use_markup() property to true in order for the label to display the markup attributes. See also Gtk::Label::set_markup() for a convenience function that sets both this property and the property_use_markup() property at the same time.

If the string contains underlines acting as mnemonics, you will have to set the property_use_underline() property to true in order for the label to display them.

Default value: ""

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_label() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::Label::property_label ( ) const

The contents of the label.

If the string contains Pango markup (see pango_parse_markup()), you will have to set the property_use_markup() property to true in order for the label to display the markup attributes. See also Gtk::Label::set_markup() for a convenience function that sets both this property and the property_use_markup() property at the same time.

If the string contains underlines acting as mnemonics, you will have to set the property_use_underline() property to true in order for the label to display them.

Default value: ""

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_lines() [1/2]

Glib::PropertyProxy< int > Gtk::Label::property_lines ( )

The number of lines to which an ellipsized, wrapping label should be limited.

This property has no effect if the label is not wrapping or ellipsized. Set this property to -1 if you don't want to limit the number of lines.

Default value: -1

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_lines() [2/2]

Glib::PropertyProxy_ReadOnly< int > Gtk::Label::property_lines ( ) const

The number of lines to which an ellipsized, wrapping label should be limited.

This property has no effect if the label is not wrapping or ellipsized. Set this property to -1 if you don't want to limit the number of lines.

Default value: -1

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_max_width_chars() [1/2]

Glib::PropertyProxy< int > Gtk::Label::property_max_width_chars ( )

The desired maximum width of the label, in characters.

If this property is set to -1, the width will be calculated automatically.

See the section on text layout for details of how property_width_chars() and property_max_width_chars() determine the width of ellipsized and wrapped labels.

Default value: -1

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_max_width_chars() [2/2]

Glib::PropertyProxy_ReadOnly< int > Gtk::Label::property_max_width_chars ( ) const

The desired maximum width of the label, in characters.

If this property is set to -1, the width will be calculated automatically.

See the section on text layout for details of how property_width_chars() and property_max_width_chars() determine the width of ellipsized and wrapped labels.

Default value: -1

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_mnemonic_keyval()

Glib::PropertyProxy_ReadOnly< guint > Gtk::Label::property_mnemonic_keyval ( ) const

The mnemonic accelerator key for the label.

Default value: 16777215

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_mnemonic_widget() [1/2]

Glib::PropertyProxy< Widget * > Gtk::Label::property_mnemonic_widget ( )

The widget to be activated when the labels mnemonic key is pressed.

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_mnemonic_widget() [2/2]

Glib::PropertyProxy_ReadOnly< Widget * > Gtk::Label::property_mnemonic_widget ( ) const

The widget to be activated when the labels mnemonic key is pressed.

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_natural_wrap_mode() [1/2]

Glib::PropertyProxy< NaturalWrapMode > Gtk::Label::property_natural_wrap_mode ( )

Select the line wrapping for the natural size request.

This only affects the natural size requested. For the actual wrapping used, see the property_wrap_mode() property.

The default is Gtk::NaturalWrapMode::INHERIT, which inherits the behavior of the property_wrap_mode() property.

Since gtkmm 4.6:

Default value: Gtk::NaturalWrapMode::INHERIT

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_natural_wrap_mode() [2/2]

Glib::PropertyProxy_ReadOnly< NaturalWrapMode > Gtk::Label::property_natural_wrap_mode ( ) const

Select the line wrapping for the natural size request.

This only affects the natural size requested. For the actual wrapping used, see the property_wrap_mode() property.

The default is Gtk::NaturalWrapMode::INHERIT, which inherits the behavior of the property_wrap_mode() property.

Since gtkmm 4.6:

Default value: Gtk::NaturalWrapMode::INHERIT

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_selectable() [1/2]

Glib::PropertyProxy< bool > Gtk::Label::property_selectable ( )

Whether the label text can be selected with the mouse.

Default value: false

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_selectable() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gtk::Label::property_selectable ( ) const

Whether the label text can be selected with the mouse.

Default value: false

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_single_line_mode() [1/2]

Glib::PropertyProxy< bool > Gtk::Label::property_single_line_mode ( )

Whether the label is in single line mode.

In single line mode, the height of the label does not depend on the actual text, it is always set to ascent + descent of the font. This can be an advantage in situations where resizing the label because of text changes would be distracting, e.g. in a statusbar.

Default value: false

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_single_line_mode() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gtk::Label::property_single_line_mode ( ) const

Whether the label is in single line mode.

In single line mode, the height of the label does not depend on the actual text, it is always set to ascent + descent of the font. This can be an advantage in situations where resizing the label because of text changes would be distracting, e.g. in a statusbar.

Default value: false

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_tabs() [1/2]

Glib::PropertyProxy< Pango::TabArray > Gtk::Label::property_tabs ( )

Custom tabs for this label.

Since gtkmm 4.8:
Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_tabs() [2/2]

Glib::PropertyProxy_ReadOnly< Pango::TabArray > Gtk::Label::property_tabs ( ) const

Custom tabs for this label.

Since gtkmm 4.8:
Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_use_markup() [1/2]

Glib::PropertyProxy< bool > Gtk::Label::property_use_markup ( )

true if the text of the label includes Pango markup.

See pango_parse_markup().

Default value: false

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_use_markup() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gtk::Label::property_use_markup ( ) const

true if the text of the label includes Pango markup.

See pango_parse_markup().

Default value: false

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_use_underline() [1/2]

Glib::PropertyProxy< bool > Gtk::Label::property_use_underline ( )

true if the text of the label indicates a mnemonic with an _ before the mnemonic character.

Default value: false

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_use_underline() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gtk::Label::property_use_underline ( ) const

true if the text of the label indicates a mnemonic with an _ before the mnemonic character.

Default value: false

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_width_chars() [1/2]

Glib::PropertyProxy< int > Gtk::Label::property_width_chars ( )

The desired width of the label, in characters.

If this property is set to -1, the width will be calculated automatically.

See the section on text layout for details of how property_width_chars() and property_max_width_chars() determine the width of ellipsized and wrapped labels.

Default value: -1

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_width_chars() [2/2]

Glib::PropertyProxy_ReadOnly< int > Gtk::Label::property_width_chars ( ) const

The desired width of the label, in characters.

If this property is set to -1, the width will be calculated automatically.

See the section on text layout for details of how property_width_chars() and property_max_width_chars() determine the width of ellipsized and wrapped labels.

Default value: -1

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_wrap() [1/2]

Glib::PropertyProxy< bool > Gtk::Label::property_wrap ( )

true if the label text will wrap if it gets too wide.

Default value: false

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_wrap() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gtk::Label::property_wrap ( ) const

true if the label text will wrap if it gets too wide.

Default value: false

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_wrap_mode() [1/2]

Glib::PropertyProxy< Pango::WrapMode > Gtk::Label::property_wrap_mode ( )

Controls how the line wrapping is done.

This only affects the formatting if line wrapping is on (see the property_wrap() property). The default is Pango::WrapMode::WORD, which means wrap on word boundaries.

For sizing behavior, also consider the property_natural_wrap_mode() property.

Default value: Pango::WrapMode::WORD

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_wrap_mode() [2/2]

Glib::PropertyProxy_ReadOnly< Pango::WrapMode > Gtk::Label::property_wrap_mode ( ) const

Controls how the line wrapping is done.

This only affects the formatting if line wrapping is on (see the property_wrap() property). The default is Pango::WrapMode::WORD, which means wrap on word boundaries.

For sizing behavior, also consider the property_natural_wrap_mode() property.

Default value: Pango::WrapMode::WORD

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_xalign() [1/2]

Glib::PropertyProxy< float > Gtk::Label::property_xalign ( )

The horizontal alignment of the label text inside its size allocation.

Compare this to Gtk::Widget::property_halign(), which determines how the labels size allocation is positioned in the space available for the label.

Default value: 0.5

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_xalign() [2/2]

Glib::PropertyProxy_ReadOnly< float > Gtk::Label::property_xalign ( ) const

The horizontal alignment of the label text inside its size allocation.

Compare this to Gtk::Widget::property_halign(), which determines how the labels size allocation is positioned in the space available for the label.

Default value: 0.5

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_yalign() [1/2]

Glib::PropertyProxy< float > Gtk::Label::property_yalign ( )

The vertical alignment of the label text inside its size allocation.

Compare this to Gtk::Widget::property_valign(), which determines how the labels size allocation is positioned in the space available for the label.

Default value: 0.5

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_yalign() [2/2]

Glib::PropertyProxy_ReadOnly< float > Gtk::Label::property_yalign ( ) const

The vertical alignment of the label text inside its size allocation.

Compare this to Gtk::Widget::property_valign(), which determines how the labels size allocation is positioned in the space available for the label.

Default value: 0.5

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ select_region() [1/2]

void Gtk::Label::select_region ( int  start_offset)

Selects a range of characters in the label, from start_offset to the end, if the label is selectable.

See gtk_label_set_selectable(). If the label is not selectable, this function has no effect.

Parameters
start_offsetStart offset (in characters not bytes)

◆ select_region() [2/2]

void Gtk::Label::select_region ( int  start_offset,
int  end_offset 
)

Selects a range of characters in the label, if the label is selectable.

See set_selectable(). If the label is not selectable, this function has no effect. If start_offset or end_offset are -1, then the end of the label will be substituted.

Parameters
start_offsetStart offset (in characters not bytes).
end_offsetEnd offset (in characters not bytes).

◆ set_attributes()

void Gtk::Label::set_attributes ( Pango::AttrList &  attrs)

Apply attributes to the label text.

The attributes set with this function will be applied and merged with any other attributes previously effected by way of the property_use_underline() or property_use_markup() properties. While it is not recommended to mix markup strings with manually set attributes, if you must; know that the attributes will be applied to the label after the markup string is parsed.

Parameters
attrsA Pango::AttrList.

◆ set_ellipsize()

void Gtk::Label::set_ellipsize ( Pango::EllipsizeMode  mode)

Sets the mode used to ellipsize the text.

The text will be ellipsized if there is not enough space to render the entire string.

Parameters
modeA Pango::EllipsizeMode.

◆ set_extra_menu()

void Gtk::Label::set_extra_menu ( const Glib::RefPtr< Gio::MenuModel > &  model)

Sets a menu model to add when constructing the context menu for label.

Parameters
modelA Gio::MenuModel.

◆ set_justify()

void Gtk::Label::set_justify ( Justification  jtype)

Sets the alignment of the lines in the text of the label relative to each other.

Gtk::Justification::LEFT is the default value when the widget is first created with new(). If you instead want to set the alignment of the label as a whole, use Gtk::Widget::set_halign() instead. set_justify() has no effect on labels containing only a single line.

Parameters
jtypeA Gtk::Justification.

◆ set_label()

void Gtk::Label::set_label ( const Glib::ustring &  str)

Sets the text of the label.

The label is interpreted as including embedded underlines and/or Pango markup depending on the values of the property_use_underline() and property_use_markup() properties.

Parameters
strThe new text to set for the label.

◆ set_lines()

void Gtk::Label::set_lines ( int  lines)

Sets the number of lines to which an ellipsized, wrapping label should be limited.

This has no effect if the label is not wrapping or ellipsized. Set this to -1 if you don’t want to limit the number of lines.

Parameters
linesThe desired number of lines, or -1.

◆ set_markup()

void Gtk::Label::set_markup ( const Glib::ustring &  str)

Sets the labels text and attributes from markup.

The string must be marked up with Pango markup (see pango_parse_markup()).

If the str is external data, you may need to escape it with Glib::markup_escape_text() or Glib::markup_printf_escaped():

[C example ellipted]

This function will set the property_use_markup() property to true as a side effect.

If you set the label contents using the property_label() property you should also ensure that you set the property_use_markup() property accordingly.

See also: set_text()

Parameters
strA markup string.

◆ set_markup_with_mnemonic()

void Gtk::Label::set_markup_with_mnemonic ( const Glib::ustring &  str)

Sets the labels text, attributes and mnemonic from markup.

Parses str which is marked up with Pango markup (see pango_parse_markup()), setting the label’s text and attribute list based on the parse results. If characters in str are preceded by an underscore, they are underlined indicating that they represent a keyboard accelerator called a mnemonic.

The mnemonic key can be used to activate another widget, chosen automatically, or explicitly using set_mnemonic_widget().

Parameters
strA markup string.

◆ set_max_width_chars()

void Gtk::Label::set_max_width_chars ( int  n_chars)

Sets the desired maximum width in characters of label to n_chars.

Parameters
n_charsThe new desired maximum width, in characters.

◆ set_mnemonic_widget()

void Gtk::Label::set_mnemonic_widget ( Widget widget)

Associate the label with its mnemonic target.

If the label has been set so that it has a mnemonic key (using i.e. set_markup_with_mnemonic(), set_text_with_mnemonic(), new_with_mnemonic() or the [prope.nosp@m.rty@.nosp@m.Gtk.L.nosp@m.abel:use_underline] property) the label can be associated with a widget that is the target of the mnemonic. When the label is inside a widget (like a Gtk::Button or a Gtk::Notebook tab) it is automatically associated with the correct widget, but sometimes (i.e. when the target is a Gtk::Entry next to the label) you need to set it explicitly using this function.

The target widget will be accelerated by emitting the Gtk::Widget::signal_mnemonic_activate() signal on it. The default handler for this signal will activate the widget if there are no mnemonic collisions and toggle focus between the colliding widgets otherwise.

Parameters
widgetThe target Gtk::Widget, or nullptr to unset.

◆ set_natural_wrap_mode()

void Gtk::Label::set_natural_wrap_mode ( NaturalWrapMode  wrap_mode)

Select the line wrapping for the natural size request.

This only affects the natural size requested, for the actual wrapping used, see the property_wrap_mode() property.

Since gtkmm 4.6:
Parameters
wrap_modeThe line wrapping mode.

◆ set_selectable()

void Gtk::Label::set_selectable ( bool  setting = true)

Makes text in the label selectable.

Selectable labels allow the user to select text from the label, for copy-and-paste.

Parameters
settingtrue to allow selecting text in the label.

◆ set_single_line_mode()

void Gtk::Label::set_single_line_mode ( bool  single_line_mode = true)

Sets whether the label is in single line mode.

Parameters
single_line_modetrue if the label should be in single line mode.

◆ set_tabs()

void Gtk::Label::set_tabs ( const Pango::TabArray &  tabs)

Sets the default tab stops for paragraphs in self.

Since gtkmm 4.8:
Parameters
tabsTabs as a Pango::TabArray.

◆ set_text()

void Gtk::Label::set_text ( const Glib::ustring &  str)

Sets the text within the Gtk::Label widget.

It overwrites any text that was there before.

This function will clear any previously set mnemonic accelerators, and set the property_use_underline() property to false as a side effect.

This function will set the property_use_markup() property to false as a side effect.

See also: set_markup()

Parameters
strThe text you want to set.

◆ set_text_with_mnemonic()

void Gtk::Label::set_text_with_mnemonic ( const Glib::ustring &  str)

Sets the label’s text from the string str.

If characters in str are preceded by an underscore, they are underlined indicating that they represent a keyboard accelerator called a mnemonic. The mnemonic key can be used to activate another widget, chosen automatically, or explicitly using set_mnemonic_widget().

Parameters
strA string.

◆ set_use_markup()

void Gtk::Label::set_use_markup ( bool  setting = true)

Sets whether the text of the label contains markup.

See set_markup().

Parameters
settingtrue if the label’s text should be parsed for markup.

◆ set_use_underline()

void Gtk::Label::set_use_underline ( bool  setting = true)

Sets whether underlines in the text indicate mnemonics.

Parameters
settingtrue if underlines in the text indicate mnemonics.

◆ set_width_chars()

void Gtk::Label::set_width_chars ( int  n_chars)

Sets the desired width in characters of label to n_chars.

Parameters
n_charsThe new desired width, in characters.

◆ set_wrap()

void Gtk::Label::set_wrap ( bool  wrap = true)

Toggles line wrapping within the Gtk::Label widget.

true makes it break lines if text exceeds the widget’s size. false lets the text get cut off by the edge of the widget if it exceeds the widget size.

Note that setting line wrapping to true does not make the label wrap at its parent container’s width, because GTK widgets conceptually can’t make their requisition depend on the parent container’s size. For a label that wraps at a specific position, set the label’s width using Gtk::Widget::set_size_request().

Parameters
wrapThe setting.

◆ set_wrap_mode()

void Gtk::Label::set_wrap_mode ( Pango::WrapMode  wrap_mode)

Controls how line wrapping is done.

This only affects the label if line wrapping is on. (See set_wrap()) The default is Pango::WrapMode::WORD which means wrap on word boundaries.

For sizing behavior, also consider the property_natural_wrap_mode() property.

Parameters
wrap_modeThe line wrapping mode.

◆ set_xalign()

void Gtk::Label::set_xalign ( float  xalign)

Sets the xalign of the label.

See the property_xalign() property.

Parameters
xalignThe new xalign value, between 0 and 1.

◆ set_yalign()

void Gtk::Label::set_yalign ( float  yalign)

Sets the yalign of the label.

See the property_yalign() property.

Parameters
yalignThe new yalign value, between 0 and 1.

◆ signal_activate_link()

Glib::SignalProxy< bool(const Glib::ustring &)> Gtk::Label::signal_activate_link ( )
Slot Prototype:
bool on_my_activate_link(const Glib::ustring& uri)

Flags: Run Last

Gets emitted to activate a URI.

Applications may connect to it to override the default behaviour, which is to call Gtk::FileLauncher::launch().

Parameters
uriThe URI that is activated.
Returns
true if the link has been activated.

Friends And Related Symbol Documentation

◆ wrap()

Gtk::Label * wrap ( GtkLabel object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.