Reference Manual

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

# itemfactory.h File Reference

A GtkItemFactory C++ wrapper interface. More...

`#include <inti/gtk/object.h>`
`#include <gtk/gtkitemfactory.h>`
`#include <vector>`

Go to the source code of this file.

## Namespaces

- namespace Inti
- namespace Inti::G
- namespace Inti::Gtk

## Defines

- #define DECLARE_ITEM_FACTORY_MAP(klass)
    Macro that declares the necessary class members needed to manage an item factory map.
- #define BEGIN_ITEM_FACTORY_MAP(klass) Inti::Gtk::ItemFactoryEntry< klass > klass::item_factory_map[] = {
    Macro that begins an item factory map.
- #define END_ITEM_FACTORY_MAP { 0, 0, 0, 0, 0, 0, 0 }};
    Macro that ends an item factory map.
- #define IFM_TITLE(path, accelerator, function) { path, accelerator, 0, 0, "<Title>", 0, (MyPMF)&MyClass::function }
    Macro that creates a title item.
- #define IFM_ITEM(path, accelerator, function) { path, accelerator, 0, 0, "<Item>", 0, (MyPMF)&MyClass::function }
    Macro that creates a simple item.
- #define IFM_IMAGE_ITEM(path, accelerator, function, pixbuf_stream) { path, accelerator, 0, 0, "<ImageItem>", pixbuf_stream, (MyPMF)&MyClass::function }
    Macro that creates an image item.
- #define IFM_STOCK_ITEM(path, accelerator, function, stock_id) { path, accelerator, 0, 0, "<StockItem>", (gconstpointer)stock_id, (MyPMF)&MyClass::function }
    Macro that creates a stock image item.
- #define IFM_CHECK_ITEM(path, accelerator, function) { path, accelerator, 0, 0, "<CheckItem>", 0, (MyPMF)&MyClass::function }
    Macro that creates a check item.
- #define IFM_TOGGLE_ITEM(path, accelerator, function) { path, accelerator, 0, 0, "<CheckItem>", 0, (MyPMF)&MyClass::function }
    Macro that creates a toggle item.
- #define IFM_RADIO_ITEM(path, accelerator, function) { path, accelerator, 0, 0, "<RadioItem>", 0, (MyPMF)&MyClass::function }
    Macro that creates a radio item.
- #define IFM_RADIO_ITEM_LINK(path, function, link_path) { path, 0, 0, 0, link_path, 0, (MyPMF)&MyClass::function }
    Macro that creates a radio item to link against.
- #define IFM_TEAROFF_ITEM(path, function) { path, 0, 0, 0, "<Tearoff>", 0, (MyPMF)&MyClass::function }
    Macro that creates a tearoff separator.
- #define IFM_SEPARATOR(path) { path, 0, 0, 0, "<Separator>", 0, 0 }
    Macro that creates a separator.
- #define IFM_BRANCH(path) { path, 0, 0, 0, "<Branch>", 0, 0 }
    Macro that creates an item to hold sub items.
- #define IFM_LAST_BRANCH(path) { path, 0, 0, 0, "<LastBranch>", 0, 0 }
    Macro that creates a right justified item to hold sub items.

## Detailed Description

A GtkItemFactory C++ wrapper interface.

Itemfactories are a quick way to implement a menu heirarchy. You can create simple menus or entire an entire menu bar with its associated menu items and submenus. Item factories are easy to use, especially when creating many menus, and there is no difference in appearence from menus created manually. There are some trade-offs in control:

- Each class can only have one item factory map.
- Each menu item in the item factory map must be connected to its own slot.

What you need to decide is which is more important, control or ease of programming. You will find example code using an ItemFactory in itemfactory.cc in the <examples/menu> directory.

## Define Documentation

#define BEGIN_ITEM_FACTORY_MAP | ( | klass |  | ) | Inti::Gtk::ItemFactoryEntry< klass > klass::item_factory_map[] = {

  | Macro that begins an item factory map. Parameters:
  klass | The name of the owner class of the item factory map.

#define DECLARE_ITEM_FACTORY_MAP | ( | klass |  | ) |

| Value:
    private:\
            friend class Gtk::ItemFactory;\
            static Inti::Gtk::ItemFactoryEntry< klass > item_factory_map[];\
            typedef Inti::Gtk::ItemFactoryEntry< klass >::PMF MyPMF;\
            typedef klass MyClass;\
    public:
  Macro that declares the necessary class members needed to manage an item factory map. Parameters:
  klass | The name of the owner class for the item factory map.

#define IFM_BRANCH | ( | path |  | ) | { path, 0, 0, 0, "<Branch>", 0, 0 }

  | Macro that creates an item to hold sub items. Parameters:
  path | A string indicating the item's level in the menu hierarchy.

