From 1095719d84a6ac5f90eefe8e23913f3e09ad692d Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 26 Aug 2018 13:33:54 -0400 Subject: [PATCH] Migrated more controls. --- BBB_GOFILES/combobox.go => combobox.go | 11 ++++------- .../editablecombobox.go => editablecombobox.go | 11 ++++------- BBB_GOFILES/entry.go => entry.go | 11 ++++------- BBB_GOFILES/form.go => form.go | 2 +- BBB_GOFILES/grid.go => grid.go | 2 +- BBB_GOFILES/group.go => group.go | 2 +- BBB_GOFILES/label.go => label.go | 2 +- pkgui.c | 15 +++++++++++++++ pkgui.h | 14 ++++++++++++++ BBB_GOFILES/progressbar.go => progressbar.go | 2 +- 10 files changed, 46 insertions(+), 26 deletions(-) rename BBB_GOFILES/combobox.go => combobox.go (80%) rename BBB_GOFILES/editablecombobox.go => editablecombobox.go (80%) rename BBB_GOFILES/entry.go => entry.go (86%) rename BBB_GOFILES/form.go => form.go (98%) rename BBB_GOFILES/grid.go => grid.go (99%) rename BBB_GOFILES/group.go => group.go (98%) rename BBB_GOFILES/label.go => label.go (97%) rename BBB_GOFILES/progressbar.go => progressbar.go (97%) diff --git a/BBB_GOFILES/combobox.go b/combobox.go similarity index 80% rename from BBB_GOFILES/combobox.go rename to combobox.go index 1e381de..60df08a 100644 --- a/BBB_GOFILES/combobox.go +++ b/combobox.go @@ -6,10 +6,7 @@ import ( "unsafe" ) -// #include "ui.h" -// extern void doComboboxOnSelected(uiCombobox *, void *); -// // see golang/go#19835 -// typedef void (*comboboxCallback)(uiCombobox *, void *); +// #include "pkgui.h" import "C" // Combobox is a Control that represents a drop-down list of strings @@ -27,7 +24,7 @@ func NewCombobox() *Combobox { c.c = C.uiNewCombobox() - C.uiComboboxOnSelected(c.c, C.comboboxCallback(C.doComboboxOnSelected), nil) + C.pkguiComboboxOnSelected(c.c) c.ControlBase = NewControlBase(c, uintptr(unsafe.Pointer(c.c))) return c @@ -58,8 +55,8 @@ func (c *Combobox) OnSelected(f func(*Combobox)) { c.onSelected = f } -//export doComboboxOnSelected -func doComboboxOnSelected(cc *C.uiCombobox, data unsafe.Pointer) { +//export pkguiDoComboboxOnSelected +func pkguiDoComboboxOnSelected(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/editablecombobox.go similarity index 80% rename from BBB_GOFILES/editablecombobox.go rename to editablecombobox.go index 1242928..9c0d9d0 100644 --- a/BBB_GOFILES/editablecombobox.go +++ b/editablecombobox.go @@ -6,10 +6,7 @@ import ( "unsafe" ) -// #include "ui.h" -// extern void doEditableComboboxOnChanged(uiEditableCombobox *, void *); -// // see golang/go#19835 -// typedef void (*editableComboboxCallback)(uiEditableCombobox *, void *); +// #include "pkgui.h" import "C" // EditableCombobox is a Control that represents a drop-down list @@ -27,7 +24,7 @@ func NewEditableCombobox() *EditableCombobox { c.c = C.uiNewEditableCombobox() - C.uiEditableComboboxOnChanged(c.c, C.editableComboboxCallback(C.doEditableComboboxOnChanged), nil) + C.pkguiEditableComboboxOnChanged(c.c) c.ControlBase = NewControlBase(c, uintptr(unsafe.Pointer(c.c))) return c @@ -63,8 +60,8 @@ func (e *EditableCombobox) OnChanged(f func(*EditableCombobox)) { e.onChanged = f } -//export doEditableComboboxOnChanged -func doEditableComboboxOnChanged(cc *C.uiEditableCombobox, data unsafe.Pointer) { +//export pkguiDoEditableComboboxOnChanged +func pkguiDoEditableComboboxOnChanged(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/entry.go similarity index 86% rename from BBB_GOFILES/entry.go rename to entry.go index 52da537..00c7dd7 100644 --- a/BBB_GOFILES/entry.go +++ b/entry.go @@ -10,10 +10,7 @@ import ( "unsafe" ) -// #include "ui.h" -// extern void doEntryOnChanged(uiEntry *, void *); -// // see golang/go#19835 -// typedef void (*entryCallback)(uiEntry *, void *); +// #include "pkgui.h" import "C" // Entry is a Control that represents a space that the user can @@ -29,7 +26,7 @@ func finishNewEntry(ee *C.uiEntry) *Entry { e.e = ee - C.uiEntryOnChanged(e.e, C.entryCallback(C.doEntryOnChanged), nil) + C.pkguiEntryOnChanged(e.e) e.ControlBase = NewControlBase(e, uintptr(unsafe.Pointer(e.e))) return e @@ -74,8 +71,8 @@ func (e *Entry) OnChanged(f func(*Entry)) { e.onChanged = f } -//export doEntryOnChanged -func doEntryOnChanged(ee *C.uiEntry, data unsafe.Pointer) { +//export pkguiDoEntryOnChanged +func pkguiDoEntryOnChanged(ee *C.uiEntry, data unsafe.Pointer) { e := ControlFromLibui(uintptr(unsafe.Pointer(ee))).(*Entry) if e.onChanged != nil { e.onChanged(e) diff --git a/BBB_GOFILES/form.go b/form.go similarity index 98% rename from BBB_GOFILES/form.go rename to form.go index 6f8a282..aef7597 100644 --- a/BBB_GOFILES/form.go +++ b/form.go @@ -6,7 +6,7 @@ import ( "unsafe" ) -// #include "ui.h" +// #include "pkgui.h" import "C" // Form is a Control that holds a group of Controls vertically diff --git a/BBB_GOFILES/grid.go b/grid.go similarity index 99% rename from BBB_GOFILES/grid.go rename to grid.go index a1985fc..7a027a8 100644 --- a/BBB_GOFILES/grid.go +++ b/grid.go @@ -6,7 +6,7 @@ import ( "unsafe" ) -// #include "ui.h" +// #include "pkgui.h" import "C" // Grid is a Control that arranges other Controls in a grid. diff --git a/BBB_GOFILES/group.go b/group.go similarity index 98% rename from BBB_GOFILES/group.go rename to group.go index 6992948..4aaa24a 100644 --- a/BBB_GOFILES/group.go +++ b/group.go @@ -6,7 +6,7 @@ import ( "unsafe" ) -// #include "ui.h" +// #include "pkgui.h" import "C" // Group is a Control that holds another Control and wraps it around diff --git a/BBB_GOFILES/label.go b/label.go similarity index 97% rename from BBB_GOFILES/label.go rename to label.go index cac7680..09d0b3c 100644 --- a/BBB_GOFILES/label.go +++ b/label.go @@ -6,7 +6,7 @@ import ( "unsafe" ) -// #include "ui.h" +// #include "pkgui.h" import "C" // Label is a Control that represents a line of text that cannot be diff --git a/pkgui.c b/pkgui.c index b6871a3..643f50e 100644 --- a/pkgui.c +++ b/pkgui.c @@ -36,3 +36,18 @@ void pkguiCheckboxOnToggled(uiCheckbox *c) { uiCheckboxOnToggled(c, pkguiDoCheckboxOnToggled, NULL); } + +void pkguiComboboxOnSelected(uiCombobox *c) +{ + uiComboboxOnSelected(c, pkguiDoComboboxOnSelected, NULL); +} + +void pkguiEditableComboboxOnChanged(uiEditableCombobox *c) +{ + uiEditableComboboxOnChanged(c, pkguiDoEditableComboboxOnChanged, NULL); +} + +void pkguiEntryOnChanged(uiEntry *e) +{ + uiEntryOnChanged(e, pkguiDoEntryOnChanged, NULL); +} diff --git a/pkgui.h b/pkgui.h index 6a0261b..eefea53 100644 --- a/pkgui.h +++ b/pkgui.h @@ -1,4 +1,7 @@ // 12 august 2018 +#ifndef pkguiHFileIncluded +#define pkguiHFileIncluded + #include #include "ui.h" @@ -16,3 +19,14 @@ extern void pkguiButtonOnClicked(uiButton *b); // checkbox.go extern void pkguiCheckboxOnToggled(uiCheckbox *c); + +// combobox.go +extern void pkguiComboboxOnSelected(uiCombobox *c); + +// editablecombobox.go +extern void pkguiEditableComboboxOnChanged(uiEditableCombobox *c); + +// entry.go +extern void pkguiEntryOnChanged(uiEntry *e); + +#endif diff --git a/BBB_GOFILES/progressbar.go b/progressbar.go similarity index 97% rename from BBB_GOFILES/progressbar.go rename to progressbar.go index f58976f..4c771df 100644 --- a/BBB_GOFILES/progressbar.go +++ b/progressbar.go @@ -6,7 +6,7 @@ import ( "unsafe" ) -// #include "ui.h" +// #include "pkgui.h" import "C" // ProgressBar is a Control that represents a horizontal bar that