fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
  SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_Return_Button.cxx

Go to the documentation of this file.
00001 //
00002 // "$Id: Fl_Return_Button.cxx 7903 2010-11-28 21:06:39Z matt $"
00003 //
00004 // Return button widget for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2010 by Bill Spitzak and others.
00007 //
00008 // This library is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU Library General Public
00010 // License as published by the Free Software Foundation; either
00011 // version 2 of the License, or (at your option) any later version.
00012 //
00013 // This library is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 // Library General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU Library General Public
00019 // License along with this library; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00021 // USA.
00022 //
00023 // Please report all bugs and problems on the following page:
00024 //
00025 //     http://www.fltk.org/str.php
00026 //
00027 
00028 #include <FL/Fl.H>
00029 #include <FL/Fl_Return_Button.H>
00030 #include <FL/fl_draw.H>
00031 
00032 int fl_return_arrow(int x, int y, int w, int h) {
00033   int size = w; if (h<size) size = h;
00034   int d = (size+2)/4; if (d<3) d = 3;
00035   int t = (size+9)/12; if (t<1) t = 1;
00036   int x0 = x+(w-2*d-2*t-1)/2;
00037   int x1 = x0+d;
00038   int y0 = y+h/2;
00039   fl_color(FL_LIGHT3);
00040   fl_line(x0, y0, x1, y0+d);
00041   fl_yxline(x1, y0+d, y0+t, x1+d+2*t, y0-d);
00042   fl_yxline(x1, y0-t, y0-d);
00043   fl_color(fl_gray_ramp(0));
00044   fl_line(x0, y0, x1, y0-d);
00045   fl_color(FL_DARK3);
00046   fl_xyline(x1+1, y0-t, x1+d, y0-d, x1+d+2*t);
00047   return 1;
00048 }
00049 
00050 void Fl_Return_Button::draw() {
00051   if (type() == FL_HIDDEN_BUTTON) return;
00052   draw_box(value() ? (down_box()?down_box():fl_down(box())) : box(),
00053            value() ? selection_color() : color());
00054   int W = h();
00055   if (w()/3 < W) W = w()/3;
00056   fl_return_arrow(x()+w()-W-4, y(), W, h());
00057   draw_label(x(), y(), w()-W+4, h());
00058   if (Fl::focus() == this) draw_focus();
00059 }
00060 
00061 int Fl_Return_Button::handle(int event) {
00062   if (event == FL_SHORTCUT &&
00063       (Fl::event_key() == FL_Enter || Fl::event_key() == FL_KP_Enter)) {
00064     simulate_key_action();
00065     do_callback();
00066     return 1;
00067   } else
00068     return Fl_Button::handle(event);
00069 }
00070 
00071 //
00072 // End of "$Id: Fl_Return_Button.cxx 7903 2010-11-28 21:06:39Z matt $".
00073 //