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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
/*
* Dillo Widget
*
* Copyright 2005-2013 Sebastian Geerken <sgeerken@dillo.org>
* Copyright 2025 Rodrigo Arias Mallo <rodarima@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __DW_PLATFORM_HH__
#define __DW_PLATFORM_HH__
#ifndef __INCLUDED_FROM_DW_CORE_HH__
# error Do not include this file directly, use "core.hh" instead.
#endif
namespace dw {
namespace core {
/**
* \brief An interface to encapsulate some platform dependencies.
*
* \sa\ref dw-overview
*/
class Platform: public lout::object::Object
{
public:
/*
* -----------------------------------
* General
* -----------------------------------
*/
/**
* \brief This methods notifies the platform, that it has been attached to
* a layout.
*/
virtual void setLayout (Layout *layout) = 0;
/*
* -------------------------
* Operations on views
* -------------------------
*/
/**
* \brief This methods notifies the platform, that a view has been attached
* to the related layout.
*/
virtual void attachView (View *view) = 0;
/**
* \brief This methods notifies the platform, that a view has been detached
* from the related layout.
*/
virtual void detachView (View *view) = 0;
/*
* -----------------------------------
* Platform dependent properties
* -----------------------------------
*/
/**
* \brief Return the width of a text, with a given length and font.
*/
virtual int textWidth (style::Font *font, const char *text, int len) = 0;
/**
* \brief Return the string resulting from transforming text to uppercase.
*/
virtual char *textToUpper (const char *text, int len) = 0;
/**
* \brief Return the string resulting from transforming text to lowercase.
*/
virtual char *textToLower (const char *text, int len) = 0;
/**
* \brief Return the index of the next glyph in string text.
*/
virtual int nextGlyph (const char *text, int idx) = 0;
/**
* \brief Return the index of the previous glyph in string text.
*/
virtual int prevGlyph (const char *text, int idx) = 0;
/**
* \brief Return screen resolution in x-direction.
*/
virtual float dpiX () = 0;
/**
* \brief Return screen resolution in y-direction.
*/
virtual float dpiY () = 0;
/*
* ---------------------------------------------------------
* These are to encapsulate some platform dependencies
* ---------------------------------------------------------
*/
/**
* \brief Add an idle function.
*
* An idle function is called once, when no other
* tasks are to be done (e.g. there are no events to process), and then
* removed from the queue. The return value is a number, which can be
* used in removeIdle below.
*/
virtual int addIdle (void (Layout::*func) ()) = 0;
/**
* \brief Remove an idle function, which has not been processed yet.
*/
virtual void removeIdle (int idleId) = 0;
/*
* ---------------------
* Style Resources
* ---------------------
*/
/**
* \brief Create a (platform dependent) font.
*
* Typically, within a platform, a sub class of dw::core::style::Font
* is defined, which holds more platform dependent data.
*
* Also, this method must fill the attributes "font" (when needed),
* "ascent", "descent", "spaceSidth", "zeroWidth" and "xHeight". If
* "tryEverything" is true, several methods should be used to use
* another font, when the requested font is not available. Passing
* false is typically done, if the caller wants to test different
* variations.
*/
virtual style::Font *createFont (style::FontAttrs *attrs,
bool tryEverything) = 0;
virtual bool fontExists (const char *name) = 0;
/**
* \brief Create a color resource for a given 0xrrggbb value.
*/
virtual style::Color *createColor (int color) = 0;
/**
* \brief Create a tooltip
*/
virtual style::Tooltip *createTooltip (const char *text) = 0;
/**
* \brief Cancel a tooltip (either shown or requested)
*/
virtual void cancelTooltip () = 0;
/**
* \brief Create a (platform specific) image buffer.
*
* "gamma" is the value by which the image data is gamma-encoded.
*/
virtual Imgbuf *createImgbuf (Imgbuf::Type type, int width, int height,
double gamma) = 0;
/**
* \brief Copy selected text (0-terminated).
*/
virtual void copySelection(const char *text, int destination) = 0;
/**
* ...
*/
virtual ui::ResourceFactory *getResourceFactory () = 0;
};
} // namespace core
} // namespace dw
#endif // __DW_PLATFORM_HH__
|