comparison dw/fltkplatform.hh @ 347:e5955ab8dafb

- Moved the dw2 tree into dillo2's tree.
author jcid
date Wed, 24 Sep 2008 18:44:40 +0200
parents
children cdfdb006f193 2a712706829a
comparison
equal deleted inserted replaced
346:05228bc9f399 347:e5955ab8dafb
1 #ifndef __DW_FLTKPLATFORM_HH__
2 #define __DW_FLTKPLATFORM_HH__
3
4 #ifndef __INCLUDED_FROM_DW_FLTK_CORE_HH__
5 # error Do not include this file directly, use "fltkcore.hh" instead.
6 #endif
7
8 #include <fltk/Font.h>
9
10 namespace dw {
11
12 /**
13 * \brief This namespace contains FLTK implementations of Dw interfaces.
14 */
15 namespace fltk {
16
17 class FltkFont: public core::style::Font
18 {
19 static lout::container::typed::HashTable <dw::core::style::FontAttrs,
20 FltkFont> *fontsTable;
21
22 FltkFont (core::style::FontAttrs *attrs);
23 ~FltkFont ();
24
25 public:
26 ::fltk::Font *font;
27
28 static FltkFont *create (core::style::FontAttrs *attrs);
29 };
30
31
32 class FltkColor: public core::style::Color
33 {
34 static lout::container::typed::HashTable <dw::core::style::ColorAttrs,
35 FltkColor> *colorsTable;
36
37 FltkColor (int color, core::style::Color::Type type);
38 ~FltkColor ();
39
40 public:
41 int colors[SHADING_NUM];
42
43 static FltkColor *create(int color, core::style::Color::Type type);
44 };
45
46
47 /**
48 * \brief This interface adds some more methods for all flkt-based views.
49 */
50 class FltkView: public core::View
51 {
52 public:
53 virtual bool usesFltkWidgets () = 0;
54
55 virtual void addFltkWidget (::fltk::Widget *widget,
56 core::Allocation *allocation);
57 virtual void removeFltkWidget (::fltk::Widget *widget);
58 virtual void allocateFltkWidget (::fltk::Widget *widget,
59 core::Allocation *allocation);
60 virtual void drawFltkWidget (::fltk::Widget *widget, core::Rectangle *area);
61 };
62
63
64 class FltkPlatform: public core::Platform
65 {
66 private:
67 class FltkResourceFactory: public core::ui::ResourceFactory
68 {
69 private:
70 FltkPlatform *platform;
71
72 public:
73 inline void setPlatform (FltkPlatform *platform) {
74 this->platform = platform; }
75
76 core::ui::LabelButtonResource *createLabelButtonResource (const char
77 *label);
78 core::ui::ComplexButtonResource *
79 createComplexButtonResource (core::Widget *widget, bool relief);
80 core::ui::ListResource *
81 createListResource (core::ui::ListResource::SelectionMode selectionMode);
82 core::ui::OptionMenuResource *createOptionMenuResource ();
83 core::ui::EntryResource *createEntryResource (int maxLength,
84 bool password);
85 core::ui::MultiLineTextResource *createMultiLineTextResource (int cols,
86 int rows);
87 core::ui::CheckButtonResource *createCheckButtonResource (bool
88 activated);
89 core::ui::RadioButtonResource *
90 createRadioButtonResource (core::ui::RadioButtonResource
91 *groupedWith, bool activated);
92 };
93
94 FltkResourceFactory resourceFactory;
95
96 class IdleFunc: public lout::object::Object
97 {
98 public:
99 int id;
100 void (core::Layout::*func) ();
101 };
102
103 core::Layout *layout;
104
105 lout::container::typed::List <IdleFunc> *idleQueue;
106 bool idleFuncRunning;
107 int idleFuncId;
108
109 static void generalStaticIdle(void *data);
110 void generalIdle();
111
112 lout::container::typed::List <FltkView> *views;
113 lout::container::typed::List <ui::FltkResource> *resources;
114
115 public:
116 FltkPlatform ();
117 ~FltkPlatform ();
118
119 void setLayout (core::Layout *layout);
120
121 void attachView (core::View *view);
122
123 void detachView (core::View *view);
124
125 int textWidth (core::style::Font *font, const char *text, int len);
126 int nextGlyph (const char *text, int idx);
127 int prevGlyph (const char *text, int idx);
128
129 int addIdle (void (core::Layout::*func) ());
130 void removeIdle (int idleId);
131
132 core::style::Font *createFont (core::style::FontAttrs *attrs,
133 bool tryEverything);
134 core::style::Color *createSimpleColor (int color);
135 core::style::Color *createShadedColor (int color);
136
137 core::Imgbuf *createImgbuf (core::Imgbuf::Type type, int width, int height);
138
139 void copySelection(const char *text);
140
141 core::ui::ResourceFactory *getResourceFactory ();
142
143 void attachResource (ui::FltkResource *resource);
144 void detachResource (ui::FltkResource *resource);
145 };
146
147 } // namespace fltk
148 } // namespace dw
149
150 #endif // __DW_FLTKPLATFORM_HH__