]> Pileus Git - ~andy/gtk/blob - gtk/gtkmenu.h
3521e5ded3079f0ea482f38a9eb06f5bb2e07ec8
[~andy/gtk] / gtk / gtkmenu.h
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, 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-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/.
25  */
26
27 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
28 #error "Only <gtk/gtk.h> can be included directly."
29 #endif
30
31 #ifndef __GTK_MENU_H__
32 #define __GTK_MENU_H__
33
34
35 #include <gdk/gdk.h>
36 #include <gtk/gtkaccelgroup.h>
37 #include <gtk/gtkmenushell.h>
38
39
40 G_BEGIN_DECLS
41
42 #define GTK_TYPE_MENU                   (gtk_menu_get_type ())
43 #define GTK_MENU(obj)                   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MENU, GtkMenu))
44 #define GTK_MENU_CLASS(klass)           (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU, GtkMenuClass))
45 #define GTK_IS_MENU(obj)                (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MENU))
46 #define GTK_IS_MENU_CLASS(klass)        (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MENU))
47 #define GTK_MENU_GET_CLASS(obj)         (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MENU, GtkMenuClass))
48
49
50 typedef struct _GtkMenu       GtkMenu;
51 typedef struct _GtkMenuClass  GtkMenuClass;
52
53 typedef void (*GtkMenuPositionFunc) (GtkMenu   *menu,
54                                      gint      *x,
55                                      gint      *y,
56                                      gboolean  *push_in,
57                                      gpointer   user_data);
58 typedef void (*GtkMenuDetachFunc)   (GtkWidget *attach_widget,
59                                      GtkMenu   *menu);
60
61 struct _GtkMenu
62 {
63   GtkMenuShell GSEAL (menu_shell);
64   
65   GtkWidget *GSEAL (parent_menu_item);
66   GtkWidget *GSEAL (old_active_menu_item);
67
68   GtkAccelGroup *GSEAL (accel_group);
69   gchar         *GSEAL (accel_path);
70   GtkMenuPositionFunc GSEAL (position_func);
71   gpointer GSEAL (position_func_data);
72
73   guint GSEAL (toggle_size);
74   /* Do _not_ touch these widgets directly. We hide the reference
75    * count from the toplevel to the menu, so it must be restored
76    * before operating on these widgets
77    */
78   GtkWidget *GSEAL (toplevel);
79   
80   GtkWidget *GSEAL (tearoff_window);
81   GtkWidget *GSEAL (tearoff_hbox);
82   GtkWidget *GSEAL (tearoff_scrollbar);
83   GtkAdjustment *GSEAL (tearoff_adjustment);
84
85   GdkWindow *GSEAL (view_window);
86   GdkWindow *GSEAL (bin_window);
87
88   gint GSEAL (scroll_offset);
89   gint GSEAL (saved_scroll_offset);
90   gint GSEAL (scroll_step);
91   guint GSEAL (timeout_id);
92   
93   /* When a submenu of this menu is popped up, motion in this
94    * region is ignored
95    */
96   GdkRegion *GSEAL (navigation_region);
97   guint GSEAL (navigation_timeout);
98
99   guint GSEAL (needs_destruction_ref_count) : 1;
100   guint GSEAL (torn_off) : 1;
101   /* The tearoff is active when it is torn off and the not-torn-off
102    * menu is not popped up.
103    */
104   guint GSEAL (tearoff_active) : 1;
105
106   guint GSEAL (scroll_fast) : 1;
107
108   guint GSEAL (upper_arrow_visible) : 1;
109   guint GSEAL (lower_arrow_visible) : 1;
110   guint GSEAL (upper_arrow_prelight) : 1;
111   guint GSEAL (lower_arrow_prelight) : 1;
112 };
113
114 struct _GtkMenuClass
115 {
116   GtkMenuShellClass parent_class;
117
118   /* Padding for future expansion */
119   void (*_gtk_reserved1) (void);
120   void (*_gtk_reserved2) (void);
121   void (*_gtk_reserved3) (void);
122   void (*_gtk_reserved4) (void);
123 };
124
125
126 GType      gtk_menu_get_type              (void) G_GNUC_CONST;
127 GtkWidget* gtk_menu_new                   (void);
128
129 /* Display the menu onscreen */
130 void       gtk_menu_popup                 (GtkMenu             *menu,
131                                            GtkWidget           *parent_menu_shell,
132                                            GtkWidget           *parent_menu_item,
133                                            GtkMenuPositionFunc  func,
134                                            gpointer             data,
135                                            guint                button,
136                                            guint32              activate_time);
137
138 /* Position the menu according to its position function. Called
139  * from gtkmenuitem.c when a menu-item changes its allocation
140  */
141 void       gtk_menu_reposition            (GtkMenu             *menu);
142
143 void       gtk_menu_popdown               (GtkMenu             *menu);
144
145 /* Keep track of the last menu item selected. (For the purposes
146  * of the option menu
147  */
148 GtkWidget* gtk_menu_get_active            (GtkMenu             *menu);
149 void       gtk_menu_set_active            (GtkMenu             *menu,
150                                            guint                index_);
151
152 /* set/get the accelerator group that holds global accelerators (should
153  * be added to the corresponding toplevel with gtk_window_add_accel_group().
154  */
155 void           gtk_menu_set_accel_group   (GtkMenu             *menu,
156                                            GtkAccelGroup       *accel_group);
157 GtkAccelGroup* gtk_menu_get_accel_group   (GtkMenu             *menu);
158 void           gtk_menu_set_accel_path    (GtkMenu             *menu,
159                                            const gchar         *accel_path);
160 const gchar*   gtk_menu_get_accel_path    (GtkMenu             *menu);
161
162 /* A reference count is kept for a widget when it is attached to
163  * a particular widget. This is typically a menu item; it may also
164  * be a widget with a popup menu - for instance, the Notebook widget.
165  */
166 void       gtk_menu_attach_to_widget      (GtkMenu             *menu,
167                                            GtkWidget           *attach_widget,
168                                            GtkMenuDetachFunc    detacher);
169 void       gtk_menu_detach                (GtkMenu             *menu);
170
171 /* This should be dumped in favor of data set when the menu is popped
172  * up - that is currently in the ItemFactory code, but should be
173  * in the Menu code.
174  */
175 GtkWidget* gtk_menu_get_attach_widget     (GtkMenu             *menu);
176
177 void       gtk_menu_set_tearoff_state     (GtkMenu             *menu,
178                                            gboolean             torn_off);
179 gboolean   gtk_menu_get_tearoff_state     (GtkMenu             *menu);
180
181 /* This sets the window manager title for the window that
182  * appears when a menu is torn off
183  */
184 void       gtk_menu_set_title             (GtkMenu             *menu,
185                                            const gchar         *title);
186 G_CONST_RETURN gchar *gtk_menu_get_title  (GtkMenu             *menu);
187
188 void       gtk_menu_reorder_child         (GtkMenu             *menu,
189                                            GtkWidget           *child,
190                                            gint                position);
191
192 void       gtk_menu_set_screen            (GtkMenu             *menu,
193                                            GdkScreen           *screen);
194
195 void       gtk_menu_attach                (GtkMenu             *menu,
196                                            GtkWidget           *child,
197                                            guint                left_attach,
198                                            guint                right_attach,
199                                            guint                top_attach,
200                                            guint                bottom_attach);
201
202 void       gtk_menu_set_monitor           (GtkMenu             *menu,
203                                            gint                 monitor_num);
204 gint       gtk_menu_get_monitor           (GtkMenu             *menu);
205 GList*     gtk_menu_get_for_attach_widget (GtkWidget           *widget); 
206
207 #ifndef GTK_DISABLE_DEPRECATED
208 #define gtk_menu_append(menu,child)     gtk_menu_shell_append  ((GtkMenuShell *)(menu),(child))
209 #define gtk_menu_prepend(menu,child)    gtk_menu_shell_prepend ((GtkMenuShell *)(menu),(child))
210 #define gtk_menu_insert(menu,child,pos) gtk_menu_shell_insert ((GtkMenuShell *)(menu),(child),(pos))
211 #endif /* GTK_DISABLE_DEPRECATED */
212
213 G_END_DECLS
214
215 #endif /* __GTK_MENU_H__ */