diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-09 10:26:42 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-09 10:26:42 -0400 |
| commit | b4a97e871a5c6c390927f5bac9b84b0fe6b40c20 (patch) | |
| tree | 0b4499da73aca7e588b9d44c97a57d7be8e76901 /redo/container_windows.c | |
| parent | 5198f7202f736ff4d2966e7e6051165bb25f72bb (diff) | |
Settled the placement of functions formerly in sizing_windows.c and updated the winapi_windows.h header file to suit.
Diffstat (limited to 'redo/container_windows.c')
| -rw-r--r-- | redo/container_windows.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/redo/container_windows.c b/redo/container_windows.c index f568440..5f71fe2 100644 --- a/redo/container_windows.c +++ b/redo/container_windows.c @@ -82,3 +82,26 @@ HWND newContainer(void *data) xpanic("container creation failed", GetLastError()); return hwnd; } + +void calculateBaseUnits(HWND hwnd, int *baseX, int *baseY, LONG *internalLeading) +{ + HDC dc; + HFONT prevFont; + TEXTMETRICW tm; + + dc = GetDC(hwnd); + if (dc == NULL) + xpanic("error getting DC for preferred size calculations", GetLastError()); + prevFont = (HFONT) SelectObject(dc, controlFont); + if (prevFont == NULL) + xpanic("error loading control font into device context for preferred size calculation", GetLastError()); + if (GetTextMetricsW(dc, &tm) == 0) + xpanic("error getting text metrics for preferred size calculations", GetLastError()); + *baseX = (int) tm.tmAveCharWidth; /* TODO not optimal; third reference below has better way */ + *baseY = (int) tm.tmHeight; + *internalLeading = tm.tmInternalLeading; + if (SelectObject(dc, prevFont) != controlFont) + xpanic("error restoring previous font into device context after preferred size calculations", GetLastError()); + if (ReleaseDC(hwnd, dc) == 0) + xpanic("error releasing DC for preferred size calculations", GetLastError()); +} |
