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/sizing_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/sizing_windows.c')
| -rw-r--r-- | redo/sizing_windows.c | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/redo/sizing_windows.c b/redo/sizing_windows.c deleted file mode 100644 index 5f14b19..0000000 --- a/redo/sizing_windows.c +++ /dev/null @@ -1,56 +0,0 @@ -/* 17 july 2014 */ - -#include "winapi_windows.h" -#include "_cgo_export.h" - -/* TODO figure out where these should go */ - -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()); -} - -void moveWindow(HWND hwnd, int x, int y, int width, int height) -{ - if (MoveWindow(hwnd, x, y, width, height, TRUE) == 0) - xpanic("error setting window/control rect", GetLastError()); -} - -LONG controlTextLength(HWND hwnd, LPWSTR text) -{ - HDC dc; - HFONT prev; - SIZE size; - - dc = GetDC(hwnd); - if (dc == NULL) - xpanic("error getting DC of control for text length", GetLastError()); - prev = SelectObject(dc, controlFont); - if (prev == NULL) - xpanic("error setting control font to DC for text length", GetLastError()); - if (GetTextExtentPoint32W(dc, text, wcslen(text), &size) == 0) - xpanic("error actually getting text length", GetLastError()); - if (SelectObject(dc, prev) != controlFont) - xpanic("error restoring previous control font to DC for text length", GetLastError()); - if (ReleaseDC(hwnd, dc) == 0) - xpanic("error releasing DC of control for text length", GetLastError()); - return size.cx; -} |
