diff options
author | Pixel <pixel@nobis-crew.org> | 2010-06-15 00:18:43 -0700 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2010-06-15 00:18:43 -0700 |
commit | 25e85e1b809ec58ecac0f2e8fe48f74836f8e131 (patch) | |
tree | a53caef2257fefdd6610a17427fd14ee656bbc92 /cd/src/win32 | |
parent | 7c0c85a86aa73c0c495523f994f8412e377a8195 (diff) |
Upgrading to CD 5.3
Diffstat (limited to 'cd/src/win32')
-rwxr-xr-x | cd/src/win32/cdwin.c | 39 | ||||
-rwxr-xr-x | cd/src/win32/cdwnative.c | 3 | ||||
-rwxr-xr-x | cd/src/win32/cdwprn.c | 41 |
3 files changed, 58 insertions, 25 deletions
diff --git a/cd/src/win32/cdwin.c b/cd/src/win32/cdwin.c index 371bb6d..313e833 100755 --- a/cd/src/win32/cdwin.c +++ b/cd/src/win32/cdwin.c @@ -575,6 +575,12 @@ static void cdstipple(cdCtxCanvas* ctxcanvas, int w, int h, const unsigned char DeleteObject(hBitmap); } +static void set_dib_res(cdwDIB* dib, cdCtxCanvas* ctxcanvas) +{ + dib->bmih->biXPelsPerMeter = (LONG)(ctxcanvas->canvas->xres*1000); + dib->bmih->biYPelsPerMeter = (LONG)(ctxcanvas->canvas->yres*1000); +} + static void cdpattern(cdCtxCanvas* ctxcanvas, int w, int h, const long int *colors) { cdwDIB dib; @@ -589,6 +595,9 @@ static void cdpattern(cdCtxCanvas* ctxcanvas, int w, int h, const long int *colo if (!cdwCreateDIB(&dib)) return; + /* trying to preserve pattern size during printing */ + set_dib_res(&dib, ctxcanvas); + cdwDIBEncodePattern(&dib, colors); hBrush = CreateDIBPatternBrushPt(dib.dib, DIB_RGB_COLORS); cdwKillDIB(&dib); @@ -997,8 +1006,6 @@ static void sTextOutBlt(cdCtxCanvas* ctxcanvas, int px, int py, const char* s, i /* calcula o alinhamento da imagem no canvas */ if (ctxcanvas->canvas->text_orientation != 0) { - double d = sqrt(wt*wt + ht*ht); - switch (ctxcanvas->canvas->text_alignment) { case CD_CENTER: @@ -1034,20 +1041,20 @@ static void sTextOutBlt(cdCtxCanvas* ctxcanvas, int px, int py, const char* s, i px_off = (int)(wt/2 * cos_teta); break; case CD_NORTH_EAST: - py_off = (int)(h/2); - px_off = - (int)(sqrt(d*d - h*h)/2); - break; - case CD_NORTH_WEST: - py_off = (int)(sqrt(d*d - w*w)/2); - px_off = - (int)(w/2); + py_off = (int)(ht/2 * cos_teta + wt/2 * sin_teta); + px_off = (int)(ht/2 * sin_teta - wt/2 * cos_teta); break; case CD_SOUTH_WEST: - py_off = - (int)(h/2); - px_off = (int)(sqrt(d*d - h*h)/2); + py_off = - (int)(ht/2 * cos_teta + wt/2 * sin_teta); + px_off = - (int)(ht/2 * sin_teta - wt/2 * cos_teta); + break; + case CD_NORTH_WEST: + py_off = (int)(ht/2 * cos_teta - wt/2 * sin_teta); + px_off = (int)(ht/2 * sin_teta + wt/2 * cos_teta); break; case CD_SOUTH_EAST: - py_off = - (int)(sqrt(d*d - w*w)/2); - px_off = (int)(w/2); + py_off = - (int)(ht/2 * cos_teta - wt/2 * sin_teta); + px_off = - (int)(ht/2 * sin_teta + wt/2 * cos_teta); break; } } @@ -1095,7 +1102,7 @@ static void sTextOutBlt(cdCtxCanvas* ctxcanvas, int px, int py, const char* s, i case CD_CENTER: case CD_EAST: case CD_WEST: - py_off = py; + py_off = 0; break; } } @@ -2366,3 +2373,9 @@ void cdwInitTable(cdCanvas* canvas) if (ctxcanvas->wtype == CDW_EMF) canvas->cxPutImageRectRGBA = cdputimagerectrgba; } + +int cdBaseDriver(void) +{ + return CD_BASE_WIN; +} + diff --git a/cd/src/win32/cdwnative.c b/cd/src/win32/cdwnative.c index fdc223e..69623e1 100755 --- a/cd/src/win32/cdwnative.c +++ b/cd/src/win32/cdwnative.c @@ -165,8 +165,7 @@ static void cdcreatecanvas(cdCanvas* canvas, void *data) if (hWnd) { - LONG style; - style = GetClassLong(hWnd, GCL_STYLE); + LONG style = GetClassLong(hWnd, GCL_STYLE); ctxcanvas->isOwnedDC = (int) ((style & CS_OWNDC) || (style & CS_CLASSDC)); } else diff --git a/cd/src/win32/cdwprn.c b/cd/src/win32/cdwprn.c index 95e4aca..1b3e1e0 100755 --- a/cd/src/win32/cdwprn.c +++ b/cd/src/win32/cdwprn.c @@ -28,6 +28,9 @@ static void cdkillcanvas (cdCtxCanvas *ctxcanvas) cdwKillCanvas(ctxcanvas); DeleteDC(ctxcanvas->hDC); + + if (ctxcanvas->filename) + free(ctxcanvas->filename); memset(ctxcanvas, 0, sizeof(cdCtxCanvas)); free(ctxcanvas); @@ -46,6 +49,18 @@ static void cdflush(cdCtxCanvas *ctxcanvas) cdwRestoreDC(ctxcanvas); } +static char* get_printername_attrib(cdCtxCanvas* ctxcanvas) +{ + return ctxcanvas->filename; +} + +static cdAttribute printername_attrib = +{ + "PRINTERNAME", + NULL, + get_printername_attrib +}; + /* %F cdCreateCanvas para Impresora. Usa a impressora default. @@ -123,24 +138,30 @@ static void cdcreatecanvas(cdCanvas* canvas, void *data) canvas->w = GetDeviceCaps(hDC, HORZRES); canvas->h = GetDeviceCaps(hDC, VERTRES); - canvas->w_mm = (double) GetDeviceCaps(hDC, HORZSIZE); - canvas->h_mm = (double) GetDeviceCaps(hDC, VERTSIZE); + canvas->w_mm = (double)GetDeviceCaps(hDC, HORZSIZE); + canvas->h_mm = (double)GetDeviceCaps(hDC, VERTSIZE); canvas->bpp = GetDeviceCaps(hDC, BITSPIXEL); - canvas->xres = canvas->w / canvas->w_mm; - canvas->yres = canvas->h / canvas->h_mm; + canvas->xres = (double)canvas->w / canvas->w_mm; + canvas->yres = (double)canvas->h / canvas->h_mm; ctxcanvas->clip_pnt[2].x = ctxcanvas->clip_pnt[1].x = canvas->w - 1; ctxcanvas->clip_pnt[3].y = ctxcanvas->clip_pnt[2].y = canvas->h - 1; - /* PDF Writer returns bpp=1, so we check if color is supported and overwrite this value */ - if (canvas->bpp==1 && pd.hDevNames) + if (pd.hDevNames) { unsigned char* devnames = (unsigned char*)GlobalLock(pd.hDevNames); DEVNAMES* dn = (DEVNAMES*)devnames; - char* name = (char*)(devnames + dn->wDeviceOffset); - char* port = (char*)(devnames + dn->wOutputOffset); + char* device = (char*)(devnames + dn->wDeviceOffset); + + ctxcanvas->filename = cdStrDup(device); + cdRegisterAttribute(canvas, &printername_attrib); - if (DeviceCapabilities(name, port, DC_COLORDEVICE, NULL, NULL)) - canvas->bpp = 24; + /* PDF Writer returns bpp=1, so we check if color is supported and overwrite this value */ + if (canvas->bpp==1) + { + char* port = (char*)(devnames + dn->wOutputOffset); + if (DeviceCapabilities(device, port, DC_COLORDEVICE, NULL, NULL)) + canvas->bpp = 24; + } GlobalUnlock(pd.hDevNames); } |