From 62ac2527732a01dfa6bd2c9523215c0ba3816641 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 26 Aug 2018 09:55:07 -0400 Subject: Moved all the Go files out of the way again, this time so we can migrate them to more proper cgo usage. --- radiobuttons.go | 66 --------------------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 radiobuttons.go (limited to 'radiobuttons.go') diff --git a/radiobuttons.go b/radiobuttons.go deleted file mode 100644 index 2413544..0000000 --- a/radiobuttons.go +++ /dev/null @@ -1,66 +0,0 @@ -// 12 december 2015 - -package ui - -import ( - "unsafe" -) - -// #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 -// buttons from which exactly one may be chosen by the user. -type RadioButtons struct { - ControlBase - r *C.uiRadioButtons - onSelected func(*RadioButtons) -} - -// NewRadioButtons creates a new RadioButtons. -func NewRadioButtons() *RadioButtons { - r := new(RadioButtons) - - r.r = C.uiNewRadioButtons() - - C.uiRadioButtonsOnSelected(r.r, C.radioButtonsCallback(C.doRadioButtonsOnSelected), nil) - - r.ControlBase = NewControlBase(r, uintptr(unsafe.Pointer(r.r))) - return r -} - -// Append adds the named button to the end of the RadioButtons. -func (r *RadioButtons) Append(text string) { - ctext := C.CString(text) - C.uiRadioButtonsAppend(r.r, ctext) - freestr(ctext) -} - -// Selected returns the index of the currently selected option in the -// RadioButtons, or -1 if no item is selected. -func (r *RadioButtons) Selected() int { - return int(C.uiRadioButtonsSelected(r.r)) -} - -// SetSelected sets the currently selected option in the RadioButtons -// to index. -func (r *RadioButtons) SetSelected(index int) { - C.uiRadioButtonsSetSelected(r.r, C.int(index)) -} - -// OnSelected registers f to be run when the user selects an option in -// the RadioButtons. Only one function can be registered at a time. -func (r *RadioButtons) OnSelected(f func(*RadioButtons)) { - r.onSelected = f -} - -//export doRadioButtonsOnSelected -func doRadioButtonsOnSelected(rr *C.uiRadioButtons, data unsafe.Pointer) { - r := ControlFromLibui(uintptr(unsafe.Pointer(rr))).(*RadioButtons) - if r.onSelected != nil { - r.onSelected(r) - } -} -- cgit v1.2.3