00001 #ifndef __FlTKPREVIEW_HH__
00002 #define __FlTKPREVIEW_HH__
00003
00004 #include <FL/Fl_Button.H>
00005 #include <FL/Fl_Menu_Window.H>
00006 #include "fltkviewbase.hh"
00007
00008 namespace dw {
00009 namespace fltk {
00010
00011 class FltkPreview: public FltkViewBase
00012 {
00013 friend class FltkPreviewWindow;
00014
00015 private:
00016 int scrollX, scrollY, scrollWidth, scrollHeight;
00017
00018 protected:
00019 int translateViewXToCanvasX (int x);
00020 int translateViewYToCanvasY (int y);
00021 int translateCanvasXToViewX (int x);
00022 int translateCanvasYToViewY (int y);
00023
00024 public:
00025 FltkPreview (int x, int y, int w, int h, dw::core::Layout *layout,
00026 const char *label = 0);
00027 ~FltkPreview ();
00028
00029 int handle (int event);
00030
00031 void setCanvasSize (int width, int ascent, int descent);
00032
00033 bool usesViewport ();
00034 int getHScrollbarThickness ();
00035 int getVScrollbarThickness ();
00036 void scrollTo (int x, int y);
00037 void scroll (dw::core::ScrollCommand cmd);
00038 void setViewportSize (int width, int height,
00039 int hScrollbarThickness, int vScrollbarThickness);
00040
00041 void drawText (core::style::Font *font,
00042 core::style::Color *color,
00043 core::style::Color::Shading shading,
00044 int x, int y, const char *text, int len);
00045 void drawSimpleWrappedText (core::style::Font *font,
00046 core::style::Color *color,
00047 core::style::Color::Shading shading,
00048 int x, int y, int w, int h,
00049 const char *text);
00050 void drawImage (core::Imgbuf *imgbuf, int xRoot, int yRoot,
00051 int x, int y, int width, int height);
00052
00053 bool usesFltkWidgets ();
00054 void drawFltkWidget (Fl_Widget *widget, core::Rectangle *area);
00055 };
00056
00057
00058 class FltkPreviewWindow: public Fl_Menu_Window
00059 {
00060 private:
00061 enum { BORDER_WIDTH = 2 };
00062
00063 FltkPreview *preview;
00064 int posX, posY;
00065
00066 public:
00067 FltkPreviewWindow (dw::core::Layout *layout);
00068 ~FltkPreviewWindow ();
00069
00070 void reallocate ();
00071
00072 void showWindow ();
00073 void hideWindow ();
00074
00075 void scrollTo (int mouseX, int mouseY);
00076 };
00077
00078
00079 class FltkPreviewButton: public Fl_Button
00080 {
00081 private:
00082 FltkPreviewWindow *window;
00083
00084 public:
00085 FltkPreviewButton (int x, int y, int w, int h,
00086 dw::core::Layout *layout, const char *label = 0);
00087 ~FltkPreviewButton ();
00088
00089 int handle (int event);
00090 };
00091
00092 }
00093 }
00094
00095 #endif // __FlTKPREVIEW_HH__