diff options
Diffstat (limited to 'dw')
-rw-r--r-- | dw/fltkviewbase.cc | 2 | ||||
-rw-r--r-- | dw/fltkviewport.cc | 27 | ||||
-rw-r--r-- | dw/layout.cc | 7 | ||||
-rw-r--r-- | dw/view.hh | 6 |
4 files changed, 24 insertions, 18 deletions
diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc index d14f866c..10c3fa65 100644 --- a/dw/fltkviewbase.cc +++ b/dw/fltkviewbase.cc @@ -297,6 +297,8 @@ int FltkViewBase::handle (int event) void FltkViewBase::setLayout (core::Layout *layout) { theLayout = layout; + if (usesViewport()) + theLayout->viewportSizeChanged(this, w(), h()); } void FltkViewBase::setCanvasSize (int width, int ascent, int descent) diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc index c0574dff..135550e8 100644 --- a/dw/fltkviewport.cc +++ b/dw/fltkviewport.cc @@ -40,11 +40,13 @@ FltkViewport::FltkViewport (int X, int Y, int W, int H, const char *label): hscrollbar = new Fl_Scrollbar (x (), y (), 1, 1); hscrollbar->type(FL_HORIZONTAL); hscrollbar->callback (hscrollbarCallback, this); + hscrollbar->hide(); add (hscrollbar); vscrollbar = new Fl_Scrollbar (x (), y(), 1, 1); vscrollbar->type(FL_VERTICAL); vscrollbar->callback (vscrollbarCallback, this); + vscrollbar->hide(); add (vscrollbar); scrollX = scrollY = scrollDX = scrollDY = 0; @@ -70,6 +72,7 @@ void FltkViewport::adjustScrollbarsAndGadgetsAllocation () int hdiff = 0, vdiff = 0; int visibility = 0; + _MSG(" >>FltkViewport::adjustScrollbarsAndGadgetsAllocation\n"); if (hscrollbar->visible ()) visibility |= 1; if (vscrollbar->visible ()) @@ -384,18 +387,26 @@ void FltkViewport::setViewportSize (int width, int height, int hScrollbarThickness, int vScrollbarThickness) { - if (hScrollbarThickness > 0) - hscrollbar->show (); - else - hscrollbar->hide (); - if (vScrollbarThickness > 0) - vscrollbar->show (); - else - vscrollbar->hide (); + int adjustReq = + (hscrollbar->visible() ? !hScrollbarThickness : hScrollbarThickness) || + (vscrollbar->visible() ? !vScrollbarThickness : vScrollbarThickness); + + _MSG("FltkViewport::setViewportSize old_w,old_h=%dx%d -> w,h=%dx%d\n" + "\t hThick=%d hVis=%d, vThick=%d vVis=%d, adjustReq=%d\n", + w(),h(),width,height, + hScrollbarThickness,hscrollbar->visible(), + vScrollbarThickness,vscrollbar->visible(), adjustReq); + + (hScrollbarThickness > 0) ? hscrollbar->show () : hscrollbar->hide (); + (vScrollbarThickness > 0) ? vscrollbar->show () : vscrollbar->hide (); /* If no scrollbar, go to the beginning */ scroll(hScrollbarThickness ? 0 : -scrollX, vScrollbarThickness ? 0 : -scrollY); + + /* Adjust when scrollbar visibility changes */ + if (adjustReq) + adjustScrollbarsAndGadgetsAllocation (); } void FltkViewport::updateCanvasWidgets (int dx, int dy) diff --git a/dw/layout.cc b/dw/layout.cc index b430eaa1..a02c87b7 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -679,10 +679,9 @@ void Layout::resizeIdle () } // Set viewport sizes. - if (view->usesViewport ()) - view->setViewportSize (viewportWidth, viewportHeight, - actualHScrollbarThickness, - actualVScrollbarThickness); + view->setViewportSize (viewportWidth, viewportHeight, + actualHScrollbarThickness, + actualVScrollbarThickness); } } @@ -92,12 +92,6 @@ public: * This will normally imply a resize of the UI widget. Width and height are * the dimensions of the new size, \em including the scrollbar thicknesses. * - * \bug The rest of this comment needs to be updated. - * - * markerWidthDiff and markerHeightDiff are the respective dimensions of - * the viewport markers (see dw::core::getMarkerWidthDiff and - * dw::core::getMarkerHeightDiff), if they are 0, the respective - * marker should not be shown at all. */ virtual void setViewportSize (int width, int height, int hScrollbarThickness, |