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
This commit is contained in:
parent
131b567003
commit
41d027ebfb
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Enumerations.H,v 1.6 1998/12/22 18:26:10 mike Exp $"
|
||||
// "$Id: Enumerations.H,v 1.7 1999/01/05 17:57:47 mike Exp $"
|
||||
//
|
||||
// Enumerations for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -277,7 +277,7 @@ enum Fl_Color { // standard colors
|
||||
FL_COLOR_CUBE = 56
|
||||
};
|
||||
|
||||
inline Fl_Color inactive(Fl_Color c) {return (Fl_Color)(c|8);}
|
||||
Fl_Color inactive(Fl_Color c);
|
||||
Fl_Color contrast(Fl_Color fg, Fl_Color bg);
|
||||
#define FL_NUM_GRAY 24
|
||||
inline Fl_Color fl_gray_ramp(int i) {return (Fl_Color)(i+FL_GRAY_RAMP);}
|
||||
@ -347,5 +347,5 @@ enum Fl_Damage {
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Enumerations.H,v 1.6 1998/12/22 18:26:10 mike Exp $".
|
||||
// End of "$Id: Enumerations.H,v 1.7 1999/01/05 17:57:47 mike Exp $".
|
||||
//
|
||||
|
@ -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 $".
|
||||
//
|
||||
|
@ -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 $".
|
||||
//
|
||||
|
@ -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 $".
|
||||
//
|
||||
|
@ -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 $".
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user