themes: Workaround for bug where a background color of RGB 0,0,0 in Black color schem...
[ntk.git] / src / fl_rounded_box.cxx
blobb4dece3891c7e787dcad49850b7ffe6ff62a6f48
1 //
2 // "$Id: fl_rounded_box.cxx 7903 2010-11-28 21:06:39Z matt $"
3 //
4 // Rounded box 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.
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.
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.
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
28 #include <FL/Fl.H>
29 #include <FL/fl_draw.H>
31 #define RN 5
32 #define RS 15
33 #define BW 3
35 static double offset[RN] = { 0.0, 0.07612, 0.29289, 0.61732, 1.0};
37 static void rbox(int fill, int x, int y, int w, int h, int asym = 0 ) {
38 int i;
39 int rsx ,rsy, rs;
40 rsx = w*2/5; rsy = h*2/5;
41 if (rsx > rsy) rs = rsy; else rs = rsx;
42 if (rs > RS) rs = RS;
43 rsx = rs; rsy = rs;
45 if (fill) fl_begin_polygon(); else fl_begin_loop();
47 for (i=0; i<RN; i++)
48 fl_vertex(x + offset[RN-i-1]*rsx, y + offset[i] * rsy);
50 if ( ! asym )
51 for (i=0; i<RN; i++)
52 fl_vertex(x + offset[i]*rsx, y + h-1 - offset[RN-i-1] * rsy);
53 else
54 fl_vertex( x, y + h - 1 );
56 for (i=0; i<RN; i++)
57 fl_vertex(x + w-1 - offset[RN-i-1]*rsx, y + h-1 - offset[i] * rsy);
59 if ( ! asym )
60 for (i=0; i<RN; i++)
61 fl_vertex(x + w-1 - offset[i]*rsx, y + offset[RN-i-1] * rsy);
62 else
63 fl_vertex( x + w - 1, y );
65 if (fill) fl_end_polygon(); else fl_end_loop();
68 static void fl_rflat_box(int x, int y, int w, int h, Fl_Color c) {
69 fl_color(c); rbox(1, x, y, w, h); rbox(0, x, y, w, h);
72 static void fl_rounded_frame(int x, int y, int w, int h, Fl_Color c) {
73 fl_color(c); rbox(0, x, y, w, h);
76 static void fl_rounded_box(int x, int y, int w, int h, Fl_Color c) {
77 fl_color(c); rbox(1, x, y, w, h);
78 fl_color(FL_BLACK); rbox(0, x, y, w, h);
81 static void fl_asym_box(int x, int y, int w, int h, Fl_Color c) {
82 fl_color(c); rbox(1, x, y, w, h, 1);
83 fl_color(FL_BLACK); rbox(0, x, y, w, h, 1 );
86 static void fl_asym_flat_box(int x, int y, int w, int h, Fl_Color c) {
87 fl_color(c); rbox(1, x, y, w, h, 1);
90 static void fl_rshadow_box(int x, int y, int w, int h, Fl_Color c) {
91 // draw shadow:
92 fl_color(FL_DARK3);
93 rbox(1, x+BW, y+BW, w, h);
94 rbox(0, x+BW, y+BW, w, h);
95 // draw the box:
96 fl_rounded_box(x, y, w, h, c);
99 extern void fl_internal_boxtype(Fl_Boxtype, Fl_Box_Draw_F*);
101 Fl_Boxtype fl_define_FL_ROUNDED_BOX() {
102 fl_internal_boxtype(_FL_ROUNDED_FRAME, fl_rounded_frame);
103 fl_internal_boxtype(_FL_ROUNDED_BOX, fl_rounded_box);
104 return _FL_ROUNDED_BOX;
107 Fl_Boxtype fl_define_FL_RFLAT_BOX() {
108 fl_internal_boxtype(_FL_RFLAT_BOX, fl_rflat_box);
109 return _FL_RFLAT_BOX;
112 Fl_Boxtype fl_define_FL_RSHADOW_BOX() {
113 fl_internal_boxtype(_FL_RSHADOW_BOX, fl_rshadow_box);
114 return _FL_RSHADOW_BOX;
117 Fl_Boxtype fl_define_FL_ASYM_BOX() {
118 fl_internal_boxtype(_FL_ASYM_BOX, fl_asym_box);
119 fl_internal_boxtype(_FL_ASYM_FLAT_BOX, fl_asym_flat_box);
120 return _FL_ASYM_BOX;
124 // End of "$Id: fl_rounded_box.cxx 7903 2010-11-28 21:06:39Z matt $".