Exemplo n.º 1
0
Arquivo: window.go Projeto: 4ydx/gxui
func (w *Window) Init(outer WindowOuter, driver gxui.Driver, width, height int, title string) {
	w.Attachable.Init(outer)
	w.BackgroundBorderPainter.Init(outer)
	w.Container.Init(outer)
	w.Paddable.Init(outer)
	w.PaintChildren.Init(outer)
	w.outer = outer
	w.driver = driver

	w.onClose = gxui.CreateEvent(func() {})
	w.onResize = gxui.CreateEvent(func() {})
	w.onMouseMove = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onMouseEnter = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onMouseExit = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onMouseDown = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onMouseUp = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onMouseScroll = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onKeyDown = gxui.CreateEvent(func(gxui.KeyboardEvent) {})
	w.onKeyUp = gxui.CreateEvent(func(gxui.KeyboardEvent) {})
	w.onKeyRepeat = gxui.CreateEvent(func(gxui.KeyboardEvent) {})
	w.onKeyStroke = gxui.CreateEvent(func(gxui.KeyStrokeEvent) {})

	w.onClick = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onDoubleClick = gxui.CreateEvent(func(gxui.MouseEvent) {})

	w.focusController = gxui.CreateFocusController(outer)
	w.mouseController = gxui.CreateMouseController(outer, w.focusController)
	w.keyboardController = gxui.CreateKeyboardController(outer)

	w.onResize.Listen(func() {
		w.outer.LayoutChildren()
		w.Draw()
	})

	w.SetBorderPen(gxui.TransparentPen)

	w.setViewport(driver.CreateWindowedViewport(width, height, title))

	// Window starts shown
	w.Attach()

	// Interface compliance test
	_ = gxui.Window(w)
}