1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27 #ifndef __GTK_MENU_H__
28 #define __GTK_MENU_H__
32 #include <gtk/gtkaccelgroup.h>
33 #include <gtk/gtkmenushell.h>
38 #endif /* __cplusplus */
40 #define GTK_TYPE_MENU (gtk_menu_get_type ())
41 #define GTK_MENU(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MENU, GtkMenu))
42 #define GTK_MENU_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU, GtkMenuClass))
43 #define GTK_IS_MENU(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_MENU))
44 #define GTK_IS_MENU_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MENU))
45 #define GTK_MENU_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_MENU, GtkMenuClass))
48 typedef struct _GtkMenu GtkMenu;
49 typedef struct _GtkMenuClass GtkMenuClass;
51 typedef void (*GtkMenuPositionFunc) (GtkMenu *menu,
56 typedef void (*GtkMenuDetachFunc) (GtkWidget *attach_widget,
61 GtkMenuShell menu_shell;
63 GtkWidget *parent_menu_item;
64 GtkWidget *old_active_menu_item;
66 GtkAccelGroup *accel_group;
68 GtkMenuPositionFunc position_func;
69 gpointer position_func_data;
72 /* Do _not_ touch these widgets directly. We hide the reference
73 * count from the toplevel to the menu, so it must be restored
74 * before operating on these widgets
78 GtkWidget *tearoff_window;
79 GtkWidget *tearoff_hbox;
80 GtkWidget *tearoff_scrollbar;
81 GtkAdjustment *tearoff_adjustment;
83 GdkWindow *view_window;
84 GdkWindow *bin_window;
87 gint saved_scroll_offset;
91 /* When a submenu of this menu is popped up, motion in this
94 GdkRegion *navigation_region;
95 guint navigation_timeout;
97 guint needs_destruction_ref_count : 1;
99 /* The tearoff is active when it is torn off and the not-torn-off
100 * menu is not popped up.
102 guint tearoff_active : 1;
104 guint scroll_fast : 1;
106 guint upper_arrow_visible : 1;
107 guint lower_arrow_visible : 1;
108 guint upper_arrow_prelight : 1;
109 guint lower_arrow_prelight : 1;
114 GtkMenuShellClass parent_class;
118 GtkType gtk_menu_get_type (void) G_GNUC_CONST;
119 GtkWidget* gtk_menu_new (void);
121 /* Display the menu onscreen */
122 void gtk_menu_popup (GtkMenu *menu,
123 GtkWidget *parent_menu_shell,
124 GtkWidget *parent_menu_item,
125 GtkMenuPositionFunc func,
128 guint32 activate_time);
130 /* Position the menu according to its position function. Called
131 * from gtkmenuitem.c when a menu-item changes its allocation
133 void gtk_menu_reposition (GtkMenu *menu);
135 void gtk_menu_popdown (GtkMenu *menu);
137 /* Keep track of the last menu item selected. (For the purposes
140 GtkWidget* gtk_menu_get_active (GtkMenu *menu);
141 void gtk_menu_set_active (GtkMenu *menu,
144 /* set/get the accelerator group that holds global accelerators (should
145 * be added to the corresponding toplevel with gtk_window_add_accel_group().
147 void gtk_menu_set_accel_group (GtkMenu *menu,
148 GtkAccelGroup *accel_group);
149 GtkAccelGroup* gtk_menu_get_accel_group (GtkMenu *menu);
150 void gtk_menu_set_accel_path (GtkMenu *menu,
151 const gchar *accel_path);
153 /* A reference count is kept for a widget when it is attached to
154 * a particular widget. This is typically a menu item; it may also
155 * be a widget with a popup menu - for instance, the Notebook widget.
157 void gtk_menu_attach_to_widget (GtkMenu *menu,
158 GtkWidget *attach_widget,
159 GtkMenuDetachFunc detacher);
160 void gtk_menu_detach (GtkMenu *menu);
162 /* This should be dumped in favor of data set when the menu is popped
163 * up - that is currently in the ItemFactory code, but should be
166 GtkWidget* gtk_menu_get_attach_widget (GtkMenu *menu);
168 void gtk_menu_set_tearoff_state (GtkMenu *menu,
170 gboolean gtk_menu_get_tearoff_state (GtkMenu *menu);
172 /* This sets the window manager title for the window that
173 * appears when a menu is torn off
175 void gtk_menu_set_title (GtkMenu *menu,
177 G_CONST_RETURN gchar *gtk_menu_get_title (GtkMenu *menu);
179 void gtk_menu_reorder_child (GtkMenu *menu,
183 #ifndef GTK_DISABLE_DEPRECATED
184 #define gtk_menu_append(menu,child) gtk_menu_shell_append ((GtkMenuShell *)(menu),(child))
185 #define gtk_menu_prepend(menu,child) gtk_menu_shell_prepend ((GtkMenuShell *)(menu),(child))
186 #define gtk_menu_insert(menu,child,pos) gtk_menu_shell_insert ((GtkMenuShell *)(menu),(child),(pos))
187 #endif /* GTK_DISABLE_DEPRECATED */
191 #endif /* __cplusplus */
194 #endif /* __GTK_MENU_H__ */