def __init__(self, **ka):
        ka['StyleName'] = ka.get('StyleName', "gwt-Tree")

        self.root = None
        self.childWidgets = Set()
        self.curSelection = None
        self.focusable = None
        self.focusListeners = []
        self.mouseListeners = []
        self.imageBase = pygwt.getModuleBaseURL()
        self.keyboardListeners = []
        self.listeners = []
        self.lastEventType = ""

        element = ka.pop('Element', None) or DOM.createDiv()
        self.setElement(element)
        DOM.setStyleAttribute(self.getElement(), "position", "relative")
        self.focusable = Focus.createFocusable()
        # Hide focus outline in Mozilla/Webkit/Opera
        DOM.setStyleAttribute(self.focusable, "outline", "0px")
        # Hide focus outline in IE 6/7
        DOM.setElemAttribute(self.focusable, "hideFocus", "true")

        DOM.setStyleAttribute(self.focusable, "fontSize", "0")
        DOM.setStyleAttribute(self.focusable, "position", "absolute")
        DOM.setIntStyleAttribute(self.focusable, "zIndex", -1)
        DOM.appendChild(self.getElement(), self.focusable)

        self.root = RootTreeItem()
        self.root.setTree(self)

        Widget.__init__(self, **ka)

        self.sinkEvents(Event.ONMOUSEDOWN | Event.ONCLICK | Event.KEYEVENTS)
        DOM.sinkEvents(self.focusable, Event.FOCUSEVENTS)
 def onBrowserEvent(self, event):
     Widget.onBrowserEvent(self, event)
     event_type = DOM.eventGetType(event)
     if event_type == "click":
         DOM.eventPreventDefault(event)
         if self.targetHistoryToken is not None:
             History.newItem(self.targetHistoryToken)
Ejemplo n.º 3
0
 def onLoad(self):
     self.tabs = TabPanel(FlowTabBar())
     self.tabs.getTabBar().addStyleName('shortcuts')
     self.tabs.getDeckPanel().addStyleName('blockDrawer')
     #------------------------------------------------------------------------------------------
     self.input = CategoriesHardware.Input()
     self.tabs.add(self.input,
                   CategoriesHardware.TabTitle(_('Input'), 'input_btn'))
     #------------------------------------------------------------------------------------------
     self.output = CategoriesHardware.Output()
     self.tabs.add(self.output,
                   CategoriesHardware.TabTitle(_('Output'), 'output_btn'))
     #------------------------------------------------------------------------------------------
     self.tabs.selectTab(0)
     panel = Element(Element=DOM.createDiv(), Width='100%', Height='100%')
     panel.append(self.tabs)
     #------------------------------------------------------------------------------------------
     self.trashCan = Widget(Element=DOM.createDiv(),
                            StyleName='trashCanClose')
     panel.append(self.trashCan)
     self.add(panel)
     #------------------------------------------------------------------------------------------
     bottom = Element(Element=DOM.createDiv(), StyleName='drawer_bottom')
     resize = ResizeWidget(self.parent, 200, 600)
     resize.addStyleName('float_right')
     bottom.append(resize)
     self.add(bottom)
     self.setCellHeight(bottom, '20px')
Ejemplo n.º 4
0
 def __init__(self, element, **kwargs):
     self.setElement(element)
     Widget.__init__(self, **kwargs)
     FocusHandler.__init__(self)
     KeyboardHandler.__init__(self)
     ClickHandler.__init__(self)
     MouseHandler.__init__(self)
Ejemplo n.º 5
0
    def __init__(self, vertical=False, **kwargs):
        self.setVertical(kwargs.pop('Vertical', vertical))
        if 'StyleName' not in kwargs or kwargs['StyleName'] == 'gwt-MenuBar':
            kwargs['StyleName'] = self.getDefaultStyleName()
        self.body = None
        self.items = []
        self.parentMenu = None
        self.popup = None
        self.selectedItem = None
        self.shownChildMenu = None
        self.autoOpen = False

        if kwargs.has_key('Element'):
            table = kwargs.pop('Element')
            fc = DOM.getFirstChild(table)
            if fc:
                self.body = fc
            else:
                self.body = DOM.createTBody()
                DOM.appendChild(table, self.body)
        else:
            table = DOM.createTable()
        self.body = DOM.createTBody()
        DOM.appendChild(table, self.body)

        outer = DOM.createDiv()
        DOM.appendChild(outer, table)
        self.setElement(outer)
        Widget.__init__(self, **kwargs)
