You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.9KB

  1. // generated by Fast Light User Interface Designer (fluid) version 2.00
  2. #include "Fl_LED_Button.H"
  3. #include <FL/fl_draw.H>
  4. Fl_LED_Button::Fl_LED_Button(int x, int y, int w, int h, const char* l):Fl_Light_Button(x,y,w,h,l) {
  5. box(FL_NO_BOX);
  6. down_box(FL_ROUND_DOWN_BOX);
  7. selection_color(FL_RED);
  8. }
  9. Fl_LED_Button::~Fl_LED_Button() {
  10. }
  11. void Fl_LED_Button::draw() {
  12. uchar r,g,b;
  13. //if (box()) draw_box(this==Fl::pushed() ? down(box()) : box(), color());
  14. Fl_Color col = value() ? selection_color() : color();
  15. Fl::get_color((Fl_Color)selection_color(),r,g,b);
  16. int d = h()/6;
  17. int W = w()<h() ? w() : h();
  18. int x1 = x()+d+2;
  19. int y1 = y()+d+3;
  20. int ww = W-2*d-6;
  21. int hh = W-2*d-6;
  22. Fl::get_color(parent()->color(),r,g,b);
  23. modulate(-90,r,g,b);
  24. fl_pie(x1-1,y1-1,ww+2,hh+2,0,360);
  25. Fl::get_color((Fl_Color)selection_color(),r,g,b);
  26. if (value()) modulate(-90,r,g,b); else modulate(-210,r,g,b);
  27. fl_pie(x1,y1,ww,hh,0,360);
  28. if (value()) modulate(-60,r,g,b); else modulate(-190,r,g,b);
  29. fl_pie(x1+1,y1+1,ww-2,hh-2,0,360);
  30. if (value()) modulate(-20,r,g,b); else modulate(-150,r,g,b);
  31. fl_pie(x1+1,y1+1,ww-3,hh-3,0,360);
  32. if (value()) modulate(0,r,g,b); else modulate(-130,r,g,b);
  33. fl_pie(x1+3,y1+3,ww-5,hh-5,0,360);
  34. if (value()) modulate(160,r,g,b); else modulate(-30,r,g,b);
  35. fl_arc(x1+3,y1+3,ww-5,hh-5,250,350);
  36. if (value()) modulate(250,r,g,b); else modulate(100,r,g,b);
  37. fl_pie((int)(x1+ww/2-(0.3*ww)/2),(int)(y1+ww/2-(0.3*ww)/2),
  38. (int)((0.45*ww)/2),(int)((0.45*ww)/2),0,360);
  39. fl_color(FL_BLACK);
  40. fl_arc(x1,y1,ww+1,hh+1,0,360);
  41. draw_label(x()+W-d, y(), w()-W+d, h());//,labelcolor());
  42. }
  43. void Fl_LED_Button::modulate(const int offs,const uchar r,uchar g,uchar b) {
  44. int rr,gg,bb;
  45. rr = r + offs;
  46. rr = rr > 255 ? 255:rr;
  47. rr = rr < 0 ? 0:rr;
  48. gg = g + offs;
  49. gg = gg > 255 ? 255:gg;
  50. gg = gg < 0 ? 0:gg;
  51. bb = b + offs;
  52. bb = bb > 255 ? 255:bb;
  53. bb = bb < 0 ? 0:bb;
  54. fl_color((uchar)rr,(uchar)gg,(uchar)bb);
  55. }