1{ Demo showing activating and deactivating objects
2}
3program objin;
4
5uses xforms;
6
7var
8form : PFL_FORM;
9
10        button1,
11        button2,
12        button3,
13        button4,
14        group,
15        firstbut : PFL_OBJECT;
16
17procedure  exit_cb(obj : PFL_OBJECT; arg : longint); cdecl;
18begin
19 halt;
20end;
21
22
23
24Procedure setit(obj : PFL_OBJECT; val : longint);
25begin
26  if (val<>0) then
27    begin
28    fl_set_object_lcol(obj,FL_BLACK);
29    fl_activate_object(obj);
30    end
31  else
32    begin
33    fl_set_object_lcol(obj,FL_INACTIVE);
34    fl_deactivate_object(obj);
35    end
36end;
37
38Procedure setit_cb(obj : PFL_OBJECT; val : longint); cdecl;
39
40begin
41  setit (obj,val)
42end;
43
44Procedure doit(b1,b2,b3,b4 : longint);
45
46begin
47  setit(button1,b1);
48  setit(button2,b2);
49  setit(button3,b3);
50  setit(button4,b4);
51end;
52
53Procedure set_active(obj : PFL_OBJECT; arg : longint); cdecl;
54
55begin
56  case arg of
57    0: doit(1,1,1,1);
58    1: doit(0,0,0,0);
59    2: doit(0,1,0,1);
60    3: doit(1,0,1,0);
61  end;
62end;
63
64Procedure create_form;
65
66var obj : PFL_OBJECT;
67
68begin
69  form := fl_bgn_form(FL_NO_BOX,420,230);
70  obj := fl_add_box(FL_UP_BOX,0,0,420,230,'');
71    fl_set_object_color(obj,FL_SLATEBLUE,FL_COL1);
72  obj := fl_add_button(FL_NORMAL_BUTTON,20,170,150,40,'Button 1');
73  button1 := obj;
74    fl_set_object_lsize(obj,FL_LARGE_SIZE);
75    fl_set_button_shortcut(obj, '1 ', 1);
76  obj := fl_add_button(FL_NORMAL_BUTTON,20,120,150,40,'Button 2');
77  button2 := obj;
78    fl_set_object_lsize(obj,FL_LARGE_SIZE);
79    fl_set_button_shortcut(obj, '2 ', 1);
80  obj := fl_add_button(FL_NORMAL_BUTTON,20,70,150,40,'Button 3');
81  button3 := obj;
82    fl_set_object_lsize(obj,FL_LARGE_SIZE);
83    fl_set_button_shortcut(obj, '3 ', 1);
84  obj := fl_add_button(FL_NORMAL_BUTTON,20,20,150,40,'Button 4');
85  button4 := obj;
86    fl_set_button_shortcut(obj, '4 ', 1);
87    fl_set_object_lsize(obj,FL_LARGE_SIZE);
88  group := fl_bgn_group();
89  obj := fl_add_lightbutton(FL_RADIO_BUTTON,260,180,140,30,'All active');
90  firstbut := obj;
91    fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_active),0);
92  obj := fl_add_lightbutton(FL_RADIO_BUTTON,260,150,140,30,'Non active');
93    fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_active),1);
94  obj := fl_add_lightbutton(FL_RADIO_BUTTON,260,120,140,30,'Even active');
95    fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_active),2);
96  obj := fl_add_lightbutton(FL_RADIO_BUTTON,260,90,140,30,'Odd active');
97    fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_active),3);
98  fl_end_group();
99  obj := fl_add_button(FL_NORMAL_BUTTON,270,20,130,30,'Quit');
100    fl_set_object_callback(obj,PFL_CALLBACKPTR(@exit_cb),0);
101  fl_end_form();
102end;
103
104begin
105  fl_initialize(@argc, argv, 'FormDemo', nil, 0);
106  create_form;
107
108  fl_set_button(firstbut,1);
109  fl_show_form(form,FL_PLACE_CENTER,FL_NOBORDER,NiL);
110  while (fl_do_forms()<>nil) do
111    begin end;
112end.
113