Ejemplo n.º 6
0
    def draw(self):
        if self.classIcon != "":
            self.icon = Element(Element=DOM.createElement("i"),
                                StyleName=self.classIcon)
            self.add(self.icon)

        if self.rootPanel is None:
            self.popup = PopupPanel(autoHide=True,
                                    modal=False,
                                    rootpanel=self,
                                    StyleName='dropdown_btn')
            DOM.setStyleAttribute(self.popup.element, "position", "static")
        else:  #o poup nao esta fechando!
            self.popup = PopupPanel(autoHide=True,
                                    modal=False,
                                    rootpanel=self.rootPanel,
                                    StyleName='dropdown_btn')

        self.dropdown_arrow = Element(Element=DOM.createElement('div'),
                                      StyleName='dropdown_arrow')
        self.title = Element(Element=DOM.createSpan(), StyleName='title')
        DOM.setInnerHTML(self.title.getElement(), self.text)
        self.add(self.title)
        self.add(Widget(Element=DOM.createDiv(), StyleName='r'))
        self.add(Widget(Element=DOM.createDiv(), StyleName='coverup'))
        self.popup.add(self.dropdown_arrow)
Ejemplo n.º 7
0
    def __init__(self, **ka):
        ka['StyleName'] = ka.get('StyleName', "gwt-Tree")

        self.root = None
        self.childWidgets = Set()
        self.curSelection = None
        self.focusable = None
        self.focusListeners = []
        self.mouseListeners = []
        self.imageBase = pygwt.getModuleBaseURL()
        self.keyboardListeners = []
        self.listeners = []
        self.lastEventType = ""

        element = ka.pop('Element', None) or DOM.createDiv()
        self.setElement(element)
        DOM.setStyleAttribute(self.getElement(), "position", "relative")
        self.focusable = Focus.createFocusable()
        # Hide focus outline in Mozilla/Webkit/Opera
        DOM.setStyleAttribute(self.focusable, "outline", "0px")
        # Hide focus outline in IE 6/7
        DOM.setElemAttribute(self.focusable, "hideFocus", "true");

        DOM.setStyleAttribute(self.focusable, "fontSize", "0")
        DOM.setStyleAttribute(self.focusable, "position", "absolute")
        DOM.setIntStyleAttribute(self.focusable, "zIndex", -1)
        DOM.appendChild(self.getElement(), self.focusable)

        self.root = RootTreeItem()
        self.root.setTree(self)

        Widget.__init__(self, **ka)

        self.sinkEvents(Event.ONMOUSEDOWN | Event.ONCLICK | Event.KEYEVENTS)
        DOM.sinkEvents(self.focusable, Event.FOCUSEVENTS)
Ejemplo n.º 8
0
 def onDragStart(self, event):
     dt = event.dataTransfer
     target = DOM.eventGetTarget(event)
     target = Widget(Element=target)
     id = target.getID()
     dt.setData("Text", "Dropped %s" % target.getID())
     dt.effectAllowed = 'copy'
     if id == 'imgdrag1':
         parent = self.getParent()
         while not hasattr(parent, 'h2'):
             parent = parent.getParent()
         dt.setDragImage(parent.h2.getElement(), 10, 10)
     elif id == 'imgdrag2':
         dt.setDragImage(doc().getElementById('logo'), 10, 10)
     elif id == 'imgdrag3':
         # OK, it's a bit of a cheat, but the following works on current
         # Opera, IE, Firefox, Safari, Chrome.
         ctx = GWTCanvas(50, 50)
         self.makeCanvasImg(ctx)
         try:
             img = DOM.createImg()
             DOM.setAttribute(img, 'src', ctx.canvas.toDataURL())
             dt.setDragImage(img, 25, 25)
         except:
             dt.setDragImage(ctx.canvas, 25, 25)
Ejemplo n.º 9
0
 def __init__(self, element=None):
     Widget.__init__(self, Element=DOM.createElement('div'))
     self.children = []
     if element is not None:
         clone = cloneElement(element)
         self.addChild(clone)
     self.setStyleAttribute('position', 'absolute')
