def LoadAttrs(self, attrs): src = attrs.src if attrs.texture: sprite = Sprite(parent=self, align=uiconst.TOALL, state=uiconst.UI_DISABLED) sprite.rectWidth = attrs.width sprite.rectHeight = attrs.height sprite.texture = attrs.texture elif src.startswith('icon:'): uthread.new(self.LoadIcon)
def LoadImage(self, *args): if not getattr(self, 'attrs', None): return browserImageSvc = sm.GetServiceIfRunning('browserImage') if not browserImageSvc: return texture, tWidth, tHeight = browserImageSvc.GetTextureFromURL(getattr(self.attrs, 'src', ''), getattr(self.attrs, 'currentURL', ''), fromWhere='Img::Load') if texture: sprite = Sprite(parent=self, align=uiconst.TOALL, pos=(0, 0, 0, 0)) sprite.rectWidth = tWidth sprite.rectHeight = tHeight sprite.rectTop = 0 sprite.rectLeft = 0 sprite.texture = texture sprite.state = uiconst.UI_DISABLED
def AddBackground(self, where, s): for i, side in enumerate(['top', 'left', 'right', 'bottom']): if s['border-%s-width' % side]: align = [ uiconst.TOTOP, uiconst.TOLEFT, uiconst.TORIGHT, uiconst.TOBOTTOM ][i] Line(parent=where, align=align, weight=s['border-%s-width' % side], color=s['border-%s-color' % side], idx=0) if s['background-image'] and where.sr.background: browser = GetBrowser(self) currentURL = None if browser: currentURL = browser.sr.currentURL texture, tWidth, tHeight = sm.GetService( 'browserImage').GetTextureFromURL( s['background-image'], currentURL, fromWhere='VirtualTable::AddBackground') pic = Sprite() pic.left = pic.top = 0 pic.width = tWidth pic.height = tHeight pic.texture = texture row = Container(name='row', align=uiconst.TOTOP, pos=(0, 0, 0, tHeight), clipChildren=1) if s['background-repeat'] in ('repeat', 'repeat-x'): for x in xrange(max(where.width / tWidth, 2) + 1): row.children.append(pic.CopyTo()) pic.left += pic.width else: row.children.append(pic.CopyTo()) if s['background-repeat'] in ('repeat', 'repeat-y'): for y in xrange(max(where.height / tHeight, 2) + 1): row.height = min(where.height - tHeight * y, row.height) where.sr.background.children.append(row.CopyTo()) else: where.sr.background.children.append(row.CopyTo()) if s['background-color']: Fill(parent=where, color=s['background-color'])
def LoadImage(self, *args): if not getattr(self, 'attrs', None): return browserImageSvc = sm.GetServiceIfRunning('browserImage') if not browserImageSvc: return texture, tWidth, tHeight = browserImageSvc.GetTextureFromURL( getattr(self.attrs, 'src', ''), getattr(self.attrs, 'currentURL', ''), fromWhere='Img::Load') if texture: sprite = Sprite(parent=self, align=uiconst.TOALL, pos=(0, 0, 0, 0)) sprite.rectWidth = tWidth sprite.rectHeight = tHeight sprite.rectTop = 0 sprite.rectLeft = 0 sprite.texture = texture sprite.state = uiconst.UI_DISABLED
def AddBackground(self, where, s): for i, side in enumerate(['top', 'left', 'right', 'bottom']): if s['border-%s-width' % side]: align = [uiconst.TOTOP, uiconst.TOLEFT, uiconst.TORIGHT, uiconst.TOBOTTOM][i] Line(parent=where, align=align, weight=s['border-%s-width' % side], color=s['border-%s-color' % side], idx=0) if s['background-image'] and where.sr.background: browser = GetBrowser(self) currentURL = None if browser: currentURL = browser.sr.currentURL texture, tWidth, tHeight = sm.GetService('browserImage').GetTextureFromURL(s['background-image'], currentURL, fromWhere='VirtualTable::AddBackground') pic = Sprite() pic.left = pic.top = 0 pic.width = tWidth pic.height = tHeight pic.texture = texture row = Container(name='row', align=uiconst.TOTOP, pos=(0, 0, 0, tHeight), clipChildren=1) if s['background-repeat'] in ('repeat', 'repeat-x'): for x in xrange(max(where.width / tWidth, 2) + 1): row.children.append(pic.CopyTo()) pic.left += pic.width else: row.children.append(pic.CopyTo()) if s['background-repeat'] in ('repeat', 'repeat-y'): for y in xrange(max(where.height / tHeight, 2) + 1): row.height = min(where.height - tHeight * y, row.height) where.sr.background.children.append(row.CopyTo()) else: where.sr.background.children.append(row.CopyTo()) if s['background-color']: Fill(parent=where, color=s['background-color'])