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.

74 lines
2.2KB

  1. //
  2. // "$Id: Fl_Return_Button.cxx 7903 2010-11-28 21:06:39Z matt $"
  3. //
  4. // Return button widget for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2010 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. #include <FL/Fl.H>
  28. #include <FL/Fl_Return_Button.H>
  29. #include <FL/fl_draw.H>
  30. int fl_return_arrow(int x, int y, int w, int h) {
  31. int size = w; if (h<size) size = h;
  32. int d = (size+2)/4; if (d<3) d = 3;
  33. int t = (size+9)/12; if (t<1) t = 1;
  34. int x0 = x+(w-2*d-2*t-1)/2;
  35. int x1 = x0+d;
  36. int y0 = y+h/2;
  37. fl_color(FL_LIGHT3);
  38. fl_line(x0, y0, x1, y0+d);
  39. fl_yxline(x1, y0+d, y0+t, x1+d+2*t, y0-d);
  40. fl_yxline(x1, y0-t, y0-d);
  41. fl_color(fl_gray_ramp(0));
  42. fl_line(x0, y0, x1, y0-d);
  43. fl_color(FL_DARK3);
  44. fl_xyline(x1+1, y0-t, x1+d, y0-d, x1+d+2*t);
  45. return 1;
  46. }
  47. void Fl_Return_Button::draw() {
  48. if (type() == FL_HIDDEN_BUTTON) return;
  49. draw_box(value() ? (down_box()?down_box():fl_down(box())) : box(),
  50. value() ? selection_color() : color());
  51. int W = h();
  52. if (w()/3 < W) W = w()/3;
  53. fl_return_arrow(x()+w()-W-4, y(), W, h());
  54. draw_label(x(), y(), w()-W+4, h());
  55. if (Fl::focus() == this) draw_focus();
  56. }
  57. int Fl_Return_Button::handle(int event) {
  58. if (event == FL_SHORTCUT &&
  59. (Fl::event_key() == FL_Enter || Fl::event_key() == FL_KP_Enter)) {
  60. simulate_key_action();
  61. do_callback();
  62. return 1;
  63. } else
  64. return Fl_Button::handle(event);
  65. }
  66. //
  67. // End of "$Id: Fl_Return_Button.cxx 7903 2010-11-28 21:06:39Z matt $".
  68. //