fdial.pp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. { This is an example of the use of filled dials, dial range
  2. and dial direction.
  3. }
  4. Program fdial;
  5. uses xforms;
  6. var
  7. form: PFL_FORM;
  8. button, red, green, blue, redtext, greentext, bluetext, theresult : PFL_OBJECT;
  9. Procedure makeform;
  10. begin
  11. form := fl_bgn_form(FL_UP_BOX,300,330);
  12. button := fl_add_button(FL_NORMAL_BUTTON,45,15,210,45,'A Color Editor');
  13. fl_set_object_lsize(button,FL_LARGE_SIZE);
  14. red := fl_add_dial(FL_FILL_DIAL,30,240,60,60,'Red');
  15. fl_set_dial_bounds(red,0.0,255.0);
  16. fl_set_dial_value(red,128.0);
  17. fl_set_object_color(red,FL_DIAL_COL1, FL_RED);
  18. redtext := fl_add_box(FL_DOWN_BOX,105,255,50,25,'');
  19. green := fl_add_dial(FL_FILL_DIAL,30,155,60,60,'Green');
  20. fl_set_dial_bounds(green,0.0,255.0);
  21. fl_set_dial_value(green,128.0);
  22. fl_set_dial_angles(green, 45.0, (360-45.0));
  23. fl_set_object_color(green,FL_DIAL_COL1, FL_GREEN);
  24. greentext := fl_add_box(FL_DOWN_BOX,105,170,50,25,'');
  25. blue := fl_add_dial(FL_FILL_DIAL,30,70,60,60,'Blue');
  26. fl_set_dial_bounds(blue,0.0,255.0);
  27. fl_set_dial_value(blue,128.0);
  28. fl_set_object_color(blue,FL_DIAL_COL1,FL_BLUE);
  29. fl_set_dial_direction(blue, FL_DIAL_CCW);
  30. bluetext := fl_add_box(FL_DOWN_BOX,105,90,50,25,'');
  31. theresult := fl_add_box(FL_DOWN_BOX,180,70,90,245,'');
  32. fl_set_object_color(theresult,FL_FREE_COL1,FL_FREE_COL1);
  33. fl_set_object_dblbuffer(theresult,1);
  34. fl_end_form;
  35. end;
  36. var
  37. ret : PFL_OBJECT;
  38. r,g,b : longint;
  39. st : string;
  40. begin
  41. fl_initialize(@argc, argv, 'FormDemo', nil, 0);
  42. makeform;
  43. fl_show_form(form,FL_PLACE_MOUSE,FL_TRANSIENT,'A Form');
  44. repeat
  45. r := round(fl_get_dial_value(red)+0.001);
  46. g := round(fl_get_dial_value(green)+0.001);
  47. b := round(fl_get_dial_value(blue)+0.001);
  48. fl_mapcolor(FL_FREE_COL1,r,g,b);
  49. fl_redraw_object(theresult);
  50. str (r,st);
  51. st:=st+#0;
  52. fl_set_object_label(redtext,@st[1]);
  53. str (g,st);
  54. st:=st+#0;
  55. fl_set_object_label(greentext,@st[1]);
  56. str (b,st);
  57. st:=st+#0;
  58. fl_set_object_label(bluetext,@st[1]);
  59. ret := fl_do_forms;
  60. until (ret = button);
  61. fl_hide_form(form);
  62. end.