| 1 | /* GTK - The GIMP Toolkit |
| 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
| 3 | * |
| 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. |
| 8 | * |
| 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. |
| 13 | * |
| 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/>. |
| 16 | */ |
| 17 | |
| 18 | /* |
| 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/. |
| 23 | */ |
| 24 | |
| 25 | #ifndef __GTK_MENU_H__ |
| 26 | #define |
| 27 | |
| 28 | #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) |
| 29 | #error "Only <gtk/gtk.h> can be included directly." |
| 30 | #endif |
| 31 | |
| 32 | #include <gtk/gtkaccelgroup.h> |
| 33 | #include <gtk/gtkmenushell.h> |
| 34 | |
| 35 | G_BEGIN_DECLS |
| 36 | |
| 37 | #define (gtk_menu_get_type ()) |
| 38 | #define (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MENU, GtkMenu)) |
| 39 | #define (klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU, GtkMenuClass)) |
| 40 | #define (obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MENU)) |
| 41 | #define (klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MENU)) |
| 42 | #define (obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MENU, GtkMenuClass)) |
| 43 | |
| 44 | |
| 45 | typedef struct _GtkMenu ; |
| 46 | typedef struct _GtkMenuClass ; |
| 47 | typedef struct ; |
| 48 | |
| 49 | /** |
| 50 | * GtkArrowPlacement: |
| 51 | * @GTK_ARROWS_BOTH: Place one arrow on each end of the menu. |
| 52 | * @GTK_ARROWS_START: Place both arrows at the top of the menu. |
| 53 | * @GTK_ARROWS_END: Place both arrows at the bottom of the menu. |
| 54 | * |
| 55 | * Used to specify the placement of scroll arrows in scrolling menus. |
| 56 | */ |
| 57 | typedef enum |
| 58 | { |
| 59 | GTK_ARROWS_BOTH, |
| 60 | GTK_ARROWS_START, |
| 61 | GTK_ARROWS_END |
| 62 | } GtkArrowPlacement; |
| 63 | |
| 64 | /** |
| 65 | * GtkMenuPositionFunc: |
| 66 | * @menu: a #GtkMenu. |
| 67 | * @x: (inout): address of the #gint representing the horizontal |
| 68 | * position where the menu shall be drawn. |
| 69 | * @y: (inout): address of the #gint representing the vertical position |
| 70 | * where the menu shall be drawn. This is an output parameter. |
| 71 | * @push_in: (out): This parameter controls how menus placed outside |
| 72 | * the monitor are handled. If this is set to %TRUE and part of |
| 73 | * the menu is outside the monitor then GTK+ pushes the window |
| 74 | * into the visible area, effectively modifying the popup |
| 75 | * position. Note that moving and possibly resizing the menu |
| 76 | * around will alter the scroll position to keep the menu items |
| 77 | * “in place”, i.e. at the same monitor position they would have |
| 78 | * been without resizing. In practice, this behavior is only |
| 79 | * useful for combobox popups or option menus and cannot be used |
| 80 | * to simply confine a menu to monitor boundaries. In that case, |
| 81 | * changing the scroll offset is not desirable. |
| 82 | * @user_data: the data supplied by the user in the gtk_menu_popup() |
| 83 | * @data parameter. |
| 84 | * |
| 85 | * A user function supplied when calling gtk_menu_popup() which |
| 86 | * controls the positioning of the menu when it is displayed. The |
| 87 | * function sets the @x and @y parameters to the coordinates where the |
| 88 | * menu is to be drawn. To make the menu appear on a different |
| 89 | * monitor than the mouse pointer, gtk_menu_set_monitor() must be |
| 90 | * called. |
| 91 | */ |
| 92 | typedef void (*) (GtkMenu *, |
| 93 | gint *x, |
| 94 | gint *y, |
| 95 | gboolean *push_in, |
| 96 | gpointer user_data); |
| 97 | |
| 98 | /** |
| 99 | * GtkMenuDetachFunc: |
| 100 | * @attach_widget: the #GtkWidget that the menu is being detached from. |
| 101 | * @menu: the #GtkMenu being detached. |
| 102 | * |
| 103 | * A user function supplied when calling gtk_menu_attach_to_widget() which |
| 104 | * will be called when the menu is later detached from the widget. |
| 105 | */ |
| 106 | typedef void (*) (GtkWidget *attach_widget, |
| 107 | GtkMenu *); |
| 108 | |
| 109 | struct |
| 110 | { |
| 111 | GtkMenuShell ; |
| 112 | |
| 113 | /*< private >*/ |
| 114 | GtkMenuPrivate *; |
| 115 | }; |
| 116 | |
| 117 | struct |
| 118 | { |
| 119 | GtkMenuShellClass ; |
| 120 | |
| 121 | /* Padding for future expansion */ |
| 122 | void (*) (void); |
| 123 | void (*) (void); |
| 124 | void (*) (void); |
| 125 | void (*) (void); |
| 126 | }; |
| 127 | |
| 128 | |
| 129 | GDK_AVAILABLE_IN_ALL |
| 130 | GType (void) G_GNUC_CONST; |
| 131 | GDK_AVAILABLE_IN_ALL |
| 132 | GtkWidget* (void); |
| 133 | GDK_AVAILABLE_IN_3_4 |
| 134 | GtkWidget* (GMenuModel *model); |
| 135 | |
| 136 | /* Display the menu onscreen */ |
| 137 | GDK_DEPRECATED_IN_3_22_FOR((gtk_menu_popup_at_widget, gtk_menu_popup_at_pointer, gtk_menu_popup_at_rect)) |
| 138 | void (GtkMenu *, |
| 139 | GtkWidget *, |
| 140 | GtkWidget *, |
| 141 | GtkMenuPositionFunc func, |
| 142 | gpointer data, |
| 143 | guint button, |
| 144 | guint32 activate_time); |
| 145 | GDK_DEPRECATED_IN_3_22_FOR((gtk_menu_popup_at_widget, gtk_menu_popup_at_pointer, gtk_menu_popup_at_rect)) |
| 146 | void (GtkMenu *, |
| 147 | GdkDevice *device, |
| 148 | GtkWidget *, |
| 149 | GtkWidget *, |
| 150 | GtkMenuPositionFunc func, |
| 151 | gpointer data, |
| 152 | GDestroyNotify destroy, |
| 153 | guint button, |
| 154 | guint32 activate_time); |
| 155 | GDK_AVAILABLE_IN_3_22 |
| 156 | void (GtkMenu *, |
| 157 | GdkWindow *rect_window, |
| 158 | const GdkRectangle *rect, |
| 159 | GdkGravity rect_anchor, |
| 160 | GdkGravity , |
| 161 | const GdkEvent *trigger_event); |
| 162 | GDK_AVAILABLE_IN_3_22 |
| 163 | void (GtkMenu *, |
| 164 | GtkWidget *widget, |
| 165 | GdkGravity widget_anchor, |
| 166 | GdkGravity , |
| 167 | const GdkEvent *trigger_event); |
| 168 | GDK_AVAILABLE_IN_3_22 |
| 169 | void (GtkMenu *, |
| 170 | const GdkEvent *trigger_event); |
| 171 | |
| 172 | /* Position the menu according to its position function. Called |
| 173 | * from gtkmenuitem.c when a menu-item changes its allocation |
| 174 | */ |
| 175 | GDK_AVAILABLE_IN_ALL |
| 176 | void (GtkMenu *); |
| 177 | |
| 178 | GDK_AVAILABLE_IN_ALL |
| 179 | void (GtkMenu *); |
| 180 | |
| 181 | /* Keep track of the last menu item selected. (For the purposes |
| 182 | * of the option menu |
| 183 | */ |
| 184 | GDK_AVAILABLE_IN_ALL |
| 185 | GtkWidget* (GtkMenu *); |
| 186 | GDK_AVAILABLE_IN_ALL |
| 187 | void (GtkMenu *, |
| 188 | guint index); |
| 189 | |
| 190 | /* set/get the accelerator group that holds global accelerators (should |
| 191 | * be added to the corresponding toplevel with gtk_window_add_accel_group(). |
| 192 | */ |
| 193 | GDK_AVAILABLE_IN_ALL |
| 194 | void (GtkMenu *, |
| 195 | GtkAccelGroup *accel_group); |
| 196 | GDK_AVAILABLE_IN_ALL |
| 197 | GtkAccelGroup* (GtkMenu *); |
| 198 | GDK_AVAILABLE_IN_ALL |
| 199 | void (GtkMenu *, |
| 200 | const gchar *accel_path); |
| 201 | GDK_AVAILABLE_IN_ALL |
| 202 | const gchar* (GtkMenu *); |
| 203 | |
| 204 | /* A reference count is kept for a widget when it is attached to |
| 205 | * a particular widget. This is typically a menu item; it may also |
| 206 | * be a widget with a popup menu - for instance, the Notebook widget. |
| 207 | */ |
| 208 | GDK_AVAILABLE_IN_ALL |
| 209 | void (GtkMenu *, |
| 210 | GtkWidget *attach_widget, |
| 211 | GtkMenuDetachFunc detacher); |
| 212 | GDK_AVAILABLE_IN_ALL |
| 213 | void (GtkMenu *); |
| 214 | |
| 215 | /* This should be dumped in favor of data set when the menu is popped |
| 216 | * up - that is currently in the ItemFactory code, but should be |
| 217 | * in the Menu code. |
| 218 | */ |
| 219 | GDK_AVAILABLE_IN_ALL |
| 220 | GtkWidget* (GtkMenu *); |
| 221 | |
| 222 | GDK_DEPRECATED_IN_3_10 |
| 223 | void (GtkMenu *, |
| 224 | gboolean torn_off); |
| 225 | GDK_DEPRECATED_IN_3_10 |
| 226 | gboolean (GtkMenu *); |
| 227 | |
| 228 | /* This sets the window manager title for the window that |
| 229 | * appears when a menu is torn off |
| 230 | */ |
| 231 | GDK_DEPRECATED_IN_3_10 |
| 232 | void (GtkMenu *, |
| 233 | const gchar *title); |
| 234 | GDK_DEPRECATED_IN_3_10 |
| 235 | const gchar * (GtkMenu *); |
| 236 | |
| 237 | GDK_AVAILABLE_IN_ALL |
| 238 | void (GtkMenu *, |
| 239 | GtkWidget *child, |
| 240 | gint position); |
| 241 | |
| 242 | GDK_AVAILABLE_IN_ALL |
| 243 | void (GtkMenu *, |
| 244 | GdkScreen *screen); |
| 245 | |
| 246 | GDK_AVAILABLE_IN_ALL |
| 247 | void (GtkMenu *, |
| 248 | GtkWidget *child, |
| 249 | guint left_attach, |
| 250 | guint right_attach, |
| 251 | guint top_attach, |
| 252 | guint bottom_attach); |
| 253 | |
| 254 | GDK_AVAILABLE_IN_ALL |
| 255 | void (GtkMenu *, |
| 256 | gint monitor_num); |
| 257 | GDK_AVAILABLE_IN_ALL |
| 258 | gint (GtkMenu *); |
| 259 | |
| 260 | GDK_AVAILABLE_IN_3_22 |
| 261 | void (GtkMenu *, |
| 262 | GdkMonitor *monitor); |
| 263 | |
| 264 | GDK_AVAILABLE_IN_ALL |
| 265 | GList* (GtkWidget *widget); |
| 266 | |
| 267 | GDK_AVAILABLE_IN_ALL |
| 268 | void (GtkMenu *, |
| 269 | gboolean reserve_toggle_size); |
| 270 | GDK_AVAILABLE_IN_ALL |
| 271 | gboolean (GtkMenu *); |
| 272 | |
| 273 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkMenu, g_object_unref) |
| 274 | |
| 275 | G_END_DECLS |
| 276 | |
| 277 | #endif /* __GTK_MENU_H__ */ |
| 278 | |