comparison 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
comparison
equal deleted inserted replaced
48:16eac0f8b45f 49:bf42d08d72d7
5404 5404
5405 if(!pixmap) 5405 if(!pixmap)
5406 WinReleasePS(hps); 5406 WinReleasePS(hps);
5407 } 5407 }
5408 5408
5409 5409 /* Query the width and height of a text string.
5410 5410 * Parameters:
5411 * handle: Handle to the window.
5412 * pixmap: Handle to the pixmap. (choose only one of these)
5413 * text: Text to be queried.
5414 * width: Pointer to a variable to be filled in with the width.
5415 * height Pointer to a variable to be filled in with the height.
5416 */
5417 void dw_font_text_extents(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height)
5418 {
5419 HPS hps;
5420 POINTL aptl[TXTBOX_COUNT];
5421
5422 if(handle)
5423 {
5424 hps = _set_colors(handle);
5425 }
5426 else if(pixmap)
5427 {
5428 HPS pixmaphps = WinGetPS(pixmap->handle);
5429
5430 hps = _set_hps(pixmap->hps);
5431 _CopyFontSettings(pixmaphps, hps);
5432 WinReleasePS(pixmaphps);
5433 }
5434 else
5435 return;
5436
5437 GpiQueryTextBox(hps, strlen(text), text, TXTBOX_COUNT, aptl);
5438
5439 if(width)
5440 *width = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_TOPLEFT].x;
5441
5442 if(height)
5443 *height = aptl[TXTBOX_TOPLEFT].y - aptl[TXTBOX_BOTTOMLEFT].y;
5444
5445 if(!pixmap)
5446 WinReleasePS(hps);
5447 }
5411 5448
5412 /* Draw a rectangle on a window (preferably a render window). 5449 /* Draw a rectangle on a window (preferably a render window).
5413 * Parameters: 5450 * Parameters:
5414 * handle: Handle to the window. 5451 * handle: Handle to the window.
5415 * pixmap: Handle to the pixmap. (choose only one of these) 5452 * pixmap: Handle to the pixmap. (choose only one of these)