26#include "../lout/msg.h"
27#include "../lout/debug.hh"
28#include "../lout/misc.hh"
46 getRefArea (x, y, width, height);
55 - (
layout->canvasHeightGreater ?
56 layout->vScrollbarThickness : 0),
59 -
layout->hScrollbarThickness,
76 return layout->bgAttachment;
81 return layout->bgPositionX;
86 return layout->bgPositionY;
91 layout->queueDraw (x, y, width, height);
107 int signalNo,
int argc,
113 case CANVAS_SIZE_CHANGED:
115 ((
Integer*)argv[1])->getValue (),
116 ((
Integer*)argv[2])->getValue ());
133 Object *argv[1] = { &ec };
134 emitVoid (RESIZE_QUEUED, 1, argv);
138 int ascent,
int descent)
140 Integer w (width), a (ascent), d (descent);
141 Object *argv[3] = { &w, &a, &d };
142 emitVoid (CANVAS_SIZE_CHANGED, 3, argv);
174 int signalNo,
int argc,
182 ((
Integer*)argv[1])->getValue (),
183 ((
Integer*)argv[2])->getValue (),
184 ((
Integer*)argv[3])->getValue (),
185 ((
Integer*)argv[4])->getValue ());
189 ((
Integer*)argv[1])->getValue (),
190 ((
Integer*)argv[2])->getValue (),
191 ((
Integer*)argv[3])->getValue (),
192 ((
Integer*)argv[4])->getValue (),
197 ((
Integer*)argv[1])->getValue (),
198 ((
Integer*)argv[2])->getValue (),
199 ((
Integer*)argv[3])->getValue (),
200 ((
Integer*)argv[4])->getValue (),
205 ((
Integer*)argv[1])->getValue (),
206 ((
Integer*)argv[2])->getValue (),
207 ((
Integer*)argv[3])->getValue (),
208 ((
Integer*)argv[4])->getValue (),
220 Integer ilink (link), iimg (img), ix (x), iy (y);
221 Object *argv[5] = { widget, &ilink, &iimg, &ix, &iy };
222 return emitBool (ENTER, 5, argv);
228 Integer ilink (link), iimg (img), ix (x), iy (y);
229 Object *argv[6] = { widget, &ilink, &iimg, &ix, &iy,
event };
230 return emitBool (PRESS, 6, argv);
236 Integer ilink (link), iimg (img), ix (x), iy (y);
237 Object *argv[6] = { widget, &ilink, &iimg, &ix, &iy,
event };
238 return emitBool (RELEASE, 6, argv);
244 Integer ilink (link), iimg (img), ix (x), iy (y);
245 Object *argv[6] = { widget, &ilink, &iimg, &ix, &iy,
event };
246 return emitBool (CLICK, 6, argv);
291 new container::typed::HashTable <object::String, Anchor> (
true,
true);
462 MSG_ERR(
"attachView: Multiple views for layout!\n");
513 if (this->view !=
view) {
514 MSG_ERR(
"detachView: this->view: %p view %p\n",
515 (
void *) this->view, (
void *)
view);
540 int x,
int y,
int width,
int height)
542 scrollTo0 (hpos, vpos, x, y, width, height,
true);
546 int x,
int y,
int width,
int height,
547 bool scrollingInterrupted)
550 _MSG(
"scrollTo (%d, %d, %s)\n",
551 x, y, scrollingInterrupted ?
"true" :
"false");
572 bool xChanged =
true;
596 bool yChanged =
true;
620 if (xChanged || yChanged) {
646 int *value,
int viewportSize)
648 if (requestedSize > viewportSize) {
653 if (*value >= requestedValue &&
654 *value + viewportSize < requestedValue + requestedSize)
657 requestedSize = viewportSize;
660 if (requestedValue < *value) {
661 *value = requestedValue;
663 }
else if (requestedValue + requestedSize > *value + viewportSize) {
664 *value = requestedValue - viewportSize + requestedSize;
675 Rectangle widgetArea, intersection, widgetDrawArea;
740 _MSG(
"setAnchor (%s)\n", anchor);
779 assert (anchor->
widget == widget);
799 if (anchor == NULL) {
812 if (
cursor != this->cursor) {
851 this->bgImage->
unref ();
888 MSG_ERR(
"Please file a bug report with the complete console output\n");
903 Widget *widget = it.getNext ();
934 DBG_OBJ_MSGF (
"resize", 1,
"toplevel size: %d * (%d + %d)",
946 allocation.
x = allocation.
y = 0;
976 currHThickness, currVThickness);
1005 int ex,
int ey,
int ewidth,
int eheight) {
1007 if (x == ex && y == ey && width == ewidth && height == eheight)
1018 int ix2 =
misc::min (x + width, ex + ewidth);
1019 int iy2 =
misc::min (y + height, ey + eheight);
1022 queueDraw (x, iy2, width, y + height - iy2);
1024 queueDraw (ix2, iy1, x + width - ix2, iy2 - iy1);
1030 extremesChanged ?
"true" :
"false");
1057 event.state = state;
1058 event.button = button;
1059 event.numPressed = numPressed;
1078 event.state = state;
1097 event.state = state;
1098 event.lastWidget = lastWidget;
1119 event.state = state;
1120 event.lastWidget = lastWidget;
1134 DBG_OBJ_ENTER (
"events", 0,
"getWidgetAtPoint",
"%d, %d", x, y);
1156 newWidgetAtPoint, state);
1160 int trackLen, i, i_a;
1170 else if (newWidgetAtPoint)
1182 if (newWidgetAtPoint)
1184 for (w = newWidgetAtPoint; w != ancestor; w = w->
getParent ())
1187 track =
new Widget* [trackLen];
1194 track[i++] = ancestor;
1195 if (newWidgetAtPoint) {
1198 for (w = newWidgetAtPoint; w != ancestor; w = w->
getParent ())
1203 for (i = 0; i < trackLen; i++)
1204 MSG(
"%s%p ", i == i_a ?
">" :
"", track[i]);
1205 MSG(
"] %s\n", newWidgetAtPoint ?
"" :
"nil");
1209 for (i = 0; i < trackLen; i++) {
1210 crossingEvent.
state = state;
1215 }
else if (i == i_a) {
1219 if (i_a == trackLen-1 && !newWidgetAtPoint)
1222 (i_a == trackLen-1 && newWidgetAtPoint))
1260 event->xCanvas = maxX;
1269 event->yCanvas = maxY;
1274 for (; widget; widget = widget->
getParent ()) {
1324 DBG_OBJ_ENTER (
"resize", 0,
"viewportSizeChanged",
"%p, %d, %d",
1325 view, width, height);
Set at the top when drawing.
Represents a enter or leave notify event.
Represents a mouse motion event.
void setWidget(Widget *widget)
Set at the top when getting the widget at the point.
Iterators are used to iterate through the contents of a widget.
virtual void unref()
Delete the iterator.
virtual bool next()=0
Move iterator forward and store content it.
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.
void emitResizeQueued(bool extremesChanged)
void emitCanvasSizeChanged(int width, int ascent, int descent)
void draw(int x, int y, int width, int height)
Draw (or queue for drawing) an area, which is given in canvas coordinates.
void getBgArea(int *x, int *y, int *width, int *height)
Return the area covered by the background image.
style::BackgroundRepeat getBackgroundRepeat()
style::BackgroundAttachment getBackgroundAttachment()
void getRefArea(int *xRef, int *yRef, int *widthRef, int *heightRef)
Return the "reference area".
style::Length getBackgroundPositionX()
style::Length getBackgroundPositionY()
style::StyleImage * getBackgroundImage()
bool readyToDraw()
If this method returns false, nothing is done at all.
bool emitEnter(Widget *widget, int link, int img, int x, int y)
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.
bool emitPress(Widget *widget, int link, int img, int x, int y, EventButton *event)
bool emitRelease(Widget *widget, int link, int img, int x, int y, EventButton *event)
bool emitClick(Widget *widget, int link, int img, int x, int y, EventButton *event)
virtual bool click(Widget *widget, int link, int img, int x, int y, EventButton *event)
Called, when the user has clicked on a link.
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).
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.
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.
Receiver interface different signals.
virtual void resizeQueued(bool extremesChanged)
virtual void canvasSizeChanged(int width, int ascent, int descent)
void attachView(View *view)
Attach a view to the layout.
lout::misc::ZoneAllocator * textZone
void changeAnchor(Widget *widget, char *name, int y)
void detachWidget(Widget *widget)
int currHScrollbarThickness()
bool emitLinkRelease(Widget *w, int link, int img, int x, int y, EventButton *event)
void setCursor(style::Cursor cursor)
void enterNotify(View *view, int x, int y, ButtonState state)
This function is called by a view, to delegate a enter notify event.
void queueDraw(int x, int y, int width, int height)
bool scrollIdleNotInterrupted
Widget * getWidgetAtPoint(int x, int y)
void containerSizeChanged()
bool motionNotify(View *view, int x, int y, ButtonState state)
This function is called by a view, to delegate a motion notify event.
Layout(Platform *platform, bool limit=true)
void setWidget(Widget *widget)
bool processMouseEvent(MousePositionEvent *event, ButtonEventType type)
Common processing of press, release and motion events.
style::StyleImage * bgImage
void setBgColor(style::Color *color)
void detachView(View *view)
void moveToWidgetAtPoint(int x, int y, ButtonState state)
Emit the necessary crossing events, when the mouse pointer has moved to position (x,...
char * addAnchor(Widget *widget, const char *name)
Used, when the widget is not allocated yet.
void leaveNotify(View *view, ButtonState state)
This function is called by a view, to delegate a leave notify event.
lout::container::typed::HashTable< lout::object::String, Anchor > * anchorsTable
void queueDrawExcept(int x, int y, int width, int height, int ex, int ey, int ewidth, int eheight)
VPosition scrollTargetVpos
void viewportSizeChanged(View *view, int width, int height)
HPosition scrollTargetHpos
lout::container::typed::Vector< Widget > * queueResizeList
void addWidget(Widget *widget)
bool buttonEvent(ButtonEventType type, View *view, int numPressed, int x, int y, ButtonState state, int button)
SelectionState selectionState
void draw(View *view, Rectangle *area)
void moveToWidget(Widget *newWidgetAtPoint, ButtonState state)
void setBgImage(style::StyleImage *bgImage, style::BackgroundRepeat bgRepeat, style::BackgroundAttachment bgAttachment, style::Length bgPositionX, style::Length bgPositionY)
void moveOutOfView(ButtonState state)
Emit the necessary crossing events, when the mouse pointer has moved out of the view.
bool emitLinkPress(Widget *w, int link, int img, int x, int y, EventButton *event)
FindtextState findtextState
style::BackgroundRepeat bgRepeat
void scrollTo0(HPosition hpos, VPosition vpos, int x, int y, int width, int height, bool scrollingInterrupted)
void removeAnchor(Widget *widget, char *name)
style::BackgroundAttachment bgAttachment
static bool calcScrollInto(int targetValue, int requestedSize, int *value, int viewportSize)
void scrollPosChanged(View *view, int x, int y)
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.
void scroll(ScrollCommand)
style::Length bgPositionX
style::Length bgPositionY
int currVScrollbarThickness()
void setAnchor(const char *anchor)
Sets the anchor to scroll to.
void queueResize(bool extremesChanged)
LayoutImgRenderer * layoutImgRenderer
Base class for all mouse events related to a specific position.
dw::core::Shape implemtation for simple rectangles.
bool intersectsWith(Rectangle *otherRect, Rectangle *dest)
Return whether this rectangle and otherRect intersect.
void setLayout(Layout *layout)
See Handling stacking contexts.
An interface to encapsulate platform dependent drawing.
virtual void setViewportSize(int width, int height, int hScrollbarThickness, int vScrollbarThickness)=0
Set the viewport size.
virtual void queueDraw(Rectangle *area)=0
Queue a region, which is given in canvas coordinates, for drawing.
virtual void startDrawing(Rectangle *area)=0
Called before drawing.
virtual int getScrollbarOnLeft()=0
virtual void scroll(ScrollCommand)
Scroll the viewport as commanded.
virtual int getHScrollbarThickness()=0
Get the thickness of the horizontal scrollbar, when it is visible.
virtual void setCanvasSize(int width, int ascent, int descent)=0
Set the canvas size.
virtual void finishDrawing(Rectangle *area)=0
Called after drawing.
virtual void queueDrawTotal()=0
Queue the total viewport for drawing.
virtual void setCursor(style::Cursor cursor)=0
Set the cursor appearance.
virtual bool usesViewport()=0
Return, whether this view uses a viewport.
virtual int getVScrollbarThickness()=0
Get the thickness of the vertical scrollbar, when it is visible.
virtual void setBgColor(style::Color *color)=0
Set the background of the view.
virtual void cancelQueueDraw()=0
Cancel a draw queue request.
virtual void scrollTo(int x, int y)=0
Scroll the vieport to the given position.
virtual void setLayout(Layout *layout)=0
This methods notifies the view, that it has been attached to a layout.
void putExternalImgRenderer(ImgRenderer *ir)
Add an additional ImgRenderer, especially used for drawing.
void removeExternalImgRenderer(ImgRenderer *ir)
Remove a previously added additional ImgRenderer.
Typed version of container::untyped::Vector.
A simple allocator optimized to handle many small chunks of memory.
An object::Object wrapper for bool's.
An object::Object wrapper for int's.
This is the base class for many other classes, which defines very common virtual methods.
An object::Object wrapper for strings (char*).
The base class for signal receiver base classes.
#define DBG_OBJ_ENTER0(aspect, prio, funname)
#define DBG_OBJ_CREATE(klass)
#define DBG_OBJ_SET_SYM(var, val)
#define DBG_OBJ_MSGF(aspect, prio, fmt,...)
#define DBG_OBJ_SET_NUM(var, val)
#define DBG_OBJ_ENTER(aspect, prio, funname, fmt,...)
#define DBG_OBJ_ASSOC(parent, child)
#define DBG_OBJ_ASSOC_CHILD(child)
#define DBG_OBJ_SET_PTR_O(obj, var, val)
char * dStrdup(const char *s)
void drawBackgroundImage(View *view, StyleImage *backgroundImage, BackgroundRepeat backgroundRepeat, BackgroundAttachment backgroundAttachment, Length backgroundPositionX, Length backgroundPositionY, int x, int y, int width, int height, int xRef, int yRef, int widthRef, int heightRef)
int Length
Type for representing all lengths within dw::core::style.
ButtonState
Platform independent representation.
Dw is in this namespace, or sub namespaces of this one.
This namespace contains a framework for container classes, which members are instances of object::Obj...
Here, some common classes (or interfaces) are defined, to standardize the access to other classes.
Represents the allocation, i.e.
@ WIDGET_IN_FLOW
widget in normal flow, so that this widget (containing this content) is both container (parent) and g...
@ WIDGET_OOF_CONT
widget out of flow (OOF); this widget (containing this content) is only the container (parent),...