summaryrefslogtreecommitdiff
path: root/fontbutton.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2018-08-26 09:55:07 -0400
committerPietro Gagliardi <[email protected]>2018-08-26 09:55:07 -0400
commit62ac2527732a01dfa6bd2c9523215c0ba3816641 (patch)
tree84244a69e048f79e4d9f134c121f4cf581200986 /fontbutton.go
parenta5a00c644c08a6e0f52740c3f2a280977929a285 (diff)
Moved all the Go files out of the way again, this time so we can migrate them to more proper cgo usage.
Diffstat (limited to 'fontbutton.go')
-rw-r--r--fontbutton.go69
1 files changed, 0 insertions, 69 deletions
diff --git a/fontbutton.go b/fontbutton.go
deleted file mode 100644
index c228151..0000000
--- a/fontbutton.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// 12 december 2015
-
-package ui
-
-import (
- "unsafe"
-)
-
-// #include <stdlib.h>
-// #include "ui.h"
-// #include "util.h"
-// extern void doFontButtonOnChanged(uiFontButton *, void *);
-// // see golang/go#19835
-// typedef void (*fontButtonCallback)(uiFontButton *, void *);
-// static inline uiFontDescriptor *pkguiNewFontDescriptor(void)
-// {
-// return (uiFontDescriptor *) pkguiAlloc(sizeof (uiFontDescriptor));
-// }
-// static inline void pkguiFreeFontDescriptor(uiFontDescriptor *fd)
-// {
-// free(fd);
-// }
-import "C"
-
-// FontButton is a Control that represents a button that the user can
-// click to select a font.
-type FontButton struct {
- ControlBase
- b *C.uiFontButton
- onChanged func(*FontButton)
-}
-
-// NewFontButton creates a new FontButton.
-func NewFontButton() *FontButton {
- b := new(FontButton)
-
- b.b = C.uiNewFontButton()
-
- C.uiFontButtonOnChanged(b.b, C.fontButtonCallback(C.doFontButtonOnChanged), nil)
-
- b.ControlBase = NewControlBase(b, uintptr(unsafe.Pointer(b.b)))
- return b
-}
-
-// Font returns the font currently selected in the FontButton.
-func (b *FontButton) Font() *FontDescriptor {
- cfd := C.pkguiNewFontDescriptor()
- defer C.pkguiFreeFontDescriptor(cfd)
- C.uiFontButtonFont(b.b, cfd)
- defer C.uiFreeFontButtonFont(cfd)
- fd := &FontDescriptor{}
- fd.fromLibui(cfd)
- return fd
-}
-
-// OnChanged registers f to be run when the user changes the
-// currently selected font in the FontButton. Only one function can
-// be registered at a time.
-func (b *FontButton) OnChanged(f func(*FontButton)) {
- b.onChanged = f
-}
-
-//export doFontButtonOnChanged
-func doFontButtonOnChanged(bb *C.uiFontButton, data unsafe.Pointer) {
- b := ControlFromLibui(uintptr(unsafe.Pointer(bb))).(*FontButton)
- if b.onChanged != nil {
- b.onChanged(b)
- }
-}