summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/gtk2/src/gtk+/gtk/gtkmenu.inc
blob: 28e90644a270a667afc4cd8880a32ceec9956559 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
// included by gtk2.pas

{$IFDEF read_forward_definitions}
   PGtkMenu = ^TGtkMenu;

{$ENDIF read_forward_definitions}

//------------------------------------------------------------------------------

{$IFDEF read_interface_types}
   TGtkMenuPositionFunc = procedure (menu:PGtkMenu; x:Pgint; y:Pgint; push_in:Pgboolean; user_data:gpointer); cdecl;

   TGtkMenuDetachFunc = procedure (attach_widget:PGtkWidget; menu:PGtkMenu); cdecl;
{ Do _not_ touch these widgets directly. We hide the reference
     count from the toplevel to the menu, so it must be restored
     before operating on these widgets
    }
{ When a submenu of this menu is popped up, motion in this
     region is ignored
    }
{ The tearoff is active when it is torn off and the not-torn-off
     menu is not popped up.
    }
   TGtkMenu = record
        menu_shell : TGtkMenuShell;
        parent_menu_item : PGtkWidget;
        old_active_menu_item : PGtkWidget;
        accel_group : PGtkAccelGroup;
        accel_path : Pgchar;
        position_func : TGtkMenuPositionFunc;
        position_func_data : gpointer;
        toggle_size : guint;
        toplevel : PGtkWidget;
        tearoff_window : PGtkWidget;
        tearoff_hbox : PGtkWidget;
        tearoff_scrollbar : PGtkWidget;
        tearoff_adjustment : PGtkAdjustment;
        view_window : PGdkWindow;
        bin_window : PGdkWindow;
        scroll_offset : gint;
        saved_scroll_offset : gint;
        scroll_step : gint;
        timeout_id : guint;
        navigation_region : PGdkRegion;
        navigation_timeout : guint;
        flag0 : word;
     end;


{ Padding for future expansion  }
   PGtkMenuClass = ^TGtkMenuClass;
   TGtkMenuClass = record
        parent_class : TGtkMenuShellClass;
        _gtk_reserved1 : procedure ; cdecl;
        _gtk_reserved2 : procedure ; cdecl;
        _gtk_reserved3 : procedure ; cdecl;
        _gtk_reserved4 : procedure ; cdecl;
     end;

{$ENDIF read_interface_types}

//------------------------------------------------------------------------------

{$IFDEF read_interface_rest}
const
   bm_TGtkMenu_needs_destruction_ref_count = $1;
   bp_TGtkMenu_needs_destruction_ref_count = 0;
   bm_TGtkMenu_torn_off = $2;
   bp_TGtkMenu_torn_off = 1;
   bm_TGtkMenu_tearoff_active = $4;
   bp_TGtkMenu_tearoff_active = 2;
   bm_TGtkMenu_scroll_fast = $8;
   bp_TGtkMenu_scroll_fast = 3;
   bm_TGtkMenu_upper_arrow_visible = $10;
   bp_TGtkMenu_upper_arrow_visible = 4;
   bm_TGtkMenu_lower_arrow_visible = $20;
   bp_TGtkMenu_lower_arrow_visible = 5;
   bm_TGtkMenu_upper_arrow_prelight = $40;
   bp_TGtkMenu_upper_arrow_prelight = 6;
   bm_TGtkMenu_lower_arrow_prelight = $80;
   bp_TGtkMenu_lower_arrow_prelight = 7;


function GTK_TYPE_MENU : GType;
function GTK_MENU(obj: pointer) : PGtkMenu;
function GTK_MENU_CLASS(klass: pointer) : PGtkMenuClass;
function GTK_IS_MENU(obj: pointer) : boolean;
function GTK_IS_MENU_CLASS(klass: pointer) : boolean;
function GTK_MENU_GET_CLASS(obj: pointer) : PGtkMenuClass;


function needs_destruction_ref_count(var a : TGtkMenu) : guint;
procedure set_needs_destruction_ref_count(var a : TGtkMenu; __needs_destruction_ref_count : guint);
function torn_off(var a : TGtkMenu) : guint; overload;
procedure set_torn_off(var a : TGtkMenu; __torn_off : guint); overload;
function tearoff_active(var a : TGtkMenu) : guint;
procedure set_tearoff_active(var a : TGtkMenu; __tearoff_active : guint);
function scroll_fast(var a : TGtkMenu) : guint;
procedure set_scroll_fast(var a : TGtkMenu; __scroll_fast : guint);
function upper_arrow_visible(var a : TGtkMenu) : guint;
procedure set_upper_arrow_visible(var a : TGtkMenu; __upper_arrow_visible : guint);
function lower_arrow_visible(var a : TGtkMenu) : guint;
procedure set_lower_arrow_visible(var a : TGtkMenu; __lower_arrow_visible : guint);
function upper_arrow_prelight(var a : TGtkMenu) : guint;
procedure set_upper_arrow_prelight(var a : TGtkMenu; __upper_arrow_prelight : guint);
function lower_arrow_prelight(var a : TGtkMenu) : guint;
procedure set_lower_arrow_prelight(var a : TGtkMenu; __lower_arrow_prelight : guint);

