def InsertWnd(self, wnd, adjustlocation=1, show=0, hilite=0): self._inserting = True l, t, mywidth, myheight = self.GetAbsolute() if not len(self.GetWindows()) and adjustlocation: log.LogInfo('WindowStack initing, taking size from', wnd.windowID, wnd.left, 'l,t,w,h', wnd.top, wnd.width, wnd.height) self.width = wnd.width self.height = wnd.height self.left = wnd.left self.top = wnd.top if wnd.IsCollapsed(): wnd.Expand() uiutil.Transplant(wnd, self.sr.content) wnd.align = uiconst.TOALL wnd.startingup = True wnd.left = wnd.top = wnd.width = wnd.height = 0 wnd.startingup = False wnd.sr.stack = self wnd.state = uiconst.UI_HIDDEN wnd.sr.loadingIndicator.Stop() self.Check(0, show != 1) if show: self.ShowWnd(wnd, hilite) wnd.CloseHeaderButtons(destroy=True) wnd.RegisterStackID(self) self.CleanupParent('snapIndicator') self._inserting = False if self.IsMinimized(): self.Maximize()
def SetWndIcon(self, iconNum=None, headerIcon=0, size=64, fullPath=None, mainTop=-3, mainLeft=0, hidden=False, **kw): self.iconNum = iconNum or self.GetDefaultWndIcon() if hidden: return icon = self.sr.mainIcon if not icon: return if iconNum is None: icon.state = uiconst.UI_HIDDEN return icon.state = uiconst.UI_DISABLED icon.LoadIcon(iconNum or fullPath, ignoreSize=True) icon.top = mainTop icon.left = mainLeft if headerIcon: icon.width = icon.height = 16 icon.left = 4 icon.top = 0 uiutil.Transplant(icon, uiutil.GetChild(self, 'captionParent')) if self.sr.caption: self.sr.caption.left = 24 self.sr.headerIcon = icon
def Startup(self, *args): BaseTacticalEntry.Startup(self, *args) self.activityID = None self.activity = None text_gaugeContainer = uiprimitives.Container(name='text_gaugeContainer', parent=self, idx=0, pos=(0, 0, 0, 0)) self.sr.gaugesContainer = uiprimitives.Container(name='gaugesContainer', parent=text_gaugeContainer, width=85, align=uiconst.TORIGHT, state=uiconst.UI_HIDDEN) tClip = uiprimitives.Container(name='textClipper', parent=text_gaugeContainer, state=uiconst.UI_PICKCHILDREN, clipChildren=1) uiutil.Transplant(self.sr.label, tClip)
def Unload(self): browser = uiutil.GetBrowser(self) if browser and self.sr.inlines: for control in self.sr.inlines.children[:]: if not control: continue if self.destroyed: break control.state = uiconst.UI_HIDDEN uiutil.Transplant(control, browser.sr.cacheContainer) if hasattr(control, 'Unload') and control.loaded: control.Unload()
def LoadInlines(self): self.Unload() if not self.sr.node.scroll: return scrollwidth = self.sr.node.scroll.GetContentWidth() linewidth = self.sr.node.Get('lineWidth', 0) lineHeight = self.sr.node.Get('maxBaseHeight', 12) leftMargin = self.sr.node.Get('lpush', self.sr.node.scroll.xmargin) rightMargin = self.sr.node.Get('rpush', self.sr.node.scroll.xmargin) self.sr.inlines.left = max(0, self.leftM) for inline, x in self.sr.node.Get('inlines', []): control = getattr(inline, 'control', None) if control and not control.destroyed: uiutil.Transplant(control, self.sr.inlines) else: if not hasattr(uicls, 'SE_' + inline.attrs.type): continue decoClass = uicls.Get('SE_' + inline.attrs.type) control = self.sr.node.scroll.GetInline(uicls.ScrollEntryNode(decoClass=decoClass, attrs=inline.attrs)) if not self or self.destroyed: return uiutil.Transplant(control, self.sr.inlines) inline.control = control control.top = 0 if inline.valign == html.ALIGNMIDDLE: control.top = (self.height - inline.inlineHeight) / 2 elif inline.valign in (html.ALIGNBOTTOM, html.ALIGNSUB): control.top = self.height - inline.inlineHeight elif inline.valign == html.ALIGNBASELINE: control.top = self.sr.node.Get('maxBaseLine', 12) - inline.inlineHeight control.left = int(x) control.height = inline.inlineHeight control.width = inline.inlineWidth if hasattr(control, 'Load') and not control.loaded: control.Load() control.state = uiconst.UI_NORMAL
def RemoveWnd(self, wnd, grab, correctpos=1, idx=0, dragging=0, check=1): if wnd.parent != self.sr.content: return if hasattr(wnd, 'OnTabSelect'): uthread.worker('WindowStack::RemoveWnd', wnd.OnTabSelect) wnd._detaching = True uiutil.Transplant(wnd, self.parent, idx) if hasattr(wnd, '_stack_cacheContents'): wnd.cacheContents = wnd._stack_cacheContents self.RemovePreferredIdx(self.windowID, wnd.windowID) wnd.sr.stack = None wnd.sr.tab = None wnd.align = uiconst.RELATIVE wnd.state = uiconst.UI_NORMAL wnd.grab = grab wnd.dragMousePosition = (uicore.uilib.x, uicore.uilib.y) wnd.width = wnd._fixedWidth or self.width wnd.height = wnd._fixedHeight or self.height wnd.RefreshHeaderButtonsIfVisible() if dragging: uicore.uilib.SetMouseCapture(wnd) uthread.new(wnd._BeginDrag) if wnd.height < wnd.GetMinHeight(): wnd.height = wnd.GetMinHeight() if wnd.width < wnd.GetMinWidth(): wnd.width = wnd.GetMinWidth() wnd.ShowHeader() wnd.ShowBackground() if correctpos: wnd.left = uicore.uilib.x - grab[0] wnd.top = uicore.uilib.y - grab[1] if check: self.Check() wnd.RegisterStackID() wnd._detaching = False wnd._dragging = dragging myWindows = self.GetWindows() if len(myWindows) == 1 and not self.IsCollapsed(): w = myWindows[0] aL, aT, aW, aH = self.GetAbsolute() x, y = aL, aT self.RemoveWnd(w, (0, 0), 1, 1, check=0) self.RemovePreferredIdx(self.windowID, w) w.left, w.top = x, y return if len(self.GetWindows()) == 0: self.sr.tabs.Close() self.Close()
def IndicateStackable(self, wnd = None): if wnd is None: if self.sr.snapIndicator: self.sr.snapIndicator.Close() self.sr.snapIndicator = None return if not wnd.IsStackable() or not self.IsStackable(): return if self.sr.snapIndicator is None: self.sr.snapIndicator = uicls.Fill(parent=None, align=uiconst.TOTOP_NOPUSH, height=19) si = self.sr.snapIndicator si.state = uiconst.UI_DISABLED if si.parent != wnd: uiutil.Transplant(si, wnd, idx=0) else: uiutil.SetOrder(si, 0)
def ResetWindowSettings(self): closeStacks = [] triggerUpdate = [] for each in uicore.registry.GetWindows(): if not isinstance(each, uicls.WindowCore): continue if each.isDialog: continue if each.parent != uicore.layer.main: uiutil.Transplant(each, uicore.layer.main) if isinstance(each, uicls.WindowStackCore): closeStacks.append(each) else: triggerUpdate.append(each) each.sr.stack = None each.state = uiconst.UI_HIDDEN each.align = uiconst.TOPLEFT each.ShowHeader() each.ShowBackground() for each in closeStacks: each.Close() uicls.Window.ResetAllWindowSettings() favorClasses = [form.LSCChannel, form.ActiveItem, form.OverView, form.DroneView, form.WatchListPanel] done = [] for cls in favorClasses: for each in triggerUpdate: if each not in done and isinstance(each, cls): each.InitializeSize() each.InitializeStatesAndPosition() done.append(each) for each in triggerUpdate: if each not in done: each.InitializeSize() each.InitializeStatesAndPosition() settings.user.ui.Delete('targetOrigin') sm.GetService('target').ArrangeTargets()
def IndicateStackable(self, wnd=None): if wnd is None: if self.sr.snapIndicator: self.sr.snapIndicator.Close() self.sr.snapIndicator = None return if not wnd.IsStackable() or not self.IsStackable(): return if self.sr.snapIndicator is None: self.sr.snapIndicator = FillUnderlay( parent=None, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, align=uiconst.TOTOP_NOPUSH, height=20, padding=(2, 2, 2, 0)) si = self.sr.snapIndicator si.state = uiconst.UI_DISABLED if si.parent != wnd: uiutil.Transplant(si, wnd, idx=0) else: uiutil.SetOrder(si, 0)
def RemoveWnd(self, wnd, grab, correctpos=1, idx=0, dragging=0, check=1): if wnd.parent != self.sr.content: return if hasattr(wnd, 'OnTabSelect'): uthread.worker('WindowStack::RemoveWnd', wnd.OnTabSelect) wnd._detaching = True uiutil.Transplant(wnd, self.parent, idx) wnd.sr.stack = None wnd.sr.tab = None wnd.align = uiconst.TOPLEFT wnd.state = uiconst.UI_NORMAL wnd.grab = grab wnd.width = wnd._fixedWidth or self.width wnd.height = wnd._fixedHeight or self.height if dragging: uicore.uilib.SetMouseCapture(wnd) uthread.new(wnd._BeginDrag) wnd.ShowHeader() wnd.ShowBackground() if correctpos: wnd.left = uicore.uilib.x - grab[0] wnd.top = uicore.uilib.y - grab[1] if check: self.Check() wnd.RegisterStackID() wnd._detaching = False wnd._dragging = dragging myWindows = self.GetWindows() if len(myWindows) == 1 and not self.IsCollapsed(): w = myWindows[0] aL, aT, aW, aH = self.GetAbsolute() x, y = aL, aT self.RemoveWnd(w, (0, 0), 1, 1, check=0) w.left, w.top = x, y return if len(self.GetWindows()) == 0: self.Close()
def SetWndIcon(self, iconNum = None, headerIcon = 0, size = 64, fullPath = None, mainTop = -3, hidden = False, **kw): self.iconNum = iconNum or self.GetDefaultWndIcon() if hidden: iconNum = None retmain = None retclipped = None for each in ['mainicon', 'clippedicon', 'clippedicon2']: icon = uiutil.FindChild(self, each) if not icon: continue elif iconNum is None: icon.state = uiconst.UI_HIDDEN continue icon.state = uiconst.UI_DISABLED icon.LoadIcon(iconNum or fullPath, ignoreSize=True) if each in ('clippedicon', 'clippedicon2'): if self.sr.topParent: icon.parent.top = -self.sr.topParent.height if headerIcon: retclipped = None icon.Close() else: retclipped = icon elif each == 'mainicon': retmain = icon icon.top = mainTop if headerIcon and each == 'mainicon': icon.width = icon.height = 16 icon.left = 4 icon.top = 0 uiutil.Transplant(icon, uiutil.GetChild(self, 'captionParent')) if self.sr.caption: self.sr.caption.left = 24 self.sr.headerIcon = icon return (retmain, retclipped)
def AddInput(self, attrs, add=1): attrs.vspace = getattr(attrs, 'vspace', 1) if attrs.type is None: attrs.type = 'text' create = getattr(self, 'Create_%s' % attrs.type.lower(), None) if create: wnd = create(attrs) else: wnd = uicls.Container() browser = uiutil.GetBrowser(self.browser) if not browser: return if add: self.fields.append((attrs, wnd)) attrs.control = wnd attrs.align = getattr(attrs, 'align', None) obj = uiutil.Bunch() obj.font = None obj.key = 'input_%s' % attrs.type.lower() obj.type = '<input>' obj.attrs = attrs wnd.state = uiconst.UI_HIDDEN if hasattr(self.browser, 'sr'): uiutil.Transplant(wnd, self.browser.sr.cacheContainer) startup = getattr(self, 'Startup_%s' % attrs.type.lower(), None) if startup: startup(wnd, attrs) obj.width = wnd.width + 5 obj.height = wnd.height + 5 obj.valign = 1 if add: obj.control = wnd wnd.loaded = 1 else: wnd.Close() return obj
def DoRepositionDrag(self, cursorClipper): """ Does the repositioning of targets while the mouse is being dragged """ blue.synchro.Sleep(200) if uicore.uilib.leftbtn and uicore.uilib.mouseOver == self: uicore.uilib.ClipCursor(*cursorClipper) else: return origin = self.GetAbsolute() xOffset = uicore.uilib.x - origin[0] yOffset = uicore.uilib.y - origin[1] horizontalAlign = settings.user.ui.Get('alignHorizontally', True) repositionLine = uiprimitives.Line(align=uiconst.TORIGHT, weight=4, color=(1, 1, 1, 0.5)) uiutil.Transplant(self, uicore.layer.abovemain) targetSvc = sm.GetService('target') targetSvc.ArrangeTargets() while uicore.uilib.leftbtn: self.SetAlign(uiconst.TOPLEFT) self.left = uicore.uilib.x - xOffset self.top = uicore.uilib.y - yOffset (x, y), (toLeft, toTop) = targetSvc.GetOriginPosition(getDirection=1) lessThanAll = True for target in uicore.layer.target.children: if isinstance(target, xtriui.Target): tl, tt, tw, th = target.GetAbsolute() if tl - 2 <= uicore.uilib.x <= tl + tw + 2 and tt - 2 <= uicore.uilib.y <= tt + th + 2: if horizontalAlign: repositionLine.padTop = repositionLine.padBottom = 32 if not toLeft: repositionLine.SetAlign(uiconst.TOLEFT) repositionLine.padLeft = -10 else: repositionLine.SetAlign(uiconst.TORIGHT) repositionLine.padLeft = 0 lessThanAll = False break else: if not toTop: repositionLine.SetAlign(uiconst.TOTOP) repositionLine.padTop = 0 else: repositionLine.SetAlign(uiconst.TOBOTTOM) repositionLine.padTop = -10 lessThanAll = False break if lessThanAll: if horizontalAlign: repositionLine.padTop = repositionLine.padBottom = 32 if not toLeft: repositionLine.SetAlign(uiconst.TORIGHT) repositionLine.padLeft = 0 else: repositionLine.SetAlign(uiconst.TOLEFT) repositionLine.padLeft = -10 elif not toTop: repositionLine.SetAlign(uiconst.TOBOTTOM) repositionLine.padTop = -10 else: repositionLine.SetAlign(uiconst.TOTOP) repositionLine.padTop = 0 uiutil.Transplant(repositionLine, target) blue.pyos.synchro.Yield() uicore.uilib.UnclipCursor() uiutil.Transplant( self, uicore.layer.target, idx=uicore.layer.target.children.index(repositionLine.parent) if not lessThanAll else None) repositionLine.Close() targetSvc.ArrangeTargets()
def Split(self, splitConst, splitValue, adjustableID = False, line = 1, minSize = None): if not self.sr.splitareacontent: self.sr.splitareacontent = uicls.Container(parent=self.sr.maincontainer, name='__splitareas_and_content', align=uiconst.TOALL, state=uiconst.UI_PICKCHILDREN) uiutil.Transplant(self.sr.content, self.sr.splitareacontent) idx = 0 for each in self.sr.splitareacontent.children: if each.name.endswith('_SplitArea'): idx = self.sr.splitareacontent.children.index(each) + 1 if adjustableID: lastSize = settings.user.ui.Get('AreaSplitSize_%s' % adjustableID, None) if lastSize is not None: splitValue = lastSize w = h = 0 if splitConst == uiconst.SPLITTOP: h = splitValue a = uiconst.TOTOP la = uiconst.TOBOTTOM s = 'top' elif splitConst == uiconst.SPLITBOTTOM: h = splitValue a = uiconst.TOBOTTOM la = uiconst.TOTOP s = 'bottom' elif splitConst == uiconst.SPLITLEFT: w = splitValue a = uiconst.TOLEFT la = uiconst.TORIGHT s = 'left' elif splitConst == uiconst.SPLITRIGHT: w = splitValue a = uiconst.TORIGHT la = uiconst.TOLEFT s = 'right' else: raise NotImplementedError newArea = uicls.Area(name=s + '_SplitArea', align=a, parent=self.sr.splitareacontent, idx=idx, clipChildren=1) newArea.isSplitArea = True newArea.Flush() newArea.isTabOrderGroup = True if type(splitValue) == types.FloatType: newArea.splitValue = splitValue else: newArea.width = w newArea.height = h newArea.splitValue = None if adjustableID: div = uicls.DividerCore(name='divider', align=a, pos=(0, 0, 5, 5), idx=idx + 1, parent=self.sr.splitareacontent) div.OnChangeStart_ = self.ScaleAreaStart div.OnChanged_ = self.ScaleAreaEnd div.OnChange_ = self.ScaleArea div.sr.area = newArea div.name = 'div_%s_SplitArea' % s if line: uicls.Line(name='line_%s_SplitArea' % s, parent=div, align=a) uicls.Line(name='line_%s_SplitArea' % s, parent=div, align=la) elif line: uicls.Line(name='line_%s_SplitArea' % s, parent=self.sr.splitareacontent, align=a, idx=idx + 1) newArea._adjustableData = (adjustableID, minSize) self._AdjustDividers(useSettings=True) return newArea