# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1306995517 0 # Node ID 6919854298fd78e2c72440f274152cb43bc18b05 # Parent 48f43c9755334aa291482f328e5d6769a93be21b Added dw_font_choose() on Windows for 2.1. diff -r 48f43c975533 -r 6919854298fd dww.def --- a/dww.def Thu Jun 02 05:23:45 2011 +0000 +++ b/dww.def Thu Jun 02 06:18:37 2011 +0000 @@ -233,6 +233,7 @@ dw_tree_get_parent @382 dw_font_text_extents_get @385 + dw_font_choose @386 dw_slider_new @390 dw_slider_get_pos @391 diff -r 48f43c975533 -r 6919854298fd mac/dw.m --- a/mac/dw.m Thu Jun 02 05:23:45 2011 +0000 +++ b/mac/dw.m Thu Jun 02 06:18:37 2011 +0000 @@ -7230,11 +7230,11 @@ return font; } -/* Allows the user to choose a color using the system's color chooser dialog. - * Parameters: - * value: current color +/* Allows the user to choose a font using the system's font chooser dialog. + * Parameters: + * currfont: current font * Returns: - * The selected color or the current color if cancelled. + * A malloced buffer with the selected font or NULL on error. */ char * API dw_font_choose(char *currfont) { diff -r 48f43c975533 -r 6919854298fd win/dw.c --- a/win/dw.c Thu Jun 02 05:23:45 2011 +0000 +++ b/win/dw.c Thu Jun 02 06:18:37 2011 +0000 @@ -3995,58 +3995,54 @@ SetParent(handle, newparent); } +LOGFONT _get_logfont(char *fontname) +{ + int Italic, Bold; + char *myFontName; + int z, size = 9; + LOGFONT lf; + for(z=0;z FW_MEDIUM ) + bold = " Bold"; + if ( lf.lfItalic ) + italic = " Italic"; + if ( lf.lfHeight <= 0 ) + height = abs (lf.lfHeight ); + else + /* + * we subtract 5 from a positive font height, because we (presumably) + * added 5 (in _acquire_font() above - don't know why ) + */ + height = lf.lfHeight - 5; + sprintf( str, "%d.%s%s%s", height, lf.lfFaceName, bold, italic ); + } + } + return str; +} + /* * Gets the font used by a specified window (widget) handle. * Parameters: @@ -4155,35 +4196,9 @@ height = lf.lfHeight - 5; sprintf( str, "%d.%s%s%s", height, lf.lfFaceName, bold, italic ); } - else - str = ""; - } - else - str = ""; + } if ( oldfont ) DeleteObject( oldfont ); -#if 0 -{ -HWND hwnd=NULL; // owner window -HDC hdc; // display device context of owner window - -CHOOSEFONT cf; // common dialog box structure -LOGFONT lf; // logical font structure -HFONT hfont, hfontPrev; - -// Initialize CHOOSEFONT -ZeroMemory(&cf, sizeof(cf)); -cf.lStructSize = sizeof (cf); -cf.hwndOwner = hwnd; -cf.lpLogFont = &lf; -cf.Flags = CF_SCREENFONTS | CF_EFFECTS; - -if (ChooseFont(&cf)==TRUE) -{ - hfont = CreateFontIndirect(cf.lpLogFont); -} -} -#endif return str; }