objinactive.pp 2.8 KB

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