diff options
-rw-r--r-- | dw/fltkviewbase.cc | 6 | ||||
-rw-r--r-- | dw/fltkviewbase.hh | 3 | ||||
-rw-r--r-- | dw/style.cc | 252 | ||||
-rw-r--r-- | dw/types.cc | 7 | ||||
-rw-r--r-- | dw/view.hh | 2 |
5 files changed, 137 insertions, 133 deletions
diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc index ce8dc475..a9cd6bcc 100644 --- a/dw/fltkviewbase.cc +++ b/dw/fltkviewbase.cc @@ -478,7 +478,7 @@ void FltkViewBase::drawArc (core::style::Color *color, void FltkViewBase::drawPolygon (core::style::Color *color, core::style::Color::Shading shading, - bool filled, bool convex, int points[][2], + bool filled, bool convex, core::Point *points, int npoints) { if (npoints > 0) { @@ -493,8 +493,8 @@ void FltkViewBase::drawPolygon (core::style::Color *color, fl_begin_loop(); for (int i = 0; i < npoints; i++) { - fl_vertex(translateCanvasXToViewX(points[i][0]), - translateCanvasYToViewY(points[i][1])); + fl_vertex(translateCanvasXToViewX(points[i].x), + translateCanvasYToViewY(points[i].y)); } if (filled) { if (convex) diff --git a/dw/fltkviewbase.hh b/dw/fltkviewbase.hh index e6e85694..b8d1e874 100644 --- a/dw/fltkviewbase.hh +++ b/dw/fltkviewbase.hh @@ -98,7 +98,8 @@ public: int angle1, int angle2); void drawPolygon (core::style::Color *color, core::style::Color::Shading shading, - bool filled, bool convex, int points[][2], int npoints); + bool filled, bool convex, + core::Point *points, int npoints); core::View *getClippingView (int x, int y, int width, int height); void mergeClippingView (core::View *clippingView); diff --git a/dw/style.cc b/dw/style.cc index c8cab24f..d11abf82 100644 --- a/dw/style.cc +++ b/dw/style.cc @@ -423,7 +423,8 @@ static void drawBorderTop(View *view, Style *style, int x1, int y1, int x2, int y2) { - int points[4][2], d, w; + int d, w; + Point points[4]; const bool filled = true, convex = true; bool ridge = false, inset = false, dotted = false; Color::Shading shading = Color::SHADING_NORMAL; @@ -453,12 +454,12 @@ static void drawBorderTop(View *view, Style *style, if (style->borderWidth.top == 1) { view->drawLine(style->borderColor.top, shading, x1, y1, x2, y2); } else { - points[0][0] = x1; - points[1][0] = x2 + 1; - points[0][1] = points[1][1] = y1; - points[2][0] = points[1][0] - style->borderWidth.right; - points[3][0] = x1 + style->borderWidth.left; - points[2][1] = points[3][1] = points[0][1] + style->borderWidth.top; + points[0].x = x1; + points[1].x = x2 + 1; + points[0].y = points[1].y = y1; + points[2].x = points[1].x - style->borderWidth.right; + points[3].x = x1 + style->borderWidth.left; + points[2].y = points[3].y = points[0].y + style->borderWidth.top; view->drawPolygon (style->borderColor.top, shading, filled, convex, points, 4); } @@ -467,21 +468,21 @@ static void drawBorderTop(View *view, Style *style, ridge = true; case BORDER_GROOVE: d = style->borderWidth.top & 1; - points[0][0] = x1; - points[1][0] = x2 + 1; - points[0][1] = points[1][1] = y1; - points[2][0] = x2 - style->borderWidth.right / 2; - points[3][0] = x1 + style->borderWidth.left / 2; - points[2][1] = points[3][1] = y1 + style->borderWidth.top / 2 + d; + points[0].x = x1; + points[1].x = x2 + 1; + points[0].y = points[1].y = y1; + points[2].x = x2 - style->borderWidth.right / 2; + points[3].x = x1 + style->borderWidth.left / 2; + points[2].y = points[3].y = y1 + style->borderWidth.top / 2 + d; shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK; view->drawPolygon (style->borderColor.top, shading, filled, convex, points, 4); - points[0][0] = x1 + style->borderWidth.left / 2 + d; - points[1][0] = x2 - style->borderWidth.right / 2 + 1 - d; - points[0][1] = points[1][1] = y1 + style->borderWidth.top / 2 + d; - points[2][0] = x2 - style->borderWidth.right + 1 - d; - points[3][0] = x1 + style->borderWidth.left; - points[2][1] = points[3][1] = y1 + style->borderWidth.top; + points[0].x = x1 + style->borderWidth.left / 2 + d; + points[1].x = x2 - style->borderWidth.right / 2 + 1 - d; + points[0].y = points[1].y = y1 + style->borderWidth.top / 2 + d; + points[2].x = x2 - style->borderWidth.right + 1 - d; + points[3].x = x1 + style->borderWidth.left; + points[2].y = points[3].y = y1 + style->borderWidth.top; shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT; view->drawPolygon (style->borderColor.top, shading, filled, convex, points, 4); @@ -495,20 +496,20 @@ static void drawBorderTop(View *view, Style *style, view->drawLine(style->borderColor.top, shading, x1, y1, x2, y2); break; } - points[0][0] = x1; - points[1][0] = x2 + 1; - points[0][1] = points[1][1] = y1; - points[2][0] = points[1][0] - w_r; - points[3][0] = points[0][0] + w_l; - points[2][1] = points[3][1] = points[0][1] + w; + points[0].x = x1; + points[1].x = x2 + 1; + points[0].y = points[1].y = y1; + points[2].x = points[1].x - w_r; + points[3].x = points[0].x + w_l; + points[2].y = points[3].y = points[0].y + w; view->drawPolygon (style->borderColor.top, shading, filled, convex, points, 4); - points[0][0] = x1 + style->borderWidth.left - w_l; - points[1][0] = x2 + 1 - style->borderWidth.right + w_r; - points[0][1] = points[1][1] = y1 + w + d; - points[2][0] = x2 + 1 - style->borderWidth.right; - points[3][0] = x1 + style->borderWidth.left; - points[2][1] = points[3][1] = y1 + style->borderWidth.top; + points[0].x = x1 + style->borderWidth.left - w_l; + points[1].x = x2 + 1 - style->borderWidth.right + w_r; + points[0].y = points[1].y = y1 + w + d; + points[2].x = x2 + 1 - style->borderWidth.right; + points[3].x = x1 + style->borderWidth.left; + points[2].y = points[3].y = y1 + style->borderWidth.top; view->drawPolygon (style->borderColor.top, shading, filled, convex, points, 4); break; @@ -519,7 +520,8 @@ static void drawBorderBottom(View *view, Style *style, int x1, int y1, int x2, int y2) { - int points[4][2], d, w; + int d, w; + Point points[4]; const bool filled = true, convex = true; bool ridge = false, inset = false, dotted = false; Color::Shading shading = Color::SHADING_NORMAL; @@ -549,12 +551,12 @@ static void drawBorderBottom(View *view, Style *style, if (style->borderWidth.bottom == 1) { /* 1 pixel line */ view->drawLine(style->borderColor.bottom, shading, x1, y1, x2, y2); } else { - points[0][0] = x1 - 1; - points[1][0] = x2 + 2; - points[0][1] = points[1][1] = y1 + 1; - points[2][0] = points[1][0] - style->borderWidth.right; - points[3][0] = points[0][0] + style->borderWidth.left; - points[2][1] = points[3][1] = points[0][1]-style->borderWidth.bottom; + points[0].x = x1 - 1; + points[1].x = x2 + 2; + points[0].y = points[1].y = y1 + 1; + points[2].x = points[1].x - style->borderWidth.right; + points[3].x = points[0].x + style->borderWidth.left; + points[2].y = points[3].y = points[0].y-style->borderWidth.bottom; view->drawPolygon (style->borderColor.bottom, shading, filled, convex, points, 4); } @@ -564,22 +566,22 @@ static void drawBorderBottom(View *view, Style *style, case BORDER_GROOVE: w = style->borderWidth.bottom; d = w & 1; - points[0][0] = x1 - 1; - points[1][0] = x2 + 2 - d; - points[0][1] = points[1][1] = y1 + 1; - points[2][0] = points[1][0] - style->borderWidth.right / 2; - points[3][0] = points[0][0] + style->borderWidth.left / 2 + d; - points[2][1] = points[3][1] = points[0][1] - w/2 - d; + points[0].x = x1 - 1; + points[1].x = x2 + 2 - d; + points[0].y = points[1].y = y1 + 1; + points[2].x = points[1].x - style->borderWidth.right / 2; + points[3].x = points[0].x + style->borderWidth.left / 2 + d; + points[2].y = points[3].y = points[0].y - w/2 - d; shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT; view->drawPolygon (style->borderColor.bottom, shading, filled, convex, points, 4); // clockwise - points[0][0] = x1 + style->borderWidth.left - 1; - points[1][0] = x2 + 1 - style->borderWidth.right + 1; - points[0][1] = points[1][1] = y1 - w + 1; - points[2][0] = points[1][0] + style->borderWidth.right / 2; - points[3][0] = points[0][0] - style->borderWidth.left / 2; - points[2][1] = points[3][1] = points[0][1] + w/2; + points[0].x = x1 + style->borderWidth.left - 1; + points[1].x = x2 + 1 - style->borderWidth.right + 1; + points[0].y = points[1].y = y1 - w + 1; + points[2].x = points[1].x + style->borderWidth.right / 2; + points[3].x = points[0].x - style->borderWidth.left / 2; + points[2].y = points[3].y = points[0].y + w/2; shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK; view->drawPolygon (style->borderColor.bottom, shading, filled, convex, points, 4); @@ -593,20 +595,20 @@ static void drawBorderBottom(View *view, Style *style, view->drawLine(style->borderColor.bottom, shading, x1, y1, x2, y2); break; } - points[0][0] = x2 + 2; - points[1][0] = x1 - 1; - points[0][1] = points[1][1] = y1 + 1; - points[2][0] = points[1][0] + w_l; - points[3][0] = points[0][0] - w_r; - points[2][1] = points[3][1] = points[0][1] - w; + points[0].x = x2 + 2; + points[1].x = x1 - 1; + points[0].y = points[1].y = y1 + 1; + points[2].x = points[1].x + w_l; + points[3].x = points[0].x - w_r; + points[2].y = points[3].y = points[0].y - w; view->drawPolygon (style->borderColor.bottom, shading, filled, convex, points, 4); - points[0][0] = x2 + 2 - style->borderWidth.right + w_r; - points[1][0] = x1 - 1 + style->borderWidth.left - w_l; - points[0][1] = points[1][1] = y1 + 1 - w - d; - points[2][0] = x1 - 1 + style->borderWidth.left; - points[3][0] = x2 + 2 - style->borderWidth.right; - points[2][1] = points[3][1] = y1 + 1 - style->borderWidth.bottom; + points[0].x = x2 + 2 - style->borderWidth.right + w_r; + points[1].x = x1 - 1 + style->borderWidth.left - w_l; + points[0].y = points[1].y = y1 + 1 - w - d; + points[2].x = x1 - 1 + style->borderWidth.left; + points[3].x = x2 + 2 - style->borderWidth.right; + points[2].y = points[3].y = y1 + 1 - style->borderWidth.bottom; view->drawPolygon (style->borderColor.bottom, shading, filled, convex, points, 4); break; @@ -617,7 +619,8 @@ static void drawBorderLeft(View *view, Style *style, int x1, int y1, int x2, int y2) { - int points[4][2], d, w; + int d, w; + Point points[4]; bool filled = true, convex = true; bool ridge = false, inset = false, dotted = false; Color::Shading shading = Color::SHADING_NORMAL; @@ -646,12 +649,12 @@ static void drawBorderLeft(View *view, Style *style, if (style->borderWidth.left == 1) { /* 1 pixel line */ view->drawLine(style->borderColor.left, shading, x1, y1, x2, y2); } else { - points[0][0] = points[1][0] = x1; - points[0][1] = y1 - 1; - points[1][1] = y2 + 1; - points[2][0] = points[3][0] = points[0][0] + style->borderWidth.left; - points[2][1] = points[1][1] - style->borderWidth.bottom; - points[3][1] = points[0][1] + style->borderWidth.top; + points[0].x = points[1].x = x1; + points[0].y = y1 - 1; + points[1].y = y2 + 1; + points[2].x = points[3].x = points[0].x + style->borderWidth.left; + points[2].y = points[1].y - style->borderWidth.bottom; + points[3].y = points[0].y + style->borderWidth.top; view->drawPolygon (style->borderColor.left, shading, filled, convex, points, 4); } @@ -661,21 +664,21 @@ static void drawBorderLeft(View *view, Style *style, case BORDER_GROOVE: w = style->borderWidth.left; d = w & 1; - points[0][0] = points[1][0] = x1; - points[0][1] = y1; - points[1][1] = y2; - points[2][0] = points[3][0] = x1 + w / 2 + d; - points[2][1] = y2 - style->borderWidth.bottom / 2; - points[3][1] = y1 + style->borderWidth.top / 2; + points[0].x = points[1].x = x1; + points[0].y = y1; + points[1].y = y2; + points[2].x = points[3].x = x1 + w / 2 + d; + points[2].y = y2 - style->borderWidth.bottom / 2; + points[3].y = y1 + style->borderWidth.top / 2; shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK; view->drawPolygon (style->borderColor.left, shading, filled, convex, points, 4); - points[0][0] = points[1][0] = x1 + w / 2 + d; - points[0][1] = y1 + style->borderWidth.top / 2; - points[1][1] = y2 - style->borderWidth.bottom / 2; - points[2][0] = points[3][0] = x1 + w; - points[2][1] = y2 - style->borderWidth.bottom; - points[3][1] = y1 + style->borderWidth.top; + points[0].x = points[1].x = x1 + w / 2 + d; + points[0].y = y1 + style->borderWidth.top / 2; + points[1].y = y2 - style->borderWidth.bottom / 2; + points[2].x = points[3].x = x1 + w; + points[2].y = y2 - style->borderWidth.bottom; + points[3].y = y1 + style->borderWidth.top; shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT; view->drawPolygon (style->borderColor.left, shading, filled, convex, points, 4); @@ -689,20 +692,20 @@ static void drawBorderLeft(View *view, Style *style, view->drawLine(style->borderColor.left, shading, x1, y1, x2, y2-1); break; } - points[0][0] = points[1][0] = x1; - points[0][1] = y1 - 1; - points[1][1] = y2 + 1; - points[2][0] = points[3][0] = points[0][0] + w; - points[2][1] = points[1][1] - w_b; - points[3][1] = points[0][1] + w_t; + points[0].x = points[1].x = x1; + points[0].y = y1 - 1; + points[1].y = y2 + 1; + points[2].x = points[3].x = points[0].x + w; + points[2].y = points[1].y - w_b; + points[3].y = points[0].y + w_t; view->drawPolygon (style->borderColor.left, shading, filled, convex, points, 4); - points[0][0] = points[1][0] = x1 + w + d; - points[0][1] = y1 - 1 + style->borderWidth.top - w_t; - points[1][1] = y2 + 1 - style->borderWidth.bottom + w_b; - points[2][0] = points[3][0] = points[0][0] + w; - points[2][1] = y2 + 1 - style->borderWidth.bottom; - points[3][1] = y1 - 1 + style->borderWidth.top; + points[0].x = points[1].x = x1 + w + d; + points[0].y = y1 - 1 + style->borderWidth.top - w_t; + points[1].y = y2 + 1 - style->borderWidth.bottom + w_b; + points[2].x = points[3].x = points[0].x + w; + points[2].y = y2 + 1 - style->borderWidth.bottom; + points[3].y = y1 - 1 + style->borderWidth.top; view->drawPolygon (style->borderColor.left, shading, filled, convex, points, 4); break; @@ -713,7 +716,8 @@ static void drawBorderRight(View *view, Style *style, int x1, int y1, int x2, int y2) { - int points[4][2], d, w; + int d, w; + Point points[4]; const bool filled = true, convex = true; bool ridge = false, inset = false, dotted = false; Color::Shading shading = Color::SHADING_NORMAL; @@ -742,12 +746,12 @@ static void drawBorderRight(View *view, Style *style, if (style->borderWidth.right == 1) { /* 1 pixel line */ view->drawLine(style->borderColor.right, shading, x1, y1, x2, y2); } else { - points[0][0] = points[1][0] = x1 + 1; - points[0][1] = y1 - 1; - points[1][1] = y2 + 1; - points[2][0] = points[3][0] = points[0][0]-style->borderWidth.right; - points[2][1] = points[1][1] - style->borderWidth.bottom; - points[3][1] = points[0][1] + style->borderWidth.top; + points[0].x = points[1].x = x1 + 1; + points[0].y = y1 - 1; + points[1].y = y2 + 1; + points[2].x = points[3].x = points[0].x-style->borderWidth.right; + points[2].y = points[1].y - style->borderWidth.bottom; + points[3].y = points[0].y + style->borderWidth.top; view->drawPolygon (style->borderColor.right, shading, filled, convex, points,4); } @@ -757,21 +761,21 @@ static void drawBorderRight(View *view, Style *style, case BORDER_GROOVE: w = style->borderWidth.right; d = w & 1; - points[0][0] = points[1][0] = x1 + 1; - points[0][1] = y1; - points[1][1] = y2; - points[2][0] = points[3][0] = points[0][0] - w / 2 - d; - points[2][1] = y2 - style->borderWidth.bottom / 2; - points[3][1] = points[0][1] + style->borderWidth.top / 2; + points[0].x = points[1].x = x1 + 1; + points[0].y = y1; + points[1].y = y2; + points[2].x = points[3].x = points[0].x - w / 2 - d; + points[2].y = y2 - style->borderWidth.bottom / 2; + points[3].y = points[0].y + style->borderWidth.top / 2; shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT; view->drawPolygon (style->borderColor.right, shading, filled, convex, points, 4); - points[0][0] = points[1][0] = x1 + 1 - w / 2 - d; - points[0][1] = y1 + style->borderWidth.top / 2; - points[1][1] = y2 - style->borderWidth.bottom / 2; - points[2][0] = points[3][0] = x1 + 1 - w; - points[2][1] = y2 - style->borderWidth.bottom; - points[3][1] = y1 + style->borderWidth.top; + points[0].x = points[1].x = x1 + 1 - w / 2 - d; + points[0].y = y1 + style->borderWidth.top / 2; + points[1].y = y2 - style->borderWidth.bottom / 2; + points[2].x = points[3].x = x1 + 1 - w; + points[2].y = y2 - style->borderWidth.bottom; + points[3].y = y1 + style->borderWidth.top; shading = (ridge) ? Color::SHADING_LIGHT: Color::SHADING_DARK; view->drawPolygon (style->borderColor.right, shading, filled, convex, points, 4); @@ -785,20 +789,20 @@ static void drawBorderRight(View *view, Style *style, view->drawLine(style->borderColor.right, shading, x1, y1, x2, y2); break; } - points[0][0] = points[1][0] = x1 + 1; - points[0][1] = y1 - 1; - points[1][1] = y2 + 1; - points[2][0] = points[3][0] = points[0][0] - w; - points[2][1] = points[1][1] - w_b; - points[3][1] = points[0][1] + w_t; + points[0].x = points[1].x = x1 + 1; + points[0].y = y1 - 1; + points[1].y = y2 + 1; + points[2].x = points[3].x = points[0].x - w; + points[2].y = points[1].y - w_b; + points[3].y = points[0].y + w_t; view->drawPolygon (style->borderColor.right, shading, filled, convex, points, 4); - points[0][0] = points[1][0] = x1 + 1 - w - d; - points[0][1] = y1 - 1 + style->borderWidth.top - w_t; - points[1][1] = y2 + 1 - style->borderWidth.bottom + w_b; - points[2][0] = points[3][0] = points[0][0] - w; - points[2][1] = y2 + 1 - style->borderWidth.bottom; - points[3][1] = y1 - 1 + style->borderWidth.top; + points[0].x = points[1].x = x1 + 1 - w - d; + points[0].y = y1 - 1 + style->borderWidth.top - w_t; + points[1].y = y2 + 1 - style->borderWidth.bottom + w_b; + points[2].x = points[3].x = points[0].x - w; + points[2].y = y2 + 1 - style->borderWidth.bottom; + points[3].y = y1 - 1 + style->borderWidth.top; view->drawPolygon (style->borderColor.right, shading, filled, convex, points, 4); break; diff --git a/dw/types.cc b/dw/types.cc index 9dcedeea..074cb352 100644 --- a/dw/types.cc +++ b/dw/types.cc @@ -141,12 +141,11 @@ void Polygon::draw (core::View *view, core::style::Style *style, int x, int y) if (points->size()) { int i; const bool filled = false, convex = false; - int (*pointArray)[2] = - (int (*)[2]) malloc(points->size() * sizeof(*pointArray)); + Point *pointArray = (Point *)malloc(points->size()*sizeof(struct Point)); for (i = 0; i < points->size(); i++) { - pointArray[i][0] = x + points->getRef(i)->x; - pointArray[i][1] = y + points->getRef(i)->y; + pointArray[i].x = x + points->getRef(i)->x; + pointArray[i].y = y + points->getRef(i)->y; } view->drawPolygon(style->color, core::style::Color::SHADING_NORMAL, filled, convex, pointArray, i); @@ -173,7 +173,7 @@ public: int angle1, int angle2) = 0; virtual void drawPolygon (style::Color *color, style::Color::Shading shading, - bool filled, bool convex, int points[][2], + bool filled, bool convex, Point *points, int npoints) = 0; virtual void drawText (style::Font *font, style::Color *color, |