diff options
author | corvid <corvid@lavabit.com> | 2010-03-11 16:47:09 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2010-03-11 16:47:09 +0000 |
commit | 286bfdb1e392ed133642f2e60e6c993102bcbea9 (patch) | |
tree | d856a3a47ced68d8fa7d59447d4592a737cbe3d9 /dw/types.cc | |
parent | 6697c42e7393ce469e8c58c9407930439208fb2a (diff) |
draw image maps when image not loaded
http://lists.auriga.wearlab.de/pipermail/dillo-dev/2010-March/007393.html
(Johannes has already fixed the Rectangle clipping problem. Why the polygons
aren't shown initially isn't known yet.)
Diffstat (limited to 'dw/types.cc')
-rw-r--r-- | dw/types.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/dw/types.cc b/dw/types.cc index eec74dba..3bc78ded 100644 --- a/dw/types.cc +++ b/dw/types.cc @@ -39,6 +39,17 @@ Rectangle::Rectangle (int x, int y, int width, int height) this->height = height; } +/* + * Draw rectangle in view relative to point (x,y). + */ +void Rectangle::draw (core::View *view, core::style::Style *style, int x,int y) +{ + const bool filled = false; + + view->drawRectangle(style->color, core::style::Color::SHADING_NORMAL,filled, + x + this->x, y + this->y, this->width, this->height); +} + /** * Return whether this rectangle and otherRect intersect. If yes, * return the intersection rectangle in dest. @@ -124,6 +135,20 @@ Circle::Circle (int x, int y, int radius) this->radius = radius; } +/* + * Draw circle in view relative to point (x,y). + */ +void Circle::draw (core::View *view, core::style::Style *style, int x, int y) +{ + const bool filled = false; + + /* drawArc() wants x, y, w, h for a rectangle, and then it draws the arc + * inside that */ + view->drawArc(style->color, core::style::Color::SHADING_NORMAL, filled, + x + this->x - this->radius, y + this->y - this->radius, + 2 * this->radius, 2 * this->radius, 0, 360); +} + bool Circle::isPointWithin (int x, int y) { return @@ -145,6 +170,27 @@ Polygon::~Polygon () delete points; } +/* + * Draw polygon in view relative to point (x,y). + */ +void Polygon::draw (core::View *view, core::style::Style *style, int x, int y) +{ + if (points->size()) { + int i; + const bool filled = false; + int (*pointArray)[2] = + (int (*)[2]) malloc(points->size() * sizeof(*pointArray)); + + for (i = 0; i < points->size(); i++) { + pointArray[i][0] = x + points->getRef(i)->x; + pointArray[i][1] = y + points->getRef(i)->y; + } + view->drawPolygon(style->color, core::style::Color::SHADING_NORMAL, + filled, pointArray, i); + free(pointArray); + } +} + void Polygon::addPoint (int x, int y) { points->increase (); |