Documentation
¶
Overview ¶
+build !windows
Index ¶
- Constants
- Variables
- func AbsInt(x int) int
- func CellsToString(cells []Cell) string
- func FloorFloat64(x float64) float64
- func GetMaxFloat64From2dSlice(slices [][]float64) (float64, error)
- func GetMaxFloat64FromSlice(slice []float64) (float64, error)
- func GetMaxIntFromSlice(slice []int) (int, error)
- func InterfaceSlice(slice interface{}) []interface{}
- func MaxFloat64(x, y float64) float64
- func MaxInt(x, y int) int
- func MinFloat64(x, y float64) float64
- func MinInt(x, y int) int
- func PollEvents() <-chan Event
- func RoundFloat64(x float64) float64
- func SetLogger(l Logger)
- func SplitCells(cells []Cell, r rune) [][]Cell
- func SumFloat64Slice(data []float64) float64
- func SumIntSlice(slice []int) int
- func TrimString(s string, w int) string
- type BarChartTheme
- type Block
- type BlockTheme
- type Box
- type Cell
- type CellWithX
- type Color
- type Decoration
- type EchoMode
- type Event
- type EventType
- type FocusChain
- type GaugeTheme
- type Input
- func (s *Input) DoEvent(ev Event) bool
- func (e *Input) DoKeyEvent(ev Event) bool
- func (e *Input) Draw()
- func (s *Input) GetInner() image.Rectangle
- func (s *Input) MinSizeHint() image.Point
- func (e *Input) OnChanged(fn func(Input *Input))
- func (e *Input) OnSubmit(fn func(Input *Input))
- func (l *Input) Resize(pos image.Point, size image.Point)
- func (e *Input) SetEchoMode(m EchoMode)
- func (s *Input) SetRect(x, y, w, h int)
- func (e *Input) SetText(text string)
- func (e *Input) SizeHint() image.Point
- func (e *Input) Text() string
- type Label
- func (l *Label) Draw()
- func (s *Label) GetInner() image.Rectangle
- func (l *Label) MinSizeHint() image.Point
- func (l *Label) Resize(pos, size image.Point)
- func (s *Label) SetRect(x, y, w, h int)
- func (l *Label) SetStyleName(style string)
- func (l *Label) SetText(text string)
- func (l *Label) SetWordWrap(enabled bool)
- func (l *Label) SizeHint() image.Point
- func (l *Label) Text() string
- type LayoutMode
- type ListTheme
- type Logger
- type Modifier
- type Mouse
- type Painter
- func (p *Painter) Begin()
- func (p *Painter) DrawCursor(x, y int)
- func (p *Painter) DrawRune(x, y int, r rune, st *Style)
- func (p *Painter) DrawText(x, y int, text string, st *Style)
- func (p *Painter) End()
- func (self *Painter) Fill(c Cell, rect image.Rectangle)
- func (self *Painter) GetCell(p image.Point) Cell
- func (p *Painter) Repaint(w Widget)
- func (p *Painter) Restore()
- func (self *Painter) SetCell(c Cell, p image.Point)
- func (self *Painter) SetString(s string, style Style, p image.Point)
- func (p *Painter) Translate(x, y int)
- type ParagraphTheme
- type PieChartTheme
- type PlotTheme
- type Resize
- type RootTheme
- type RuneBuffer
- func (r *RuneBuffer) Backspace()
- func (r *RuneBuffer) CursorPos() image.Point
- func (r *RuneBuffer) Delete()
- func (r *RuneBuffer) Kill()
- func (r *RuneBuffer) Len() int
- func (r *RuneBuffer) MoveBackward()
- func (r *RuneBuffer) MoveForward()
- func (r *RuneBuffer) MoveToLineEnd()
- func (r *RuneBuffer) MoveToLineStart()
- func (r *RuneBuffer) Pos() int
- func (r *RuneBuffer) Runes() []rune
- func (r *RuneBuffer) Set(buf []rune)
- func (r *RuneBuffer) SetMaxWidth(w int)
- func (r *RuneBuffer) SetWithIdx(idx int, buf []rune)
- func (r *RuneBuffer) SplitByLine() []string
- func (r *RuneBuffer) String() string
- func (r *RuneBuffer) Width() int
- func (r *RuneBuffer) WriteRune(s rune)
- func (r *RuneBuffer) WriteRunes(s []rune)
- type Screen
- func (s *Screen) Clear()
- func (self *Screen) Fill(c Cell, rect image.Rectangle)
- func (self *Screen) GetCell(p image.Point) Cell
- func (s *Screen) HideCursor()
- func (self *Screen) SetCell(c Cell, p image.Point)
- func (s *Screen) SetCursor(x, y int)
- func (self *Screen) SetString(s string, style Style, p image.Point)
- func (s *Screen) Show()
- func (self *Screen) Size() image.Point
- type SimpleFocusChain
- type SizePolicy
- type Space
- type SparklineTheme
- type StackedBarChartTheme
- type Style
- type Surface
- type TabTheme
- type TableTheme
- type TreeTheme
- type UI
- type Widget
- type WidgetBase
- func (s *WidgetBase) Append(w Widget)
- func (s *WidgetBase) DoEvent(e Event) bool
- func (s *WidgetBase) Draw()
- func (s *WidgetBase) GetInner() image.Rectangle
- func (s *WidgetBase) GetInnerRealPos() image.Rectangle
- func (s *WidgetBase) GetOuter() image.Rectangle
- func (w *WidgetBase) GetPainter() *Painter
- func (s *WidgetBase) GetParentMin() image.Point
- func (s *WidgetBase) Init()
- func (s *WidgetBase) Insert(i int, w Widget)
- func (w *WidgetBase) IsActive() bool
- func (w *WidgetBase) IsFocused() bool
- func (s *WidgetBase) LayoutMode() LayoutMode
- func (s *WidgetBase) Length() int
- func (s *WidgetBase) MinSizeHint() image.Point
- func (s *WidgetBase) OnEvent(fn func(w Widget, e *Event))
- func (s *WidgetBase) Prepend(w Widget)
- func (s *WidgetBase) ReLayout()
- func (s *WidgetBase) Remove(i int)
- func (s *WidgetBase) Resize(pos image.Point, size image.Point)
- func (w *WidgetBase) SetActive(a bool)
- func (w *WidgetBase) SetFocused(f bool)
- func (w *WidgetBase) SetHeight(height int)
- func (w *WidgetBase) SetPainter(p *Painter)
- func (w *WidgetBase) SetParent(p Widget)
- func (s *WidgetBase) SetRect(x, y, w, h int)
- func (w *WidgetBase) SetStyle(style Style)
- func (w *WidgetBase) SetText(text string)
- func (w *WidgetBase) SetWidth(width int)
- func (s *WidgetBase) SizeHint() image.Point
- func (w *WidgetBase) SizePolicy() (SizePolicy, SizePolicy)
Constants ¶
const ( KeyF1 = "<F1>" KeyF2 = "<F2>" KeyF3 = "<F3>" KeyF4 = "<F4>" KeyF5 = "<F5>" KeyF6 = "<F6>" KeyF7 = "<F7>" KeyF8 = "<F8>" KeyF9 = "<F9>" KeyF10 = "<F10>" KeyF11 = "<F11>" KeyF12 = "<F12>" KeyInsert = "<Insert>" KeyDelete = "<Delete>" KeyHome = "<Home>" KeyEnd = "<End>" KeyPgup = "<PageUp>" KeyPgdn = "<PageDown>" KeyArrowUp = "<Up>" KeyArrowDown = "<Down>" KeyArrowLeft = "<Left>" KeyArrowRight = "<Right>" KeyCtrlSpace = "<C-<Space>>" // KeyCtrl2 KeyCtrlTilde KeyCtrlA = "<C-a>" KeyCtrlB = "<C-b>" KeyCtrlC = "<C-c>" KeyCtrlD = "<C-d>" KeyCtrlE = "<C-e>" KeyCtrlF = "<C-f>" KeyCtrlG = "<C-g>" KeyBackspace = "<C-<Backspace>>" // KeyCtrlH KeyTab = "<Tab>" // KeyCtrlI KeyCtrlJ = "<C-j>" KeyCtrlK = "<C-k>" KeyCtrlL = "<C-l>" KeyEnter = "<Enter>" // KeyCtrlM KeyCtrlN = "<C-n>" KeyCtrlO = "<C-o>" KeyCtrlP = "<C-p>" KeyCtrlQ = "<C-q>" KeyCtrlR = "<C-r>" KeyCtrlS = "<C-s>" KeyCtrlT = "<C-t>" KeyCtrlU = "<C-u>" KeyCtrlV = "<C-v>" KeyCtrlW = "<C-w>" KeyCtrlX = "<C-x>" KeyCtrlY = "<C-y>" KeyCtrlZ = "<C-z>" KeyEsc = "<Escape>" // KeyCtrlLsqBracket KeyCtrl3 KeyCtrl4 = "<C-4>" // KeyCtrlBackslash KeyCtrl5 = "<C-5>" // KeyCtrlRsqBracket KeyCtrl6 = "<C-6>" KeyCtrl7 = "<C-7>" // KeyCtrlSlash KeyCtrlUnderscore KeySpace = "<Space>" KeyBackspace2 = "<Backspace>" // KeyCtrl8: )
List of events:
mouse events: <MouseLeft> <MouseRight> <MouseMiddle> <MouseWheelUp> <MouseWheelDown> keyboard events: any uppercase or lowercase letter like j or J <C-d> etc <M-d> etc <Up> <Down> <Left> <Right> <Insert> <Delete> <Home> <End> <Previous> <Next> <Backspace> <Tab> <Enter> <Escape> <Space> <C-<Space>> etc terminal events: <Resize> keyboard events that do not work: <C--> <C-2> <C-~> <C-h> <C-i> <C-m> <C-[> <C-3> <C-\\> <C-]> <C-/> <C-_> <C-8>
const ( DOT = '•' ELLIPSES = '…' UP_ARROW = '▲' DOWN_ARROW = '▼' COLLAPSED = '+' EXPANDED = '−' )
const ( TOP_LEFT = '┌' TOP_RIGHT = '┐' BOTTOM_LEFT = '└' BOTTOM_RIGHT = '┘' VERTICAL_LINE = '│' HORIZONTAL_LINE = '─' VERTICAL_LEFT = '┤' VERTICAL_RIGHT = '├' HORIZONTAL_UP = '┴' HORIZONTAL_DOWN = '┬' QUOTA_LEFT = '«' QUOTA_RIGHT = '»' VERTICAL_DASH = '┊' HORIZONTAL_DASH = '┈' )
Variables ¶
var ( BARS = [...]rune{' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'} SHADED_BLOCKS = [...]rune{' ', '░', '▒', '▓', '█'} IRREGULAR_BLOCKS = [...]rune{ ' ', '▘', '▝', '▀', '▖', '▌', '▞', '▛', '▗', '▚', '▐', '▜', '▄', '▙', '▟', '█', } BRAILLE_OFFSET = '\u2800' BRAILLE = [4][2]rune{ {'\u0001', '\u0008'}, {'\u0002', '\u0010'}, {'\u0004', '\u0020'}, {'\u0040', '\u0080'}, } DOUBLE_BRAILLE = map[[2]int]rune{ [2]int{0, 0}: '⣀', [2]int{0, 1}: '⡠', [2]int{0, 2}: '⡐', [2]int{0, 3}: '⡈', [2]int{1, 0}: '⢄', [2]int{1, 1}: '⠤', [2]int{1, 2}: '⠔', [2]int{1, 3}: '⠌', [2]int{2, 0}: '⢂', [2]int{2, 1}: '⠢', [2]int{2, 2}: '⠒', [2]int{2, 3}: '⠊', [2]int{3, 0}: '⢁', [2]int{3, 1}: '⠡', [2]int{3, 2}: '⠑', [2]int{3, 3}: '⠉', } SINGLE_BRAILLE_LEFT = [4]rune{'\u2840', '⠄', '⠂', '⠁'} SINGLE_BRAILLE_RIGHT = [4]rune{'\u2880', '⠠', '⠐', '⠈'} )
var CellClear = Cell{ Rune: ' ', Style: StyleClear, }
var DefaultFocusChain = &SimpleFocusChain{ widgets: make([]Widget, 0), }
DefaultFocusChain is the default focus chain.
var DefaultTheme = &RootTheme{ styles: map[string]Style{}, }
DefaultTheme is a theme with reasonable defaults.
var StandardColors = []Color{ ColorRed, ColorGreen, ColorYellow, ColorBlue, ColorMagenta, ColorCyan, ColorWhite, }
var StandardStyles = []Style{ NewStyle(ColorRed), NewStyle(ColorGreen), NewStyle(ColorYellow), NewStyle(ColorBlue), NewStyle(ColorMagenta), NewStyle(ColorCyan), NewStyle(ColorWhite), }
var StyleClear = Style{ Fg: ColorClear, Bg: ColorClear, Modifier: ModifierClear, }
var Theme = RootTheme{ Default: NewStyle(ColorWhite), Block: BlockTheme{ Title: NewStyle(ColorWhite), Border: NewStyle(ColorWhite), }, BarChart: BarChartTheme{ Bars: StandardColors, Nums: StandardStyles, Labels: StandardStyles, }, Paragraph: ParagraphTheme{ Text: NewStyle(ColorWhite), }, PieChart: PieChartTheme{ Slices: StandardColors, }, List: ListTheme{ Text: NewStyle(ColorWhite), }, Tree: TreeTheme{ Text: NewStyle(ColorWhite), Collapsed: COLLAPSED, Expanded: EXPANDED, }, StackedBarChart: StackedBarChartTheme{ Bars: StandardColors, Nums: StandardStyles, Labels: StandardStyles, }, Gauge: GaugeTheme{ Bar: ColorWhite, Label: NewStyle(ColorWhite), }, Sparkline: SparklineTheme{ Title: NewStyle(ColorWhite), Line: ColorWhite, }, Plot: PlotTheme{ Lines: StandardColors, Axes: ColorWhite, }, Table: TableTheme{ Text: NewStyle(ColorWhite), }, Tab: TabTheme{ Active: NewStyle(ColorRed), Inactive: NewStyle(ColorWhite), }, }
Theme holds the default Styles and Colors for all widgets. You can set default widget Styles by modifying the Theme before creating the widgets.
Functions ¶
func CellsToString ¶
func FloorFloat64 ¶
func GetMaxFloat64FromSlice ¶
func GetMaxIntFromSlice ¶
func InterfaceSlice ¶
func InterfaceSlice(slice interface{}) []interface{}
InterfaceSlice takes an []interface{} represented as an interface{} and converts it https://stackoverflow.com/questions/12753805/type-converting-slices-of-interfaces-in-go
func MaxFloat64 ¶
func MinFloat64 ¶
func PollEvents ¶
func PollEvents() <-chan Event
PollEvents gets events from termbox, converts them, then sends them to each of its channels.
func RoundFloat64 ¶
func SplitCells ¶
func SumFloat64Slice ¶
func SumIntSlice ¶
func TrimString ¶
TrimString trims a string to a max length and adds '…' to the end if it was trimmed.
Types ¶
type BarChartTheme ¶
type Block ¶
type Block struct {
WidgetBase
}
Block is the base struct inherited by most widgets. Block manages size, position, border, and title. It implements all 3 of the methods needed for the `Drawable` interface. Custom widgets will override the Draw method.
type BlockTheme ¶
type Box ¶
type Box struct {
Block
}
type Cell ¶
Cell represents a viewable terminal cell
func RunesToStyledCells ¶
type CellWithX ¶
func BuildCellWithXArray ¶
type Color ¶
type Color int32
Color represents a color.
const ( ColorDefault Color = iota ColorBlack Color = 0 ColorRed Color = 1 ColorGreen Color = 2 ColorYellow Color = 3 ColorBlue Color = 4 ColorMagenta Color = 5 ColorCyan Color = 6 ColorWhite Color = 7 )
Common colors.
const ColorClear Color = -1
func SelectColor ¶
type Decoration ¶
type Decoration int
Decoration represents a bold/underline/etc. state
const ( DecorationInherit Decoration = iota DecorationOn DecorationOff )
Decoration modes: Inherit from parent widget, explicitly on, or explicitly off.
type EchoMode ¶
type EchoMode int
EchoMode is used to determine the visibility of Input text.
const ( // EchoModeNormal displays the characters as they're being entered. EchoModeNormal EchoMode = iota // EchoModeNoEcho disables text display. This is useful for when the length // of the password should be kept secret. EchoModeNoEcho // EchoModePassword replaces all characters with asterisks. EchoModePassword )
type FocusChain ¶
type FocusChain interface { FocusNext(w Widget) Widget FocusPrev(w Widget) Widget FocusDefault() Widget }
FocusChain enables custom focus traversal when Tab or Backtab is pressed.
type GaugeTheme ¶
type Input ¶
type Input struct { //WidgetBase Block // contains filtered or unexported fields }
Input is a one-line text editor. It lets the user supply the application with text, e.g., to input user and password information.
func (*Input) MinSizeHint ¶
MinSizeHint returns the minimum size hint for the layout.
func (*Input) OnChanged ¶
OnChanged sets a function to be run whenever the content of the Input has been changed.
func (*Input) OnSubmit ¶
OnSubmit sets a function to be run whenever the user submits the Input (by pressing KeyEnter).
func (*Input) SetEchoMode ¶
SetEchoMode sets the echo mode of the Input.
type Label ¶
type Label struct { Block // contains filtered or unexported fields }
Label is a widget to display read-only text.
func (*Label) MinSizeHint ¶
MinSizeHint returns the minimum size the widget is allowed to be.
func (*Label) SetStyleName ¶
SetStyleName sets the identifier used for custom styling.
func (*Label) SetWordWrap ¶
SetWordWrap sets whether text content should be wrapped.
type LayoutMode ¶
type LayoutMode int
Alignment is used to set the direction in which widgets are laid out.
const ( Horizontal LayoutMode = iota Vertical )
Available alignment options.
type Logger ¶
type Logger interface {
Printf(format string, args ...interface{})
}
Logger provides a interface for the standard logger.
type Painter ¶
type Painter struct {
// contains filtered or unexported fields
}
Painter provides operations to paint on a surface.
func (*Painter) DrawCursor ¶
DrawCursor draws the cursor at the given position.
type ParagraphTheme ¶
type ParagraphTheme struct {
Text Style
}
type PieChartTheme ¶
type PieChartTheme struct {
Slices []Color
}
type RootTheme ¶
type RootTheme struct { Default Style Block BlockTheme BarChart BarChartTheme Gauge GaugeTheme Plot PlotTheme List ListTheme Tree TreeTheme Paragraph ParagraphTheme PieChart PieChartTheme Sparkline SparklineTheme StackedBarChart StackedBarChartTheme Tab TabTheme Table TableTheme // contains filtered or unexported fields }
Theme defines the styles for a set of identifiers.
func (*RootTheme) HasStyle ¶
HasStyle returns whether an identifier is associated with an identifier.
type RuneBuffer ¶
type RuneBuffer struct {
// contains filtered or unexported fields
}
RuneBuffer provides readline functionality for text widgets.
func (*RuneBuffer) Backspace ¶
func (r *RuneBuffer) Backspace()
Backspace deletes the rune left of the cursor.
func (*RuneBuffer) CursorPos ¶
func (r *RuneBuffer) CursorPos() image.Point
CursorPos returns the coordinate for the cursor for a given width.
func (*RuneBuffer) Delete ¶
func (r *RuneBuffer) Delete()
Delete deletes the rune at the current cursor position.
func (*RuneBuffer) Kill ¶
func (r *RuneBuffer) Kill()
Kill deletes all runes from the cursor until the end of the line.
func (*RuneBuffer) Len ¶
func (r *RuneBuffer) Len() int
Len returns the number of runes in the buffer.
func (*RuneBuffer) MoveBackward ¶
func (r *RuneBuffer) MoveBackward()
MoveBackward moves the cursor back by one rune.
func (*RuneBuffer) MoveForward ¶
func (r *RuneBuffer) MoveForward()
MoveForward moves the cursor forward by one rune.
func (*RuneBuffer) MoveToLineEnd ¶
func (r *RuneBuffer) MoveToLineEnd()
MoveToLineEnd moves the cursor to the end of the current line.
func (*RuneBuffer) MoveToLineStart ¶
func (r *RuneBuffer) MoveToLineStart()
MoveToLineStart moves the cursor to the start of the current line.
func (*RuneBuffer) Pos ¶
func (r *RuneBuffer) Pos() int
Pos returns the current index in the buffer.
func (*RuneBuffer) Set ¶
func (r *RuneBuffer) Set(buf []rune)
Set the buffer and the index at the end of the buffer.
func (*RuneBuffer) SetMaxWidth ¶
func (r *RuneBuffer) SetMaxWidth(w int)
SetMaxWidth sets the maximum text width.
func (*RuneBuffer) SetWithIdx ¶
func (r *RuneBuffer) SetWithIdx(idx int, buf []rune)
SetWithIdx set the the buffer with a given index.
func (*RuneBuffer) SplitByLine ¶
func (r *RuneBuffer) SplitByLine() []string
SplitByLine returns the lines for a given width.
func (*RuneBuffer) String ¶
func (r *RuneBuffer) String() string
func (*RuneBuffer) Width ¶
func (r *RuneBuffer) Width() int
Width returns the width of the rune buffer, taking into account for CJK.
func (*RuneBuffer) WriteRune ¶
func (r *RuneBuffer) WriteRune(s rune)
WriteRune appends a rune to the buffer.
func (*RuneBuffer) WriteRunes ¶
func (r *RuneBuffer) WriteRunes(s []rune)
WriteRunes appends runes to the buffer.
type Screen ¶
Buffer represents a section of a terminal and is a renderable rectangle of cells.
func (*Screen) HideCursor ¶
func (s *Screen) HideCursor()
type SimpleFocusChain ¶
type SimpleFocusChain struct {
// contains filtered or unexported fields
}
SimpleFocusChain represents a ring of widgets where focus is loops to the first widget when it reaches the end.
func (*SimpleFocusChain) FocusDefault ¶
func (c *SimpleFocusChain) FocusDefault() Widget
FocusDefault returns the default widget for when there is no widget currently focused.
func (*SimpleFocusChain) FocusNext ¶
func (c *SimpleFocusChain) FocusNext(current Widget) Widget
FocusNext returns the widget in the ring that is after the given widget.
func (*SimpleFocusChain) FocusPrev ¶
func (c *SimpleFocusChain) FocusPrev(current Widget) Widget
FocusPrev returns the widget in the ring that is before the given widget.
func (*SimpleFocusChain) Set ¶
func (c *SimpleFocusChain) Set(ws ...Widget)
Set sets the widgets in the focus chain. Widgets will received focus in the order widgets were passed.
type SizePolicy ¶
type SizePolicy int
SizePolicy determines the space occupied by a widget.
const ( // Preferred interprets the size hint as the preferred size. Preferred SizePolicy = iota // Minimum allows the widget to shrink down to the size hint. Minimum // Maximum allows the widget to grow up to the size hint. Maximum // Expanding makes the widget expand to the available space. Expanding )
type SparklineTheme ¶
type StackedBarChartTheme ¶
type Style ¶
Style determines how a cell should be painted. The zero value uses default from
func NewStyle ¶
NewStyle takes 1 to 3 arguments 1st argument = Fg 2nd argument = optional Bg 3rd argument = optional Modifier
func SelectStyle ¶
func (*Style) SetModifier ¶
type Surface ¶
type Surface interface { GetCell(p image.Point) Cell SetCell(c Cell, p image.Point) Fill(c Cell, rect image.Rectangle) SetCursor(x, y int) HideCursor() Size() image.Point Clear() Show() }
Surface defines a surface that can be painted on.
type TableTheme ¶
type TableTheme struct {
Text Style
}
type UI ¶
type UI interface { // SetWidget sets the root widget of the UI. SetWidget(w Widget) // SetTheme sets the current theme of the UI. //SetTheme(p *Theme) // SetKeybinding sets the callback for when a key sequence is pressed. SetKeybinding(seq string, fn func()) // ClearKeybindings removes all previous set keybindings. ClearKeybindings() // SetFocusChain sets a chain of widgets that determines focus order. SetFocusChain(ch FocusChain) // Run starts the UI goroutine and blocks either Quit was called or an error occurred. Run() error // Update schedules work in the UI thread and await its completion. // Note that calling Update from the UI thread will result in deadlock. Update(fn func()) // Quit shuts down the UI goroutine. Quit() // Repaint the UI Repaint() }
type Widget ¶
type Widget interface { GetOuter() image.Rectangle GetInner() image.Rectangle GetInnerRealPos() image.Rectangle SetRect(x, y, w, h int) Draw() sync.Locker SetFocused(bool) IsFocused() bool SetActive(a bool) IsActive() bool SetParent(p Widget) GetPainter() *Painter SetPainter(p *Painter) DoEvent(e Event) bool OnEvent(fn func(w Widget, e *Event)) Append(w Widget) Prepend(w Widget) Insert(i int, w Widget) Remove(i int) Length() int //SetBorder(enabled bool) //SetTitle(title string) SetText(text string) LayoutMode() LayoutMode //子元素排列布局 SizePolicy() (SizePolicy, SizePolicy) //显示模式 MinSizeHint() image.Point SizeHint() image.Point Resize(pos image.Point, size image.Point) ReLayout() //重新布局 sync.Locker }
type WidgetBase ¶
func (*WidgetBase) Append ¶
func (s *WidgetBase) Append(w Widget)
Append adds the given widget at the end of the Box.
func (*WidgetBase) Draw ¶
func (s *WidgetBase) Draw()
func (*WidgetBase) GetInnerRealPos ¶
func (s *WidgetBase) GetInnerRealPos() image.Rectangle
获取打印的真实坐标
func (*WidgetBase) GetPainter ¶
func (w *WidgetBase) GetPainter() *Painter
func (*WidgetBase) GetParentMin ¶
func (s *WidgetBase) GetParentMin() image.Point
func (*WidgetBase) Init ¶
func (s *WidgetBase) Init()
func (*WidgetBase) Insert ¶
func (s *WidgetBase) Insert(i int, w Widget)
Insert adds the widget into the Box at a given index.
func (*WidgetBase) IsActive ¶
func (w *WidgetBase) IsActive() bool
IsActive returns whether the widget is active.
func (*WidgetBase) IsFocused ¶
func (w *WidgetBase) IsFocused() bool
IsFocused returns whether the widget is focused.
func (*WidgetBase) LayoutMode ¶
func (s *WidgetBase) LayoutMode() LayoutMode
Alignment returns the current alignment of the Box.
func (*WidgetBase) Length ¶
func (s *WidgetBase) Length() int
Length returns the number of items in the box.
func (*WidgetBase) MinSizeHint ¶
func (s *WidgetBase) MinSizeHint() image.Point
MinSizeHint returns the minimum size hint for the layout.
func (*WidgetBase) OnEvent ¶
func (s *WidgetBase) OnEvent(fn func(w Widget, e *Event))
func (*WidgetBase) Prepend ¶
func (s *WidgetBase) Prepend(w Widget)
Prepend adds the given widget at the start of the Box.
func (*WidgetBase) Remove ¶
func (s *WidgetBase) Remove(i int)
Remove deletes the widget from the Box at a given index.
func (*WidgetBase) SetFocused ¶
func (w *WidgetBase) SetFocused(f bool)
SetFocused focuses the widget.
func (*WidgetBase) SetHeight ¶
func (w *WidgetBase) SetHeight(height int)
SetHeight returns whether the widget is active.
func (*WidgetBase) SetPainter ¶
func (w *WidgetBase) SetPainter(p *Painter)
func (*WidgetBase) SetParent ¶
func (w *WidgetBase) SetParent(p Widget)
SetActive active the widget.
func (*WidgetBase) SetStyle ¶
func (w *WidgetBase) SetStyle(style Style)
IsActive returns whether the widget is active.
func (*WidgetBase) SetWidth ¶
func (w *WidgetBase) SetWidth(width int)
SetWidth returns whether the widget is active.
func (*WidgetBase) SizeHint ¶
func (s *WidgetBase) SizeHint() image.Point
SizeHint returns the recommended size hint for the layout.
func (*WidgetBase) SizePolicy ¶
func (w *WidgetBase) SizePolicy() (SizePolicy, SizePolicy)
SizePolicy returns the current size policy.