diff options
Diffstat (limited to 'AAA_GOFILES')
| -rw-r--r-- | AAA_GOFILES/combobox.go | 116 | ||||
| -rw-r--r-- | AAA_GOFILES/datetimepicker.go | 160 | ||||
| -rw-r--r-- | AAA_GOFILES/editablecombobox.go | 120 | ||||
| -rw-r--r-- | AAA_GOFILES/entry.go | 125 |
4 files changed, 0 insertions, 521 deletions
diff --git a/AAA_GOFILES/combobox.go b/AAA_GOFILES/combobox.go deleted file mode 100644 index 1224e1e..0000000 --- a/AAA_GOFILES/combobox.go +++ /dev/null @@ -1,116 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -// extern void doComboboxOnSelected(uiCombobox *, void *); -// static inline void realuiComboboxOnSelected(uiCombobox *c) -// { -// uiComboboxOnSelected(c, doComboboxOnSelected, NULL); -// } -import "C" - -// no need to lock this; only the GUI thread can access it -var comboboxes = make(map[*C.uiCombobox]*Combobox) - -// 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 { - co *C.uiControl - c *C.uiCombobox - - onSelected func(*Combobox) -} - -// NewCombobox creates a new Combobox. -func NewCombobox() *Combobox { - c := new(Combobox) - - c.c = C.uiNewCombobox() - c.co = (*C.uiControl)(unsafe.Pointer(c.c)) - - C.realuiComboboxOnSelected(c.c) - comboboxes[c.c] = c - - return c -} - -// Destroy destroys the Combobox. -func (c *Combobox) Destroy() { - delete(comboboxes, 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 *Combobox) LibuiControl() uintptr { - return uintptr(unsafe.Pointer(c.co)) -} - -// Handle returns the OS-level handle associated with this Combobox. -// On Windows this is an HWND of a standard Windows API COMBOBOX -// class (as provided by Common Controls version 6). -// On GTK+ this is a pointer to a GtkComboBoxText. -// On OS X this is a pointer to a NSPopUpButton. -func (c *Combobox) Handle() uintptr { - return uintptr(C.uiControlHandle(c.co)) -} - -// Show shows the Combobox. -func (c *Combobox) Show() { - C.uiControlShow(c.co) -} - -// Hide hides the Combobox. -func (c *Combobox) Hide() { - C.uiControlHide(c.co) -} - -// Enable enables the Combobox. -func (c *Combobox) Enable() { - C.uiControlEnable(c.co) -} - -// Disable disables the Combobox. -func (c *Combobox) Disable() { - C.uiControlDisable(c.co) -} - -// 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)) -} - -// SetChecked sets the currently select 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.intmax_t(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 := comboboxes[cc] - if c.onSelected != nil { - c.onSelected(c) - } -} diff --git a/AAA_GOFILES/datetimepicker.go b/AAA_GOFILES/datetimepicker.go deleted file mode 100644 index ff98ced..0000000 --- a/AAA_GOFILES/datetimepicker.go +++ /dev/null @@ -1,160 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "time" - "unsafe" -) - -// #include <time.h> -// #include "ui.h" -// static inline struct tm *allocTimeStruct(void) -// { -// /* TODO handle error */ -// return (struct tm *) malloc(sizeof (struct tm)); -// } -// extern void doDateTimePickerChanged(uiDateTimePicker *, void *); -// static inline void realuiDateTimePickerOnChanged(uiDateTimePicker *d) -// { -// uiDateTimePickerOnChanged(d, doDateTimePickerOnChanged, NULL); -// } -import "C" - -// DateTimePicker is a Control that represents a field where the user -// can enter a date and/or a time. -type DateTimePicker struct { - c *C.uiControl - d *C.uiDateTimePicker - - onChanged func(*DateTimePicker) -} - -// NewDateTimePicker creates a new DateTimePicker that shows -// both a date and a time. -func NewDateTimePicker() *DateTimePicker { - d := new(DateTimePicker) - - d.d = C.uiNewDateTimePicker() - d.c = (*C.uiControl)(unsafe.Pointer(d.d)) - - C.realuiDateTimePickerOnChanged(d.d) - - return d -} - -// NewDatePicker creates a new DateTimePicker that shows -// only a date. -func NewDatePicker() *DateTimePicker { - d := new(DateTimePicker) - - d.d = C.uiNewDatePicker() - d.c = (*C.uiControl)(unsafe.Pointer(d.d)) - - C.realuiDateTimePickerOnChanged(d.d) - - return d -} - -// NewTimePicker creates a new DateTimePicker that shows -// only a time. -func NewTimePicker() *DateTimePicker { - d := new(DateTimePicker) - - d.d = C.uiNewTimePicker() - d.c = (*C.uiControl)(unsafe.Pointer(d.d)) - - C.realuiDateTimePickerOnChanged(d.d) - - return d -} - -// Destroy destroys the DateTimePicker. -func (d *DateTimePicker) Destroy() { - C.uiControlDestroy(d.c) -} - -// 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 (d *DateTimePicker) LibuiControl() uintptr { - return uintptr(unsafe.Pointer(d.c)) -} - -// Handle returns the OS-level handle associated with this DateTimePicker. -// On Windows this is an HWND of a standard Windows API -// DATETIMEPICK_CLASS class (as provided by Common Controls -// version 6). -// On GTK+ this is a pointer to a libui-internal class. -// On OS X this is a pointer to a NSDatePicker. -func (d *DateTimePicker) Handle() uintptr { - return uintptr(C.uiControlHandle(d.c)) -} - -// Show shows the DateTimePicker. -func (d *DateTimePicker) Show() { - C.uiControlShow(d.c) -} - -// Hide hides the DateTimePicker. -func (d *DateTimePicker) Hide() { - C.uiControlHide(d.c) -} - -// Enable enables the DateTimePicker. -func (d *DateTimePicker) Enable() { - C.uiControlEnable(d.c) -} - -// Disable disables the DateTimePicker. -func (d *DateTimePicker) Disable() { - C.uiControlDisable(d.c) -} - -// Time returns the time stored in the uiDateTimePicker. -// The time is assumed to be local time. -func (d *DateTimePicker) Time() time.Time { - tm := C.allocTimeStruct() - defer C.free(unsafe.Pointer(tm)) - C.uiDateTimePickerTime(d.d, tm) - return time.Date( - int(tm.tm_year + 1900), - time.Month(tm.tm_mon + 1), - int(tm.tm_mday), - int(tm.tm_hour), - int(tm.tm_min), - int(tm.tm_sec), - 0, time.Local) -} - -// SetTime sets the time in the DateTimePicker to t. -// t's components are read as-is; no time zone manipulations -// are done. -func (d *DateTimePicker) SetTime(t time.Time) { - tm := C.allocTimeStruct() - defer C.free(unsafe.Pointer(tm)) - year, mon, mday := t.Date() - tm.tm_year = C.int(year - 1900) - tm.tm_mon = C.int(mon - 1) - tm.tm_mday = C.int(mday) - hour, min, sec := t.Time() - tm.tm_hour = C.int(hour) - tm.tm_min = C.int(min) - tm.tm_sec = C.int(sec) - tm.tm_isdst = -1 - C.uiDateTimePickerSetTime(d.d, tm) -} - -// OnChanged registers f to be run when the user changes the time in the DateTimePicker. -// Only one function can be registered at a time. -func (d *DateTimePicker) OnChanged(f func(*DateTimePicker)) { - d.onChanged = f -} - -//export doDateTimePickerOnChanged -func doDateTimePickerOnChanged(dd *C.uiDateTimePicker, data unsafe.Pointer) { - d := dateTimePickers[dd] - if d.onChanged != nil { - d.onChanged(d) - } -} diff --git a/AAA_GOFILES/editablecombobox.go b/AAA_GOFILES/editablecombobox.go deleted file mode 100644 index 8f6a825..0000000 --- a/AAA_GOFILES/editablecombobox.go +++ /dev/null @@ -1,120 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #include "ui.h" -// extern void doEditableComboboxOnChanged(uiCombobox *, void *); -// static inline void realuiEditableComboboxOnChanged(uiCombobox *c) -// { -// uiEditableComboboxOnChanged(c, doEditableComboboxOnChanged, NULL); -// } -import "C" - -// no need to lock this; only the GUI thread can access it -var editableComboboxes = make(map[*C.uiEditableCombobox]*Combobox) - -// 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 { - co *C.uiControl - c *C.uiEditableCombobox - - onChanged func(*EditableCombobox) -} - -// NewEditableCombobox creates a new EditableCombobox. -func NewEditableCombobox() *EditableCombobox { - c := new(EditableCombobox) - - c.c = C.uiNewEditableCombobox() - c.co = (*C.uiControl)(unsafe.Pointer(c.c)) - - C.realuiEditableComboboxOnChanged(c.c) - editableComboboxes[c.c] = c - - return c -} - -// Destroy destroys the EditableCombobox. -func (c *Combobox) Destroy() { - delete(editableComboboxes, c.c) - C.uiControlDestroy(c.co) -} - -// LibuiControl returns the libui uiControl pointer that backs -// the EditableCombobox. This is only used by package ui itself and -// should not be called by programs. -func (c *Combobox) LibuiControl() uintptr { - return uintptr(unsafe.Pointer(c.co)) -} - -// Handle returns the OS-level handle associated with this EditableCombobox. -// On Windows this is an HWND of a standard Windows API COMBOBOX -// class (as provided by Common Controls version 6). -// On GTK+ this is a pointer to a GtkComboBoxText. -// On OS X this is a pointer to a NSComboBox. -func (c *Combobox) Handle() uintptr { - return uintptr(C.uiControlHandle(c.co)) -} - -// Show shows the EditableCombobox. -func (c *Combobox) Show() { - C.uiControlShow(c.co) -} - -// Hide hides the EditableCombobox. -func (c *Combobox) Hide() { - C.uiControlHide(c.co) -} - -// Enable enables the EditableCombobox. -func (c *Combobox) Enable() { - C.uiControlEnable(c.co) -} - -// Disable disables the EditableCombobox. -func (c *Combobox) Disable() { - C.uiControlDisable(c.co) -} - -// Append adds the named item to the end of the EditableCombobox. -func (c *Combobox) Append(text string) { - ctext := C.CString(text) - C.uiComboboxAppend(c.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 (c *Combobox) Text() string { - ctext := C.uiEditableComboboxText(c.c) - text := C.GoString(ctext) - C.uiFreeText(ctext) - return text -} - -// SetText sets the text in the entry of the EditableCombobox. -func (c *Combobox) SetText(index int) { - ctext := C.CString(text) - C.uiEditableComboboxSetText(c.c, ctext) - freestr(ctext) -} - -// OnChanged 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) OnChanged(f func(*Combobox)) { - c.onChanged = f -} - -//export doComboboxOnChanged -func doComboboxOnChanged(cc *C.uiCombobox, data unsafe.Pointer) { - c := editableComboboxes[cc] - if c.onChanged != nil { - c.onChanged(c) - } -} diff --git a/AAA_GOFILES/entry.go b/AAA_GOFILES/entry.go deleted file mode 100644 index ee14fc8..0000000 --- a/AAA_GOFILES/entry.go +++ /dev/null @@ -1,125 +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 *); -// static inline void realuiEntryOnChanged(uiEntry *b) -// { -// uiEntryOnChanged(b, doEntryOnChanged, NULL); -// } -import "C" - -// no need to lock this; only the GUI thread can access it -var entries = make(map[*C.uiEntry]*Entry) - -// Entry is a Control that represents a space that the user can -// type a single line of text into. -type Entry struct { - c *C.uiControl - e *C.uiEntry - - onChanged func(*Entry) -} - -// NewEntry creates a new Entry. -func NewEntry() *Entry { - e := new(Entry) - - e.e = C.uiNewEntry() - e.c = (*C.uiControl)(unsafe.Pointer(e.e)) - - C.realuiEntryOnChanged(e.e) - entries[e.e] = e - - return e -} - -// Destroy destroys the Entry. -func (e *Entry) Destroy() { - delete(entries, e.e) - C.uiControlDestroy(e.c) -} - -// 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 (e *Entry) LibuiControl() uintptr { - return uintptr(unsafe.Pointer(e.c)) -} - -// Handle returns the OS-level handle associated with this Entry. -// On Windows this is an HWND of a standard Windows API EDIT -// class (as provided by Common Controls version 6). -// On GTK+ this is a pointer to a GtkEntry. -// On OS X this is a pointer to a NSTextField. -func (e *Entry) Handle() uintptr { - return uintptr(C.uiControlHandle(e.c)) -} - -// Show shows the Entry. -func (e *Entry) Show() { - C.uiControlShow(e.c) -} - -// Hide hides the Entry. -func (e *Entry) Hide() { - C.uiControlHide(e.c) -} - -// Enable enables the Entry. -func (e *Entry) Enable() { - C.uiControlEnable(e.c) -} - -// Disable disables the Entry. -func (e *Entry) Disable() { - C.uiControlDisable(e.c) -} - -// 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 := entries[ee] - 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)) -} |
