Class: Gtk::Label
- Inherits:
-
Object
- Object
- Gtk::Label
- Defined in:
- (unknown)
Instance Method Summary collapse
-
#angle ⇒ Float
The angle that the baseline of the label makes with the horizontal, in degrees, measured counterclockwise.
-
#angle=(angle) ⇒ Float
The angle that the baseline of the label makes with the horizontal, in degrees, measured counterclockwise.
-
#attributes ⇒ Pango::AttrList
Attributes.
- #attributes=(attributes) ⇒ Pango::AttrList
-
#current_uri ⇒ String
Returns the URI for the currently active link in the label.
-
#cursor_position ⇒ Integer
Cursor-position.
- #cursor_position=(cursor_position) ⇒ Integer
-
#ellipsize ⇒ Pango::EllipsizeMode
The preferred place to ellipsize the string, if the label does not have enough room to display the entire string, specified as a Pango::EllipsizeMode.
-
#ellipsize=(ellipsize) ⇒ Pango::EllipsizeMode
The preferred place to ellipsize the string, if the label does not have enough room to display the entire string, specified as a Pango::EllipsizeMode.
-
#get_layout_offsets(x, y) ⇒ nil
Obtains the coordinates where the label will draw the Pango::Layout representing the text in the label; useful to convert mouse events into coordinates inside the Pango::Layout, e.g.
-
#get_selection_bounds(start, end) ⇒ TrueClass
Gets the selected range of characters in the label, returning true if there’s a selection.
-
#justify ⇒ Gtk::Justification
Justify.
- #justify=(justify) ⇒ Gtk::Justification
-
#label ⇒ String
The contents of the label.
-
#label=(label) ⇒ String
The contents of the label.
-
#layout ⇒ Pango::Layout
Gets the Pango::Layout used to display the label.
-
#line_wrap ⇒ TrueClass
Returns whether lines in the label are automatically wrapped.
-
#line_wrap=(wrap) ⇒ nil
Toggles line wrapping within the Gtk::Label widget.
-
#line_wrap_mode ⇒ Pango::WrapMode
Returns line wrap mode used by the label.
-
#line_wrap_mode=(wrap_mode) ⇒ nil
If line wrapping is on (see gtk_label_set_line_wrap()) this controls how the line wrapping is done.
-
#lines ⇒ Integer
The number of lines to which an ellipsized, wrapping label should be limited.
-
#lines=(lines) ⇒ Integer
The number of lines to which an ellipsized, wrapping label should be limited.
-
#markup=(str) ⇒ nil
Parses str which is marked up with the [Pango text markup language], setting the label’s text and attribute list based on the parse results.
-
#markup_with_mnemonic=(str) ⇒ nil
Parses str which is marked up with the [Pango text markup language], setting the label’s text and attribute list based on the parse results.
-
#max_width_chars ⇒ Integer
The desired maximum width of the label, in characters.
-
#max_width_chars=(max_width_chars) ⇒ Integer
The desired maximum width of the label, in characters.
-
#mnemonic_keyval ⇒ Integer
Mnemonic-keyval.
- #mnemonic_keyval=(mnemonic_keyval) ⇒ Integer
-
#mnemonic_widget ⇒ Gtk::Widget
Mnemonic-widget.
- #mnemonic_widget=(mnemonic_widget) ⇒ Gtk::Widget
-
#new(str) ⇒ Gtk::Widget
Creates a new label with the given text inside it.
-
#new_with_mnemonic(str) ⇒ Gtk::Widget
Creates a new Gtk::Label, containing the text in str.
-
#pattern=(pattern) ⇒ String
Pattern.
-
#select_region(start_offset, end_offset) ⇒ nil
Selects a range of characters in the label, if the label is selectable.
-
#selectable ⇒ TrueClass
Gets the value set by gtk_label_set_selectable().
- #selectable=(selectable) ⇒ TrueClass
-
#selectable? ⇒ TrueClass
Selectable.
-
#selection_bound ⇒ Integer
Selection-bound.
- #selection_bound=(selection_bound) ⇒ Integer
-
#single_line_mode ⇒ TrueClass
Returns whether the label is in single line mode.
-
#single_line_mode=(single_line_mode) ⇒ TrueClass
Whether the label is in single line mode.
-
#single_line_mode? ⇒ TrueClass
Whether the label is in single line mode.
-
#text ⇒ String
Fetches the text from a label widget, as displayed on the screen.
-
#text=(str) ⇒ nil
Sets the text within the Gtk::Label widget.
-
#text_with_mnemonic=(str) ⇒ nil
Sets the label’s text from the string str.
-
#track_visited_links ⇒ TrueClass
Returns whether the label is currently keeping track of clicked links.
-
#track_visited_links=(track_visited_links) ⇒ TrueClass
Set this property to true to make the label track which links have been visited.
-
#track_visited_links? ⇒ TrueClass
Set this property to true to make the label track which links have been visited.
-
#use_markup ⇒ TrueClass
Returns whether the label’s text is interpreted as marked up with the [Pango text markup language].
- #use_markup=(use_markup) ⇒ TrueClass
-
#use_markup? ⇒ TrueClass
Use-markup.
-
#use_underline ⇒ TrueClass
Returns whether an embedded underline in the label indicates a mnemonic.
- #use_underline=(use_underline) ⇒ TrueClass
-
#use_underline? ⇒ TrueClass
Use-underline.
-
#width_chars ⇒ Integer
The desired width of the label, in characters.
-
#width_chars=(width_chars) ⇒ Integer
The desired width of the label, in characters.
- #wrap=(wrap) ⇒ TrueClass
-
#wrap? ⇒ TrueClass
Wrap.
-
#wrap_mode ⇒ Pango::WrapMode
If line wrapping is on (see the Gtk::Label:wrap property) this controls how the line wrapping is done.
-
#wrap_mode=(wrap_mode) ⇒ Pango::WrapMode
If line wrapping is on (see the Gtk::Label:wrap property) this controls how the line wrapping is done.
-
#xalign ⇒ Gtk::gfloat
The xalign property determines the horizontal aligment of the label text inside the labels size allocation.
-
#xalign=(xalign) ⇒ Gtk::gfloat
The xalign property determines the horizontal aligment of the label text inside the labels size allocation.
-
#yalign ⇒ Gtk::gfloat
The yalign property determines the vertical aligment of the label text inside the labels size allocation.
-
#yalign=(yalign) ⇒ Gtk::gfloat
The yalign property determines the vertical aligment of the label text inside the labels size allocation.
Instance Method Details
#angle ⇒ Float
The angle that the baseline of the label makes with the horizontal, in degrees, measured counterclockwise. An angle of 90 reads from from bottom to top, an angle of 270, from top to bottom. Ignored if the label is selectable.
#angle=(angle) ⇒ Float
The angle that the baseline of the label makes with the horizontal, in degrees, measured counterclockwise. An angle of 90 reads from from bottom to top, an angle of 270, from top to bottom. Ignored if the label is selectable.
#attributes ⇒ Pango::AttrList
Returns attributes.
#attributes=(attributes) ⇒ Pango::AttrList
#current_uri ⇒ String
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 Gtk::Label::activate-link handler or for use in a Gtk::Widget::query-tooltip handler.
#cursor_position ⇒ Integer
Returns cursor-position.
#cursor_position=(cursor_position) ⇒ Integer
#ellipsize ⇒ Pango::EllipsizeMode
The preferred place to ellipsize the string, if the label does not have enough room to display the entire string, specified as a Pango::EllipsizeMode.
Note that setting this property to a value other than %PANGO_ELLIPSIZE_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::Notebook 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().
#ellipsize=(ellipsize) ⇒ Pango::EllipsizeMode
The preferred place to ellipsize the string, if the label does not have enough room to display the entire string, specified as a Pango::EllipsizeMode.
Note that setting this property to a value other than %PANGO_ELLIPSIZE_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::Notebook 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().
#get_layout_offsets(x, y) ⇒ nil
Obtains the coordinates where the label will draw the Pango::Layout representing the text in the label; 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. Of course you will need to create a Gtk::EventBox to receive the events, and pack the label inside it, since labels are windowless (they return false from gtk_widget_get_has_window()). Remember when using the Pango::Layout functions you need to convert to and from pixels using PANGO_PIXELS() or #PANGO_SCALE.
#get_selection_bounds(start, end) ⇒ TrueClass
Gets the selected range of characters in the label, returning true if there’s a selection.
#justify ⇒ Gtk::Justification
Returns justify.
#justify=(justify) ⇒ Gtk::Justification
#label ⇒ String
The contents of the label.
If the string contains [Pango XML markup], you will have to set the Gtk::Label: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 Gtk::Label:use-markup property at the same time.
If the string contains underlines acting as mnemonics, you will have to set the Gtk::Label:use-underline property to true in order for the label to display them.
#label=(label) ⇒ String
The contents of the label.
If the string contains [Pango XML markup], you will have to set the Gtk::Label: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 Gtk::Label:use-markup property at the same time.
If the string contains underlines acting as mnemonics, you will have to set the Gtk::Label:use-underline property to true in order for the label to display them.
#layout ⇒ Pango::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 gtk_label_get_layout_offsets(). The returned layout is owned by the label so need not be freed by the caller. The label is free to recreate its layout at any time, so it should be considered read-only.
#line_wrap ⇒ TrueClass
Returns whether lines in the label are automatically wrapped. See gtk_label_set_line_wrap().
#line_wrap=(wrap) ⇒ nil
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().
#line_wrap_mode ⇒ Pango::WrapMode
Returns line wrap mode used by the label. See gtk_label_set_line_wrap_mode().
#line_wrap_mode=(wrap_mode) ⇒ nil
If line wrapping is on (see gtk_label_set_line_wrap()) this controls how the line wrapping is done. The default is %PANGO_WRAP_WORD which means wrap on word boundaries.
#lines ⇒ Integer
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.
#lines=(lines) ⇒ Integer
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.
#markup=(str) ⇒ nil
Parses str which is marked up with the [Pango text markup language], setting the label’s text and attribute list based on the parse results.
If the str is external data, you may need to escape it with g_markup_escape_text() or g_markup_printf_escaped():
GtkWidget *label = gtk_label_new (NULL);
const char *str = "some text";
const char *format = "<span style=\"italic\">\%s</span>";
char *markup;
markup = g_markup_printf_escaped (format, str);
gtk_label_set_markup (GTK_LABEL (label), markup);
g_free (markup);
This function will set the Gtk::Label:use-markup property to true as a side effect.
If you set the label contents using the Gtk::Label:label property you should also ensure that you set the Gtk::Label:use-markup property accordingly.
See also: gtk_label_set_text()
#markup_with_mnemonic=(str) ⇒ nil
Parses str which is marked up with the [Pango text markup language], 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 gtk_label_set_mnemonic_widget().
#max_width_chars ⇒ Integer
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 Gtk::Label:width-chars and #GtkLabel:max-width-chars determine the width of ellipsized and wrapped labels.
#max_width_chars=(max_width_chars) ⇒ Integer
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 Gtk::Label:width-chars and #GtkLabel:max-width-chars determine the width of ellipsized and wrapped labels.
#mnemonic_keyval ⇒ Integer
Returns mnemonic-keyval.
#mnemonic_keyval=(mnemonic_keyval) ⇒ Integer
#mnemonic_widget ⇒ Gtk::Widget
Returns mnemonic-widget.
#mnemonic_widget=(mnemonic_widget) ⇒ Gtk::Widget
#new(str) ⇒ Gtk::Widget
Creates a new label with the given text inside it. You can pass nil to get an empty label widget.
#new_with_mnemonic(str) ⇒ Gtk::Widget
Creates a new Gtk::Label, containing the text in str.
If characters in str are preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use ‘__’ (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. The mnemonic key can be used to activate another widget, chosen automatically, or explicitly using gtk_label_set_mnemonic_widget().
If gtk_label_set_mnemonic_widget() is not called, then the first activatable ancestor of the Gtk::Label will be chosen as the mnemonic widget. For instance, if the label is inside a button or menu item, the button or menu item will automatically become the mnemonic widget and be activated by the mnemonic.
#pattern=(pattern) ⇒ String
Returns pattern.
#select_region(start_offset, end_offset) ⇒ nil
Selects a range of characters in the label, if the label is selectable. See gtk_label_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.
#selectable ⇒ TrueClass
Gets the value set by gtk_label_set_selectable().
#selectable=(selectable) ⇒ TrueClass
#selectable? ⇒ TrueClass
Returns selectable.
#selection_bound ⇒ Integer
Returns selection-bound.
#selection_bound=(selection_bound) ⇒ Integer
#single_line_mode ⇒ TrueClass
Returns whether the label is in single line mode.
#single_line_mode=(single_line_mode) ⇒ TrueClass
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.
#single_line_mode? ⇒ TrueClass
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.
#text ⇒ String
Fetches the text from a label widget, as displayed on the screen. This does not include any embedded underlines indicating mnemonics or Pango markup. (See gtk_label_get_label())
#text=(str) ⇒ nil
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 Gtk::Label:use-underline property to false as a side effect.
This function will set the Gtk::Label:use-markup property to false as a side effect.
See also: gtk_label_set_markup()
#text_with_mnemonic=(str) ⇒ nil
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 gtk_label_set_mnemonic_widget().
#track_visited_links ⇒ TrueClass
Returns whether the label is currently keeping track of clicked links.
#track_visited_links=(track_visited_links) ⇒ TrueClass
Set this property to true to make the label track which links have been visited. It will then apply the #GTK_STATE_FLAG_VISITED when rendering this link, in addition to #GTK_STATE_FLAG_LINK.
#track_visited_links? ⇒ TrueClass
Set this property to true to make the label track which links have been visited. It will then apply the #GTK_STATE_FLAG_VISITED when rendering this link, in addition to #GTK_STATE_FLAG_LINK.
#use_markup ⇒ TrueClass
Returns whether the label’s text is interpreted as marked up with the [Pango text markup language]. See gtk_label_set_use_markup ().
#use_markup=(use_markup) ⇒ TrueClass
#use_markup? ⇒ TrueClass
Returns use-markup.
#use_underline ⇒ TrueClass
Returns whether an embedded underline in the label indicates a mnemonic. See gtk_label_set_use_underline().
#use_underline=(use_underline) ⇒ TrueClass
#use_underline? ⇒ TrueClass
Returns use-underline.
#width_chars ⇒ Integer
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 Gtk::Label:width-chars and #GtkLabel:max-width-chars determine the width of ellipsized and wrapped labels.
#width_chars=(width_chars) ⇒ Integer
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 Gtk::Label:width-chars and #GtkLabel:max-width-chars determine the width of ellipsized and wrapped labels.
#wrap=(wrap) ⇒ TrueClass
#wrap? ⇒ TrueClass
Returns wrap.
#wrap_mode ⇒ Pango::WrapMode
If line wrapping is on (see the Gtk::Label:wrap property) this controls how the line wrapping is done. The default is %PANGO_WRAP_WORD, which means wrap on word boundaries.
#wrap_mode=(wrap_mode) ⇒ Pango::WrapMode
If line wrapping is on (see the Gtk::Label:wrap property) this controls how the line wrapping is done. The default is %PANGO_WRAP_WORD, which means wrap on word boundaries.
#xalign ⇒ Gtk::gfloat
The xalign property determines the horizontal aligment of the label text inside the labels size allocation. Compare this to Gtk::Widget:halign, which determines how the labels size allocation is positioned in the space available for the label.
#xalign=(xalign) ⇒ Gtk::gfloat
The xalign property determines the horizontal aligment of the label text inside the labels size allocation. Compare this to Gtk::Widget:halign, which determines how the labels size allocation is positioned in the space available for the label.
#yalign ⇒ Gtk::gfloat
The yalign property determines the vertical aligment of the label text inside the labels size allocation. Compare this to Gtk::Widget:valign, which determines how the labels size allocation is positioned in the space available for the label.
#yalign=(yalign) ⇒ Gtk::gfloat
The yalign property determines the vertical aligment of the label text inside the labels size allocation. Compare this to Gtk::Widget:valign, which determines how the labels size allocation is positioned in the space available for the label.