widget

package
v0.0.0-...-f36f2b5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2014 License: BSD-2-Clause Imports: 3 Imported by: 1

Documentation

Overview

Package widget provides a concrete widgets using the sparta package.

Index

Constants

View Source
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.

View Source
const (
	// sets the value (int) that the button will send to the target if
	// pressed.
	ButtonValue sparta.Property = "value"
)

Button particular properties.

View Source
const (
	// sets the string list
	ListList sparta.Property = "list"
)

List particular properties.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arc

type Arc struct {
	Rect           image.Rectangle
	Angle1, Angle2 float64 // in radians
	Fill           bool
}

Arc is an arc for the canvas widget.

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 NewButton

func NewButton(parent sparta.Widget, name, caption string, rect image.Rectangle) *Button

Button creates a new button.

func (*Button) Capture

func (b *Button) Capture(e sparta.EventType, fn func(sparta.Widget, interface{}) bool)

Capture sets an event function of the button.

func (*Button) Focus

func (b *Button) Focus()

Focus set the focus on the button.

func (*Button) OnEvent

func (b *Button) OnEvent(e interface{})

OnEvent process a particularevent on the button.

func (*Button) Property

func (b *Button) Property(p sparta.Property) interface{}

Property returns the indicated property of the button.

func (*Button) RemoveWindow

func (b *Button) RemoveWindow()

RemoveWindow removes the backend window.

func (*Button) SetProperty

func (b *Button) SetProperty(p sparta.Property, v interface{})

SetProperty sets a property of the button.

func (*Button) SetWindow

func (b *Button) SetWindow(win sparta.Window)

SetWindow is used by the backend to sets the backend window of the button.

func (*Button) Update

func (b *Button) Update()

Update updates the button.

func (*Button) Window

func (b *Button) Window() sparta.Window

Window returns the backend window.

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 NewCanvas

func NewCanvas(parent sparta.Widget, name string, rect image.Rectangle) *Canvas

NewCanvas creates a new canvas at a given position.

func (*Canvas) Capture

func (c *Canvas) Capture(e sparta.EventType, fn func(sparta.Widget, interface{}) bool)

Capture sets an event function of the canvas.

func (*Canvas) Draw

func (c *Canvas) Draw(v interface{})

Draw draws an object in the canvas, in the given position.

func (*Canvas) DrawMode

func (c *Canvas) DrawMode(mode bool)

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) Focus

func (c *Canvas) Focus()

Focus set the focus on the canvas.

func (*Canvas) OnEvent

func (c *Canvas) OnEvent(e interface{})

OnEvent process a particular event on the canvas.

func (*Canvas) Property

func (c *Canvas) Property(p sparta.Property) interface{}

Property returns the indicated property of the canvas.

func (*Canvas) RemoveWindow

func (c *Canvas) RemoveWindow()

RemoveWindow removes the backend window.

func (*Canvas) SetColor

func (c *Canvas) SetColor(p sparta.Property, cl color.RGBA)

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

func (c *Canvas) SetProperty(p sparta.Property, v interface{})

SetProperty sets a property of the canvas.

func (*Canvas) SetWindow

func (c *Canvas) SetWindow(win sparta.Window)

SetWindow is used by the backend to set the backend window of the canvas.

func (*Canvas) Update

func (c *Canvas) Update()

Update updates the canvas.

func (*Canvas) Window

func (c *Canvas) Window() sparta.Window

Window returns the backend window.

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 NewList

func NewList(parent sparta.Widget, name string, rect image.Rectangle) *List

NewList creates a new list.

func (*List) Capture

func (l *List) Capture(e sparta.EventType, fn func(sparta.Widget, interface{}) bool)

Capture sets an event function of the list.

func (*List) Focus

func (l *List) Focus()

Focus set the focus on the list.

func (*List) OnEvent

func (l *List) OnEvent(e interface{})

OnEvent process a particular event on the list.

func (*List) Property

func (l *List) Property(p sparta.Property) interface{}

Property returns the indicated property of the list.

func (*List) RemoveWindow

func (l *List) RemoveWindow()

RemoveWindow removes the backend window.

func (*List) SetProperty

func (l *List) SetProperty(p sparta.Property, v interface{})

SetProperty sets a property of the list.

func (*List) SetWindow

func (l *List) SetWindow(win sparta.Window)

SetWindow is used by the backend to sets the backend window of the list.

func (*List) Update

func (l *List) Update()

Update updates the list.

func (*List) Window

func (l *List) Window() sparta.Window

Window returns the backend window.

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) Capture

func (w *MainWindow) Capture(e sparta.EventType, fn func(sparta.Widget, interface{}) bool)

Capture sets an event function of the main window.

func (*MainWindow) Close

func (w *MainWindow) Close()

Close closes the main window.

func (*MainWindow) Focus

func (w *MainWindow) Focus()

Focus set the focus on the 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) Update

func (w *MainWindow) Update()

Update updates the main window.

func (*MainWindow) Window

func (w *MainWindow) Window() sparta.Window

Window returns the backend window.

type Polygon

type Polygon struct {
	Pt   []image.Point
	Fill bool
}

Polygon is a polygon for the canvas widget.

type Rectangle

type Rectangle struct {
	Rect image.Rectangle
	Fill bool
}

Rectangle is a rectangle for the canvas widget.

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) Capture

func (s *Scroll) Capture(e sparta.EventType, fn func(sparta.Widget, interface{}) bool)

Capture sets an event function of the scroll.

func (*Scroll) Focus

func (s *Scroll) Focus()

Focus set the focus on the scroll.

func (*Scroll) OnEvent

func (s *Scroll) OnEvent(e interface{})

OnEvent process a particular event on the scroll.

func (*Scroll) Property

func (s *Scroll) Property(p sparta.Property) interface{}

Property returns the indicated property of the scroll.

func (*Scroll) RemoveWindow

func (s *Scroll) RemoveWindow()

RemoveWindow removes the backend window.

func (*Scroll) SetProperty

func (s *Scroll) SetProperty(p sparta.Property, v interface{})

SetProperty sets a property of the scroll.

func (*Scroll) SetWindow

func (s *Scroll) SetWindow(win sparta.Window)

SetWindow is used by the backend to sets the backend window of the scroll.

func (*Scroll) Update

func (s *Scroll) Update()

Update updates the scroll.

func (*Scroll) Window

func (s *Scroll) Window() sparta.Window

Window returns the backend window.

type ScrollType

type ScrollType bool

ScrollType is the kind of the scroll

const (
	// Vertical scroll
	Vertical ScrollType = false

	// Horizontal scroll
	Horizontal = true
)

type Text

type Text struct {
	Pos  image.Point
	Text string
}

Text is a text for the canvas widget.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL