File: gtk-paned.ads

package info (click to toggle)
libgtkada2 2.8.1-6lenny3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 13,496 kB
  • ctags: 3,886
  • sloc: ada: 103,189; ansic: 45,411; perl: 5,500; sh: 2,812; makefile: 1,169; xml: 19
file content (351 lines) | stat: -rw-r--r-- 14,853 bytes parent folder | download | duplicates (2)
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
-----------------------------------------------------------------------
--               GtkAda - Ada95 binding for Gtk+/Gnome               --
--                                                                   --
--   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   --
--                Copyright (C) 2000-2006 AdaCore                    --
--                                                                   --
-- This library is free software; you can redistribute it and/or     --
-- modify it under the terms of the GNU General Public               --
-- License as published by the Free Software Foundation; either      --
-- version 2 of the License, or (at your option) any later version.  --
--                                                                   --
-- This library is distributed in the hope that it will be useful,   --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of    --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU --
-- General Public License for more details.                          --
--                                                                   --
-- You should have received a copy of the GNU General Public         --
-- License along with this library; if not, write to the             --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      --
-- Boston, MA 02111-1307, USA.                                       --
--                                                                   --
-----------------------------------------------------------------------

--  <description>
--  A Gtk_Paned is a container that organizes its two children either
--  horizontally or vertically.
--  The initial size allocated to the children depends on the size
--  they request. However, the user has the possibility to interactively
--  move a separation bar between the two to enlarge one of the children,
--  while at the same time shrinking the second one.
--  The bar can be moved by clicking with the mouse on a small cursor
--  displayed in the bar, and then dragging the mouse.
--
--  No additional decoration is provided around the children.
--
--  Each child has two parameters, Resize and Shrink.
--
--  If Shrink is True, then the widget can be made smaller than its
--  requisition size by the user. Set this to False if you want to
--  set a minimum size.
--
--  if Resize is True, this means that the child accepts to be resized, and
--  will not require any size. Thus, the size allocated to it will be
--  the total size allocated to the container minus the size requested by
--  the other child.
--  If Resize is False, the child should ask for a specific size, which it
--  will get. The other child will be resized accordingly.
--  If both Child have the same value for Resize (either True or False), then
--  the size allocated to each is a ratio between the size requested by both.
--
--  When you use Set_Position with a parameter other than -1, or the user
--  moves the handle to resize the widgets, the behavior of Resize is
--  canceled.
--
--  </description>
--  <c_version>2.8.17</c_version>
--  <group>Layout containers</group>
--  <testgtk>create_paned.adb</testgtk>
--  <screenshot>gtk-paned</screenshot>

with Glib.Properties;
with Gtk.Container;
with Gtk.Widget; use Gtk.Widget;

