|
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) ![]() |
00001 // 00002 // "$Id: fl_rounded_box.cxx 7903 2010-11-28 21:06:39Z matt $" 00003 // 00004 // Rounded box drawing routines 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_draw.H> 00030 00031 #define RN 5 00032 #define RS 15 00033 #define BW 3 00034 00035 static double offset[RN] = { 0.0, 0.07612, 0.29289, 0.61732, 1.0}; 00036 00037 static void rbox(int fill, int x, int y, int w, int h) { 00038 int i; 00039 int rsx ,rsy, rs; 00040 rsx = w*2/5; rsy = h*2/5; 00041 if (rsx > rsy) rs = rsy; else rs = rsx; 00042 if (rs > RS) rs = RS; 00043 rsx = rs; rsy = rs; 00044 00045 if (fill) fl_begin_polygon(); else fl_begin_loop(); 00046 for (i=0; i<RN; i++) 00047 fl_vertex(x + offset[RN-i-1]*rsx, y + offset[i] * rsy); 00048 for (i=0; i<RN; i++) 00049 fl_vertex(x + offset[i]*rsx, y + h-1 - offset[RN-i-1] * rsy); 00050 for (i=0; i<RN; i++) 00051 fl_vertex(x + w-1 - offset[RN-i-1]*rsx, y + h-1 - offset[i] * rsy); 00052 for (i=0; i<RN; i++) 00053 fl_vertex(x + w-1 - offset[i]*rsx, y + offset[RN-i-1] * rsy); 00054 if (fill) fl_end_polygon(); else fl_end_loop(); 00055 } 00056 00057 static void fl_rflat_box(int x, int y, int w, int h, Fl_Color c) { 00058 fl_color(c); rbox(1, x, y, w, h); rbox(0, x, y, w, h); 00059 } 00060 00061 static void fl_rounded_frame(int x, int y, int w, int h, Fl_Color c) { 00062 fl_color(c); rbox(0, x, y, w, h); 00063 } 00064 00065 static void fl_rounded_box(int x, int y, int w, int h, Fl_Color c) { 00066 fl_color(c); rbox(1, x, y, w, h); 00067 fl_color(FL_BLACK); rbox(0, x, y, w, h); 00068 } 00069 00070 static void fl_rshadow_box(int x, int y, int w, int h, Fl_Color c) { 00071 // draw shadow: 00072 fl_color(FL_DARK3); 00073 rbox(1, x+BW, y+BW, w, h); 00074 rbox(0, x+BW, y+BW, w, h); 00075 // draw the box: 00076 fl_rounded_box(x, y, w, h, c); 00077 } 00078 00079 extern void fl_internal_boxtype(Fl_Boxtype, Fl_Box_Draw_F*); 00080 00081 Fl_Boxtype fl_define_FL_ROUNDED_BOX() { 00082 fl_internal_boxtype(_FL_ROUNDED_FRAME, fl_rounded_frame); 00083 fl_internal_boxtype(_FL_ROUNDED_BOX, fl_rounded_box); 00084 return _FL_ROUNDED_BOX; 00085 } 00086 00087 Fl_Boxtype fl_define_FL_RFLAT_BOX() { 00088 fl_internal_boxtype(_FL_RFLAT_BOX, fl_rflat_box); 00089 return _FL_RFLAT_BOX; 00090 } 00091 00092 Fl_Boxtype fl_define_FL_RSHADOW_BOX() { 00093 fl_internal_boxtype(_FL_RSHADOW_BOX, fl_rshadow_box); 00094 return _FL_RSHADOW_BOX; 00095 } 00096 00097 // 00098 // End of "$Id: fl_rounded_box.cxx 7903 2010-11-28 21:06:39Z matt $". 00099 //