view dw/fltkpreview.hh @ 1733:f39cfc38ea10

rework nonCssHints API of StyleEngine * Instead of passing the nonCssHints as a CssPropertyList, set the hints separately and create the list in StyleEngine. * The CssPropertyList holding the nonCssHints is now completely managed by StyleEngine and kept on the stack. * Replace the table_cell_props mechanic in with a new method inheritNonCssHints() in StyleEngine.
author Johannes Hofmann <>
date Mon, 11 Oct 2010 21:35:53 +0200
parents 6b35322fb5f2
children 22b329c07e07
line wrap: on
line source
#ifndef __FlTKPREVIEW_HH__
#define __FlTKPREVIEW_HH__

#include <fltk/Button.h>
#include <fltk/MenuWindow.h>
#include "fltkviewbase.hh"

namespace dw {
namespace fltk {

class FltkPreview: public FltkViewBase
   friend class FltkPreviewWindow;

   int scrollX, scrollY, scrollWidth, scrollHeight;

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

   FltkPreview (int x, int y, int w, int h, dw::core::Layout *layout,
                const char *label = 0);
   ~FltkPreview ();

   int handle (int event);

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

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

   void drawText (core::style::Font *font,
                  core::style::Color *color,
                  core::style::Color::Shading shading,
                  int x, int y, const char *text, int len);
   void drawImage (core::Imgbuf *imgbuf, int xRoot, int yRoot,
                   int x, int y, int width, int height);

   bool usesFltkWidgets ();
   void drawFltkWidget (::fltk::Widget *widget, core::Rectangle *area);

class FltkPreviewWindow: public ::fltk::MenuWindow
   enum { BORDER_WIDTH = 2 };

   FltkPreview *preview;
   int posX, posY;

   FltkPreviewWindow (dw::core::Layout *layout);
   ~FltkPreviewWindow ();

   void reallocate ();

   void showWindow ();
   void hideWindow ();

   void scrollTo (int mouseX, int mouseY);

class FltkPreviewButton: public  ::fltk::Button
   FltkPreviewWindow *window;

   FltkPreviewButton (int x, int y, int w, int h,
                      dw::core::Layout *layout, const char *label = 0);
   ~FltkPreviewButton ();

   int handle (int event);

} // namespace fltk
} // namespace dw

#endif // __FlTKPREVIEW_HH__