예제 #1
0
 def getStyleAttribute(self, attribute):
     """ can be called with two forms:
         getStyleAttribute(self, attr) - returns value
         getStyleAttribute(self, (attr1,attr2,...)) - returns dictionary of attr:value pairs
     """
     if isinstance(attribute, basestring):
         return DOM.getStyleAttribute(self.getElement(), attribute)
     # if attribute is not a string, assume it is iterable,
     # and return the multi-attribute form
     el = self.getElement()
     result = {}
     for attr in attribute:
         result[attr] = DOM.getStyleAttribute(el, attr)
     return result
예제 #2
0
파일: UIObject.py 프로젝트: sofianhw/pyjs
 def getStyleAttribute(self, attribute):
     """ can be called with two forms:
         getStyleAttribute(self, attr) - returns value
         getStyleAttribute(self, (attr1,attr2,...)) - returns dictionary of attr:value pairs
     """
     if isinstance(attribute, basestring):
         return DOM.getStyleAttribute(self.getElement(), attribute)
     # if attribute is not a string, assume it is iterable,
     # and return the multi-attribute form
     el = self.getElement()
     result = {}
     for attr in attribute:
         result[attr] = DOM.getStyleAttribute(el, attr)
     return result
예제 #3
0
 def identify(self, element):
     if element.nodeType != 1:
         return False
     if str(string.lower(element.tagName)) != 'span':
         return False
     style = DOM.getStyleAttribute(element, "font-family")
     return style is not None
예제 #4
0
 def hidePanelRight(self):
     if DOM.getStyleAttribute(
             self.mainPanel.getWidgetTd(self.cod),
             'display') == '':  # bug: "block" in <td> not work's on firefox
         DOM.setStyleAttribute(self.mainPanel.getWidgetTd(self.cod),
                               "display", "none")
         self.showHideRight.setStyleName('control_bar open_left')
예제 #5
0
 def identify(self, element):
     if element.nodeType != 1:
         return False
     if str(string.lower(element.tagName)) != 'span':
         return False
     style = DOM.getStyleAttribute(element, "font-family")
     return style is not None
예제 #6
0
 def showHidePanelRight(self):
     if DOM.getStyleAttribute(self.mainPanel.getWidgetTd(self.cod),
                              'display') == 'none':
         DOM.setStyleAttribute(self.mainPanel.getWidgetTd(self.cod),
                               "display", "")
         self.showHideRight.setStyleName('control_bar close_right')
     else:
         DOM.setStyleAttribute(self.mainPanel.getWidgetTd(self.cod),
                               "display", "none")
         self.showHideRight.setStyleName('control_bar open_left')
예제 #7
0
 def setDragImage(self, element, x, y):
     position_absolute = DOM.getStyleAttribute(element,
                                               'position') == 'absolute'
     if position_absolute:
         self.dragLeftOffset = x + DOM.getAbsoluteLeft(element.offsetParent)
         self.dragTopOffset = y + DOM.getAbsoluteTop(element.offsetParent)
     else:
         self.dragLeftOffset = x
         self.dragTopOffset = y
     if element.tagName.lower().endswith('img'):
         src = DOM.getAttribute(element, 'src')
         element = DOM.createElement('img')
         DOM.setAttribute(element, 'src', src)
     if not self.draggingImage:
         self.createDraggingImage(element)
     else:
         self.draggingImage.setImage(element)
예제 #8
0
 def showHidePanelMonitor(self):
     if DOM.getStyleAttribute(
             DOM.getParent(self.center.getWidgetTd(self.serialMonitor)),
             'display') == 'none':
         DOM.setStyleAttribute(
             DOM.getParent(self.center.getWidgetTd(self.serialMonitor)),
             "display", "")
         self.showHideMonitor.setStyleName('collapse open_down')
         #JS("""addCodeBenderPlugin();@{{!addCodeBenderPlugin}}();""")
         DOM.setStyleAttribute(self.resizeMonitor.getElement(), "display",
                               "")
     else:
         DOM.setStyleAttribute(
             DOM.getParent(self.center.getWidgetTd(self.serialMonitor)),
             "display", "none")
         self.showHideMonitor.setStyleName('collapse close_up')
         DOM.setStyleAttribute(self.resizeMonitor.getElement(), "display",
                               "none")
