def Startup(self, *args):
     attrs = self.data.attrs
     self.name = 'div'
     browser = GetBrowser(self)
     contentWidth = browser.GetContentWidth()
     self.width = width = self.GetPercent(
         attrs.stack['width'] or contentWidth - attrs.stack.get('left', 0),
         contentWidth - attrs.stack.get('left', 0))
     self.height = attrs.stack['height'] or 32
     self.SetAlign(uiconst.RELATIVE)
     self.AddBackground(self, attrs.stack)
     self.LoadBuffer(self.data.attrs.content, setWidth=self.width)
     self.CheckOverlaysAndUnderlays()
     self.width = attrs.width = width or self.contentWidth
     self.height = attrs.height = attrs.stack.get(
         'height', None) or self.contentHeight
     if attrs.stack['position'] == 'absolute':
         self.left = attrs.left = attrs.stack.get('left', 0)
         self.top = attrs.top = attrs.stack.get('top', 0)
     elif attrs.stack['position'] == 'relative' and attrs.stack['align']:
         if attrs.stack['align'] == 'center':
             aL, aT, aW, aH = self.parent.GetAbsolute()
             self.left = attrs.left = (aW - self.width) / 2
         elif attrs.stack['align'] == 'right':
             aL, aT, aW, aH = self.parent.GetAbsolute()
             self.left = attrs.left = aW - self.width
         else:
             self.left = attrs.left
         self.top = attrs.top
     elif attrs.stack['float'] in ('left', 'right'):
         self.left = attrs.left
         self.top = attrs.top
 def OnSetFocus(self, *args):
     if self and not self.destroyed and self.parent and self.parent.name == 'inlines':
         browser = GetBrowser(self)
         if browser:
             browser.ShowNodeIdx(self.parent.parent.sr.node.idx)
     if self and not self.destroyed and self.sr and self.sr.activeframe:
         self.sr.activeframe.state = uiconst.UI_DISABLED
     btns = self.GetDefaultBtnsInSameWnd()
     if btns:
         self.SetWndDefaultFrameState(btns, 0)
 def Load(self, contentList=[], scrolltotop=0, scrollTo=0.0, *args):
     browser = GetBrowser(self)
     if browser:
         self.attrStack = browser.attrStack
         self.css = browser.css
         self.LoadFont()
     self.LoadContent(contentList)
Beispiel #4
0
 def LinkExit(self, link, *args):
     browser = GetBrowser(self)
     if browser and browser.sr.window and hasattr(browser.sr.window,
                                                  'ShowHint'):
         browser.sr.window.ShowHint('')
     for each in self.sr.hiliteLinks:
         each.Flush()
Beispiel #5
0
    def OnSubmit(self, *etc):
        if self.submitting:
            uicore.Message('Busy')
            return
        self.submitting = 1
        e = []
        for attrs, wnd in self.fields:
            if not attrs.name:
                continue
            if getattr(attrs, 'type',
                       None).lower() == 'submit' and wnd not in etc:
                continue
            getval = getattr(self, 'GetValue_%s' % attrs.type.lower(),
                             lambda *args: None)
            val = getval(wnd, attrs)
            if val is not None:
                e.append((attrs.name, val))

        d = []
        for key, val in e:
            if type(val) == list:
                for v in val:
                    if isinstance(v, unicode):
                        v = self.decode(v)
                    d.append((key, v))

            else:
                if isinstance(val, unicode):
                    val = self.decode(val)
                d.append((key, val))

        s = urllib.urlencode(d)
        if isinstance(s, unicode):
            s = self.decode(val)
        browser = GetBrowser(self.browser)
        if not browser:
            return
        if getattr(self.attrs, 'method', 'get').lower() == 'get':
            if 'localsvc:' in self.attrs.action:
                from carbonui.control.baselink import BaseLinkCoreOverride as BaseLink
                BaseLink().LocalSvcCall(self.attrs.action[9:] +
                                        ''.join([name for name, value in d]))
                self.submitting = 0
            else:
                browser.GoTo('?'.join((self.attrs.action, s)))
        elif self.attrs.method.lower() == 'post':
            browser.GoTo(self.attrs.action, s)
Beispiel #6
0
 def OnSetFocus(self, *args):
     if self and not self.destroyed and self.parent and self.parent.name == 'inlines':
         if self.parent.parent and self.parent.parent.sr.node:
             browser = GetBrowser(self)
             if browser:
                 uthread.new(browser.ShowObject, self)
     if self.sr.active:
         self.sr.active.state = uiconst.UI_DISABLED
