view dw/fltkviewport.hh @ 2068:e6a6cf3aab0f

Switched menu item callbacks to Fl_Menu_Item (instead of Fl_Widget) (segfaulted in Win32 with mingw) * Also lots of cosmetic whitespace
author Jorge Arellano Cid <>
date Tue, 31 May 2011 17:28:09 -0400
parents 5b8f66e6f715
children 8c0772fac825
line wrap: on
line source

#include <FL/Fl_Group.H>
#include <FL/Fl_Scrollbar.H>

#include "core.hh"
#include "fltkcore.hh"
#include "fltkviewbase.hh"

namespace dw {
namespace fltk {

class FltkViewport: public FltkWidgetView
   enum GadgetOrientation { GADGET_VERTICAL, GADGET_HORIZONTAL };

   enum { SCROLLBAR_THICKNESS = 15 };

   int scrollX, scrollY;
   int scrollDX, scrollDY;
   int dragScrolling, dragX, dragY;

   Fl_Scrollbar *vscrollbar, *hscrollbar;

   GadgetOrientation gadgetOrientation[4];
   lout::container::typed::List <lout::object::TypedPointer < Fl_Widget> >

   void adjustScrollbarsAndGadgetsAllocation ();
   void adjustScrollbarValues ();
   void hscrollbarChanged ();
   void vscrollbarChanged ();
   void positionChanged ();

   static void hscrollbarCallback (Fl_Widget *hscrollbar, void *viewportPtr);
   static void vscrollbarCallback (Fl_Widget *vscrollbar, void *viewportPtr);

   void updateCanvasWidgets (int oldScrollX, int oldScrollY);
   static void draw_area (void *data, int x, int y, int w, int h);

   int translateViewXToCanvasX (int x);
   int translateViewYToCanvasY (int y);
   int translateCanvasXToViewX (int x);
   int translateCanvasYToViewY (int y);

   FltkViewport (int x, int y, int w, int h, const char *label = 0);
   ~FltkViewport ();

   void resize(int x, int y, int w, int h);
   void draw ();
   int handle (int event);

   void setCanvasSize (int width, int ascent, int descent);

   bool usesViewport ();
   int getHScrollbarThickness ();
   int getVScrollbarThickness ();
   void scroll(int dx, int dy);
   void scroll(dw::core::ScrollCommand cmd);
   void scrollTo (int x, int y);
   void setViewportSize (int width, int height,
                         int hScrollbarThickness, int vScrollbarThickness);
   void setScrollStep(int step);

   void setGadgetOrientation (bool hscrollbarVisible, bool vscrollbarVisible,
                              GadgetOrientation gadgetOrientation);
   void addGadget (Fl_Widget *gadget);

} // namespace fltk
} // namespace dw

#endif // __DW_FLTKVIEWPORT_HH__