예제 #9
0
파일: DNDHelper.py 프로젝트: Afey/pyjs
 def setDragImage(self, element, x, y):
     position_absolute = DOM.getStyleAttribute(element,
                                 'position') == 'absolute'
     if position_absolute:
         self.dragLeftOffset = x + DOM.getAbsoluteLeft(
                 element.offsetParent)
         self.dragTopOffset = y + DOM.getAbsoluteTop(
                 element.offsetParent)
     else:
         self.dragLeftOffset = x
         self.dragTopOffset = y
     if element.tagName.lower().endswith('img'):
         src = DOM.getAttribute(element,'src')
         element = DOM.createElement('img')
         DOM.setAttribute(element, 'src', src)
     if not self.draggingImage:
         self.createDraggingImage(element)
     else:
         self.draggingImage.setImage(element)
예제 #10
0
파일: utils.py 프로젝트: anandology/pyjamas
def copyStyles(elem1, elem2):
    """
    Copy styles from one element to another, like in
    http://efreedom.com/Question/1-1848445/Duplicating-Element-Style-JavaScript
    """
    element_style = getComputedStyle(elem1)
    if element_style:
        element_style = dict(element_style)
    else:
        return
    for style in element_style:
        try:
            value = element_style[style]
            if isinstance(value, str):
                if not style == 'cssText':
                    DOM.setStyleAttribute(elem2, style, value)
                    if value == 'font':
                        DOM.setStyleAttribute(elem2, 'fontSize',
                            DOM.getStyleAttribute(elem1, 'fontSize'))
        except:
            pass
예제 #11
0
def copyStyles(elem1, elem2):
    """
    Copy styles from one element to another, like in
    http://efreedom.com/Question/1-1848445/Duplicating-Element-Style-JavaScript
    """
    element_style = getComputedStyle(elem1)
    if element_style:
        element_style = dict(element_style)
    else:
        return
    for style in element_style:
        try:
            value = element_style[style]
            if isinstance(value, str):
                if not style == 'cssText':
                    DOM.setStyleAttribute(elem2, style, value)
                    if value == 'font':
                        DOM.setStyleAttribute(
                            elem2, 'fontSize',
                            DOM.getStyleAttribute(elem1, 'fontSize'))
        except:
            pass
예제 #12
0
    def onMouseMove(self, sender, x, y):
        event = DOM.eventGetCurrentEvent()
        self.mouseEvent = event
        button = DOM.eventGetButton(event)
        if not button == Event.BUTTON_LEFT:
            return
## The following commented code lets the native dnd happen in IE. sucks.
## But it may enable dragging our widgets out of IE into other apps.
#        else:
#            try:
#                self.dragWidget.getElement().dragDrop()
#                return
#            except:
#                pass

# Adjust x and y to absolute coordinates.
        x, y = eventCoordinates(event)

        if self.dragging == DRAGGING_NO_MOVEMENT_YET:
            self.origMouseX = x
            self.origMouseY = y
            self.currentDragOperation = 'none'
            fromElement = self.dragWidget.getElement()
            # Is the widget itself draggable?
            try:
                draggable = fromElement.draggable
            except:
                draggable = False
            # if not, find the draggable element at (x, y) in the widget
            if not draggable:
                fromElement = findDraggable(sender.getElement(),
                                            self.origMouseX, self.origMouseY)
            # Nothing draggable found. return.
            if fromElement is None:
                self.dragging = NOT_DRAGGING
                return
            # Get the location for the dragging widget

            #self.absParent = None

            #self.absParent = self.dragWidget.getParent()
            #self.absLeft = DOM.getStyleAttribute(fromElement, 'left')

            #print self.absLeft
            #self.absTop = DOM.getStyleAttribute(fromElement, 'top')
            #print self.absTop
            #self.origTop = DOM.getAbsoluteTop(fromElement) + parent.getAbsoluteTop()
            #self.origLeft = DOM.getAbsoluteLeft(fromElement) + parent.getAbsoluteLeft()
            self.origTop = DOM.getAbsoluteTop(fromElement)
            self.origLeft = DOM.getAbsoluteLeft(fromElement)
            #self.glassTop = DOM.getAbsoluteTop(fromElement.offsetParent)
            #self.glassLeft = DOM.getAbsoluteTop(fromElement.offsetParent)
            position_absolute = DOM.getStyleAttribute(fromElement,
                                                      'position') == 'absolute'
            if position_absolute:
                self.dragLeftOffset = (
                    self.origMouseX -
                    DOM.getAbsoluteLeft(fromElement.offsetParent))
                self.dragTopOffset = (
                    self.origMouseY -
                    DOM.getAbsoluteTop(fromElement.offsetParent))
            else:
                self.dragLeftOffset = self.origMouseX - self.origLeft
                self.dragTopOffset = self.origMouseY - self.origTop

