25 #include <FL/fl_draw.H> 29 #include "../lout/msg.h" 30 #include "../lout/debug.hh" 47 if (e == FL_SHORTCUT && Fl::event_state() == FL_SHIFT &&
48 (Fl::event_key() == FL_Left || Fl::event_key() == FL_Right))
50 return Fl_Scrollbar::handle(e);
54 FltkViewport::FltkViewport (
int X,
int Y,
int W,
int H,
const char *label):
65 vscrollbar =
new Fl_Scrollbar (x (), y(), 1, 1);
93 int hdiff = 0, vdiff = 0;
96 _MSG(
" >>FltkViewport::adjustScrollbarsAndGadgetsAllocation\n");
128 Fl_Widget *widget = it.getNext()->getTypedValue ();
173 bool dimension_changed = W != w() ||
H != h();
175 Fl_Group::resize(X, Y, W,
H);
176 if (dimension_changed) {
185 fl_push_clip(x, y, w, h);
187 vp->FltkWidgetView::draw ();
191 Fl_Widget *widget = it.getNext()->getTypedValue ();
192 vp->draw_child (*widget);
205 if (d & FL_DAMAGE_SCROLL) {
206 clear_damage (FL_DAMAGE_SCROLL);
207 fl_scroll(x(), y(), w() - hdiff, h() - vdiff,
209 clear_damage (d & ~FL_DAMAGE_SCROLL);
213 draw_area(
this, x(), y(), w () - hdiff, h () - vdiff);
215 if (d == FL_DAMAGE_ALL ||
hscrollbar->damage ())
217 if (d == FL_DAMAGE_ALL ||
vscrollbar->damage ())
220 if (d == FL_DAMAGE_ALL && hdiff && vdiff) {
221 fl_color(FL_BACKGROUND_COLOR);
222 fl_rectf(x()+w()-hdiff, y()+h()-vdiff, hdiff, vdiff);
232 _MSG(
"FltkViewport::handle %s\n", fl_eventnames[event]);
242 if (Fl::event_key() != FL_Tab || Fl::event_ctrl())
266 Fl::event_button() == FL_MIDDLE_MOUSE) {
273 dragX = Fl::event_x();
274 dragY = Fl::event_y();
282 if (Fl::event_inside(
this))
286 dragX = Fl::event_x();
287 dragY = Fl::event_y();
295 }
else if (!Fl::event_inside(
this)) {
309 if (Fl::event_button() == FL_MIDDLE_MOUSE) {
406 damage(FL_DAMAGE_SCROLL);
449 if ((distance = x() -
mouse_x) > 0)
450 dx = -distance *
hscrollbar->linesize () / 48 - 1;
451 else if ((distance =
mouse_x - (x() + w())) > 0)
452 dx = distance *
hscrollbar->linesize () / 48 + 1;
453 if ((distance = y() -
mouse_y) > 0)
454 dy = -distance *
vscrollbar->linesize () / 48 - 1;
455 else if ((distance =
mouse_y - (y() + h())) > 0)
456 dy = distance *
vscrollbar->linesize () / 48 + 1;
468 int hScrollbarThickness,
469 int vScrollbarThickness)
472 (
hscrollbar->visible() ? !hScrollbarThickness : hScrollbarThickness) ||
473 (
vscrollbar->visible() ? !vScrollbarThickness : vScrollbarThickness);
475 _MSG(
"FltkViewport::setViewportSize old_w,old_h=%dx%d -> w,h=%dx%d\n" 476 "\t hThick=%d hVis=%d, vThick=%d vVis=%d, adjustReq=%d\n",
477 w(),h(),width,height,
479 vScrollbarThickness,
vscrollbar->visible(), adjustReq);
486 vScrollbarThickness ? 0 : -
scrollY);
496 for (
int i = children () - 1; i > 0; i--) {
497 Fl_Widget *widget = child (i);
502 widget->position(widget->x () - dx, widget->y () - dy);
529 bool vscrollbarVisible,
533 this->gadgetOrientation[(hscrollbarVisible ? 0 : 1) |