aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/fltkviewbase.cc21
-rw-r--r--dw/fltkviewbase.hh2
-rw-r--r--dw/style.cc64
-rw-r--r--dw/types.cc4
-rw-r--r--dw/view.hh3
5 files changed, 63 insertions, 31 deletions
diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc
index 1fa93e5a..f29c9a12 100644
--- a/dw/fltkviewbase.cc
+++ b/dw/fltkviewbase.cc
@@ -476,23 +476,30 @@ void FltkViewBase::drawArc (core::style::Color *color,
void FltkViewBase::drawPolygon (core::style::Color *color,
core::style::Color::Shading shading,
- bool filled, int points[][2], int npoints)
+ bool filled, bool convex, int points[][2],
+ int npoints)
{
if (npoints > 0) {
fl_color(((FltkColor*)color)->colors[shading]);
- if (filled)
- fl_begin_complex_polygon();
- else
+ if (filled) {
+ if (convex)
+ fl_begin_polygon();
+ else
+ fl_begin_complex_polygon();
+ } else
fl_begin_loop();
for (int i = 0; i < npoints; i++) {
fl_vertex(translateCanvasXToViewX(points[i][0]),
translateCanvasYToViewY(points[i][1]));
}
- if (filled)
- fl_end_complex_polygon();
- else
+ if (filled) {
+ if (convex)
+ fl_end_polygon();
+ else
+ fl_end_complex_polygon();
+ } else
fl_end_loop();
}
}
diff --git a/dw/fltkviewbase.hh b/dw/fltkviewbase.hh
index ccdc86ef..d741397f 100644
--- a/dw/fltkviewbase.hh
+++ b/dw/fltkviewbase.hh
@@ -86,7 +86,7 @@ public:
int angle1, int angle2);
void drawPolygon (core::style::Color *color,
core::style::Color::Shading shading,
- bool filled, int points[][2], int npoints);
+ bool filled, bool convex, int points[][2], 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 4b4ef33d..134ffb2a 100644
--- a/dw/style.cc
+++ b/dw/style.cc
@@ -424,6 +424,7 @@ static void drawBorderTop(View *view, Style *style,
{
int points[4][2], d, w;
+ const bool filled = true, convex = true;
bool ridge = false, inset = false, dotted = false;
Color::Shading shading = Color::SHADING_NORMAL;
@@ -458,7 +459,8 @@ static void drawBorderTop(View *view, Style *style,
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;
- view->drawPolygon (style->borderColor.top, shading, true, points, 4);
+ view->drawPolygon (style->borderColor.top, shading, filled, convex,
+ points, 4);
}
break;
case BORDER_RIDGE:
@@ -472,7 +474,8 @@ static void drawBorderTop(View *view, Style *style,
points[3][0] = x1 + style->borderWidth.left / 2;
points[2][1] = points[3][1] = y1 + style->borderWidth.top / 2 + d;
shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
- view->drawPolygon (style->borderColor.top, shading, true, points, 4);
+ 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;
@@ -480,7 +483,8 @@ static void drawBorderTop(View *view, Style *style,
points[3][0] = x1 + style->borderWidth.left;
points[2][1] = points[3][1] = y1 + style->borderWidth.top;
shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
- view->drawPolygon (style->borderColor.top, shading, true, points, 4);
+ view->drawPolygon (style->borderColor.top, shading, filled, convex,
+ points, 4);
break;
case BORDER_DOUBLE:
w = (int) rint(style->borderWidth.top / 3.0);
@@ -497,14 +501,16 @@ static void drawBorderTop(View *view, Style *style,
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;
- view->drawPolygon (style->borderColor.top, shading, true, points, 4);
+ 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;
- view->drawPolygon (style->borderColor.top, shading, true, points, 4);
+ view->drawPolygon (style->borderColor.top, shading, filled, convex,
+ points, 4);
break;
}
}
@@ -514,6 +520,7 @@ static void drawBorderBottom(View *view, Style *style,
{
int points[4][2], d, w;
+ const bool filled = true, convex = true;
bool ridge = false, inset = false, dotted = false;
Color::Shading shading = Color::SHADING_NORMAL;
@@ -548,7 +555,8 @@ static void drawBorderBottom(View *view, Style *style,
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;
- view->drawPolygon (style->borderColor.top, shading, true, points, 4);
+ view->drawPolygon (style->borderColor.top, shading, filled, convex,
+ points, 4);
}
break;
case BORDER_RIDGE:
@@ -563,7 +571,8 @@ static void drawBorderBottom(View *view, Style *style,
points[3][0] = points[0][0] + style->borderWidth.left / 2 + d;
points[2][1] = points[3][1] = points[0][1] - w/2 - d;
shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
- view->drawPolygon (style->borderColor.bottom, shading, true, points, 4);
+ 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;
@@ -572,7 +581,8 @@ static void drawBorderBottom(View *view, Style *style,
points[3][0] = points[0][0] - style->borderWidth.left / 2;
points[2][1] = points[3][1] = points[0][1] + w/2;
shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
- view->drawPolygon (style->borderColor.top, shading, true, points, 4);
+ view->drawPolygon (style->borderColor.top, shading, filled, convex,
+ points, 4);
break;
case BORDER_DOUBLE:
w = (int) rint(style->borderWidth.bottom / 3.0);
@@ -589,14 +599,16 @@ static void drawBorderBottom(View *view, Style *style,
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;
- view->drawPolygon (style->borderColor.top, shading, true, points, 4);
+ view->drawPolygon (style->borderColor.top, 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;
- view->drawPolygon (style->borderColor.top, shading, true, points, 4);
+ view->drawPolygon (style->borderColor.top, shading, filled, convex,
+ points, 4);
break;
}
}
@@ -606,6 +618,7 @@ static void drawBorderLeft(View *view, Style *style,
{
int points[4][2], d, w;
+ bool filled = true, convex = true;
bool ridge = false, inset = false, dotted = false;
Color::Shading shading = Color::SHADING_NORMAL;
@@ -639,7 +652,8 @@ static void drawBorderLeft(View *view, Style *style,
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;
- view->drawPolygon (style->borderColor.left, shading, true, points, 4);
+ view->drawPolygon (style->borderColor.left, shading, filled, convex,
+ points, 4);
}
break;
case BORDER_RIDGE:
@@ -654,7 +668,8 @@ static void drawBorderLeft(View *view, Style *style,
points[2][1] = y2 - style->borderWidth.bottom / 2;
points[3][1] = y1 + style->borderWidth.top / 2;
shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
- view->drawPolygon (style->borderColor.top, shading, true, points, 4);
+ view->drawPolygon (style->borderColor.top, 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;
@@ -662,7 +677,8 @@ static void drawBorderLeft(View *view, Style *style,
points[2][1] = y2 - style->borderWidth.bottom;
points[3][1] = y1 + style->borderWidth.top;
shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
- view->drawPolygon (style->borderColor.top, shading, true, points, 4);
+ view->drawPolygon (style->borderColor.top, shading, filled, convex,
+ points, 4);
break;
case BORDER_DOUBLE:
w = (int) rint(style->borderWidth.left / 3.0);
@@ -679,14 +695,16 @@ static void drawBorderLeft(View *view, Style *style,
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;
- view->drawPolygon (style->borderColor.left, shading, true, points, 4);
+ 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;
- view->drawPolygon (style->borderColor.left, shading, true, points, 4);
+ view->drawPolygon (style->borderColor.left, shading, filled, convex,
+ points, 4);
break;
}
}
@@ -696,6 +714,7 @@ static void drawBorderRight(View *view, Style *style,
{
int points[4][2], d, w;
+ const bool filled = true, convex = true;
bool ridge = false, inset = false, dotted = false;
Color::Shading shading = Color::SHADING_NORMAL;
@@ -729,7 +748,8 @@ static void drawBorderRight(View *view, Style *style,
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;
- view->drawPolygon (style->borderColor.right, shading, true,points,4);
+ view->drawPolygon (style->borderColor.right, shading, filled, convex,
+ points,4);
}
break;
case BORDER_RIDGE:
@@ -744,7 +764,8 @@ static void drawBorderRight(View *view, Style *style,
points[2][1] = y2 - style->borderWidth.bottom / 2;
points[3][1] = points[0][1] + style->borderWidth.top / 2;
shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
- view->drawPolygon (style->borderColor.right, shading, true, points, 4);
+ 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;
@@ -752,7 +773,8 @@ static void drawBorderRight(View *view, Style *style,
points[2][1] = y2 - style->borderWidth.bottom;
points[3][1] = y1 + style->borderWidth.top;
shading = (ridge) ? Color::SHADING_LIGHT: Color::SHADING_DARK;
- view->drawPolygon (style->borderColor.right, shading, true, points, 4);
+ view->drawPolygon (style->borderColor.right, shading, filled, convex,
+ points, 4);
break;
case BORDER_DOUBLE:
w = (int) rint(style->borderWidth.right / 3.0);
@@ -769,14 +791,16 @@ static void drawBorderRight(View *view, Style *style,
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;
- view->drawPolygon (style->borderColor.right, shading, true, points, 4);
+ 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;
- view->drawPolygon (style->borderColor.right, shading, true, points, 4);
+ view->drawPolygon (style->borderColor.right, shading, filled, convex,
+ points, 4);
break;
}
}
diff --git a/dw/types.cc b/dw/types.cc
index 4d94f494..9dcedeea 100644
--- a/dw/types.cc
+++ b/dw/types.cc
@@ -140,7 +140,7 @@ void Polygon::draw (core::View *view, core::style::Style *style, int x, int y)
{
if (points->size()) {
int i;
- const bool filled = false;
+ const bool filled = false, convex = false;
int (*pointArray)[2] =
(int (*)[2]) malloc(points->size() * sizeof(*pointArray));
@@ -149,7 +149,7 @@ void Polygon::draw (core::View *view, core::style::Style *style, int x, int y)
pointArray[i][1] = y + points->getRef(i)->y;
}
view->drawPolygon(style->color, core::style::Color::SHADING_NORMAL,
- filled, pointArray, i);
+ filled, convex, pointArray, i);
free(pointArray);
}
}
diff --git a/dw/view.hh b/dw/view.hh
index 08853323..308e5e31 100644
--- a/dw/view.hh
+++ b/dw/view.hh
@@ -179,7 +179,8 @@ public:
int angle1, int angle2) = 0;
virtual void drawPolygon (style::Color *color,
style::Color::Shading shading,
- bool filled, int points[][2], int npoints) = 0;
+ bool filled, bool convex, int points[][2],
+ int npoints) = 0;
virtual void drawText (style::Font *font,
style::Color *color,
style::Color::Shading shading,