summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl.H1
-rw-r--r--FL/Fl_Browser_.H60
-rw-r--r--src/Fl.cxx28
-rw-r--r--src/Fl_Browser_.cxx60
4 files changed, 98 insertions, 51 deletions
diff --git a/FL/Fl.H b/FL/Fl.H
index e0cd2bf88..dc09c22f8 100644
--- a/FL/Fl.H
+++ b/FL/Fl.H
@@ -124,6 +124,7 @@ public: // should be private!
static Fl_Image* scheme_bg_;
static int e_original_keysym; // late addition
+ static int scrollbar_size_;
#endif
diff --git a/FL/Fl_Browser_.H b/FL/Fl_Browser_.H
index ee977880b..26db76358 100644
--- a/FL/Fl_Browser_.H
+++ b/FL/Fl_Browser_.H
@@ -37,6 +37,7 @@
#include "Fl_Group.H"
#endif
#include "Fl_Scrollbar.H"
+#include <FL/Fl.H> // Fl::scrollbar_size()
#define FL_NORMAL_BROWSER 0 /**< type() of Fl_Browser */
#define FL_SELECT_BROWSER 1 /**< type() of FL_Select_Browser */
@@ -78,8 +79,7 @@ class FL_EXPORT Fl_Browser_ : public Fl_Group {
void* selection_; // which is selected (except for FL_MULTI_BROWSER)
void *redraw1,*redraw2; // minimal update pointers
void* max_width_item; // which item has max_width_
-
- static int scrollbar_width_;
+ int scrollbar_size_; // size of scrollbar trough
void update_top();
@@ -304,14 +304,60 @@ public:
void textcolor(unsigned col) { textcolor_ = col; }
/**
- Gets the current width of scrollbars in pixels.
+ Gets the current size of the scrollbars' troughs, in pixels.
+
+ If this value is zero (default), this widget will use the
+ Fl::scrollbar_size() value as the scrollbar's width.
+
+ \returns Scrollbar size in pixels, or 0 if the global Fl::scrollsize() is being used.
+ \see Fl::scrollbar_size(int)
*/
- static int scrollbar_width() { return scrollbar_width_; }
+ int scrollbar_size() const {
+ return(scrollbar_size_);
+ }
/**
- Sets the width of scrollbars to pixel size \p width.
- */
- static void scrollbar_width(int width) { scrollbar_width_ = width; }
+ Sets the pixel size of the scrollbars' troughs to the \p size, in pixels.
+
+ Normally you should not need this method, and should use
+ Fl::scrollbar_size(int) instead to manage the size of ALL
+ your widgets' scrollbars. This ensures your application
+ has a consistent UI, is the default behavior, and is normally
+ what you want.
+ Only use THIS method if you really need to override the global
+ scrollbar size. The need for this should be rare.
+
+ Setting \p size to the special value of 0 causes the widget to
+ track the global Fl::scrollbar_size(), which is the default.
+
+ \param[in] size Sets the scrollbar size in pixels.\n
+ If 0 (default), scrollbar size tracks the global Fl::scrollbar_size()
+ \see Fl::scrollbar_size()
+ */
+ void scrollbar_size(int size) {
+ scrollbar_size_ = size;
+ }
+ /**
+ This method has been deprecated, existing for backwards compatibility only.
+ Use scrollbar_size() instead.
+ This method always returns the global value Fl::scrollbar_size().
+ \returns Always returns the global value Fl::scrollbar_size().
+ \todo This method should eventually be removed in 1.4+
+ */
+ int scrollbar_width() const {
+ return(Fl::scrollbar_size());
+ }
+ /**
+ This method has been deprecated, existing for backwards compatibility only.
+ Use scrollbar_size(int) instead.
+ This method sets the global Fl::scrollbar_size(), and forces this
+ instance of the widget to use it.
+ \todo This method should eventually be removed in 1.4+
+ */
+ void scrollbar_width(int width) {
+ Fl::scrollbar_size(width);
+ scrollbar_size_ = 0;
+ }
/**
Moves the vertical scrollbar to the righthand side of the list.
For back compatibility.
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 232d4bb6b..1c4705075 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -73,7 +73,9 @@ int Fl::damage_,
Fl::e_clicks,
Fl::e_is_click,
Fl::e_keysym,
- Fl::e_original_keysym;
+ Fl::e_original_keysym,
+ Fl::scrollbar_size_ = 16;
+
char *Fl::e_text = (char *)"";
int Fl::e_length;
int Fl::visible_focus_ = 1,
@@ -99,6 +101,30 @@ Fl::version() {
return FL_VERSION;
}
+/**
+ Gets the default scrollbar size used by
+ Fl_Browser_,
+ Fl_Help_View,
+ Fl_Scroll, and
+ Fl_Text_Display widgets.
+ \returns The default size for widget scrollbars, in pixels.
+*/
+int Fl::scrollbar_size() {
+ return scrollbar_size_;
+}
+
+/**
+ Sets the default scrollbar size that is used by the
+ Fl_Browser_,
+ Fl_Help_View,
+ Fl_Scroll, and
+ Fl_Text_Display widgets.
+ \param[in] W The new default size for widget scrollbars, in pixels.
+*/
+void Fl::scrollbar_size(int W) {
+ scrollbar_size_ = W;
+}
+
/**
Returns whether or not the mouse event is inside the given rectangle.
diff --git a/src/Fl_Browser_.cxx b/src/Fl_Browser_.cxx
index 91c8b4e1c..ed5641b41 100644
--- a/src/Fl_Browser_.cxx
+++ b/src/Fl_Browser_.cxx
@@ -67,36 +67,6 @@ static void hscrollbar_callback(Fl_Widget* s, void*) {
((Fl_Browser_*)(s->parent()))->hposition(int(((Fl_Scrollbar*)s)->value()));
}
-// Scrollbar size should be part of the Fl class, but is left here for
-// binary compatibility in 1.1.x - M. Sweet
-int Fl_Browser_::scrollbar_width_ = 16;
-
-/**
- Gets the default scrollbar size used by
- Fl_Browser_,
- Fl_Help_View,
- Fl_Scroll, and
- Fl_Text_Display widgets.
- \returns The default size for widget scrollbars, in pixels.
- \todo The source code for this method needs to be moved from Fl_Browser_.cxx to Fl.cxx
-*/
-int Fl::scrollbar_size() {
- return Fl_Browser_::scrollbar_width();
-}
-
-/**
- Sets the default scrollbar size that is used by the
- Fl_Browser_,
- Fl_Help_View,
- Fl_Scroll, and
- Fl_Text_Display widgets.
- \param[in] W The new default size for widget scrollbars, in pixels.
- \todo The source code for this method needs to be moved from Fl_Browser_.cxx to Fl.cxx
-*/
-void Fl::scrollbar_size(int W) {
- Fl_Browser_::scrollbar_width(W);
-}
-
// return where to draw the actual box:
/**
Returns the bounding box for the interior of the list's display window, inside
@@ -105,19 +75,20 @@ void Fl::scrollbar_size(int W) {
(The original contents of these parameters are overwritten)
*/
void Fl_Browser_::bbox(int& X, int& Y, int& W, int& H) const {
+ int scrollsize = scrollbar_size_ ? scrollbar_size_ : Fl::scrollbar_size();
Fl_Boxtype b = box() ? box() : FL_DOWN_BOX;
X = x()+Fl::box_dx(b);
Y = y()+Fl::box_dy(b);
W = w()-Fl::box_dw(b);
H = h()-Fl::box_dh(b);
if (scrollbar.visible()) {
- W -= scrollbar_width_;
- if (scrollbar.align() & FL_ALIGN_LEFT) X += scrollbar_width_;
+ W -= scrollsize;
+ if (scrollbar.align() & FL_ALIGN_LEFT) X += scrollsize;
}
if (W < 0) W = 0;
if (hscrollbar.visible()) {
- H -= scrollbar_width_;
- if (scrollbar.align() & FL_ALIGN_TOP) Y += scrollbar_width_;
+ H -= scrollsize;
+ if (scrollbar.align() & FL_ALIGN_TOP) Y += scrollsize;
}
if (H < 0) H = 0;
}
@@ -141,15 +112,16 @@ int Fl_Browser_::leftedge() const {
\param[in] X,Y,W,H The new position and size for the browser, in pixels.
*/
void Fl_Browser_::resize(int X, int Y, int W, int H) {
+ int scrollsize = scrollbar_size_ ? scrollbar_size_ : Fl::scrollbar_size();
Fl_Widget::resize(X, Y, W, H);
// move the scrollbars so they can respond to events:
bbox(X,Y,W,H);
scrollbar.resize(
- scrollbar.align()&FL_ALIGN_LEFT ? X-scrollbar_width_ : X+W,
- Y, scrollbar_width_, H);
+ scrollbar.align()&FL_ALIGN_LEFT ? X-scrollsize : X+W,
+ Y, scrollsize, H);
hscrollbar.resize(
- X, scrollbar.align()&FL_ALIGN_TOP ? Y-scrollbar_width_ : Y+H,
- W, scrollbar_width_);
+ X, scrollbar.align()&FL_ALIGN_TOP ? Y-scrollsize : Y+H,
+ W, scrollsize);
}
// Cause minimal update to redraw the given item:
@@ -483,11 +455,12 @@ J1:
}
// update the scrollbars and redraw them:
+ int scrollsize = scrollbar_size_ ? scrollbar_size_ : Fl::scrollbar_size();
int dy = top_ ? item_quick_height(top_) : 0; if (dy < 10) dy = 10;
if (scrollbar.visible()) {
scrollbar.damage_resize(
- scrollbar.align()&FL_ALIGN_LEFT ? X-scrollbar_width_ : X+W,
- Y, scrollbar_width_, H);
+ scrollbar.align()&FL_ALIGN_LEFT ? X-scrollsize : X+W,
+ Y, scrollsize, H);
scrollbar.value(position_, H, 0, full_height_);
scrollbar.linesize(dy);
if (drawsquare) draw_child(scrollbar);
@@ -495,8 +468,8 @@ J1:
}
if (hscrollbar.visible()) {
hscrollbar.damage_resize(
- X, scrollbar.align()&FL_ALIGN_TOP ? Y-scrollbar_width_ : Y+H,
- W, scrollbar_width_);
+ X, scrollbar.align()&FL_ALIGN_TOP ? Y-scrollsize : Y+H,
+ W, scrollsize);
hscrollbar.value(hposition_, W, 0, full_width_);
hscrollbar.linesize(dy);
if (drawsquare) draw_child(hscrollbar);
@@ -506,7 +479,7 @@ J1:
// draw that little square between the scrollbars:
if (drawsquare && scrollbar.visible() && hscrollbar.visible()) {
fl_color(parent()->color());
- fl_rectf(scrollbar.x(), hscrollbar.y(), scrollbar_width_,scrollbar_width_);
+ fl_rectf(scrollbar.x(), hscrollbar.y(), scrollsize, scrollsize);
}
real_hposition_ = hposition_;
@@ -964,6 +937,7 @@ Fl_Browser_::Fl_Browser_(int X, int Y, int W, int H, const char* L)
has_scrollbar_ = BOTH;
max_width = 0;
max_width_item = 0;
+ scrollbar_size_ = 0;
redraw1 = redraw2 = 0;
end();
}