diff options
Diffstat (limited to 'AAA_GOFILES')
| -rw-r--r-- | AAA_GOFILES/box.go | 121 | ||||
| -rw-r--r-- | AAA_GOFILES/button.go | 114 | ||||
| -rw-r--r-- | AAA_GOFILES/checkbox.go | 124 |
3 files changed, 0 insertions, 359 deletions
diff --git a/AAA_GOFILES/box.go b/AAA_GOFILES/box.go deleted file mode 100644 index caf49e3..0000000 --- a/AAA_GOFILES/box.go +++ /dev/null @@ -1,121 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -import "C" - -// Box is a Control that holds a group of Controls horizontally -// or vertically. If horizontally, then all controls have the same -// height. If vertically, then all controls have the same width. -// By default, each control has its preferred width (horizontal) -// or height (vertical); 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 Box struct { - c *C.uiControl - b *C.uiBox - - children []Control -} - -// NewHorizontalBox creates a new horizontal Box. -func NewHorizontalBox() *Box { - b := new(Box) - - b.b = C.uiNewHorizontalBox() - b.c = (*C.uiControl)(unsafe.Pointer(b.b)) - - return b -} - -// NewVerticalBox creates a new vertical Box. -func NewVerticalBox() *Box { - b := new(Box) - - b.b = C.uiNewVerticalBox() - b.c = (*C.uiControl)(unsafe.Pointer(b.b)) - - return b -} - -// Destroy destroys the Box. If the Box has children, -// Destroy calls Destroy on those Controls as well. -func (b *Box) Destroy() { - for len(b.children) != 0 { - c := b.children[0] - b.Delete(0) - c.Destroy() - } - C.uiControlDestroy(b.c) -} - -// LibuiControl returns the libui uiControl pointer that backs -// the Box. This is only used by package ui itself and should -// not be called by programs. -func (b *Box) LibuiControl() uintptr { - return uintptr(unsafe.Pointer(b.c)) -} - -// Handle returns the OS-level handle associated with this Box. -// On Windows this is an HWND of a libui-internal class. -// On GTK+ this is a pointer to a GtkBox. -// On OS X this is a pointer to a NSView. -func (b *Box) Handle() uintptr { - return uintptr(C.uiControlHandle(b.c)) -} - -// Show shows the Box. -func (b *Box) Show() { - C.uiControlShow(b.c) -} - -// Hide hides the Box. -func (b *Box) Hide() { - C.uiControlHide(b.c) -} - -// Enable enables the Box. -func (b *Box) Enable() { - C.uiControlEnable(b.c) -} - -// Disable disables the Box. -func (b *Box) Disable() { - C.uiControlDisable(b.c) -} - -// Append adds the given control to the end of the Box. -func (b *Box) Append(child Control, stretchy bool) { - c := (*C.uiControl)(nil) - if child != nil { - c = touiControl(child.LibuiControl()) - } - C.uiBoxAppend(b.b, c, frombool(stretchy)) - b.children = append(b.children, child) -} - -// Delete deletes the nth control of the Box. -func (b *Box) Delete(n int) { - b.children = append(b.children[:n], b.children[n + 1:]...) - // TODO why is this uintmax_t instead of intmax_t - C.uiBoxDelete(b.b, C.uintmax_t(n)) -} - -// Padded returns whether there is space between each control -// of the Box. -func (b *Box) Padded() bool { - return tobool(C.uiBoxPadded(b.b)) -} - -// SetPadded controls whether there is space between each control -// of the Box. The size of the padding is determined by the OS and -// its best practices. -func (b *Box) SetPadded(padded bool) { - C.uiBoxSetPadded(b.b, frombool(padded)) -} diff --git a/AAA_GOFILES/button.go b/AAA_GOFILES/button.go deleted file mode 100644 index 2696f82..0000000 --- a/AAA_GOFILES/button.go +++ /dev/null @@ -1,114 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -// extern void doButtonOnClicked(uiButton *, void *); -// static inline void realuiButtonOnClicked(uiButton *b) -// { -// uiButtonOnClicked(b, doButtonOnClicked, NULL); -// } -import "C" - -// no need to lock this; only the GUI thread can access it -var buttons = make(map[*C.uiButton]*Button) - -// Button is a Control that represents a button that the user can -// click to perform an action. A Button has a text label that should -// describe what the button does. -type Button struct { - c *C.uiControl - b *C.uiButton - - onClicked func(*Button) -} - -// NewButton creates a new Button with the given text as its label. -func NewButton(text string) *Button { - b := new(Button) - - ctext := C.CString(text) - b.b = C.uiNewButton(ctext) - b.c = (*C.uiControl)(unsafe.Pointer(b.b)) - freestr(ctext) - - C.realuiButtonOnClicked(b.b) - buttons[b.b] = b - - return b -} - -// Destroy destroys the Button. -func (b *Button) Destroy() { - delete(buttons, b.b) - C.uiControlDestroy(b.c) -} - -// LibuiControl returns the libui uiControl pointer that backs -// the Button. This is only used by package ui itself and should -// not be called by programs. -func (b *Button) LibuiControl() uintptr { - return uintptr(unsafe.Pointer(b.c)) -} - -// Handle returns the OS-level handle associated with this Button. -// On Windows this is an HWND of a standard Windows API BUTTON -// class (as provided by Common Controls version 6). -// On GTK+ this is a pointer to a GtkButton. -// On OS X this is a pointer to a NSButton. -func (b *Button) Handle() uintptr { - return uintptr(C.uiControlHandle(b.c)) -} - -// Show shows the Button. -func (b *Button) Show() { - C.uiControlShow(b.c) -} - -// Hide hides the Button. -func (b *Button) Hide() { - C.uiControlHide(b.c) -} - -// Enable enables the Button. -func (b *Button) Enable() { - C.uiControlEnable(b.c) -} - -// Disable disables the Button. -func (b *Button) Disable() { - C.uiControlDisable(b.c) -} - -// Text returns the Button's text. -func (b *Button) Text() string { - ctext := C.uiButtonText(b.b) - text := C.GoString(ctext) - C.uiFreeText(ctext) - return text -} - -// SetText sets the Button's text to text. -func (b *Button) SetText(text string) { - ctext := C.CString(text) - C.uiButtonSetText(b.b, ctext) - freestr(ctext) -} - -// OnClicked registers f to be run when the user clicks the Button. -// Only one function can be registered at a time. -func (b *Button) OnClicked(f func(*Button)) { - b.onClicked = f -} - -//export doButtonOnClicked -func doButtonOnClicked(bb *C.uiButton, data unsafe.Pointer) { - b := buttons[bb] - if b.onClicked != nil { - b.onClicked(b) - } -} diff --git a/AAA_GOFILES/checkbox.go b/AAA_GOFILES/checkbox.go deleted file mode 100644 index b518b29..0000000 --- a/AAA_GOFILES/checkbox.go +++ /dev/null @@ -1,124 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -// extern void doCheckboxOnToggled(uiCheckbox *, void *); -// static inline void realuiCheckboxOnToggled(uiCheckbox *c) -// { -// uiCheckboxOnToggled(c, doCheckboxOnToggled, NULL); -// } -import "C" - -// no need to lock this; only the GUI thread can access it -var checkboxes = make(map[*C.uiCheckbox]*Checkbox) - -// Checkbox is a Control that represents a box with a text label at its -// side. When the user clicks the checkbox, a check mark will appear -// in the box; clicking it again removes the check. -type Checkbox struct { - co *C.uiControl - c *C.uiCheckbox - - onToggled func(*Checkbox) -} - -// NewCheckbox creates a new Checkbox with the given text as its label. -func NewCheckbox(text string) *Checkbox { - c := new(Checkbox) - - ctext := C.CString(text) - c.c = C.uiNewCheckbox(ctext) - c.co = (*C.uiControl)(unsafe.Pointer(c.c)) - freestr(ctext) - - C.realuiCheckboxOnToggled(c.c) - checkboxes[c.c] = c - - return c -} - -// Destroy destroys the Checkbox. -func (c *Checkbox) Destroy() { - delete(checkboxes, c.c) - C.uiControlDestroy(c.co) -} - -// LibuiControl returns the libui uiControl pointer that backs -// the Window. This is only used by package ui itself and should -// not be called by programs. -func (c *Checkbox) LibuiControl() uintptr { - return uintptr(unsafe.Pointer(c.co)) -} - -// Handle returns the OS-level handle associated with this Checkbox. -// On Windows this is an HWND of a standard Windows API BUTTON -// class (as provided by Common Controls version 6). -// On GTK+ this is a pointer to a GtkCheckButton. -// On OS X this is a pointer to a NSButton. -func (c *Checkbox) Handle() uintptr { - return uintptr(C.uiControlHandle(c.co)) -} - -// Show shows the Checkbox. -func (c *Checkbox) Show() { - C.uiControlShow(c.co) -} - -// Hide hides the Checkbox. -func (c *Checkbox) Hide() { - C.uiControlHide(c.co) -} - -// Enable enables the Checkbox. -func (c *Checkbox) Enable() { - C.uiControlEnable(c.co) -} - -// Disable disables the Checkbox. -func (c *Checkbox) Disable() { - C.uiControlDisable(c.co) -} - -// Text returns the Checkbox's text. -func (c *Checkbox) Text() string { - ctext := C.uiCheckboxText(c.c) - text := C.GoString(ctext) - C.uiFreeText(ctext) - return text -} - -// SetText sets the Checkbox's text to text. -func (c *Checkbox) SetText(text string) { - ctext := C.CString(text) - C.uiCheckboxSetText(c.c, ctext) - freestr(ctext) -} - -// OnToggled registers f to be run when the user clicks the Checkbox. -// Only one function can be registered at a time. -func (c *Checkbox) OnToggled(f func(*Checkbox)) { - c.onToggled = f -} - -//export doCheckboxOnToggled -func doCheckboxOnToggled(cc *C.uiCheckbox, data unsafe.Pointer) { - c := checkboxes[cc] - if c.onToggled != nil { - c.onToggled(c) - } -} - -// Checked returns whether the Checkbox is checked. -func (c *Checkbox) Checked() bool { - return tobool(C.uiCheckboxChecked(c.c)) -} - -// SetChecked sets whether the Checkbox is checked. -func (c *Checkbox) SetChecked(checked bool) { - C.uiCheckboxSetChecked(c.c, frombool(checked)) -} |
