Added sysData.setWindowSize(), which will simplify a few things in Window.Open() and Control.make().

This commit is contained in:
Pietro Gagliardi 2014-02-15 13:02:10 -05:00
parent 0247935cbf
commit 32e70f6414
2 changed files with 28 additions and 1 deletions

View File

@ -48,6 +48,9 @@ func (c *cSysData) selectedIndices() ([]int, error) {
func (c *cSysData) selectedTexts() ([]string, error) {
panic(runtime.GOOS + " sysData does not define selectedIndex()")
}
func (c *cSysData) setWindowSize(int, int) error {
panic(runtime.GOOS + " sysData does not define setWindowSize()")
}
const (
c_window = iota

View File

@ -240,7 +240,7 @@ func (s *sysData) setRect(x int, y int, width int, height int) error {
}
r := <-ret
if r.ret == 0 { // failure
return r.err
return fmt.Errorf("error setting window/control rect: %v", r.err)
}
return nil
}
@ -437,3 +437,27 @@ func (s *sysData) selectedTexts() ([]string, error) {
}
return strings, nil
}
func (s *sysData) setWindowSize(width int, height int) error {
var rect _RECT
ret := make(chan uiret)
defer close(ret)
uitask <- &uimsg{
call: _getClientRect,
p: []uintptr{
uintptr(s.hwnd),
uintptr(unsafe.Pointer(&rect)),
},
ret: ret,
}
r := <-ret
if r.ret == 0 {
return fmt.Errorf("error getting upper-left of window for resize: %v", r.err)
}
err := s.setRect(int(rect.Left), int(rect.Top), width, height)
if err != nil {
return fmt.Errorf("error actually resizing window: %v", err)
}
return nil
}