// NewWindow creates a new window and assigns it to a widget. func newWindow(w sparta.Widget) { var win *window rect := w.Property(sparta.Geometry).(image.Rectangle) if p := w.Property(sparta.Parent); p != nil { pW := p.(sparta.Widget) pWin := pW.Window().(*window) win = &window{ w: w, back: pWin.back, fore: pWin.fore, pos: rect.Min, } count := len(pW.Property(sparta.Childs).([]sparta.Widget)) pW.SetProperty(sparta.Childs, w) win.id = w32.CreateWindowEx(0, stringToUTF16(childClass), nil, uint(w32.WS_CHILDWINDOW|w32.WS_VISIBLE), rect.Min.X, rect.Min.Y, rect.Dx(), rect.Dy(), pWin.id, w32.HMENU(count), w32.HINSTANCE(w32.GetWindowLong(pWin.id, w32.GWL_HINSTANCE)), nil) if win.id == 0 { log.Printf("w32: error: %v\n", getLastError()) os.Exit(1) } } else { win = &window{ w: w, back: bkGround, fore: frGround, } win.id = w32.CreateWindowEx(uint(w32.WS_EX_CLIENTEDGE), stringToUTF16(baseClass), stringToUTF16(""), uint(w32.WS_OVERLAPPEDWINDOW), 150, 150, rect.Dx()+extraX, rect.Dy()+extraY, 0, 0, instance, nil) if win.id == 0 { log.Printf("w32: error: %v\n", getLastError()) os.Exit(1) } } widgetTable[win.id] = w w.SetWindow(win) w32.ShowWindow(win.id, w32.SW_SHOWDEFAULT) if !w32.UpdateWindow(win.id) { log.Printf("w32: error: %v\n", getLastError()) os.Exit(1) } }
// NewWindow creates a new window and assigns it to a widget. func newWindow(w sparta.Widget) { s := xwin.DefaultScreen() pId := s.Root win := &window{ id: xwin.NewId(), w: w, gc: xwin.NewId(), back: s.WhitePixel, fore: s.BlackPixel, } if p := w.Property(sparta.Parent); p != nil { pw := p.(sparta.Widget) pWin := pw.Window().(*window) win.back = pWin.back win.fore = pWin.fore pId = pWin.id pw.SetProperty(sparta.Childs, w) } widgetTable[win.id] = w w.SetWindow(win) r := w.Property(sparta.Geometry).(image.Rectangle) xwin.CreateWindow(0, win.id, pId, int16(r.Min.X), int16(r.Min.Y), uint16(r.Dx()), uint16(r.Dy()), 0, xgb.WindowClassInputOutput, s.RootVisual, 0, nil) xwin.ChangeWindowAttributes(win.id, xgb.CWBackPixel|xgb.CWEventMask, []uint32{ win.back, allEventMask, }) font := xwin.NewId() xwin.OpenFont(font, fixed) xwin.CreateGC(win.gc, win.id, xgb.GCBackground|xgb.GCForeground|xgb.GCFont, []uint32{ win.fore, win.back, uint32(font), }) xwin.CloseFont(font) xwin.MapWindow(win.id) xwin.ChangeProperty(xgb.PropModeReplace, win.id, wmProtocols, atomType, 32, wmDelete) }