Esempio n. 1
0
    def remove(self, child, index=None):
        if index is None:
            if isinstance(child, int):
                index = child
                child = self.getWidget(child)
            else:
                index = self.getWidgetIndex(child)

        if child.getParent() != self:
            return False

        if self.visibleStack == index:
            self.visibleStack = -1
        elif self.visibleStack > index:
            self.visibleStack -= 1

        rowIndex = 2 * index
        tr = DOM.getChild(self.body, rowIndex)
        DOM.removeChild(self.body, tr)
        tr = DOM.getChild(self.body, rowIndex)
        DOM.removeChild(self.body, tr)
        CellPanel.remove(self, child)
        rows = self.getWidgetCount() * 2

        #for (int i = rowIndex; i < rows; i = i + 2) {
        for i in range(rowIndex, rows, 2):
            childTR = DOM.getChild(self.body, i)
            td = DOM.getFirstChild(childTR)
            curIndex = self._getIndex(td)
            self._setIndex(td, index)
            index += 1

        return True
Esempio n. 2
0
    def setStackText(self, index, text, asHTML=False):
        if index >= self.getWidgetCount():
            return

        td = DOM.getChild(DOM.getChild(self.body, index * 2), 0)
        if asHTML:
            DOM.setInnerHTML(td, text)
        else:
            DOM.setInnerText(td, text)
Esempio n. 3
0
    def setStackText(self, index, text, asHTML=False):
        if index >= self.getWidgetCount():
            return

        td = DOM.getChild(DOM.getChild(self.body, index * 2), 0)
        if asHTML:
            DOM.setInnerHTML(td, text)
        else:
            DOM.setInnerText(td, text)
 def getCellElement(self, row, cell) :
   """   Get a specific Element from the panel.
    
     @param row the row index
     @param cell the cell index
     @return the Element at the given row and cell
   """
   tr = DOM.getChild(self.tbody, row)
   td = DOM.getChild(tr, cell)
   return DOM.getFirstChild(td)
Esempio n. 5
0
    def setStackVisible(self, index, visible):
        tr = DOM.getChild(self.body, (index * 2))
        if tr is None:
            return

        td = DOM.getFirstChild(tr)
        self.setStyleName(td, "gwt-StackPanelItem-selected", visible)

        tr = DOM.getChild(self.body, (index * 2) + 1)
        self.setVisible(tr, visible)
        self.getWidget(index).setVisible(visible)
Esempio n. 6
0
 def inicia(self):
     global IMAGEREPO
     self.__form = f = DOM.getElementById('mainform')
     self.x = DOM.getChild(f,0).value #DOM.getElementByName('_xsrf').value
     g = DOM.getChild(f,1).value
     self.scored = DOM.getChild(f,2)
     self.housed = DOM.getChild(f,3)
     if g == '12de6b622cbfe4d8f5c8d3347e56ae8c': IMAGEREPO = 'imagens/'
     #self.talk(self.scored.value+self.housed.value+IMAGEREPO)
     self._socket = NullSocket() #WebSocket("ws://%s/chatsocket"%self.test())
     self._socket.register_receiver(self.game.receive)
     obj = j_p.wdecode(self.housed.value)
     #self.text(400,85, str(obj) ,'darkbrown',10)
     #obj = [dict(body='nonono')]
     return obj
Esempio n. 7
0
def findTextPoint(node, offset):
    """
    If the found range is not on a text node, this finds the cooresponding
    text node to where the selection is.  If it is on a text node, just
    directly creates the endpoint from it.

    @param node node returned as an endpoint of a range
    @param offset offset returned to the endpoint of a range
    @return A range end point with a proper (or None) text node
    """
    if DOM.getNodeType(node) == DOM.TEXT_NODE:
        res = RangeEndPoint(node, offset)
    else:
        # search backwards unless this is after the last node
        dirn = offset >= DOM.getChildCount(node)
        child = (DOM.getChildCount(node) == 0) and node or DOM.getChild(node, dirn and (offset - 1) or offset)
        # Get the previous/next text node
        text = RangeUtil.getAdjacentTextElement(child, dirn)
        if text is None:
            # If we didn't find a text node in the preferred direction,
            # try the other direction
            dirn = not dirn
            text = RangeUtil.getAdjacentTextElement(child, dirn)

        res = RangeEndPoint(text, dirn)

    return res
