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     char *id;
00057 };
00058 
00059 typedef void (*GntMenuItemCallback)(GntMenuItem *item, gpointer data);
00060 
00061 struct _GntMenuItem
00062 {
00063     GObject parent;
00064     GntMenuItemPriv priv;
00065 
00066     char *text;
00067 
00068     /* A GntMenuItem can have a callback associated with it.
00069      * The callback will be activated whenever the suer selects it and presses enter (or clicks).
00070      * However, if the GntMenuItem has some child, then the callback and callbackdata will be ignored. */
00071     gpointer callbackdata;
00072     GntMenuItemCallback callback;
00073 
00074     GntMenu *submenu;
00075 };
00076 
00077 struct _GntMenuItemClass
00078 {
00079     GObjectClass parent;
00080 
00081     void (*gnt_reserved1)(void);
00082     void (*gnt_reserved2)(void);
00083     void (*gnt_reserved3)(void);
00084     void (*gnt_reserved4)(void);
00085 };
00086 
00087 G_BEGIN_DECLS
00088 
00092 GType gnt_menuitem_get_gtype(void);
00093 
00101 GntMenuItem * gnt_menuitem_new(const char *text);
00102 
00110 void gnt_menuitem_set_callback(GntMenuItem *item, GntMenuItemCallback callback, gpointer data);
00111 
00118 void gnt_menuitem_set_submenu(GntMenuItem *item, GntMenu *menu);
00119 
00129 GntMenu *gnt_menuitem_get_submenu(GntMenuItem *item);
00130 
00137 void gnt_menuitem_set_trigger(GntMenuItem *item, char trigger);
00138 
00148 char gnt_menuitem_get_trigger(GntMenuItem *item);
00149 
00158 void gnt_menuitem_set_id(GntMenuItem *item, const char *id);
00159 
00169 const char * gnt_menuitem_get_id(GntMenuItem *item);
00170 
00182 gboolean gnt_menuitem_activate(GntMenuItem *item);
00183 
00184 G_END_DECLS
00185 
00186 #endif /* GNT_MENUITEM_H */