From 3fca1117107cb8a264abbb10b9755eefd93547e8 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 1 Aug 2014 20:56:11 -0400 Subject: [PATCH] Removed previous commit's TODO and added Checkbox preferredSize() on Windows. --- redo/basicctrls_windows.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/redo/basicctrls_windows.go b/redo/basicctrls_windows.go index b116ae3..feb4332 100644 --- a/redo/basicctrls_windows.go +++ b/redo/basicctrls_windows.go @@ -66,6 +66,7 @@ func newCheckbox(text string) *checkbox { // we'll handle actually toggling the check state ourselves (see controls_windows.c) button: startNewButton(text, C.BS_CHECKBOX), } + c.fpreferredSize = c.checkboxpreferredSize C.setCheckboxSubclass(c.hwnd, unsafe.Pointer(c)) return c } @@ -96,6 +97,18 @@ type textField struct { *controlbase } +const ( + // from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing + checkboxHeight = 10 + // from http://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx + checkboxXFromLeftOfBoxToLeftOfLabel = 12 +) + +func (c *checkbox) checkboxpreferredSize(d *sizing) (width, height int) { + return fromdlgunitsX(checkboxXFromLeftOfBoxToLeftOfLabel, d) + int(c.textlen), + fromdlgunitsY(checkboxHeight, d) +} + var editclass = toUTF16("EDIT") func startNewTextField(style C.DWORD) *textField { @@ -174,7 +187,6 @@ const ( ) func (l *label) labelpreferredSize(d *sizing) (width, height int) { - // TODO have some padding to the right of the width return int(l.textlen), fromdlgunitsY(labelHeight, d) }