summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2006-09-17 14:58:25 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2006-09-17 14:58:25 +0000
commitb4c1d3ef03084496a1899ba116ddcc7f6e5647c8 (patch)
tree6f3360c7f796a013e0ea0b1cb1ddb4b1744c8ab9 /src
parentd63cf6e3153f6be5ef6586588cdbaf53e1ff532c (diff)
Implement new "gtk+" scheme which provides a Bluecurve look-n-feel.
Fix size and position of dialog controls in FLUID to match the HIG. Add "GTK+" scheme to the list of selectable schemes in FLUID. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5438 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Button.cxx10
-rw-r--r--src/Fl_Choice.cxx7
-rw-r--r--src/Fl_Scroll.cxx2
-rw-r--r--src/Fl_Scrollbar.cxx28
-rw-r--r--src/Fl_Slider.cxx42
-rw-r--r--src/Fl_get_system_colors.cxx20
-rw-r--r--src/Makefile3
-rw-r--r--src/fl_boxtype.cxx10
-rw-r--r--src/fl_gtk.cxx134
9 files changed, 237 insertions, 19 deletions
diff --git a/src/Fl_Button.cxx b/src/Fl_Button.cxx
index 8a4536de0..7ba692162 100644
--- a/src/Fl_Button.cxx
+++ b/src/Fl_Button.cxx
@@ -3,7 +3,7 @@
//
// 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
@@ -60,9 +60,13 @@ void Fl_Button::setonly() { // set this radio button on, turn others off
void Fl_Button::draw() {
if (type() == FL_HIDDEN_BUTTON) return;
Fl_Color col = value() ? selection_color() : color();
-//if (col == FL_GRAY && Fl::belowmouse()==this) col = FL_LIGHT1;
draw_box(value() ? (down_box()?down_box():fl_down(box())) : box(), col);
- draw_label();
+ if (labeltype() == FL_NORMAL_LABEL) {
+ Fl_Color c = labelcolor();
+ labelcolor(fl_contrast(c, col));
+ draw_label();
+ labelcolor(c);
+ } else draw_label();
if (Fl::focus() == this) draw_focus();
}
diff --git a/src/Fl_Choice.cxx b/src/Fl_Choice.cxx
index 6361e03a4..338390a15 100644
--- a/src/Fl_Choice.cxx
+++ b/src/Fl_Choice.cxx
@@ -3,7 +3,7 @@
//
// Choice 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
@@ -51,8 +51,8 @@ void Fl_Choice::draw() {
fl_polygon(x1, y1 + 3, x1 + w1, y1 + w1 + 3, x1 + 2 * w1, y1 + 3);
fl_polygon(x1, y1 + 1, x1 + w1, y1 - w1 + 1, x1 + 2 * w1, y1 + 1);
} else {
- draw_box(FL_DOWN_BOX, color());
- draw_box(FL_UP_BOX,X,Y,W,H,FL_GRAY);
+ draw_box(FL_DOWN_BOX, fl_lighter(color()));
+ draw_box(FL_UP_BOX,X,Y,W,H,color());
fl_color(active_r() ? labelcolor() : fl_inactive(labelcolor()));
fl_polygon(x1, y1, x1 + w1, y1 + w1, x1 + 2 * w1, y1);
@@ -103,7 +103,6 @@ Fl_Choice::Fl_Choice(int X, int Y, int W, int H, const char *l)
textfont(FL_HELVETICA);
box(FL_FLAT_BOX);
down_box(FL_BORDER_BOX);
- color(FL_BACKGROUND2_COLOR);
}
int Fl_Choice::value(const Fl_Menu_Item *v) {
diff --git a/src/Fl_Scroll.cxx b/src/Fl_Scroll.cxx
index 09bf543bf..0053385cc 100644
--- a/src/Fl_Scroll.cxx
+++ b/src/Fl_Scroll.cxx
@@ -3,7 +3,7 @@
//
// Scroll 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
diff --git a/src/Fl_Scrollbar.cxx b/src/Fl_Scrollbar.cxx
index 66547b469..4ee2dc786 100644
--- a/src/Fl_Scrollbar.cxx
+++ b/src/Fl_Scrollbar.cxx
@@ -3,7 +3,7 @@
//
// Scroll bar 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
@@ -29,6 +29,7 @@
#include <FL/Fl_Scrollbar.H>
#include <FL/fl_draw.H>
#include <math.h>
+#include "flstring.h"
#define INITIALREPEAT .5
#define REPEAT .05
@@ -215,9 +216,15 @@ void Fl_Scrollbar::draw() {
int w1 = (H-4)/3; if (w1 < 1) w1 = 1;
int x1 = X+(H-w1-1)/2;
int yy1 = Y+(H-2*w1-1)/2;
- fl_polygon(x1, yy1+w1, x1+w1, yy1+2*w1, x1+w1, yy1);
- x1 += (W-H);
- fl_polygon(x1, yy1, x1, yy1+2*w1, x1+w1, yy1+w1);
+ if (Fl::scheme_ && !strcmp(Fl::scheme_, "gtk+")) {
+ fl_polygon(x1, yy1+w1, x1+w1, yy1+2*w1, x1+w1-1, yy1+w1, x1+w1, yy1);
+ x1 += (W-H);
+ fl_polygon(x1, yy1, x1+1, yy1+w1, x1, yy1+2*w1, x1+w1, yy1+w1);
+ } else {
+ fl_polygon(x1, yy1+w1, x1+w1, yy1+2*w1, x1+w1, yy1);
+ x1 += (W-H);
+ fl_polygon(x1, yy1, x1, yy1+2*w1, x1+w1, yy1+w1);
+ }
}
} else { // vertical
if (H < 3*W) {Fl_Slider::draw(X,Y,W,H); return;}
@@ -234,9 +241,16 @@ void Fl_Scrollbar::draw() {
int w1 = (W-4)/3; if (w1 < 1) w1 = 1;
int x1 = X+(W-2*w1-1)/2;
int yy1 = Y+(W-w1-1)/2;
- fl_polygon(x1, yy1+w1, x1+2*w1, yy1+w1, x1+w1, yy1);
- yy1 += H-W;
- fl_polygon(x1, yy1, x1+w1, yy1+w1, x1+2*w1, yy1);
+ if (Fl::scheme_ && !strcmp(Fl::scheme_, "gtk+")) {
+ fl_polygon(x1, yy1+w1, x1+w1, yy1+w1-1, x1+2*w1, yy1+w1, x1+w1, yy1);
+ yy1 += H-W;
+ fl_polygon(x1, yy1, x1+w1, yy1+1, x1+w1, yy1+w1);
+ fl_polygon(x1+w1, yy1+1, x1+2*w1, yy1, x1+w1, yy1+w1);
+ } else {
+ fl_polygon(x1, yy1+w1, x1+2*w1, yy1+w1, x1+w1, yy1);
+ yy1 += H-W;
+ fl_polygon(x1, yy1, x1+w1, yy1+w1, x1+2*w1, yy1);
+ }
}
}
}
diff --git a/src/Fl_Slider.cxx b/src/Fl_Slider.cxx
index 874ffa102..be39e9ce8 100644
--- a/src/Fl_Slider.cxx
+++ b/src/Fl_Slider.cxx
@@ -3,7 +3,7 @@
//
// Slider 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
@@ -29,6 +29,7 @@
#include <FL/Fl_Slider.H>
#include <FL/fl_draw.H>
#include <math.h>
+#include "flstring.h"
void Fl_Slider::_Fl_Slider() {
slider_size_ = 0;
@@ -148,6 +149,45 @@ void Fl_Slider::draw(int X, int Y, int W, int H) {
draw_box(FL_THIN_DOWN_BOX, xsl+d, ysl+2, wsl-2*d, hsl-4,selection_color());
} else {
if (wsl>0 && hsl>0) draw_box(box1, xsl, ysl, wsl, hsl, selection_color());
+
+ if (type()!=FL_HOR_FILL_SLIDER && type() != FL_VERT_FILL_SLIDER &&
+ Fl::scheme_ && !strcmp(Fl::scheme_, "gtk+")) {
+ if (W>H && wsl>(hsl+8)) {
+ // Draw horizontal grippers
+ int yy, hh;
+ hh = hsl-8;
+ xx = xsl+(wsl-hsl-4)/2;
+ yy = ysl+3;
+
+ fl_color(fl_darker(selection_color()));
+ fl_line(xx, yy+hh, xx+hh, yy);
+ fl_line(xx+6, yy+hh, xx+hh+6, yy);
+ fl_line(xx+12, yy+hh, xx+hh+12, yy);
+
+ xx++;
+ fl_color(fl_lighter(selection_color()));
+ fl_line(xx, yy+hh, xx+hh, yy);
+ fl_line(xx+6, yy+hh, xx+hh+6, yy);
+ fl_line(xx+12, yy+hh, xx+hh+12, yy);
+ } else if (H>W && hsl>(wsl+8)) {
+ // Draw vertical grippers
+ int yy;
+ xx = xsl+4;
+ ww = wsl-8;
+ yy = ysl+(hsl-wsl-4)/2;
+
+ fl_color(fl_darker(selection_color()));
+ fl_line(xx, yy+ww, xx+ww, yy);
+ fl_line(xx, yy+ww+6, xx+ww, yy+6);
+ fl_line(xx, yy+ww+12, xx+ww, yy+12);
+
+ yy++;
+ fl_color(fl_lighter(selection_color()));
+ fl_line(xx, yy+ww, xx+ww, yy);
+ fl_line(xx, yy+ww+6, xx+ww, yy+6);
+ fl_line(xx, yy+ww+12, xx+ww, yy+12);
+ }
+ }
}
draw_label(xsl, ysl, wsl, hsl);
diff --git a/src/Fl_get_system_colors.cxx b/src/Fl_get_system_colors.cxx
index 0b630703c..bce9e2cbe 100644
--- a/src/Fl_get_system_colors.cxx
+++ b/src/Fl_get_system_colors.cxx
@@ -3,7 +3,7 @@
//
// System color support 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
@@ -322,6 +322,24 @@ int Fl::reload_scheme() {
set_boxtype(FL_THIN_DOWN_BOX, FL_PLASTIC_THIN_DOWN_BOX);
set_boxtype(_FL_ROUND_UP_BOX, FL_PLASTIC_ROUND_UP_BOX);
set_boxtype(_FL_ROUND_DOWN_BOX, FL_PLASTIC_ROUND_DOWN_BOX);
+ } else if (scheme_ && !strcasecmp(scheme_, "gtk+")) {
+ // Use a GTK+ inspired look-n-feel...
+ if (scheme_bg_) {
+ delete scheme_bg_;
+ scheme_bg_ = (Fl_Image *)0;
+ }
+
+ 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_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_ROUND_UP_BOX, FL_GTK_ROUND_UP_BOX);
+ set_boxtype(_FL_ROUND_DOWN_BOX, FL_GTK_ROUND_DOWN_BOX);
} else {
// Use the standard FLTK look-n-feel...
if (scheme_bg_) {
diff --git a/src/Makefile b/src/Makefile
index 0df493d80..4397eb5f5 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -3,7 +3,7 @@
#
# Library makefile 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
@@ -133,6 +133,7 @@ CPPFILES = \
fl_engraved_label.cxx \
fl_file_dir.cxx \
fl_font.cxx \
+ fl_gtk.cxx \
fl_labeltype.cxx \
fl_line_style.cxx \
fl_oval_box.cxx \
diff --git a/src/fl_boxtype.cxx b/src/fl_boxtype.cxx
index cb6aa0a7a..5e8f5e45c 100644
--- a/src/fl_boxtype.cxx
+++ b/src/fl_boxtype.cxx
@@ -3,7 +3,7 @@
//
// Box drawing code 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
@@ -237,6 +237,14 @@ static struct {
{fl_down_frame, 2,2,4,4,0}, // _FL_PLASTIC_DOWN_FRAME,
{fl_up_box, 2,2,4,4,0}, // _FL_PLASTIC_THIN_UP_BOX,
{fl_down_box, 2,2,4,4,0}, // _FL_PLASTIC_THIN_DOWN_BOX,
+ {fl_up_box, 2,2,4,4,0}, // _FL_PLASTIC_ROUND_UP_BOX,
+ {fl_down_box, 2,2,4,4,0}, // _FL_PLASTIC_ROUND_DOWN_BOX,
+ {fl_up_box, 2,2,4,4,0}, // _FL_GTK_UP_BOX,
+ {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_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
{fl_down_box, 3,3,6,6,0}, // FL_FREE_BOX+1
{fl_up_box, 3,3,6,6,0}, // FL_FREE_BOX+2
diff --git a/src/fl_gtk.cxx b/src/fl_gtk.cxx
new file mode 100644
index 000000000..cae03585f
--- /dev/null
+++ b/src/fl_gtk.cxx
@@ -0,0 +1,134 @@
+//
+// "$Id$"
+//
+// "GTK" drawing routines for the Fast Light Tool Kit (FLTK).
+//
+// These box types provide a GTK+ look, based on Red Hat's Bluecurve
+// theme...
+//
+// Copyright 2006 by Michael Sweet.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+// Box drawing code for an obscure box type.
+// These box types are in seperate files so they are not linked
+// in if not used.
+
+#include <FL/Fl.H>
+#include <FL/fl_draw.H>
+
+extern void fl_internal_boxtype(Fl_Boxtype, Fl_Box_Draw_F*);
+
+
+static void gtk_up_frame(int x, int y, int w, int h, Fl_Color c) {
+ fl_color(fl_color_average(FL_WHITE, c, 0.5));
+ fl_xyline(x + 2, y + 1, x + w - 3);
+ fl_yxline(x + 1, y + 2, y + h - 4);
+
+ fl_color(fl_color_average(FL_BLACK, c, 0.5));
+ fl_begin_loop();
+ fl_vertex(x, y + 2);
+ fl_vertex(x + 2, y);
+ fl_vertex(x + w - 3, y);
+ fl_vertex(x + w - 1, y + 2);
+ fl_vertex(x + w - 1, y + h - 3);
+ fl_vertex(x + w - 3, y + h - 1);
+ fl_vertex(x + 2, y + h - 1);
+ fl_vertex(x, y + h - 3);
+ fl_end_loop();
+}
+
+
+static void gtk_up_box(int x, int y, int w, int h, Fl_Color c) {
+ gtk_up_frame(x, y, w, h, c);
+
+ fl_color(fl_color_average(FL_WHITE, c, 0.4));
+ fl_xyline(x + 2, y + 2, x + w - 3);
+ fl_color(fl_color_average(FL_WHITE, c, 0.2));
+ fl_xyline(x + 2, y + 3, x + w - 3);
+ fl_color(fl_color_average(FL_WHITE, c, 0.1));
+ fl_xyline(x + 2, y + 4, x + w - 3);
+ fl_color(c);
+ fl_rectf(x + 2, y + 5, w - 4, h - 7);
+ fl_color(fl_color_average(FL_BLACK, c, 0.025));
+ fl_xyline(x + 2, y + h - 4, x + w - 3);
+ fl_color(fl_color_average(FL_BLACK, c, 0.05));
+ fl_xyline(x + 2, y + h - 3, x + w - 3);
+ fl_color(fl_color_average(FL_BLACK, c, 0.1));
+ fl_xyline(x + 2, y + h - 2, x + w - 3);
+ fl_yxline(x + w - 2, y + 2, y + h - 3);
+}
+
+
+void gtk_down_frame(int x, int y, int w, int h, Fl_Color c) {
+ fl_color(fl_color_average(FL_BLACK, c, 0.5));
+ fl_begin_loop();
+ fl_vertex(x, y + 2);
+ fl_vertex(x + 2, y);
+ fl_vertex(x + w - 3, y);
+ fl_vertex(x + w - 1, y + 2);
+ fl_vertex(x + w - 1, y + h - 3);
+ fl_vertex(x + w - 3, y + h - 1);
+ fl_vertex(x + 2, y + h - 1);
+ fl_vertex(x, y + h - 3);
+ fl_end_loop();
+
+ fl_color(fl_color_average(FL_BLACK, c, 0.1));
+ fl_xyline(x + 2, y + 1, x + w - 3);
+ fl_yxline(x + 1, y + 2, y + h - 3);
+
+ fl_color(fl_color_average(FL_BLACK, c, 0.05));
+ fl_yxline(x + 2, y + h - 2, y + 2, x + w - 2);
+}
+
+
+void gtk_down_box(int x, int y, int w, int h, Fl_Color c) {
+ gtk_down_frame(x, y, w, h, c);
+
+ fl_color(c);
+ fl_rectf(x + 3, y + 3, w - 5, h - 4);
+ fl_yxline(x + w - 2, y + 3, y + h - 3);
+}
+
+
+void gtk_round_box(int x, int y, int w, int h, Fl_Color c) {
+ fl_color(c);
+ fl_pie(x, y, w, h, 0.0, 360.0);
+ fl_color(fl_color_average(FL_BLACK, c, 0.5));
+ fl_arc(x, y, w, h, 0.0, 360.0);
+}
+
+
+Fl_Boxtype fl_define_FL_GTK_UP_BOX() {
+ fl_internal_boxtype(_FL_GTK_UP_BOX, 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);
+
+ return _FL_GTK_UP_BOX;
+}
+
+
+//
+// End of "$Id$".
+//