Google

logo top
Main Page   Widgets   Namespaces   Book  

Gtk::Label Class Reference
[Widgets]

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

Inheritance diagram for Gtk::Label:

Inheritance graph
[legend]
List of all members.

Public Methods

virtual ~Label ()
GtkLabel* gobj ()
const GtkLabel* gobj () const
 Label ()
 Label (const Glib::ustring& label, bool mnemonic=false)
 Label (const Glib::ustring& label, float xalign, float yalign, bool mnemonic=false)
 This constructor is a shortcut for often used code when you want to create a label with alignment different than default one.

 Label (const Glib::ustring& label, AlignmentEnum xalign, AlignmentEnum yalign=ALIGN_CENTER, bool mnemonic=false)
 This constructor is a shortcut for often used code when you want to create a label with alignment different than default one.

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 widget, as displayed on the screen.

void set_attributes (Pango::AttrList& attrs)
 Sets a Pango::AttrList; the attributes in the list are applied to the label text.

Pango::AttrList get_attributes ()
 Gets the attribute list that was set on the label using set_attributes(), if any.

void set_label (const Glib::ustring& str)
 Sets the text of the label.

Glib::ustring get_label () const
 Fetches the text from a label widget including any embedded underlines indicating mnemonics and Pango markup.

void set_markup (const Glib::ustring& str)
 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.

void set_use_markup (bool setting=true)
 Sets whether the text of the label contains markup in Pango's text markup language.

bool get_use_markup () const
 Returns whether the label's text is interpreted as marked up with the Pango text markup language.

void set_use_underline (bool setting=true)
 If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.

bool get_use_underline () const
 Returns whether an embedded underline in the label indicates a mnemonic.

void set_markup_with_mnemonic (const Glib::ustring& str)
 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.

guint get_mnemonic_keyval () const
 If the label has been set so that it has an mnemonic key this function returns the keyval used for the mnemonic accelerator.

void set_mnemonic_widget (Widget& widget)
 If the label has been set so that it has an mnemonic key (using i.e. set_markup_with_mnemonic(), set_text_with_mnemonic(), new_with_mnemonic() or the "use_underline" property) the label can be associated with a widget that is the target of the mnemonic.

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_pattern (const Glib::ustring& pattern)
void set_line_wrap (bool wrap=true)
 Toggles line wrapping within the Gtk::Label widget.

bool get_line_wrap () const
 Returns whether lines in the label are automatically wrapped.

void set_selectable (bool setting=true)
 Selectable labels allow the user to select text from the label, for copy-and-paste.

bool get_selectable () const
 Gets the value set by set_selectable().

void select_region (int start_offset, int end_offset)
 Selects a range of characters in the label, if the label is selectable.

bool get_selection_bounds (int& start, int& end) const
 Gets the selected range of characters in the label, returning true if there's a selection.

Glib::RefPtr<Pango::Layoutget_layout ()
 Gets the Pango::Layout used to display the label.

Glib::RefPtr<const Pango::Layoutget_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 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.

Glib::SignalProxy3< void,
MovementStep, int, bool > 
signal_move_cursor ()
Glib::SignalProxy0<void> signal_copy_clipboard ()
Glib::SignalProxy1< void,
Menu* > 
signal_populate_popup ()
Glib::PropertyProxy<Glib::ustringproperty_label ()
Glib::PropertyProxy<Pango::AttrListproperty_attributes ()
Glib::PropertyProxy<bool> property_use_markup ()
Glib::PropertyProxy<bool> property_use_underline ()
Glib::PropertyProxy<Justificationproperty_justify ()
Glib::PropertyProxy_WriteOnly<
Glib::ustring
property_pattern ()
Glib::PropertyProxy<bool> property_wrap ()
Glib::PropertyProxy<bool> property_selectable ()
Glib::PropertyProxy_ReadOnly<
guint > 
property_mnemonic_keyval ()
Glib::PropertyProxy<Widget*> property_mnemonic_widget ()
Glib::PropertyProxy_ReadOnly<
int > 
property_cursor_position ()
Glib::PropertyProxy_ReadOnly<
int > 
property_selection_bound ()

Protected Methods

virtual void on_move_cursor (MovementStep step, int count, bool extend_selection)
virtual void on_copy_clipboard ()
virtual void on_populate_popup (Menu* menu)

Related Functions

(Note that these are not member functions.)

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

Detailed Description

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

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


Constructor & Destructor Documentation

