26#include <FL/fl_draw.H>
30#include "../lout/msg.h"
31#include "../lout/debug.hh"
43class CustScrollbar :
public Fl_Scrollbar
46 CustScrollbar(
int x,
int y,
int w,
int h) : Fl_Scrollbar(x,y,w,h) {};
48 if (e == FL_SHORTCUT && Fl::event_state() == FL_SHIFT &&
49 (Fl::event_key() == FL_Left || Fl::event_key() == FL_Right))
51 return Fl_Scrollbar::handle(e);
60 hscrollbar =
new CustScrollbar (x (), y (), 1, 1);
66 vscrollbar =
new Fl_Scrollbar (x (), y(), 1, 1);
88 new container::typed::List <object::TypedPointer < Fl_Widget> >
100 int hdiff = 0, vdiff = 0;
103 _MSG(
" >>FltkViewport::adjustScrollbarsAndGadgetsAllocation\n");
142 Fl_Widget *widget = it.getNext()->getTypedValue ();
192 bool dimension_changed = W != w() ||
H != h();
194 Fl_Group::resize(X, Y, W,
H);
195 if (dimension_changed) {
204 fl_push_clip(x, y, w, h);
206 vp->FltkWidgetView::draw ();
210 Fl_Widget *widget = it.getNext()->getTypedValue ();
211 vp->draw_child (*widget);
226 const int d = damage(),
229 draw = d & (FL_DAMAGE_ALL | FL_DAMAGE_EXPOSE),
233 _MSG(
"FltkViewport::draw d=%d => ", d);
239 if (
draw && vis_vs && vis_hs) {
240 fl_color(FL_BACKGROUND_COLOR);
242 fl_rectf(x(), y()+h()-vis_hs, vis_vs, vis_hs);
244 fl_rectf(x()+w()-vis_vs, y()+h()-vis_hs, vis_vs, vis_hs);
248 if (d == FL_DAMAGE_CHILD && (draw_vs || draw_hs)) {
250 }
else if (d == (FL_DAMAGE_SCROLL | FL_DAMAGE_CHILD)) {
255 fl_scroll(x, y(), w() - vis_vs, h() - vis_hs,
257 _MSG(
"fl_scroll()\n");
263 draw_area(
this, x, y(), w() - vis_vs, h() - vis_hs);
264 _MSG(
"draw_area()\n");
274 _MSG(
"FltkViewport::handle %s\n", fl_eventnames[event]);
284 if (Fl::event_key() != FL_Tab || Fl::event_ctrl())
304 int yclick = Fl::event_y();
310 if (yclick <= ytop) {
313 }
else if (yclick >= ybottom) {
318 if (Fl::event_button() == FL_LEFT_MOUSE)
320 else if (Fl::event_button() == FL_RIGHT_MOUSE)
341 Fl::event_button() == FL_MIDDLE_MOUSE) {
348 dragX = Fl::event_x();
349 dragY = Fl::event_y();
357 if (Fl::event_inside(
this))
361 dragX = Fl::event_x();
362 dragY = Fl::event_y();
370 }
else if (!Fl::event_inside(
this)) {
381 if (Fl::event_dy() > 0) {
384 }
else if (Fl::event_dy() < 0) {
395 if (Fl::event_button() == FL_MIDDLE_MOUSE) {
517 damage(FL_DAMAGE_SCROLL);
562 if ((distance = x() -
mouse_x) > 0)
563 dx = -distance *
hscrollbar->linesize () / 48 - 1;
564 else if ((distance =
mouse_x - (x() + w())) > 0)
565 dx = distance *
hscrollbar->linesize () / 48 + 1;
566 if ((distance = y() -
mouse_y) > 0)
567 dy = -distance *
vscrollbar->linesize () / 48 - 1;
568 else if ((distance =
mouse_y - (y() + h())) > 0)
569 dy = distance *
vscrollbar->linesize () / 48 + 1;
595 damage(FL_DAMAGE_ALL);
599 int hScrollbarThickness,
600 int vScrollbarThickness)
603 (
hscrollbar->visible() ? !hScrollbarThickness : hScrollbarThickness) ||
604 (
vscrollbar->visible() ? !vScrollbarThickness : vScrollbarThickness);
606 _MSG(
"FltkViewport::setViewportSize old_w,old_h=%dx%d -> w,h=%dx%d\n"
607 "\t hThick=%d hVis=%d, vThick=%d vVis=%d, adjustReq=%d\n",
608 w(),h(),width,height,
610 vScrollbarThickness,
vscrollbar->visible(), adjustReq);
617 vScrollbarThickness ? 0 : -
scrollY);
627 for (
int i = children () - 1; i > 0; i--) {
628 Fl_Widget *widget = child (i);
633 widget->position(widget->x () - dx, widget->y () - dy);
660 bool vscrollbarVisible,
664 this->gadgetOrientation[(hscrollbarVisible ? 0 : 1) |
bool motionNotify(View *view, int x, int y, ButtonState state)
This function is called by a view, to delegate a motion notify event.
void viewportSizeChanged(View *view, int width, int height)
void scrollPosChanged(View *view, int x, int y)
void setCanvasSize(int width, int ascent, int descent)
Set the canvas size.
void setCursor(core::style::Cursor cursor)
Set the cursor appearance.
void scrollTo(int x, int y)
Scroll the vieport to the given position.
static void vscrollbarCallback(Fl_Widget *vscrollbar, void *viewportPtr)
static void draw_area(void *data, int x, int y, int w, int h)
int translateCanvasXToViewX(int x)
void setPageOverlap(int overlap)
void addGadget(Fl_Widget *gadget)
int translateViewXToCanvasX(int x)
int translateViewYToCanvasY(int y)
Fl_Scrollbar * hscrollbar
Fl_Scrollbar * vscrollbar
void scroll(int dx, int dy)
int getVScrollbarThickness()
Get the thickness of the vertical scrollbar, when it is visible.
void adjustScrollbarValues()
void setCanvasSize(int width, int ascent, int descent)
Set the canvas size.
void setScrollbarPageMode(bool enable)
void updateCanvasWidgets(int oldScrollX, int oldScrollY)
static void hscrollbarCallback(Fl_Widget *hscrollbar, void *viewportPtr)
void adjustScrollbarsAndGadgetsAllocation()
FltkViewport(int x, int y, int w, int h, const char *label=0)
enum dw::core::ScrollCommand pageScrolling
bool usesViewport()
Return, whether this view uses a viewport.
int translateCanvasYToViewY(int y)
GadgetOrientation gadgetOrientation[4]
void setScrollStep(int step)
void setViewportSize(int width, int height, int hScrollbarThickness, int vScrollbarThickness)
Set the viewport size.
void setScrollbarOnLeft(bool enable)
void setGadgetOrientation(bool hscrollbarVisible, bool vscrollbarVisible, GadgetOrientation gadgetOrientation)
void resize(int x, int y, int w, int h)
lout::container::typed::List< lout::object::TypedPointer< Fl_Widget > > * gadgets
int getHScrollbarThickness()
Get the thickness of the horizontal scrollbar, when it is visible.
Typed version of container::untyped::Iterator.
#define DBG_OBJ_CREATE(klass)
ButtonState
Platform independent representation.
Dw is in this namespace, or sub namespaces of this one.
This namespace provides thin wrappers, implemented as C++ templates, to gain type-safety.
Here, some common classes (or interfaces) are defined, to standardize the access to other classes.