Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Gtk::AccelLabel Class Reference

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

`#include <inti/gtk/accellabel.h>`

Inheritance diagram for Inti::Gtk::AccelLabel:

List of all members.

## Public Member Functions

Constructors

- AccelLabel ()
    Construct an empty accelerator label.
- AccelLabel (const String &str, bool use_underline=false)
    Construct an accelerator label.
- virtual ~AccelLabel ()
    Destructor.

Accessors

- GtkAccelLabel * gtk_accel_label () const
    Get a pointer to the GtkAccelLabel structure.
- GtkAccelLabelClass * gtk_accel_label_class () const
    Get a pointer to the GtkAccelLabelClass structure.
- operator GtkAccelLabel * () const
    Conversion operator; safely converts an AccelLabel to a GtkAccelLabel pointer.
- Widget * get_accel_widget () const
    Fetches the widget monitored by this accelerator label (See set_accel_widget()).
- unsigned int get_accel_width () const
    Returns the width needed to display the accelerator key(s).

Methods

- void set_accel_widget (Widget &accel_widget)
    Sets the widget to be monitored by this accelerator label.
- void set_accel_closure (GClosure *accel_closure)
    Sets the closure to be monitored by this accelerator label.
- bool refetch ()
    Recreates the string representing the accelerator keys.

Property Proxies

- const AccelClosurePropertyProxy prop_accel_closure ()
    Set the closure to be monitored by this accelerator label (GClosure* : Read / Write).
- const AccelWidgetPropertyProxy prop_accel_widget ()
    Set the widget to be monitored by this accelerator label (Widget* : Read / Write).

## Protected Member Functions

Constructors

- AccelLabel (GtkAccelLabel *accel_label, bool reference=false)
    Construct a new AccelLabel from an existing GtkAccelLabel.

## 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));

## Constructor & Destructor Documentation

Inti::Gtk::AccelLabel::AccelLabel | ( | GtkAccelLabel * | accel_label,
|  | bool | reference = false
| ) | `[explicit, protected]`

  | Construct a new AccelLabel from an existing GtkAccelLabel. Parameters:
  accel_label | A pointer to a GtkAccelLabel.
  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).

Inti::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* Inti::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 Inti::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 Inti::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 Inti::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 Inti::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:

- accellabel.h

Main Page - Footer