Migrated window.go, box.go, button.go, and checkbox.go back.
This commit is contained in:
parent
809662459d
commit
2bc7621928
|
@ -6,7 +6,7 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
// #include "ui.h"
|
||||
// #include "pkgui.h"
|
||||
import "C"
|
||||
|
||||
// Box is a Control that holds a group of Controls horizontally
|
|
@ -6,10 +6,7 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
// #include "ui.h"
|
||||
// extern void doButtonOnClicked(uiButton *, void *);
|
||||
// // see golang/go#19835
|
||||
// typedef void (*buttonCallback)(uiButton *, void *);
|
||||
// #include "pkgui.h"
|
||||
import "C"
|
||||
|
||||
// Button is a Control that represents a button that the user can
|
||||
|
@ -29,7 +26,7 @@ func NewButton(text string) *Button {
|
|||
b.b = C.uiNewButton(ctext)
|
||||
freestr(ctext)
|
||||
|
||||
C.uiButtonOnClicked(b.b, C.buttonCallback(C.doButtonOnClicked), nil)
|
||||
C.pkguiButtonOnClicked(b.b)
|
||||
|
||||
b.ControlBase = NewControlBase(b, uintptr(unsafe.Pointer(b.b)))
|
||||
return b
|
||||
|
@ -56,8 +53,8 @@ func (b *Button) OnClicked(f func(*Button)) {
|
|||
b.onClicked = f
|
||||
}
|
||||
|
||||
//export doButtonOnClicked
|
||||
func doButtonOnClicked(bb *C.uiButton, data unsafe.Pointer) {
|
||||
//export pkguiDoButtonOnClicked
|
||||
func pkguiDoButtonOnClicked(bb *C.uiButton, data unsafe.Pointer) {
|
||||
b := ControlFromLibui(uintptr(unsafe.Pointer(bb))).(*Button)
|
||||
if b.onClicked != nil {
|
||||
b.onClicked(b)
|
|
@ -6,10 +6,7 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
// #include "ui.h"
|
||||
// extern void doCheckboxOnToggled(uiCheckbox *, void *);
|
||||
// // see golang/go#19835
|
||||
// typedef void (*checkboxCallback)(uiCheckbox *, void *);
|
||||
// #include "pkgui.h"
|
||||
import "C"
|
||||
|
||||
// Checkbox is a Control that represents a box with a text label at its
|
||||
|
@ -30,7 +27,7 @@ func NewCheckbox(text string) *Checkbox {
|
|||
c.c = C.uiNewCheckbox(ctext)
|
||||
freestr(ctext)
|
||||
|
||||
C.uiCheckboxOnToggled(c.c, C.checkboxCallback(C.doCheckboxOnToggled), nil)
|
||||
C.pkguiCheckboxOnToggled(c.c)
|
||||
|
||||
c.ControlBase = NewControlBase(c, uintptr(unsafe.Pointer(c.c)))
|
||||
return c
|
||||
|
@ -57,8 +54,8 @@ func (c *Checkbox) OnToggled(f func(*Checkbox)) {
|
|||
c.onToggled = f
|
||||
}
|
||||
|
||||
//export doCheckboxOnToggled
|
||||
func doCheckboxOnToggled(cc *C.uiCheckbox, data unsafe.Pointer) {
|
||||
//export pkguiDoCheckboxOnToggled
|
||||
func pkguiDoCheckboxOnToggled(cc *C.uiCheckbox, data unsafe.Pointer) {
|
||||
c := ControlFromLibui(uintptr(unsafe.Pointer(cc))).(*Checkbox)
|
||||
if c.onToggled != nil {
|
||||
c.onToggled(c)
|
15
pkgui.c
15
pkgui.c
|
@ -21,3 +21,18 @@ void pkguiOnShouldQuit(void)
|
|||
{
|
||||
uiOnShouldQuit(pkguiDoOnShouldQuit, NULL);
|
||||
}
|
||||
|
||||
void pkguiWindowOnClosing(uiWindow *w)
|
||||
{
|
||||
uiWindowOnClosing(w, pkguiDoWindowOnClosing, NULL);
|
||||
}
|
||||
|
||||
void pkguiButtonOnClicked(uiButton *b)
|
||||
{
|
||||
uiButtonOnClicked(b, pkguiDoButtonOnClicked, NULL);
|
||||
}
|
||||
|
||||
void pkguiCheckboxOnToggled(uiCheckbox *c)
|
||||
{
|
||||
uiCheckboxOnToggled(c, pkguiDoCheckboxOnToggled, NULL);
|
||||
}
|
||||
|
|
9
pkgui.h
9
pkgui.h
|
@ -7,3 +7,12 @@ extern uiInitOptions *pkguiAllocInitOptions(void);
|
|||
extern void pkguiFreeInitOptions(uiInitOptions *o);
|
||||
extern void pkguiQueueMain(uintptr_t n);
|
||||
extern void pkguiOnShouldQuit(void);
|
||||
|
||||
// window.go
|
||||
extern void pkguiWindowOnClosing(uiWindow *w);
|
||||
|
||||
// button.go
|
||||
extern void pkguiButtonOnClicked(uiButton *b);
|
||||
|
||||
// checkbox.go
|
||||
extern void pkguiCheckboxOnToggled(uiCheckbox *c);
|
||||
|
|
|
@ -6,10 +6,7 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
// #include "ui.h"
|
||||
// extern int doWindowOnClosing(uiWindow *, void *);
|
||||
// // see golang/go#19835
|
||||
// typedef int (*windowOnClosingCallback)(uiWindow *, void *);
|
||||
// #include "pkgui.h"
|
||||
import "C"
|
||||
|
||||
// Window is a Control that represents a top-level window.
|
||||
|
@ -31,7 +28,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.windowOnClosingCallback(C.doWindowOnClosing), nil)
|
||||
C.pkguiWindowOnClosing(w.w)
|
||||
|
||||
w.ControlBase = NewControlBase(w, uintptr(unsafe.Pointer(w.w)))
|
||||
return w
|
||||
|
@ -79,8 +76,8 @@ func (w *Window) OnClosing(f func(*Window) bool) {
|
|||
w.onClosing = f
|
||||
}
|
||||
|
||||
//export doWindowOnClosing
|
||||
func doWindowOnClosing(ww *C.uiWindow, data unsafe.Pointer) C.int {
|
||||
//export pkguiDoWindowOnClosing
|
||||
func pkguiDoWindowOnClosing(ww *C.uiWindow, data unsafe.Pointer) C.int {
|
||||
w := ControlFromLibui(uintptr(unsafe.Pointer(ww))).(*Window)
|
||||
if w.onClosing == nil {
|
||||
return 0
|
Loading…
Reference in New Issue