#define IFM_CHECK_ITEM | ( | path,
|  | accelerator,
|  | function |  | ) | { path, accelerator, 0, 0, "<CheckItem>", 0, (MyPMF)&MyClass::function }

  | Macro that creates a check item. Parameters:
  path | A string indicating the item's level in the menu hierarchy.
  accelerator | A string indicating the keyboard shortcut for the menu item, or null.
  function | The name of the class method to call, without any scope prefix.

#define IFM_IMAGE_ITEM | ( | path,
|  | accelerator,
|  | function,
|  | pixbuf_stream |  | ) | { path, accelerator, 0, 0, "<ImageItem>", pixbuf_stream, (MyPMF)&MyClass::function }

  | Macro that creates an image item. Parameters:
  path | A string indicating the item's level in the menu hierarchy.
  accelerator | A string indicating the keyboard shortcut for the menu item, or null.
  function | The name of the class method to call, without any scope prefix.
  pixbuf_stream | A pointer to an inlined pixbuf stream.

#define IFM_ITEM | ( | path,
|  | accelerator,
|  | function |  | ) | { path, accelerator, 0, 0, "<Item>", 0, (MyPMF)&MyClass::function }

  | Macro that creates a simple item. Parameters:
  path | A string indicating the item's level in the menu hierarchy.
  accelerator | A string indicating the keyboard shortcut for the menu item, or null.
  function | The name of the class method to call, without any scope prefix.

#define IFM_LAST_BRANCH | ( | path |  | ) | { path, 0, 0, 0, "<LastBranch>", 0, 0 }

  | Macro that creates a right justified item to hold sub items. Parameters:
  path | A string indicating the item's level in the menu hierarchy.

#define IFM_RADIO_ITEM | ( | path,
|  | accelerator,
|  | function |  | ) | { path, accelerator, 0, 0, "<RadioItem>", 0, (MyPMF)&MyClass::function }

  | Macro that creates a radio item. Parameters:
  path | A string indicating the item's level in the menu hierarchy.
  accelerator | A string indicating the keyboard shortcut for the menu item, or null.
  function | The name of the class method to call, without any scope prefix.
To declare a group of radio menu items in an item factory map the first item in the group is defined with the IFM_RADIO_ITEM macro. Other items in the group are then defined with the IFM_RADIO_LINK_ITEM macro, specifying the first item's path as the link_path.

#define IFM_RADIO_ITEM_LINK | ( | path,
|  | function,
|  | link_path |  | ) | { path, 0, 0, 0, link_path, 0, (MyPMF)&MyClass::function }

  | Macro that creates a radio item to link against. Parameters:
  path | A string indicating the item's level in the menu hierarchy.
  function | The name of the class method to call, without any scope prefix.
  link_path | The path string of the radio item to link against; this is usually the first radio item in the group, the one defined in the item factory map with IFM_RADIO_ITEM.

#define IFM_SEPARATOR | ( | path |  | ) | { path, 0, 0, 0, "<Separator>", 0, 0 }

  | Macro that creates a separator. Parameters:
  path | A string indicating the item's level in the menu hierarchy.

#define IFM_STOCK_ITEM | ( | path,
|  | accelerator,
|  | function,
|  | stock_id |  | ) | { path, accelerator, 0, 0, "<StockItem>", (gconstpointer)stock_id, (MyPMF)&MyClass::function }

  | Macro that creates a stock image item. Parameters:
  path | A string indicating the item's level in the menu hierarchy.
  accelerator | A string indicating the keyboard shortcut for the menu item, or null.
  function | The name of the class method to call, without any scope prefix.
  stock_id | The stock item, such as GTK_STOCK_NEW, GTK_STOCK_SAVE etc.

#define IFM_TEAROFF_ITEM | ( | path,
|  | function |  | ) | { path, 0, 0, 0, "<Tearoff>", 0, (MyPMF)&MyClass::function }

  | Macro that creates a tearoff separator. Parameters:
  path | A string indicating the item's level in the menu hierarchy.
  function | The name of the class method to call, without any scope prefix.

#define IFM_TITLE | ( | path,
|  | accelerator,
|  | function |  | ) | { path, accelerator, 0, 0, "<Title>", 0, (MyPMF)&MyClass::function }

  | Macro that creates a title item. Parameters:
  path | A string indicating the item's level in the menu hierarchy.
  accelerator | A string indicating the keyboard shortcut for the menu item, or null.
  function | The name of the class method to call, without any scope prefix.

#define IFM_TOGGLE_ITEM | ( | path,
|  | accelerator,
|  | function |  | ) | { path, accelerator, 0, 0, "<CheckItem>", 0, (MyPMF)&MyClass::function }

  | Macro that creates a toggle item. Parameters:
  path | A string indicating the item's level in the menu hierarchy.
  accelerator | A string indicating the keyboard shortcut for the menu item, or null.
  function | The name of the class method to call, without any scope prefix.

Main Page - Footer