2014-07-07 08:43:01 -05:00
// 7 july 2014
package ui
// Control represents a control.
// All Controls have event handlers that take a single argument (the Doer active during the event) and return nothing.
type Control interface {
2014-07-25 16:34:45 -05:00
controlParent // platform-specific
2014-07-07 08:43:01 -05:00
// TODO enable/disable (public)
// TODO show/hide (public)
2014-07-25 11:45:56 -05:00
containerShow ( ) // for Windows, where all controls need ot belong to an overlapped window, not to a container control; these respect programmer settings
containerHide ( )
2014-07-16 20:30:19 -05:00
controlSizing
2014-07-07 08:43:01 -05:00
}
// Button is a clickable button that performs some task.
type Button interface {
Control
2014-07-19 08:44:32 -05:00
// OnClicked sets the event handler for when the Button is clicked.
OnClicked ( func ( ) )
2014-07-07 08:43:01 -05:00
2014-07-19 08:44:32 -05:00
// Text and SetText get and set the Button's label text.
Text ( ) string
SetText ( text string )
2014-07-07 08:43:01 -05:00
}
2014-07-19 08:44:32 -05:00
// NewButton creates a new Button with the given label text.
2014-07-19 15:47:19 -05:00
func NewButton ( text string ) Button {
2014-07-07 08:43:01 -05:00
return newButton ( text )
}
2014-07-21 08:51:05 -05:00
// Checkbox is a clickable box that indicates some Boolean value.
type Checkbox interface {
Control
// OnClicked sets the event handler for when the Checkbox is clicked (to change its toggle state).
2014-07-21 20:07:14 -05:00
// TODO change to OnToggled() or OnChecked()?
2014-07-21 08:51:05 -05:00
OnClicked ( func ( ) )
// Text and SetText are Requests that get and set the Checkbox's label text.
Text ( ) string
SetText ( text string )
// Checked and SetChecked get and set the Checkbox's check state.
Checked ( ) bool
SetChecked ( checked bool )
}
// NewCheckbox creates a new Checkbox with the given label text.
// The Checkbox will be initially unchecked.
func NewCheckbox ( text string ) Checkbox {
2014-07-21 20:07:14 -05:00
return newCheckbox ( text )
2014-07-21 08:51:05 -05:00
}
2014-07-24 16:24:25 -05:00
// LineEdit blah blah blah TODO write this
// TODO change name
type LineEdit interface {
Control
// TODO figure out what events are appropriate
// Text and SetText are Requests that get and set the Checkbox's label text.
Text ( ) string
SetText ( text string )
}
// TODO NewLineEdit, NewPasswordEdit, ...