Add GTK thin up/down box/frame types.

Update the GTK round up/down box types.

Update radio/check box drawing for gtk+ scheme.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5505 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2006-10-03 02:35:12 +00:00
parent ad4a4ea0db
commit 7febae3f9e
8 changed files with 125 additions and 14 deletions

View File

@ -179,6 +179,8 @@ enum Fl_Boxtype { // boxtypes (if you change these you must fix fl_boxtype.C):
_FL_PLASTIC_ROUND_UP_BOX, _FL_PLASTIC_ROUND_DOWN_BOX,
_FL_GTK_UP_BOX, _FL_GTK_DOWN_BOX,
_FL_GTK_UP_FRAME, _FL_GTK_DOWN_FRAME,
_FL_GTK_THIN_UP_BOX, _FL_GTK_THIN_DOWN_BOX,
_FL_GTK_THIN_UP_FRAME, _FL_GTK_THIN_DOWN_FRAME,
_FL_GTK_ROUND_UP_BOX, _FL_GTK_ROUND_DOWN_BOX,
FL_FREE_BOXTYPE
};
@ -219,8 +221,12 @@ extern FL_EXPORT Fl_Boxtype fl_define_FL_GTK_UP_BOX();
#define FL_GTK_DOWN_BOX (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+1)
#define FL_GTK_UP_FRAME (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+2)
#define FL_GTK_DOWN_FRAME (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+3)
#define FL_GTK_ROUND_UP_BOX (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+4)
#define FL_GTK_ROUND_DOWN_BOX (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+5)
#define FL_GTK_THIN_UP_BOX (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+4)
#define FL_GTK_THIN_DOWN_BOX (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+5)
#define FL_GTK_THIN_UP_FRAME (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+6)
#define FL_GTK_THIN_DOWN_FRAME (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+7)
#define FL_GTK_ROUND_UP_BOX (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+8)
#define FL_GTK_ROUND_DOWN_BOX (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+9)
// conversions of box types to other boxtypes:
inline Fl_Boxtype fl_down(Fl_Boxtype b) {return (Fl_Boxtype)(b|1);}

View File

