Added Control.preferredSize() and preferredSize() for all the standard Controls.

This commit is contained in:
Pietro Gagliardi 2014-02-24 10:56:35 -05:00
parent 1510af0005
commit 53db57745f
7 changed files with 49 additions and 0 deletions

View File

@ -67,3 +67,11 @@ func (b *Button) setRect(x int, y int, width int, height int) error {
return b.sysData.setRect(x, y, width, height)
}
func (b *Button) preferredSize() (width int, height int, err error) {
b.lock.Lock()
defer b.lock.Unlock()
width, height = b.sysData.preferredSize()
return
}

View File

@ -74,3 +74,11 @@ func (c *Checkbox) setRect(x int, y int, width int, height int) error {
return c.sysData.setRect(x, y, width, height)
}
func (c *Checkbox) preferredSize() (width int, height int, err error) {
c.lock.Lock()
defer c.lock.Unlock()
width, height = c.sysData.preferredSize()
return
}

View File

@ -110,3 +110,11 @@ func (c *Combobox) setRect(x int, y int, width int, height int) error {
return c.sysData.setRect(x, y, width, height)
}
func (c *Combobox) preferredSize() (width int, height int, err error) {
c.lock.Lock()
defer c.lock.Unlock()
width, height = c.sysData.preferredSize()
return
}

View File

@ -9,4 +9,5 @@ import (
type Control interface {
make(window *sysData) error
setRect(x int, y int, width int, height int) error
preferredSize() (width int, height int, err error)
}

View File

@ -62,3 +62,11 @@ func (l *Label) setRect(x int, y int, width int, height int) error {
return l.sysData.setRect(x, y, width, height)
}
func (l *Label) preferredSize() (width int, height int, err error) {
l.lock.Lock()
defer l.lock.Unlock()
width, height = l.sysData.preferredSize()
return
}

View File

@ -64,3 +64,11 @@ func (l *LineEdit) setRect(x int, y int, width int, height int) error {
return l.sysData.setRect(x, y, width, height)
}
func (l *LineEdit) preferredSize() (width int, height int, err error) {
l.lock.Lock()
defer l.lock.Unlock()
width, height = l.sysData.preferredSize()
return
}

View File

@ -110,3 +110,11 @@ func (l *Listbox) setRect(x int, y int, width int, height int) error {
return l.sysData.setRect(x, y, width, height)
}
func (l *Listbox) preferredSize() (width int, height int, err error) {
l.lock.Lock()
defer l.lock.Unlock()
width, height = l.sysData.preferredSize()
return
}