Removed previous commit's TODO and added Checkbox preferredSize() on Windows.

This commit is contained in:
Pietro Gagliardi 2014-08-01 20:56:11 -04:00
parent 83eeae1ec2
commit 3fca111710
1 changed files with 13 additions and 1 deletions

View File

@ -66,6 +66,7 @@ func newCheckbox(text string) *checkbox {
// we'll handle actually toggling the check state ourselves (see controls_windows.c) // we'll handle actually toggling the check state ourselves (see controls_windows.c)
button: startNewButton(text, C.BS_CHECKBOX), button: startNewButton(text, C.BS_CHECKBOX),
} }
c.fpreferredSize = c.checkboxpreferredSize
C.setCheckboxSubclass(c.hwnd, unsafe.Pointer(c)) C.setCheckboxSubclass(c.hwnd, unsafe.Pointer(c))
return c return c
} }
@ -96,6 +97,18 @@ type textField struct {
*controlbase *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") var editclass = toUTF16("EDIT")
func startNewTextField(style C.DWORD) *textField { func startNewTextField(style C.DWORD) *textField {
@ -174,7 +187,6 @@ const (
) )
func (l *label) labelpreferredSize(d *sizing) (width, height int) { 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) return int(l.textlen), fromdlgunitsY(labelHeight, d)
} }