25#include <FL/fl_draw.H>
29#include "../lout/msg.h"
30#include "../lout/debug.hh"
42class CustScrollbar :
public Fl_Scrollbar
45 CustScrollbar(
int x,
int y,
int w,
int h) : Fl_Scrollbar(x,y,w,h) {};
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);
59 hscrollbar =
new CustScrollbar (x (), y (), 1, 1);
65 vscrollbar =
new Fl_Scrollbar (x (), y(), 1, 1);
81 new container::typed::List <object::TypedPointer < Fl_Widget> >
93 int hdiff = 0, vdiff = 0;
96 _MSG(
" >>FltkViewport::adjustScrollbarsAndGadgetsAllocation\n");
128 Fl_Widget *widget = it.getNext()->getTypedValue ();
176 bool dimension_changed = W != w() ||
H != h();
178 Fl_Group::resize(X, Y, W,
H);
179 if (dimension_changed) {
188 fl_push_clip(x, y, w, h);
190 vp->FltkWidgetView::draw ();
194 Fl_Widget *widget = it.getNext()->getTypedValue ();
195 vp->draw_child (*widget);
210 const int d = damage(),
213 draw = d & (FL_DAMAGE_ALL | FL_DAMAGE_EXPOSE),
217 _MSG(
"FltkViewport::draw d=%d => ", d);
223 if (
draw && vis_vs && vis_hs) {
224 fl_color(FL_BACKGROUND_COLOR);
225 fl_rectf(x()+w()-vis_vs, y()+h()-vis_hs, vis_vs, vis_hs);
228 if (d == FL_DAMAGE_CHILD && (draw_vs || draw_hs)) {
230 }
else if (d == (FL_DAMAGE_SCROLL | FL_DAMAGE_CHILD)) {
231 fl_scroll(x(), y(), w() - vis_vs, h() - vis_hs,
233 _MSG(
"fl_scroll()\n");
235 draw_area(
this, x(), y(), w() - vis_vs, h() - vis_hs);
236 _MSG(
"draw_area()\n");
246 _MSG(
"FltkViewport::handle %s\n", fl_eventnames[event]);
256 if (Fl::event_key() != FL_Tab || Fl::event_ctrl())
280 Fl::event_button() == FL_MIDDLE_MOUSE) {
287 dragX = Fl::event_x();
288 dragY = Fl::event_y();
296 if (Fl::event_inside(
this))
300 dragX = Fl::event_x();
301 dragY = Fl::event_y();
309 }
else if (!Fl::event_inside(
this)) {
323 if (Fl::event_button() == FL_MIDDLE_MOUSE) {
420 damage(FL_DAMAGE_SCROLL);
463 if ((distance = x() -
mouse_x) > 0)
464 dx = -distance *
hscrollbar->linesize () / 48 - 1;
465 else if ((distance =
mouse_x - (x() + w())) > 0)
466 dx = distance *
hscrollbar->linesize () / 48 + 1;
467 if ((distance = y() -
mouse_y) > 0)
468 dy = -distance *
vscrollbar->linesize () / 48 - 1;
469 else if ((distance =
mouse_y - (y() + h())) > 0)
470 dy = distance *
vscrollbar->linesize () / 48 + 1;
482 int hScrollbarThickness,
483 int vScrollbarThickness)
486 (
hscrollbar->visible() ? !hScrollbarThickness : hScrollbarThickness) ||
487 (
vscrollbar->visible() ? !vScrollbarThickness : vScrollbarThickness);
489 _MSG(
"FltkViewport::setViewportSize old_w,old_h=%dx%d -> w,h=%dx%d\n"
490 "\t hThick=%d hVis=%d, vThick=%d vVis=%d, adjustReq=%d\n",
491 w(),h(),width,height,
493 vScrollbarThickness,
vscrollbar->visible(), adjustReq);
500 vScrollbarThickness ? 0 : -
scrollY);
510 for (
int i = children () - 1; i > 0; i--) {
511 Fl_Widget *widget = child (i);
516 widget->position(widget->x () - dx, widget->y () - dy);
543 bool vscrollbarVisible,
547 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 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 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)
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 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.