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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
#ifndef __DW_FLTKPLATFORM_HH__
#define __DW_FLTKPLATFORM_HH__
#ifndef __INCLUDED_FROM_DW_FLTK_CORE_HH__
# error Do not include this file directly, use "fltkcore.hh" instead.
#endif
#include <fltk/Font.h>
namespace dw {
/**
* \brief This namespace contains FLTK implementations of Dw interfaces.
*/
namespace fltk {
class FltkFont: public core::style::Font
{
static lout::container::typed::HashTable <dw::core::style::FontAttrs,
FltkFont> *fontsTable;
FltkFont (core::style::FontAttrs *attrs);
~FltkFont ();
public:
::fltk::Font *font;
static FltkFont *create (core::style::FontAttrs *attrs);
};
class FltkColor: public core::style::Color
{
static lout::container::typed::HashTable <dw::core::style::ColorAttrs,
FltkColor> *colorsTable;
FltkColor (int color);
~FltkColor ();
public:
int colors[SHADING_NUM];
static FltkColor *create(int color);
};
class FltkTooltip: public core::style::Tooltip
{
private:
FltkTooltip (const char *text);
~FltkTooltip ();
bool shown;
char *escaped_str; /* fltk WORKAROUND */
public:
static FltkTooltip *create(const char *text);
void onEnter();
void onLeave();
void onMotion();
};
/**
* \brief This interface adds some more methods for all flkt-based views.
*/
class FltkView: public core::View
{
public:
virtual bool usesFltkWidgets () = 0;
virtual void addFltkWidget (Fl_Widget *widget,
core::Allocation *allocation);
virtual void removeFltkWidget (Fl_Widget *widget);
virtual void allocateFltkWidget (Fl_Widget *widget,
core::Allocation *allocation);
virtual void drawFltkWidget (Fl_Widget *widget, core::Rectangle *area);
};
class FltkPlatform: public core::Platform
{
private:
class FltkResourceFactory: public core::ui::ResourceFactory
{
private:
FltkPlatform *platform;
public:
inline void setPlatform (FltkPlatform *platform) {
this->platform = platform; }
core::ui::LabelButtonResource *createLabelButtonResource (const char
*label);
core::ui::ComplexButtonResource *
createComplexButtonResource (core::Widget *widget, bool relief);
core::ui::ListResource *
createListResource (core::ui::ListResource::SelectionMode selectionMode,
int rows);
core::ui::OptionMenuResource *createOptionMenuResource ();
core::ui::EntryResource *createEntryResource (int maxLength,
bool password,
const char *label);
core::ui::MultiLineTextResource *createMultiLineTextResource (int cols,
int rows);
core::ui::CheckButtonResource *createCheckButtonResource (bool
activated);
core::ui::RadioButtonResource *
createRadioButtonResource (core::ui::RadioButtonResource
*groupedWith, bool activated);
};
FltkResourceFactory resourceFactory;
class IdleFunc: public lout::object::Object
{
public:
int id;
void (core::Layout::*func) ();
};
core::Layout *layout;
lout::container::typed::List <IdleFunc> *idleQueue;
bool idleFuncRunning;
int idleFuncId;
static void generalStaticIdle(void *data);
void generalIdle();
FltkView *view;
lout::container::typed::List <ui::FltkResource> *resources;
public:
FltkPlatform ();
~FltkPlatform ();
void setLayout (core::Layout *layout);
void attachView (core::View *view);
void detachView (core::View *view);
int textWidth (core::style::Font *font, const char *text, int len);
int nextGlyph (const char *text, int idx);
int prevGlyph (const char *text, int idx);
float dpiX ();
float dpiY ();
int addIdle (void (core::Layout::*func) ());
void removeIdle (int idleId);
core::style::Font *createFont (core::style::FontAttrs *attrs,
bool tryEverything);
bool fontExists (const char *name);
core::style::Color *createColor (int color);
core::style::Tooltip *createTooltip (const char *text);
core::Imgbuf *createImgbuf (core::Imgbuf::Type type, int width, int height);
void copySelection(const char *text);
core::ui::ResourceFactory *getResourceFactory ();
void attachResource (ui::FltkResource *resource);
void detachResource (ui::FltkResource *resource);
};
} // namespace fltk
} // namespace dw
#endif // __DW_FLTKPLATFORM_HH__
|