gntmenuitem.h

Go to the documentation of this file.
00001 
00005 /*
00006  * GNT - The GLib Ncurses Toolkit
00007  *
00008  * GNT is the legal property of its developers, whose names are too numerous
00009  * to list here.  Please refer to the COPYRIGHT file distributed with this
00010  * source distribution.
00011  *
00012  * This library is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00025  */
00026 
00027 #ifndef GNT_MENUITEM_H
00028 #define GNT_MENUITEM_H
00029 
00030 #include <glib.h>
00031 #include <glib-object.h>
00032 
00033 #define GNT_TYPE_MENU_ITEM              (gnt_menuitem_get_gtype())
00034 #define GNT_MENU_ITEM(obj)              (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_MENU_ITEM, GntMenuItem))
00035 #define GNT_MENU_ITEM_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_MENU_ITEM, GntMenuItemClass))
00036 #define GNT_IS_MENU_ITEM(obj)           (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_MENU_ITEM))
00037 #define GNT_IS_MENU_ITEM_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_MENU_ITEM))
00038 #define GNT_MENU_ITEM_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_MENU_ITEM, GntMenuItemClass))
00039 
00040 #define GNT_MENU_ITEM_FLAGS(obj)                (GNT_MENU_ITEM(obj)->priv.flags)
00041 #define GNT_MENU_ITEM_SET_FLAGS(obj, flags)     (GNT_MENU_ITEM_FLAGS(obj) |= flags)
00042 #define GNT_MENU_ITEM_UNSET_FLAGS(obj, flags)   (GNT_MENU_ITEM_FLAGS(obj) &= ~(flags))
00043 
00044 typedef struct _GntMenuItem         GntMenuItem;
00045 typedef struct _GntMenuItemPriv     GntMenuItemPriv;
00046 typedef struct _GntMenuItemClass        GntMenuItemClass;
00047 
00048 #include "gntmenu.h"
00049 
00050 struct _GntMenuItemPriv
00051 {
00052     /* These will be used to determine the position of the submenu */
00053     int x;
00054     int y;
00055     char trigger;
00056 };
00057 
00058 typedef void (*GntMenuItemCallback)(GntMenuItem *item, gpointer data);
00059 
00060 struct _GntMenuItem
00061 {
00062     GObject parent;
00063     GntMenuItemPriv priv;
00064 
00065     char *text;
00066 
00067     /* A GntMenuItem can have a callback associated with it.
00068      * The callback will be activated whenever the suer selects it and presses enter (or clicks).
00069      * However, if the GntMenuItem has some child, then the callback and callbackdata will be ignored. */
00070     gpointer callbackdata;
00071     GntMenuItemCallback callback;
00072 
00073     GntMenu *submenu;
00074 };
00075 
00076 struct _GntMenuItemClass
00077 {
00078     GObjectClass parent;
00079 
00080     void (*gnt_reserved1)(void);
00081     void (*gnt_reserved2)(void);
00082     void (*gnt_reserved3)(void);
00083     void (*gnt_reserved4)(void);
00084 };
00085 
00086 G_BEGIN_DECLS
00087 
00093 GType gnt_menuitem_get_gtype(void);
00094 
00101 GntMenuItem * gnt_menuitem_new(const char *text);
00102 
00109 void gnt_menuitem_set_callback(GntMenuItem *item, GntMenuItemCallback callback, gpointer data);
00110 
00116 void gnt_menuitem_set_submenu(GntMenuItem *item, GntMenu *menu);
00117 
00124 void gnt_menuitem_set_trigger(GntMenuItem *item, char trigger);
00125 
00135 char gnt_menuitem_get_trigger(GntMenuItem *item);
00136 
00137 G_END_DECLS
00138 
00139 #endif /* GNT_MENUITEM_H */