diff options
Diffstat (limited to 'BBB_GOFILES')
| -rw-r--r-- | BBB_GOFILES/combobox.go | 67 | ||||
| -rw-r--r-- | BBB_GOFILES/editablecombobox.go | 72 | ||||
| -rw-r--r-- | BBB_GOFILES/entry.go | 93 | ||||
| -rw-r--r-- | BBB_GOFILES/form.go | 71 | ||||
| -rw-r--r-- | BBB_GOFILES/grid.go | 96 | ||||
| -rw-r--r-- | BBB_GOFILES/group.go | 80 | ||||
| -rw-r--r-- | BBB_GOFILES/label.go | 44 | ||||
| -rw-r--r-- | BBB_GOFILES/progressbar.go | 39 |
8 files changed, 0 insertions, 562 deletions
diff --git a/BBB_GOFILES/combobox.go b/BBB_GOFILES/combobox.go deleted file mode 100644 index 1e381de..0000000 --- a/BBB_GOFILES/combobox.go +++ /dev/null @@ -1,67 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -// extern void doComboboxOnSelected(uiCombobox *, void *); -// // see golang/go#19835 -// typedef void (*comboboxCallback)(uiCombobox *, void *); -import "C" - -// Combobox is a Control that represents a drop-down list of strings -// that the user can choose one of at any time. For a Combobox that -// users can type values into, see EditableCombobox. -type Combobox struct { - ControlBase - c *C.uiCombobox - onSelected func(*Combobox) -} - -// NewCombobox creates a new Combobox. -func NewCombobox() *Combobox { - c := new(Combobox) - - c.c = C.uiNewCombobox() - - C.uiComboboxOnSelected(c.c, C.comboboxCallback(C.doComboboxOnSelected), nil) - - c.ControlBase = NewControlBase(c, uintptr(unsafe.Pointer(c.c))) - return c -} - -// Append adds the named item to the end of the Combobox. -func (c *Combobox) Append(text string) { - ctext := C.CString(text) - C.uiComboboxAppend(c.c, ctext) - freestr(ctext) -} - -// Selected returns the index of the currently selected item in the -// Combobox, or -1 if nothing is selected. -func (c *Combobox) Selected() int { - return int(C.uiComboboxSelected(c.c)) -} - -// SetSelected sets the currently selected item in the Combobox -// to index. If index is -1 no item will be selected. -func (c *Combobox) SetSelected(index int) { - C.uiComboboxSetSelected(c.c, C.int(index)) -} - -// OnSelected registers f to be run when the user selects an item in -// the Combobox. Only one function can be registered at a time. -func (c *Combobox) OnSelected(f func(*Combobox)) { - c.onSelected = f -} - -//export doComboboxOnSelected -func doComboboxOnSelected(cc *C.uiCombobox, data unsafe.Pointer) { - c := ControlFromLibui(uintptr(unsafe.Pointer(cc))).(*Combobox) - if c.onSelected != nil { - c.onSelected(c) - } -} diff --git a/BBB_GOFILES/editablecombobox.go b/BBB_GOFILES/editablecombobox.go deleted file mode 100644 index 1242928..0000000 --- a/BBB_GOFILES/editablecombobox.go +++ /dev/null @@ -1,72 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -// extern void doEditableComboboxOnChanged(uiEditableCombobox *, void *); -// // see golang/go#19835 -// typedef void (*editableComboboxCallback)(uiEditableCombobox *, void *); -import "C" - -// EditableCombobox is a Control that represents a drop-down list -// of strings that the user can choose one of at any time. It also has -// an entry field that the user can type an alternate choice into. -type EditableCombobox struct { - ControlBase - c *C.uiEditableCombobox - onChanged func(*EditableCombobox) -} - -// NewEditableCombobox creates a new EditableCombobox. -func NewEditableCombobox() *EditableCombobox { - c := new(EditableCombobox) - - c.c = C.uiNewEditableCombobox() - - C.uiEditableComboboxOnChanged(c.c, C.editableComboboxCallback(C.doEditableComboboxOnChanged), nil) - - c.ControlBase = NewControlBase(c, uintptr(unsafe.Pointer(c.c))) - return c -} - -// Append adds the named item to the end of the EditableCombobox. -func (e *EditableCombobox) Append(text string) { - ctext := C.CString(text) - C.uiEditableComboboxAppend(e.c, ctext) - freestr(ctext) -} - -// Text returns the text in the entry of the EditableCombobox, which -// could be one of the choices in the list if the user has selected one. -func (e *EditableCombobox) Text() string { - ctext := C.uiEditableComboboxText(e.c) - text := C.GoString(ctext) - C.uiFreeText(ctext) - return text -} - -// SetText sets the text in the entry of the EditableCombobox. -func (e *EditableCombobox) SetText(text string) { - ctext := C.CString(text) - C.uiEditableComboboxSetText(e.c, ctext) - freestr(ctext) -} - -// OnChanged registers f to be run when the user either selects an -// item or changes the text in the EditableCombobox. Only one -// function can be registered at a time. -func (e *EditableCombobox) OnChanged(f func(*EditableCombobox)) { - e.onChanged = f -} - -//export doEditableComboboxOnChanged -func doEditableComboboxOnChanged(cc *C.uiEditableCombobox, data unsafe.Pointer) { - e := ControlFromLibui(uintptr(unsafe.Pointer(cc))).(*EditableCombobox) - if e.onChanged != nil { - e.onChanged(e) - } -} diff --git a/BBB_GOFILES/entry.go b/BBB_GOFILES/entry.go deleted file mode 100644 index 52da537..0000000 --- a/BBB_GOFILES/entry.go +++ /dev/null @@ -1,93 +0,0 @@ -// 12 december 2015 - -// TODO typing in entry in OS X crashes libui -// I've had similar issues with checkboxes on libui -// something's wrong with NSMapTable - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -// extern void doEntryOnChanged(uiEntry *, void *); -// // see golang/go#19835 -// typedef void (*entryCallback)(uiEntry *, void *); -import "C" - -// Entry is a Control that represents a space that the user can -// type a single line of text into. -type Entry struct { - ControlBase - e *C.uiEntry - onChanged func(*Entry) -} - -func finishNewEntry(ee *C.uiEntry) *Entry { - e := new(Entry) - - e.e = ee - - C.uiEntryOnChanged(e.e, C.entryCallback(C.doEntryOnChanged), nil) - - e.ControlBase = NewControlBase(e, uintptr(unsafe.Pointer(e.e))) - return e -} - -// NewEntry creates a new Entry. -func NewEntry() *Entry { - return finishNewEntry(C.uiNewEntry()) -} - -// NewPasswordEntry creates a new Entry whose contents are -// visibly obfuscated, suitable for passwords. -func NewPasswordEntry() *Entry { - return finishNewEntry(C.uiNewPasswordEntry()) -} - -// NewSearchEntry creates a new Entry suitable for searching with. -// Changed events may, depending on the system, be delayed -// with a search Entry, to produce a smoother user experience. -func NewSearchEntry() *Entry { - return finishNewEntry(C.uiNewSearchEntry()) -} - -// Text returns the Entry's text. -func (e *Entry) Text() string { - ctext := C.uiEntryText(e.e) - text := C.GoString(ctext) - C.uiFreeText(ctext) - return text -} - -// SetText sets the Entry's text to text. -func (e *Entry) SetText(text string) { - ctext := C.CString(text) - C.uiEntrySetText(e.e, ctext) - freestr(ctext) -} - -// OnChanged registers f to be run when the user makes a change to -// the Entry. Only one function can be registered at a time. -func (e *Entry) OnChanged(f func(*Entry)) { - e.onChanged = f -} - -//export doEntryOnChanged -func doEntryOnChanged(ee *C.uiEntry, data unsafe.Pointer) { - e := ControlFromLibui(uintptr(unsafe.Pointer(ee))).(*Entry) - if e.onChanged != nil { - e.onChanged(e) - } -} - -// ReadOnly returns whether the Entry can be changed. -func (e *Entry) ReadOnly() bool { - return tobool(C.uiEntryReadOnly(e.e)) -} - -// SetReadOnly sets whether the Entry can be changed. -func (e *Entry) SetReadOnly(ro bool) { - C.uiEntrySetReadOnly(e.e, frombool(ro)) -} diff --git a/BBB_GOFILES/form.go b/BBB_GOFILES/form.go deleted file mode 100644 index 6f8a282..0000000 --- a/BBB_GOFILES/form.go +++ /dev/null @@ -1,71 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -import "C" - -// Form is a Control that holds a group of Controls vertically -// with labels next to each. By default, each control has its -// preferred height; if a control is marked "stretchy", it will take -// whatever space is left over. If multiple controls are marked -// stretchy, they will be given equal shares of the leftover space. -// There can also be space between each control ("padding"). -type Form struct { - ControlBase - f *C.uiForm - children []Control -} - -// NewForm creates a new horizontal Form. -func NewForm() *Form { - f := new(Form) - - f.f = C.uiNewForm() - - f.ControlBase = NewControlBase(f, uintptr(unsafe.Pointer(f.f))) - return f -} - -// Destroy destroys the Form. If the Form has children, -// Destroy calls Destroy on those Controls as well. -func (f *Form) Destroy() { - for len(f.children) != 0 { - c := f.children[0] - f.Delete(0) - c.Destroy() - } - f.ControlBase.Destroy() -} - -// Append adds the given control to the end of the Form. -func (f *Form) Append(label string, child Control, stretchy bool) { - clabel := C.CString(label) - defer freestr(clabel) - c := touiControl(child.LibuiControl()) - C.uiFormAppend(f.f, clabel, c, frombool(stretchy)) - f.children = append(f.children, child) -} - -// Delete deletes the nth control of the Form. -func (f *Form) Delete(n int) { - f.children = append(f.children[:n], f.children[n + 1:]...) - C.uiFormDelete(f.f, C.int(n)) -} - -// Padded returns whether there is space between each control -// of the Form. -func (f *Form) Padded() bool { - return tobool(C.uiFormPadded(f.f)) -} - -// SetPadded controls whether there is space between each control -// of the Form. The size of the padding is determined by the OS and -// its best practices. -func (f *Form) SetPadded(padded bool) { - C.uiFormSetPadded(f.f, frombool(padded)) -} diff --git a/BBB_GOFILES/grid.go b/BBB_GOFILES/grid.go deleted file mode 100644 index a1985fc..0000000 --- a/BBB_GOFILES/grid.go +++ /dev/null @@ -1,96 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -import "C" - -// Grid is a Control that arranges other Controls in a grid. -// Grid is a very powerful container: it can position and size each -// Control in several ways and can (and must) have Controls added -// to it in any direction. It can also have Controls spanning multiple -// rows and columns. -// -// Each Control in a Grid has associated "expansion" and -// "alignment" values in both the X and Y direction. -// Expansion determines whether all cells in the same row/column -// are given whatever space is left over after figuring out how big -// the rest of the Grid should be. Alignment determines the position -// of a Control relative to its cell after computing the above. The -// special alignment Fill can be used to grow a Control to fit its cell. -// Note that expansion and alignment are independent variables. -// For more information on expansion and alignment, read -// https://developer.gnome.org/gtk3/unstable/ch28s02.html. -type Grid struct { - ControlBase - g *C.uiGrid - children []Control -} - -// Align represents the alignment of a Control in its cell of a Grid. -type Align int -const ( - AlignFill Align = iota - AlignStart - AlignCenter - AlignEnd -) - -// At represents a side of a Control to add other Controls to a Grid to. -type At int -const ( - Leading At = iota - Top - Trailing - Bottom -) - -// NewGrid creates a new Grid. -func NewGrid() *Grid { - g := new(Grid) - - g.g = C.uiNewGrid() - - g.ControlBase = NewControlBase(g, uintptr(unsafe.Pointer(g.g))) - return g -} - -// TODO Destroy - -// Append adds the given control to the Grid, at the given coordinate. -func (g *Grid) Append(child Control, left, top int, xspan, yspan int, hexpand bool, halign Align, vexpand bool, valign Align) { - C.uiGridAppend(g.g, touiControl(child.LibuiControl()), - C.int(left), C.int(top), - C.int(xspan), C.int(yspan), - frombool(hexpand), C.uiAlign(halign), - frombool(vexpand), C.uiAlign(valign)) - g.children = append(g.children, child) -} - -// InsertAt adds the given control to the Grid relative to an existing -// control. -func (g *Grid) InsertAt(child Control, existing Control, at At, xspan, yspan int, hexpand bool, halign Align, vexpand bool, valign Align) { - C.uiGridInsertAt(g.g, touiControl(child.LibuiControl()), - touiControl(existing.LibuiControl()), C.uiAt(at), - C.int(xspan), C.int(yspan), - frombool(hexpand), C.uiAlign(halign), - frombool(vexpand), C.uiAlign(valign)) - g.children = append(g.children, child) -} - -// Padded returns whether there is space between each control -// of the Grid. -func (g *Grid) Padded() bool { - return tobool(C.uiGridPadded(g.g)) -} - -// SetPadded controls whether there is space between each control -// of the Grid. The size of the padding is determined by the OS and -// its best practices. -func (g *Grid) SetPadded(padded bool) { - C.uiGridSetPadded(g.g, frombool(padded)) -} diff --git a/BBB_GOFILES/group.go b/BBB_GOFILES/group.go deleted file mode 100644 index 6992948..0000000 --- a/BBB_GOFILES/group.go +++ /dev/null @@ -1,80 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -import "C" - -// Group is a Control that holds another Control and wraps it around -// a labelled box (though some systems make this box invisible). -// You can use this to group related controls together. -type Group struct { - ControlBase - g *C.uiGroup - child Control -} - -// NewGroup creates a new Group. -func NewGroup(title string) *Group { - g := new(Group) - - ctitle := C.CString(title) - g.g = C.uiNewGroup(ctitle) - freestr(ctitle) - - g.ControlBase = NewControlBase(g, uintptr(unsafe.Pointer(g.g))) - return g -} - -// Destroy destroys the Group. If the Group has a child, -// Destroy calls Destroy on that as well. -func (g *Group) Destroy() { - if g.child != nil { - c := g.child - g.SetChild(nil) - c.Destroy() - } - g.ControlBase.Destroy() -} - -// Title returns the Group's title. -func (g *Group) Title() string { - ctitle := C.uiGroupTitle(g.g) - title := C.GoString(ctitle) - C.uiFreeText(ctitle) - return title -} - -// SetTitle sets the Group's title to title. -func (g *Group) SetTitle(title string) { - ctitle := C.CString(title) - C.uiGroupSetTitle(g.g, ctitle) - freestr(ctitle) -} - -// SetChild sets the Group's child to child. If child is nil, the Group -// will not have a child. -func (g *Group) SetChild(child Control) { - g.child = child - c := (*C.uiControl)(nil) - if g.child != nil { - c = touiControl(g.child.LibuiControl()) - } - C.uiGroupSetChild(g.g, c) -} - -// Margined returns whether the Group has margins around its child. -func (g *Group) Margined() bool { - return tobool(C.uiGroupMargined(g.g)) -} - -// SetMargined controls whether the Group has margins around its -// child. The size of the margins are determined by the OS and its -// best practices. -func (g *Group) SetMargined(margined bool) { - C.uiGroupSetMargined(g.g, frombool(margined)) -} diff --git a/BBB_GOFILES/label.go b/BBB_GOFILES/label.go deleted file mode 100644 index cac7680..0000000 --- a/BBB_GOFILES/label.go +++ /dev/null @@ -1,44 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -import "C" - -// Label is a Control that represents a line of text that cannot be -// interacted with. -type Label struct { - ControlBase - l *C.uiLabel -} - -// NewLabel creates a new Label with the given text. -func NewLabel(text string) *Label { - l := new(Label) - - ctext := C.CString(text) - l.l = C.uiNewLabel(ctext) - freestr(ctext) - - l.ControlBase = NewControlBase(l, uintptr(unsafe.Pointer(l.l))) - return l -} - -// Text returns the Label's text. -func (l *Label) Text() string { - ctext := C.uiLabelText(l.l) - text := C.GoString(ctext) - C.uiFreeText(ctext) - return text -} - -// SetText sets the Label's text to text. -func (l *Label) SetText(text string) { - ctext := C.CString(text) - C.uiLabelSetText(l.l, ctext) - freestr(ctext) -} diff --git a/BBB_GOFILES/progressbar.go b/BBB_GOFILES/progressbar.go deleted file mode 100644 index f58976f..0000000 --- a/BBB_GOFILES/progressbar.go +++ /dev/null @@ -1,39 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -import "C" - -// ProgressBar is a Control that represents a horizontal bar that -// is filled in progressively over time as a process completes. -type ProgressBar struct { - ControlBase - p *C.uiProgressBar -} - -// NewProgressBar creates a new ProgressBar. -func NewProgressBar() *ProgressBar { - p := new(ProgressBar) - - p.p = C.uiNewProgressBar() - - p.ControlBase = NewControlBase(p, uintptr(unsafe.Pointer(p.p))) - return p -} - -// Value returns the value currently shown in the ProgressBar. -func (p *ProgressBar) Value() int { - return int(C.uiProgressBarValue(p.p)) -} - -// SetValue sets the ProgressBar's currently displayed percentage -// to value. value must be between 0 and 100 inclusive, or -1 for -// an indeterminate progressbar. -func (p *ProgressBar) SetValue(value int) { - C.uiProgressBarSetValue(p.p, C.int(value)) -} |
