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, see <http://www.gnu.org/licenses/>.
19 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25 #ifndef __GTK_MENU_H__
26 #define __GTK_MENU_H__
29 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
30 #error "Only <gtk/gtk.h> can be included directly."
33 #include <gtk/gtkaccelgroup.h>
34 #include <gtk/gtkmenushell.h>
39 #define GTK_TYPE_MENU (gtk_menu_get_type ())
40 #define GTK_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MENU, GtkMenu))
41 #define GTK_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU, GtkMenuClass))
42 #define GTK_IS_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MENU))
43 #define GTK_IS_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MENU))
44 #define GTK_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MENU, GtkMenuClass))
47 typedef struct _GtkMenu GtkMenu;
48 typedef struct _GtkMenuClass GtkMenuClass;
49 typedef struct _GtkMenuPrivate GtkMenuPrivate;
52 * GtkMenuPositionFunc:
54 * @x: (out): address of the #gint representing the horizontal
55 * position where the menu shall be drawn.
56 * @y: (out): address of the #gint representing the vertical position
57 * where the menu shall be drawn. This is an output parameter.
58 * @push_in: (out): This parameter controls how menus placed outside
59 * the monitor are handled. If this is set to %TRUE and part of
60 * the menu is outside the monitor then GTK+ pushes the window
61 * into the visible area, effectively modifying the popup
62 * position. Note that moving and possibly resizing the menu
63 * around will alter the scroll position to keep the menu items
64 * "in place", i.e. at the same monitor position they would have
65 * been without resizing. In practice, this behavior is only
66 * useful for combobox popups or option menus and cannot be used
67 * to simply confine a menu to monitor boundaries. In that case,
68 * changing the scroll offset is not desirable.
69 * @user_data: the data supplied by the user in the gtk_menu_popup()
72 * A user function supplied when calling gtk_menu_popup() which
73 * controls the positioning of the menu when it is displayed. The
74 * function sets the @x and @y parameters to the coordinates where the
75 * menu is to be drawn. To make the menu appear on a different
76 * monitor than the mouse pointer, gtk_menu_set_monitor() must be
79 typedef void (*GtkMenuPositionFunc) (GtkMenu *menu,
87 * @attach_widget: the #GtkWidget that the menu is being detached from.
88 * @menu: the #GtkMenu being detached.
90 * A user function supplied when calling gtk_menu_attach_to_widget() which
91 * will be called when the menu is later detached from the widget.
93 typedef void (*GtkMenuDetachFunc) (GtkWidget *attach_widget,
98 GtkMenuShell menu_shell;
101 GtkMenuPrivate *priv;
106 GtkMenuShellClass parent_class;
108 /* Padding for future expansion */
109 void (*_gtk_reserved1) (void);
110 void (*_gtk_reserved2) (void);
111 void (*_gtk_reserved3) (void);
112 void (*_gtk_reserved4) (void);
116 GType gtk_menu_get_type (void) G_GNUC_CONST;
117 GtkWidget* gtk_menu_new (void);
119 GtkWidget* gtk_menu_new_from_model (GMenuModel *model);
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);
129 void gtk_menu_popup_for_device (GtkMenu *menu,
131 GtkWidget *parent_menu_shell,
132 GtkWidget *parent_menu_item,
133 GtkMenuPositionFunc func,
135 GDestroyNotify destroy,
137 guint32 activate_time);
139 /* Position the menu according to its position function. Called
140 * from gtkmenuitem.c when a menu-item changes its allocation
142 void gtk_menu_reposition (GtkMenu *menu);
144 void gtk_menu_popdown (GtkMenu *menu);
146 /* Keep track of the last menu item selected. (For the purposes
149 GtkWidget* gtk_menu_get_active (GtkMenu *menu);
150 void gtk_menu_set_active (GtkMenu *menu,
153 /* set/get the accelerator group that holds global accelerators (should
154 * be added to the corresponding toplevel with gtk_window_add_accel_group().
156 void gtk_menu_set_accel_group (GtkMenu *menu,
157 GtkAccelGroup *accel_group);
158 GtkAccelGroup* gtk_menu_get_accel_group (GtkMenu *menu);
159 void gtk_menu_set_accel_path (GtkMenu *menu,
160 const gchar *accel_path);
161 const gchar* gtk_menu_get_accel_path (GtkMenu *menu);
163 /* A reference count is kept for a widget when it is attached to
164 * a particular widget. This is typically a menu item; it may also
165 * be a widget with a popup menu - for instance, the Notebook widget.
167 void gtk_menu_attach_to_widget (GtkMenu *menu,
168 GtkWidget *attach_widget,
169 GtkMenuDetachFunc detacher);
170 void gtk_menu_detach (GtkMenu *menu);
172 /* This should be dumped in favor of data set when the menu is popped
173 * up - that is currently in the ItemFactory code, but should be
176 GtkWidget* gtk_menu_get_attach_widget (GtkMenu *menu);
178 void gtk_menu_set_tearoff_state (GtkMenu *menu,
180 gboolean gtk_menu_get_tearoff_state (GtkMenu *menu);
182 /* This sets the window manager title for the window that
183 * appears when a menu is torn off
185 void gtk_menu_set_title (GtkMenu *menu,
187 const gchar * gtk_menu_get_title (GtkMenu *menu);
189 void gtk_menu_reorder_child (GtkMenu *menu,
193 void gtk_menu_set_screen (GtkMenu *menu,
196 void gtk_menu_attach (GtkMenu *menu,
201 guint bottom_attach);
203 void gtk_menu_set_monitor (GtkMenu *menu,
205 gint gtk_menu_get_monitor (GtkMenu *menu);
206 GList* gtk_menu_get_for_attach_widget (GtkWidget *widget);
208 void gtk_menu_set_reserve_toggle_size (GtkMenu *menu,
209 gboolean reserve_toggle_size);
210 gboolean gtk_menu_get_reserve_toggle_size (GtkMenu *menu);
215 #endif /* __GTK_MENU_H__ */