Removed setting the initial width and height in sysData.make() (this gets rid of the dummy 300x300 sizes from the controls) and added an explicit sysData.setWindowSize() to Window.Open() to ensure everything's sized properly.
This commit is contained in:
parent
32e70f6414
commit
99feed7628
|
@ -42,7 +42,7 @@ func (b *Button) make(window *sysData) error {
|
|||
defer b.lock.Unlock()
|
||||
|
||||
b.sysData.event = b.Clicked
|
||||
err := b.sysData.make(b.initText, 300, 300, window)
|
||||
err := b.sysData.make(b.initText, window)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ func (c *Checkbox) make(window *sysData) error {
|
|||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
err := c.sysData.make(c.initText, 300, 300, window)
|
||||
err := c.sysData.make(c.initText, window)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ func (c *Combobox) make(window *sysData) (err error) {
|
|||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
err = c.sysData.make("", 300, 300, window)
|
||||
err = c.sysData.make("", window)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
2
label.go
2
label.go
|
@ -29,7 +29,7 @@ func (l *Label) make(window *sysData) error {
|
|||
l.lock.Lock()
|
||||
defer l.lock.Unlock()
|
||||
|
||||
err := l.sysData.make(l.initText, 300, 300, window)
|
||||
err := l.sysData.make(l.initText, window)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ func (l *LineEdit) make(window *sysData) error {
|
|||
l.lock.Lock()
|
||||
defer l.lock.Unlock()
|
||||
|
||||
err := l.sysData.make(l.initText, 300, 300, window)
|
||||
err := l.sysData.make(l.initText, window)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func (l *Listbox) make(window *sysData) (err error) {
|
|||
l.lock.Lock()
|
||||
defer l.lock.Unlock()
|
||||
|
||||
err = l.sysData.make("", 300, 300, window)
|
||||
err = l.sysData.make("", window)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ type cSysData struct {
|
|||
resize func(x int, y int, width int, height int) error
|
||||
alternate bool // editable for Combobox, multi-select for listbox
|
||||
}
|
||||
func (c *cSysData) make(initText string, initWidth int, initHeight int, window *sysData) error {
|
||||
func (c *cSysData) make(initText string, window *sysData) error {
|
||||
panic(runtime.GOOS + " sysData does not define make()")
|
||||
}
|
||||
func (c *cSysData) show() error {
|
||||
|
|
|
@ -102,7 +102,7 @@ func (s *sysData) delChild(id _HMENU) {
|
|||
}
|
||||
|
||||
// TODO adorn error messages with what stage failed?
|
||||
func (s *sysData) make(initText string, initWidth int, initHeight int, window *sysData) (err error) {
|
||||
func (s *sysData) make(initText string, window *sysData) (err error) {
|
||||
ret := make(chan uiret)
|
||||
defer close(ret)
|
||||
ct := classTypes[s.ctype]
|
||||
|
@ -130,10 +130,10 @@ func (s *sysData) make(initText string, initWidth int, initHeight int, window *s
|
|||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(classname))),
|
||||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(initText))),
|
||||
style,
|
||||
uintptr(_CW_USEDEFAULT), // TODO
|
||||
uintptr(_CW_USEDEFAULT),
|
||||
uintptr(initWidth),
|
||||
uintptr(initHeight),
|
||||
uintptr(_CW_USEDEFAULT),
|
||||
uintptr(_CW_USEDEFAULT),
|
||||
uintptr(_CW_USEDEFAULT),
|
||||
pwin,
|
||||
uintptr(cid),
|
||||
uintptr(hInstance),
|
||||
|
|
|
@ -71,7 +71,7 @@ func (w *Window) Open(control Control) (err error) {
|
|||
panic("window already open")
|
||||
}
|
||||
w.sysData.event = w.Closing
|
||||
err = w.sysData.make(w.initTitle, w.initWidth, w.initHeight, nil)
|
||||
err = w.sysData.make(w.initTitle, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error opening window: %v", err)
|
||||
}
|
||||
|
@ -82,7 +82,10 @@ func (w *Window) Open(control Control) (err error) {
|
|||
return fmt.Errorf("error adding window's control: %v", err)
|
||||
}
|
||||
}
|
||||
// TODO resize window to apply control sizes
|
||||
err = w.sysData.setWindowSize(w.initWidth, w.initHeight)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error setting window size (in Window.Open()): %v", err)
|
||||
}
|
||||
// TODO separate showing?
|
||||
err = w.sysData.show()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue