summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>1999-01-05 17:57:49 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>1999-01-05 17:57:49 +0000
commit41d027ebfb33de38c8761defe926f5f681489143 (patch)
treeddb2db2f8d26d03314ae0e49ec521dafb11edd4c /src
parent131b567003e4f19b27b2dcc0797dec2ddb64ce16 (diff)
Fix from Carl - the inactive() function now works with all colors, and
all widgets now use it. git-svn-id: file:///fltk/svn/fltk/trunk@185 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Menu.cxx6
-rw-r--r--src/fl_color.cxx23
-rw-r--r--src/fl_color_win32.cxx23
-rw-r--r--src/fl_labeltype.cxx6
4 files changed, 48 insertions, 10 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx
index 3fba0070c..0beb9323b 100644
--- a/src/Fl_Menu.cxx
+++ b/src/Fl_Menu.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Menu.cxx,v 1.9 1999/01/05 17:52:59 mike Exp $"
+// "$Id: Fl_Menu.cxx,v 1.10 1999/01/05 17:57:48 mike Exp $"
//
// Menu code for the Fast Light Tool Kit (FLTK).
//
@@ -127,7 +127,7 @@ void Fl_Menu_Item::draw(int x, int y, int w, int h, const Fl_Menu_* m,
l.type = labeltype_;
l.font = labelsize_ ? labelfont_ : uchar(m ? m->textfont() : FL_HELVETICA);
l.size = labelsize_ ? labelsize_ : m ? m->textsize() : FL_NORMAL_SIZE;
- l.color = !active() ? (labelcolor_|8) : labelcolor_;
+ l.color = !active() ? inactive((Fl_Color)labelcolor_) : labelcolor_;
Fl_Color color = m ? m->color() : FL_GRAY;
if (selected) {
Fl_Color r = m ? m->selection_color() : FL_SELECTION_COLOR;
@@ -703,5 +703,5 @@ const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const {
}
//
-// End of "$Id: Fl_Menu.cxx,v 1.9 1999/01/05 17:52:59 mike Exp $".
+// End of "$Id: Fl_Menu.cxx,v 1.10 1999/01/05 17:57:48 mike Exp $".
//
diff --git a/src/fl_color.cxx b/src/fl_color.cxx
index f60d1e16f..592b0b519 100644
--- a/src/fl_color.cxx
+++ b/src/fl_color.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_color.cxx,v 1.5 1998/12/29 14:05:13 mike Exp $"
+// "$Id: fl_color.cxx,v 1.6 1999/01/05 17:57:48 mike Exp $"
//
// Color functions for the Fast Light Tool Kit (FLTK).
//
@@ -275,6 +275,25 @@ void fl_color(Fl_Color i) {
// bright/dark is decided based on high bits of green:
#define bright(x) ((x)&0xc00000)
+Fl_Color inactive(Fl_Color c) {
+ Fl_Color i;
+ unsigned incolor = fl_cmap[c];
+ unsigned gray = fl_cmap[FL_GRAY];
+ uchar r, g, b;
+
+ r = ((uchar)(incolor>>24))/3 + ((uchar)(gray>>24))/3 * 2;
+ g = ((uchar)(incolor>>16))/3 + ((uchar)(gray>>16))/3 * 2;
+ b = ((uchar)(incolor>>8))/3 + ((uchar)(gray>>8))/3 * 2;
+
+ if (r == g && r == b) { // get it out of gray ramp
+ i = fl_gray_ramp(r*FL_NUM_GRAY/256);
+ } else { // get it out of color cube:
+ i = fl_color_cube(r*FL_NUM_RED/256,g*FL_NUM_GREEN/256,b*FL_NUM_BLUE/256);
+ }
+
+ return i;
+}
+
Fl_Color contrast(Fl_Color fg, Fl_Color bg) {
if (bright(fl_cmap[bg])) {
if (bright(fl_cmap[fg]))
@@ -334,5 +353,5 @@ void Fl::get_color(Fl_Color i, uchar &red, uchar &green, uchar &blue) {
#endif
//
-// End of "$Id: fl_color.cxx,v 1.5 1998/12/29 14:05:13 mike Exp $".
+// End of "$Id: fl_color.cxx,v 1.6 1999/01/05 17:57:48 mike Exp $".
//
diff --git a/src/fl_color_win32.cxx b/src/fl_color_win32.cxx
index 361d2eb57..8da810183 100644
--- a/src/fl_color_win32.cxx
+++ b/src/fl_color_win32.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_color_win32.cxx,v 1.9 1998/12/08 22:07:30 mike Exp $"
+// "$Id: fl_color_win32.cxx,v 1.10 1999/01/05 17:57:48 mike Exp $"
//
// WIN32 color functions for the Fast Light Tool Kit (FLTK).
//
@@ -147,6 +147,25 @@ CREATE_BRUSH:
return brushes[i].brush;
}
+Fl_Color inactive(Fl_Color c) {
+ Fl_Color i;
+ unsigned incolor = fl_cmap[c];
+ unsigned gray = fl_cmap[FL_GRAY];
+ uchar r, g, b;
+
+ r = ((uchar)(incolor>>24))/3 + ((uchar)(gray>>24))/3 * 2;
+ g = ((uchar)(incolor>>16))/3 + ((uchar)(gray>>16))/3 * 2;
+ b = ((uchar)(incolor>>8))/3 + ((uchar)(gray>>8))/3 * 2;
+
+ if (r == g && r == b) { // get it out of gray ramp
+ i = fl_gray_ramp(r*FL_NUM_GRAY/256);
+ } else { // get it out of color cube:
+ i = fl_color_cube(r*FL_NUM_RED/256,g*FL_NUM_GREEN/256,b*FL_NUM_BLUE/256);
+ }
+
+ return i;
+}
+
Fl_Color contrast(Fl_Color fg, Fl_Color bg) {
// bright/dark is decided based on high bit of green:
if (fl_cmap[bg] & 0x800000) {
@@ -233,5 +252,5 @@ fl_select_palette(void)
#endif
//
-// End of "$Id: fl_color_win32.cxx,v 1.9 1998/12/08 22:07:30 mike Exp $".
+// End of "$Id: fl_color_win32.cxx,v 1.10 1999/01/05 17:57:48 mike Exp $".
//
diff --git a/src/fl_labeltype.cxx b/src/fl_labeltype.cxx
index b9f8ace53..5fa8550cf 100644
--- a/src/fl_labeltype.cxx
+++ b/src/fl_labeltype.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_labeltype.cxx,v 1.4 1998/12/02 15:39:37 mike Exp $"
+// "$Id: fl_labeltype.cxx,v 1.5 1999/01/05 17:57:49 mike Exp $"
//
// Label drawing routines for the Fast Light Tool Kit (FLTK).
//
@@ -107,7 +107,7 @@ extern char fl_draw_shortcut;
void Fl_Widget::draw_label(int X, int Y, int W, int H, Fl_Align a) const {
if (flags()&SHORTCUT_LABEL) fl_draw_shortcut = 1;
Fl_Label l1 = label_;
- if (!active_r()) l1.color |= 8;
+ if (!active_r()) l1.color = inactive((Fl_Color)l1.color);
l1.draw(X,Y,W,H,a);
fl_draw_shortcut = 0;
}
@@ -117,5 +117,5 @@ void Fl_Widget::draw_label(int X, int Y, int W, int H, Fl_Align a) const {
#include <FL/Fl_Input_.H>
//
-// End of "$Id: fl_labeltype.cxx,v 1.4 1998/12/02 15:39:37 mike Exp $".
+// End of "$Id: fl_labeltype.cxx,v 1.5 1999/01/05 17:57:49 mike Exp $".
//