/packages/gtk1/examples/tutorial/tut6_4.pp
Puppet | 87 lines | 66 code | 21 blank | 0 comment | 0 complexity | 4667a1a82f6455fdc7c281f225948723 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
1{ 2 3 This file extracted from the GTK 1.2 tutorial. 4 Section 6.4 5 6 Converted from C to Pascal by Thomas E. Payne 7} 8 program Tut6_4; 9 10{$mode objfpc} 11 12 uses 13 glib,gdk,gtk,sysutils; 14 15 //* example-start radiobuttons radiobuttons.c *// 16 17 procedure close_application( widget : pGtkWidget; 18 event : pGdkEvent; 19 data : gpointer ); cdecl; 20 begin 21 gtk_main_quit(); 22 end; 23 24 var 25 window,box1,box2,button,separator : pGtkWidget; 26 group : pGSList; 27 28 begin 29 gtk_init(@argc,@argv); 30 31 window := Nil; 32 33 window := gtk_window_new (GTK_WINDOW_TOPLEVEL); 34 35 gtk_signal_connect (GTK_OBJECT (window), 'delete_event', 36 GTK_SIGNAL_FUNC(@close_application), 37 Nil); 38 39 gtk_window_set_title (GTK_WINDOW (window), 'radio buttons'); 40 gtk_container_set_border_width (GTK_CONTAINER (window), 0); 41 42 box1 := gtk_vbox_new (FALSE, 0); 43 gtk_container_add (GTK_CONTAINER (window), box1); 44 gtk_widget_show (box1); 45 46 box2 := gtk_vbox_new (FALSE, 10); 47 gtk_container_set_border_width (GTK_CONTAINER (box2), 10); 48 gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); 49 gtk_widget_show (box2); 50 51 button := gtk_radio_button_new_with_label (Nil, 'button1'); 52 gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); 53 gtk_widget_show (button); 54 55 group := gtk_radio_button_group (GTK_RADIO_BUTTON (button)); 56 button := gtk_radio_button_new_with_label(group, 'button2'); 57 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); 58 gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); 59 gtk_widget_show (button); 60 61 button := gtk_radio_button_new_with_label( 62 gtk_radio_button_group (GTK_RADIO_BUTTON (button)), 63 'button3'); 64 gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); 65 gtk_widget_show (button); 66 67 separator := gtk_hseparator_new (); 68 gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0); 69 gtk_widget_show (separator); 70 71 box2 := gtk_vbox_new (FALSE, 10); 72 gtk_container_set_border_width (GTK_CONTAINER (box2), 10); 73 gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0); 74 gtk_widget_show (box2); 75 76 button := gtk_button_new_with_label ('close'); 77 gtk_signal_connect_object (GTK_OBJECT (button), 'clicked', 78 GTK_SIGNAL_FUNC(@close_application), 79 GTK_OBJECT (window)); 80 gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); 81 GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); 82 gtk_widget_grab_default (button); 83 gtk_widget_show (button); 84 gtk_widget_show (window); 85 86 gtk_main(); 87 end.