Ejemplo n.º 10
0
    def __init__(self, width=0, height=0):
        Widget.__init__(self)
        self.context = None
        
        self.setElement(DOM.createDiv())
        canvas = DOM.createElement("canvas")
        self.setWidth(width)
        self.setHeight(height)
        
        canvas.width=width
        canvas.height=height
        
        DOM.appendChild(self.getElement(), canvas)
        self.setStyleName("gwt-Canvas")
        
        self.init()
        
        self.context.fillStyle = "black"
        self.context.strokeStyle = "black"

        self.focusable = None
        self.focusable = Focus.createFocusable()
        
        self.focusListeners = []
        self.clickListeners = []
        self.mouseListeners = []
        self.keyboardListeners = []
        
        DOM.appendChild(self.getElement(), self.focusable)
        DOM.sinkEvents(canvas, Event.ONCLICK | Event.MOUSEEVENTS | DOM.getEventsSunk(canvas))
        DOM.sinkEvents(self.focusable, Event.FOCUSEVENTS | Event.KEYEVENTS)
Ejemplo n.º 11
0
 def __init__(self, **kw):
     if (not hasattr(self, 'attached')) or kw:
         Widget.__init__(self, **kw)
     MouseHandler.__init__(self)
     self.addMouseListener(DNDHelper.dndHelper)
     DragHandler.__init__(self)
     self.addDragListener(self)
Ejemplo n.º 12
0
 def onDragStart(self, event):
     dt = event.dataTransfer
     target = DOM.eventGetTarget(event)
     target = Widget(Element=target)
     id = target.getID()
     dt.setData("Text", "Dropped %s" % target.getID())
     dt.effectAllowed = 'copy'
     if id == 'imgdrag1':
         parent = self.getParent()
         while not hasattr(parent, 'h2'):
             parent = parent.getParent()
         dt.setDragImage(parent.h2.getElement(), 10, 10)
     elif id == 'imgdrag2':
         dt.setDragImage(doc().getElementById('logo'), 10, 10)
     elif id == 'imgdrag3':
         # OK, it's a bit of a cheat, but the following works on current
         # Opera, IE, Firefox, Safari, Chrome.
         ctx = GWTCanvas(50, 50)
         self.makeCanvasImg(ctx)
         try:
             img = DOM.createImg()
             DOM.setAttribute(img, 'src', ctx.canvas.toDataURL())
             dt.setDragImage(img, 25, 25)
         except:
             dt.setDragImage(ctx.canvas, 25, 25)
Ejemplo n.º 13
0
 def __init__(self, **kw):
     if (not hasattr(self, 'attached')) or kw:
         Widget.__init__(self, **kw)
     MouseHandler.__init__(self)
     self.addMouseListener(DNDHelper.dndHelper)
     DragHandler.__init__(self)
     self.addDragListener(self)
Ejemplo n.º 14
0
 def show(self):
     if self.hasBackground:
         self.background = Widget(Element=DOM.createDiv(), StyleName='diaglog_coverup')
         self.background.setHeight(RootPanel().getOffsetHeight())
         RootPanel().add(self.background)
     DialogBox.show(self)
     
Ejemplo n.º 15
0
    def __init__(self, vertical=False, **kwargs):
        self.setVertical(kwargs.pop('Vertical', vertical))
        if 'StyleName' not in kwargs or kwargs['StyleName'] == 'gwt-MenuBar':
            kwargs['StyleName'] = self.getDefaultStyleName()
        self.body = None
        self.items = []
        self.parentMenu = None
        self.popup = None
        self.selectedItem = None
        self.shownChildMenu = None
        self.autoOpen = False
        self.itemsPerRow = None

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

        outer = DOM.createDiv()
        DOM.appendChild(outer, table)
        self.setElement(outer)
        Widget.__init__(self, **kwargs)
Ejemplo n.º 16
0
 def __init__(self, element=None):
     Widget.__init__(self, Element=DOM.createElement('div'))
     self.children = []
     if element is not None:
         clone = cloneElement(element)
         self.addChild(clone)
     self.setStyleAttribute('position', 'absolute')
Ejemplo n.º 17
0
 def __init__(self, element, **kwargs):
     self.setElement(element)
     Widget.__init__(self, **kwargs)
     FocusHandler.__init__(self)
     KeyboardHandler.__init__(self)
     ClickHandler.__init__(self)
     MouseHandler.__init__(self)
Ejemplo n.º 18
0
 def __init__(self, **kwargs):
     element = kwargs.pop('Element', None) or DOM.createAnchor()
     kwargs['StyleName'] = kwargs.pop('StyleName', 'gwt-Anchor')
     _Attributes.__init__(self, element)
     self.setElement(element)
     self.widget = None
     Widget.__init__(self, **kwargs)
     ClickHandler.__init__(self)
