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: (out): 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);
120 GtkWidget* gtk_menu_new_from_model (GMenuModel *model);
122 /* Display the menu onscreen */
123 void gtk_menu_popup (GtkMenu *menu,
124 GtkWidget *parent_menu_shell,
125 GtkWidget *parent_menu_item,
126 GtkMenuPositionFunc func,
129 guint32 activate_time);
130 void gtk_menu_popup_for_device (GtkMenu *menu,
132 GtkWidget *parent_menu_shell,
133 GtkWidget *parent_menu_item,
134 GtkMenuPositionFunc func,
136 GDestroyNotify destroy,
138 guint32 activate_time);
140 /* Position the menu according to its position function. Called
141 * from gtkmenuitem.c when a menu-item changes its allocation
143 void gtk_menu_reposition (GtkMenu *menu);
145 void gtk_menu_popdown (GtkMenu *menu);
147 /* Keep track of the last menu item selected. (For the purposes
150 GtkWidget* gtk_menu_get_active (GtkMenu *menu);
151 void gtk_menu_set_active (GtkMenu *menu,
154 /* set/get the accelerator group that holds global accelerators (should
155 * be added to the corresponding toplevel with gtk_window_add_accel_group().
157 void gtk_menu_set_accel_group (GtkMenu *menu,
158 GtkAccelGroup *accel_group);
159 GtkAccelGroup* gtk_menu_get_accel_group (GtkMenu *menu);
160 void gtk_menu_set_accel_path (GtkMenu *menu,
161 const gchar *accel_path);
162 const gchar* gtk_menu_get_accel_path (GtkMenu *menu);
164 /* A reference count is kept for a widget when it is attached to
165 * a particular widget. This is typically a menu item; it may also
166 * be a widget with a popup menu - for instance, the Notebook widget.
168 void gtk_menu_attach_to_widget (GtkMenu *menu,
169 GtkWidget *attach_widget,
170 GtkMenuDetachFunc detacher);
171 void gtk_menu_detach (GtkMenu *menu);
173 /* This should be dumped in favor of data set when the menu is popped
174 * up - that is currently in the ItemFactory code, but should be
177 GtkWidget* gtk_menu_get_attach_widget (GtkMenu *menu);
179 void gtk_menu_set_tearoff_state (GtkMenu *menu,
181 gboolean gtk_menu_get_tearoff_state (GtkMenu *menu);
183 /* This sets the window manager title for the window that
184 * appears when a menu is torn off
186 void gtk_menu_set_title (GtkMenu *menu,
188 const gchar * gtk_menu_get_title (GtkMenu *menu);
190 void gtk_menu_reorder_child (GtkMenu *menu,
194 void gtk_menu_set_screen (GtkMenu *menu,
197 void gtk_menu_attach (GtkMenu *menu,
202 guint bottom_attach);
204 void gtk_menu_set_monitor (GtkMenu *menu,
206 gint gtk_menu_get_monitor (GtkMenu *menu);
207 GList* gtk_menu_get_for_attach_widget (GtkWidget *widget);
209 void gtk_menu_set_reserve_toggle_size (GtkMenu *menu,
210 gboolean reserve_toggle_size);
211 gboolean gtk_menu_get_reserve_toggle_size (GtkMenu *menu);
216 #endif /* __GTK_MENU_H__ */