blob: bd0af8965dbfdf6360bd2356cf3695e360177317 [file] [log] [blame]
DRC2ff39b82011-07-28 08:38:59 +00001//
2// "$Id: fl_engraved_label.cxx 7903 2010-11-28 21:06:39Z matt $"
3//
4// Engraved label drawing routines for the Fast Light Tool Kit (FLTK).
5//
6// Copyright 1998-2010 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// Drawing code for XForms style engraved & embossed labels
29
30#include <FL/Fl.H>
31#include <FL/Fl_Widget.H>
32#include <FL/fl_draw.H>
33
34// data[] is dx, dy, color triples
35
36static void innards(
37 const Fl_Label* o, int X, int Y, int W, int H, Fl_Align align,
38 int data[][3], int n)
39{
40 Fl_Align a1 = align;
41 if (a1 & FL_ALIGN_CLIP) {
42 fl_push_clip(X, Y, W, H); a1 = (Fl_Align)(a1&~FL_ALIGN_CLIP);}
43 fl_font((Fl_Font)o->font, o->size);
44 for (int i = 0; i < n; i++) {
45 fl_color((Fl_Color)(i < n-1 ? data[i][2] : o->color));
46 fl_draw(o->value, X+data[i][0], Y+data[i][1], W, H, a1);
47 }
48 if (align & FL_ALIGN_CLIP) fl_pop_clip();
49}
50
51static void fl_shadow_label(
52 const Fl_Label* o, int X, int Y, int W, int H, Fl_Align align)
53{
54 static int data[2][3] = {{2,2,FL_DARK3},{0,0,0}};
55 innards(o, X, Y, W, H, align, data, 2);
56}
57
58static void fl_engraved_label(
59 const Fl_Label* o, int X, int Y, int W, int H, Fl_Align align)
60{
61 static int data[7][3] = {
62 {1,0,FL_LIGHT3},{1,1,FL_LIGHT3},{0,1,FL_LIGHT3},
63 {-1,0,FL_DARK3},{-1,-1,FL_DARK3},{0,-1,FL_DARK3},
64 {0,0,0}};
65 innards(o, X, Y, W, H, align, data, 7);
66}
67
68static void fl_embossed_label(
69 const Fl_Label* o, int X, int Y, int W, int H, Fl_Align align)
70{
71 static int data[7][3] = {
72 {-1,0,FL_LIGHT3},{-1,-1,FL_LIGHT3},{0,-1,FL_LIGHT3},
73 {1,0,FL_DARK3},{1,1,FL_DARK3},{0,1,FL_DARK3},
74 {0,0,0}};
75 innards(o, X, Y, W, H, align, data, 7);
76}
77
78Fl_Labeltype fl_define_FL_SHADOW_LABEL() {
79 Fl::set_labeltype(_FL_SHADOW_LABEL, fl_shadow_label, 0);
80 return _FL_SHADOW_LABEL;
81}
82Fl_Labeltype fl_define_FL_ENGRAVED_LABEL() {
83 Fl::set_labeltype(_FL_ENGRAVED_LABEL, fl_engraved_label, 0);
84 return _FL_ENGRAVED_LABEL;
85}
86Fl_Labeltype fl_define_FL_EMBOSSED_LABEL() {
87 Fl::set_labeltype(_FL_EMBOSSED_LABEL, fl_embossed_label, 0);
88 return _FL_EMBOSSED_LABEL;
89}
90
91//
92// End of "$Id: fl_engraved_label.cxx 7903 2010-11-28 21:06:39Z matt $".
93//