Esempio n. 8
0
 def removeItem(self, item):
     try:
         idx = self.items.index(item)
     except ValueError:
         return
     container = self.getItemContainerElement()
     DOM.removeChild(container, DOM.getChild(container, idx))
     del self.items[idx]
Esempio n. 9
0
 def getItemContainerElement(self, item):
     if self.vertical:
         return self.body
     else:
         self._checkVerticalContainer()
         if self.itemsPerRow:
             row = items / self.itemsPerRow
         else:
             row = 0
         return DOM.getChild(self.body, row)
Esempio n. 10
0
File: MenuBar.py Progetto: Afey/pyjs
 def insertItem(self, item, index):
     if self.vertical:
         tr = DOM.createTR()
         DOM.insertChild(self.body, tr, index)
     else:
         self._checkVerticalContainer()
         tr = DOM.getChild(self.body, 0)
     DOM.insertChild(tr, item.getElement(), index)
     item.setParentMenu(self)
     item.setSelectionStyle(False)
     self.items.insert(index, item)
 def clear(self):
     # as long as the canvas has children other than our <defs> element
     while DOM.getChildCount(self.canvas) > 1:
         # remove the second one (skip defs)
         DOM.removeChild(self.canvas, DOM.getChild(self.canvas, 1))
     # # init styles context stack
     # self.ctx_stack = []
     # # init current context
     # self._init_context()
     # also reset path
     self.beginPath()
Esempio n. 12
0
    def addItem(self, item, asHTML=None, popup=None):
        if not hasattr(item, "setSubMenu"):
            item = MenuItem(item, asHTML, popup)

        if self.vertical:
            tr = DOM.createTR()
            DOM.appendChild(self.body, tr)
        else:
            tr = DOM.getChild(self.body, 0)

        DOM.appendChild(tr, item.getElement())

        item.setParentMenu(self)
        item.setSelectionStyle(False)
        self.items.append(item)
        return item
Esempio n. 13
0
    def addItem(self, item, asHTML=None, popup=None):
        if not hasattr(item, "setSubMenu"):
            item = MenuItem(item, asHTML, popup)

        if self.vertical:
            tr = DOM.createTR()
            DOM.appendChild(self.body, tr)
        else:
            tr = DOM.getChild(self.body, 0)

        DOM.appendChild(tr, item.getElement())

        item.setParentMenu(self)
        item.setSelectionStyle(False)
        self.items.append(item)
        return item
Esempio n. 14
0
 def clear(self):
     """
     Clears the entire canvas.
     Also deletes the context stack and current path
     TODO: NEED TO RESET STYLES?
     TODO: NEED TO RESET STYLES?
     """
     # as long as the canvas has children other than our <defs> element
     while DOM.getChildCount(self.canvas) > 1:
         # remove the second one (skip defs)
         DOM.removeChild(self.canvas, DOM.getChild(self.canvas, 1))
     # # init styles context stack
     # self.ctx_stack = []
     # # init current context
     # self._init_context()
     # also reset path
     self.beginPath()
Esempio n. 15
0
 def clear(self):
     """
     Clears the entire canvas.
     Also deletes the context stack and current path
     TODO: NEED TO RESET STYLES?
     TODO: NEED TO RESET STYLES?
     """
     # as long as the canvas has children other than our <defs> element
     while DOM.getChildCount(self.canvas) > 1:
         # remove the second one (skip defs)
         DOM.removeChild(self.canvas, DOM.getChild(self.canvas, 1))
     # # init styles context stack
     # self.ctx_stack = []
     # # init current context
     # self._init_context()
     # also reset path
     self.beginPath()
Esempio n. 16
0
def findTextPoint(node, offset):
    if DOM.getNodeType(node) == DOM.TEXT_NODE:
        res = RangeEndPoint(node, offset)
    else:
        # search backwards unless this is after the last node
        dirn = offset >= DOM.getChildCount(node)
        child = (DOM.getChildCount(node) == 0) and node or DOM.getChild(node, dirn and (offset - 1) or offset)
        # Get the previous/next text node
        text = RangeUtil.getAdjacentTextElement(child, dirn)
        if text is None:
            # If we didn't find a text node in the preferred direction,
            # try the other direction
            dirn = not dirn
            text = RangeUtil.getAdjacentTextElement(child, dirn)

        res = RangeEndPoint(text, dirn)

    return res
