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 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
28 #error "Only <gtk/gtk.h> can be included directly."
31 #ifndef __GTK_MENU_H__
32 #define __GTK_MENU_H__
35 #include <gtk/gtkaccelgroup.h>
36 #include <gtk/gtkmenushell.h>
41 #define GTK_TYPE_MENU (gtk_menu_get_type ())
42 #define GTK_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MENU, GtkMenu))
43 #define GTK_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU, GtkMenuClass))
44 #define GTK_IS_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MENU))
45 #define GTK_IS_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MENU))
46 #define GTK_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MENU, GtkMenuClass))
49 typedef struct _GtkMenu GtkMenu;
50 typedef struct _GtkMenuClass GtkMenuClass;
51 typedef struct _GtkMenuPrivate GtkMenuPrivate;
54 * GtkMenuPositionFunc:
56 * @x: (out): address of the #gint representing the horizontal
57 * position where the menu shall be drawn.
58 * @y: (out): address of the #gint representing the vertical position
59 * where the menu shall be drawn. This is an output parameter.
60 * @push_in: (inout): This parameter controls how menus placed outside
61 * the monitor are handled. If this is set to %TRUE and part of
62 * the menu is outside the monitor then GTK+ pushes the window
63 * into the visible area, effectively modifying the popup
64 * position. Note that moving and possibly resizing the menu
65 * around will alter the scroll position to keep the menu items
66 * "in place", i.e. at the same monitor position they would have
67 * been without resizing. In practice, this behavior is only
68 * useful for combobox popups or option menus and cannot be used
69 * to simply confine a menu to monitor boundaries. In that case,
70 * changing the scroll offset is not desirable.
71 * @user_data: the data supplied by the user in the gtk_menu_popup()
74 * A user function supplied when calling gtk_menu_popup() which
75 * controls the positioning of the menu when it is displayed. The
76 * function sets the @x and @y parameters to the coordinates where the
77 * menu is to be drawn. To make the menu appear on a different
78 * monitor than the mouse pointer, gtk_menu_set_monitor() must be
81 typedef void (*GtkMenuPositionFunc) (GtkMenu *menu,
89 * @attach_widget: the #GtkWidget that the menu is being detached from.
90 * @menu: the #GtkMenu being detached.
92 * A user function supplied when calling gtk_menu_attach_to_widget() which
93 * will be called when the menu is later detached from the widget.
95 typedef void (*GtkMenuDetachFunc) (GtkWidget *attach_widget,
100 GtkMenuShell menu_shell;
103 GtkMenuPrivate *priv;
108 GtkMenuShellClass parent_class;
110 /* Padding for future expansion */
111 void (*_gtk_reserved1) (void);
112 void (*_gtk_reserved2) (void);
113 void (*_gtk_reserved3) (void);
114 void (*_gtk_reserved4) (void);
118 GType 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);
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 G_CONST_RETURN 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__ */