|
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_engraved_label.cxx 7903 2010-11-28 21:06:39Z matt $" 00003 // 00004 // Engraved label 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 // Drawing code for XForms style engraved & embossed labels 00029 00030 #include <FL/Fl.H> 00031 #include <FL/Fl_Widget.H> 00032 #include <FL/fl_draw.H> 00033 00034 // data[] is dx, dy, color triples 00035 00036 static void innards( 00037 const Fl_Label* o, int X, int Y, int W, int H, Fl_Align align, 00038 int data[][3], int n) 00039 { 00040 Fl_Align a1 = align; 00041 if (a1 & FL_ALIGN_CLIP) { 00042 fl_push_clip(X, Y, W, H); a1 = (Fl_Align)(a1&~FL_ALIGN_CLIP);} 00043 fl_font((Fl_Font)o->font, o->size); 00044 for (int i = 0; i < n; i++) { 00045 fl_color((Fl_Color)(i < n-1 ? data[i][2] : o->color)); 00046 fl_draw(o->value, X+data[i][0], Y+data[i][1], W, H, a1); 00047 } 00048 if (align & FL_ALIGN_CLIP) fl_pop_clip(); 00049 } 00050 00051 static void fl_shadow_label( 00052 const Fl_Label* o, int X, int Y, int W, int H, Fl_Align align) 00053 { 00054 static int data[2][3] = {{2,2,FL_DARK3},{0,0,0}}; 00055 innards(o, X, Y, W, H, align, data, 2); 00056 } 00057 00058 static void fl_engraved_label( 00059 const Fl_Label* o, int X, int Y, int W, int H, Fl_Align align) 00060 { 00061 static int data[7][3] = { 00062 {1,0,FL_LIGHT3},{1,1,FL_LIGHT3},{0,1,FL_LIGHT3}, 00063 {-1,0,FL_DARK3},{-1,-1,FL_DARK3},{0,-1,FL_DARK3}, 00064 {0,0,0}}; 00065 innards(o, X, Y, W, H, align, data, 7); 00066 } 00067 00068 static void fl_embossed_label( 00069 const Fl_Label* o, int X, int Y, int W, int H, Fl_Align align) 00070 { 00071 static int data[7][3] = { 00072 {-1,0,FL_LIGHT3},{-1,-1,FL_LIGHT3},{0,-1,FL_LIGHT3}, 00073 {1,0,FL_DARK3},{1,1,FL_DARK3},{0,1,FL_DARK3}, 00074 {0,0,0}}; 00075 innards(o, X, Y, W, H, align, data, 7); 00076 } 00077 00078 Fl_Labeltype fl_define_FL_SHADOW_LABEL() { 00079 Fl::set_labeltype(_FL_SHADOW_LABEL, fl_shadow_label, 0); 00080 return _FL_SHADOW_LABEL; 00081 } 00082 Fl_Labeltype fl_define_FL_ENGRAVED_LABEL() { 00083 Fl::set_labeltype(_FL_ENGRAVED_LABEL, fl_engraved_label, 0); 00084 return _FL_ENGRAVED_LABEL; 00085 } 00086 Fl_Labeltype fl_define_FL_EMBOSSED_LABEL() { 00087 Fl::set_labeltype(_FL_EMBOSSED_LABEL, fl_embossed_label, 0); 00088 return _FL_EMBOSSED_LABEL; 00089 } 00090 00091 // 00092 // End of "$Id: fl_engraved_label.cxx 7903 2010-11-28 21:06:39Z matt $". 00093 //