Dillo v3.1.1-91-g6d5b3ee3
Loading...
Searching...
No Matches
layout.hh
Go to the documentation of this file.
1#ifndef __DW_LAYOUT_HH__
2#define __DW_LAYOUT_HH__
3
4#ifndef __INCLUDED_FROM_DW_CORE_HH__
5# error Do not include this file directly, use "core.hh" instead.
6#endif
7
8namespace dw {
9namespace core {
10
17{
18 friend class Widget;
19
20private:
22 {
24
25 public:
26 LayoutImgRenderer (Layout *layout) { this->layout = layout; }
27
28 bool readyToDraw ();
29 void getBgArea (int *x, int *y, int *width, int *height);
30 void getRefArea (int *xRef, int *yRef, int *widthRef, int *heightRef);
36 void draw (int x, int y, int width, int height);
37 };
38
40
41public:
48 {
49 public:
50 virtual void resizeQueued (bool extremesChanged);
51 virtual void canvasSizeChanged (int width, int ascent, int descent);
52 };
53
55 {
56 public:
68 virtual bool enter (Widget *widget, int link, int img, int x, int y);
69
76 virtual bool press (Widget *widget, int link, int img, int x, int y,
77 EventButton *event);
78
85 virtual bool release (Widget *widget, int link, int img, int x, int y,
86 EventButton *event);
87
99 virtual bool click (Widget *widget, int link, int img, int x, int y,
100 EventButton *event);
101 };
102
104 {
105 private:
107
108 protected:
109 bool emitToReceiver (lout::signal::Receiver *receiver, int signalNo,
110 int argc, lout::object::Object **argv);
111
112 public:
113 inline void connectLink (LinkReceiver *receiver) { connect (receiver); }
114
115 bool emitEnter (Widget *widget, int link, int img, int x, int y);
116 bool emitPress (Widget *widget, int link, int img, int x, int y,
117 EventButton *event);
118 bool emitRelease (Widget *widget, int link, int img, int x, int y,
119 EventButton *event);
120 bool emitClick (Widget *widget, int link, int img, int x, int y,
121 EventButton *event);
122 };
123
125
126private:
128 {
129 private:
131
132 protected:
133 bool emitToReceiver (lout::signal::Receiver *receiver, int signalNo,
134 int argc, lout::object::Object **argv);
135
136 public:
137 inline void connectLayout (Receiver *receiver) { connect (receiver); }
138
139 void emitResizeQueued (bool extremesChanged);
140 void emitCanvasSizeChanged (int width, int ascent, int descent);
141 };
142
144
146 {
147 public:
148 char *name;
150 int y;
151
152 ~Anchor ();
153 };
154
159
160 /* The state, which must be projected into the view. */
166
169
174
178
182
183 /* Anchors of the widget tree */
184 lout::container::typed::HashTable <lout::object::String, Anchor>
186
189
191
192 void detachWidget (Widget *widget);
193
194 Widget *getWidgetAtPoint (int x, int y);
195 void moveToWidget (Widget *newWidgetAtPoint, ButtonState state);
196
201 void moveToWidgetAtPoint (int x, int y, ButtonState state)
202 { moveToWidget (getWidgetAtPoint (x, y), state); }
203
208 void moveOutOfView (ButtonState state) { moveToWidget (NULL, state); }
209
212 int numPressed, int x, int y, ButtonState state,
213 int button);
214 void resizeIdle ();
216 void draw (View *view, Rectangle *area);
217
218 void scrollTo0(HPosition hpos, VPosition vpos,
219 int x, int y, int width, int height,
220 bool scrollingInterrupted);
221 void scrollIdle ();
222 void adjustScrollPos ();
223 static bool calcScrollInto (int targetValue, int requestedSize,
224 int *value, int viewportSize);
227
228 void updateAnchor ();
229
230 /* Widget */
231
232 char *addAnchor (Widget *widget, const char* name);
233 char *addAnchor (Widget *widget, const char* name, int y);
234 void changeAnchor (Widget *widget, char* name, int y);
235 void removeAnchor (Widget *widget, char* name);
237 void updateCursor ();
238 void queueDraw (int x, int y, int width, int height);
239 void queueDrawExcept (int x, int y, int width, int height,
240 int ex, int ey, int ewidth, int eheight);
241 void queueResize (bool extremesChanged);
242 void removeWidget ();
243
244 /* For tests regarding the respective Layout and (mostly) Widget
245 methods. Accessed by respective methods (enter..., leave...,
246 ...Entered) defined here and in Widget. */
247
250
253
254public:
256 ~Layout ();
257
258 inline void connectLink (LinkReceiver *receiver)
259 { linkEmitter.connectLink (receiver); }
260
261 inline bool emitLinkEnter (Widget *w, int link, int img, int x, int y)
262 { return linkEmitter.emitEnter (w, link, img, x, y); }
263
264 inline bool emitLinkPress (Widget *w, int link, int img,
265 int x, int y, EventButton *event)
266 { return linkEmitter.emitPress (w, link, img, x, y, event); }
267
268 inline bool emitLinkRelease (Widget *w, int link, int img,
269 int x, int y, EventButton *event)
270 { return linkEmitter.emitRelease (w, link, img, x, y, event); }
271
272 inline bool emitLinkClick (Widget *w, int link, int img,
273 int x, int y, EventButton *event)
274 { return linkEmitter.emitClick (w, link, img, x, y, event); }
275
277
278 void addWidget (Widget *widget);
279 void setWidget (Widget *widget);
280
281 void attachView (View *view);
282 void detachView (View *view);
283
284 inline bool getUsesViewport () { return usesViewport; }
285 inline int getWidthViewport () { return viewportWidth; }
286 inline int getHeightViewport () { return viewportHeight; }
287 inline int getScrollPosX () { return scrollX; }
288 inline int getScrollPosY () { return scrollY; }
289
290 /* public */
291
292 void scrollTo (HPosition hpos, VPosition vpos,
293 int x, int y, int width, int height);
294 void scroll (ScrollCommand);
295 void setAnchor (const char *anchor);
296
297 /* View */
298
299 inline void expose (View *view, Rectangle *area) {
300 DBG_OBJ_ENTER ("draw", 0, "expose", "%d, %d, %d * %d",
301 area->x, area->y, area->width, area->height);
302 draw (view, area);
303 DBG_OBJ_LEAVE ();
304 }
305
314 inline bool buttonPress (View *view, int numPressed, int x, int y,
315 ButtonState state, int button)
316 {
317 return buttonEvent (BUTTON_PRESS, view, numPressed, x, y, state, button);
318 }
319
320 void containerSizeChanged ();
321
328 inline bool buttonRelease (View *view, int numPressed, int x, int y,
329 ButtonState state, int button)
330 {
331 return buttonEvent (BUTTON_RELEASE, view, numPressed, x, y, state,
332 button);
333 }
334
335 bool motionNotify (View *view, int x, int y, ButtonState state);
336 void enterNotify (View *view, int x, int y, ButtonState state);
337 void leaveNotify (View *view, ButtonState state);
338
339 void scrollPosChanged (View *view, int x, int y);
340 void viewportSizeChanged (View *view, int width, int height);
341
343 {
344 return platform;
345 }
346
347 /* delegated */
348
349 inline int textWidth (style::Font *font, const char *text, int len)
350 {
351 return platform->textWidth (font, text, len);
352 }
353
354 inline char *textToUpper (const char *text, int len)
355 {
356 return platform->textToUpper (text, len);
357 }
358
359 inline char *textToLower (const char *text, int len)
360 {
361 return platform->textToLower (text, len);
362 }
363
364 inline int nextGlyph (const char *text, int idx)
365 {
366 return platform->nextGlyph (text, idx);
367 }
368
369 inline int prevGlyph (const char *text, int idx)
370 {
371 return platform->prevGlyph (text, idx);
372 }
373
374 inline float dpiX ()
375 {
376 return platform->dpiX ();
377 }
378
379 inline float dpiY ()
380 {
381 return platform->dpiY ();
382 }
383
384 inline style::Font *createFont (style::FontAttrs *attrs, bool tryEverything)
385 {
386 return platform->createFont (attrs, tryEverything);
387 }
388
389 inline bool fontExists (const char *name)
390 {
391 return platform->fontExists (name);
392 }
393
394 inline style::Color *createColor (int color)
395 {
396 return platform->createColor (color);
397 }
398
399 inline style::Tooltip *createTooltip (const char *text)
400 {
401 return platform->createTooltip (text);
402 }
403
404 inline void cancelTooltip ()
405 {
406 return platform->cancelTooltip ();
407 }
408
409 inline Imgbuf *createImgbuf (Imgbuf::Type type, int width, int height,
410 double gamma)
411 {
412 return platform->createImgbuf (type, width, height, gamma);
413 }
414
415 inline void copySelection(const char *text)
416 {
417 platform->copySelection(text);
418 }
419
424
425 inline void connect (Receiver *receiver) {
426 emitter.connectLayout (receiver); }
427
429 inline FindtextState::Result search (const char *str, bool caseSens,
430 int backwards)
431 { return findtextState.search (str, caseSens, backwards); }
432
434 inline void resetSearch () { findtextState.resetSearch (); }
435
436 void setBgColor (style::Color *color);
441
442 inline style::Color* getBgColor () { return bgColor; }
443 inline style::StyleImage* getBgImage () { return bgImage; }
444};
445
446} // namespace core
447} // namespace dw
448
449#endif // __DW_LAYOUT_HH__
450
Represents a button press or release event.
Definition events.hh:58
void resetSearch()
This method is called when the user closes the "find text" dialog.
Definition findtext.cc:151
Result search(const char *key, bool caseSens, bool backwards)
Definition findtext.cc:75
The platform independent interface for image buffers.
Definition imgbuf.hh:162
bool emitToReceiver(lout::signal::Receiver *receiver, int signalNo, int argc, lout::object::Object **argv)
A sub class must implement this for a call to a single receiver.
Definition layout.cc:106
void emitResizeQueued(bool extremesChanged)
Definition layout.cc:130
void connectLayout(Receiver *receiver)
Definition layout.hh:137
void emitCanvasSizeChanged(int width, int ascent, int descent)
Definition layout.cc:137
void draw(int x, int y, int width, int height)
Draw (or queue for drawing) an area, which is given in canvas coordinates.
Definition layout.cc:89
void getBgArea(int *x, int *y, int *width, int *height)
Return the area covered by the background image.
Definition layout.cc:42
style::BackgroundRepeat getBackgroundRepeat()
Definition layout.cc:68
LayoutImgRenderer(Layout *layout)
Definition layout.hh:26
style::BackgroundAttachment getBackgroundAttachment()
Definition layout.cc:74
void getRefArea(int *xRef, int *yRef, int *widthRef, int *heightRef)
Return the "reference area".
Definition layout.cc:49
style::Length getBackgroundPositionX()
Definition layout.cc:79
style::Length getBackgroundPositionY()
Definition layout.cc:84
style::StyleImage * getBackgroundImage()
Definition layout.cc:63
bool readyToDraw()
If this method returns false, nothing is done at all.
Definition layout.cc:37
bool emitEnter(Widget *widget, int link, int img, int x, int y)
Definition layout.cc:217
bool emitToReceiver(lout::signal::Receiver *receiver, int signalNo, int argc, lout::object::Object **argv)
A sub class must implement this for a call to a single receiver.
Definition layout.cc:173
bool emitPress(Widget *widget, int link, int img, int x, int y, EventButton *event)
Definition layout.cc:225
void connectLink(LinkReceiver *receiver)
Definition layout.hh:113
bool emitRelease(Widget *widget, int link, int img, int x, int y, EventButton *event)
Definition layout.cc:233
bool emitClick(Widget *widget, int link, int img, int x, int y, EventButton *event)
Definition layout.cc:241
virtual bool click(Widget *widget, int link, int img, int x, int y, EventButton *event)
Called, when the user has clicked on a link.
Definition layout.cc:165
virtual bool press(Widget *widget, int link, int img, int x, int y, EventButton *event)
Called, when the user has pressed the mouse button on a link (but not yet released).
Definition layout.cc:153
virtual bool release(Widget *widget, int link, int img, int x, int y, EventButton *event)
Called, when the user has released the mouse button on a link.
Definition layout.cc:159
virtual bool enter(Widget *widget, int link, int img, int x, int y)
Called, when a link is entered, left, or the position has changed.
Definition layout.cc:147
Receiver interface different signals.
Definition layout.hh:48
virtual void resizeQueued(bool extremesChanged)
Definition layout.cc:96
virtual void canvasSizeChanged(int width, int ascent, int descent)
Definition layout.cc:100
The central class for managing and drawing a widget tree.
Definition layout.hh:17
bool fontExists(const char *name)
Definition layout.hh:389
void attachView(View *view)
Attach a view to the layout.
Definition layout.cc:458
lout::misc::ZoneAllocator * textZone
Definition layout.hh:276
void changeAnchor(Widget *widget, char *name, int y)
Definition layout.cc:773
void detachWidget(Widget *widget)
Definition layout.cc:350
int currHScrollbarThickness()
Definition layout.cc:723
int getScrollPosY()
Definition layout.hh:288
style::Cursor cursor
Definition layout.hh:167
void updateAnchor()
Definition layout.cc:789
bool emitLinkRelease(Widget *w, int link, int img, int x, int y, EventButton *event)
Definition layout.hh:268
FindtextState::Result search(const char *str, bool caseSens, int backwards)
See dw::core::FindtextState::search.
Definition layout.hh:429
void setCursor(style::Cursor cursor)
Definition layout.cc:809
void scrollIdle()
Definition layout.cc:569
void resetSearch()
See dw::core::FindtextState::resetSearch.
Definition layout.hh:434
void enterNotify(View *view, int x, int y, ButtonState state)
This function is called by a view, to delegate a enter notify event.
Definition layout.cc:1087
style::Font * createFont(style::FontAttrs *attrs, bool tryEverything)
Definition layout.hh:384
void queueDraw(int x, int y, int width, int height)
Definition layout.cc:990
bool scrollIdleNotInterrupted
Definition layout.hh:181
Widget * getWidgetAtPoint(int x, int y)
Definition layout.cc:1131
int scrollTargetWidth
Definition layout.hh:177
void containerSizeChanged()
Definition layout.cc:1342
bool motionNotify(View *view, int x, int y, ButtonState state)
This function is called by a view, to delegate a motion notify event.
Definition layout.cc:1069
bool drawAfterScrollReq
Definition layout.hh:170
void cancelTooltip()
Definition layout.hh:404
void setWidget(Widget *widget)
Definition layout.cc:432
int textWidth(style::Font *font, const char *text, int len)
Definition layout.hh:349
bool processMouseEvent(MousePositionEvent *event, ButtonEventType type)
Common processing of press, release and motion events.
Definition layout.cc:1243
style::StyleImage * bgImage
Definition layout.hh:162
void setBgColor(style::Color *color)
Definition layout.cc:825
void detachView(View *view)
Definition layout.cc:510
style::Color * getBgColor()
Definition layout.hh:442
void moveToWidgetAtPoint(int x, int y, ButtonState state)
Emit the necessary crossing events, when the mouse pointer has moved to position (x,...
Definition layout.hh:201
char * addAnchor(Widget *widget, const char *name)
Used, when the widget is not allocated yet.
Definition layout.cc:750
void leaveNotify(View *view, ButtonState state)
This function is called by a view, to delegate a leave notify event.
Definition layout.cc:1108
int getWidthViewport()
Definition layout.hh:285
void expose(View *view, Rectangle *area)
Definition layout.hh:299
lout::container::typed::HashTable< lout::object::String, Anchor > * anchorsTable
Definition layout.hh:185
void queueDrawExcept(int x, int y, int width, int height, int ex, int ey, int ewidth, int eheight)
Definition layout.cc:1003
int nextGlyph(const char *text, int idx)
Definition layout.hh:364
VPosition scrollTargetVpos
Definition layout.hh:176
void viewportSizeChanged(View *view, int width, int height)
Definition layout.cc:1321
HPosition scrollTargetHpos
Definition layout.hh:175
int sizeRequestCounter
Definition layout.hh:249
lout::container::typed::Vector< Widget > * queueResizeList
Definition layout.hh:158
int vScrollbarThickness
Definition layout.hh:173
Platform * getPlatform()
Definition layout.hh:342
LinkEmitter linkEmitter
Definition layout.hh:124
void addWidget(Widget *widget)
Definition layout.cc:370
Imgbuf * createImgbuf(Imgbuf::Type type, int width, int height, double gamma)
Definition layout.hh:409
int queueResizeCounter
Definition layout.hh:248
style::Tooltip * createTooltip(const char *text)
Definition layout.hh:399
bool buttonEvent(ButtonEventType type, View *view, int numPressed, int x, int y, ButtonState state, int button)
Definition layout.cc:1046
SelectionState selectionState
Definition layout.hh:187
void updateCursor()
Definition layout.cc:817
bool emitLinkEnter(Widget *w, int link, int img, int x, int y)
Definition layout.hh:261
void resizeIdle()
Definition layout.cc:869
void draw(View *view, Rectangle *area)
Definition layout.cc:669
style::Color * createColor(int color)
Definition layout.hh:394
void moveToWidget(Widget *newWidgetAtPoint, ButtonState state)
Definition layout.cc:1152
void setBgImage(style::StyleImage *bgImage, style::BackgroundRepeat bgRepeat, style::BackgroundAttachment bgAttachment, style::Length bgPositionX, style::Length bgPositionY)
Definition layout.cc:838
void connect(Receiver *receiver)
Definition layout.hh:425
void moveOutOfView(ButtonState state)
Emit the necessary crossing events, when the mouse pointer has moved out of the view.
Definition layout.hh:208
bool emitLinkClick(Widget *w, int link, int img, int x, int y, EventButton *event)
Definition layout.hh:272
style::StyleImage * getBgImage()
Definition layout.hh:443
bool emitLinkPress(Widget *w, int link, int img, int x, int y, EventButton *event)
Definition layout.hh:264
bool getUsesViewport()
Definition layout.hh:284
void adjustScrollPos()
Definition layout.cc:631
int sizeAllocateCounter
Definition layout.hh:248
void copySelection(const char *text)
Definition layout.hh:415
int getScrollPosX()
Definition layout.hh:287
char * textToUpper(const char *text, int len)
Definition layout.hh:354
FindtextState findtextState
Definition layout.hh:188
Platform * platform
Definition layout.hh:155
bool buttonRelease(View *view, int numPressed, int x, int y, ButtonState state, int button)
This function is called by a view, to delegate a button press event.
Definition layout.hh:328
style::Color * bgColor
Definition layout.hh:161
void enterResizeIdle()
Definition layout.hh:251
style::BackgroundRepeat bgRepeat
Definition layout.hh:163
void scrollTo0(HPosition hpos, VPosition vpos, int x, int y, int width, int height, bool scrollingInterrupted)
Definition layout.cc:544
Widget * widgetAtPoint
Definition layout.hh:157
void removeWidget()
Definition layout.cc:405
char * textToLower(const char *text, int len)
Definition layout.hh:359
int getExtremesCounter
Definition layout.hh:249
Widget * topLevel
Definition layout.hh:157
void removeAnchor(Widget *widget, char *name)
Definition layout.cc:783
style::BackgroundAttachment bgAttachment
Definition layout.hh:164
static bool calcScrollInto(int targetValue, int requestedSize, int *value, int viewportSize)
Definition layout.cc:644
int scrollTargetHeight
Definition layout.hh:177
void scrollPosChanged(View *view, int x, int y)
Definition layout.cc:1306
int resizeIdleCounter
Definition layout.hh:248
int getHeightViewport()
Definition layout.hh:286
ui::ResourceFactory * getResourceFactory()
Definition layout.hh:420
void scrollTo(HPosition hpos, VPosition vpos, int x, int y, int width, int height)
Scrolls all viewports, so that the region [x, y, width, height] is seen, according to hpos and vpos.
Definition layout.cc:538
void scroll(ScrollCommand)
Definition layout.cc:528
int prevGlyph(const char *text, int idx)
Definition layout.hh:369
style::Length bgPositionX
Definition layout.hh:165
bool buttonPress(View *view, int numPressed, int x, int y, ButtonState state, int button)
This function is called by a view, to delegate a button press event.
Definition layout.hh:314
style::Length bgPositionY
Definition layout.hh:165
int hScrollbarThickness
Definition layout.hh:173
char * requestedAnchor
Definition layout.hh:179
int currVScrollbarThickness()
Definition layout.cc:728
Emitter emitter
Definition layout.hh:143
void connectLink(LinkReceiver *receiver)
Definition layout.hh:258
void setAnchor(const char *anchor)
Sets the anchor to scroll to.
Definition layout.cc:737
bool canvasHeightGreater
Definition layout.hh:172
void queueResize(bool extremesChanged)
Definition layout.cc:1026
LayoutImgRenderer * layoutImgRenderer
Definition layout.hh:39
void leaveResizeIdle()
Definition layout.hh:252
Base class for all mouse events related to a specific position.
Definition events.hh:49
An interface to encapsulate some platform dependencies.
Definition platform.hh:17
virtual float dpiX()=0
Return screen resolution in x-direction.
virtual int textWidth(style::Font *font, const char *text, int len)=0
Return the width of a text, with a given length and font.
virtual ui::ResourceFactory * getResourceFactory()=0
...
virtual int nextGlyph(const char *text, int idx)=0
Return the index of the next glyph in string text.
virtual style::Tooltip * createTooltip(const char *text)=0
Create a tooltip.
virtual void copySelection(const char *text)=0
Copy selected text (0-terminated).
virtual char * textToUpper(const char *text, int len)=0
Return the string resulting from transforming text to uppercase.
virtual style::Color * createColor(int color)=0
Create a color resource for a given 0xrrggbb value.
virtual char * textToLower(const char *text, int len)=0
Return the string resulting from transforming text to lowercase.
virtual void cancelTooltip()=0
Cancel a tooltip (either shown or requested)
virtual float dpiY()=0
Return screen resolution in y-direction.
virtual style::Font * createFont(style::FontAttrs *attrs, bool tryEverything)=0
Create a (platform dependent) font.
virtual int prevGlyph(const char *text, int idx)=0
Return the index of the previous glyph in string text.
virtual Imgbuf * createImgbuf(Imgbuf::Type type, int width, int height, double gamma)=0
Create a (platform speficic) image buffer.
virtual bool fontExists(const char *name)=0
dw::core::Shape implemtation for simple rectangles.
Definition types.hh:70
This class handles selections, as well as activation of links, which is closely related.
Definition selection.hh:179
An interface to encapsulate platform dependent drawing.
Definition view.hh:17
The base class of all dillo widgets.
Definition widget.hh:44
Useful (but not mandatory) base class for updates of areas with background images.
Definition style.hh:815
A factory for the common resource.
Definition ui.hh:581
Typed version of container::untyped::Vector.
Definition container.hh:447
A simple allocator optimized to handle many small chunks of memory.
Definition misc.hh:631
This is the base class for many other classes, which defines very common virtual methods.
Definition object.hh:25
The base class for signal emitters.
Definition signal.hh:213
void connect(Receiver *receiver)
Connect a receiver to the emitter.
Definition signal.cc:65
The base class for signal receiver base classes.
Definition signal.hh:254
#define DBG_OBJ_ENTER(aspect, prio, funname, fmt,...)
#define DBG_OBJ_LEAVE()
int Length
Type for representing all lengths within dw::core::style.
Definition style.hh:429
ButtonState
Platform independent representation.
Definition events.hh:15
VPosition
Definition types.hh:26
HPosition
Definition types.hh:16
ScrollCommand
Definition types.hh:35
Dw is in this namespace, or sub namespaces of this one.