* NEW: implement Paint.TextExtents

[GB.QT4]
* NEW: implement Paint.TextExtents



git-svn-id: svn://localhost/gambas/trunk@2585 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Fabien Bodard 2010-01-01 22:19:11 +00:00
parent a2fa1cc408
commit 5a319b4eb5
11 changed files with 28 additions and 8 deletions

View file

@ -647,11 +647,29 @@ static void Text(GB_PAINT *d, const char *text, int len, float w, float h, int a
/*static void RichText(GB_PAINT *d, const char *text, int len, float w, float h, int align)
{
draw_text(d, TRUE, text, len, w, h, align);
}
}*/
static void TextExtents(GB_PAINT *d, const char *text, int len, GB_EXTENTS *ext)
{
}*/
PangoLayout *layout;
CFONT *font;
PangoRectangle *rect;
PangoRectangle *logrect;
layout = pango_cairo_create_layout(CONTEXT(d));
Paint_Font(d, FALSE, (GB_FONT *)&font);
gt_add_layout_from_font(layout, font->font);
pango_layout_set_text(layout, text, len);
pango_layout_get_extents(layout, rect, logrect);
ext->x2 = (float)rect->width;
ext->y2 = (float)rect->height;
g_object_unref(layout);
g_object_unref(rect);
g_object_unref(logrect);
}
static void Matrix(GB_PAINT *d, int set, GB_TRANSFORM matrix)
@ -945,6 +963,7 @@ GB_PAINT_DESC PAINT_Interface = {
LineTo,
CurveTo,
Text,
TextExtents,
Matrix,
SetBrush,
{

View file

@ -623,7 +623,7 @@ static void Text(GB_PAINT *d, const char *text, int len, float w, float h, int a
DRAW_text_with(PAINTER(d), text, len, pos.x(), pos.y(), w, h, align, draw_text_cb);
}
/*static void TextExtents(GB_PAINT *d, const char *text, int len, GB_EXTENTS *ext)
static void TextExtents(GB_PAINT *d, const char *text, int len, GB_EXTENTS *ext)
{
QRectF rect = PAINTER(d)->boundingRect(QRectF(0, 0, d->width, d->height), Qt::AlignLeft | Qt::AlignTop | Qt::TextSingleLine | Qt::TextIncludeTrailingSpaces, QString::fromUtf8(text, len));
@ -631,7 +631,7 @@ static void Text(GB_PAINT *d, const char *text, int len, float w, float h, int a
ext->y1 = 0;
ext->x2 = (float)rect.width();
ext->y2 = (float)rect.height();
}*/
}
static void Matrix(GB_PAINT *d, int set, GB_TRANSFORM matrix)
@ -842,6 +842,7 @@ GB_PAINT_DESC PAINT_Interface = {
LineTo,
CurveTo,
Text,
TextExtents,
Matrix,
SetBrush,
{

View file

@ -643,7 +643,7 @@ BEGIN_METHOD(Paint_RichText, GB_STRING text; GB_FLOAT x; GB_FLOAT y; GB_FLOAT w;
END_METHOD
*/
/*BEGIN_METHOD(Paint_TextExtents, GB_STRING text)
BEGIN_METHOD(Paint_TextExtents, GB_STRING text)
PAINT_EXTENTS *extents;
@ -654,7 +654,7 @@ END_METHOD
GB.ReturnObject(extents);
END_METHOD*/
END_METHOD
static PAINT_BRUSH *make_brush(GB_PAINT *d, GB_BRUSH brush)
{
@ -913,7 +913,7 @@ GB_DESC PaintDesc[] =
GB_STATIC_PROPERTY("Font", "Font", Paint_Font),
GB_STATIC_METHOD("Text", NULL, Paint_Text, "(Text)s[(X)f(Y)f(Width)f(Height)f(Alignment)i)]"),
//GB_STATIC_METHOD("RichText", NULL, Paint_RichText, "(Text)s[(X)f(Y)f(Width)f(Height)f(Alignment)i)]"),
//GB_STATIC_METHOD("TextExtents", "TextExtents", Paint_TextExtents, "(Text)s"),
GB_STATIC_METHOD("TextExtents", "PaintExtents", Paint_TextExtents, "(Text)s"),
GB_STATIC_METHOD("Color", "PaintBrush", Paint_Color, "(Color)i"),
GB_STATIC_METHOD("Image", "PaintBrush", Paint_Image, "(Image)Image;[(X)f(Y)f]"),

View file

@ -164,7 +164,7 @@ typedef
void (*Text)(GB_PAINT *d, const char *text, int len, float w, float h, int align);
//void (*RichText)(GB_PAINT *d, const char *text, int len, float w, float h, int align);
//void (*TextExtents)(GB_PAINT *d, const char *text, int len, GB_EXTENTS *ext);
void (*TextExtents)(GB_PAINT *d, const char *text, int len, GB_EXTENTS *ext);
void (*Matrix)(GB_PAINT *d, int set, GB_TRANSFORM matrix);