Ejemplo n.º 19
0
 def __init__(self, **kwargs):
     element = kwargs.pop('Element', None) or DOM.createAnchor()
     kwargs['StyleName'] = kwargs.pop('StyleName', 'gwt-Anchor')
     _Attributes.__init__(self, element)
     self.setElement(element)
     self.widget = None
     Widget.__init__(self, **kwargs)
     ClickHandler.__init__(self)
Ejemplo n.º 20
0
 def onBrowserEvent(self, event):
     Widget.onBrowserEvent(self, event)
     type = DOM.eventGetType(event)
     if type == "load":
         for listener in self.loadListeners:
             listener.onImageLoad(self)
     elif type == "error":
         for listener in self.loadListeners:
             listener.onImageError(self)
Ejemplo n.º 21
0
 def onDragOver(self, event):
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     dt = event.dataTransfer
     dt.dropEffect = 'copy'
     class_names = t.getStyleName()
     if class_names is not None:
         if 'drophere' in class_names:
             DOM.eventPreventDefault(event)
Ejemplo n.º 22
0
    def __init__(self, width=0, height=0):
        """ Standard initialiser.

            'width' and 'height' are the dimensions to use for this whitespace,
            in pixels.
        """
        Widget.__init__(self)
        self.setElement(DOM.createElement('div'))
        self.setPixelSize(width, height)
Ejemplo n.º 23
0
 def onDragOver(self, event):
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     dt = event.dataTransfer
     dt.dropEffect = 'copy'
     class_names = t.getStyleName()
     if class_names is not None:
         if 'drophere' in class_names:
             DOM.eventPreventDefault(event)
Ejemplo n.º 24
0
    def __init__(self, width=0, height=0):
        """ Standard initialiser.

            'width' and 'height' are the dimensions to use for this whitespace,
            in pixels.
        """
        Widget.__init__(self)
        self.setElement(DOM.createElement('div'))
        self.setPixelSize(width, height)
Ejemplo n.º 25
0
 def __init__(self, widget=None, **kwargs):
     # this is all a bit awkward!  initialising
     # stuff that really should be done in Widget.__init__
     # allows us to call self.initWidget here and thus
     # have **kwargs applied afterwards.
     self.widget = None
     self.attached = None
     if widget is not None:
         self.initWidget(widget)
     Widget.__init__(self, **kwargs)
Ejemplo n.º 26
0
 def __init__(self, widget=None, **kwargs):
     # this is all a bit awkward!  initialising
     # stuff that really should be done in Widget.__init__
     # allows us to call self.initWidget here and thus
     # have **kwargs applied afterwards.
     self.widget = None
     self.attached = None
     if widget is not None:
         self.initWidget(widget)
     Widget.__init__(self, **kwargs)
Ejemplo n.º 27
0
 def onDragLeave(self, event):
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     try:
         class_names = t.getStyleName()
     except:
         class_names = None
     if class_names is not None:
         if 'drophere' in class_names:
             t.removeStyleName('dragover')
Ejemplo n.º 28
0
 def onDragLeave(self, event):
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     try:
         class_names = t.getStyleName()
     except:
         class_names = None
     if class_names is not None:
         if 'drophere' in class_names:
             t.removeStyleName('dragover')
Ejemplo n.º 29
0
    def __init__(self, url="", **kwargs):
        if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-Image"
        if url: kwargs['Url'] = url

        self.setElement(kwargs.pop('Element', None) or DOM.createImg())
        Widget.__init__(self, **kwargs)
        MouseHandler.__init__(self)
        ClickHandler.__init__(self)
        self.sinkEvents(Event.ONLOAD | Event.ONERROR)
        self.loadListeners = []
Ejemplo n.º 30
0
 def onDrop(self, event):
     dt = event.dataTransfer
     text = dt.getData('Text')
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     class_names = t.getStyleName()
     DOM.eventPreventDefault(event)
     if class_names is not None:
         if 'drophere' in class_names:
             self.addMessage('%s onto %s' % (text, target.id))
             return
Ejemplo n.º 31
0
 def onDragEnter(self, event):
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     try:
         class_names = t.getStyleName()
     except:
         class_names = None
     if class_names is not None:
         if 'drophere' in class_names:
             t.addStyleName('dragover')
             DOM.eventPreventDefault(event)
Ejemplo n.º 32
0
 def onDrop(self, event):
     dt = event.dataTransfer
     text = dt.getData('Text')
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     class_names = t.getStyleName()
     if class_names is not None:
         if 'drophere' in class_names:
             self.addMessage('%s onto %s<br>effectAllowed=%s, dropEffect=%s'
             % (text, target.id, dt.effectAllowed, dt.dropEffect))
             DOM.eventPreventDefault(event)