# self.setDragImage(fromElement,
#                             self.origMouseX - self.origLeft,
#                             self.origMouseY - self.origTop)
            self.dragDataStore.elements = [fromElement]
            dragStartEvent = self.fireDNDEvent('dragstart', None,
                                               self.dragWidget)
            if not isCanceled(dragStartEvent):
                self.initFeedbackImage()
                RootPanel().add(self.draggingImage)
                self.setDragImageLocation(x, y)
                self.dragging = ACTIVELY_DRAGGING
                GlassWidget.show(self)
        elif self.dragging == ACTIVELY_DRAGGING:
            try:
                doc().selection.empty()
            except:
                wnd().getSelection().removeAllRanges()

            self.setDragImageLocation(x, y)

            # If we are still working on the previous iteration, or if we have
            # done this recently, we'll wait for the next event.
            if self.dragBusy or time.time() - self.drag_time < 0.25:
                return

            self.doDrag(event, x, y)
            self.drag_time = time.time()
예제 #13
0
 def getWidgetTopPos(self, widget):
     self.checkWidgetParent(widget)
     return DOM.getStyleAttribute(widget.getElement(), "left")
예제 #14
0
파일: Label.py 프로젝트: Afey/pyjs
 def getWordWrap(self):
     ws = DOM.getStyleAttribute(self.getElement(), "whiteSpace")
     return ws != "nowrap"
예제 #15
0
 def getWidth(self):
     return DOM.getStyleAttribute(self.element, "width")
예제 #16
0
    def getWidgetPosition(self, widget):
        self.checkWidgetParent(widget)

        h = widget.getElement()
        return DOM.getStyleAttribute(h,
                                     "left"), DOM.getStyleAttribute(h, "top")
예제 #17
0
            if info.initialDraggableParent instanceof AbsolutePanel:
                info.initialDraggableParentLocation = WidgetLocation(widget,
                info.initialDraggableParent)
             elif info.initialDraggableParent instanceof HorizontalPanel:
                info.initialDraggableIndex = ((HorizontalPanel) info.initialDraggableParent).getWidgetIndex(widget)
             elif info.initialDraggableParent instanceof VerticalPanel:
                info.initialDraggableIndex = ((VerticalPanel) info.initialDraggableParent).getWidgetIndex(widget)
             elif info.initialDraggableParent instanceof FlowPanel:
                info.initialDraggableIndex = ((FlowPanel) info.initialDraggableParent).getWidgetIndex(widget)
             elif info.initialDraggableParent instanceof SimplePanel:
                # save nothing
             else:
                raise RuntimeException(
                "Unable to handle 'initialDraggableParent instanceof "
                + GWT.getTypeName(info.initialDraggableParent)
                + "'; Please create your own DragController and override saveDraggableLocationAndStyle() and restoreDraggableLocation()")
            
            
            info.initialDraggableMargin = DOM.getStyleAttribute(widget.getElement(), "margin")
            DOM.setStyleAttribute(widget.getElement(), "margin", "0px")
            savedWidgetInfoMap.put(widget, info)
        
    
    
    def getIntersectDropController(self, x, y):
        DropController dropController = dropControllerCollection.getIntersectDropController(x, y)
        return dropController is not None ? dropController : boundaryDropController
    


예제 #18
0
 def getTextAlignment(self, align):
     return DOM.getStyleAttribute(self.getElement(), "textAlign")
예제 #19
0
 def getStyleAttr(self, row, column, attr):
     elem = self.getElement(row, column)
     return DOM.getStyleAttribute(elem, attr)
예제 #20
0
 def getTextAlignment(self, align):
     return DOM.getStyleAttribute(self.getElement(), "textAlign")
예제 #21
0
파일: DNDHelper.py 프로젝트: Afey/pyjs
    def onMouseMove(self, sender, x, y):
        event = DOM.eventGetCurrentEvent()
        self.mouseEvent = event
        button = DOM.eventGetButton(event)
        if not button == Event.BUTTON_LEFT:
            return
