26#include "../lout/msg.h"
27#include "../lout/misc.hh"
28#include "../lout/debug.hh"
42 delete shapesAndLinks;
48 container::typed::Iterator <ShapeAndLink> it;
50 for (it = shapesAndLinks->iterator (); it.
hasNext (); ) {
53 shapeAndLink->
shape->
draw(view, style, x, y);
59 shapeAndLink->
shape = shape;
61 shapesAndLinks->append (shapeAndLink);
65 container::typed::Iterator <ShapeAndLink> it;
66 int link = defaultLink;
68 for (it = shapesAndLinks->iterator (); it.
hasNext (); ) {
82 imageMaps =
new container::typed::HashTable <object::Object, ImageMap>
130 map->
draw(view, style, x, y);
151 registerName (
"dw::Image", &CLASS_ID);
152 this->altText = altText ?
dStrdup (altText) : NULL;
155 bufWidth = bufHeight = -1;
182 DEBUG_MSG(1,
"-- Image::sizeRequestSimpl() begins\n");
184 DEBUG_MSG(1,
"Image::sizeRequestImpl border: w=%d h=%d\n",
185 boxDiffWidth(), boxDiffHeight());
190 requisition->
width = buffer->getRootWidth ();
191 requisition->
ascent = buffer->getRootHeight ();
194 if (altText && altText[0]) {
195 if (altTextWidth == -1)
197 layout->textWidth (getStyle()->font, altText, strlen (altText));
199 requisition->
width = altTextWidth;
200 requisition->
ascent = getStyle()->font->ascent;
201 requisition->
descent = getStyle()->font->descent;
203 requisition->
width = 0;
209 requisition->
width += boxDiffWidth ();
210 requisition->
ascent += boxOffsetY ();
211 requisition->
descent += boxRestHeight ();
213 DEBUG_MSG(1,
"Image: initial requisition (with border): w=%d, h=%d\n",
223 DEBUG_MSG(1,
"Image: corrected requisition: w=%d, h=%d\n",
235 contentWidth = buffer->getRootWidth ();
237 if (altText && altText[0]) {
238 if (altTextWidth == -1)
240 layout->textWidth (getStyle()->font, altText, strlen (altText));
241 contentWidth = altTextWidth;
246 int width = contentWidth + boxDiffWidth ();
258 correctExtremes (extremes,
false);
266 DBG_OBJ_ENTER (
"resize", 0,
"sizeAllocateImpl",
"%d, %d; %d * (%d + %d)",
267 allocation->
x, allocation->
y, allocation->
width,
270 DEBUG_MSG(1,
"Image::sizeAllocateImpl x=%d y=%d w=%d h=(%d + %d)\n",
271 allocation->
x, allocation->
y, allocation->
width,
274 DEBUG_MSG(1,
"Image::sizeAllocateImpl border: w=%d h=%d\n",
275 boxDiffWidth(), boxDiffHeight());
278 int newBufWidth = allocation->
width - boxDiffWidth ();
282 if (buffer && newBufWidth > 0 && newBufHeight > 0 &&
284 (newBufWidth != bufWidth || newBufHeight != bufHeight)) {
287 DEBUG_MSG(1,
"Image::sizeAllocateImpl new buffer size: w=%d h=%d\n",
288 newBufWidth, newBufHeight);
291 buffer = oldBuffer->
getScaledBuf (newBufWidth, newBufHeight);
294 bufWidth = newBufWidth;
295 bufHeight = newBufHeight;
302 DEBUG_MSG(1,
"Image::sizeAllocateImpl x=%d y=%d w=%d h=(%d + %d)\n",
303 allocation->
x, allocation->
y, allocation->
width,
319 currLink = getStyle()->x_link;
321 if (currLink != -1) {
322 (void)
layout->emitLinkEnter (
this, currLink, -1, -1, -1);
324 Widget::enterNotifyImpl(event);
331 if (currLink != -1) {
333 (void)
layout->emitLinkEnter (
this, -1, -1, -1, -1);
335 Widget::leaveNotifyImpl(event);
345 int ret =
event->xWidget - boxOffsetX();
353 int ret =
event->yWidget - boxOffsetY();
361 if (mapList || isMap) {
362 int x = contentX(event);
363 int y = contentY(event);
367 int newLink = mapList->link (mapKey, x, y);
368 if (newLink != currLink) {
372 setCursor(newLink == -1 ? getStyle()->cursor :
374 (void)
layout->emitLinkEnter (
this, newLink, -1, -1, -1);
376 }
else if (isMap && currLink != -1) {
378 (void)
layout->emitLinkEnter (
this, currLink, -1, x, y);
388 currLink = mapList ? mapList->link(mapKey,contentX(event),contentY(event)) :
391 (void)
layout->emitLinkPress(
this, currLink, getStyle()->x_img, -1, -1,
394 }
else if (event->
button == 1 || currLink != -1){
403 currLink = mapList ? mapList->link(mapKey,contentX(event),contentY(event)) :
406 int x = isMap ? contentX(event) : -1;
407 int y = isMap ? contentY(event) : -1;
409 layout->emitLinkClick (
this, currLink, getStyle()->x_img, x, y, event);
421 drawWidgetBox (view, area,
false);
428 content.
width = getContentWidth ();
429 content.
height = getContentHeight ();
433 allocation.x + dx, allocation.y + dy,
434 intersection.
x - dx, intersection.
y - dy,
439 if (altText && altText[0]) {
444 if (altTextWidth == -1)
446 layout->textWidth (getStyle()->font, altText, strlen (altText));
448 if ((getContentWidth() < altTextWidth) ||
449 (getContentHeight() <
450 getStyle()->font->ascent + getStyle()->font->descent)) {
451 clippingView = usedView =
453 allocation.y + boxOffsetY (),
460 allocation.x + boxOffsetX (),
461 allocation.y + boxOffsetY (),
462 getContentWidth(), getContentHeight(), altText);
469 allocation.y + boxOffsetY (),
472 mapList->drawMap(mapKey, clippingView, getStyle(),
473 allocation.x + boxOffsetX (),
474 allocation.y + boxOffsetY ());
493 if (wasAllocated () && needsResize () &&
494 getContentWidth () > 0 && getContentHeight () > 0) {
498 bufWidth = getContentWidth ();
499 bufHeight = getContentHeight ();
500 this->buffer = buffer->
getScaledBuf (bufWidth, bufHeight);
502 this->buffer = buffer;
507 queueResize (0,
true);
510 this->ratio = (float) bufWidth / (
float) bufHeight;
524 assert (buffer != NULL);
526 buffer->getRowArea (row, &area);
528 queueDrawArea (area.
x + boxOffsetX (), area.
y + boxOffsetY (), area.
width,
562 if (mapKey && mapKey != key)
void setDefaultLink(int link)
void add(core::Shape *shape, int link)
void draw(core::View *view, core::style::Style *style, int x, int y)
lout::container::typed::List< ShapeAndLink > * shapesAndLinks
Represents a list of client-side image maps.
void drawMap(lout::object::Object *key, core::View *view, core::style::Style *style, int x, int y)
void addShapeToCurrentMap(core::Shape *shape, int link)
Add a shape to the current map-.
void startNewMap(lout::object::Object *key)
Start a new map and make it the current one.
lout::container::typed::HashTable< lout::object::Object, ImageMap > * imageMaps
void setCurrentMapDefaultLink(int link)
Set default link for current map-.
int link(lout::object::Object *key, int x, int y)
void setIsMap()
Sets image as server side image map.
void setUseMap(ImageMapsList *list, Object *key)
Sets image as client side image map.
core::Iterator * iterator(core::Content::Type mask, bool atEnd)
Return an iterator for this widget.
int contentY(core::MousePositionEvent *event)
void finish()
Called, when all image data has been retrieved.
void drawRow(int row)
Called, when data from a row is available and has been copied into the image buffer.
Image(const char *altText)
void sizeAllocateImpl(core::Allocation *allocation)
See Sizes of Dillo Widgets.
bool buttonReleaseImpl(core::EventButton *event)
void sizeRequestSimpl(core::Requisition *requisition)
Simple variant, to be implemented by widgets with sizes not depending on positions.
void containerSizeChangedForChildren()
bool buttonPressImpl(core::EventButton *event)
void fatal()
Called, when there are problems with the retrieval of image data.
int contentX(core::MousePositionEvent *event)
void getExtremesSimpl(core::Extremes *extremes)
Simple variant, to be implemented by widgets with extremes not depending on positions.
void setBuffer(core::Imgbuf *buffer, bool resize=false)
Called, when an image buffer is attached.
void enterNotifyImpl(core::EventCrossing *event)
void leaveNotifyImpl(core::EventCrossing *event)
bool motionNotifyImpl(core::EventMotion *event)
void draw(core::View *view, core::Rectangle *area, core::DrawingContext *context)
Area is given in widget coordinates.
Set at the top when drawing.
This implementation of dw::core::Iterator can be used by widgets with no contents.
Represents a enter or leave notify event.
Represents a mouse motion event.
The platform independent interface for image buffers.
virtual int getRootWidth()=0
virtual Imgbuf * getScaledBuf(int width, int height)=0
virtual int getRootHeight()=0
Iterators are used to iterate through the contents of a widget.
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.
Abstract interface for different shapes.
virtual bool isPointWithin(int x, int y)=0
virtual void draw(core::View *view, core::style::Style *style, int x, int y)=0
An interface to encapsulate platform dependent drawing.
virtual void mergeClippingView(View *clippingView)=0
virtual void drawImage(Imgbuf *imgbuf, int xRoot, int yRoot, int x, int y, int width, int height)=0
virtual void drawSimpleWrappedText(style::Font *font, style::Color *color, style::Color::Shading shading, int x, int y, int w, int h, const char *text)=0
virtual View * getClippingView(int x, int y, int width, int height)=0
This is the base class for many other classes, which defines very common virtual methods.
#define DEBUG_MSG(level,...)
#define DBG_OBJ_ENTER0(aspect, prio, funname)
#define DBG_OBJ_CREATE(klass)
#define DBG_OBJ_MSGF(aspect, prio, fmt,...)
#define DBG_OBJ_SET_NUM(var, val)
#define DBG_OBJ_MSG(aspect, prio, msg)
#define DBG_OBJ_ENTER(aspect, prio, funname, fmt,...)
#define DBG_OBJ_ASSOC_CHILD(child)
char * dStrdup(const char *s)
bool isPerLength(Length l)
Returns true if l is a percentage.
void splitHeightPreserveDescent(int height, int *ascent, int *descent)
Dw is in this namespace, or sub namespaces of this one.
The DilloImage data-structure and methods.
Represents the allocation, i.e.