Ejemplo n.º 33
0
 def onDragOver(self, event):
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     class_names = t.getStyleName()
     if class_names is not None:
         if 'drophere' in class_names:
             dt = event.dataTransfer
             id = Widget(Element=target).getID()
             drop_effect = self.data[int(id[-1])]
             dt.dropEffect = drop_effect
             DOM.eventPreventDefault(event)
Ejemplo n.º 34
0
 def onDragEnter(self, event):
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     try:
         class_names = t.getStyleName()
     except:
         class_names = None
     if class_names is not None:
         if 'drophere' in class_names:
             t.addStyleName('dragover')
             DOM.eventPreventDefault(event)
Ejemplo n.º 35
0
 def onDragOver(self, event):
     target = DOM.eventGetTarget(event)
     t = Widget(Element=target)
     class_names = t.getStyleName()
     if class_names is not None:
         if 'drophere' in class_names:
             dt = event.dataTransfer
             id = Widget(Element=target).getID()
             drop_effect = self.data[int(id[-1])]
             dt.dropEffect = drop_effect
             DOM.eventPreventDefault(event)
    def __init__(self, text=None, wordWrap=True, **kwargs):
        kwargs['StyleName'] = kwargs.get('StyleName', "gwt-Label")
        kwargs['WordWrap'] = kwargs.get('WordWrap', wordWrap)
        kwargs['HorizontalAlignment'] = kwargs.get('HorizontalAlignment', "")
        if text:
            kwargs['Text'] = text
        self.setElement(kwargs.pop('Element', None) or DOM.createDiv())
        self.horzAlign = ""

        Widget.__init__(self, **kwargs)
        MouseHandler.__init__(self)
        ClickHandler.__init__(self)
Ejemplo n.º 37
0
Archivo: Label.py Proyecto: Afey/pyjs
    def __init__(self, text=None, wordWrap=True, **kwargs):
        kwargs['StyleName'] = kwargs.get('StyleName', "gwt-Label")
        kwargs['WordWrap'] = kwargs.get('WordWrap', wordWrap)
        kwargs['HorizontalAlignment'] = kwargs.get('HorizontalAlignment', "")
        if text:
            kwargs['Text'] = text
        self.setElement(kwargs.pop('Element', None) or DOM.createDiv())
        self.horzAlign = ""

        Widget.__init__(self, **kwargs)
        MouseHandler.__init__(self)
        ClickHandler.__init__(self)
Ejemplo n.º 38
0
    def onBrowserEvent(self, event):
        etype = DOM.eventGetType(event)

        if etype == "click":
            e = DOM.eventGetTarget(event)
            if not self.shouldTreeDelegateFocusToElement(e) and \
                            self.curSelection is not None:
                self.setFocus(True)
        elif etype in MouseListener.MOUSE_EVENTS:
            if etype == "mousedown":
                self.elementClicked(self.root, DOM.eventGetTarget(event))
            MouseListener.fireMouseEvent(self.mouseListeners, self, event)
        elif etype == "blur" or etype == "focus":
            FocusListener.fireFocusEvent(self.focusListeners, self, event)
        elif etype == "keydown":
            if self.curSelection is None:
                if self.root.getChildCount() > 0:
                    self.onSelection(self.root.getChild(0), True)
                Widget.onBrowserEvent(self, event)
                return

            if self.lastEventType == "keydown":
                return

            keycode = DOM.eventGetKeyCode(event)
            if keycode == KeyboardListener.KEY_UP:
                self.moveSelectionUp(self.curSelection, True)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_DOWN:
                self.moveSelectionDown(self.curSelection, True)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_LEFT:
                if self.curSelection.getState():
                    self.curSelection.setState(False)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_RIGHT:
                if not self.curSelection.getState():
                    self.curSelection.setState(True)
                DOM.eventPreventDefault(event)
        elif etype == "keyup":
            if DOM.eventGetKeyCode(event) == KeyboardListener.KEY_TAB:
                chain = []
                self.collectElementChain(chain, self.getElement(),
                                         DOM.eventGetTarget(event))
                item = self.findItemByChain(chain, 0, self.root)
                if item != self.getSelectedItem():
                    self.setSelectedItem(item, True)
        elif etype == "keypress":
            KeyboardListener.fireKeyboardEvent(self.keyboardListeners,
                                               self, event)

        Widget.onBrowserEvent(self, event)
        self.lastEventType = etype
