2014-07-12 10:29:54 -05:00
|
|
|
// 12 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"syscall"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2014-08-14 09:26:09 -05:00
|
|
|
// #cgo CFLAGS: --std=c99
|
2014-08-18 18:01:56 -05:00
|
|
|
// #cgo LDFLAGS: -luser32 -lkernel32 -lgdi32 -luxtheme -lmsimg32 -lcomdlg32
|
2014-07-17 18:36:24 -05:00
|
|
|
// #include "winapi_windows.h"
|
|
|
|
import "C"
|
2014-07-12 10:29:54 -05:00
|
|
|
|
2014-07-17 18:36:24 -05:00
|
|
|
var msgwin C.HWND
|
2014-07-12 10:29:54 -05:00
|
|
|
|
|
|
|
func uiinit() error {
|
2014-07-17 21:33:03 -05:00
|
|
|
var errmsg *C.char
|
|
|
|
|
|
|
|
errcode := C.initWindows(&errmsg)
|
|
|
|
if errcode != 0 || errmsg != nil {
|
|
|
|
return fmt.Errorf("error initializing package ui on Windows: %s: %v", C.GoString(errmsg), syscall.Errno(errcode))
|
2014-07-12 10:29:54 -05:00
|
|
|
}
|
2014-08-12 11:05:23 -05:00
|
|
|
errmsg = nil
|
|
|
|
errcode = C.initCommonControls(&errmsg)
|
|
|
|
if errcode != 0 || errmsg != nil {
|
|
|
|
return fmt.Errorf("error initializing comctl32.dll: %s: %v", C.GoString(errmsg), syscall.Errno(errcode))
|
2014-07-17 17:04:51 -05:00
|
|
|
}
|
2014-07-12 10:29:54 -05:00
|
|
|
if err := makemsgwin(); err != nil {
|
|
|
|
return fmt.Errorf("error creating message-only window: %v", err)
|
|
|
|
}
|
|
|
|
if err := makeWindowWindowClass(); err != nil {
|
|
|
|
return fmt.Errorf("error creating Window window class: %v", err)
|
|
|
|
}
|
2014-08-05 11:29:37 -05:00
|
|
|
if err := makeAreaWindowClass(); err != nil {
|
|
|
|
return fmt.Errorf("error creating Area window class: %v", err)
|
|
|
|
}
|
2014-07-12 10:29:54 -05:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func uimsgloop() {
|
2014-07-17 18:36:24 -05:00
|
|
|
C.uimsgloop()
|
2014-07-12 10:29:54 -05:00
|
|
|
}
|
|
|
|
|
2014-07-13 00:14:55 -05:00
|
|
|
func uistop() {
|
2014-07-17 23:22:21 -05:00
|
|
|
C.PostQuitMessage(0)
|
2014-07-13 00:14:55 -05:00
|
|
|
}
|
|
|
|
|
2014-08-11 20:57:20 -05:00
|
|
|
func issue(f *func()) {
|
|
|
|
C.issue(unsafe.Pointer(f))
|
2014-07-12 10:29:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func makemsgwin() error {
|
2014-07-17 18:36:24 -05:00
|
|
|
var errmsg *C.char
|
2014-07-12 10:29:54 -05:00
|
|
|
|
2014-07-17 18:36:24 -05:00
|
|
|
err := C.makemsgwin(&errmsg)
|
|
|
|
if err != 0 || errmsg != nil {
|
|
|
|
return fmt.Errorf("%s: %v", C.GoString(errmsg), syscall.Errno(err))
|
2014-07-12 10:29:54 -05:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2014-07-19 08:57:01 -05:00
|
|
|
//export doissue
|
|
|
|
func doissue(fp unsafe.Pointer) {
|
|
|
|
perform(fp)
|
2014-07-12 10:29:54 -05:00
|
|
|
}
|