comparison os2/dw.c @ 1182:cef7400dcaba

Switch to using a dummy window handle for pixmap fonts on OS/2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 20 Sep 2011 23:52:36 +0000
parents 5d3c1b0686ce
children 0f85796c6988
comparison
equal deleted inserted replaced
1181:5d3c1b0686ce 1182:cef7400dcaba
8361 * y: Y coordinate. 8361 * y: Y coordinate.
8362 * text: Text to be displayed. 8362 * text: Text to be displayed.
8363 */ 8363 */
8364 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) 8364 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
8365 { 8365 {
8366 HPS hps; 8366 HPS hps;
8367 int z, height; 8367 int z, height;
8368 RECTL rcl; 8368 RECTL rcl;
8369 char fontname[128]; 8369 char fontname[128];
8370 POINTL aptl[TXTBOX_COUNT]; 8370 POINTL aptl[TXTBOX_COUNT];
8371 8371
8372 if(handle) 8372 if(handle)
8373 { 8373 {
8374 hps = _set_colors(handle); 8374 hps = _set_colors(handle);
8375 height = _get_height(handle); 8375 height = _get_height(handle);
8376 _GetPPFont(handle, fontname); 8376 _GetPPFont(handle, fontname);
8377 } 8377 }
8378 else if(pixmap) 8378 else if(pixmap)
8379 { 8379 {
8380 HPS pixmaphps = WinGetPS(pixmap->handle); 8380 HPS pixmaphps = WinGetPS(pixmap->font ? pixmap->font : pixmap->handle);
8381 8381
8382 hps = _set_hps(pixmap->hps); 8382 hps = _set_hps(pixmap->hps);
8383 height = pixmap->height; 8383 height = pixmap->height;
8384 _GetPPFont(pixmap->handle, fontname); 8384 _GetPPFont(pixmap->font ? pixmap->font : pixmap->handle, fontname);
8385 _CopyFontSettings(pixmaphps, hps); 8385 _CopyFontSettings(pixmaphps, hps);
8386 WinReleasePS(pixmaphps); 8386 WinReleasePS(pixmaphps);
8387 } 8387 }
8388 else 8388 else
8389 return; 8389 return;
8390 8390
8391 for(z=0;z<strlen(fontname);z++) 8391 for(z=0;z<strlen(fontname);z++)
8392 { 8392 {
8393 if(fontname[z]=='.') 8393 if(fontname[z]=='.')
8394 break; 8394 break;
8395 } 8395 }
8396 8396
8397 GpiQueryTextBox(hps, strlen(text), text, TXTBOX_COUNT, aptl); 8397 GpiQueryTextBox(hps, strlen(text), text, TXTBOX_COUNT, aptl);
8398 8398
8399 rcl.xLeft = x; 8399 rcl.xLeft = x;
8400 rcl.yTop = height - y; 8400 rcl.yTop = height - y;
8401 rcl.yBottom = rcl.yTop - (aptl[TXTBOX_TOPLEFT].y - aptl[TXTBOX_BOTTOMLEFT].y); 8401 rcl.yBottom = rcl.yTop - (aptl[TXTBOX_TOPLEFT].y - aptl[TXTBOX_BOTTOMLEFT].y);
8402 rcl.xRight = rcl.xLeft + (aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_TOPLEFT].x); 8402 rcl.xRight = rcl.xLeft + (aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_TOPLEFT].x);
8403 8403
8404 if(_background == DW_CLR_DEFAULT) 8404 if(_background == DW_CLR_DEFAULT)
8405 WinDrawText(hps, -1, text, &rcl, DT_TEXTATTRS, DT_TEXTATTRS, DT_VCENTER | DT_LEFT | DT_TEXTATTRS); 8405 WinDrawText(hps, -1, text, &rcl, DT_TEXTATTRS, DT_TEXTATTRS, DT_VCENTER | DT_LEFT | DT_TEXTATTRS);
8406 else 8406 else
8407 WinDrawText(hps, -1, text, &rcl, _internal_color(_foreground), _internal_color(_background), DT_VCENTER | DT_LEFT | DT_ERASERECT); 8407 WinDrawText(hps, -1, text, &rcl, _internal_color(_foreground), _internal_color(_background), DT_VCENTER | DT_LEFT | DT_ERASERECT);
8408 8408
8409 if(!pixmap) 8409 if(!pixmap)
8410 WinReleasePS(hps); 8410 WinReleasePS(hps);
8411 } 8411 }
8412 8412
8413 /* Query the width and height of a text string. 8413 /* Query the width and height of a text string.
8414 * Parameters: 8414 * Parameters:
8415 * handle: Handle to the window. 8415 * handle: Handle to the window.
8795 */ 8795 */
8796 int API dw_pixmap_set_font(HPIXMAP pixmap, char *fontname) 8796 int API dw_pixmap_set_font(HPIXMAP pixmap, char *fontname)
8797 { 8797 {
8798 if(pixmap && fontname && *fontname) 8798 if(pixmap && fontname && *fontname)
8799 { 8799 {
8800 char *name = strchr(fontname, '.'); 8800 if(!pixmap->font)
8801 8801 pixmap->font = WinCreateWindow(HWND_OBJECT, WC_FRAME, NULL, 0,0,0,1,1, NULLHANDLE, HWND_TOP,0, NULL, NULL);
8802 if(name) 8802 WinSetPresParam(pixmap->font, PP_FONTNAMESIZE, strlen(fontname)+1, fontname);
8803 { 8803 return DW_ERROR_NONE;
8804 FATTRS fat;
8805
8806 memset(&fat, 0, sizeof(fat));
8807
8808 fat.usRecordLength = sizeof(FATTRS);
8809 strcpy(fat.szFacename, name);
8810
8811 GpiCreateLogFont(pixmap->hps, 0, 1L, &fat);
8812 GpiSetCharSet(pixmap->hps, 1L);
8813 return DW_ERROR_NONE;
8814 }
8815 } 8804 }
8816 return DW_ERROR_GENERAL; 8805 return DW_ERROR_GENERAL;
8817 } 8806 }
8818 8807
8819 /* 8808 /*
8822 * pixmap: Handle to a pixmap returned by 8811 * pixmap: Handle to a pixmap returned by
8823 * dw_pixmap_new.. 8812 * dw_pixmap_new..
8824 */ 8813 */
8825 void API dw_pixmap_destroy(HPIXMAP pixmap) 8814 void API dw_pixmap_destroy(HPIXMAP pixmap)
8826 { 8815 {
8827 GpiSetBitmap(pixmap->hps, NULLHANDLE); 8816 if(pixmap->font)
8828 GpiDeleteBitmap(pixmap->hbm); 8817 WinDestroyWindow(pixmap->font);
8829 GpiAssociate(pixmap->hps, NULLHANDLE); 8818 GpiSetBitmap(pixmap->hps, NULLHANDLE);
8830 GpiDestroyPS(pixmap->hps); 8819 GpiDeleteBitmap(pixmap->hbm);
8831 DevCloseDC(pixmap->hdc); 8820 GpiAssociate(pixmap->hps, NULLHANDLE);
8832 free(pixmap); 8821 GpiDestroyPS(pixmap->hps);
8822 DevCloseDC(pixmap->hdc);
8823 free(pixmap);
8833 } 8824 }
8834 8825
8835 /* 8826 /*
8836 * Copies from one item to another. 8827 * Copies from one item to another.
8837 * Parameters: 8828 * Parameters:
8849 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) 8840 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc)
8850 { 8841 {
8851 HPS hpsdest; 8842 HPS hpsdest;
8852 HPS hpssrc; 8843 HPS hpssrc;
8853 POINTL ptl[4]; 8844 POINTL ptl[4];
8854 int destheight, srcheight; 8845 int destheight, srcheight;
8855 8846
8856 if(dest) 8847 if(dest)
8857 { 8848 {
8858 hpsdest = WinGetPS(dest); 8849 hpsdest = WinGetPS(dest);
8859 destheight = _get_height(dest); 8850 destheight = _get_height(dest);
10331 return result; 10322 return result;
10332 10323
10333 /* Start the job */ 10324 /* Start the job */
10334 DevEscape(p->hdc, DEVESC_STARTDOC, strlen(p->jobname), p->jobname, NULL, NULL); 10325 DevEscape(p->hdc, DEVESC_STARTDOC, strlen(p->jobname), p->jobname, NULL, NULL);
10335 10326
10336 /*pixmap->handle = handle;*/ 10327 pixmap->font = WinCreateWindow(HWND_OBJECT, WC_FRAME, NULL, 0,0,0,1,1, NULLHANDLE, HWND_TOP,0, NULL, NULL);
10337 pixmap->hdc = p->hdc; 10328 pixmap->hdc = p->hdc;
10338 pixmap->hps = GpiCreatePS(dwhab, p->hdc, &sizl, PU_PELS | GPIF_DEFAULT | GPIT_NORMAL | GPIA_ASSOC); 10329 pixmap->hps = GpiCreatePS(dwhab, p->hdc, &sizl, PU_PELS | GPIF_DEFAULT | GPIT_NORMAL | GPIA_ASSOC);
10339 pixmap->transcolor = DW_RGB_TRANSPARENT; 10330 pixmap->transcolor = DW_RGB_TRANSPARENT;
10340 pixmap->width = sizl.cx; 10331 pixmap->width = sizl.cx;
10341 pixmap->height = sizl.cy; 10332 pixmap->height = sizl.cy;
10333 dw_pixmap_set_font(pixmap, DefaultFont);
10342 10334
10343 /* Cycle through each page */ 10335 /* Cycle through each page */
10344 for(x=p->startpage-1; x<p->endpage && p->drawfunc; x++) 10336 for(x=p->startpage-1; x<p->endpage && p->drawfunc; x++)
10345 { 10337 {
10346 p->drawfunc(print, pixmap, x, p->drawdata); 10338 p->drawfunc(print, pixmap, x, p->drawdata);