package Gtk.Paned is

   type Gtk_Paned_Record is new
     Gtk.Container.Gtk_Container_Record with private;
   subtype Gtk_Hpaned_Record is Gtk_Paned_Record;
   subtype Gtk_Vpaned_Record is Gtk_Paned_Record;

   type Gtk_Paned is access all Gtk_Paned_Record'Class;
   subtype Gtk_Hpaned is Gtk_Paned;
   subtype Gtk_Vpaned is Gtk_Paned;

   procedure Gtk_New_Vpaned (Widget : out Gtk_Paned);
   --  Create a new vertical container.
   --  The children will be displayed one on top of the other.

   procedure Gtk_New_Hpaned (Widget : out Gtk_Paned);
   --  Create a new horizontal container.
   --  The children will be displayed one besides the other.

   procedure Initialize_Vpaned (Widget : access Gtk_Paned_Record'Class);
   --  Internal initialization function.
   --  See the section "Creating your own widgets" in the documentation.

   procedure Initialize_Hpaned (Widget : access Gtk_Paned_Record'Class);
   --  Internal initialization function.
   --  See the section "Creating your own widgets" in the documentation.

   function Get_Type return Glib.GType;
   function Get_Type_Vpaned return Glib.GType;
   function Get_Type_Hpaned return Glib.GType;
   --  Return the internal value associated with a Gtk_Paned.

   procedure Add1
     (Paned : access Gtk_Paned_Record;
      Child : access Gtk_Widget_Record'Class);
   --  Add the first child of the container.
   --  The child will be displayed either in the top or in the left pane,
   --  depending on the orientation of the container.
   --  This is equivalent to using the Pack1 procedure with its default
   --  parameters.

   procedure Pack1
     (Paned  : access Gtk_Paned_Record;
      Child  : access Gtk_Widget_Record'Class;
      Resize : Boolean := False;
      Shrink : Boolean := True);
   --  Add a child to the top or left pane.
   --  You can not change dynamically the attributes Resize and Shrink.
   --  Instead, you have to remove the child from the container, and put it
   --  back with the new value of the attributes. You should also first
   --  call Gtk.Object.Ref on the child so as to be sure it is not destroyed
   --  when you remove it, and Gtk.Object.Unref it at the end. See the
   --  example in testgtk/ in the GtkAda distribution.

   procedure Add2
     (Paned : access Gtk_Paned_Record;
      Child : access Gtk_Widget_Record'Class);
   --  Add the second child of the container.
   --  It will be displayed in the bottom or right pane, depending on the
   --  container's orientation.
   --  This is equivalent to using Pack2 with its default parameters.

   procedure Pack2
     (Paned  : access Gtk_Paned_Record;
      Child  : access Gtk_Widget_Record'Class;
      Resize : Boolean := False;
      Shrink : Boolean := False);
   --  Add a child to the bottom or right pane.

   procedure Set_Position (Paned : access Gtk_Paned_Record; Position : Gint);
   function  Get_Position (Paned : access Gtk_Paned_Record) return Gint;
   --  Change or get the position of the separator.
   --  If position is negative, the remembered position is forgotten,
   --  and the division is recomputed from the requisitions of the
   --  children.
   --  Position is in fact the size (either vertically or horizontally,
   --  depending on the container) set for the first child.

   function Get_Child1
     (Paned : access Gtk_Paned_Record) return Gtk.Widget.Gtk_Widget;
   --  Return the child displayed in the top or left pane.

   function Get_Child2
     (Paned : access Gtk_Paned_Record) return Gtk.Widget.Gtk_Widget;
   --  Return the child displayed in the bottom or right pane.

   function Get_Child1_Resize
     (Paned : access Gtk_Paned_Record) return Boolean;
   --  Get the value of the resize attribute for the first child.

   function Get_Child2_Resize (Paned : access Gtk_Paned_Record) return Boolean;
   --  Get the value of the resize attribute for the second child.

   function Get_Child1_Shrink (Paned : access Gtk_Paned_Record) return Boolean;
   --  Get the value of the shrink attribute for the first child.

   function Get_Child2_Shrink (Paned : access Gtk_Paned_Record) return Boolean;
   --  Get the value of the shrink attribute for the second child.

   -----------------
   -- Obsolescent --
   -----------------
   --  All subprograms below are now obsolescent in gtk+. They might be removed
   --  from future versions of gtk+ (and therefore GtkAda).
   --  To find out whether your code uses any of these, we recommend compiling
   --  with the -gnatwj switch
   --  <doc_ignore>

   procedure Set_Handle_Size (Paned : access Gtk_Paned_Record; Size : Guint16);
   pragma Obsolescent;
   --  Do nothing.
   --  Only provided for compatibility.

   function Get_Handle_Size (Paned : access Gtk_Paned_Record) return Guint16;
   pragma Obsolescent;
   --  Return 0.
   --  Only provided for compatibility.

   procedure Set_Gutter_Size (Paned : access Gtk_Paned_Record; Size : Guint16);
   pragma Obsolescent;
   --  Do nothing.
   --  Only provided for compatibility.

   function Get_Gutter_Size (Paned : access Gtk_Paned_Record) return Guint16;
   pragma Obsolescent;
   --  Return 0.
   --  Only provided for compatibility.

   --  </doc_ignore>

   ----------------
   -- Properties --
   ----------------
   --  The following properties are defined for this widget. See
   --  Glib.Properties for more information on properties.

   --  <properties>
   --  Name:  Max_Position_Property
   --  Type:  Int
   --  Descr: Largest possible value for the "position" property
   --
   --  Name:  Min_Position_Property
   --  Type:  Int
   --  Descr: Smallest possible value for the "position" property. This is
   --         derived from the size and shrinkability of the widget
   --
   --  Name:  Position_Property
   --  Type:  Int
   --  Descr: Position of paned separator in pixels (0 means all the way to the
   --         left/top)
   --
   --  Name:  Position_Set_Property
   --  Type:  Boolean
   --  Descr: TRUE if the Position property should be used
   --  </properties>

   Max_Position_Property : constant Glib.Properties.Property_Int;
   Min_Position_Property : constant Glib.Properties.Property_Int;
   Position_Property     : constant Glib.Properties.Property_Int;
   Position_Set_Property : constant Glib.Properties.Property_Boolean;

   ----------------------
   -- Child Properties --
   ----------------------
   --  The following properties can be set on children of this widget. See
   --  in particular Gtk.Containers.Child_Set_Property.

   --  <child_properties>
   --  Name:  Resize_Property
   --  Type:  Boolean
   --  Descr: If TRUE, the child expands and shrinks along with the paned
   --         widget
   --
   --  Name:  Shrink_Property
   --  Type:  Boolean
   --  Descr: If TRUE, the child can be made smaller than its requisition
   --  </child_properties>

   Resize_Property : constant Glib.Properties.Property_Boolean;
   Shrink_Property : constant Glib.Properties.Property_Boolean;

   ----------------------
   -- Style Properties --
   ----------------------
   --  The following properties can be changed through the gtk theme and
   --  configuration files, and retrieved through Gtk.Widget.Style_Get_Property

   --  <style_properties>
   --  Name:  Handle_Size_Property
   --  Type:  Int
   --  Descr: Width of handle
   --  </style_properties>

   Handle_Size_Property : constant Glib.Properties.Property_Int;

   -------------
   -- Signals --
   -------------

   --  <signals>
   --  The following new signals are defined for this widget:
   --
   --  - "accept_position"
   --    procedure Handler (Paned : access Gtk_Paned_Record'Class);
   --    You should emit this signal to request that the current handle
   --    position be considered as valid, and the focus moved out of the
   --    handle. By default, this is bound to the key <enter>, so that after
   --    resizing through the keyboard (see cycle_handle_focus), the user can
   --    validate the new position
   --
   --  - "cancel_position"
   --    procedure Handler (Paned : access Gtk_Paned_Record'Class);
   --    Similar to accept_position, but cancel the last resizing operation.
   --    This is bound to <esc> by default.
   --
   --  - "cycle_child_focus"
   --    procedure Handler
   --       (Paned   : access Gtk_Paned_Record'Class;
   --        To_Next : Boolean);
   --    You should emit this signal to request that the child be moved to the
   --    next child of paned. After the last child, the focus is moved to the
   --    parent of Paned (if it is a Gtk_Paned_Record itself),...
   --    This signal is mostly intended to be used from a keybinding (by
   --    default, gtk+ attaches it to F6 and shift-F6).
   --
   --  - "cycle_handle_focus"
   --    procedure Handler
   --       (Paned   : access Gtk_Paned_Record'Class;
   --        To_Next : Boolean);
   --    You should emit this signal to request that the focus be given to the
   --    handle, so that the user can then resize the children through the
   --    keyboard. It it mostly intended to be used from a keybinding. By
   --    default, gtk+ attaches it to F8. The children can then be resized
   --    with the arrow keys, PageUp, PageDown, Home and End.
   --
   --  - "move_handle"
   --    procedure Handler
   --       (Paned : access Gtk_Paned_Record'Class;
   --        Typ   : Gtk_Scroll_Type);
   --    You should emit this signal to request a resizing of the children.
   --    This is mostly useful when bound to keys, so that when the handle has
   --    the focus (cycle_handle_focus), the children can be resized with the
   --    arrow keys, PageUp, PageDown, Home and End
   --
   --  - "toggle_handle_focus"
   --    procedure Handler (Paned : access Gtk_Paned_Record'Class);
   --    Mostly intended to be bound to a keybinding. When called, this removes
   --    the keyboard focus from the handle (if it was given through
   --    cycle_handle_focus above).
   --
   --  </signals>

   Signal_Accept_Position     : constant String := "accept_position";
   Signal_Cancel_Position     : constant String := "cancel_position";
   Signal_Cycle_Child_Focus   : constant String := "cycle_child_focus";
   Signal_Cycle_Handle_Focus  : constant String := "cycle_handle_focus";
   Signal_Move_Handle         : constant String := "move_handle";
   Signal_Toggle_Handle_Focus : constant String := "toggle_handle_focus";

private
   type Gtk_Paned_Record is new Gtk.Container.Gtk_Container_Record
   with null record;

   Max_Position_Property : constant Glib.Properties.Property_Int :=
     Glib.Properties.Build ("max-position");
   Min_Position_Property : constant Glib.Properties.Property_Int :=
     Glib.Properties.Build ("min-position");
   Position_Property : constant Glib.Properties.Property_Int :=
     Glib.Properties.Build ("position");
   Position_Set_Property : constant Glib.Properties.Property_Boolean :=
     Glib.Properties.Build ("position-set");

   Resize_Property : constant Glib.Properties.Property_Boolean :=
     Glib.Properties.Build ("resize");
   Shrink_Property : constant Glib.Properties.Property_Boolean :=
     Glib.Properties.Build ("shrink");

   Handle_Size_Property : constant Glib.Properties.Property_Int :=
     Glib.Properties.Build ("handle-size");

   pragma Import (C, Get_Type, "gtk_paned_get_type");
   pragma Import (C, Get_Type_Vpaned, "gtk_vpaned_get_type");
   pragma Import (C, Get_Type_Hpaned, "gtk_hpaned_get_type");
end Gtk.Paned;

--  Was never implemented, and is now obsolescent anyway:
--  No binding: gtk_paned_compute_position