Documentation ¶
Overview ¶
Package widget provides a concrete widgets using the sparta package.
Index ¶
- Constants
- type Arc
- type Button
- func (b *Button) Capture(e sparta.EventType, fn func(sparta.Widget, interface{}) bool)
- func (b *Button) Focus()
- func (b *Button) OnEvent(e interface{})
- func (b *Button) Property(p sparta.Property) interface{}
- func (b *Button) RemoveWindow()
- func (b *Button) SetProperty(p sparta.Property, v interface{})
- func (b *Button) SetWindow(win sparta.Window)
- func (b *Button) Update()
- func (b *Button) Window() sparta.Window
- type Canvas
- func (c *Canvas) Capture(e sparta.EventType, fn func(sparta.Widget, interface{}) bool)
- func (c *Canvas) Draw(v interface{})
- func (c *Canvas) DrawMode(mode bool)
- func (c *Canvas) Focus()
- func (c *Canvas) OnEvent(e interface{})
- func (c *Canvas) Property(p sparta.Property) interface{}
- func (c *Canvas) RemoveWindow()
- func (c *Canvas) SetColor(p sparta.Property, cl color.RGBA)
- func (c *Canvas) SetProperty(p sparta.Property, v interface{})
- func (c *Canvas) SetWindow(win sparta.Window)
- func (c *Canvas) Update()
- func (c *Canvas) Window() sparta.Window
- type List
- func (l *List) Capture(e sparta.EventType, fn func(sparta.Widget, interface{}) bool)
- func (l *List) Focus()
- func (l *List) OnEvent(e interface{})
- func (l *List) Property(p sparta.Property) interface{}
- func (l *List) RemoveWindow()
- func (l *List) SetProperty(p sparta.Property, v interface{})
- func (l *List) SetWindow(win sparta.Window)
- func (l *List) Update()
- func (l *List) Window() sparta.Window
- type ListData
- type MainWindow
- func (w *MainWindow) Capture(e sparta.EventType, fn func(sparta.Widget, interface{}) bool)
- func (w *MainWindow) Close()
- func (w *MainWindow) Focus()
- func (w *MainWindow) OnEvent(e interface{})
- func (w *MainWindow) Property(p sparta.Property) interface{}
- func (w *MainWindow) RemoveWindow()
- func (w *MainWindow) SetProperty(p sparta.Property, v interface{})
- func (w *MainWindow) SetWindow(win sparta.Window)
- func (w *MainWindow) Update()
- func (w *MainWindow) Window() sparta.Window
- type Polygon
- type Rectangle
- type Scroll
- func (s *Scroll) Capture(e sparta.EventType, fn func(sparta.Widget, interface{}) bool)
- func (s *Scroll) Focus()
- func (s *Scroll) OnEvent(e interface{})
- func (s *Scroll) Property(p sparta.Property) interface{}
- func (s *Scroll) RemoveWindow()
- func (s *Scroll) SetProperty(p sparta.Property, v interface{})
- func (s *Scroll) SetWindow(win sparta.Window)
- func (s *Scroll) Update()
- func (s *Scroll) Window() sparta.Window
- type ScrollType
- type Text
Constants ¶
const ( // sets the size of the scroll page (int) ScrollPage sparta.Property = "page" // sets the position of the scroll (int) ScrollPos = "pos" // sets the size of the scroll (int) ScrollSize = "size" )
Scroll particular properties.
const ( // sets the value (int) that the button will send to the target if // pressed. ButtonValue sparta.Property = "value" )
Button particular properties.
const ( // sets the string list ListList sparta.Property = "list" )
List particular properties.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Button ¶
type Button struct {
// contains filtered or unexported fields
}
Button is a widget that shows a text, and can be "pushed" with the mouse. When a mouse button is pressed over a button widget, it will sends an arbitrary value (that can be set with the propery ButtonValue) to the target widget.
func (*Button) OnEvent ¶
func (b *Button) OnEvent(e interface{})
OnEvent process a particularevent on the button.
func (*Button) RemoveWindow ¶
func (b *Button) RemoveWindow()
RemoveWindow removes the backend window.
func (*Button) SetProperty ¶
SetProperty sets a property of the button.
type Canvas ¶
type Canvas struct {
// contains filtered or unexported fields
}
Canvas is a widget in which the client code can draw text, lines, rectangles, etc.
func (*Canvas) Draw ¶
func (c *Canvas) Draw(v interface{})
Draw draws an object in the canvas, in the given position.
func (*Canvas) DrawMode ¶
DrawMode starts the drawing process of the canvas. Before any drawing outside of an expose event, this function must be called with the mode parameter as true. When drawing functions end, then, the DrawMode function must be called with false mode.
func (*Canvas) OnEvent ¶
func (c *Canvas) OnEvent(e interface{})
OnEvent process a particular event on the canvas.
func (*Canvas) RemoveWindow ¶
func (c *Canvas) RemoveWindow()
RemoveWindow removes the backend window.
func (*Canvas) SetColor ¶
SetColor sets the color of the canvas for the next drawing operations. If the canvas receive an expose event, the colors will be back to defaults.
func (*Canvas) SetProperty ¶
SetProperty sets a property of the canvas.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is a widget that shows a list of strings, and one or more elements can be selected with the mouse.
When a element of the list is selected, it send a comand event to its target widget indicating the index of the selected element. It will be a positive number if the selection is made with the left button or negative (starting at -1), if it was with the right button.
It is up to client code to manage multiple or single selection.
func (*List) OnEvent ¶
func (l *List) OnEvent(e interface{})
OnEvent process a particular event on the list.
func (*List) SetProperty ¶
SetProperty sets a property of the list.
type ListData ¶
type ListData interface { // Len returns the length of the list. Len() int // Item returns the name of the i-th element of the list. Item(int) string // IsSel returns true if the i-th element is selected. IsSel(int) bool }
ListData is a list used by a list control.
type MainWindow ¶
type MainWindow struct {
// contains filtered or unexported fields
}
MainWindow is a main window.
func NewMainWindow ¶
func NewMainWindow(name, title string) *MainWindow
NewMainWindow creates a new main window.
func (*MainWindow) OnEvent ¶
func (w *MainWindow) OnEvent(e interface{})
OnEvent process a particular event on the main window.
func (*MainWindow) Property ¶
func (w *MainWindow) Property(p sparta.Property) interface{}
Property returns the indicated property of the main window.
func (*MainWindow) RemoveWindow ¶
func (w *MainWindow) RemoveWindow()
RemoveWindow removes the backend window.
func (*MainWindow) SetProperty ¶
func (w *MainWindow) SetProperty(p sparta.Property, v interface{})
SetProperty sets a property of the main window.
func (*MainWindow) SetWindow ¶
func (w *MainWindow) SetWindow(win sparta.Window)
SetWindow is used by the backend to sets the backend window of the main window.
func (*MainWindow) Window ¶
func (w *MainWindow) Window() sparta.Window
Window returns the backend window.
type Scroll ¶
type Scroll struct {
// contains filtered or unexported fields
}
Scroll is a widget that shows a position inside a document. When a scroll is moved, it sends an event to its target indicating the new position.
If you are using an scroll, and want to move the content of the target client, the change the scroll position property, and process the movement when the target client receive the position event from the scroll.
func NewScroll ¶
func NewScroll(parent sparta.Widget, name string, size, page int, typ ScrollType, rect image.Rectangle) *Scroll
NewScroll creates a new scroll of the given type.
func (*Scroll) OnEvent ¶
func (s *Scroll) OnEvent(e interface{})
OnEvent process a particular event on the scroll.
func (*Scroll) RemoveWindow ¶
func (s *Scroll) RemoveWindow()
RemoveWindow removes the backend window.
func (*Scroll) SetProperty ¶
SetProperty sets a property of the scroll.
type ScrollType ¶
type ScrollType bool
ScrollType is the kind of the scroll
const ( // Vertical scroll Vertical ScrollType = false // Horizontal scroll Horizontal = true )