2014-07-07 08:43:01 -05:00
// 7 july 2014
package ui
// 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
2014-08-03 08:12:39 -05:00
// OnToggled sets the event handler for when the Checkbox is toggled.
OnToggled ( func ( ) )
2014-07-21 08:51:05 -05:00
2014-07-29 12:48:31 -05:00
// Text and SetText get and set the Checkbox's label text.
2014-07-21 08:51:05 -05:00
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
2014-07-26 05:43:59 -05:00
// TextField is a Control in which the user can enter a single line of text.
type TextField interface {
2014-07-24 16:24:25 -05:00
Control
2014-07-26 05:43:59 -05:00
// Text and SetText are Requests that get and set the TextField's text.
2014-07-24 16:24:25 -05:00
Text ( ) string
SetText ( text string )
2014-08-20 00:08:24 -05:00
// OnChanged is triggered when the text in a TextField is changed somehow.
// Do not bother trying to figure out how the text was changed; instead, perform your validation and use Invalid to inform the user that the entered text is invalid instead.
OnChanged ( func ( ) )
// Invalid throws a non-modal alert (whose nature is system-defined) on or near the TextField that alerts the user that input is invalid.
// The string passed to Invalid will be displayed to the user to inform them of what specifically is wrong with the input.
// Pass an empty string to remove the warning.
Invalid ( reason string )
2014-07-24 16:24:25 -05:00
}
2014-07-26 05:43:59 -05:00
// NewTextField creates a new TextField.
func NewTextField ( ) TextField {
return newTextField ( )
}
// NewPasswordField creates a new TextField for entering passwords; that is, it hides the text being entered.
func NewPasswordField ( ) TextField {
return newPasswordField ( )
}
2014-07-29 12:48:31 -05:00
2014-08-04 16:46:08 -05:00
// Tab is a Control that contains multiple pages of tabs, each containing a single Control.
// You can add and remove tabs from the Tab at any time.
2014-08-08 21:28:58 -05:00
// The appearance of a Tab with no tabs is implementation-defined.
2014-08-04 16:46:08 -05:00
type Tab interface {
Control
// Append adds a new tab to Tab.
// The tab is added to the end of the current list of tabs.
Append ( name string , control Control )
}
// NewTab creates a new Tab with no tabs.
func NewTab ( ) Tab {
return newTab ( )
}
2014-07-29 12:48:31 -05:00
// Label is a Control that shows a static line of text.
// Label shows one line of text; any text that does not fit is truncated.
// A Label can either have smart vertical alignment relative to the control to its right or just be vertically aligned to the top (standalone).
2014-08-13 13:56:58 -05:00
// The effect of placing a non-standalone Label in any context other than to the immediate left of a Control is undefined.
2014-08-14 08:38:12 -05:00
// Both types of labels are left-aligned. [FUTURE PLANS: For platform-specific horizontal alignment rules, use a Form.]
2014-07-29 12:48:31 -05:00
type Label interface {
Control
// Text and SetText get and set the Label's text.
Text ( ) string
SetText ( text string )
2014-08-15 18:35:49 -05:00
isStandalone ( ) bool
2014-07-29 12:48:31 -05:00
}
// NewLabel creates a new Label with the given text.
// The Label will smartly vertically position itself relative to the control to its immediate right.
func NewLabel ( text string ) Label {
return newLabel ( text )
}
// NewStandaloneLabel creates a new Label with the given text.
// The Label will be vertically positioned at the top of its allocated space.
func NewStandaloneLabel ( text string ) Label {
return newStandaloneLabel ( text )
}
2014-08-15 20:43:24 -05:00
// Group is a Control that holds a single Control; if that Control also contains other Controls, then the Controls will appear visually grouped together.
// The appearance of a Group varies from system to system; for the most part a Group consists of a thin frame.
// All Groups have a text label indicating what the Group is for.
type Group interface {
Control
// Text and SetText get and set the Group's label text.
Text ( ) string
SetText ( text string )
}
// NewGroup creates a new Group with the given text label and child Control.
func NewGroup ( text string , control Control ) Group {
return newGroup ( text , control )
}