Migrated more controls.

This commit is contained in:
Pietro Gagliardi 2018-08-26 13:33:54 -04:00
parent 2bc7621928
commit 1095719d84
10 changed files with 46 additions and 26 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

15
pkgui.c
View File

@ -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);
}

14
pkgui.h
View File

@ -1,4 +1,7 @@
// 12 august 2018
#ifndef pkguiHFileIncluded
#define pkguiHFileIncluded
#include <stdlib.h>
#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

View File

@ -6,7 +6,7 @@ import (
"unsafe"
)
// #include "ui.h"
// #include "pkgui.h"
import "C"
// ProgressBar is a Control that represents a horizontal bar that