Esempio n. 17
0
def findTextPoint(node, offset):
    if DOM.getNodeType(node) == DOM.TEXT_NODE:
        res = RangeEndPoint(node, offset)
    else:
        # search backwards unless this is after the last node
        dirn = offset >= DOM.getChildCount(node)
        child = (DOM.getChildCount(node) == 0) and node or \
            DOM.getChild(node, dirn and (offset - 1) or offset)
        # Get the previous/next text node
        text = RangeUtil.getAdjacentTextElement(child, dirn)
        if text is None:
            # If we didn't find a text node in the preferred direction,
            # try the other direction
            dirn = not dirn
            text = RangeUtil.getAdjacentTextElement(child, dirn)

        res = RangeEndPoint(text, dirn)

    return res
Esempio n. 18
0
    def addItem(self, item, asHTML=None, popup=None):
        if not hasattr(item, "setSubMenu"):
            item = MenuItem(item, asHTML, popup)

        if self.vertical:
            tr = DOM.createTR()
            DOM.appendChild(self.body, tr)
        else:
            self._checkVerticalContainer()
            if len(self.items) == self.itemsPerRow:
                DOM.appendChild(self.body, DOM.createTR())
            count = DOM.getChildCount(self.body)
            tr = DOM.getChild(self.body, count-1)

        DOM.appendChild(tr, item.getElement())

        item.setParentMenu(self)
        item.setSelectionStyle(False)
        self.items.append(item)
        return item
    def __init__(self, rowStyles=None, containerIndex=1, **kwargs):
        """ Creates a new panel using the specified style names to
            apply to each row.  Each row will contain three cells
            (Left, Center, and Right). The Center cell in the
            containerIndex row will contain the {@link Widget}.
            
            @param rowStyles an array of style names to apply to each row
            @param containerIndex the index of the container row
        """
      
        if rowStyles is None:
            rowStyles = self.DEFAULT_ROW_STYLENAMES

        if kwargs.has_key('Element'):
            self.table = kwargs.pop('Element')
            fc = DOM.getFirstChild(self.table)
            if fc:
                self.tbody = fc
            else:
                self.tbody = DOM.createTBody()
                DOM.appendChild(self.table, self.tbody)
        else:
            # Add a tbody
            self.table = DOM.createTable()
            self.tbody = DOM.createTBody()
            DOM.appendChild(self.table, self.tbody)
            DOM.setAttribute(self.table, "cellSpacing", "0")
            DOM.setAttribute(self.table, "cellPadding", "0")

        if not kwargs.has_key('StyleName'): kwargs['StyleName']=self.DEFAULT_STYLENAME
        SimplePanel.__init__(self, self.table, **kwargs)

        # Add each row
        for i in range(len(rowStyles)): 
            row = self.createTR(rowStyles[i])
            DOM.appendChild(self.tbody, row)
            if i == containerIndex:
                self.containerElem = DOM.getFirstChild(DOM.getChild(row, 1))
Esempio n. 20
0
File: ListBox.py Progetto: Afey/pyjs
 def setItemSelected(self, index, selected):
     self.checkIndex(index)
     option = DOM.getChild(self.getElement(), index)
     DOM.setIntAttribute(option, "selected", selected and 1 or 0)
Esempio n. 21
0
 def clearItems(self):
     container = self.getItemContainerElement()
     while DOM.getChildCount(container) > 0:
         DOM.removeChild(container, DOM.getChild(container, 0))
     self.items = []
Esempio n. 22
0
 def getItemContainerElement(self):
     if self.vertical:
         return self.body
     else:
         return DOM.getChild(self.body, 0)
Esempio n. 23
0
 def getElement(self, row, column):
     self.outer.checkCellBounds(row, column)
     return DOM.getChild(self.outer.rowFormatter.getRow(self.outer.bodyElem, row), column)
Esempio n. 24
0
 def ensureElement(self, row, column):
     self.outer.prepareCell(row, column)
     return DOM.getChild(self.outer.rowFormatter.ensureElement(row), column)
