[GB.DRAW]

* BUG: The optional painting area is correclty reset after a call to 
  Paint.Reset().
 

git-svn-id: svn://localhost/gambas/trunk@6936 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2015-03-02 18:20:56 +00:00
parent 7d72df028f
commit a07a02c086
4 changed files with 24 additions and 14 deletions

View file

@ -116,8 +116,8 @@ static bool init_painting(GB_PAINT *d, cairo_surface_t *target, double w, double
{
GB_PAINT_EXTRA *dx = EXTRA(d);
d->width = w;
d->height = h;
d->area.width = w;
d->area.height = h;
d->resolutionX = rx; //device->physicalDpiX();
d->resolutionY = ry; //device->physicalDpiY();

View file

@ -97,8 +97,8 @@ static bool init_painting(GB_PAINT *d, QPaintDevice *device)
{
QPen pen;
d->width = device->width();
d->height = device->height();
d->area.width = device->width();
d->area.height = device->height();
d->resolutionX = device->physicalDpiX();
d->resolutionY = device->physicalDpiY();
@ -236,8 +236,8 @@ static int Begin(GB_PAINT *d)
if (wid->isCached())
PAINTER(d)->initFrom(wid);
d->width = wid->width();
d->height = wid->height();
d->area.width = wid->width();
d->area.height = wid->height();
return FALSE;
}
else if (GB.Is(device, CLASS_Printer))

View file

@ -163,6 +163,7 @@ bool PAINT_begin(void *device)
paint->other = FALSE;
paint->has_path = FALSE;
paint->tag = NULL;
paint->area.x = paint->area.y = 0;
paint->previous = _current;
_current = paint;
@ -176,8 +177,7 @@ bool PAINT_begin(void *device)
paint->extra = other->extra;
paint->opened = TRUE;
paint->other = TRUE;
paint->width = other->width;
paint->height = other->height;
paint->area = other->area;
paint->resolutionX = other->resolutionX;
paint->resolutionY = other->resolutionY;
paint->brush = other->brush;
@ -219,6 +219,9 @@ void PAINT_translate(double tx, double ty)
{
GB_TRANSFORM transform;
if (tx == 0.0 && ty == 0.0)
return;
MPAINT->Create(&transform);
PAINT->Matrix(THIS, FALSE, transform);
MPAINT->Translate(transform, (float)tx, (float)ty);
@ -228,9 +231,11 @@ void PAINT_translate(double tx, double ty)
void PAINT_set_area(GEOM_RECTF *area)
{
THIS->area.x = area->x;
THIS->area.y = area->y;
THIS->area.width = area->w;
THIS->area.height = area->h;
PAINT_translate(area->x, area->y);
THIS->width = area->w;
THIS->height = area->h;
}
//---- PaintExtents ---------------------------------------------------------
@ -564,7 +569,7 @@ END_PROPERTY
BEGIN_PROPERTY(Paint_Width)
CHECK_DEVICE();
GB.ReturnFloat(THIS->width);
GB.ReturnFloat(THIS->area.width);
END_PROPERTY
@ -572,7 +577,7 @@ END_PROPERTY
BEGIN_PROPERTY(Paint_Height)
CHECK_DEVICE();
GB.ReturnFloat(THIS->height);
GB.ReturnFloat(THIS->area.height);
END_PROPERTY
@ -1302,6 +1307,7 @@ BEGIN_METHOD_VOID(Paint_Reset)
CHECK_DEVICE();
PAINT->Matrix(THIS, TRUE, NULL);
PAINT_translate(THIS->area.x, THIS->area.y);
END_METHOD

View file

@ -120,8 +120,12 @@ typedef
struct GB_PAINT_DESC *desc; // drawing driver
struct GB_PAINT *previous; // previous drawing context
void *device; // drawing object
double width; // device width in device coordinates
double height; // device height in device coordinates
struct {
double x;
double y;
double width;
double height;
} area; // drawing area
int resolutionX; // device horizontal resolution in DPI
int resolutionY; // device vertical resolution in DPI
PAINT_BRUSH *brush; // current brush