function gtk_menu_get_type:TGtkType; cdecl; external gtklib;
function gtk_menu_new:PGtkWidget; cdecl; external gtklib;
{ Display the menu onscreen  }
procedure gtk_menu_popup(menu:PGtkMenu; parent_menu_shell:PGtkWidget; parent_menu_item:PGtkWidget; func:TGtkMenuPositionFunc; data:gpointer;
            button:guint; activate_time:guint32); cdecl; external gtklib;
{ Position the menu according to its position function. Called
   from gtkmenuitem.c when a menu-item changes its allocation
  }
procedure gtk_menu_reposition(menu:PGtkMenu); cdecl; external gtklib;
procedure gtk_menu_popdown(menu:PGtkMenu); cdecl; external gtklib;
{ Keep track of the last menu item selected. (For the purposes
   of the option menu
  }
function gtk_menu_get_active(menu:PGtkMenu):PGtkWidget; cdecl; external gtklib;
procedure gtk_menu_set_active(menu:PGtkMenu; index:guint); cdecl; external gtklib;
{ set/get the accelerator group that holds global accelerators (should
   be added to the corresponding toplevel with gtk_window_add_accel_group().
  }
procedure gtk_menu_set_accel_group(menu:PGtkMenu; accel_group:PGtkAccelGroup); cdecl; external gtklib;
function gtk_menu_get_accel_group(menu:PGtkMenu):PGtkAccelGroup; cdecl; external gtklib;
procedure gtk_menu_set_accel_path(menu:PGtkMenu; accel_path:Pgchar); cdecl; external gtklib;
{ A reference count is kept for a widget when it is attached to
   a particular widget. This is typically a menu item; it may also
   be a widget with a popup menu - for instance, the Notebook widget.
  }
procedure gtk_menu_attach_to_widget(menu:PGtkMenu; attach_widget:PGtkWidget; detacher:TGtkMenuDetachFunc); cdecl; external gtklib;
procedure gtk_menu_detach(menu:PGtkMenu); cdecl; external gtklib;
{ This should be dumped in favor of data set when the menu is popped
   up - that is currently in the ItemFactory code, but should be
   in the Menu code.
  }
function gtk_menu_get_attach_widget(menu:PGtkMenu):PGtkWidget; cdecl; external gtklib;
procedure gtk_menu_set_tearoff_state(menu:PGtkMenu; torn_off:gboolean); cdecl; external gtklib;
function gtk_menu_get_tearoff_state(menu:PGtkMenu):gboolean; cdecl; external gtklib;
{ This sets the window manager title for the window that
   appears when a menu is torn off
  }
procedure gtk_menu_set_title(menu:PGtkMenu; title:Pgchar); cdecl; external gtklib;
function gtk_menu_get_title(menu:PGtkMenu):Pgchar; cdecl; external gtklib;
procedure gtk_menu_reorder_child(menu:PGtkMenu; child:PGtkWidget; position:gint); cdecl; external gtklib;

{$ifndef GTK_DISABLE_DEPRECATED}
procedure gtk_menu_append(menu,child : PGtkWidget);
procedure gtk_menu_prepend(menu,child : PGtkWidget);
procedure gtk_menu_insert(menu,child: PGtkWidget; pos : gint);
{$endif}
{ GTK_DISABLE_DEPRECATED  }

{$IFDEF HasGTK2_2}
procedure gtk_menu_set_screen(menu:PGtkMenu; screen:PGdkScreen); cdecl; external gtklib;
{$ENDIF}

{$ifdef HasGTK2_4}
procedure gtk_menu_attach(menu: PGtkMenu; child: PGtkWidget; left_attach: guint; right_attach: guint; top_attach: guint; bottom_attach: guint); cdecl; external gtklib;
procedure gtk_menu_set_monitor(menu: PGtkMenu; monitor_num: gint); cdecl; external gtklib;
{$endif}

{$ifdef HasGTK2_6}
function gtk_menu_get_for_attach_widget(widget:PGtkWidget):PGList; cdecl; external gtklib;
{$endif}

{$ENDIF read_interface_rest}

//------------------------------------------------------------------------------

{$IFDEF read_implementation}
function GTK_TYPE_MENU : GType;
begin
   GTK_TYPE_MENU:=gtk_menu_get_type;
end;

function GTK_MENU(obj: pointer) : PGtkMenu;
begin
   GTK_MENU:=PGtkMenu(GTK_CHECK_CAST(obj,GTK_TYPE_MENU));
end;

function GTK_MENU_CLASS(klass: pointer) : PGtkMenuClass;
begin
   GTK_MENU_CLASS:=PGtkMenuClass(GTK_CHECK_CLASS_CAST(klass,GTK_TYPE_MENU));
end;

function GTK_IS_MENU(obj: pointer) : boolean;
begin
   GTK_IS_MENU:=GTK_CHECK_TYPE(obj,GTK_TYPE_MENU);
end;

function GTK_IS_MENU_CLASS(klass: pointer) : boolean;
begin
   GTK_IS_MENU_CLASS:=GTK_CHECK_CLASS_TYPE(klass,GTK_TYPE_MENU);
end;

function GTK_MENU_GET_CLASS(obj: pointer) : PGtkMenuClass;
begin
   GTK_MENU_GET_CLASS:=PGtkMenuClass(GTK_CHECK_GET_CLASS(obj,GTK_TYPE_MENU));
end;

function needs_destruction_ref_count(var a : TGtkMenu) : guint;
begin
   needs_destruction_ref_count:=(a.flag0 and bm_TGtkMenu_needs_destruction_ref_count) shr bp_TGtkMenu_needs_destruction_ref_count;
end;

procedure set_needs_destruction_ref_count(var a : TGtkMenu; __needs_destruction_ref_count : guint);
begin
   a.flag0:=a.flag0 or ((__needs_destruction_ref_count shl bp_TGtkMenu_needs_destruction_ref_count) and bm_TGtkMenu_needs_destruction_ref_count);
end;

function torn_off(var a : TGtkMenu) : guint;
begin
   torn_off:=(a.flag0 and bm_TGtkMenu_torn_off) shr bp_TGtkMenu_torn_off;
end;

procedure set_torn_off(var a : TGtkMenu; __torn_off : guint);
begin
   a.flag0:=a.flag0 or ((__torn_off shl bp_TGtkMenu_torn_off) and bm_TGtkMenu_torn_off);
end;

function tearoff_active(var a : TGtkMenu) : guint;
begin
   tearoff_active:=(a.flag0 and bm_TGtkMenu_tearoff_active) shr bp_TGtkMenu_tearoff_active;
end;

procedure set_tearoff_active(var a : TGtkMenu; __tearoff_active : guint);
begin
   a.flag0:=a.flag0 or ((__tearoff_active shl bp_TGtkMenu_tearoff_active) and bm_TGtkMenu_tearoff_active);
end;

function scroll_fast(var a : TGtkMenu) : guint;
begin
   scroll_fast:=(a.flag0 and bm_TGtkMenu_scroll_fast) shr bp_TGtkMenu_scroll_fast;
end;

procedure set_scroll_fast(var a : TGtkMenu; __scroll_fast : guint);
begin
   a.flag0:=a.flag0 or ((__scroll_fast shl bp_TGtkMenu_scroll_fast) and bm_TGtkMenu_scroll_fast);
end;

function upper_arrow_visible(var a : TGtkMenu) : guint;
begin
   upper_arrow_visible:=(a.flag0 and bm_TGtkMenu_upper_arrow_visible) shr bp_TGtkMenu_upper_arrow_visible;
end;

procedure set_upper_arrow_visible(var a : TGtkMenu; __upper_arrow_visible : guint);
begin
   a.flag0:=a.flag0 or ((__upper_arrow_visible shl bp_TGtkMenu_upper_arrow_visible) and bm_TGtkMenu_upper_arrow_visible);
end;

function lower_arrow_visible(var a : TGtkMenu) : guint;
begin
   lower_arrow_visible:=(a.flag0 and bm_TGtkMenu_lower_arrow_visible) shr bp_TGtkMenu_lower_arrow_visible;
end;

procedure set_lower_arrow_visible(var a : TGtkMenu; __lower_arrow_visible : guint);
begin
   a.flag0:=a.flag0 or ((__lower_arrow_visible shl bp_TGtkMenu_lower_arrow_visible) and bm_TGtkMenu_lower_arrow_visible);
end;

function upper_arrow_prelight(var a : TGtkMenu) : guint;
begin
   upper_arrow_prelight:=(a.flag0 and bm_TGtkMenu_upper_arrow_prelight) shr bp_TGtkMenu_upper_arrow_prelight;
end;

procedure set_upper_arrow_prelight(var a : TGtkMenu; __upper_arrow_prelight : guint);
begin
   a.flag0:=a.flag0 or ((__upper_arrow_prelight shl bp_TGtkMenu_upper_arrow_prelight) and bm_TGtkMenu_upper_arrow_prelight);
end;

function lower_arrow_prelight(var a : TGtkMenu) : guint;
begin
   lower_arrow_prelight:=(a.flag0 and bm_TGtkMenu_lower_arrow_prelight) shr bp_TGtkMenu_lower_arrow_prelight;
end;

procedure set_lower_arrow_prelight(var a : TGtkMenu; __lower_arrow_prelight : guint);
begin
   a.flag0:=a.flag0 or ((__lower_arrow_prelight shl bp_TGtkMenu_lower_arrow_prelight) and bm_TGtkMenu_lower_arrow_prelight);
end;

procedure gtk_menu_append(menu,child : PGtkWidget);
begin
   gtk_menu_shell_append(PGtkMenuShell(menu),child);
end;

procedure gtk_menu_prepend(menu,child : PGtkWidget);
begin
   gtk_menu_shell_prepend(PGtkMenuShell(menu),child);
end;

procedure gtk_menu_insert(menu,child: PGtkWidget; pos : gint);
begin
   gtk_menu_shell_insert(PGtkMenuShell(menu),child,pos);
end;

{$ENDIF read_implementation}
// included by gtk2.pas