virtual Gtk::Label::~Label (   [virtual]
 

Gtk::Label::Label (  
 

Gtk::Label::Label ( const Glib::ustring   label,
bool    mnemonic = false
[explicit]
 

Gtk::Label::Label ( const Glib::ustring   label,
float    xalign,
float    yalign,
bool    mnemonic = false
 

This constructor is a shortcut for often used code when you want to create a label with alignment different than default one.

 Gtk::Label label(text, x, y, mnemonic);
 
is equivalent to:
 Gtk::Label label(text, mnemonic);
 label.set_alignment(x, y);
 

Gtk::Label::Label ( const Glib::ustring   label,
AlignmentEnum    xalign,
AlignmentEnum    yalign = ALIGN_CENTER,
bool    mnemonic = false
 

This constructor is a shortcut for often used code when you want to create a label with alignment different than default one.

 Gtk::Label label(text, x, y, mnemonic);
 
is equivalent to:
 Gtk::Label label(text, mnemonic);
 label.set_alignment(x, y);
 


Member Function Documentation

Pango::AttrList Gtk::Label::get_attributes (  
 

Gets the attribute list that was set on the label using set_attributes(), if any.

This function does not reflect attributes that come from the labels markup (see set_markup()). If you want to get the effective attributes for the label, use pango_layout_get_attribute (gtk_label_get_layout (label)).

Returns:
The attribute list, or 0 if none was set.

Justification Gtk::Label::get_justify (   const
 

Returns the justification of the label.

See set_justify().

Returns:
Gtk::Justification.

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

Fetches the text from a label widget including any embedded underlines indicating mnemonics and Pango markup.

(See get_text()).

Returns:
The text of the label widget..

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.

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.

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

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 a Gtk::NO_WINDOW widget. Remember when using the Pango::Layout functions you need to convert to and from pixels using PANGO_PIXELS() or Pango::SCALE.

Parameters:
x Location to store X offset of layout, or 0.
y Location to store Y offset of layout, or 0.

bool Gtk::Label::get_line_wrap (   const
 

Returns whether lines in the label are automatically wrapped.

See set_line_wrap().

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

guint Gtk::Label::get_mnemonic_keyval (   const
 

If the label has been set so that it has an mnemonic key this function returns the keyval used for the mnemonic accelerator.

If there is no mnemonic set up it returns #GDK_VoidSymbol.

Returns:
GDK keyval usable for accelerators, or #GDK_VoidSymbol.

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 0 if none has been set and the default algorithm will be used.

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 0 if none has been set and the default algorithm will be used.

bool Gtk::Label::get_selectable (   const
 

Gets the value set by set_selectable().

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

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

Gets the selected range of characters in the label, returning true if there's a selection.

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

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

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 get_label())

Returns:
The text in the label widget.

bool Gtk::Label::get_use_markup (   const
 

Returns whether the label's text is interpreted as marked up with the Pango text markup language.

See set_use_markup().

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

bool Gtk::Label::get_use_underline (   const
 

Returns whether an embedded underline in the label indicates a mnemonic.

See set_use_underline().

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

const GtkLabel* Gtk::Label::gobj (   const [inline]
 

Reimplemented from Gtk::Misc.

Reimplemented in Gtk::AccelLabel.

GtkLabel* Gtk::Label::gobj (   [inline]
 

Reimplemented from Gtk::Misc.

Reimplemented in Gtk::AccelLabel.

virtual void Gtk::Label::on_copy_clipboard (   [protected, virtual]
 

virtual void Gtk::Label::on_move_cursor ( MovementStep    step,
int    count,
bool    extend_selection
[protected, virtual]
 

virtual void Gtk::Label::on_populate_popup ( Menu   menu [protected, virtual]
 

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

Glib::PropertyProxy_ReadOnly<int> Gtk::Label::property_cursor_position (  
 

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

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

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

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

Glib::PropertyProxy_WriteOnly<Glib::ustring> Gtk::Label::property_pattern (  
 

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

Glib::PropertyProxy_ReadOnly<int> Gtk::Label::property_selection_bound (  
 

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

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

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

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_offset Start offset (in characters not bytes).
end_offset End offset (in characters not bytes).

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

Sets a Pango::AttrList; the attributes in the list are applied to the label text.

The attributes set with this function will be ignored if the "use_underline" property or the "use_markup" property is true.

Parameters:
attrs A Pango::AttrList.

void Gtk::Label::set_justify ( Justification    jtype
 

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

Gtk::JUSTIFY_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::Misc::set_alignment() instead. set_justify() has no effect on labels containing only a single line.

Parameters:
jtype A Gtk::Justification.

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 label->use_underline and label->use_markup.

Parameters:
str The new text to set for the label.

void Gtk::Label::set_line_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.

Parameters:
wrap The setting.

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

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.

Parameters:
str A markup string (see Pango markup format).

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

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 set_mnemonic_widget().

Parameters:
str A markup string (see Pango markup format).

void Gtk::Label::set_mnemonic_widget ( Widget   widget
 

If the label has been set so that it has an mnemonic key (using i.e. set_markup_with_mnemonic(), set_text_with_mnemonic(), new_with_mnemonic() or the "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 "mnemonic_activate" 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:
widget The target Gtk::Widget.

void Gtk::Label::set_pattern ( const Glib::ustring   pattern
 

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

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

Parameters:
setting true to allow selecting text in the label.

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 will also clear any previously set mnemonic accelerators.

Parameters:
str The text you want to set.

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:
str A string.

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

Sets whether the text of the label contains markup in Pango's text markup language.

See set_markup().

Parameters:
setting true if the label's text should be parsed for markup.

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

If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.

Parameters:
setting true if underlines in the text indicate mnemonics.

Glib::SignalProxy0<void> Gtk::Label::signal_copy_clipboard (  
 

Prototype:
void copy_clipboard()

Glib::SignalProxy3<void,MovementStep,int,bool> Gtk::Label::signal_move_cursor (  
 

Prototype:
void move_cursor(MovementStep step, int count, bool extend_selection)

Glib::SignalProxy1<void,Menu*> Gtk::Label::signal_populate_popup (  
 

Prototype:
void populate_popup(Menu* menu)


Friends And Related Function Documentation

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


The documentation for this class was generated from the following file:
Generated for gtkmm by Doxygen 1.3-rc1 © 1997-2001