23 #include "../lout/msg.h" 24 #include "../lout/misc.hh" 25 #include "../lout/debug.hh" 39 delete shapesAndLinks;
47 for (it = shapesAndLinks->iterator (); it.
hasNext (); ) {
50 shapeAndLink->
shape->
draw(view, style, x, y);
56 shapeAndLink->
shape = shape;
57 shapeAndLink->
link = link;
58 shapesAndLinks->append (shapeAndLink);
63 int link = defaultLink;
65 for (it = shapesAndLinks->iterator (); it.
hasNext (); ) {
69 link = shapeAndLink->
link;
99 imageMaps->put (
key, currentMap);
110 currentMap->add (shape, link);
118 currentMap->setDefaultLink (link);
127 map->
draw(view, style, x, y);
136 link = map->
link (x, y);
148 registerName (
"dw::Image", &CLASS_ID);
149 this->altText = altText ? strdup (altText) : NULL;
176 buffer->getRootWidth () > 0) {
179 requisition->
ascent = buffer->getRootHeight () *
180 requisition->
width / buffer->getRootWidth ();
183 buffer->getRootHeight () > 0) {
186 requisition->
width = buffer->getRootWidth () *
187 requisition->
ascent / buffer->getRootHeight ();
189 requisition->
width = buffer->getRootWidth ();
190 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 += getStyle()->boxDiffWidth ();
210 requisition->
ascent += getStyle()->boxOffsetY ();
211 requisition->
descent += getStyle()->boxRestHeight ();
220 if (allocation->
width == this->allocation.width &&
224 dx = getStyle()->boxDiffWidth ();
225 dy = getStyle()->boxDiffHeight ();
227 MSG(
"boxDiffHeight = %d + %d, buffer=%p\n",
228 getStyle()->boxOffsetY(), getStyle()->boxRestHeight(), buffer);
229 MSG(
"getContentWidth() = allocation.width - style->boxDiffWidth ()" 231 this->allocation.
width, getStyle()->boxDiffWidth(),
232 this->allocation.
width - getStyle()->boxDiffWidth());
233 MSG(
"getContentHeight() = getHeight() - style->boxDiffHeight ()" 234 " = %d - %d = %d\n", this->getHeight(), getStyle()->boxDiffHeight(),
235 this->getHeight() - getStyle()->boxDiffHeight());
238 (allocation->
width - dx > 0 ||
253 currLink = getStyle()->x_link;
255 if (currLink != -1) {
256 (void) layout->emitLinkEnter (
this, currLink, -1, -1, -1);
258 Widget::enterNotifyImpl(event);
265 if (currLink != -1) {
267 (void) layout->emitLinkEnter (
this, -1, -1, -1, -1);
269 Widget::leaveNotifyImpl(event);
279 int ret =
event->xWidget - getStyle()->boxOffsetX();
287 int ret =
event->yWidget - getStyle()->boxOffsetY();
295 if (mapList || isMap) {
296 int x = contentX(event);
297 int y = contentY(event);
301 int newLink = mapList->link (mapKey, x, y);
302 if (newLink != currLink) {
306 setCursor(newLink == -1 ? getStyle()->cursor :
308 (void) layout->emitLinkEnter (
this, newLink, -1, -1, -1);
310 }
else if (isMap && currLink != -1) {
312 (void) layout->emitLinkEnter (
this, currLink, -1, x, y);
322 currLink = mapList ? mapList->link(mapKey,contentX(event),contentY(event)) :
325 (void)layout->emitLinkPress(
this, currLink, getStyle()->x_img, -1, -1,
328 }
else if (event->
button == 1 || currLink != -1){
337 currLink = mapList ? mapList->link(mapKey,contentX(event),contentY(event)) :
340 int x = isMap ? contentX(event) : -1;
341 int y = isMap ? contentY(event) : -1;
343 layout->emitLinkClick (
this, currLink, getStyle()->x_img, x, y, event);
354 drawWidgetBox (view, area,
false);
357 dx = getStyle()->boxOffsetX ();
358 dy = getStyle()->boxOffsetY ();
361 content.
width = getContentWidth ();
362 content.
height = getContentHeight ();
366 allocation.x + dx, allocation.y + dy,
367 intersection.
x - dx, intersection.
y - dy,
372 if (altText && altText[0]) {
377 if (altTextWidth == -1)
379 layout->textWidth (getStyle()->font, altText, strlen (altText));
381 if ((getContentWidth() < altTextWidth) ||
382 (getContentHeight() <
383 getStyle()->font->ascent + getStyle()->font->descent)) {
384 clippingView = usedView =
386 allocation.y + getStyle()->boxOffsetY (),
393 allocation.x + getStyle()->boxOffsetX (),
394 allocation.y + getStyle()->boxOffsetY (),
395 getContentWidth(), getContentHeight(), altText);
402 getStyle()->boxOffsetX (),
404 getStyle()->boxOffsetY (),
407 mapList->drawMap(mapKey, clippingView, getStyle(),
408 allocation.x + getStyle()->boxOffsetX (),
409 allocation.y + getStyle()->boxOffsetY ());
428 if (wasAllocated () && needsResize () &&
429 getContentWidth () > 0 && getContentHeight () > 0) {
433 buffer->
getScaledBuf (getContentWidth (), getContentHeight ());
435 this->buffer = buffer;
438 queueResize (0,
true);
450 assert (buffer != NULL);
452 buffer->getRowArea (row, &area);
454 queueDrawArea (area.
x + getStyle()->boxOffsetX (),
455 area.
y + getStyle()->boxOffsetY (),
489 if (mapKey && mapKey !=
key)