Esempio n. 25
0
    def realizeTable(self, beingAdded):
        bodyElement = self.getBody()

        while DOM.getChildCount(bodyElement) > 0:
            DOM.removeChild(bodyElement, DOM.getChild(bodyElement, 0))

        rowCount = 1
        colCount = 1
        for child in self.dock_children:
            dir = child.getLayoutData().direction
            if dir == self.NORTH or dir == self.SOUTH:
                rowCount += 1
            elif dir == self.EAST or dir == self.WEST:
                colCount += 1

        rows = []
        for i in range(rowCount):
            rows.append(DockPanelTmpRow())
            rows[i].tr = DOM.createTR()
            DOM.appendChild(bodyElement, rows[i].tr)

        westCol = 0
        eastCol = colCount - 1
        northRow = 0
        southRow = rowCount - 1
        centerTd = None

        for child in self.dock_children:
            layout = child.getLayoutData()

            td = DOM.createTD()
            layout.td = td
            DOM.setAttribute(layout.td, "align", layout.hAlign)
            DOM.setStyleAttribute(layout.td, "verticalAlign", layout.vAlign)
            DOM.setAttribute(layout.td, "width", layout.width)
            DOM.setAttribute(layout.td, "height", layout.height)

            if layout.direction == self.NORTH:
                DOM.insertChild(rows[northRow].tr, td, rows[northRow].center)
                self.appendAndMaybeAdopt(td, child.getElement(), beingAdded)
                DOM.setIntAttribute(td, "colSpan", eastCol - westCol + 1)
                northRow += 1
            elif layout.direction == self.SOUTH:
                DOM.insertChild(rows[southRow].tr, td, rows[southRow].center)
                self.appendAndMaybeAdopt(td, child.getElement(), beingAdded)
                DOM.setIntAttribute(td, "colSpan", eastCol - westCol + 1)
                southRow -= 1
            elif layout.direction == self.WEST:
                row = rows[northRow]
                DOM.insertChild(row.tr, td, row.center)
                row.center += 1
                self.appendAndMaybeAdopt(td, child.getElement(), beingAdded)
                DOM.setIntAttribute(td, "rowSpan", southRow - northRow + 1)
                westCol += 1
            elif layout.direction == self.EAST:
                row = rows[northRow]
                DOM.insertChild(row.tr, td, row.center)
                self.appendAndMaybeAdopt(td, child.getElement(), beingAdded)
                DOM.setIntAttribute(td, "rowSpan", southRow - northRow + 1)
                eastCol -= 1
            elif layout.direction == self.CENTER:
                centerTd = td

        if self.center is not None:
            row = rows[northRow]
            DOM.insertChild(row.tr, centerTd, row.center)
            self.appendAndMaybeAdopt(centerTd, self.center.getElement(), beingAdded)
Esempio n. 26
0
File: ListBox.py Progetto: Afey/pyjs
    def setValue(self, index, value):
        self.checkIndex(index)

        option = DOM.getChild(self.getElement(), index)
        DOM.setAttribute(option, "value", value)
Esempio n. 27
0
File: ListBox.py Progetto: Afey/pyjs
 def clear(self):
     h = self.getElement()
     while DOM.getChildCount(h) > 0:
         DOM.removeChild(h, DOM.getChild(h, 0))
Esempio n. 28
0
File: ListBox.py Progetto: Afey/pyjs
 def getItemText(self, index):
     child = DOM.getChild(self.getElement(), index)
     return DOM.getInnerText(child)
Esempio n. 29
0
File: ListBox.py Progetto: Afey/pyjs
 def removeItem(self, idx):
     child = DOM.getChild(self.getElement(), idx)
     DOM.removeChild(self.getElement(), child)
Esempio n. 30
0
File: ListBox.py Progetto: Afey/pyjs
 def isItemSelected(self, index):
     self.checkIndex(index)
     option = DOM.getChild(self.getElement(), index)
     return DOM.getBooleanAttribute(option, "selected")
Esempio n. 31
0
File: ListBox.py Progetto: Afey/pyjs
    def getValue(self, index):
        self.checkIndex(index)

        option = DOM.getChild(self.getElement(), index)
        return DOM.getAttribute(option, "value")