source: rtems-graphics-toolkit/fltk-1.1.10/src/Fl_Return_Button.cxx @ 513eea1

Last change on this file since 513eea1 was 513eea1, checked in by Joel Sherrill <joel.sherrill@…>, on 01/09/10 at 22:43:24

2010-01-08 Joel Sherrill <joel.sherrill@…>

fltk 1.1.10. imported

  • ORIGIN: Updated.
  • Property mode set to 100644
File size: 2.1 KB
Line 
1//
2// "$Id$"
3//
4// Return button widget for the Fast Light Tool Kit (FLTK).
5//
6// Copyright 1998-2005 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
28#include <FL/Fl.H>
29#include <FL/Fl_Return_Button.H>
30#include <FL/fl_draw.H>
31
32int 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;
37  int x1 = x0+d;
38  int y0 = y+h/2;
39  fl_color(FL_LIGHT3);
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);
45  fl_color(FL_DARK3);
46  fl_xyline(x1+1, y0-t, x1+d, y0-d, x1+d+2*t);
47  return 1;
48}
49
50void 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());
54  int W = h();
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();
59}
60
61int Fl_Return_Button::handle(int event) {
62  if (event == FL_SHORTCUT &&
63      (Fl::event_key() == FL_Enter || Fl::event_key() == FL_KP_Enter)) {
64    do_callback();
65    return 1;
66  } else
67    return Fl_Button::handle(event);
68}
69
70//
71// End of "$Id$".
72//
Note: See TracBrowser for help on using the repository browser.