rows and columns

svn path=/branches/KDE/4.4/kdebase/runtime/; revision=1095390
This commit is contained in:
Aaron J. Seigo 2010-02-24 08:00:10 +00:00
parent b08edac797
commit ef904e84e6
2 changed files with 75 additions and 4 deletions

View File

@ -125,7 +125,23 @@ BEGIN_DECLARE_METHOD(QGraphicsGridLayout, addItem) {
return eng->undefinedValue();
}
self->addItem(item, ctx->argument(1).toInt32(), ctx->argument(2).toInt32());
int rowSpan = 1;
int colSpan = 1;
Qt::Alignment alignment = 0;
const int argCount = ctx->argumentCount();
if (argCount > 3) {
rowSpan = ctx->argument(3).toInt32();
if (argCount > 4) {
colSpan = ctx->argument(4).toInt32();
if (argCount > 5) {
alignment = static_cast<Qt::Alignment>(ctx->argument(5).toInt32());
}
}
}
self->addItem(item, ctx->argument(1).toInt32(), ctx->argument(2).toInt32(),
rowSpan, colSpan, alignment);
return eng->undefinedValue();
} END_DECLARE_METHOD

View File

@ -184,6 +184,28 @@ static QScriptValue drawArc(QScriptContext *ctx, QScriptEngine *eng)
return eng->undefinedValue();
}
static QScriptValue fillArc(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPainter, fillArc);
QPainterPath path;
if (ctx->argumentCount() == 6) {
// drawArc(x, y, height, width, startAngle, spanAngle)
path.arcTo(ctx->argument(0).toInt32(),
ctx->argument(1).toInt32(),
ctx->argument(2).toInt32(),
ctx->argument(3).toInt32(),
ctx->argument(4).toInt32(),
ctx->argument(5).toInt32());
} else if (ctx->argumentCount() == 3) {
// drawArc(rectangle, startAngle, spanAngle)
path.arcTo(qscriptvalue_cast<QRectF>(ctx->argument(0)),
ctx->argument(1).toInt32(),
ctx->argument(2).toInt32());
}
self->fillPath(path, self->brush());
return eng->undefinedValue();
}
/////////////////////////////////////////////////////////////
static QScriptValue drawChord(QScriptContext *ctx, QScriptEngine *eng)
@ -233,6 +255,25 @@ static QScriptValue drawEllipse(QScriptContext *ctx, QScriptEngine *eng)
return eng->undefinedValue();
}
static QScriptValue fillEllipse(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPainter, fill);
QPainterPath path;
if (ctx->argumentCount() == 4) {
// drawEllipse(x, y, width, height)
path.addEllipse(ctx->argument(0).toInt32(),
ctx->argument(1).toInt32(),
ctx->argument(2).toInt32(),
ctx->argument(3).toInt32());
} else if (ctx->argumentCount() == 1) {
// drawEllipse(rect)
path.addEllipse(qscriptvalue_cast<QRectF>(ctx->argument(0)));
}
self->fillPath(path, self->brush());
return eng->undefinedValue();
}
/////////////////////////////////////////////////////////////
static QScriptValue drawImage(QScriptContext *ctx, QScriptEngine *eng)
@ -403,8 +444,20 @@ static QScriptValue drawPoints(QScriptContext *ctx, QScriptEngine *eng)
static QScriptValue drawPolygon(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QPainter, drawPolygon);
// ### fillRule (2nd argument)
self->drawPolygon(qscriptvalue_cast<QPolygonF>(ctx->argument(0)));
if (ctx->argumentCount() < 1) {
return eng->undefinedValue();
}
if (ctx->argumentCount() == 1) {
self->drawPolygon(qscriptvalue_cast<QPolygonF>(ctx->argument(0)));
} else {
QPointF *points = new QPointF[ctx->argumentCount()];
for (int i = 0; i < ctx->argumentCount(); ++i) {
points[i] = qscriptvalue_cast<QPointF>(ctx->argument(i));
}
delete[] points;
}
return eng->undefinedValue();
}
@ -928,7 +981,7 @@ static QScriptValue strokePath(QScriptContext *ctx, QScriptEngine *eng)
QPainterPath *path = qscriptvalue_cast<QPainterPath*>(ctx->argument(0));
if (!path) {
return ctx->throwError(QScriptContext::TypeError,
"QPainter.prototype.strokePath: argument is not a PainterPath");
"QPainter.prototype.fillPath: argument is not a PainterPath");
}
self->strokePath(*path, qscriptvalue_cast<QPen>(ctx->argument(1)));
return eng->undefinedValue();
@ -1117,6 +1170,8 @@ QScriptValue constructPainterClass(QScriptEngine *eng)
ADD_METHOD(proto, drawRoundRect);
ADD_METHOD(proto, drawText);
ADD_METHOD(proto, drawTiledPixmap);
ADD_METHOD(proto, fillArc);
ADD_METHOD(proto, fillEllipse);
ADD_METHOD(proto, eraseRect);
ADD_METHOD(proto, fillPath);
ADD_METHOD(proto, fillRect);