Ejemplo n.º 39
0
    def onBrowserEvent(self, event):
        etype = DOM.eventGetType(event)

        if etype == "click":
            e = DOM.eventGetTarget(event)
            if not self.shouldTreeDelegateFocusToElement(e) and \
                            self.curSelection is not None:
                self.setFocus(True)
        elif etype in MouseListener.MOUSE_EVENTS:
            if etype == "mousedown":
                self.elementClicked(self.root, DOM.eventGetTarget(event))
            MouseListener.fireMouseEvent(self.mouseListeners, self, event)
        elif etype == "blur" or etype == "focus":
            FocusListener.fireFocusEvent(self.focusListeners, self, event)
        elif etype == "keydown":
            if self.curSelection is None:
                if self.root.getChildCount() > 0:
                    self.onSelection(self.root.getChild(0), True)
                Widget.onBrowserEvent(self, event)
                return

            if self.lastEventType == "keydown":
                return

            keycode = DOM.eventGetKeyCode(event)
            if keycode == KeyboardListener.KEY_UP:
                self.moveSelectionUp(self.curSelection, True)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_DOWN:
                self.moveSelectionDown(self.curSelection, True)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_LEFT:
                if self.curSelection.getState():
                    self.curSelection.setState(False)
                DOM.eventPreventDefault(event)
            elif keycode == KeyboardListener.KEY_RIGHT:
                if not self.curSelection.getState():
                    self.curSelection.setState(True)
                DOM.eventPreventDefault(event)
        elif etype == "keyup":
            if DOM.eventGetKeyCode(event) == KeyboardListener.KEY_TAB:
                chain = []
                self.collectElementChain(chain, self.getElement(),
                                         DOM.eventGetTarget(event))
                item = self.findItemByChain(chain, 0, self.root)
                if item != self.getSelectedItem():
                    self.setSelectedItem(item, True)
        elif etype == "keypress":
            KeyboardListener.fireKeyboardEvent(self.keyboardListeners, self,
                                               event)

        Widget.onBrowserEvent(self, event)
        self.lastEventType = etype
Ejemplo n.º 40
0
 def __init__(self, Shape, Coords, **kwargs):
     if not kwargs.has_key('Href'):
         kwargs['Href'] = ""
     kwargs['Shape'] = Shape
     kwargs['Coords'] = Coords
     if kwargs.has_key('Element'):
         element = kwargs.pop('Element')
     else:
         element = DOM.createElement("area")
     self.setElement(element)
     Widget.__init__(self, **kwargs)
     MouseHandler.__init__(self, preventDefault=True)
     ClickHandler.__init__(self, preventDefault=True)
    def __init__(self, name=None, value=None, **kwargs):

        name = kwargs.get("Name", name)
        if name is not None:
            kwargs['Name'] = name
        value = kwargs.get("Value", value)
        if value is not None:
            kwargs['Value'] = kwargs.get("Value", value)
        element = kwargs.pop('Element', None) or DOM.createElement("input")
        self.setElement(element)
        DOM.setAttribute(element, "type", "hidden")

        Widget.__init__(self, **kwargs)
Ejemplo n.º 42
0
    def __init__(self, width, height):
        """ Standard initialiser.

            'width' and 'height' are the dimensions to use for the canvas, in
            pixels.
        """
        Widget.__init__(self)

        element = DOM.createDiv()
        self.setElement(element)
        self.setPixelSize(width, height)
        JS("""
           this._canvas = $wnd.Raphael(element, width, height);
        """)
Ejemplo n.º 43
0
def _fill_panel(panel, content, ui, item_handler=None):
    """ Fill a page based container panel with content.
    """
    active = 0

    for index, item in enumerate(content):
        page_name = item.get_label(ui)
        if page_name == "":
            page_name = "Page %d" % index

        if isinstance(item, Group):
            if item.selected:
                active = index

            gp = _GroupPanel(item, ui, suppress_label=True)
            page = gp.control
            sub_page = gp.sub_control

            # If the result is the same type with only one page, collapse it
            # down into just the page.
            if type(sub_page) is type(panel) and sub_page.count() == 1:
                new = sub_page.getWidget(0)
                if isinstance(panel, TabPanel):
                    sub_page.remove(sub_page.getWidget(0))
                else:
                    sub_page.remove(sub_page.getWidget(0))
            elif isinstance(page, Widget):
                new = page
            else:
                new = Widget()
                new.setLayoutData(page)

            layout = new.getLayoutData()
