37
31
with Gtk.Box; use Gtk.Box;
38
32
with Gtk.Button; use Gtk.Button;
39
33
with Gtk.Check_Button; use Gtk.Check_Button;
34
with Gtk.Combo_Box; use Gtk.Combo_Box;
40
35
with Gtk.Enums; use Gtk.Enums;
41
36
with Gtk.Handlers; use Gtk.Handlers;
42
37
with Gtk.Image; use Gtk.Image;
43
38
with Gtk.Label; use Gtk.Label;
44
with Gtk.Menu; use Gtk.Menu;
45
39
with Gtk.Notebook; use Gtk.Notebook;
46
with Gtk.Option_Menu; use Gtk.Option_Menu;
47
with Gtk.Radio_Menu_Item; use Gtk.Radio_Menu_Item;
48
40
with Gtk.Separator; use Gtk.Separator;
49
41
with Gtk.Widget; use Gtk.Widget;
55
47
package Note_Cb is new Handlers.Callback (Gtk_Notebook_Record);
56
48
package Button_Cb is new Handlers.User_Callback
57
49
(Gtk_Check_Button_Record, Gtk_Notebook);
50
package Combo_Cb is new Handlers.User_Callback
51
(Gtk_Combo_Box_Record, Gtk_Notebook);
58
52
package Notebook_Cb is new Handlers.Callback (Gtk_Notebook_Record);
59
53
package Frame_Cb is new Handlers.User_Callback
60
54
(Gtk_Check_Button_Record, Gtk_Frame);
65
59
Book_Closed_Mask : Gdk_Bitmap;
66
60
Notebook : Gtk_Notebook;
63
(Button : access Gtk_Check_Button_Record'Class;
64
Child : in Gtk_Frame);
65
-- Fill all the space with tabs
68
(Button : access Gtk_Check_Button_Record'Class;
69
Child : in Gtk_Frame);
72
procedure Hide (Widget : access Gtk_Widget_Record'Class);
75
procedure Next_Page (Notebook : access Gtk_Notebook_Record'Class);
76
-- Switch to the next page
78
procedure Prev_Page (Notebook : access Gtk_Notebook_Record'Class);
79
-- Switch to the previous page
82
(Button : access Gtk_Check_Button_Record'Class;
83
Child : in Gtk_Frame);
85
procedure Create_Pages
86
(Notebook : access Gtk_Notebook_Record'Class;
89
-- Create the notebook pages
91
procedure Rotate_Notebook (Notebook : access Gtk_Notebook_Record'Class);
92
-- Rotate the tabs around the notebook
94
procedure Show_All_Pages (Notebook : access Gtk_Notebook_Record'Class);
97
procedure Change_Tabs_Display
98
(Combo : access Gtk_Combo_Box_Record'Class;
99
Notebook : Gtk_Notebook);
100
-- Change notebook to be displayed without tabs, with scrollable tabs or
101
-- with the standard tabs.
103
procedure Notebook_Popup
104
(Button : access Gtk_Check_Button_Record'Class;
105
Notebook : Gtk_Notebook);
106
-- Allow popup window to switch from a page to another
108
procedure Homogeneous
109
(Button : access Gtk_Check_Button_Record'Class;
110
Notebook : Gtk_Notebook);
111
-- Set tabs homogeneous
113
procedure Set_Tabs_Detachable
114
(Button : access Gtk_Check_Button_Record'Class;
115
Notebook : Gtk_Notebook);
116
-- Set tabs detachable
118
procedure Set_Tabs_Reorderable
119
(Button : access Gtk_Check_Button_Record'Class;
120
Notebook : Gtk_Notebook);
121
-- Set tabs reorderable
123
procedure Page_Switch
124
(Notebook : access Gtk_Notebook_Record'Class;
125
Params : Gtk.Arguments.Gtk_Args);
126
-- Switch the current page
186
252
Gtk_New (Check, "Fill tab");
187
253
Pack_Start (Hbox, Check, True, True, 5);
188
254
Set_Active (Check, True);
189
Frame_Cb.Connect (Check, "toggled",
190
Frame_Cb.To_Marshaller (Tab_Fill'Access),
257
Frame_Cb.To_Marshaller (Tab_Fill'Access),
193
260
Gtk_New (Check, "Expand tab");
194
261
Pack_Start (Hbox, Check, True, True, 5);
195
262
Set_Active (Check, True);
196
Frame_Cb.Connect (Check, "toggled",
197
Frame_Cb.To_Marshaller (Tab_Expand'Access),
265
Frame_Cb.To_Marshaller (Tab_Expand'Access),
200
268
Gtk_New (Check, "Pack end");
201
269
Pack_Start (Hbox, Check, True, True, 5);
202
270
Set_Active (Check, True);
203
Frame_Cb.Connect (Check, "toggled",
204
Frame_Cb.To_Marshaller (Tab_Pack'Access),
273
Frame_Cb.To_Marshaller (Tab_Pack'Access),
207
276
Gtk_New (Button, "Hide page");
208
277
Pack_Start (Vbox, Button, True, True, 5);
255
325
Show_All (Notebook);
256
326
end Show_All_Pages;
258
-----------------------
259
-- Standard_Notebook --
260
-----------------------
262
procedure Standard_Notebook (Notebook : access Gtk_Notebook_Record'Class) is
264
Set_Show_Tabs (Notebook, True);
265
Set_Scrollable (Notebook, False);
266
if Get_N_Pages (Notebook) = 15 then
268
Remove_Page (Notebook, 5);
271
end Standard_Notebook;
273
---------------------
274
-- Notabs_Notebook --
275
---------------------
277
procedure Notabs_Notebook (Notebook : access Gtk_Notebook_Record'Class) is
279
Set_Show_Tabs (Notebook, False);
280
if Get_N_Pages (Notebook) = 15 then
282
Remove_Page (Notebook, 5);
287
-------------------------
288
-- Scrollable_Notebook --
289
-------------------------
291
procedure Scrollable_Notebook (Notebook : access Gtk_Notebook_Record'Class)
328
-------------------------
329
-- Change_Tabs_Display --
330
-------------------------
332
procedure Change_Tabs_Display
333
(Combo : access Gtk_Combo_Box_Record'Class;
334
Notebook : Gtk_Notebook)
336
Active_Text : constant String := Get_Active_Text (Combo);
294
Set_Show_Tabs (Notebook, True);
295
Set_Scrollable (Notebook, True);
296
if Get_N_Pages (Notebook) = 5 then
297
Create_Pages (Notebook, 6, 15);
338
if Active_Text = "Standard" then
339
Set_Show_Tabs (Notebook, True);
340
Set_Scrollable (Notebook, False);
341
if Get_N_Pages (Notebook) = 15 then
343
Remove_Page (Notebook, 5);
346
elsif Active_Text = "w/o tabs" then
347
Set_Show_Tabs (Notebook, False);
348
if Get_N_Pages (Notebook) = 15 then
350
Remove_Page (Notebook, 5);
353
elsif Active_Text = "Scrollable" then
354
Set_Show_Tabs (Notebook, True);
355
Set_Scrollable (Notebook, True);
356
if Get_N_Pages (Notebook) = 5 then
357
Create_Pages (Notebook, 6, 15);
299
end Scrollable_Notebook;
360
end Change_Tabs_Display;
301
362
--------------------
302
363
-- Notebook_Popup --
303
364
--------------------
305
procedure Notebook_Popup (Button : access Gtk_Check_Button_Record'Class;
306
Notebook : in Gtk_Notebook) is
366
procedure Notebook_Popup
367
(Button : access Gtk_Check_Button_Record'Class;
368
Notebook : Gtk_Notebook) is
308
370
if Get_Active (Button) then
309
371
Popup_Enable (Notebook);
316
378
-- Homogeneous --
317
379
-----------------
319
procedure Homogeneous (Button : access Gtk_Check_Button_Record'Class;
320
Notebook : in Gtk_Notebook) is
381
procedure Homogeneous
382
(Button : access Gtk_Check_Button_Record'Class;
383
Notebook : Gtk_Notebook) is
323
386
(Notebook, Gtk.Notebook.Homogeneous_Property, Get_Active (Button));
389
--------------------------
390
-- Set_Pages_Detachable --
391
--------------------------
393
procedure Set_Tabs_Detachable
394
(Button : access Gtk_Check_Button_Record'Class;
395
Notebook : Gtk_Notebook) is
397
for N in 0 .. Get_N_Pages (Notebook) - 1 loop
399
(Notebook, Get_Nth_Page (Notebook, N), Get_Active (Button));
401
end Set_Tabs_Detachable;
403
---------------------------
404
-- Set_Pages_Reorderable --
405
---------------------------
407
procedure Set_Tabs_Reorderable
408
(Button : access Gtk_Check_Button_Record'Class;
409
Notebook : Gtk_Notebook) is
411
for N in 0 .. Get_N_Pages (Notebook) - 1 loop
413
(Notebook, Get_Nth_Page (Notebook, N), Get_Active (Button));
415
end Set_Tabs_Reorderable;
326
417
-----------------
327
418
-- Page_Switch --
328
419
-----------------
363
454
procedure Run (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is
366
Option_Menu : Gtk_Option_Menu;
368
Menu_Item : Gtk_Radio_Menu_Item;
369
Group : Widget_SList.GSlist;
370
Button : Gtk_Check_Button;
371
Button2 : Gtk_Button;
373
Separator : Gtk_Separator;
457
Combo : Gtk_Combo_Box;
458
Button : Gtk_Check_Button;
459
Button2 : Gtk_Button;
461
Separator : Gtk_Separator;
376
464
Set_Label (Frame, "Notebook");
386
475
Set_Border_Width (Notebook, 10);
387
476
Realize (Notebook);
389
Create_From_Xpm_D (Book_Open,
390
Get_Window (Notebook),
391
Book_Open_Mask, Null_Color,
393
Create_From_Xpm_D (Book_Closed,
394
Get_Window (Notebook),
395
Book_Closed_Mask, Null_Color,
480
Get_Window (Notebook),
481
Book_Open_Mask, Null_Color,
485
Get_Window (Notebook),
486
Book_Closed_Mask, Null_Color,
398
489
Create_Pages (Notebook, 1, 5);
415
506
(Button, "clicked",
416
507
Button_Cb.To_Marshaller (Homogeneous'Access), Notebook);
509
Gtk_New (Button, "reorderable tabs");
510
Pack_Start (Box2, Button, True, False, 0);
513
Button_Cb.To_Marshaller (Set_Tabs_Reorderable'Access), Notebook);
515
Gtk_New (Button, "detachable tabs");
516
Pack_Start (Box2, Button, True, False, 0);
519
Button_Cb.To_Marshaller (Set_Tabs_Detachable'Access), Notebook);
418
521
Gtk_New_Hbox (Box2, False, 5);
419
522
Set_Border_Width (Box2, 10);
420
523
Pack_Start (Box1, Box2, False, True, 0);
422
525
Gtk_New (Label, "Notebook Style :");
423
526
Pack_Start (Box2, Label, False, True, 0);
425
Gtk_New (Option_Menu);
428
Gtk_New (Menu_Item, Group, "Standard");
429
Note_Cb.Object_Connect
430
(Menu_Item, "activate",
431
Note_Cb.To_Marshaller (Standard_Notebook'Access),
432
Slot_Object => Notebook);
433
Group := Gtk.Radio_Menu_Item.Get_Group (Menu_Item);
434
Append (Menu, Menu_Item);
437
Gtk_New (Menu_Item, Group, "w/o Tabs");
438
Note_Cb.Object_Connect
439
(Menu_Item, "activate",
440
Note_Cb.To_Marshaller (Notabs_Notebook'Access),
441
Slot_Object => Notebook);
442
Group := Gtk.Radio_Menu_Item.Get_Group (Menu_Item);
443
Append (Menu, Menu_Item);
446
Gtk_New (Menu_Item, Group, "Scrollable");
447
Note_Cb.Object_Connect
448
(Menu_Item, "activate",
449
Note_Cb.To_Marshaller (Scrollable_Notebook'Access),
450
Slot_Object => Notebook);
451
Group := Gtk.Radio_Menu_Item.Get_Group (Menu_Item);
452
Append (Menu, Menu_Item);
455
Set_Menu (Option_Menu, Menu);
456
Pack_Start (Box2, Option_Menu, False, False, 0);
528
Gtk_New_Text (Combo);
529
Append_Text (Combo, "Standard");
530
Append_Text (Combo, "w/o tabs");
531
Append_Text (Combo, "Scrollable");
534
Combo_Cb.To_Marshaller (Change_Tabs_Display'Access), Notebook);
535
Pack_Start (Box2, Combo, False, False, 0);
458
537
Gtk_New (Button2, "Show all pages");
459
538
Pack_Start (Box2, Button2, False, True, 0);