More tweeking of plastic boxtypes.

Redraw parent if child button loses focus and is using FL_NO_BOX.

Fix test/Makefile to build mandelbrot and shiny demos right.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1844 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet
2001-12-14 16:48:13 +00:00
parent ce129e1620
commit 5c3b2f74bc
7 changed files with 108 additions and 100 deletions
+15
View File
@@ -1,3 +1,18 @@
CHANGES IN FLTK 1.1.0b8
- Cosmetic changes to plastic boxtypes. Now look much
better for large areas and the sides now have a much
greater "3D" feeling to them.
- Added new Fl::draw_box_active() method so that
boxtypes can find out if the widget they are drawing
for is active or not.
- Fl_Button and its subclasses did not redraw the parent
when the boxtype was FL_NO_BOX and they lost keyboard
focus (the parent redraw clears the focus box.)
- Fixed the example program makefile - wasn't building
the mandelbrot and shiny demos right.
CHANGES IN FLTK 1.1.0b7 CHANGES IN FLTK 1.1.0b7
- More documentation updates... - More documentation updates...
+3 -2
View File
@@ -1,5 +1,5 @@
// //
// "$Id: Fl.H,v 1.8.2.11.2.8 2001/12/11 16:03:11 easysw Exp $" // "$Id: Fl.H,v 1.8.2.11.2.9 2001/12/14 16:48:13 easysw Exp $"
// //
// Main header file for the Fast Light Tool Kit (FLTK). // Main header file for the Fast Light Tool Kit (FLTK).
// //
@@ -202,6 +202,7 @@ public:
static FL_EXPORT int box_dy(Fl_Boxtype); static FL_EXPORT int box_dy(Fl_Boxtype);
static FL_EXPORT int box_dw(Fl_Boxtype); static FL_EXPORT int box_dw(Fl_Boxtype);
static FL_EXPORT int box_dh(Fl_Boxtype); static FL_EXPORT int box_dh(Fl_Boxtype);
static FL_EXPORT int draw_box_active();
// back compatability: // back compatability:
static FL_EXPORT void set_abort(void (*f)(const char*,...)) {fatal = f;} static FL_EXPORT void set_abort(void (*f)(const char*,...)) {fatal = f;}
@@ -233,5 +234,5 @@ public:
#endif // !Fl_H #endif // !Fl_H
// //
// End of "$Id: Fl.H,v 1.8.2.11.2.8 2001/12/11 16:03:11 easysw Exp $". // End of "$Id: Fl.H,v 1.8.2.11.2.9 2001/12/14 16:48:13 easysw Exp $".
// //
+4 -3
View File
@@ -1,5 +1,5 @@
// //
// "$Id: Fl_Button.cxx,v 1.4.2.6.2.6 2001/12/11 16:03:11 easysw Exp $" // "$Id: Fl_Button.cxx,v 1.4.2.6.2.7 2001/12/14 16:48:13 easysw Exp $"
// //
// Button widget for the Fast Light Tool Kit (FLTK). // Button widget for the Fast Light Tool Kit (FLTK).
// //
@@ -108,7 +108,8 @@ int Fl_Button::handle(int event) {
case FL_FOCUS : case FL_FOCUS :
case FL_UNFOCUS : case FL_UNFOCUS :
if (Fl::visible_focus()) { if (Fl::visible_focus()) {
redraw(); if (event == FL_UNFOCUS && box() == FL_NO_BOX) parent()->redraw();
else redraw();
return 1; return 1;
} else return 0; } else return 0;
case FL_KEYBOARD : case FL_KEYBOARD :
@@ -138,5 +139,5 @@ Fl_Button::Fl_Button(int x,int y,int w,int h, const char *l)
} }
// //
// End of "$Id: Fl_Button.cxx,v 1.4.2.6.2.6 2001/12/11 16:03:11 easysw Exp $". // End of "$Id: Fl_Button.cxx,v 1.4.2.6.2.7 2001/12/14 16:48:13 easysw Exp $".
// //
+3 -3
View File
@@ -1,5 +1,5 @@
// //
// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.9 2001/12/07 16:28:38 easysw Exp $" // "$Id: Fl_Widget.cxx,v 1.5.2.4.2.10 2001/12/14 16:48:13 easysw Exp $"
// //
// Base widget class for the Fast Light Tool Kit (FLTK). // Base widget class for the Fast Light Tool Kit (FLTK).
// //
@@ -152,7 +152,7 @@ Fl_Widget::draw_focus(Fl_Boxtype B, int X, int Y, int W, int H) const {
// every other pixel around the focus area... // every other pixel around the focus area...
// //
// Also, QuickDraw (MacOS) does not support line styles specifically, // Also, QuickDraw (MacOS) does not support line styles specifically,
// and the hack we use in fl_line_style() will not horizontal lines // and the hack we use in fl_line_style() will not draw horizontal lines
// on odd-numbered rows... // on odd-numbered rows...
int i, xx, yy; int i, xx, yy;
@@ -248,5 +248,5 @@ int Fl_Widget::contains(const Fl_Widget *o) const {
} }
// //
// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.9 2001/12/07 16:28:38 easysw Exp $". // End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.10 2001/12/14 16:48:13 easysw Exp $".
// //
+9 -6
View File
@@ -1,5 +1,5 @@
// //
// "$Id: fl_boxtype.cxx,v 1.8.2.4.2.4 2001/11/28 21:37:35 easysw Exp $" // "$Id: fl_boxtype.cxx,v 1.8.2.4.2.5 2001/12/14 16:48:13 easysw Exp $"
// //
// Box drawing code for the Fast Light Tool Kit (FLTK). // Box drawing code for the Fast Light Tool Kit (FLTK).
// //
@@ -49,6 +49,9 @@ static uchar inactive_ramp[24] = {
49, 49, 50, 50, 49, 49, 50, 50,
51, 51, 52, 52}; 51, 51, 52, 52};
static int draw_it_active = 1; static int draw_it_active = 1;
int Fl::draw_box_active() { return draw_it_active; }
uchar *fl_gray_ramp() {return (draw_it_active?active_ramp:inactive_ramp)-'A';} uchar *fl_gray_ramp() {return (draw_it_active?active_ramp:inactive_ramp)-'A';}
void fl_frame(const char* s, int x, int y, int w, int h) { void fl_frame(const char* s, int x, int y, int w, int h) {
@@ -219,10 +222,10 @@ static struct {
{fl_border_box, 1,1,2,2,0}, // _FL_OVAL_SHADOW_BOX, {fl_border_box, 1,1,2,2,0}, // _FL_OVAL_SHADOW_BOX,
{fl_border_frame, 1,1,2,2,0}, // _FL_OVAL_FRAME {fl_border_frame, 1,1,2,2,0}, // _FL_OVAL_FRAME
{fl_rectf, 0,0,0,0,0}, // _FL_OVAL_FLAT_BOX, {fl_rectf, 0,0,0,0,0}, // _FL_OVAL_FLAT_BOX,
{fl_up_box, 3,3,5,5,0}, // _FL_PLASTIC_UP_BOX, {fl_up_box, 4,4,7,6,0}, // _FL_PLASTIC_UP_BOX,
{fl_down_box, 3,3,5,5,0}, // _FL_PLASTIC_DOWN_BOX, {fl_down_box, 4,4,7,6,0}, // _FL_PLASTIC_DOWN_BOX,
{fl_up_frame, 3,3,5,5,0}, // _FL_PLASTIC_UP_FRAME, {fl_up_frame, 4,4,7,6,0}, // _FL_PLASTIC_UP_FRAME,
{fl_down_frame, 3,3,5,5,0}, // _FL_PLASTIC_DOWN_FRAME, {fl_down_frame, 4,4,7,6,0}, // _FL_PLASTIC_DOWN_FRAME,
{fl_up_box, 3,3,6,6,0}, // FL_FREE_BOX+0 {fl_up_box, 3,3,6,6,0}, // FL_FREE_BOX+0
{fl_down_box, 3,3,6,6,0}, // FL_FREE_BOX+1 {fl_down_box, 3,3,6,6,0}, // FL_FREE_BOX+1
{fl_up_box, 3,3,6,6,0}, // FL_FREE_BOX+2 {fl_up_box, 3,3,6,6,0}, // FL_FREE_BOX+2
@@ -288,5 +291,5 @@ const {
} }
// //
// End of "$Id: fl_boxtype.cxx,v 1.8.2.4.2.4 2001/11/28 21:37:35 easysw Exp $". // End of "$Id: fl_boxtype.cxx,v 1.8.2.4.2.5 2001/12/14 16:48:13 easysw Exp $".
// //
+66 -82
View File
@@ -1,5 +1,5 @@
// //
// "$Id: fl_plastic.cxx,v 1.1.2.6 2001/12/14 03:45:37 easysw Exp $" // "$Id: fl_plastic.cxx,v 1.1.2.7 2001/12/14 16:48:13 easysw Exp $"
// //
// "Plastic" drawing routines for the Fast Light Tool Kit (FLTK). // "Plastic" drawing routines for the Fast Light Tool Kit (FLTK).
// //
@@ -38,15 +38,17 @@
extern uchar *fl_gray_ramp(); extern uchar *fl_gray_ramp();
inline Fl_Color shade_color(uchar gc, Fl_Color bc) { inline Fl_Color shade_color(uchar gc, Fl_Color bc) {
return fl_color_average((Fl_Color)gc, bc, 0.67f); return fl_color_average((Fl_Color)gc, bc, 0.75f);
} }
static void shade_frame(int x, int y, int w, int h, const char *c, Fl_Color bc) { static void shade_frame(int x, int y, int w, int h, const char *c, Fl_Color bc) {
uchar *g = fl_gray_ramp(); uchar *g = fl_gray_ramp();
int b = strlen(c) / 4 + 1; int b = strlen(c) / 4 + 1;
for (x += b, y += b, w -= 2 * b, h -= 2 * b; b > 1; b --) for (x += b, y += b, w -= 2 * b + 1, h -= 2 * b + 1; b > 1; b --)
{ {
// Draw lines around the perimeter of the button, 4 colors per
// circuit.
fl_color(shade_color(g[*c++], bc)); fl_color(shade_color(g[*c++], bc));
fl_line(x, y + h + b, x + w - 1, y + h + b, x + w + b - 1, y + h); fl_line(x, y + h + b, x + w - 1, y + h + b, x + w + b - 1, y + h);
fl_color(shade_color(g[*c++], bc)); fl_color(shade_color(g[*c++], bc));
@@ -58,87 +60,88 @@ static void shade_frame(int x, int y, int w, int h, const char *c, Fl_Color bc)
} }
} }
static void shade_rect(int x, int y, int w, int h, const char *c, Fl_Color bc) static void shade_rect(int x, int y, int w, int h, const char *c, Fl_Color bc)
{ {
uchar *g = fl_gray_ramp(); uchar *g = fl_gray_ramp();
int xoff, yoff; int i, j;
int cmod, cerr; int clen = strlen(c) - 1;
int clen = strlen(c); int chalf = clen / 2;
int cstep = 1;
if (h < (w * 2)) {
// Horizontal shading...
if (clen >= h) cstep = 2;
if (h < (w * 2)) for (i = 0, j = 0; j < chalf; i ++, j += cstep) {
{ // Draw the top line and points...
h ++; fl_color(shade_color(g[c[i]], bc));
cmod = clen % h; fl_xyline(x + 1, y + i, x + w - 1);
cerr = 0;
fl_color(shade_color(g[*c], bc)); fl_color(shade_color(g[c[i] - 8], bc));
fl_point(x, y + i);
fl_point(x + w - 1, y + i);
for (yoff = 0; yoff < h; yoff ++) // Draw the bottom line and points...
{ fl_color(shade_color(g[c[clen - i]], bc));
fl_xyline(x, y + yoff, x + w - 1); fl_xyline(x + 1, y + h - 1 - i, x + w - 1);
cerr += cmod; fl_color(shade_color(g[c[clen - i] - 8], bc));
if (cerr >= h) fl_point(x, y + h - i);
{ fl_point(x + w - 1, y + h - i);
cerr -= h;
c ++;
fl_color(shade_color(g[*c], bc));
}
} }
}
else
{
w ++;
cmod = clen % w;
cerr = 0;
fl_color(shade_color(g[*c], bc)); // Draw the interior and sides...
i = chalf / cstep;
for (xoff = 0; xoff < w; xoff ++) fl_color(shade_color(g[c[chalf]], bc));
{ fl_rectf(x + 1, y + i, w - 2, h - 2 * i);
fl_yxline(x + xoff, y, y + h - 1);
cerr += cmod; fl_color(shade_color(g[c[chalf] - 8], bc));
if (cerr >= w) fl_yxline(x, y + i, y + h - i);
{ fl_yxline(x + w - 1, y + i, y + h - i);
cerr -= w; } else {
c ++; // Vertical shading...
if (clen >= w) cstep = 2;
fl_color(shade_color(g[*c], bc)); for (i = 0, j = 0; j < chalf; i ++, j += cstep) {
} // Draw the left line and points...
fl_color(shade_color(g[c[i]], bc));
fl_yxline(x + i, y + 1, y + h - 1);
fl_color(shade_color(g[c[i] - 8], bc));
fl_point(x + i, y);
fl_point(x + i, y + h - 1);
// Draw the right line and points...
fl_color(shade_color(g[c[clen - i]], bc));
fl_yxline(x + w - 1 - i, y + 1, y + h - 1);
fl_color(shade_color(g[c[clen - i] - 8], bc));
fl_point(x + w - 1 - i, y);
fl_point(x + w - 1 - i, y + h - 1);
} }
// Draw the interior, top, and bottom...
i = chalf / cstep;
fl_color(shade_color(g[c[chalf]], bc));
fl_rectf(x + i, y + 1, w - 2 * i, h - 2);
fl_color(shade_color(g[c[chalf] - 8], bc));
fl_xyline(x + i, y, x + w - i);
fl_xyline(x + i, y + h - 1, x + w - i);
} }
} }
static void up_frame(int x, int y, int w, int h, Fl_Color c) { static void up_frame(int x, int y, int w, int h, Fl_Color c) {
shade_frame(x, y, w, h, "RRSSDLNN", c); shade_frame(x, y, w, h, "KLOPMNNO", c);
} }
static void up_box(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 (w > 30 && h > 30) shade_rect(x + 2, y + 2, w - 4, h - 4, "QTXWVUTRSTUVWXS", c);
{
uchar *g = fl_gray_ramp();
if ( h<(w*2) )
{
shade_rect(x + 2, y + 2, w - 4, 9, "VTR", c);
fl_color(shade_color(g['P'], c));
fl_rectf(x + 2, y + 11, w - 4, h - 25);
shade_rect(x + 2, y + h - 14, w - 4, 12, "RTVXX", c);
}
else
{
shade_rect(x + 2, y + 2, 9, h-4, "VTR", c);
fl_color(shade_color(g['P'], c));
fl_rectf(x + 11, y + 2, w - 25, h - 4);
shade_rect(x + w - 14, y + 2, 12, h-4, "RTVXX", c);
}
}
else
shade_rect(x + 2, y + 2, w - 4, h - 4, "VTRPPRTVXX", c);
up_frame(x, y, w, h, c); up_frame(x, y, w, h, c);
} }
@@ -150,26 +153,7 @@ static void down_frame(int x, int y, int w, int h, Fl_Color c) {
static void down_box(int x, int y, int w, int h, Fl_Color c) { static void down_box(int x, int y, int w, int h, Fl_Color c) {
if (w > 30 && h > 30) shade_rect(x + 2, y + 2, w - 4, h - 4, "STUVWWWVT", c);
{
uchar *g = fl_gray_ramp();
if ( w>=h )
{
shade_rect(x + 2, y + 2, w - 4, 11, "STUV", c);
fl_color(shade_color(g['W'], c));
fl_rectf(x + 2, y + 13, w - 4, h - 21);
shade_rect(x + 2, y + h - 8, w - 4, 6, "VT", c);
}
else
{
shade_rect(x + 2, y + 2, 11, h-4, "STUV", c);
fl_color(shade_color(g['W'], c));
fl_rectf(x + 13, y + 2, w - 21, h - 4);
shade_rect(x + w - 8, y + 2, 6, h-4, "VT", c);
}
}
else
shade_rect(x + 2, y + 2, w - 4, h - 4, "STUVWWWWVT", c);
down_frame(x, y, w, h, c); down_frame(x, y, w, h, c);
} }
@@ -189,5 +173,5 @@ Fl_Boxtype define_FL_PLASTIC_UP_BOX() {
// //
// End of "$Id: fl_plastic.cxx,v 1.1.2.6 2001/12/14 03:45:37 easysw Exp $". // End of "$Id: fl_plastic.cxx,v 1.1.2.7 2001/12/14 16:48:13 easysw Exp $".
// //
+8 -4
View File
@@ -1,5 +1,5 @@
# #
# "$Id: Makefile,v 1.19.2.7.2.18 2001/12/12 21:33:34 easysw Exp $" # "$Id: Makefile,v 1.19.2.7.2.19 2001/12/14 16:48:13 easysw Exp $"
# #
# Test/example program makefile for the Fast Light Tool Kit (FLTK). # Test/example program makefile for the Fast Light Tool Kit (FLTK).
# #
@@ -181,10 +181,12 @@ keyboard$(EXEEXT): keyboard.o
$(POSTBUILD) $(POSTBUILD)
keyboard.o: keyboard.cxx keyboard_ui.cxx keyboard.o: keyboard.cxx keyboard_ui.cxx
mandelbrot$(EXEEXT): mandelbrot.o mandelbrot_ui.o mandelbrot$(EXEEXT): mandelbrot.o
echo Linking $@... echo Linking $@...
$(CXX) -I.. $(CXXFLAGS) mandelbrot.o $(LINKFLTK) $(LDLIBS) -o $@ $(CXX) -I.. $(CXXFLAGS) mandelbrot.o $(LINKFLTK) $(LDLIBS) -o $@
$(POSTBUILD) $(POSTBUILD)
mandlebrot.o: mandelbrot.cxx mandelbrot_ui.cxx
pixmap_browser$(EXEEXT): pixmap_browser.o pixmap_browser$(EXEEXT): pixmap_browser.o
echo Linking $@... echo Linking $@...
$(CXX) -I.. $(CXXFLAGS) pixmap_browser.o -o $@ $(LINKFLTK) $(LDLIBS) $(IMAGELIBS) $(CXX) -I.. $(CXXFLAGS) pixmap_browser.o -o $@ $(LINKFLTK) $(LDLIBS) $(IMAGELIBS)
@@ -219,10 +221,12 @@ gl_overlay$(EXEEXT): gl_overlay.o
echo Linking $@... echo Linking $@...
$(CXX) -I.. $(CXXFLAGS) gl_overlay.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS) -o $@ $(CXX) -I.. $(CXXFLAGS) gl_overlay.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS) -o $@
$(POSTBUILD) $(POSTBUILD)
shiny$(EXEEXT): shiny.o shiny_panel.o shiny$(EXEEXT): shiny.o
echo Linking $@... echo Linking $@...
$(CXX) -I.. $(CXXFLAGS) shiny.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS) -o $@ $(CXX) -I.. $(CXXFLAGS) shiny.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS) -o $@
$(POSTBUILD) $(POSTBUILD)
shiny.o: shiny.cxx shiny_panel.cxx
shape$(EXEEXT): shape.o shape$(EXEEXT): shape.o
echo Linking $@... echo Linking $@...
$(CXX) -I.. $(CXXFLAGS) shape.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS) -o $@ $(CXX) -I.. $(CXXFLAGS) shape.o $(LINKFLTKGL) $(LINKFLTK) $(GLDLIBS) -o $@
@@ -249,5 +253,5 @@ uninstall:
@echo Nothing to uninstall in test directory. @echo Nothing to uninstall in test directory.
# #
# End of "$Id: Makefile,v 1.19.2.7.2.18 2001/12/12 21:33:34 easysw Exp $". # End of "$Id: Makefile,v 1.19.2.7.2.19 2001/12/14 16:48:13 easysw Exp $".
# #