From 67a672c6d70e5f25e48fa48bd46f82c02df06e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sun, 27 Dec 2009 15:51:27 +0000 Subject: [PATCH] [CONFIGURATION] * NEW: Do not compile gb.qt.kde anymore. [GB.DRAW] * NEW: Work continues on the new Paint interface. git-svn-id: svn://localhost/gambas/trunk@2521 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- Makefile.am | 2 +- app/src/gambas3/.lang/.pot | 40 +++---- app/src/gambas3/.src/FOption.form | 1 + configure.ac | 1 - main/lib/draw/cpaint.c | 171 +++++++++++++++++++++++++----- main/lib/draw/gb.paint.h | 49 ++++----- 6 files changed, 194 insertions(+), 70 deletions(-) diff --git a/Makefile.am b/Makefile.am index dd0477533..c940b5ea5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = main @bzlib2_dir@ @zlib_dir@ @mysql_dir@ @odbc_dir@ @postgresql_dir@ @sqlite3_dir@ @sqlite2_dir@ @firebird_dir@ @gtk_dir@ @net_dir@ @curl_dir@ @smtp_dir@ @pcre_dir@ @qt_dir@ @kde_dir@ @sdl_dir@ @sdlsound_dir@ @xml_dir@ @v4l_dir@ @crypt_dir@ @opengl_dir@ @corba_dir@ @pdf_dir@ @gtksvg_dir@ @desktop_dir@ @qt4_dir@ @cairo_dir@ @imageio_dir@ @imageimlib_dir@ comp app examples +SUBDIRS = main @bzlib2_dir@ @zlib_dir@ @mysql_dir@ @odbc_dir@ @postgresql_dir@ @sqlite3_dir@ @sqlite2_dir@ @firebird_dir@ @gtk_dir@ @net_dir@ @curl_dir@ @smtp_dir@ @pcre_dir@ @qt_dir@ @sdl_dir@ @sdlsound_dir@ @xml_dir@ @v4l_dir@ @crypt_dir@ @opengl_dir@ @corba_dir@ @pdf_dir@ @gtksvg_dir@ @desktop_dir@ @qt4_dir@ @cairo_dir@ @imageio_dir@ @imageimlib_dir@ comp app examples EXTRA_DIST = component.am README README.*[^~] TODO TEMPLATE reconf reconf-all diff --git a/app/src/gambas3/.lang/.pot b/app/src/gambas3/.lang/.pot index ccc6398d8..d466e7e5b 100644 --- a/app/src/gambas3/.lang/.pot +++ b/app/src/gambas3/.lang/.pot @@ -496,7 +496,7 @@ msgstr "" #: FCommit.class:255 FConflict.class:348 FConnectionEditor.class:1822 #: FEditor.class:3196 FForm.class:3622 FIconEditor.class:2150 -#: FOption.class:1189 FOutput.class:455 FTextEditor.class:642 +#: FOption.class:1190 FOutput.class:455 FTextEditor.class:642 msgid "Undo" msgstr "" @@ -555,7 +555,7 @@ msgstr "" #: FConflict.class:25 FFindList.class:203 FIconEditor.class:1412 #: FImportTable.class:656 FInfo.class:427 FMakeInstall.class:260 -#: FOption.class:1210 FTips.class:232 +#: FOption.class:1211 FTips.class:232 msgid "Close" msgstr "" @@ -909,7 +909,7 @@ msgid "Style sheet" msgstr "" #: FCreateFile.class:744 FCreateProject.class:537 FImportTable.class:489 -#: FOption.class:1016 FPropertyProject.class:1653 +#: FOption.class:1017 FPropertyProject.class:1653 msgid "Options" msgstr "" @@ -1113,7 +1113,7 @@ msgid "Function" msgstr "" #: FDebugInfo.class:51 FFindList.class:73 FIconEditor.class:2278 -#: FOption.class:1034 +#: FOption.class:1035 msgid "Line" msgstr "" @@ -1318,7 +1318,7 @@ msgstr "" msgid "Paste as comments" msgstr "" -#: FEditor.class:3365 FOption.class:997 +#: FEditor.class:3365 FOption.class:998 msgid "Editor" msgstr "" @@ -3081,63 +3081,63 @@ msgstr "" msgid "Show documentation in popups" msgstr "" -#: FOption.class:992 +#: FOption.class:993 msgid "Clear documentation cache" msgstr "" -#: FOption.class:1002 +#: FOption.class:1003 msgid "Font" msgstr "" -#: FOption.class:1026 +#: FOption.class:1027 msgid "Procedure separation" msgstr "" -#: FOption.class:1034 FProperty.class:739 +#: FOption.class:1035 FProperty.class:739 msgid "None" msgstr "" -#: FOption.class:1034 +#: FOption.class:1035 msgid "Blend" msgstr "" -#: FOption.class:1045 +#: FOption.class:1046 msgid "Highlight current line" msgstr "" -#: FOption.class:1063 +#: FOption.class:1064 msgid "Highlight modified lines" msgstr "" -#: FOption.class:1081 +#: FOption.class:1082 msgid "Show line numbers" msgstr "" -#: FOption.class:1099 +#: FOption.class:1100 msgid "Fold procedures by default" msgstr "" -#: FOption.class:1117 +#: FOption.class:1118 msgid "Default tab size" msgstr "" -#: FOption.class:1130 +#: FOption.class:1131 msgid "spaces" msgstr "" -#: FOption.class:1141 +#: FOption.class:1142 msgid "Keywords in upper case" msgstr "" -#: FOption.class:1152 +#: FOption.class:1153 msgid "Theme" msgstr "" -#: FOption.class:1175 +#: FOption.class:1176 msgid "Import theme" msgstr "" -#: FOption.class:1182 +#: FOption.class:1183 msgid "Export theme" msgstr "" diff --git a/app/src/gambas3/.src/FOption.form b/app/src/gambas3/.src/FOption.form index a2456b6c2..02c9fc65f 100644 --- a/app/src/gambas3/.src/FOption.form +++ b/app/src/gambas3/.src/FOption.form @@ -264,6 +264,7 @@ Indent = True { btnClearCache Button MoveScaled(0,0,39,4) + AutoResize = True Text = ("Clear documentation cache") Picture = Picture["icon:/small/trash"] } diff --git a/configure.ac b/configure.ac index 0b6379f09..fb11a71d2 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,6 @@ GB_CONFIG_SUBDIRS(curl, gb.net.curl) GB_CONFIG_SUBDIRS(smtp, gb.net.smtp) GB_CONFIG_SUBDIRS(pcre, gb.pcre) GB_CONFIG_SUBDIRS(qt, gb.qt) -GB_CONFIG_SUBDIRS(kde, gb.qt.kde) GB_CONFIG_SUBDIRS(sdl, gb.sdl) GB_CONFIG_SUBDIRS(sdlsound, gb.sdl.sound) GB_CONFIG_SUBDIRS(xml, gb.xml) diff --git a/main/lib/draw/cpaint.c b/main/lib/draw/cpaint.c index e11373e75..45651ec83 100644 --- a/main/lib/draw/cpaint.c +++ b/main/lib/draw/cpaint.c @@ -334,37 +334,27 @@ BEGIN_PROPERTY(_property) \ GB.ReturnObject(extents); \ END_METHOD -#define IMPLEMENT_PROPERTY_INTEGER(_property, _api) \ +#define IMPLEMENT_PROPERTY(_property, _api, _type, _gtype, _return) \ BEGIN_PROPERTY(_property) \ - int value; \ + _type value; \ CHECK_DEVICE(); \ if (READ_PROPERTY) \ { \ PAINT->_api(THIS, FALSE, &value); \ - GB.ReturnInteger(value); \ + _return(value); \ } \ else \ { \ - value = VPROP(GB_INTEGER); \ + value = (_type)VPROP(_gtype); \ PAINT->_api(THIS, TRUE, &value); \ } \ END_METHOD +#define IMPLEMENT_PROPERTY_INTEGER(_property, _api) \ + IMPLEMENT_PROPERTY(_property, _api, int, GB_INTEGER, GB.ReturnInteger) + #define IMPLEMENT_PROPERTY_FLOAT(_property, _api) \ -BEGIN_PROPERTY(_property) \ - double value; \ - CHECK_DEVICE(); \ - if (READ_PROPERTY) \ - { \ - PAINT->_api(THIS, FALSE, &value); \ - GB.ReturnFloat(value); \ - } \ - else \ - { \ - value = VPROP(GB_FLOAT); \ - PAINT->_api(THIS, TRUE, &value); \ - } \ -END_METHOD + IMPLEMENT_PROPERTY(_property, _api, float, GB_FLOAT, GB.ReturnFloat) IMPLEMENT_METHOD(Paint_Save, Save) IMPLEMENT_METHOD(Paint_Restore, Restore) @@ -384,6 +374,24 @@ IMPLEMENT_PROPERTY_FLOAT(Paint_DashOffset, DashOffset) IMPLEMENT_METHOD(Paint_NewPath, NewPath) IMPLEMENT_METHOD(Paint_ClosePath, ClosePath) +BEGIN_PROPERTY(Paint_X) + + float x, y; + CHECK_DEVICE(); + PAINT->GetCurrentPoint(THIS, &x, &y); + GB.ReturnFloat((double)x); + +END_PROPERTY + +BEGIN_PROPERTY(Paint_Y) + + float x, y; + CHECK_DEVICE(); + PAINT->GetCurrentPoint(THIS, &x, &y); + GB.ReturnFloat((double)y); + +END_PROPERTY + BEGIN_METHOD(Paint_Arc, GB_FLOAT xc; GB_FLOAT yc; GB_FLOAT radius; GB_FLOAT angle1; GB_FLOAT angle2) CHECK_DEVICE(); @@ -419,6 +427,121 @@ BEGIN_METHOD(Paint_Rectangle, GB_FLOAT x; GB_FLOAT y; GB_FLOAT w; GB_FLOAT h) END_METHOD +IMPLEMENT_PROPERTY(Paint_Font, Font, GB_FONT, GB_OBJECT, GB.ReturnObject) + +BEGIN_METHOD(Paint_Text, GB_STRING text; GB_FLOAT x; GB_FLOAT y; GB_FLOAT w; GB_FLOAT h; GB_INTEGER align) + + CHECK_DEVICE(); + + if (MISSING(x) || MISSING(y)) + { + PAINT->Text(THIS, STRING(text), LENGTH(text)); + return; + } + + if (MISSING(w) || MISSING(h)) + { + PAINT->MoveTo(THIS, (float)VARG(x), (float)VARG(y)); + PAINT->Text(THIS, STRING(text), LENGTH(text)); + return; + } + + fprintf(stderr, "Paint.Text: Not yet implemented\n"); + +END_METHOD + +BEGIN_METHOD(Paint_TextExtents, GB_STRING text) + + PAINT_EXTENTS *extents; + + CHECK_DEVICE(); + + GB.New(POINTER(&extents), GB.FindClass("PaintExtents"), NULL, NULL); + PAINT->TextExtents(THIS, STRING(text), LENGTH(text), &extents->ext); + + GB.ReturnObject(extents); + +END_METHOD + +static void make_brush(GB_BRUSH brush) +{ + PAINT_BRUSH *that; + GB.New(POINTER(&that), GB.FindClass("PaintBrush"), NULL, NULL); + that->brush = brush; + GB.ReturnObject(that); +} + +BEGIN_METHOD(Paint_Color, GB_INTEGER color) + + GB_BRUSH brush; + + CHECK_DEVICE(); + + PAINT->Brush.Color(&brush, VARG(color)); + make_brush(brush); + +END_METHOD + +BEGIN_METHOD(Paint_Image, GB_OBJECT image; GB_FLOAT x; GB_FLOAT y; GB_INTEGER extend) + + GB_BRUSH brush; + + CHECK_DEVICE(); + + if (GB.CheckObject(VARG(image))) + return; + + PAINT->Brush.Image(&brush, (GB_IMAGE)VARG(image), (float)VARGOPT(x, 0), (float)VARGOPT(y, 0), VARGOPT(extend, GB_PAINT_EXTEND_PAD)); + make_brush(brush); + +END_METHOD + +static void handle_color_stop(GB_BRUSH brush, GB_ARRAY positions, GB_ARRAY colors) +{ + int nstop; + + nstop = Min(GB.Array.Count(positions), GB.Array.Count(colors)); + if (nstop) + PAINT->Brush.SetColorStops(brush, nstop, (double *)GB.Array.Get(positions, 0), (GB_COLOR *)GB.Array.Get(colors, 0)); +} + +BEGIN_METHOD(Paint_LinearGradient, GB_FLOAT x0; GB_FLOAT y0; GB_FLOAT x1; GB_FLOAT y1; GB_OBJECT positions; GB_OBJECT colors) + + GB_BRUSH brush; + GB_ARRAY positions, colors; + + positions = (GB_ARRAY)VARG(positions); + if (GB.CheckObject(positions)) + return; + colors = (GB_ARRAY)VARG(colors); + if (GB.CheckObject(colors)) + return; + + PAINT->Brush.LinearGradient(&brush, (float)VARG(x0), (float)VARG(y0), (float)VARG(x1), (float)VARG(y1)); + handle_color_stop(brush, positions, colors); + make_brush(brush); + +END_METHOD + +BEGIN_METHOD(Paint_RadialGradient, GB_FLOAT cx0; GB_FLOAT cy0; GB_FLOAT radius0; GB_FLOAT cx1; GB_FLOAT cy1; GB_FLOAT radius1; GB_OBJECT positions; GB_OBJECT colors) + + GB_BRUSH brush; + GB_ARRAY positions, colors; + + positions = (GB_ARRAY)VARG(positions); + if (GB.CheckObject(positions)) + return; + colors = (GB_ARRAY)VARG(colors); + if (GB.CheckObject(colors)) + return; + + PAINT->Brush.RadialGradient(&brush, (float)VARG(cx0), (float)VARG(cy0), (float)VARG(radius0), (float)VARG(cx1), (float)VARG(cy1), (float)VARG(radius1)); + handle_color_stop(brush, positions, colors); + make_brush(brush); + +END_METHOD + + GB_DESC CPaintDesc[] = { GB_DECLARE("Paint", 0), GB_VIRTUAL_CLASS(), @@ -502,6 +625,8 @@ GB_DESC CPaintDesc[] = //GB_STATIC_METHOD("NewSubPath", NULL, CAIRO_new_sub_path, NULL), GB_STATIC_METHOD("ClosePath", NULL, Paint_ClosePath, NULL), + GB_STATIC_PROPERTY_READ("X", "f", Paint_X), + GB_STATIC_PROPERTY_READ("Y", "f", Paint_Y), GB_STATIC_METHOD("Arc", NULL, Paint_Arc, "(XC)f(YC)f(Radius)f[(Angle1)f(Angle2)f]"), //GB_STATIC_METHOD("ArcNegative", NULL, CAIRO_arc_negative, "(XC)f(YC)f(Radius)f[(Angle1)f(Angle2)f]"), GB_STATIC_METHOD("CurveTo", NULL, Paint_CurveTo, "(X1)f(Y1)f(X2)f(Y2)f(X3)f(Y3)f"), @@ -509,18 +634,16 @@ GB_DESC CPaintDesc[] = GB_STATIC_METHOD("MoveTo", NULL, Paint_MoveTo, "(X)f(Y)f"), GB_STATIC_METHOD("Rectangle", NULL, Paint_Rectangle, "(X)f(Y)f(Width)f(Height)f"), - #if 0 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("TextExtents", "TextExtents", Paint_TextExtents, "(Text)s"), - GB_STATIC_METHOD("ColorBrush", "PaintBrush", Paint_ColorBrush, "(Color)i"), - GB_STATIC_METHOD("ImageBrush", "PaintBrush", Paint_ImageBrush, "(Image)Image;[(X)f(Y)f(Extend)i]"), - GB_STATIC_METHOD("LinearGradient", "PaintBrush", Paint_LinearGradient, "(X0)f(Y0)f(X1)f(Y1)f(Colors)Float[][];"), - GB_STATIC_METHOD("RadialGradient", "PaintBrush", Paint_RadialGradient, "(CX0)f(CY0)f(Radius0)f(CX1)f(CY1)f(Radius1)f(Colors)Float[][];"), + GB_STATIC_METHOD("Color", "PaintBrush", Paint_Color, "(Color)i"), + GB_STATIC_METHOD("Image", "PaintBrush", Paint_Image, "(Image)Image;[(X)f(Y)f(Extend)i]"), + GB_STATIC_METHOD("LinearGradient", "PaintBrush", Paint_LinearGradient, "(X0)f(Y0)f(X1)f(Y1)f(Positions)Float[];(Colors)Integer[];"), + GB_STATIC_METHOD("RadialGradient", "PaintBrush", Paint_RadialGradient, "(CX0)f(CY0)f(Radius0)f(CX1)f(CY1)f(Radius1)f(Positions)Float[];(Colors)Integer[];"), GB_STATIC_PROPERTY_SELF("Matrix", ".PaintMatrix"), - #endif GB_END_DECLARE }; diff --git a/main/lib/draw/gb.paint.h b/main/lib/draw/gb.paint.h index 014c06b60..7cadd1c7c 100644 --- a/main/lib/draw/gb.paint.h +++ b/main/lib/draw/gb.paint.h @@ -71,7 +71,7 @@ struct GB_PAINT_DESC; typedef struct { - double x1, y1, x2, y2; + float x1, y1, x2, y2; } GB_EXTENTS; @@ -138,34 +138,35 @@ typedef void (*Stroke)(GB_PAINT *d, bool preserve); void (*PathExtents)(GB_PAINT *d, GB_EXTENTS *ext); - bool (*PathContains)(GB_PAINT *d, double x, double y); + bool (*PathContains)(GB_PAINT *d, float x, float y); - void (*Dash)(GB_PAINT *d, bool set, double **dash, int *count); - void (*DashOffset)(GB_PAINT *d, bool set, double *offset); + void (*Dash)(GB_PAINT *d, bool set, float **dash, int *count); + void (*DashOffset)(GB_PAINT *d, bool set, float *offset); void (*FillRule)(GB_PAINT *d, bool set, int *value); void (*LineCap)(GB_PAINT *d, bool set, int *value); void (*LineJoin)(GB_PAINT *d, bool set, int *value); - void (*LineWidth)(GB_PAINT *d, bool set, double *value); - void (*MiterLimit)(GB_PAINT *d, bool set, double *value); + void (*LineWidth)(GB_PAINT *d, bool set, float *value); + void (*MiterLimit)(GB_PAINT *d, bool set, float *value); void (*Operator)(GB_PAINT *d, bool set, int *value); void (*NewPath)(GB_PAINT *d); void (*ClosePath)(GB_PAINT *d); - void (*Arc)(GB_PAINT *d, double xc, double yc, double radius, double a1, double a2); - void (*Rectangle)(GB_PAINT *d, double x, double y, double width, double height); - void (*MoveTo)(GB_PAINT *d, double x, double y); - void (*LineTo)(GB_PAINT *d, double x, double y); - void (*CurveTo)(GB_PAINT *d, double x1, double y1, double x2, double y2, double x3, double y3); + void (*Arc)(GB_PAINT *d, float xc, float yc, float radius, float a1, float a2); + void (*Rectangle)(GB_PAINT *d, float x, float y, float width, float height); + void (*GetCurrentPoint)(GB_PAINT *d, float *x, float *y); + void (*MoveTo)(GB_PAINT *d, float x, float y); + void (*LineTo)(GB_PAINT *d, float x, float y); + void (*CurveTo)(GB_PAINT *d, float x1, float y1, float x2, float y2, float x3, float y3); - void (*Text)(GB_PAINT *d, const char *text); - void (*TextExtents)(GB_PAINT *d, const char *text, GB_EXTENTS *ext); + void (*Text)(GB_PAINT *d, const char *text, int len); + void (*TextExtents)(GB_PAINT *d, const char *text, int len, GB_EXTENTS *ext); - void (*Translate)(GB_PAINT *d, double tx, double ty); - void (*Scale)(GB_PAINT *d, double sx, double sy); - void (*Rotate)(GB_PAINT *d, double angle); + void (*Translate)(GB_PAINT *d, float tx, float ty); + void (*Scale)(GB_PAINT *d, float sx, float sy); + void (*Rotate)(GB_PAINT *d, float angle); void (*Matrix)(GB_PAINT *d, bool set, GB_TRANSFORM *matrix); void (*SetBrush)(GB_PAINT *d, GB_BRUSH brush); @@ -173,19 +174,19 @@ typedef struct { void (*Free)(GB_BRUSH brush); void (*Color)(GB_BRUSH *brush, GB_COLOR color); - void (*Image)(GB_BRUSH *brush, GB_IMAGE image, double x, double y, int extend); - void (*LinearGradient)(GB_BRUSH *brush, double x0, double y0, double x1, double y1); - void (*RadialGradient)(GB_BRUSH *brush, double cx0, double cy0, double r0, double cx1, double cy1, double r1); - void (*SetColorStop)(GB_BRUSH brush, int nstop, double *pos, GB_COLOR *color); + void (*Image)(GB_BRUSH *brush, GB_IMAGE image, float x, float y, int extend); + void (*LinearGradient)(GB_BRUSH *brush, float x0, float y0, float x1, float y1); + void (*RadialGradient)(GB_BRUSH *brush, float cx0, float cy0, float r0, float cx1, float cy1, float r1); + void (*SetColorStops)(GB_BRUSH brush, int nstop, double *pos, GB_COLOR *color); void (*Matrix)(GB_BRUSH brush, bool set, GB_TRANSFORM *matrix); } Brush; struct { - void (*Init)(GB_TRANSFORM matrix, double xx, double yx, double xy, double yy, double x0, double y0); - void (*Translate)(GB_TRANSFORM matrix, double tx, double ty); - void (*Scale)(GB_TRANSFORM matrix, double sx, double sy); - void (*Rotate)(GB_TRANSFORM matrix, double angle); + void (*Init)(GB_TRANSFORM matrix, float xx, float yx, float xy, float yy, float x0, float y0); + void (*Translate)(GB_TRANSFORM matrix, float tx, float ty); + void (*Scale)(GB_TRANSFORM matrix, float sx, float sy); + void (*Rotate)(GB_TRANSFORM matrix, float angle); bool (*Invert)(GB_TRANSFORM matrix); void (*Multiply)(GB_TRANSFORM matrix, GB_TRANSFORM matrix2); }