#            if layout is not None:
#                layout.setAlignment(QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)

        else:
            new = Widget()
            layout = VerticalPanel()
            layout.setBorderWidth(0)
            item_handler(item, layout)

        # Add the content.
        if isinstance(panel, TabPanel):
            panel.add(new, page_name)
        else:
            panel.add(new)

    panel.selectTab( active )
Ejemplo n.º 44
0
 def __init__(self, coordX=300, coordY=150, pixelX=300, pixelY=150):
     
     """
     * Impl Instance. Compiler should statify all the methods, so we do not end up
     * with duplicate code for each canvas instance.
     """
     self.impl = self.getCanvasImpl()
     
     self.coordHeight = 0
     self.coordWidth = 0
     Widget.__init__(self)
     self.setElement(self.impl.createElement())
     self.setPixelWidth(pixelX)
     self.setPixelHeight(pixelY)
     self.setCoordSize(coordX, coordY)
Ejemplo n.º 45
0
    def __init__(self, width, height):
        """ Standard initialiser.

            'width' and 'height' are the dimensions to use for the canvas, in
            pixels.
        """
        Widget.__init__(self)
        #self.getParent()

        element = DOM.createDiv()
        self.setElement(element)
        self.setPixelSize(width, height)
        JS("""
           this['_canvas'] = $wnd['Raphael'](@{{element}}, @{{width}}, @{{height}});
        """)
        RaphaelEventHandler.__init__(self, self.element)
Ejemplo n.º 46
0
    def __init__(self, width, height):
        """ Standard initialiser.

            'width' and 'height' are the dimensions to use for the canvas, in
            pixels.
        """
        Widget.__init__(self)
        #self.getParent()

        element = DOM.createDiv()
        self.setElement(element)
        self.setPixelSize(width, height)
        JS("""
           this._canvas = $wnd.Raphael(@{{element}}, @{{width}}, @{{height}});
        """)
        RaphaelEventHandler.__init__(self,self.element)
Ejemplo n.º 47
0
    def draw(self):
        Popup.draw(self)

        namePanel = HorizontalPanel()
        namePanel.add(Label(_('Name') + ':'))
        self.textBox = TextBox()
        self.textBox.setMaxLength(15)
        self.textBox.setStyleAttribute('marginLeft', 10)
        namePanel.add(self.textBox)
        self.center.add(namePanel)

        self.choose = ChooseTypeVarPanel()
        self.center.add(self.choose)

        self.textBox.addInputListener(self)

        self.message = Element(Element=DOM.createDiv())
        self.message.add(Widget(Element=DOM.createDiv(),
                                StyleName='not_image'))
        self.message.add(
            Label(text=_('Name already used'),
                  wordWrap=False,
                  StyleName='not_message'))

        self.onInput()
Ejemplo n.º 48
0
    def __init__(self, width, height):
        """ Standard initialiser.

            'width' and 'height' are the dimensions to use for the canvas, in
            pixels.
        """
        Widget.__init__(self)

        element = DOM.createDiv()
        self.setElement(element)
        self.setPixelSize(width, height)
        JS(
            """
           this._canvas = $wnd.Raphael(element, width, height);
        """
        )
Ejemplo n.º 49
0
 def draw(self):
     if self.classIcon != "":
         self.icon = Element(Element=DOM.createElement("i"), StyleName=self.classIcon)
         self.add(self.icon)
     self.title = Element(Element=DOM.createSpan(), StyleName='title')
     DOM.setInnerHTML(self.title.getElement(), self.text)
     self.add(self.title)     
     self.add(Widget(Element=DOM.createDiv(), StyleName='r'))
Ejemplo n.º 50
0
    def onBrowserEvent(self, event):
        Widget.onBrowserEvent(self, event)

        item = self.findItem(DOM.eventGetTarget(event))
        if item is None:
            return False

        type = DOM.eventGetType(event)
        if type == "click":
            self.doItemAction(item, True)
            return True
        elif type == "mouseover":
            self.itemOver(item)
        elif type == "mouseout":
            self.itemOver(None)

        return False
Ejemplo n.º 51
0
    def onBrowserEvent(self, event):
        Widget.onBrowserEvent(self, event)

        item = self.findItem(DOM.eventGetTarget(event))
        if item is None:
            return False

        type = DOM.eventGetType(event)
        if type == "click":
            self.doItemAction(item, True)
            return True
        elif type == "mouseover":
            self.itemOver(item)
        elif type == "mouseout":
            self.itemOver(None)

        return False
