1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#ifndef __FlTKPREVIEW_HH__
#define __FlTKPREVIEW_HH__
#include <FL/Fl_Button.H>
#include <FL/Fl_Menu_Window.H>
#include "fltkviewbase.hh"
namespace dw {
namespace fltk {
class FltkPreview: public FltkViewBase
{
friend class FltkPreviewWindow;
private:
int scrollX, scrollY, scrollWidth, scrollHeight;
protected:
int translateViewXToCanvasX (int x);
int translateViewYToCanvasY (int y);
int translateCanvasXToViewX (int x);
int translateCanvasYToViewY (int y);
public:
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 ();
int getScrollbarOnLeft ();
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 drawSimpleWrappedText (core::style::Font *font,
core::style::Color *color,
core::style::Color::Shading shading,
int x, int y, int w, int h,
const char *text);
void drawImage (core::Imgbuf *imgbuf, int xRoot, int yRoot,
int x, int y, int width, int height);
bool usesFltkWidgets ();
void drawFltkWidget (Fl_Widget *widget, core::Rectangle *area);
};
class FltkPreviewWindow: public Fl_Menu_Window
{
private:
enum { BORDER_WIDTH = 2 };
FltkPreview *preview;
int posX, posY;
public:
FltkPreviewWindow (dw::core::Layout *layout);
~FltkPreviewWindow ();
void reallocate ();
void showWindow ();
void hideWindow ();
void scrollTo (int mouseX, int mouseY);
};
class FltkPreviewButton: public Fl_Button
{
private:
FltkPreviewWindow *window;
public:
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__
|