Dillo v3.1.1-98-g318d1f14
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
251
254
255public:
256 Layout (Platform *platform, bool limit=true);
257 ~Layout ();
258
259 inline void connectLink (LinkReceiver *receiver)
260 { linkEmitter.connectLink (receiver); }
261
262 inline bool emitLinkEnter (Widget *w, int link, int img, int x, int y)
263 { return linkEmitter.emitEnter (w, link, img, x, y); }
264
265 inline bool emitLinkPress (Widget *w, int link, int img,
266 int x, int y, EventButton *event)
267 { return linkEmitter.emitPress (w, link, img, x, y, event); }
268
269 inline bool emitLinkRelease (Widget *w, int link, int img,
270 int x, int y, EventButton *event)
271 { return linkEmitter.emitRelease (w, link, img, x, y, event); }
272
273 inline bool emitLinkClick (Widget *w, int link, int img,
274 int x, int y, EventButton *event)
275 { return linkEmitter.emitClick (w, link, img, x, y, event); }
276
278
279 void addWidget (Widget *widget);
280 void setWidget (Widget *widget);
281
282 void attachView (View *view);
283 void detachView (View *view);
284
285 inline bool getUsesViewport () { return usesViewport; }
286 inline int getWidthViewport () { return viewportWidth; }
287 inline int getHeightViewport () { return viewportHeight; }
288 inline int getScrollPosX () { return scrollX; }
289 inline int getScrollPosY () { return scrollY; }
290
291 /* public */
292
293 void scrollTo (HPosition hpos, VPosition vpos,
294 int x, int y, int width, int height);
295 void scroll (ScrollCommand);
296 void setAnchor (const char *anchor);
297
298 /* View */
299
300 inline void expose (View *view, Rectangle *area) {
301 DBG_OBJ_ENTER ("draw", 0, "expose", "%d, %d, %d * %d",
302 area->x, area->y, area->width, area->height);
303 draw (view, area);
304 DBG_OBJ_LEAVE ();
305 }
306
315 inline bool buttonPress (View *view, int numPressed, int x, int y,
316 ButtonState state, int button)
317 {
318 return buttonEvent (BUTTON_PRESS, view, numPressed, x, y, state, button);
319 }
320
321 void containerSizeChanged ();
322
329 inline bool buttonRelease (View *view, int numPressed, int x, int y,
330 ButtonState state, int button)
331 {
332 return buttonEvent (BUTTON_RELEASE, view, numPressed, x, y, state,
333 button);
334 }
335
336 bool motionNotify (View *view, int x, int y, ButtonState state);
337 void enterNotify (View *view, int x, int y, ButtonState state);
338 void leaveNotify (View *view, ButtonState state);
339
340 void scrollPosChanged (View *view, int x, int y);
341 void viewportSizeChanged (View *view, int width, int height);
342
344 {
345 return platform;
346 }
347
348 /* delegated */
349
350 inline int textWidth (style::Font *font, const char *text, int len)
351 {
352 return platform->textWidth (font, text, len);
353 }
354
355 inline char *textToUpper (const char *text, int len)
356 {
357 return platform->textToUpper (text, len);
358 }
359
360 inline char *textToLower (const char *text, int len)
361 {
362 return platform->textToLower (text, len);
363 }
364
365 inline int nextGlyph (const char *text, int idx)
366 {
367 return platform->nextGlyph (text, idx);
368 }
369
370 inline int prevGlyph (const char *text, int idx)
371 {
372 return platform->prevGlyph (text, idx);
373 }
374
375 inline float dpiX ()
376 {
377 return platform->dpiX ();
378 }
379
380 inline float dpiY ()
381 {
382 return platform->dpiY ();
383 }
384
385 inline style::Font *createFont (style::FontAttrs *attrs, bool tryEverything)
386 {
387 return platform->createFont (attrs, tryEverything);
388 }
389
390 inline bool fontExists (const char *name)
391 {
392 return platform->fontExists (name);
393 }
394
395 inline style::Color *createColor (int color)
396 {
397 return platform->createColor (color);
398 }
399
400 inline style::Tooltip *createTooltip (const char *text)
401 {
402 return platform->createTooltip (text);
403 }
404
405 inline void cancelTooltip ()
406 {
407 return platform->cancelTooltip ();
408 }
409
410 inline Imgbuf *createImgbuf (Imgbuf::Type type, int width, int height,
411 double gamma)
412 {
413 return platform->createImgbuf (type, width, height, gamma);
414 }
415
416 inline void copySelection(const char *text)
417 {
418 platform->copySelection(text);
419 }
420
425
426 inline void connect (Receiver *receiver) {
427 emitter.connectLayout (receiver); }
428
430 inline FindtextState::Result search (const char *str, bool caseSens,
431 int backwards)
432 { return findtextState.search (str, caseSens, backwards); }
433
435 inline void resetSearch () { findtextState.resetSearch (); }
436
437 void setBgColor (style::Color *color);
442
443 inline style::Color* getBgColor () { return bgColor; }
444 inline style::StyleImage* getBgImage () { return bgImage; }
445};
446
447} // namespace core
448} // namespace dw
449
450#endif // __DW_LAYOUT_HH__
451
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:390
void attachView(View *view)
Attach a view to the layout.
Definition layout.cc:459
lout::misc::ZoneAllocator * textZone
Definition layout.hh:277
void changeAnchor(Widget *widget, char *name, int y)
Definition layout.cc:774
void detachWidget(Widget *widget)
Definition layout.cc:351
int currHScrollbarThickness()
Definition layout.cc:724
int getScrollPosY()
Definition layout.hh:289
style::Cursor cursor
Definition layout.hh:167
void updateAnchor()
Definition layout.cc:790
bool emitLinkRelease(Widget *w, int link, int img, int x, int y, EventButton *event)
Definition layout.hh:269
FindtextState::Result search(const char *str, bool caseSens, int backwards)
See dw::core::FindtextState::search.
Definition layout.hh:430
void setCursor(style::Cursor cursor)
Definition layout.cc:810
void scrollIdle()
Definition layout.cc:570
void resetSearch()
See dw::core::FindtextState::resetSearch.
Definition layout.hh:435
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:1088
style::Font * createFont(style::FontAttrs *attrs, bool tryEverything)
Definition layout.hh:385
void queueDraw(int x, int y, int width, int height)
Definition layout.cc:991
bool scrollIdleNotInterrupted
Definition layout.hh:181
Widget * getWidgetAtPoint(int x, int y)
Definition layout.cc:1132
int scrollTargetWidth
Definition layout.hh:177
void containerSizeChanged()
Definition layout.cc:1344
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:1070
bool drawAfterScrollReq
Definition layout.hh:170
void cancelTooltip()
Definition layout.hh:405
void setWidget(Widget *widget)
Definition layout.cc:433
int textWidth(style::Font *font, const char *text, int len)
Definition layout.hh:350
bool processMouseEvent(MousePositionEvent *event, ButtonEventType type)
Common processing of press, release and motion events.
Definition layout.cc:1244
style::StyleImage * bgImage
Definition layout.hh:162
void setBgColor(style::Color *color)
Definition layout.cc:826
void detachView(View *view)
Definition layout.cc:511
style::Color * getBgColor()
Definition layout.hh:443
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:751
void leaveNotify(View *view, ButtonState state)
This function is called by a view, to delegate a leave notify event.
Definition layout.cc:1109
int getWidthViewport()
Definition layout.hh:286
void expose(View *view, Rectangle *area)
Definition layout.hh:300
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:1004
int nextGlyph(const char *text, int idx)
Definition layout.hh:365
VPosition scrollTargetVpos
Definition layout.hh:176
void viewportSizeChanged(View *view, int width, int height)
Definition layout.cc:1322
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:343
LinkEmitter linkEmitter
Definition layout.hh:124
void addWidget(Widget *widget)
Definition layout.cc:371
Imgbuf * createImgbuf(Imgbuf::Type type, int width, int height, double gamma)
Definition layout.hh:410
int queueResizeCounter
Definition layout.hh:248
style::Tooltip * createTooltip(const char *text)
Definition layout.hh:400
bool buttonEvent(ButtonEventType type, View *view, int numPressed, int x, int y, ButtonState state, int button)
Definition layout.cc:1047
SelectionState selectionState
Definition layout.hh:187
void updateCursor()
Definition layout.cc:818
bool emitLinkEnter(Widget *w, int link, int img, int x, int y)
Definition layout.hh:262
void resizeIdle()
Definition layout.cc:870
void draw(View *view, Rectangle *area)
Definition layout.cc:670
style::Color * createColor(int color)
Definition layout.hh:395
void moveToWidget(Widget *newWidgetAtPoint, ButtonState state)
Definition layout.cc:1153
void setBgImage(style::StyleImage *bgImage, style::BackgroundRepeat bgRepeat, style::BackgroundAttachment bgAttachment, style::Length bgPositionX, style::Length bgPositionY)
Definition layout.cc:839
void connect(Receiver *receiver)
Definition layout.hh:426
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:273
style::StyleImage * getBgImage()
Definition layout.hh:444
bool emitLinkPress(Widget *w, int link, int img, int x, int y, EventButton *event)
Definition layout.hh:265
bool getUsesViewport()
Definition layout.hh:285
void adjustScrollPos()
Definition layout.cc:632
int sizeAllocateCounter
Definition layout.hh:248
void copySelection(const char *text)
Definition layout.hh:416
int getScrollPosX()
Definition layout.hh:288
char * textToUpper(const char *text, int len)
Definition layout.hh:355
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:329
style::Color * bgColor
Definition layout.hh:161
void enterResizeIdle()
Definition layout.hh:252
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:545
Widget * widgetAtPoint
Definition layout.hh:157
void removeWidget()
Definition layout.cc:406
char * textToLower(const char *text, int len)
Definition layout.hh:360
int getExtremesCounter
Definition layout.hh:249
Widget * topLevel
Definition layout.hh:157
void removeAnchor(Widget *widget, char *name)
Definition layout.cc:784
style::BackgroundAttachment bgAttachment
Definition layout.hh:164
static bool calcScrollInto(int targetValue, int requestedSize, int *value, int viewportSize)
Definition layout.cc:645
int scrollTargetHeight
Definition layout.hh:177
void scrollPosChanged(View *view, int x, int y)
Definition layout.cc:1307
int resizeIdleCounter
Definition layout.hh:248
int getHeightViewport()
Definition layout.hh:287
ui::ResourceFactory * getResourceFactory()
Definition layout.hh:421
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:539
void scroll(ScrollCommand)
Definition layout.cc:529
int prevGlyph(const char *text, int idx)
Definition layout.hh:370
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:315
style::Length bgPositionY
Definition layout.hh:165
int hScrollbarThickness
Definition layout.hh:173
char * requestedAnchor
Definition layout.hh:179
int currVScrollbarThickness()
Definition layout.cc:729
Emitter emitter
Definition layout.hh:143
void connectLink(LinkReceiver *receiver)
Definition layout.hh:259
void setAnchor(const char *anchor)
Sets the anchor to scroll to.
Definition layout.cc:738
bool canvasHeightGreater
Definition layout.hh:172
void queueResize(bool extremesChanged)
Definition layout.cc:1027
LayoutImgRenderer * layoutImgRenderer
Definition layout.hh:39
void leaveResizeIdle()
Definition layout.hh:253
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.