Ejemplo n.º 52
0
 def onLoad(self):
     self.tabs = TabPanel(FlowTabBar())
     # self.tabs.getTabBar().addStyleName('shortcuts') === gwt-TabBar
     # self.tabs.getDeckPanel().addStyleName('blockDrawer') === gwt-TabPanelBottom{
     #------------------------------------------------------------------------------------------
     self.control = CategoriesBlock.Control()
     self.tabs.add(self.control,
                   CategoriesBlock.TabTitle(_('Control'), 'control_btn'))
     #------------------------------------------------------------------------------------------
     self.operators = CategoriesBlock.Operators()
     self.tabs.add(
         self.operators,
         CategoriesBlock.TabTitle(_('Operators'), 'operators_btn'))
     #------------------------------------------------------------------------------------------
     self.input = CategoriesBlock.Input()
     self.tabs.add(self.input,
                   CategoriesBlock.TabTitle(_('Input'), 'input_btn'))
     #------------------------------------------------------------------------------------------
     self.output = CategoriesBlock.Output()
     self.tabs.add(self.output,
                   CategoriesBlock.TabTitle(_('Output'), 'output_btn'))
     #------------------------------------------------------------------------------------------
     self.utilities = CategoriesBlock.Setup()
     self.tabs.add(self.utilities,
                   CategoriesBlock.TabTitle(_('Utilities'), 'config_btn'))
     #------------------------------------------------------------------------------------------
     self.variables = CategoriesBlock.Variables()
     self.tabs.add(
         self.variables,
         CategoriesBlock.TabTitle(_('Variables'), 'variables_btn'))
     #------------------------------------------------------------------------------------------
     self.tabs.selectTab(0)
     panel = Element(Element=DOM.createDiv(), Width='100%', Height='100%')
     panel.append(self.tabs)
     #------------------------------------------------------------------------------------------
     self.trashCan = Widget(Element=DOM.createDiv(),
                            StyleName='trashCanClose')
     panel.append(self.trashCan)
     self.add(panel)
     #------------------------------------------------------------------------------------------
     bottom = Element(Element=DOM.createDiv(), StyleName='drawer_bottom')
     resize = ResizeWidget(self.parent, 200, 510)
     resize.addStyleName('float_right')
     bottom.append(resize)
     self.add(bottom)
     self.setCellHeight(bottom, '20px')
Ejemplo n.º 53
0
    def __init__(self, text):
        Widget.__init__(self)
        self.imageBase = pygwt.getModuleBaseURL()

        self.root = DOM.createTable()
        self.tbody = DOM.createTBody()
        self.tr = DOM.createTR()
        self.imageTD = DOM.createTD()
        self.labelTD = DOM.createTD()
        self.imgElem = DOM.createImg()

        self.setElement(self.root)
        DOM.appendChild(self.root, self.tbody)
        DOM.appendChild(self.tbody, self.tr)
        DOM.appendChild(self.tr, self.imageTD)
        DOM.appendChild(self.tr, self.labelTD)
        DOM.appendChild(self.imageTD, self.imgElem)

        self.setText(text)
Ejemplo n.º 54
0
    def __init__(self, **kwargs):

        self.glassListeners = []
        self.showing = False
        self.mousehandler = False

        if not 'StyleName' in kwargs:
            kwargs['StyleName'] = "gwt-GlassWidget"

        if 'Element' in kwargs:
            element = kwargs.pop('Element')
        else:
            element = DOM.createDiv()

        self.setElement(element)
        Widget.__init__(self, **kwargs)
        MouseHandler.__init__(self)
        self.setzIndex(1000000)
        self.addMouseListener(self)
Ejemplo n.º 55
0
    def __init__(self, text, images=True):
        Widget.__init__(self)
        self.setImageBase(images)

        self.root = DOM.createTable()
        self.tbody = DOM.createTBody()
        self.tr = DOM.createTR()
        self.imageTD = DOM.createTD()
        self.labelTD = DOM.createTD()
        self.imgElem = DOM.createImg()

        self.setElement(self.root)
        DOM.appendChild(self.root, self.tbody)
        DOM.appendChild(self.tbody, self.tr)
        DOM.appendChild(self.tr, self.imageTD)
        DOM.appendChild(self.tr, self.labelTD)
        DOM.appendChild(self.imageTD, self.imgElem)

        self.setText(text)