Changed manual sysData construction to use a helper function instead.

This commit is contained in:
Pietro Gagliardi 2014-02-14 11:02:59 -05:00
parent 9a4e7bf5eb
commit 8407bfb0cb
4 changed files with 11 additions and 15 deletions

View File

@ -19,11 +19,7 @@ type Button struct {
// NewButton creates a new button with the specified text.
func NewButton(text string) (b *Button) {
return &Button{
sysData: &sysData{
cSysData: cSysData{
ctype: c_button,
},
},
sysData: mksysdata(c_button),
initText: text,
Clicked: make(chan struct{}),
}

View File

@ -20,11 +20,7 @@ type Checkbox struct {
// NewCheckbox creates a new checkbox with the specified text.
func NewCheckbox(text string) (c *Checkbox) {
return &Checkbox{
sysData: &sysData{
cSysData: cSysData{
ctype: c_checkbox,
},
},
sysData: mksysdata(c_checkbox),
initText: text,
}
}

View File

@ -36,3 +36,11 @@ const (
c_checkbox
nctypes
)
func mksysdata(ctype int) *sysData {
return &sysData{
cSysData: cSysData{
ctype: ctype,
},
}
}

View File

@ -25,11 +25,7 @@ type Window struct {
// NewWindow creates a new window with the given title and size. The window is not constructed at the OS level until a call to Open().
func NewWindow(title string, width int, height int) *Window {
return &Window{
sysData: &sysData{
cSysData: cSysData{
ctype: c_window,
},
},
sysData: mksysdata(c_window),
initTitle: title,
initWidth: width,
initHeight: height,