gntmenu.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_MENU_H
00028 #define GNT_MENU_H
00029 
00030 #include "gnttree.h"
00031 #include "gntcolors.h"
00032 #include "gntkeys.h"
00033 
00034 #define GNT_TYPE_MENU               (gnt_menu_get_gtype())
00035 #define GNT_MENU(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_MENU, GntMenu))
00036 #define GNT_MENU_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_MENU, GntMenuClass))
00037 #define GNT_IS_MENU(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_MENU))
00038 #define GNT_IS_MENU_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_MENU))
00039 #define GNT_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_MENU, GntMenuClass))
00040 
00041 #define GNT_MENU_FLAGS(obj)             (GNT_MENU(obj)->priv.flags)
00042 #define GNT_MENU_SET_FLAGS(obj, flags)      (GNT_MENU_FLAGS(obj) |= flags)
00043 #define GNT_MENU_UNSET_FLAGS(obj, flags)    (GNT_MENU_FLAGS(obj) &= ~(flags))
00044 
00045 typedef struct _GntMenu         GntMenu;
00046 typedef struct _GntMenuPriv     GntMenuPriv;
00047 typedef struct _GntMenuClass        GntMenuClass;
00048 
00049 #include "gntmenuitem.h"
00050 
00056 typedef enum
00057 {
00058     GNT_MENU_TOPLEVEL = 1,  /* Menu for a toplevel window */
00059     GNT_MENU_POPUP,         /* A popup menu */
00060 } GntMenuType;
00061 
00062 struct _GntMenu
00063 {
00064     GntTree parent;
00065     GntMenuType type;
00066     
00067     GList *list;
00068     int selected;
00069 
00070     /* This will keep track of its immediate submenu which is visible so that
00071      * keystrokes can be passed to it. */
00072     GntMenu *submenu;
00073     GntMenu *parentmenu;
00074 };
00075 
00076 struct _GntMenuClass
00077 {
00078     GntTreeClass 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 
00091 GType gnt_menu_get_gtype(void);
00092 
00100 GntWidget * gnt_menu_new(GntMenuType type);
00101 
00108 void gnt_menu_add_item(GntMenu *menu, GntMenuItem *item);
00109 
00120 GntMenuItem *gnt_menu_get_item(GntMenu *menu, const char *id);
00121 
00122 G_END_DECLS
00123 
00124 #endif /* GNT_MENU_H */