Patch from Mike Lindner to make the turning on/off of scrollbars on
Fl_Scroll smarter. It appears to work with my own tests. He did not handle FL_ALIGN_TOP correctly, fixed that. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1285 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
797d78d86c
commit
fb06bd8019
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Scroll.cxx,v 1.7.2.3 2000/06/05 21:20:56 mike Exp $"
|
||||
// "$Id: Fl_Scroll.cxx,v 1.7.2.4 2000/08/12 08:42:12 spitzak Exp $"
|
||||
//
|
||||
// Scroll widget for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -116,40 +116,58 @@ void Fl_Scroll::draw() {
|
||||
}
|
||||
|
||||
// turn the scrollbars on and off as necessary:
|
||||
for (int z = 0; z<2; z++) {
|
||||
if ((type()&VERTICAL) && (type()&ALWAYS_ON || t < Y || b > Y+H)) {
|
||||
if (!scrollbar.visible()) {
|
||||
scrollbar.set_visible();
|
||||
W -= scrollbar.w();
|
||||
d = FL_DAMAGE_ALL;
|
||||
}
|
||||
} else {
|
||||
if (scrollbar.visible()) {
|
||||
scrollbar.clear_visible();
|
||||
draw_clip(this,
|
||||
scrollbar.align()&FL_ALIGN_LEFT ? X-scrollbar.w() : X+W,
|
||||
Y, scrollbar.w(), H);
|
||||
W += scrollbar.w();
|
||||
d = FL_DAMAGE_ALL;
|
||||
}
|
||||
}
|
||||
if ((type()&HORIZONTAL) && (type()&ALWAYS_ON || l < X || r > X+W)) {
|
||||
if (!hscrollbar.visible()) {
|
||||
hscrollbar.set_visible();
|
||||
H -= hscrollbar.h();
|
||||
d = FL_DAMAGE_ALL;
|
||||
}
|
||||
} else {
|
||||
if (hscrollbar.visible()) {
|
||||
hscrollbar.clear_visible();
|
||||
draw_clip(this, X,
|
||||
scrollbar.align()&FL_ALIGN_TOP ? Y-hscrollbar.h() : Y+H,
|
||||
W, hscrollbar.h());
|
||||
H += hscrollbar.h();
|
||||
d = FL_DAMAGE_ALL;
|
||||
// See if children would fit if we had no scrollbars...
|
||||
X = x()+Fl::box_dx(box());
|
||||
Y = y()+Fl::box_dy(box());
|
||||
W = w()-Fl::box_dw(box());
|
||||
H = h()-Fl::box_dh(box());
|
||||
int vneeded = 0;
|
||||
int hneeded = 0;
|
||||
if (type() & VERTICAL) {
|
||||
if ((type() & ALWAYS_ON) || t < Y || b > Y+H) {
|
||||
vneeded = 1;
|
||||
W -= scrollbar.w();
|
||||
if (scrollbar.align() & FL_ALIGN_LEFT) X += scrollbar.w();
|
||||
}
|
||||
}
|
||||
if (type() & HORIZONTAL) {
|
||||
if ((type() & ALWAYS_ON) || l < X || r > X+W) {
|
||||
hneeded = 1;
|
||||
H -= hscrollbar.h();
|
||||
if (scrollbar.align() & FL_ALIGN_TOP) Y += hscrollbar.h();
|
||||
// recheck vertical since we added a horizontal scrollbar
|
||||
if (!vneeded && (type() & VERTICAL)) {
|
||||
if ((type() & ALWAYS_ON) || t < Y || b > Y+H) {
|
||||
vneeded = 1;
|
||||
W -= scrollbar.w();
|
||||
if (scrollbar.align() & FL_ALIGN_LEFT) X += scrollbar.w();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Now that we know what's needed, make it so.
|
||||
if (vneeded && !scrollbar.visible()) {
|
||||
scrollbar.set_visible();
|
||||
d = FL_DAMAGE_ALL;
|
||||
}
|
||||
else if (!vneeded && scrollbar.visible()) {
|
||||
scrollbar.clear_visible();
|
||||
draw_clip(this,
|
||||
scrollbar.align()&FL_ALIGN_LEFT ? X : X+W-scrollbar.w(),
|
||||
Y, scrollbar.w(), H);
|
||||
d = FL_DAMAGE_ALL;
|
||||
}
|
||||
if (hneeded && !hscrollbar.visible()) {
|
||||
hscrollbar.set_visible();
|
||||
d = FL_DAMAGE_ALL;
|
||||
}
|
||||
else if (!hneeded && hscrollbar.visible()) {
|
||||
hscrollbar.clear_visible();
|
||||
draw_clip(this,
|
||||
X, scrollbar.align()&FL_ALIGN_TOP ? Y : Y+H-hscrollbar.h(),
|
||||
W, hscrollbar.h());
|
||||
d = FL_DAMAGE_ALL;
|
||||
}
|
||||
|
||||
scrollbar.resize(scrollbar.align()&FL_ALIGN_LEFT ? X-scrollbar.w() : X+W,
|
||||
Y, scrollbar.w(), H);
|
||||
@ -231,5 +249,5 @@ int Fl_Scroll::handle(int event) {
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Scroll.cxx,v 1.7.2.3 2000/06/05 21:20:56 mike Exp $".
|
||||
// End of "$Id: Fl_Scroll.cxx,v 1.7.2.4 2000/08/12 08:42:12 spitzak Exp $".
|
||||
//
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Tabs.cxx,v 1.6.2.6 2000/06/05 21:20:57 mike Exp $"
|
||||
// "$Id: Fl_Tabs.cxx,v 1.6.2.7 2000/08/12 08:42:12 spitzak Exp $"
|
||||
//
|
||||
// Tab widget for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -34,7 +34,8 @@
|
||||
#include <FL/fl_draw.H>
|
||||
|
||||
#define BORDER 10
|
||||
#define TABSLOPE 8
|
||||
#define TABSLOPE 5
|
||||
#define EXTRASPACE 5
|
||||
|
||||
// return the left edges of each tab (plus a fake left edge for a tab
|
||||
// past the right-hand one). These position are actually of the left
|
||||
@ -52,8 +53,8 @@ int Fl_Tabs::tab_positions(int* p, int* w) {
|
||||
if (o->visible()) selected = i;
|
||||
if (o->label()) {
|
||||
int wt = 0; int ht = 0; o->measure_label(wt,ht);
|
||||
w[i] = wt+TABSLOPE;
|
||||
if (2*TABSLOPE > w[i]) w[i] = 2*TABSLOPE;
|
||||
w[i] = wt+TABSLOPE+EXTRASPACE;
|
||||
//if (2*TABSLOPE > w[i]) w[i] = 2*TABSLOPE;
|
||||
} else
|
||||
w[i] = 2*TABSLOPE;
|
||||
p[i+1] = p[i]+w[i];
|
||||
@ -257,9 +258,9 @@ void Fl_Tabs::draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int what) {
|
||||
fl_color(!sel && o==push_ ? FL_DARK3 : FL_LIGHT3);
|
||||
fl_line(x1, y()+h()+H, x1+TABSLOPE, y()+h()-1);
|
||||
}
|
||||
if (W > TABSLOPE)
|
||||
o->draw_label(what==LEFT ? x1+TABSLOPE : x2-W+TABSLOPE,
|
||||
y()+(H<0?h()+H-3:0), W-TABSLOPE,
|
||||
if (W > TABSLOPE+EXTRASPACE/2)
|
||||
o->draw_label((what==LEFT ? x1 : x2-W)+(TABSLOPE+EXTRASPACE/2),
|
||||
y()+(H<0?h()+H-2:0), W-(TABSLOPE+EXTRASPACE/2),
|
||||
(H<0?-H:H)+3, FL_ALIGN_CENTER);
|
||||
}
|
||||
|
||||
@ -271,5 +272,5 @@ Fl_Tabs::Fl_Tabs(int X,int Y,int W, int H, const char *l) :
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Tabs.cxx,v 1.6.2.6 2000/06/05 21:20:57 mike Exp $".
|
||||
// End of "$Id: Fl_Tabs.cxx,v 1.6.2.7 2000/08/12 08:42:12 spitzak Exp $".
|
||||
//
|
||||
|
||||
Loading…
Reference in New Issue
Block a user