aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
Diffstat (limited to 'dw')
-rw-r--r--dw/fltkflatview.cc5
-rw-r--r--dw/fltkflatview.hh1
-rw-r--r--dw/fltkpreview.cc5
-rw-r--r--dw/fltkpreview.hh1
-rw-r--r--dw/fltkviewport.cc65
-rw-r--r--dw/fltkviewport.hh3
-rw-r--r--dw/layout.cc2
-rw-r--r--dw/view.hh2
8 files changed, 73 insertions, 11 deletions
diff --git a/dw/fltkflatview.cc b/dw/fltkflatview.cc
index d40c59e5..b9223a4a 100644
--- a/dw/fltkflatview.cc
+++ b/dw/fltkflatview.cc
@@ -70,6 +70,11 @@ int FltkFlatView::getVScrollbarThickness ()
return 0;
}
+int FltkFlatView::getScrollbarOnLeft ()
+{
+ return 0;
+}
+
void FltkFlatView::scrollTo (int x, int y)
{
}
diff --git a/dw/fltkflatview.hh b/dw/fltkflatview.hh
index 8d84fda9..6016dac6 100644
--- a/dw/fltkflatview.hh
+++ b/dw/fltkflatview.hh
@@ -25,6 +25,7 @@ public:
bool usesViewport ();
int getHScrollbarThickness ();
int getVScrollbarThickness ();
+ int getScrollbarOnLeft ();
void scrollTo (int x, int y);
void setViewportSize (int width, int height,
int hScrollbarThickness, int vScrollbarThickness);
diff --git a/dw/fltkpreview.cc b/dw/fltkpreview.cc
index ecb96f22..8a2a3587 100644
--- a/dw/fltkpreview.cc
+++ b/dw/fltkpreview.cc
@@ -95,6 +95,11 @@ int FltkPreview::getVScrollbarThickness ()
return 0;
}
+int FltkPreview::getScrollbarOnLeft ()
+{
+ return 0;
+}
+
void FltkPreview::scrollTo (int x, int y)
{
scrollX = x;
diff --git a/dw/fltkpreview.hh b/dw/fltkpreview.hh
index 2382b861..a92063fe 100644
--- a/dw/fltkpreview.hh
+++ b/dw/fltkpreview.hh
@@ -33,6 +33,7 @@ public:
bool usesViewport ();
int getHScrollbarThickness ();
int getVScrollbarThickness ();
+ int getScrollbarOnLeft ();
void scrollTo (int x, int y);
void scroll (dw::core::ScrollCommand cmd);
void setViewportSize (int width, int height,
diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc
index 6d2c5ecd..28c4101c 100644
--- a/dw/fltkviewport.cc
+++ b/dw/fltkviewport.cc
@@ -116,10 +116,17 @@ void FltkViewport::adjustScrollbarsAndGadgetsAllocation ()
vdiff = hscrollbar->visible () ? SCROLLBAR_THICKNESS : 0;
}
- hscrollbar->resize(x (), y () + h () - SCROLLBAR_THICKNESS,
- w () - hdiff, SCROLLBAR_THICKNESS);
- vscrollbar->resize(x () + w () - SCROLLBAR_THICKNESS, y (),
- SCROLLBAR_THICKNESS, h () - vdiff);
+ if (scrollbarOnLeft) {
+ hscrollbar->resize(x () + hdiff, y () + h () - SCROLLBAR_THICKNESS,
+ w () - hdiff, SCROLLBAR_THICKNESS);
+ vscrollbar->resize(x (), y (),
+ SCROLLBAR_THICKNESS, h () - vdiff);
+ } else {
+ hscrollbar->resize(x (), y () + h () - SCROLLBAR_THICKNESS,
+ w () - hdiff, SCROLLBAR_THICKNESS);
+ vscrollbar->resize(x () + w () - SCROLLBAR_THICKNESS, y (),
+ SCROLLBAR_THICKNESS, h () - vdiff);
+ }
//int X = x () + w () - SCROLLBAR_THICKNESS;
//int Y = y () + h () - SCROLLBAR_THICKNESS;
@@ -141,6 +148,8 @@ void FltkViewport::adjustScrollbarsAndGadgetsAllocation ()
}
#endif
}
+
+ adjustScrollbarValues();
}
void FltkViewport::adjustScrollbarValues ()
@@ -222,17 +231,29 @@ void FltkViewport::draw ()
draw_child (*hscrollbar);
if (draw && vis_vs && vis_hs) {
fl_color(FL_BACKGROUND_COLOR);
- fl_rectf(x()+w()-vis_vs, y()+h()-vis_hs, vis_vs, vis_hs);
+ if (scrollbarOnLeft) {
+ fl_rectf(x(), y()+h()-vis_hs, vis_vs, vis_hs);
+ } else {
+ fl_rectf(x()+w()-vis_vs, y()+h()-vis_hs, vis_vs, vis_hs);
+ }
}
// main area
if (d == FL_DAMAGE_CHILD && (draw_vs || draw_hs)) {
_MSG("none\n");
} else if (d == (FL_DAMAGE_SCROLL | FL_DAMAGE_CHILD)) {
- fl_scroll(x(), y(), w() - vis_vs, h() - vis_hs,
+ int x = this->x();
+
+ if (scrollbarOnLeft)
+ x += vis_vs;
+ fl_scroll(x, y(), w() - vis_vs, h() - vis_hs,
-scrollDX, -scrollDY, draw_area, this);
_MSG("fl_scroll()\n");
} else {
- draw_area(this, x(), y(), w() - vis_vs, h() - vis_hs);
+ int x = this->x();
+
+ if (scrollbarOnLeft)
+ x += vis_vs;
+ draw_area(this, x, y(), w() - vis_vs, h() - vis_hs);
_MSG("draw_area()\n");
}
@@ -331,12 +352,27 @@ int FltkViewport::handle (int event)
break;
case FL_ENTER:
+ if (vscrollbar->visible() && Fl::event_inside(vscrollbar))
+ return vscrollbar->handle(event);
+ if (hscrollbar->visible() && Fl::event_inside(hscrollbar))
+ return hscrollbar->handle(event);
/* could be the result of, e.g., closing another window. */
mouse_x = Fl::event_x();
mouse_y = Fl::event_y();
positionChanged();
break;
+ case FL_MOVE:
+ /* Use LEAVE in order not to be over a link, etc., anymore. */
+ if (vscrollbar->visible() && Fl::event_inside(vscrollbar)) {
+ (void)FltkWidgetView::handle(FL_LEAVE);
+ return vscrollbar->handle(event);
+ }
+ if (hscrollbar->visible() && Fl::event_inside(hscrollbar)) {
+ (void)FltkWidgetView::handle(FL_LEAVE);
+ return hscrollbar->handle(event);
+ }
+ break;
case FL_LEAVE:
mouse_x = mouse_y = -1;
break;
@@ -438,13 +474,13 @@ void FltkViewport::scroll (core::ScrollCommand cmd)
} else if (cmd == core::SCREEN_RIGHT_CMD) {
scroll (w() - hscrollbar->linesize (), 0);
} else if (cmd == core::LINE_UP_CMD) {
- scroll (0, (int) -vscrollbar->linesize ());
+ scroll (0, -vscrollbar->linesize ());
} else if (cmd == core::LINE_DOWN_CMD) {
- scroll (0, (int) vscrollbar->linesize ());
+ scroll (0, vscrollbar->linesize ());
} else if (cmd == core::LEFT_CMD) {
- scroll ((int) -hscrollbar->linesize (), 0);
+ scroll (-hscrollbar->linesize (), 0);
} else if (cmd == core::RIGHT_CMD) {
- scroll ((int) hscrollbar->linesize (), 0);
+ scroll (hscrollbar->linesize (), 0);
} else if (cmd == core::TOP_CMD) {
scrollTo (scrollX, 0);
} else if (cmd == core::BOTTOM_CMD) {
@@ -478,6 +514,13 @@ void FltkViewport::selectionScroll (void *data)
Fl::repeat_timeout(0.025, selectionScroll, data);
}
+void FltkViewport::setScrollbarOnLeft (bool enable)
+{
+ scrollbarOnLeft = enable ? 1 : 0;
+ adjustScrollbarsAndGadgetsAllocation();
+ damage(FL_DAMAGE_ALL);
+}
+
void FltkViewport::setViewportSize (int width, int height,
int hScrollbarThickness,
int vScrollbarThickness)
diff --git a/dw/fltkviewport.hh b/dw/fltkviewport.hh
index 1569a7d8..fdcbb3be 100644
--- a/dw/fltkviewport.hh
+++ b/dw/fltkviewport.hh
@@ -21,6 +21,7 @@ private:
int scrollX, scrollY;
int scrollDX, scrollDY;
+ int scrollbarOnLeft;
int hasDragScroll, dragScrolling, dragX, dragY;
int horScrolling, verScrolling;
@@ -64,6 +65,7 @@ public:
bool usesViewport ();
int getHScrollbarThickness ();
int getVScrollbarThickness ();
+ int getScrollbarOnLeft () {return scrollbarOnLeft; };
void scroll(int dx, int dy);
void scroll(dw::core::ScrollCommand cmd);
void scrollTo (int x, int y);
@@ -75,6 +77,7 @@ public:
GadgetOrientation gadgetOrientation);
void setDragScroll (bool enable) { hasDragScroll = enable ? 1 : 0; }
void addGadget (Fl_Widget *gadget);
+ void setScrollbarOnLeft (bool enable);
};
} // namespace fltk
diff --git a/dw/layout.cc b/dw/layout.cc
index ee54e892..4a5be74e 100644
--- a/dw/layout.cc
+++ b/dw/layout.cc
@@ -943,6 +943,8 @@ void Layout::resizeIdle ()
assert (topLevel->needsAllocate ());
allocation.x = allocation.y = 0;
+ if (usesViewport && view->getScrollbarOnLeft())
+ allocation.x += currVScrollbarThickness();
allocation.width = requisition.width;
allocation.ascent = requisition.ascent;
allocation.descent = requisition.descent;
diff --git a/dw/view.hh b/dw/view.hh
index 234cc9fb..995c2d9c 100644
--- a/dw/view.hh
+++ b/dw/view.hh
@@ -72,6 +72,8 @@ public:
*/
virtual int getVScrollbarThickness () = 0;
+ virtual int getScrollbarOnLeft () = 0;
+
/**
* \brief Scroll the vieport to the given position.
*