diff options
Diffstat (limited to 'src/Fl_Return_Button.cxx')
| -rw-r--r-- | src/Fl_Return_Button.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Fl_Return_Button.cxx b/src/Fl_Return_Button.cxx new file mode 100644 index 000000000..6d2e224ff --- /dev/null +++ b/src/Fl_Return_Button.cxx @@ -0,0 +1,42 @@ +// Fl_Return_Button.C + +#include <FL/Fl.H> +#include <FL/Fl_Return_Button.H> +#include <FL/fl_draw.H> + +int fl_return_arrow(int x, int y, int w, int h) { + int size = w; if (h<size) size = h; + int d = (size+2)/4; if (d<3) d = 3; + int t = (size+9)/12; if (t<1) t = 1; + int x0 = x+(w-2*d-2*t-1)/2; + int x1 = x0+d; + int y0 = y+h/2; + fl_color(FL_LIGHT3); + fl_line(x0, y0, x1, y0+d); + fl_yxline(x1, y0+d, y0+t, x1+d+2*t, y0-d); + fl_yxline(x1, y0-t, y0-d); + fl_color(fl_gray_ramp(0)); + fl_line(x0, y0, x1+1, y0-d-1); + fl_color(FL_DARK3); + fl_xyline(x1+1, y0-t, x1+d, y0-d, x1+d+2*t); + return 1; +} + +void Fl_Return_Button::draw() { + if (type() == FL_HIDDEN_BUTTON) return; + draw_box(value() ? (down_box()?down_box():down(box())) : box(), + value() ? selection_color() : color()); + int W = h(); + if (w()/3 < W) W = w()/3; + fl_return_arrow(x()+w()-W-4, y(), W, h()); + draw_label(x(), y(), w()-W+4, h()); +} + +int Fl_Return_Button::handle(int event) { + if (event == FL_SHORTCUT && + (Fl::event_key() == FL_Enter || Fl::event_key() == FL_KP_Enter)) { + do_callback(); + return 1; + } else + return Fl_Button::handle(event); +} |
