diff options
-rw-r--r-- | html/en/history.html | 3 | ||||
-rw-r--r-- | html/examples/iuplua_cdlua.wlua | 3 | ||||
-rw-r--r-- | mak.vc9/cdluacontextplus51.vcproj | 4 | ||||
-rw-r--r-- | src/cairo/cdcaironative_gdk.c | 34 |
4 files changed, 37 insertions, 7 deletions
diff --git a/html/en/history.html b/html/en/history.html index 06eb512..f68efe6 100644 --- a/html/en/history.html +++ b/html/en/history.html @@ -62,6 +62,9 @@ <li> <span class="hist_fixed">Fixed:</span> locale in SVG for floating point numbers, it must use dots "." for decimal separators.</li> + <li> + <span class="hist_fixed">Fixed:</span> Cairo context plus base driver + when used with GDK.</li> </ul> <h3><a href="http://sourceforge.net/projects/canvasdraw/files/5.4/">Version 5.4</a> (24/June/2010)</h3> <ul> diff --git a/html/examples/iuplua_cdlua.wlua b/html/examples/iuplua_cdlua.wlua index 5528117..d9c5058 100644 --- a/html/examples/iuplua_cdlua.wlua +++ b/html/examples/iuplua_cdlua.wlua @@ -1,6 +1,7 @@ require"cdlua" require"iuplua" require"iupluacd" +require"cdluacontextplus" cnv = iup.canvas {size = "200x100"} @@ -13,7 +14,9 @@ box = iup.vbox{ dlg = iup.dialog{box; title="Example IUPLUA/CDLUA"} function cnv:map_cb() + cd.UseContextPlus(true) canvas = cd.CreateCanvas(cd.IUP, self) + cd.UseContextPlus(false) self.canvas = canvas -- store the CD canvas in a IUP attribute end diff --git a/mak.vc9/cdluacontextplus51.vcproj b/mak.vc9/cdluacontextplus51.vcproj index 640408a..270fa02 100644 --- a/mak.vc9/cdluacontextplus51.vcproj +++ b/mak.vc9/cdluacontextplus51.vcproj @@ -89,10 +89,6 @@ </References> <Files> <File - RelativePath="..\include\cdluacontextplus.h" - > - </File> - <File RelativePath="..\src\lua5\cdluacontextplus5.c" > </File> diff --git a/src/cairo/cdcaironative_gdk.c b/src/cairo/cdcaironative_gdk.c index 29be6c6..e233ed6 100644 --- a/src/cairo/cdcaironative_gdk.c +++ b/src/cairo/cdcaironative_gdk.c @@ -20,10 +20,35 @@ static void cdkillcanvas(cdCtxCanvas *ctxcanvas) int cdactivate(cdCtxCanvas *ctxcanvas) { - gdk_drawable_get_size(ctxcanvas->drawable, &ctxcanvas->canvas->w, &ctxcanvas->canvas->h); + cdCanvas* canvas = ctxcanvas->canvas; + int old_w = canvas->w; + int old_h = canvas->h; - ctxcanvas->canvas->w_mm = ((double)ctxcanvas->canvas->w) / ctxcanvas->canvas->xres; - ctxcanvas->canvas->h_mm = ((double)ctxcanvas->canvas->h) / ctxcanvas->canvas->yres; + gdk_drawable_get_size(ctxcanvas->drawable, &canvas->w, &canvas->h); + + ctxcanvas->canvas->w_mm = ((double)canvas->w) / canvas->xres; + ctxcanvas->canvas->h_mm = ((double)canvas->h) / canvas->yres; + + if (old_w != canvas->w || old_h != canvas->h) + { + cairo_destroy(ctxcanvas->cr); + ctxcanvas->cr = gdk_cairo_create(ctxcanvas->drawable); + + ctxcanvas->last_source = -1; + + cairo_save(ctxcanvas->cr); + cairo_set_operator(ctxcanvas->cr, CAIRO_OPERATOR_OVER); + + /* update canvas attributes */ + canvas->cxForeground(ctxcanvas, canvas->foreground); + canvas->cxLineStyle(ctxcanvas, canvas->line_style); + canvas->cxLineWidth(ctxcanvas, canvas->line_width); + canvas->cxLineCap(ctxcanvas, canvas->line_cap); + canvas->cxLineJoin(ctxcanvas, canvas->line_join); + canvas->cxInteriorStyle(ctxcanvas, canvas->interior_style); + if (canvas->clip_mode != CD_CLIPOFF) canvas->cxClip(ctxcanvas, canvas->clip_mode); + if (canvas->use_matrix) canvas->cxTransform(ctxcanvas, canvas->matrix); + } return CD_OK; } @@ -35,6 +60,9 @@ static void cdcreatecanvas(cdCanvas* canvas, void *data) GdkScreen* screen; GdkDrawable* drawable = (GdkDrawable*)data; + if (!GDK_IS_DRAWABLE(drawable)) + return; + cr = gdk_cairo_create(drawable); if (!cr) return; |