source: trunk/third/gtk/gtk/gtkmenu.h @ 14482

Revision 14482, 5.3 KB checked in by ghudson, 25 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r14481, which included commits to RCS files with non-trunk default branches.
Line 
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 Library 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 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library 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.
18 */
19
20/*
21 * Modified by the GTK+ Team and others 1997-1999.  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/.
25 */
26
27#ifndef __GTK_MENU_H__
28#define __GTK_MENU_H__
29
30
31#include <gdk/gdk.h>
32#include <gtk/gtkaccelgroup.h>
33#include <gtk/gtkmenushell.h>
34
35
36#ifdef __cplusplus
37extern "C" {
38#endif /* __cplusplus */
39
40
41#define GTK_TYPE_MENU                   (gtk_menu_get_type ())
42#define GTK_MENU(obj)                   (GTK_CHECK_CAST ((obj), GTK_TYPE_MENU, GtkMenu))
43#define GTK_MENU_CLASS(klass)           (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU, GtkMenuClass))
44#define GTK_IS_MENU(obj)                (GTK_CHECK_TYPE ((obj), GTK_TYPE_MENU))
45#define GTK_IS_MENU_CLASS(klass)        (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MENU))
46
47
48typedef struct _GtkMenu       GtkMenu;
49typedef struct _GtkMenuClass  GtkMenuClass;
50
51typedef void (*GtkMenuPositionFunc) (GtkMenu   *menu,
52                                     gint      *x,
53                                     gint      *y,
54                                     gpointer   user_data);
55typedef void (*GtkMenuDetachFunc)   (GtkWidget *attach_widget,
56                                     GtkMenu   *menu);
57
58struct _GtkMenu
59{
60  GtkMenuShell menu_shell;
61 
62  GtkWidget *parent_menu_item;
63  GtkWidget *old_active_menu_item;
64 
65  GtkAccelGroup *accel_group;
66  GtkMenuPositionFunc position_func;
67  gpointer position_func_data;
68
69  /* Do _not_ touch these widgets directly. We hide the reference
70   * count from the toplevel to the menu, so it must be restored
71   * before operating on these widgets
72   */
73  GtkWidget *toplevel;
74  GtkWidget *tearoff_window;
75
76  guint torn_off : 1;
77};
78
79struct _GtkMenuClass
80{
81  GtkMenuShellClass parent_class;
82};
83
84
85GtkType    gtk_menu_get_type              (void);
86GtkWidget* gtk_menu_new                   (void);
87
88/* Wrappers for the Menu Shell operations */
89void       gtk_menu_append                (GtkMenu             *menu,
90                                           GtkWidget           *child);
91void       gtk_menu_prepend               (GtkMenu             *menu,
92                                           GtkWidget           *child);
93void       gtk_menu_insert                (GtkMenu             *menu,
94                                           GtkWidget           *child,
95                                           gint                 position);
96
97/* Display the menu onscreen */
98void       gtk_menu_popup                 (GtkMenu             *menu,
99                                           GtkWidget           *parent_menu_shell,
100                                           GtkWidget           *parent_menu_item,
101                                           GtkMenuPositionFunc  func,
102                                           gpointer             data,
103                                           guint                button,
104                                           guint32              activate_time);
105
106/* Position the menu according to it's position function. Called
107 * from gtkmenuitem.c when a menu-item changes its allocation
108 */
109void       gtk_menu_reposition            (GtkMenu             *menu);
110
111void       gtk_menu_popdown               (GtkMenu             *menu);
112
113/* Keep track of the last menu item selected. (For the purposes
114 * of the option menu
115 */
116GtkWidget* gtk_menu_get_active            (GtkMenu             *menu);
117void       gtk_menu_set_active            (GtkMenu             *menu,
118                                           guint                index);
119
120/* set/get the acclerator group that holds global accelerators (should
121 * be added to the corresponding toplevel with gtk_window_add_accel_group().
122 */
123void           gtk_menu_set_accel_group   (GtkMenu             *menu,
124                                           GtkAccelGroup       *accel_group);
125GtkAccelGroup* gtk_menu_get_accel_group   (GtkMenu             *menu);
126
127/* get the accelerator group that is used internally by the menu for
128 * underline accelerators while the menu is popped up.
129 */
130GtkAccelGroup* gtk_menu_get_uline_accel_group    (GtkMenu         *menu);
131GtkAccelGroup* gtk_menu_ensure_uline_accel_group (GtkMenu         *menu);
132
133
134/* A reference count is kept for a widget when it is attached to
135 * a particular widget. This is typically a menu item; it may also
136 * be a widget with a popup menu - for instance, the Notebook widget.
137 */
138void       gtk_menu_attach_to_widget      (GtkMenu             *menu,
139                                           GtkWidget           *attach_widget,
140                                           GtkMenuDetachFunc    detacher);
141void       gtk_menu_detach                (GtkMenu             *menu);
142
143/* This should be dumped in favor of data set when the menu is popped
144 * up - that is currently in the ItemFactory code, but should be
145 * in the Menu code.
146 */
147GtkWidget* gtk_menu_get_attach_widget     (GtkMenu             *menu);
148
149void       gtk_menu_set_tearoff_state     (GtkMenu             *menu,
150                                           gboolean             torn_off);
151
152/* This sets the window manager title for the window that
153 * appears when a menu is torn off
154 */
155void       gtk_menu_set_title             (GtkMenu             *menu,
156                                           const gchar         *title);
157
158void       gtk_menu_reorder_child         (GtkMenu             *menu,
159                                           GtkWidget           *child,
160                                           gint                position);
161
162#ifdef __cplusplus
163}
164#endif /* __cplusplus */
165
166
167#endif /* __GTK_MENU_H__ */
Note: See TracBrowser for help on using the repository browser.