Exemple #1
0
func newWindow(title string, width int, height int, control Control) *window {
	w := &window{
		closing: newEvent(),
		child:   control,
	}
	w.hwnd = C.newWindow(toUTF16(title), C.int(width), C.int(height), unsafe.Pointer(w))
	hresult := C.EnableThemeDialogTexture(w.hwnd, C.ETDT_ENABLE|C.ETDT_USETABTEXTURE)
	if hresult != C.S_OK {
		panic(fmt.Errorf("error setting tab background texture on Window; HRESULT: 0x%X", hresult))
	}
	w.child.setParent(&controlParent{w.hwnd})
	return w
}
Exemple #2
0
func newWindow(title string, width int, height int, control Control) *window {
	id := C.newWindow(C.intptr_t(width), C.intptr_t(height))
	ctitle := C.CString(title)
	defer C.free(unsafe.Pointer(ctitle))
	C.windowSetTitle(id, ctitle)
	w := &window{
		id:        id,
		closing:   newEvent(),
		container: newContainer(control),
	}
	C.windowSetDelegate(w.id, unsafe.Pointer(w))
	C.windowSetContentView(w.id, w.container.id)
	return w
}
Exemple #3
0
func newWindow(title string, width int, height int, control Control) *window {
	id := C.newWindow(C.intptr_t(width), C.intptr_t(height))
	ctitle := C.CString(title)
	defer C.free(unsafe.Pointer(ctitle))
	C.windowSetTitle(id, ctitle)
	w := &window{
		id:      id,
		closing: newEvent(),
		child:   control,
	}
	C.windowSetDelegate(w.id, unsafe.Pointer(w))
	w.container = newContainer(w.child.resize)
	w.child.setParent(w.container.parent())
	C.windowSetContentView(w.id, w.container.id)
	// trigger an initial resize
	return w
}
Exemple #4
0
func newWindow(title string, width int, height int, control Control) *window {
	w := &window{
		// hwnd set in WM_CREATE handler
		closing:   newEvent(),
		container: newContainer(control),
	}
	hwnd := C.newWindow(toUTF16(title), C.int(width), C.int(height), unsafe.Pointer(w))
	if hwnd != w.hwnd {
		panic(fmt.Errorf("inconsistency: hwnd returned by CreateWindowEx() (%p) and hwnd stored in Window (%p) differ", hwnd, w.hwnd))
	}
	hresult := C.EnableThemeDialogTexture(w.hwnd, C.ETDT_ENABLE|C.ETDT_USETABTEXTURE)
	if hresult != C.S_OK {
		panic(fmt.Errorf("error setting tab background texture on Window; HRESULT: 0x%X", hresult))
	}
	w.container.setParent(w.hwnd)
	return w
}
Exemple #5
0
// NewWindow returns new widow.
func NewWindow(width, height int, title string, bgColor util.Color, timePeriod int) *Window {
	timeBarHeight := 20
	return &Window{
		w: C.newWindow(C.int(width),
			C.int(height),
			C.int(timeBarHeight),
			C.CString(title),
			C.double(bgColor.R),
			C.double(bgColor.G),
			C.double(bgColor.B)),
		width:         width,
		height:        height,
		title:         title,
		bgColor:       bgColor,
		timePeriod:    timePeriod,
		shiftPx:       1,
		TimeBarHeight: timeBarHeight,
	}
}
Exemple #6
0
func (s *screenImpl) NewWindow(opts *screen.NewWindowOptions) (screen.Window, error) {
	// TODO: look at opts.
	const width, height = 1024, 768

	id := C.newWindow(width, height)
	w := &windowImpl{
		s:        s,
		id:       uintptr(id),
		pump:     pump.Make(),
		endPaint: make(chan paint.Event, 1),
		draw:     make(chan struct{}),
		drawDone: make(chan struct{}),
	}

	s.mu.Lock()
	s.windows[uintptr(id)] = w
	s.mu.Unlock()

	go w.drawLoop(uintptr(C.showWindow(id)))

	return w, nil
}
Exemple #7
0
func NewWindow() *Window {
	w := C.newWindow()
	return &Window{w, nil}
}