Mercurial > dwindows
diff os2/dw.c @ 49:bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
without Dynamic Windows.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 09 Nov 2001 13:49:44 +0000 |
parents | 997e9ed670ef |
children | 0804483f6320 |
line wrap: on
line diff
--- a/os2/dw.c Mon Nov 05 10:56:39 2001 +0000 +++ b/os2/dw.c Fri Nov 09 13:49:44 2001 +0000 @@ -5406,8 +5406,45 @@ WinReleasePS(hps); } - - +/* Query the width and height of a text string. + * Parameters: + * handle: Handle to the window. + * pixmap: Handle to the pixmap. (choose only one of these) + * text: Text to be queried. + * width: Pointer to a variable to be filled in with the width. + * height Pointer to a variable to be filled in with the height. + */ +void dw_font_text_extents(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) +{ + HPS hps; + POINTL aptl[TXTBOX_COUNT]; + + if(handle) + { + hps = _set_colors(handle); + } + else if(pixmap) + { + HPS pixmaphps = WinGetPS(pixmap->handle); + + hps = _set_hps(pixmap->hps); + _CopyFontSettings(pixmaphps, hps); + WinReleasePS(pixmaphps); + } + else + return; + + GpiQueryTextBox(hps, strlen(text), text, TXTBOX_COUNT, aptl); + + if(width) + *width = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_TOPLEFT].x; + + if(height) + *height = aptl[TXTBOX_TOPLEFT].y - aptl[TXTBOX_BOTTOMLEFT].y; + + if(!pixmap) + WinReleasePS(hps); +} /* Draw a rectangle on a window (preferably a render window). * Parameters: