[Uml-devel] branches/work/soc-umbrello/umbrello
Gopala Krishna A
krishna.ggk at gmail.com
Sun Jul 20 16:22:30 UTC 2008
SVN commit 835469 by gopala:
Added a utility method to draw a triangled rectange (Like note, new icon).
M +20 -0 widget_utils.cpp
M +11 -0 widget_utils.h
--- branches/work/soc-umbrello/umbrello/widget_utils.cpp #835468:835469
@@ -22,6 +22,7 @@
// qt/kde includes
#include <QtGui/QBrush>
#include <QtGui/QPen>
+#include <QtGui/QPolygonF>
// c++ include
#include <cmath>
@@ -97,6 +98,25 @@
p->translate(-r.center().x(), -r.center().y());
}
+ void drawTriangledRect(QPainter *painter,
+ const QRectF& rect, const QSizeF& triSize)
+ {
+ // Draw outer boundary defined by polygon "poly".
+ QPolygonF poly(5);
+ poly[0] = rect.topLeft();
+ poly[1] = rect.topRight() - QPointF(triSize.width(), 0);
+ poly[2] = rect.topRight() + QPointF(0, triSize.height());
+ poly[3] = rect.bottomRight();
+ poly[4] = rect.bottomLeft();
+ painter->drawPolygon(poly);
+
+ // Now draw the triangle base and height edges.
+ QLineF heightEdge(poly[1], poly[1] + QPointF(0, triSize.height()));
+ painter->drawLine(heightEdge);
+ QLineF baseEdge(heightEdge.p2(), poly[2]);
+ painter->drawLine(baseEdge);
+ }
+
QString pointToString(const QPointF& point)
{
return QString("%1,%2").arg(point.x()).arg(point.y());
--- branches/work/soc-umbrello/umbrello/widget_utils.h #835468:835469
@@ -59,6 +59,17 @@
*/
void drawCrossInEllipse(QPainter *p, const QRectF& ellipse);
+ /**
+ * Draws a polygon which is almost rectanguar except for the top
+ * right corner. A triangle is drawn in top right corner of the
+ * rectangle.
+ *
+ * @param painter The painter with which this shape is to be drawn.
+ * @param rect The rectangle dimensions.
+ * @param triSize The size of the triange in the top-right corner.
+ */
+ void drawTriangledRect(QPainter *painter, const QRectF& rect, const QSizeF& triSize);
+
/**
* Converts a point to a comma separated string i.e "x,y"
*/
More information about the umbrello-devel
mailing list