Beispiel #7
0
 def __init__(self, attrs, browser):
     if getattr(attrs, 'action', None) is None:
         setattr(attrs, 'action',
                 GetBrowser(browser).sr.currentURL.split('?')[0])
     if str(getattr(attrs, 'method', 'get')).lower() not in ('get', 'post'):
         setattr(attrs, 'method', 'get')
     self.submitting = 0
     self.attrs = attrs
     self.browser = browser
     self.fields = []
Beispiel #8
0
 def Unload(self):
     browser = 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
             control.SetParent(browser.sr.cacheContainer)
             if hasattr(control, 'Unload') and control.loaded:
                 control.Unload()
Beispiel #9
0
 def LinkEnter(self, link, *args):
     browser = GetBrowser(self)
     if browser and browser.sr.window and hasattr(browser.sr.window, 'ShowHint'):
         browser.sr.window.ShowHint(link.hint or link.url)
     self.sr.hiliteLinks = []
     for entry in self.sr.node.scroll.GetNodes():
         if not entry.panel:
             continue
         if entry.panel.sr.Get('links', None):
             for item in entry.panel.sr.links.children:
                 if item.name == 'textlink' and item.url == link.url:
                     self.HiliteLink(item)
                     self.sr.hiliteLinks.append(item)
    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 ApplyAttributes(self, attributes):
     SE_BaseClassCore.ApplyAttributes(self, attributes)
     ParserBase.Prepare(self)
     self.sr.selfProxy = _weakref.proxy(self)
     self.htmldebug = 0
     self.xmargin = 0
     self.sr.entries = []
     self.sr.overlays = []
     self.sr.overlays_content = Container(name='overlays',
                                          parent=self,
                                          padding=(1, 1, 1, 1))
     self.sr.content = Container(name='content', parent=self)
     self.sr.underlays_content = Container(name='underlays_content',
                                           parent=self,
                                           padding=(1, 1, 1, 1))
     self.sr.background = Container(name='background', parent=self)
     self.sr.backgroundColorContainer = Container(
         name='backgroundColorContainer', parent=self)
     browser = GetBrowser(self)
     self.sr.browser = browser
Beispiel #12
0
 def OnSetFocus(self, *args):
     if self.pickState != uiconst.TR2_SPS_ON:
         return
     if not self.readonly and uicore.imeHandler:
         uicore.imeHandler.SetFocus(self)
     if self and not self.destroyed and self.parent and self.parent.name == 'inlines':
         if self.parent.parent and getattr(self.parent.parent.sr, 'node', None):
             browser = GetBrowser(self)
             if browser:
                 uthread.new(browser.ShowObject, self)
     self.sr.background.AnimEntry()
     if self.integermode or self.floatmode:
         self.SetText(self.text)
         self.caretIndex = self.GetCursorFromIndex(-1)
     self.ShowCaret()
     if self.autoselect:
         self.SelectAll()
     else:
         self.RefreshSelectionDisplay()
     if self.__OnSetFocus:
         self.__OnSetFocus(*args)
    def AddBackground(self, where, s):
        contentWidth = GetBrowser(self).GetContentWidth()
        for i, side in enumerate(['top', 'left', 'right', 'bottom']):
            align = [
                uiconst.TOTOP, uiconst.TOLEFT, uiconst.TORIGHT,
                uiconst.TOBOTTOM
            ][i]
            if s['margin-%s' % side]:
                s['margin-%s' % side] = self.GetPercent(
                    s['margin-%s' % side], contentWidth)
                Container(name='margin-%s' % side,
                          parent=where,
                          align=align,
                          padding=(0, 0, int(s['margin-%s' % side]),
                                   int(s['margin-%s' % side])),
                          idx=0)
            if s['border-%s-width' % side]:
                Line(parent=where,
                     align=align,
                     weight=s['border-%s-width' % side],
                     color=s['border-%s-color' % side])

        if s['background-color']:
            Fill(parent=where, color=s['background-color'])
Beispiel #14
0
 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 = Container()
     browser = GetBrowser(self.browser)
     if not browser:
         return
     if add:
         self.fields.append((attrs, wnd))
     attrs.control = wnd
     attrs.align = getattr(attrs, 'align', None)
     obj = 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'):
         wnd.SetParent(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 GetFixedURL(self, parent, url):
     browser = GetBrowser(parent)
     currentURL = None
     if browser and hasattr(browser.sr, 'currentURL'):
         currentURL = browser.sr.currentURL
     return urlparse.urljoin(currentURL, url)
Beispiel #16
0
 def OnSetFocus(self, *args):
     if self and not self.destroyed and self.parent and self.parent.name == 'inlines':
         if self.parent.parent and self.parent.parent.sr.node:
             browser = GetBrowser(self)
             if browser:
                 uthread.new(browser.ShowObject, self)