Tweak themes.
[ntk.git] / src / Gleam_Theme.cxx
blob955c7f38ef6fa13c81ef95973ab9c95215381acc
2 /*******************************************************************************/
3 /* Copyright (C) 2012 Jonathan Moore Liles */
4 /* Copyright (C) 2001-2005 by Colin Jones */
5 /* */
6 /* This program is free software; you can redistribute it and/or modify it */
7 /* under the terms of the GNU General Public License as published by the */
8 /* Free Software Foundation; either version 2 of the License, or (at your */
9 /* option) any later version. */
10 /* */
11 /* This program is distributed in the hope that it will be useful, but WITHOUT */
12 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
13 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
14 /* more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License along */
17 /* with This program; see the file COPYING. If not,write to the Free Software */
18 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19 /*******************************************************************************/
21 /* Taken from the "Gleam" FLTK scheme, as modified by prodatum */
23 #include <FL/Fl.H>
24 #include <FL/fl_draw.H>
26 #include "FL/Fl_Theme.H"
28 static void gleam_color(Fl_Color c)
30 if (Fl::draw_box_active())
31 fl_color(c);
32 else
33 fl_color(fl_inactive(c));
35 static void frame_rect(int x, int y, int w, int h, Fl_Color bc)
38 // Draw the outline around the perimeter of the box
39 fl_color(fl_color_average(FL_BLACK, FL_BACKGROUND_COLOR, .1));
40 fl_line(x, y, x + w, y);
41 fl_line(x + w, y, x + w, y + h);
42 fl_line(x + w, y + h, x, y + h);
43 fl_line(x, y + h, x, y);
47 static void shade_rect_up(int x, int y, int w, int h, Fl_Color bc)
49 // Draws the shiny
50 const float third = 5;
51 gleam_color(bc);
52 fl_rectf(x, y, w, third + 1);
53 const float step_size = 0.10;
54 float k = 0.5f;
55 int j = 0;
56 for (; j < third; k -= step_size, j++ )
58 gleam_color(fl_color_average( FL_WHITE, bc, k));
59 fl_line(x, y + j, x + w - 1, y + j);
62 gleam_color(bc);
63 fl_rectf( x, y + j, x + w - 1, h - j );
66 static void frame_rect_up(int x, int y, int w, int h, Fl_Color bc)
69 // Draw the outline around the perimeter of the box
70 gleam_color(bc);
71 fl_line(x, y, x + w, y); //Go across.
72 fl_line(x, y + (h / 2), x, y + 1); //Go to top
73 fl_line(x + w, y + (h / 2), x + w, y + 1); //Go to top
75 gleam_color(fl_darker(bc));
76 fl_line(x, y + h, x + w, y + h); //Go across again!
77 fl_line(x, y + (h / 2), x, y + h - 1); //Go to top
78 fl_line(x + w, y + (h / 2), x + w, y + h - 1); //Go to top
82 static void frame_rect_down(int x, int y, int w, int h, Fl_Color bc)
85 // Draw the outline around the perimeter of the box
86 gleam_color(fl_darker(bc));
87 fl_line(x, y, x + w, y); //Go across.
88 fl_line(x, y + (h / 2), x, y + 1); //Go to top
89 fl_line(x + w, y + (h / 2), x + w, y + 1); //Go to top
91 //gleam_color(bc);
92 fl_line(x, y + h, x + w, y + h); //Go across again!
93 fl_line(x, y + (h / 2), x, y + h - 1); //Go to top
94 fl_line(x + w, y + (h / 2), x + w, y + h - 1); //Go to top
98 static void shade_rect_down(int x, int y, int w, int h, Fl_Color bc)
101 gleam_color(bc);
102 Fl_Color color = fl_color();
103 fl_rectf(x, y, w, h);
104 gleam_color(fl_color_average(bc, fl_darker(color), 0.65));
105 fl_line(x, y + 1, x + w, y + 1);
106 fl_line(x, y + 1, x, y + h - 2);
107 gleam_color(fl_color_average(bc, fl_darker(color), 0.85));
108 fl_line(x + 1, y + 2, x + w, y + 2);
109 fl_line(x + 1, y + 2, x + 1, y + h - 2);
113 static void up_frame(int x, int y, int w, int h, Fl_Color c)
115 frame_rect_up(x, y, w - 1, h - 1, fl_darker(c));
118 static void up_box(int x, int y, int w, int h, Fl_Color c)
120 shade_rect_up(x + 1, y, w - 2, h - 1, c);
121 frame_rect_up(x, y, w - 1, h - 1, fl_darker(c));
122 //draw the inner rect.
123 frame_rect(x + 1, y + 1, w - 3, h - 3, fl_color_average(c, FL_WHITE, .25f));
127 static void down_frame(int x, int y, int w, int h, Fl_Color c)
129 frame_rect_down(x, y, w - 1, h - 1, fl_darker(c));
132 static void down_box(int x, int y, int w, int h, Fl_Color c)
134 shade_rect_down(x + 1, y, w - 2, h,
135 FL_BACKGROUND_COLOR == c || FL_BACKGROUND2_COLOR == c
136 ? fl_darker(c)
137 : c );
138 down_frame(x, y, w, h, fl_darker(c));
139 //draw the inner rect.
140 //frame_rect(x + 1, y + 1, w - 3, h - 3, fl_color_average(c, FL_BLACK, .65));
144 static void border_box(int x, int y, int w, int h, Fl_Color c)
146 gleam_color(c);
147 fl_rectf(x,y,w,h);
148 gleam_color(fl_darker(c));
149 fl_rect(x+1,y+1,w-2,h-2);
152 static void
153 init_theme ( void )
155 /* replace the gtk+ boxes... (is there a better way?) */
156 Fl::set_boxtype( FL_UP_BOX, up_box, 2,2,4,4 );
157 Fl::set_boxtype( FL_DOWN_BOX, down_box, 2,2,3,3 );
158 Fl::set_boxtype( FL_THIN_UP_BOX, up_box, 2,2,3,3 );
159 Fl::set_boxtype( FL_THIN_DOWN_BOX, down_box, 2,2,3,3 );
160 Fl::set_boxtype( FL_UP_FRAME, up_frame, 2,2,3,3 );
161 Fl::set_boxtype( FL_DOWN_FRAME, down_frame, 2,2,3,3 );
162 Fl::set_boxtype( FL_ROUND_UP_BOX, up_box, 2,2,3,3 );
163 Fl::set_boxtype( FL_ROUND_DOWN_BOX, down_box, 2,2,3,3 );
164 Fl::set_boxtype( FL_BORDER_BOX, border_box, 1,1,2,2 );
167 void
168 init_gleam_theme ( void )
170 Fl_Theme *t = new Fl_Theme( "Gleam", "", "", init_theme );
172 Fl_Theme::add( t );