summaryrefslogtreecommitdiff
path: root/src/fl_plastic.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2003-05-18 22:12:24 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2003-05-18 22:12:24 +0000
commit8a2aa0a0d1876c88953de29e0709e290cc8daa97 (patch)
treeaaba419f297ab24e7033596a8a1bb22c2c856079 /src/fl_plastic.cxx
parent180e2985377981d5d8ac2f668f371ab841bbfca2 (diff)
Add thin up box with plastic style.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2981 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_plastic.cxx')
-rw-r--r--src/fl_plastic.cxx58
1 files changed, 53 insertions, 5 deletions
diff --git a/src/fl_plastic.cxx b/src/fl_plastic.cxx
index e8565a829..f073463e3 100644
--- a/src/fl_plastic.cxx
+++ b/src/fl_plastic.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_plastic.cxx,v 1.1.2.17 2003/05/16 18:33:03 easysw Exp $"
+// "$Id: fl_plastic.cxx,v 1.1.2.18 2003/05/18 22:12:24 easysw Exp $"
//
// "Plastic" drawing routines for the Fast Light Tool Kit (FLTK).
//
@@ -34,13 +34,48 @@
#include <FL/fl_draw.H>
#include "flstring.h"
+//
+// Uncomment the following line to restore the old plastic box type
+// appearance.
+//
+
+//#define USE_OLD_PLASTIC_BOX
extern uchar *fl_gray_ramp();
inline Fl_Color shade_color(uchar gc, Fl_Color bc) {
+#ifdef USE_OLD_PLASTIC_BOX
return fl_color_average((Fl_Color)gc, bc, 0.75f);
+#else
+ unsigned grgb = Fl::get_color((Fl_Color)gc),
+ brgb = Fl::get_color(bc);
+ int red, green, blue, gray;
+
+
+ gray = ((grgb >> 24) & 255);
+ red = gray * ((brgb >> 24) & 255) / 255 + gray * gray / 510;
+ gray = ((grgb >> 16) & 255);
+ green = gray * ((brgb >> 16) & 255) / 255 + gray * gray / 510;
+ gray = ((grgb >> 8) & 255);
+ blue = gray * ((brgb >> 8) & 255) / 255 + gray * gray / 510;
+
+ if (red > 255)
+ red = 255;
+
+ if (green > 255)
+ green = 255;
+
+ if (blue > 255)
+ blue = 255;
+
+ if (Fl::draw_box_active())
+ return fl_rgb_color(red, green, blue);
+ else
+ return fl_color_average(FL_GRAY, fl_rgb_color(red, green, blue), 0.75f);
+#endif // USE_OLD_PLASTIC_BOX
}
+
static void shade_frame(int x, int y, int w, int h, const char *c, Fl_Color bc) {
uchar *g = fl_gray_ramp();
int b = strlen(c) / 4 + 1;
@@ -141,13 +176,24 @@ static void up_frame(int x, int y, int w, int h, Fl_Color c) {
static void up_box(int x, int y, int w, int h, Fl_Color c) {
-#if 0 // OLD UP BOX
+#ifdef USE_OLD_PLASTIC_BOX
shade_rect(x + 2, y + 2, w - 4, h - 5, "RVQNOPQRSTUVWVQ", c);
up_frame(x, y, w, h, c);
-#else // NEW UP BOX
+#else
shade_rect(x + 1, y + 1, w - 2, h - 3, "RVQNOPQRSTUVWVQ", c);
shade_frame(x, y, w, h - 1, "IJLM", c);
-#endif // 0
+#endif // USE_OLD_PLASTIC_BOX
+}
+
+
+static void thin_up_box(int x, int y, int w, int h, Fl_Color c) {
+#ifdef USE_OLD_PLASTIC_BOX
+ shade_rect(x + 2, y + 2, w - 4, h - 5, "RVQNOPQRSTUVWVQ", c);
+ up_frame(x, y, w, h, c);
+#else
+ shade_rect(x + 1, y + 1, w - 2, h - 3, "RQOQSUWQ", c);
+ shade_frame(x, y, w, h - 1, "IJLM", c);
+#endif // USE_OLD_PLASTIC_BOX
}
@@ -171,11 +217,13 @@ Fl_Boxtype fl_define_FL_PLASTIC_UP_BOX() {
fl_internal_boxtype(_FL_PLASTIC_DOWN_BOX, down_box);
fl_internal_boxtype(_FL_PLASTIC_UP_FRAME, up_frame);
fl_internal_boxtype(_FL_PLASTIC_DOWN_FRAME, down_frame);
+ fl_internal_boxtype(_FL_PLASTIC_THIN_UP_BOX, thin_up_box);
+ fl_internal_boxtype(_FL_PLASTIC_THIN_DOWN_BOX, down_box);
return _FL_PLASTIC_UP_BOX;
}
//
-// End of "$Id: fl_plastic.cxx,v 1.1.2.17 2003/05/16 18:33:03 easysw Exp $".
+// End of "$Id: fl_plastic.cxx,v 1.1.2.18 2003/05/18 22:12:24 easysw Exp $".
//