Beispiel #1
0
func CreateWindow(left, top, right, bottom int, isVisible bool, drawCallback DrawWindow, keyCallback HandleKey, mouseClickCallback HandleMouseClick, ref interface{}) WindowID {
	regInfo := &CreateWindowData{}
	regInfo.Left = left
	regInfo.Top = top
	regInfo.Right = right
	regInfo.Bottom = bottom
	regInfo.Visible = isVisible
	regInfo.DrawWindowFunc = drawCallback
	regInfo.HandleKeyFunc = keyCallback
	regInfo.HandleMouseClickFunc = mouseClickCallback
	regInfo.Ref = ref

	id := C.CString(goplane.IdGenerator())
	windows[id] = regInfo

	return WindowID(C.XPLMCreateWindow(
		C.int(left),
		C.int(top),
		C.int(right),
		C.int(bottom),
		C.int(goplane.FromBoolToInt(isVisible)),
		C.XPLMDrawWindow_f(unsafe.Pointer(C.drawWindowCallback)),
		C.XPLMHandleKey_f(unsafe.Pointer(C.windowHandleKey)),
		C.XPLMHandleMouseClick_f(unsafe.Pointer(C.windowHandleMouseClick)),
		unsafe.Pointer(id)))
}
Beispiel #2
0
func CreateWindowEx(params *CreateWindowData) WindowID {
	id := C.CString(goplane.IdGenerator())
	windows[id] = params
	cCreateWindowData := C.XPLMCreateWindow_t{}
	cCreateWindowData.structSize = C.int(unsafe.Sizeof(cCreateWindowData))
	cCreateWindowData.left = C.int(params.Left)
	cCreateWindowData.top = C.int(params.Top)
	cCreateWindowData.right = C.int(params.Right)
	cCreateWindowData.bottom = C.int(params.Bottom)
	cCreateWindowData.visible = C.int(goplane.FromBoolToInt(params.Visible))
	cCreateWindowData.drawWindowFunc = C.XPLMDrawWindow_f(unsafe.Pointer(C.drawWindowCallback))
	cCreateWindowData.handleMouseClickFunc = C.XPLMHandleMouseClick_f(unsafe.Pointer(C.windowHandleMouseClick))
	cCreateWindowData.handleKeyFunc = C.XPLMHandleKey_f(unsafe.Pointer(C.windowHandleKey))
	cCreateWindowData.handleCursorFunc = C.XPLMHandleCursor_f(unsafe.Pointer(C.windowHandleCursorStatus))
	cCreateWindowData.handleMouseWheelFunc = C.XPLMHandleMouseWheel_f(unsafe.Pointer(C.windowHandleMouseWheel))
	cCreateWindowData.refcon = unsafe.Pointer(id)
	return WindowID(C.XPLMCreateWindowEx((*C.XPLMCreateWindow_t)(unsafe.Pointer(&cCreateWindowData))))
}