Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::Gtk::AccelLabel Class Reference

A GtkAccelLabel C++ wrapper class. More...

#include <xfc/gtk/accellabel.hh>

Inheritance diagram for Xfc::Gtk::AccelLabel:

Xfc::Gtk::Label Xfc::Gtk::Misc Xfc::Gtk::Widget Xfc::Gtk::Object Xfc::Atk::Implementor Xfc::G::Object Xfc::G::TypeInterface Xfc::G::TypeInstance Xfc::G::TypeInstance Xfc::Trackable Xfc::Trackable List of all members.

Public Member Functions

Constructors
Accessors
Methods

Protected Member Functions

Constructors

Detailed Description

A GtkAccelLabel C++ wrapper class.

The AccelLabel widget is a subclass of Label that also displays an accelerator key on the right of the label text, e.g. 'Ctl+S'. It is commonly used in menus to show the keyboard short-cuts for commands. The accelerator key to display is not set explicitly. Instead, the AccelLabel displays the accelerators which have been added to a particular widget. This widget is set by calling set_accel_widget().

For example, a MenuItem widget may have an accelerator added to emit the "activate" signal when the 'Ctl+S' key combination is pressed. An AccelLabel is created and added to the MenuItem, and set_accel_widget() is called with the MenuItem as its argument. The AccelLabel will now display 'Ctl+S' after its label.

Note that creating a MenuItem with a label (or CheckMenuItem and RadioMenuItem) automatically adds an AccelLabel to the MenuItem and calls set_accel_widget() to set it up for you. An AccelLabel will only display accelerators which have Gtk::ACCEL_VISIBLE set. An AccelLabel can display multiple accelerators and even signal names, though it is almost always used to display just one accelerator key.

Example: Creating a simple menu item with an accelerator key.

    // Create a AccelGroup and add it to the window.
    Pointer<Gtk::AccelGroup> accel_group;
    window->add_accel_group(accel_group):
   
    // Create the menu item.
    Gtk::MenuItem *save_item = new Gtk::MenuItem("Save");
    menu->add(*save_item);
    save_item->show();
   
    // Now add the accelerator to the MenuItem.
    save_item->add_accelerator("activate", *accel_group, AccelKey(GDK_s, Gdk::CONTROL_MASK));

See also: the AccelLabel Widget HOWTO.


Constructor & Destructor Documentation

Xfc::Gtk::AccelLabel::AccelLabel GtkAccelLabel *  accel_label,
bool  owns_reference = false
[explicit, protected]
 

Construct a new AccelLabel from an existing GtkAccelLabel.

Parameters:
accel_label A pointer to a GtkAccelLabel.
owns_reference Set false if the initial reference count is floating, set true if it's not.
The accel_label can be a newly created GtkAccelLabel or an existing GtkAccelLabel. (see G::Object::Object).

Xfc::Gtk::AccelLabel::AccelLabel const String str,
bool  use_underline = false
[explicit]
 

Construct an accelerator label.

Parameters:
str The label string.
use_underline Set true if label contains a mnemonic character.


Member Function Documentation

Widget* Xfc::Gtk::AccelLabel::get_accel_widget  )  const
 

Fetches the widget monitored by this accelerator label (See set_accel_widget()).

Returns:
The widget monitored by this accelerator label.

unsigned int Xfc::Gtk::AccelLabel::get_accel_width  )  const
 

Returns the width needed to display the accelerator key(s).

Returns:
The width needed to display the accelerator key(s).
This is used by menus to align all of the MenuItem widgets, and shouldn't be needed by applications.

bool Xfc::Gtk::AccelLabel::refetch  ) 
 

Recreates the string representing the accelerator keys.

Returns:
Always returns false.
This should not be needed since the string is automatically updated whenever accelerators are added or removed from the associated widget.

void Xfc::Gtk::AccelLabel::set_accel_closure GClosure *  accel_closure  ) 
 

Sets the closure to be monitored by this accelerator label.

Parameters:
accel_closure The closure to monitor for accelerator changes.
The closure must be connected to an accelerator group; see Gtk::AccelGroup::connect().

void Xfc::Gtk::AccelLabel::set_accel_widget Widget accel_widget  ) 
 

Sets the widget to be monitored by this accelerator label.

Parameters:
accel_widget The widget to be monitored.


The documentation for this class was generated from the following file: Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC 4.3