2 // "$Id: Fl_Return_Button.cxx 7903 2010-11-28 21:06:39Z matt $"
4 // Return button widget for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2010 by Bill Spitzak and others.
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.
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.
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
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
29 #include <FL/Fl_Return_Button.H>
30 #include <FL/fl_draw.H>
32 int fl_return_arrow(int x
, int y
, int w
, int h
) {
33 int size
= w
; if (h
<size
) size
= h
;
34 int d
= (size
+2)/4; if (d
<3) d
= 3;
35 int t
= (size
+9)/12; if (t
<1) t
= 1;
36 int x0
= x
+(w
-2*d
-2*t
-1)/2;
40 fl_line(x0
, y0
, x1
, y0
+d
);
41 fl_yxline(x1
, y0
+d
, y0
+t
, x1
+d
+2*t
, y0
-d
);
42 fl_yxline(x1
, y0
-t
, y0
-d
);
43 fl_color(fl_gray_ramp(0));
44 fl_line(x0
, y0
, x1
, y0
-d
);
46 fl_xyline(x1
+1, y0
-t
, x1
+d
, y0
-d
, x1
+d
+2*t
);
50 void Fl_Return_Button::draw() {
51 if (type() == FL_HIDDEN_BUTTON
) return;
52 draw_box(value() ? (down_box()?down_box():fl_down(box())) : box(),
53 value() ? selection_color() : color());
55 if (w()/3 < W
) W
= w()/3;
56 fl_return_arrow(x()+w()-W
-4, y(), W
, h());
57 draw_label(x(), y(), w()-W
+4, h());
58 if (Fl::focus() == this) draw_focus();
61 int Fl_Return_Button::handle(int event
) {
62 if (event
== FL_SHORTCUT
&&
63 (Fl::event_key() == FL_Enter
|| Fl::event_key() == FL_KP_Enter
)) {
64 simulate_key_action();
68 return Fl_Button::handle(event
);
72 // End of "$Id: Fl_Return_Button.cxx 7903 2010-11-28 21:06:39Z matt $".