# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1315778215 0 # Node ID 091ed7c20b3fd44763c592782122d7fb6a26fd52 # Parent 9d97610b21403a34b7d8863cc9127292379a84fb Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2. Added the function to the template and fixed the comments on several platforms. diff -r 9d97610b2140 -r 091ed7c20b3f dw.def --- a/dw.def Sun Sep 11 21:36:07 2011 +0000 +++ b/dw.def Sun Sep 11 21:56:55 2011 +0000 @@ -210,6 +210,7 @@ dw_pixmap_new_from_file @344 dw_pixmap_new_from_data @345 dw_pixmap_set_transparent_color @346 + dw_pixmap_set_font @347 dw_dialog_new @350 dw_dialog_dismiss @351 diff -r 9d97610b2140 -r 091ed7c20b3f dww.def --- a/dww.def Sun Sep 11 21:36:07 2011 +0000 +++ b/dww.def Sun Sep 11 21:56:55 2011 +0000 @@ -207,6 +207,7 @@ dw_pixmap_new_from_file @344 dw_pixmap_new_from_data @345 dw_pixmap_set_transparent_color @346 + dw_pixmap_set_font @347 dw_dialog_new @350 dw_dialog_dismiss @351 diff -r 9d97610b2140 -r 091ed7c20b3f mac/dw.m --- a/mac/dw.m Sun Sep 11 21:36:07 2011 +0000 +++ b/mac/dw.m Sun Sep 11 21:56:55 2011 +0000 @@ -6294,7 +6294,6 @@ return pixmap; } - /* * Sets the font used by a specified pixmap. * Normally the pixmap font is obtained from the associated window handle. @@ -6303,6 +6302,8 @@ * pixmap: Handle to a pixmap returned by dw_pixmap_new() or * passed to the application via a callback. * fontname: Name and size of the font in the form "size.fontname" + * Returns: + * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. */ int API dw_pixmap_set_font(HPIXMAP pixmap, char *fontname) { diff -r 9d97610b2140 -r 091ed7c20b3f template/dw.c --- a/template/dw.c Sun Sep 11 21:36:07 2011 +0000 +++ b/template/dw.c Sun Sep 11 21:56:55 2011 +0000 @@ -2186,6 +2186,22 @@ } /* + * Sets the font used by a specified pixmap. + * Normally the pixmap font is obtained from the associated window handle. + * However this can be used to override that, or for pixmaps with no window. + * Parameters: + * pixmap: Handle to a pixmap returned by dw_pixmap_new() or + * passed to the application via a callback. + * fontname: Name and size of the font in the form "size.fontname" + * Returns: + * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. +*/ +int API dw_pixmap_set_font(HPIXMAP pixmap, char *fontname) +{ + return DW_ERROR_GENERAL; +} + +/* * Destroys an allocated pixmap. * Parameters: * pixmap: Handle to a pixmap returned by diff -r 9d97610b2140 -r 091ed7c20b3f win/dw.c --- a/win/dw.c Sun Sep 11 21:36:07 2011 +0000 +++ b/win/dw.c Sun Sep 11 21:56:55 2011 +0000 @@ -8618,7 +8618,7 @@ HDC hdc; int mustdelete = 0; HFONT hFont = 0, oldFont = 0; - ColorInfo *cinfo; + ColorInfo *cinfo = NULL; COLORREF background; if(handle) @@ -8630,7 +8630,9 @@ if(handle) cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); - else + else if(pixmap->font) + hFont = pixmap->font; + else if(pixmap->handle) cinfo = (ColorInfo *)GetWindowLongPtr(pixmap->handle, GWLP_USERDATA); if(cinfo) @@ -8988,6 +8990,35 @@ } /* + * Sets the font used by a specified pixmap. + * Normally the pixmap font is obtained from the associated window handle. + * However this can be used to override that, or for pixmaps with no window. + * Parameters: + * pixmap: Handle to a pixmap returned by dw_pixmap_new() or + * passed to the application via a callback. + * fontname: Name and size of the font in the form "size.fontname" + * Returns: + * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. + */ +int API dw_pixmap_set_font(HPIXMAP pixmap, char *fontname) +{ + if(pixmap) + { + HFONT hfont = _acquire_font(pixmap->handle, fontname); + + if(hfont) + { + HFONT oldfont = pixmap->font; + pixmap->font = hfont; + if(oldfont) + DeleteObject(oldfont); + return DW_ERROR_NONE; + } + } + return DW_ERROR_GENERAL; +} + +/* * Destroys an allocated pixmap. * Parameters: * pixmap: Handle to a pixmap returned by @@ -8997,9 +9028,11 @@ { if(pixmap) { - DeleteDC( pixmap->hdc ); - DeleteObject( pixmap->hbm ); - free( pixmap ); + DeleteDC(pixmap->hdc); + DeleteObject(pixmap->hbm); + if(pixmap->font) + DeleteObject(pixmap->font); + free(pixmap); } } @@ -10058,8 +10091,8 @@ if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) return result; - pixmap->width = GetDeviceCaps(p->pd.hDC, PHYSICALWIDTH); - pixmap->height = GetDeviceCaps(p->pd.hDC, PHYSICALHEIGHT); + pixmap->width = GetDeviceCaps(p->pd.hDC, HORZRES); + pixmap->height = GetDeviceCaps(p->pd.hDC, VERTRES); /*pixmap->handle = handle;*/ pixmap->hbm = CreateCompatibleBitmap(p->pd.hDC, pixmap->width, pixmap->height);