summaryrefslogtreecommitdiff
path: root/src/Fl_Slider.cxx
diff options
context:
space:
mode:
authorBill Spitzak <spitzak@gmail.com>1999-05-14 09:07:09 +0000
committerBill Spitzak <spitzak@gmail.com>1999-05-14 09:07:09 +0000
commitce68c7386cf90ef28e7cc88a2a2449620f5703a4 (patch)
tree9e403c349001e07382365affc7aaaecdeca888ce /src/Fl_Slider.cxx
parent4e66f937698fd0792c17db2085d99ee5985c81ff (diff)
Colors in cmap changed to use 0xFF instead of 0xF4.
Drawing of scrollbars altered somewhat so that the box (if any) goes around the buttons, this seems to match the design that other toolkits use. Hope everybody likes this... This required internal changes to the Fl_Slider and Fl_Value_Slider as well but they should draw exactly the same. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@587 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Slider.cxx')
-rw-r--r--src/Fl_Slider.cxx60
1 files changed, 34 insertions, 26 deletions
diff --git a/src/Fl_Slider.cxx b/src/Fl_Slider.cxx
index cc28e32b7..eb779565d 100644
--- a/src/Fl_Slider.cxx
+++ b/src/Fl_Slider.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Slider.cxx,v 1.8 1999/03/03 07:21:28 bill Exp $"
+// "$Id: Fl_Slider.cxx,v 1.8.2.1 1999/05/14 09:07:08 bill Exp $"
//
// Slider widget for the Fast Light Tool Kit (FLTK).
//
@@ -83,13 +83,15 @@ int Fl_Slider::scrollvalue(int p, int w, int t, int l) {
// actually it ranges from 0 to 1/(1-size).
void Fl_Slider::draw_bg(int x, int y, int w, int h) {
- draw_box(box(), x, y, w, h, color());
- int BW = Fl::box_dx(box());
+ if (!(damage()&FL_DAMAGE_ALL)) { // not a complete redraw
+ fl_color(color());
+ fl_rectf(x, y, w, h);
+ }
Fl_Color black = active_r() ? FL_BLACK : FL_INACTIVE_COLOR;
if (type() == FL_VERT_NICE_SLIDER) {
- draw_box(FL_THIN_DOWN_BOX, x+w/2-2, y+BW, 4, h-2*BW, black);
+ draw_box(FL_THIN_DOWN_BOX, x+w/2-2, y, 4, h, black);
} else if (type() == FL_HOR_NICE_SLIDER) {
- draw_box(FL_THIN_DOWN_BOX, x+BW, y+h/2-2, w-2*BW, 4, black);
+ draw_box(FL_THIN_DOWN_BOX, x, y+h/2-2, w, 4, black);
}
}
@@ -104,45 +106,44 @@ void Fl_Slider::draw(int x, int y, int w, int h) {
else if (val < 0.0) val = 0.0;
}
- int BW = Fl::box_dx(box());
- int W = (horizontal() ? w : h) - 2*BW;
+ int W = (horizontal() ? w : h);
int X, S;
if (type()==FL_HOR_FILL_SLIDER || type() == FL_VERT_FILL_SLIDER) {
S = int(val*W+.5);
- if (minimum()>maximum()) {S = W-S; X = W-S+BW;}
- else X = BW;
+ if (minimum()>maximum()) {S = W-S; X = W-S;}
+ else X = 0;
} else {
S = int(slider_size_*W+.5);
- int T = (horizontal() ? h : w)/2-BW+1;
+ int T = (horizontal() ? h : w)/2+1;
if (type()==FL_VERT_NICE_SLIDER || type()==FL_HOR_NICE_SLIDER) T += 4;
if (S < T) S = T;
- X = BW+int(val*(W-S)+.5);
+ X = int(val*(W-S)+.5);
}
int xsl, ysl, wsl, hsl;
if (horizontal()) {
xsl = x+X;
wsl = S;
- ysl = y+BW;
- hsl = h-2*BW;
+ ysl = y;
+ hsl = h;
} else {
ysl = y+X;
hsl = S;
- xsl = x+BW;
- wsl = w-2*BW;
+ xsl = x;
+ wsl = w;
}
if (damage()&FL_DAMAGE_ALL) { // complete redraw
draw_bg(x, y, w, h);
} else { // partial redraw, clip off new position of slider
- if (X > BW) {
+ if (X > 0) {
if (horizontal()) fl_clip(x, ysl, X, hsl);
else fl_clip(xsl, y, wsl, X);
draw_bg(x, y, w, h);
fl_pop_clip();
}
- if (X+S < W+BW) {
- if (horizontal()) fl_clip(xsl+wsl, ysl, x+w-BW-xsl-wsl, hsl);
- else fl_clip(xsl, ysl+hsl, wsl, y+h-BW-ysl-hsl);
+ if (X+S < W) {
+ if (horizontal()) fl_clip(xsl+wsl, ysl, x+w-xsl-wsl, hsl);
+ else fl_clip(xsl, ysl+hsl, wsl, y+h-ysl-hsl);
draw_bg(x, y, w, h);
fl_pop_clip();
}
@@ -166,7 +167,11 @@ void Fl_Slider::draw(int x, int y, int w, int h) {
}
void Fl_Slider::draw() {
- draw(x(), y(), w(), h());
+ if (damage()&FL_DAMAGE_ALL) draw_box();
+ draw(x()+Fl::box_dx(box()),
+ y()+Fl::box_dy(box()),
+ w()-Fl::box_dw(box()),
+ h()-Fl::box_dh(box()));
}
int Fl_Slider::handle(int event, int x, int y, int w, int h) {
@@ -176,11 +181,10 @@ int Fl_Slider::handle(int event, int x, int y, int w, int h) {
handle_push();
case FL_DRAG: {
if (slider_size() >= 1 || minimum()==maximum()) return 1;
- int BW = Fl::box_dx(box());
- int W = (horizontal() ? w : h) - 2*BW;
- int X = (horizontal() ? Fl::event_x()-x : Fl::event_y()-y) - BW;
+ int W = (horizontal() ? w : h);
+ int X = (horizontal() ? Fl::event_x()-x : Fl::event_y()-y);
int S = int(slider_size_*W+.5);
- int T = (horizontal() ? h : w)/2-BW+1;
+ int T = (horizontal() ? h : w)/2+1;
if (type()==FL_VERT_NICE_SLIDER || type()==FL_HOR_NICE_SLIDER) T += 4;
if (type()!=FL_HOR_FILL_SLIDER && type()!=FL_VERT_FILL_SLIDER) {
if (S < T) S = T;
@@ -226,9 +230,13 @@ int Fl_Slider::handle(int event, int x, int y, int w, int h) {
}
int Fl_Slider::handle(int event) {
- return handle(event, x(), y(), w(), h());
+ return handle(event,
+ x()+Fl::box_dx(box()),
+ y()+Fl::box_dy(box()),
+ w()-Fl::box_dw(box()),
+ h()-Fl::box_dh(box()));
}
//
-// End of "$Id: Fl_Slider.cxx,v 1.8 1999/03/03 07:21:28 bill Exp $".
+// End of "$Id: Fl_Slider.cxx,v 1.8.2.1 1999/05/14 09:07:08 bill Exp $".
//