@ -643,6 +643,8 @@ Fl_Menu_Item boxmenu[] = {
{"PLASTIC_ROUND_DOWN_BOX",0,0,(void *)FL_PLASTIC_ROUND_DOWN_BOX},
{"GTK_UP_BOX",0,0,(void *)FL_GTK_UP_BOX},
{"GTK_DOWN_BOX",0,0,(void *)FL_GTK_DOWN_BOX},
{"GTK_THIN_UP_BOX",0,0,(void *)FL_GTK_THIN_UP_BOX},
{"GTK_THIN_DOWN_BOX",0,0,(void *)FL_GTK_THIN_DOWN_BOX},
{"GTK_ROUND_UP_BOX",0,0,(void *)FL_GTK_ROUND_UP_BOX},
{"GTK_ROUND_DOWN_BOX",0,0,(void *)FL_GTK_ROUND_DOWN_BOX},
{0},
@ -661,6 +663,8 @@ Fl_Menu_Item boxmenu[] = {
{"PLASTIC_DOWN_FRAME",0,0,(void *)FL_PLASTIC_DOWN_FRAME},
{"GTK_UP_FRAME",0,0,(void *)FL_GTK_UP_FRAME},
{"GTK_DOWN_FRAME",0,0,(void *)FL_GTK_DOWN_FRAME},
{"GTK_THIN_UP_FRAME",0,0,(void *)FL_GTK_THIN_UP_FRAME},
{"GTK_THIN_DOWN_FRAME",0,0,(void *)FL_GTK_THIN_DOWN_FRAME},
{0},
{0}};

View File

@ -3,7 +3,7 @@
//
// Lighted button widget for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2005 by Bill Spitzak and others.
// Copyright 1998-2006 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@ -59,7 +59,11 @@ void Fl_Light_Button::draw() {
// Check box...
draw_box(down_box(), x()+dx, y()+dy, W, W, FL_BACKGROUND2_COLOR);
if (value()) {
if (Fl::scheme() && !strcmp(Fl::scheme(), "gtk+")) {
fl_color(FL_SELECTION_COLOR);
} else {
fl_color(col);
}
int tx = x() + dx + 3;
int tw = W - 6;
int d1 = tw/3;
@ -76,12 +80,19 @@ void Fl_Light_Button::draw() {
// Radio button...
draw_box(down_box(), x()+dx, y()+dy, W, W, FL_BACKGROUND2_COLOR);
if (value()) {
fl_color(col);
int tW = (W - Fl::box_dw(down_box())) / 2 + 1;
if ((W - tW) & 1) tW++; // Make sure difference is even to center
int tdx = dx + (W - tW) / 2;
int tdy = dy + (W - tW) / 2;
if (Fl::scheme() && !strcmp(Fl::scheme(), "gtk+")) {
fl_color(FL_SELECTION_COLOR);
tW --;
fl_pie(x() + tdx - 1, y() + tdy - 1, tW + 3, tW + 3, 0.0, 360.0);
fl_arc(x() + tdx - 1, y() + tdy - 1, tW + 3, tW + 3, 0.0, 360.0);
fl_color(fl_color_average(FL_WHITE, FL_SELECTION_COLOR, 0.2));
} else fl_color(col);
switch (tW) {
// Larger circles draw fine...
default :
@ -107,6 +118,11 @@ void Fl_Light_Button::draw() {
fl_rectf(x() + tdx, y() + tdy, tW, tW);
break;
}
if (Fl::scheme() && !strcmp(Fl::scheme(), "gtk+")) {
fl_color(fl_color_average(FL_WHITE, FL_SELECTION_COLOR, 0.5));
fl_arc(x() + tdx, y() + tdy, tW + 1, tW + 1, 60.0, 180.0);
} else fl_color(col);
}
break;
default :

View File

@ -331,13 +331,13 @@ int Fl::reload_scheme() {
set_boxtype(FL_UP_FRAME, FL_GTK_UP_FRAME);
set_boxtype(FL_DOWN_FRAME, FL_GTK_DOWN_FRAME);
set_boxtype(FL_THIN_UP_FRAME, FL_GTK_UP_FRAME);
set_boxtype(FL_THIN_DOWN_FRAME, FL_GTK_DOWN_FRAME);
set_boxtype(FL_THIN_UP_FRAME, FL_GTK_THIN_UP_FRAME);
set_boxtype(FL_THIN_DOWN_FRAME, FL_GTK_THIN_DOWN_FRAME);
set_boxtype(FL_UP_BOX, FL_GTK_UP_BOX);
set_boxtype(FL_DOWN_BOX, FL_GTK_DOWN_BOX);
set_boxtype(FL_THIN_UP_BOX, FL_GTK_UP_BOX);
set_boxtype(FL_THIN_DOWN_BOX, FL_GTK_DOWN_BOX);
set_boxtype(FL_THIN_UP_BOX, FL_GTK_THIN_UP_BOX);
set_boxtype(FL_THIN_DOWN_BOX, FL_GTK_THIN_DOWN_BOX);
set_boxtype(_FL_ROUND_UP_BOX, FL_GTK_ROUND_UP_BOX);
set_boxtype(_FL_ROUND_DOWN_BOX, FL_GTK_ROUND_DOWN_BOX);
} else {

View File

@ -243,6 +243,10 @@ static struct {
{fl_down_box, 2,2,4,4,0}, // _FL_GTK_DOWN_BOX,
{fl_up_frame, 2,2,4,4,0}, // _FL_GTK_UP_FRAME,
{fl_down_frame, 2,2,4,4,0}, // _FL_GTK_DOWN_FRAME,
{fl_up_frame, 1,1,2,2,0}, // _FL_GTK_THIN_UP_FRAME,
{fl_down_frame, 1,1,2,2,0}, // _FL_GTK_THIN_DOWN_FRAME,
{fl_up_box, 1,1,2,2,0}, // _FL_GTK_THIN_ROUND_UP_BOX,
{fl_down_box, 1,1,2,2,0}, // _FL_GTK_THIN_ROUND_DOWN_BOX,
{fl_up_box, 2,2,4,4,0}, // _FL_GTK_ROUND_UP_BOX,
{fl_down_box, 2,2,4,4,0}, // _FL_GTK_ROUND_DOWN_BOX,
{fl_up_box, 3,3,6,6,0}, // FL_FREE_BOX+0

View File

@ -115,10 +115,74 @@ static void gtk_down_box(int x, int y, int w, int h, Fl_Color c) {
}
static void gtk_round_box(int x, int y, int w, int h, Fl_Color c) {
static void gtk_thin_up_frame(int x, int y, int w, int h, Fl_Color c) {
gtk_color(fl_color_average(FL_WHITE, c, 0.5));
fl_xyline(x + 1, y, x + w - 2);
fl_yxline(x, y + 1, y + h - 2);
gtk_color(fl_color_average(FL_BLACK, c, 0.5));
fl_xyline(x + 1, y + h - 1, x + w - 2);
fl_yxline(x + w - 1, y + 1, y + h - 2);
}
static void gtk_thin_up_box(int x, int y, int w, int h, Fl_Color c) {
gtk_thin_up_frame(x, y, w, h, c);
gtk_color(fl_color_average(FL_WHITE, c, 0.4));
fl_xyline(x + 1, y + 1, x + w - 2);
gtk_color(fl_color_average(FL_WHITE, c, 0.2));
fl_xyline(x + 1, y + 2, x + w - 2);
gtk_color(fl_color_average(FL_WHITE, c, 0.1));
fl_xyline(x + 1, y + 3, x + w - 2);
gtk_color(c);
fl_rectf(x + 1, y + 4, w - 2, h - 8);
gtk_color(fl_color_average(FL_BLACK, c, 0.025));
fl_xyline(x + 1, y + h - 4, x + w - 2);
gtk_color(fl_color_average(FL_BLACK, c, 0.05));
fl_xyline(x + 1, y + h - 3, x + w - 2);
gtk_color(fl_color_average(FL_BLACK, c, 0.1));
fl_xyline(x + 1, y + h - 2, x + w - 2);
}
static void gtk_thin_down_frame(int x, int y, int w, int h, Fl_Color c) {
gtk_color(fl_color_average(FL_BLACK, c, 0.5));
fl_xyline(x + 1, y, x + w - 2);
fl_yxline(x, y + 1, y + h - 2);
gtk_color(fl_color_average(FL_WHITE, c, 0.5));
fl_xyline(x + 1, y + h - 1, x + w - 2);
fl_yxline(x + w - 1, y + 1, y + h - 2);
}
static void gtk_thin_down_box(int x, int y, int w, int h, Fl_Color c) {
gtk_thin_down_frame(x, y, w, h, c);
gtk_color(c);
fl_rectf(x + 1, y + 1, w - 2, h - 2);
}
static void gtk_round_up_box(int x, int y, int w, int h, Fl_Color c) {
gtk_color(c);
fl_pie(x, y, w, h, 0.0, 360.0);
gtk_color(fl_color_average(FL_WHITE, c, 0.5));
fl_arc(x, y, w, h, 45.0, 180.0);
gtk_color(fl_color_average(FL_WHITE, c, 0.25));
fl_arc(x, y, w, h, 180.0, 405.0);
gtk_color(fl_color_average(FL_BLACK, c, 0.5));
fl_arc(x, y, w, h, 225.0, 360.0);
}
static void gtk_round_down_box(int x, int y, int w, int h, Fl_Color c) {
gtk_color(c);
fl_pie(x, y, w, h, 0.0, 360.0);
gtk_color(fl_color_average(FL_BLACK, c, 0.2));
fl_arc(x + 1, y, w, h, 90.0, 210.0);
gtk_color(fl_color_average(FL_BLACK, c, 0.6));
fl_arc(x, y, w, h, 0.0, 360.0);
}
@ -128,8 +192,12 @@ Fl_Boxtype fl_define_FL_GTK_UP_BOX() {
fl_internal_boxtype(_FL_GTK_DOWN_BOX, gtk_down_box);
fl_internal_boxtype(_FL_GTK_UP_FRAME, gtk_up_frame);
fl_internal_boxtype(_FL_GTK_DOWN_FRAME, gtk_down_frame);
fl_internal_boxtype(_FL_GTK_ROUND_UP_BOX, gtk_round_box);
fl_internal_boxtype(_FL_GTK_ROUND_DOWN_BOX, gtk_round_box);
fl_internal_boxtype(_FL_GTK_THIN_UP_BOX, gtk_thin_up_box);
fl_internal_boxtype(_FL_GTK_THIN_DOWN_BOX, gtk_thin_down_box);
fl_internal_boxtype(_FL_GTK_THIN_UP_FRAME, gtk_thin_up_frame);
fl_internal_boxtype(_FL_GTK_THIN_DOWN_FRAME, gtk_thin_down_frame);
fl_internal_boxtype(_FL_GTK_ROUND_UP_BOX, gtk_round_up_box);
fl_internal_boxtype(_FL_GTK_ROUND_DOWN_BOX, gtk_round_down_box);
return _FL_GTK_UP_BOX;
}

View File

@ -3,7 +3,7 @@
//
// More font utilities for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2005 by Bill Spitzak and others.
// Copyright 1998-2006 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public

View File

@ -34,7 +34,7 @@
int N = 0;
#define W 200
#define H 50
#define ROWS 11
#define ROWS 14
Fl_Window *window;
@ -94,6 +94,7 @@ int main(int argc, char ** argv) {
bt("FL_ROUND_DOWN_BOX",FL_ROUND_DOWN_BOX);
bt("FL_DIAMOND_UP_BOX",FL_DIAMOND_UP_BOX);
bt("FL_DIAMOND_DOWN_BOX",FL_DIAMOND_DOWN_BOX);
bt("FL_PLASTIC_UP_BOX",FL_PLASTIC_UP_BOX);
bt("FL_PLASTIC_DOWN_BOX",FL_PLASTIC_DOWN_BOX);
bt("FL_PLASTIC_UP_FRAME",FL_PLASTIC_UP_FRAME);
@ -103,6 +104,18 @@ int main(int argc, char ** argv) {
N += 2;
bt("FL_PLASTIC_ROUND_UP_BOX",FL_PLASTIC_ROUND_UP_BOX);
bt("FL_PLASTIC_ROUND_DOWN_BOX",FL_PLASTIC_ROUND_DOWN_BOX);
N += 2;
bt("FL_GTK_UP_BOX",FL_GTK_UP_BOX);
bt("FL_GTK_DOWN_BOX",FL_GTK_DOWN_BOX);
bt("FL_GTK_UP_FRAME",FL_GTK_UP_FRAME);
bt("FL_GTK_DOWN_FRAME",FL_GTK_DOWN_FRAME);
bt("FL_GTK_THIN_UP_BOX",FL_GTK_THIN_UP_BOX);
bt("FL_GTK_THIN_DOWN_BOX",FL_GTK_THIN_DOWN_BOX);
bt("FL_GTK_THIN_UP_FRAME",FL_GTK_THIN_UP_FRAME);
bt("FL_GTK_THIN_DOWN_FRAME",FL_GTK_THIN_DOWN_FRAME);
bt("FL_GTK_ROUND_UP_BOX",FL_GTK_ROUND_UP_BOX);
bt("FL_GTK_ROUND_DOWN_BOX",FL_GTK_ROUND_DOWN_BOX);
window->resizable(window);
window->end();
window->show();