diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-24 13:47:19 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-24 13:47:19 +0100 |
commit | 72544c3aa7005e6f0e60a505923b6afae4eba84d (patch) | |
tree | 2a6940e5d6dffcd8c97a525f904661826a6292f7 | |
parent | fbbfa1144e7bdaa0071ab7d27e447056e2e423c1 (diff) |
Added box (image) renderer.
-rw-r--r-- | plugingui/painter.cc | 80 | ||||
-rw-r--r-- | plugingui/painter.h | 12 |
2 files changed, 92 insertions, 0 deletions
diff --git a/plugingui/painter.cc b/plugingui/painter.cc index 40d6112..7d5499f 100644 --- a/plugingui/painter.cc +++ b/plugingui/painter.cc @@ -396,6 +396,86 @@ void GUI::Painter::drawImage(int x0, int y0, GUI::Image *image) } } +/* + typedef struct { + Image *topleft; + Image *top; + Image *topright; + Image *left; + Image *right; + Image *bottomleft; + Image *bottom; + Image *bottomright; + } Box; +*/ +void GUI::Painter::drawBox(int x, int y, Box *box, int width, int height) +{ + int dx = x; + int dy = y; + + printf("%d %d %d %d %d %d %d %d\n", + box->topLeft->width(), + box->top->width(), + box->topRight->width(), + box->left->width(), + box->right->width(), + box->bottomLeft->width(), + box->bottom->width(), + box->bottomRight->width()); + + printf("%d %d %d %d %d %d %d %d\n", + box->topLeft->height(), + box->top->height(), + box->topRight->height(), + box->left->height(), + box->right->height(), + box->bottomLeft->height(), + box->bottom->height(), + box->bottomRight->height()); + + // Top: + + drawImage(dx, dy, box->topLeft); + dx += box->topLeft->width() - 1; + + while(dx < (x + width - box->topRight->width())) { + drawImage(dx, dy, box->top); + dx += box->top->width(); + } + + dx = x + width - box->topRight->width(); + drawImage(dx, dy, box->topRight); + + // Mid: + dx = x; + dy = y + box->topLeft->height(); + while(dy < (y + height - box->bottomLeft->height())) { + drawImage(dx, dy, box->left); + dy += box->left->height(); + } + + dx = x + width - box->right->width(); + dy = y + box->topRight->height(); + while(dy < (y + height - box->bottomRight->height())) { + drawImage(dx, dy, box->right); + dy += box->right->height(); + } + + // Bottom: + dx = x; + dy = y + height - box->bottomLeft->height(); + drawImage(dx, dy, box->bottomLeft); + dx += box->bottomLeft->width() - 1; + + while(dx < (x + width - box->bottomRight->width())) { + drawImage(dx, dy, box->bottom); + dx += box->bottom->width(); + } + + dx = x + width - box->bottomRight->width(); + drawImage(dx, dy, box->bottomRight); +} + void GUI::Painter::flush() { #ifdef X11 diff --git a/plugingui/painter.h b/plugingui/painter.h index 467e612..4341fc3 100644 --- a/plugingui/painter.h +++ b/plugingui/painter.h @@ -70,6 +70,18 @@ public: void drawImage(int x, int y, struct __img__ * img); void drawImage(int x, int y, Image *image); + typedef struct { + Image *topLeft; + Image *top; + Image *topRight; + Image *left; + Image *right; + Image *bottomLeft; + Image *bottom; + Image *bottomRight; + } Box; + void drawBox(int x, int y, Box *box, int width, int height); + void clear(); private: |