## The following commented code lets the native dnd happen in IE. sucks.
## But it may enable dragging our widgets out of IE into other apps.
#        else:
#            try:
#                self.dragWidget.getElement().dragDrop()
#                return
#            except:
#                pass

        # Adjust x and y to absolute coordinates.
        x, y = eventCoordinates(event)

        if self.dragging == DRAGGING_NO_MOVEMENT_YET:
            self.origMouseX = x
            self.origMouseY = y
            self.currentDragOperation = 'none'
            fromElement = self.dragWidget.getElement()
            # Is the widget itself draggable?
            try:
                draggable = fromElement.draggable
            except:
                draggable = False
            # if not, find the draggable element at (x, y) in the widget
            if not draggable:
                fromElement = findDraggable(sender.getElement(),
                    self.origMouseX, self.origMouseY)
            # Nothing draggable found. return.
            if fromElement is None:
                self.dragging = NOT_DRAGGING
                return
            # Get the location for the dragging widget

            #self.absParent = None

                #self.absParent = self.dragWidget.getParent()
                #self.absLeft = DOM.getStyleAttribute(fromElement, 'left')

                #print self.absLeft
                #self.absTop = DOM.getStyleAttribute(fromElement, 'top')
                #print self.absTop
                #self.origTop = DOM.getAbsoluteTop(fromElement) + parent.getAbsoluteTop()
                #self.origLeft = DOM.getAbsoluteLeft(fromElement) + parent.getAbsoluteLeft()
            self.origTop = DOM.getAbsoluteTop(fromElement)
            self.origLeft = DOM.getAbsoluteLeft(fromElement)
            #self.glassTop = DOM.getAbsoluteTop(fromElement.offsetParent)
            #self.glassLeft = DOM.getAbsoluteTop(fromElement.offsetParent)
            position_absolute = DOM.getStyleAttribute(fromElement,
                                'position') == 'absolute'
            if position_absolute:
                self.dragLeftOffset = (self.origMouseX -
                                DOM.getAbsoluteLeft(fromElement.offsetParent))
                self.dragTopOffset = (self.origMouseY -
                                DOM.getAbsoluteTop(fromElement.offsetParent))
            else:
                self.dragLeftOffset = self.origMouseX - self.origLeft
                self.dragTopOffset = self.origMouseY - self.origTop

# self.setDragImage(fromElement,
#                             self.origMouseX - self.origLeft,
#                             self.origMouseY - self.origTop)
            self.dragDataStore.elements = [fromElement]
            dragStartEvent = self.fireDNDEvent('dragstart', None,
                                               self.dragWidget)
            if not isCanceled(dragStartEvent):
                self.initFeedbackImage()
                RootPanel().add(self.draggingImage)
                self.setDragImageLocation(x, y)
                self.dragging = ACTIVELY_DRAGGING
                GlassWidget.show(self)
        elif self.dragging == ACTIVELY_DRAGGING:
            try:
                doc().selection.empty()
            except:
                wnd().getSelection().removeAllRanges()

            self.setDragImageLocation(x, y)

            # If we are still working on the previous iteration, or if we have
            # done this recently, we'll wait for the next event.
            if self.dragBusy or time.time() - self.drag_time < 0.25:
                return

            self.doDrag(event, x, y)
            self.drag_time = time.time()
 def getWordWrap(self):
     ws = DOM.getStyleAttribute(self.getElement(), "whiteSpace")
     return ws != "nowrap"
예제 #23
0
파일: Label.py 프로젝트: emk/pyjamas
 def getWordWrap(self):
     return not (DOM.getStyleAttribute(self.getElement(), "whiteSpace") == "nowrap")
예제 #24
0
 def getStyleAttr(self, row, column, attr):
     elem = self.getElement(row, column)
     return DOM.getStyleAttribute(elem, attr)
예제 #25
0
파일: UIObject.py 프로젝트: sofianhw/pyjs
 def getHeight(self):
     return DOM.getStyleAttribute(self.element, "height")
예제 #26
0
 def getHeight(self):
     return DOM.getStyleAttribute(self.element, "height")
예제 #27
0
 def getCellVerticalAlignment(self, widget):
     td = self.getWidgetTd(widget)
     if td is None:
         return None
     return DOM.getStyleAttribute(td, "verticalAlign")
예제 #28
0
 def getWordWrap(self):
     return not (DOM.getStyleAttribute(self.getElement(), "whiteSpace")
                 == "nowrap")
예제 #29
0
파일: CellPanel.py 프로젝트: Afey/pyjs
 def getCellVerticalAlignment(self, widget):
     td = self.getWidgetTd(widget)
     if td is None:
         return None
     return DOM.getStyleAttribute(td, "verticalAlign")
예제 #30
0
파일: UIObject.py 프로젝트: sofianhw/pyjs
 def getWidth(self):
     return DOM.getStyleAttribute(self.element, "width")
예제 #31
0
 def getCellWordWrap(self, widget):
     td = DOM.getParent(widget.getElement())
     return DOM.getStyleAttribute(td, "whiteSpace") == "nowrap"