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.
2014-10-18 16:03:07 -05:00
// 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 )
}
// NewLabel creates a new Label with the given text.
func NewLabel ( text string ) Label {
return newLabel ( 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 )
2014-10-18 16:03:07 -05:00
// Margined and SetMargined get and set whether the contents of the Group have a margin around them.
// The size of the margin is platform-dependent.
Margined ( ) bool
SetMargined ( margined bool )
2014-08-15 20:43:24 -05:00
}
// NewGroup creates a new Group with the given text label and child Control.
func NewGroup ( text string , control Control ) Group {
return newGroup ( text , control )
}
2014-10-23 15:54:21 -05:00
// Textbox represents a multi-line text entry box.
// Text in a Textbox is unformatted, and scrollbars are applied automatically.
// TODO rename to TextBox? merge with TextField (but cannot use Invalid())? enable/disable line wrapping?
// TODO events
2014-10-27 10:03:39 -05:00
// TODO Tab key - insert horizontal tab or tab stop?
2014-10-23 15:54:21 -05:00
type Textbox interface {
Control
// Text and SetText get and set the Textbox's text.
Text ( ) string
SetText ( text string )
}
// NewTextbox creates a new Textbox.
func NewTextbox ( ) Textbox {
return newTextbox ( )
}
2014-10-28 10:01:02 -05:00
// Spinbox is a Control that provides a text entry field that accepts integers and up and down buttons to increment and decrement those values.
// This control is in its preliminary state.
// TODO everything:
// - TODO set increment
// - TODO set step
// - TODO set page step?
// - TODO wrapping
// - TODO set/get integer value
// - TODO negative values
2014-10-28 19:30:40 -05:00
// - TODO ensuring values entered in text box stay within bounds
2014-10-28 10:01:02 -05:00
type Spinbox interface {
Control
}
// NewSpinbox creates a new Spinbox.
func NewSpinbox ( ) Spinbox {
return newSpinbox ( )
}