Mercurial > dwindows
changeset 1147:091ed7c20b3f
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.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 11 Sep 2011 21:56:55 +0000 |
parents | 9d97610b2140 |
children | 439f276042cc |
files | dw.def dww.def mac/dw.m template/dw.c win/dw.c |
diffstat | 5 files changed, 60 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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
--- 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) {
--- 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
--- 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);