Xfce Foundation Classes
Main Page | Index | Namespace List | Alphabetical List | Class List | File List

# Xfc::Gtk::StockItem Class Reference

A GtkStockItem C++ wrapper class. More...

`#include <xfc/gtk/stock.hh>`

Inheritance diagram for Xfc::Gtk::StockItem:

List of all members.

## Public Member Functions

Constructors

- StockItem ()
    Constructs an empty StockItem to initialize with values by calling Gtk::Stock::lookup().
- StockItem (const StockId &stock_id, const String &label, const String &domain=0)
    Constructs a new StockItem initialized with the specified values; This item should be registered with Gtk::Stock::add().
- StockItem (const StockId &stock_id, const String &label, const AccelKey &accel_key, const String &domain=0)
    Constructs a new StockItem initialized with the specified values; This item should be registered with Gtk::Stock::add().
- StockItem (const StockId &stock_id, const String &label, Gdk::ModifierTypeField modifier, unsigned int key, const String &domain=0)
    Constructs a new StockItem initialized with the specified values; This item should be registered with Gtk::Stock::add().
- StockItem (const StockItem &src)
    Copy constructor.
- ~StockItem ()
    Destructor.
- StockItem & operator= (const StockItem &src)
    Assignment operator.

Accessors

- GtkStockItem * gtk_stock_item () const
    Get a pointer to the GtkStockItem structure.
- StockId stock_id () const
    Returns the stock_id for the stock item.
- const char * label () const
    Returns the user-visible label for the stock item.
- Gdk::ModifierTypeField modifier () const
    Gets the modifier combination of the keyboard accelerator for the stock item.
- unsigned int keyval () const
    Gets the key value of the keyboard accelerator for the stock item.
- const char * translation_domain () const
    Returns the translation domain for the stock item.
- AccelKey accel_key () const
    Returns an AccelKey object for the keyboard accelerator.

Methods

- void set (const StockId &stock_id, const String &label, Gdk::ModifierTypeField modifier, unsigned int key, const String &domain)
    Sets the values for the stock item.

## Detailed Description

A GtkStockItem C++ wrapper class.

Stock items represent commonly-used menu or toolbar items such as "Open" or "Exit". Each stock item is identified by a stock ID; stock IDs are just strings. GTK+ provides macros, such as GTK_STOCK_OPEN, to avoid typing mistakes in the strings. XFC wraps the stock ID's in a class called Gtk::StockId. As well as providing constructors, StockId provides convenient ready-to-use static StockId objects, one for each pre-registered GTK+ stock ID, such as Gtk::StockId::OPEN and Gtk::StockId::QUIT.

Applications can register their own stock items in addition to those built-in to GTK+. Each stock ID can be associated with a StockItem, which contains the user-visible label, keyboard accelerator, and translation domain of the menu or toolbar item; and/or with an icon stored in an IconFactory. See IconFactory for more information on stock icons. The connection between a StockItem and stock icons is purely conventional (by virtue of using the same stock ID); it's possible to register a stock item but no icon, and vice versa (see Gtk::StockId).

StockItem is derived from Xfc::StackObject, a base class that can only be created on the stack and not dynamically on the heap. In the <demo/gfc-demo> source directory the application.cc file has an example that registers a new stock item and the stockbrowser.cc file has an example that retrieves the values for registered stock items.

## Constructor & Destructor Documentation

Xfc::Gtk::StockItem::StockItem | ( | const StockId & | stock_id,
|  | const String & | label,
|  | const String & | domain = `0`
| ) |

Constructs a new StockItem initialized with the specified values; This item should be registered with Gtk::Stock::add().

Parameters:

  | stock_id | The string identifier for the stock item.
  | label | The user-visible label.
  | domain | The translation domain.

If the item already exists with the same stock ID as one of the items, the old item gets replaced. This stock item will have no accelerator key.

Xfc::Gtk::StockItem::StockItem | ( | const StockId & | stock_id,
|  | const String & | label,
|  | const AccelKey & | accel_key,
|  | const String & | domain = `0`
| ) |

Constructs a new StockItem initialized with the specified values; This item should be registered with Gtk::Stock::add().

Parameters:

  | stock_id | The string identifier for the stock item.
  | label | The user-visible label.
  | accel_key | An AccelKey that holds the accelerator modifier and key values to set.
  | domain | The translation domain.

If the item already exists with the same stock ID as one of the items, the old item gets replaced.

Xfc::Gtk::StockItem::StockItem | ( | const StockId & | stock_id,
|  | const String & | label,
|  | Gdk::ModifierTypeField | modifier,
|  | unsigned int | key,
|  | const String & | domain = `0`
| ) |

Constructs a new StockItem initialized with the specified values; This item should be registered with Gtk::Stock::add().

Parameters:

  | stock_id | The string identifier for the stock item.
  | label | The user-visible label.
  | modifier | The modifier combination of the accelerator.
  | key | The key value of the accelerator
  | domain | The translation domain.

If the item already exists with the same stock ID as one of the items, the old item gets replaced.

Xfc::Gtk::StockItem::StockItem | ( | const StockItem & | src | ) |

Copy constructor.

Parameters:

  | src | Another stock item.

## Member Function Documentation

StockItem& Xfc::Gtk::StockItem::operator= | ( | const StockItem & | src | ) |

Assignment operator.

Parameters:

  | src | Another stock item.

Returns:
  A reference to the modified stock item, after assignment.

void Xfc::Gtk::StockItem::set | ( | const StockId & | stock_id,
|  | const String & | label,
|  | Gdk::ModifierTypeField | modifier,
|  | unsigned int | key,
|  | const String & | domain
| ) |

Sets the values for the stock item.

Parameters:

  | stock_id | The string identifier for the stock item.
  | label | The user-visible label.
  | modifier | The modifier combination of the accelerator.
  | key | The key value of the accelerator
  | domain | The translation domain.

The documentation for this class was generated from the following file:

- stock.hh

Xfce Foundation Classes

Copyright © 2004-2005 The XFC Development Team | XFC 4.3