Fixed build errors.

This commit is contained in:
Pietro Gagliardi 2018-08-12 11:07:33 -04:00
parent cfea745dc7
commit 925adc0782
12 changed files with 46 additions and 20 deletions

View File

@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern void doButtonOnClicked(uiButton *, void *);
// // see golang/go#19835
// typedef void (*buttonCallback)(uiButton *, void *);
import "C"
// Button is a Control that represents a button that the user can
@ -27,7 +29,7 @@ func NewButton(text string) *Button {
b.b = C.uiNewButton(ctext)
freestr(ctext)
C.uiButtonOnClicked(b.b, C.doButtonOnClicked, nil)
C.uiButtonOnClicked(b.b, C.buttonCallback(C.doButtonOnClicked), nil)
b.ControlBase = NewControlBase(b, uintptr(unsafe.Pointer(b.b)))
return b

View File

@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern void doCheckboxOnToggled(uiCheckbox *, void *);
// // see golang/go#19835
// typedef void (*checkboxCallback)(uiCheckbox *, void *);
import "C"
// Checkbox is a Control that represents a box with a text label at its
@ -28,7 +30,7 @@ func NewCheckbox(text string) *Checkbox {
c.c = C.uiNewCheckbox(ctext)
freestr(ctext)
C.uiCheckboxOnToggled(c.c, C.doCheckboxOnToggled, nil)
C.uiCheckboxOnToggled(c.c, C.checkboxCallback(C.doCheckboxOnToggled), nil)
c.ControlBase = NewControlBase(c, uintptr(unsafe.Pointer(c.c)))
return c

View File

@ -8,6 +8,8 @@ import (
// #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
@ -25,7 +27,7 @@ func NewCombobox() *Combobox {
c.c = C.uiNewCombobox()
C.uiComboboxOnSelected(c.c, C.doComboboxOnSelected, nil)
C.uiComboboxOnSelected(c.c, C.comboboxCallback(C.doComboboxOnSelected), nil)
c.ControlBase = NewControlBase(c, uintptr(unsafe.Pointer(c.c)))
return c

View File

@ -130,8 +130,12 @@ func (c *ControlBase) Disable() {
// This function only works on Controls that use ControlBase.
func ControlFromLibui(c uintptr) Control {
// comma-ok form to avoid creating nil entries
c, _ := controls[(*C.uiControl)(unsafe.Pointer(c))]
return c
cc, _ := controls[(*C.uiControl)(unsafe.Pointer(c))]
return cc
}
func touiControl(c uintptr) *C.uiControl {
return (*C.uiControl)(unsafe.Pointer(c))
}
// LibuiFreeText allows implementations of Control

View File

@ -16,6 +16,8 @@ import (
// return (struct tm *) pkguiAlloc(sizeof (struct tm));
// }
// extern void doDateTimePickerOnChanged(uiDateTimePicker *, void *);
// // see golang/go#19835
// typedef void (*dtpCallback)(uiDateTimePicker *, void *);
import "C"
// DateTimePicker is a Control that represents a field where the user
@ -31,7 +33,7 @@ func finishNewDateTimePicker(dd *C.uiDateTimePicker) *DateTimePicker {
d.d = dd
C.uiDateTimePickerOnChanged(d.d, C.doDateTimePickerOnChanged, nil)
C.uiDateTimePickerOnChanged(d.d, C.dtpCallback(C.doDateTimePickerOnChanged), nil)
d.ControlBase = NewControlBase(d, uintptr(unsafe.Pointer(d.d)))
return d
@ -40,7 +42,7 @@ func finishNewDateTimePicker(dd *C.uiDateTimePicker) *DateTimePicker {
// NewDateTimePicker creates a new DateTimePicker that shows
// both a date and a time.
func NewDateTimePicker() *DateTimePicker {
return finishNewDateTImePicker(C.uiNewDateTimePicker())
return finishNewDateTimePicker(C.uiNewDateTimePicker())
}
// NewDatePicker creates a new DateTimePicker that shows
@ -72,7 +74,7 @@ func (d *DateTimePicker) Time() time.Time {
}
// SetTime sets the time in the DateTimePicker to t.
// t's components are read as-is via t.Date() and t.Time();
// t's components are read as-is via t.Date() and t.Clock();
// no time zone manipulations are done.
func (d *DateTimePicker) SetTime(t time.Time) {
tm := C.allocTimeStruct()
@ -81,7 +83,7 @@ func (d *DateTimePicker) SetTime(t time.Time) {
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()
hour, min, sec := t.Clock()
tm.tm_hour = C.int(hour)
tm.tm_min = C.int(min)
tm.tm_sec = C.int(sec)

View File

@ -8,6 +8,8 @@ import (
// #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
@ -25,7 +27,7 @@ func NewEditableCombobox() *EditableCombobox {
c.c = C.uiNewEditableCombobox()
C.uiEditableComboboxOnChanged(c.c, C.doEditableComboboxOnChanged, nil)
C.uiEditableComboboxOnChanged(c.c, C.editableComboboxCallback(C.doEditableComboboxOnChanged), nil)
c.ControlBase = NewControlBase(c, uintptr(unsafe.Pointer(c.c)))
return c
@ -48,7 +50,7 @@ func (e *EditableCombobox) Text() string {
}
// SetText sets the text in the entry of the EditableCombobox.
func (e *EditableCombobox) SetText(index int) {
func (e *EditableCombobox) SetText(text string) {
ctext := C.CString(text)
C.uiEditableComboboxSetText(e.c, ctext)
freestr(ctext)
@ -58,7 +60,7 @@ func (e *EditableCombobox) SetText(index int) {
// item or changes the text in the EditableCombobox. Only one
// function can be registered at a time.
func (e *EditableCombobox) OnChanged(f func(*EditableCombobox)) {
c.onChanged = f
e.onChanged = f
}
//export doEditableComboboxOnChanged

View File

@ -12,6 +12,8 @@ import (
// #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
@ -27,7 +29,7 @@ func finishNewEntry(ee *C.uiEntry) *Entry {
e.e = ee
C.uiEntryOnChanged(e.e, C.doEntryOnChanged, nil)
C.uiEntryOnChanged(e.e, C.entryCallback(C.doEntryOnChanged), nil)
e.ControlBase = NewControlBase(e, uintptr(unsafe.Pointer(e.e)))
return e

View File

@ -12,7 +12,9 @@ import (
// #include "ui.h"
// extern void doQueueMain(void *);
// extern int doOnShouldQuit(void *);
// extern int doOnTimer(void *);
// // see golang/go#19835
// typedef void (*queueMainCallback)(void *);
// typedef int (*onShouldQuitCallback)(void *);
import "C"
// make sure main() runs on the first thread created by the OS
@ -39,7 +41,7 @@ func Main(f func()) error {
C.uiFreeInitError(estr)
return err
}
C.uiOnShouldQuit(C.doOnShouldQuit, nil)
C.uiOnShouldQuit(C.onShouldQuitCallback(C.doOnShouldQuit), nil)
QueueMain(f)
C.uiMain()
return nil
@ -88,7 +90,7 @@ func QueueMain(f func()) {
}
}
qmmap[n] = f
C.uiQueueMain(C.doQueueMain, unsafe.Pointer(n))
C.uiQueueMain(C.queueMainCallback(C.doQueueMain), unsafe.Pointer(n))
}
//export doQueueMain

View File

@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern void doRadioButtonsOnSelected(uiRadioButtons *, void *);
// // see golang/go#19835
// typedef void (*radioButtonsCallback)(uiRadioButtons *, void *);
import "C"
// RadioButtons is a Control that represents a set of checkable
@ -24,7 +26,7 @@ func NewRadioButtons() *RadioButtons {
r.r = C.uiNewRadioButtons()
C.uiRadioButtonsOnSelected(r.r, C.doRadioButtonsOnSelected, nil)
C.uiRadioButtonsOnSelected(r.r, C.radioButtonsCallback(C.doRadioButtonsOnSelected), nil)
r.ControlBase = NewControlBase(r, uintptr(unsafe.Pointer(r.r)))
return r

View File

@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern void doSliderOnChanged(uiSlider *, void *);
// // see golang/go#19835
// typedef void (*sliderCallback)(uiSlider *, void *);
import "C"
// Slider is a Control that represents a horizontal bar that represents
@ -25,7 +27,7 @@ func NewSlider(min int, max int) *Slider {
s.s = C.uiNewSlider(C.int(min), C.int(max))
C.uiSliderOnChanged(s.s, C.doSliderOnChanged, nil)
C.uiSliderOnChanged(s.s, C.sliderCallback(C.doSliderOnChanged), nil)
s.ControlBase = NewControlBase(s, uintptr(unsafe.Pointer(s.s)))
return s

View File

@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern void doSpinboxOnChanged(uiSpinbox *, void *);
// // see golang/go#19835
// typedef void (*spinboxCallback)(uiSpinbox *, void *);
import "C"
// Spinbox is a Control that represents a space where the user can
@ -25,7 +27,7 @@ func NewSpinbox(min int, max int) *Spinbox {
s.s = C.uiNewSpinbox(C.int(min), C.int(max))
C.uiSpinboxOnChanged(s.s, C.doSpinboxOnChanged, nil)
C.uiSpinboxOnChanged(s.s, C.spinboxCallback(C.doSpinboxOnChanged), nil)
s.ControlBase = NewControlBase(s, uintptr(unsafe.Pointer(s.s)))
return s

View File

@ -8,6 +8,8 @@ import (
// #include "ui.h"
// extern int doWindowOnClosing(uiWindow *, void *);
// // see golang/go#19835
// typedef int (*windowOnClosingCallback)(uiWindow *, void *);
import "C"
// Window is a Control that represents a top-level window.
@ -29,7 +31,7 @@ func NewWindow(title string, width int, height int, hasMenubar bool) *Window {
w.w = C.uiNewWindow(ctitle, C.int(width), C.int(height), frombool(hasMenubar))
freestr(ctitle)
C.uiWindowOnClosing(w.w, C.doWindowOnClosing, nil)
C.uiWindowOnClosing(w.w, C.windowOnClosingCallback(C.doWindowOnClosing), nil)
w.ControlBase = NewControlBase(w, uintptr(unsafe.Pointer(w.w)))
return w