Implemented container.bounds() on Windows.

This commit is contained in:
Pietro Gagliardi 2014-10-18 09:06:17 -04:00
parent 45acb35a6d
commit 1face3a455
3 changed files with 15 additions and 0 deletions

View File

@ -57,6 +57,15 @@ HWND newContainer(void)
return hwnd;
}
RECT containerBounds(HWND hwnd)
{
RECT r;
if (GetClientRect(hwnd, &r) == 0)
xpanic("error getting container client rect for container.bounds()", GetLastError());
return r;
}
void calculateBaseUnits(HWND hwnd, int *baseX, int *baseY, LONG *internalLeading)
{
HDC dc;

View File

@ -57,6 +57,11 @@ func (c *container) parent() *controlParent {
return &controlParent{c.hwnd}
}
func (c *container) bounds(d *sizing) (int, int, int, int) {
r := C.containerBounds(c.hwnd)
return int(r.left), int(r.top), int(r.right - r.left), int(r.bottom - r.top)
}
// For Windows, Microsoft just hands you a list of preferred control sizes as part of the MSDN documentation and tells you to roll with it.
// These sizes are given in "dialog units", which are independent of the font in use.
// We need to convert these into standard pixels, which requires we get the device context of the OS window.

View File

@ -125,6 +125,7 @@ extern void tableSelectItem(HWND, intptr_t);
#define containerclass L"gouicontainer"
extern DWORD makeContainerWindowClass(char **);
extern HWND newContainer();
extern RECT containerBounds(HWND);
extern void calculateBaseUnits(HWND, int *, int *, LONG *);
// area_windows.c