Exemplo n.º 1
0
Arquivo: Widget.py Projeto: Afey/pyjs
    def onBrowserEvent(self, event):

        # farm out the event to convenience handlers.
        # detect existence by checking for the listener lists of each
        # type of handler.  there's probably a better way to do this...
        if hasattr(self, "_clickListeners"):
            ClickHandler.onBrowserEvent(self, event)
        if hasattr(self, "_keyboardListeners"):
            KeyboardHandler.onBrowserEvent(self, event)
        if hasattr(self, "_mouseListeners"):
            MouseHandler.onBrowserEvent(self, event)
        if hasattr(self, "_mouseWheelListeners"):
            MouseWheelHandler.onBrowserEvent(self, event)
        if hasattr(self, "_focusListeners"):
            FocusHandler.onBrowserEvent(self, event)
        if hasattr(self, "_dragListeners"):
            DragHandler.onBrowserEvent(self, event)
        if hasattr(self, "_changeListeners"):
            ChangeHandler.onBrowserEvent(self, event)
        if hasattr(self, "_inputListeners"):
            InputHandler.onBrowserEvent(self, event)
        if hasattr(self, "_dropListeners"):
            DropHandler.onBrowserEvent(self, event)

        if self.contextMenu is None:
            return True

        type = DOM.eventGetType(event)
        if type == "contextmenu":
            DOM.eventCancelBubble(event, True)
            DOM.eventPreventDefault(event)
            self.contextMenu.onContextMenu(self)
            return False

        return True
    def onBrowserEvent(self, event):

        # farm out the event to convenience handlers.
        # detect existence by checking for the listener lists of each
        # type of handler.  there's probably a better way to do this...
        if hasattr(self, "_clickListeners"):
            ClickHandler.onBrowserEvent(self, event)
        if hasattr(self, "_keyboardListeners"):
            KeyboardHandler.onBrowserEvent(self, event)
        if hasattr(self, "_mouseListeners"):
            MouseHandler.onBrowserEvent(self, event)
        if hasattr(self, "_mouseWheelListeners"):
            MouseWheelHandler.onBrowserEvent(self, event)
        if hasattr(self, "_focusListeners"):
            FocusHandler.onBrowserEvent(self, event)
        if hasattr(self, "_dragListeners"):
            DragHandler.onBrowserEvent(self, event)
        if hasattr(self, "_changeListeners"):
            ChangeHandler.onBrowserEvent(self, event)
        if hasattr(self, "_inputListeners"):
            InputHandler.onBrowserEvent(self, event)
        if hasattr(self, "_dropListeners"):
            DropHandler.onBrowserEvent(self, event)

        if self.contextMenu is None:
            return True

        type = DOM.eventGetType(event)
        if type == "contextmenu":
            DOM.eventCancelBubble(event, True)
            DOM.eventPreventDefault(event)
            self.contextMenu.onContextMenu(self)
            return False

        return True
Exemplo n.º 3
0
    def __init__(self, element, **kwargs):
        self.currentEvent = None

        FocusWidget.__init__(self, element, **kwargs)
        ChangeHandler.__init__(self)
        InputHandler.__init__(self)
 def __init__(self, **kwargs):
     if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-ListBox"
     self.INSERT_AT_END = -1
     element = kwargs.pop('Element', None) or DOM.createSelect()
     FocusWidget.__init__(self, element, **kwargs)
     ChangeHandler.__init__(self)
Exemplo n.º 5
0
    def __init__(self, richText, _parent, **kwargs):

        self.isInText = False
        self.lastText = ""
        self.trigger = False
        self.lastRange = None
        self._parent = _parent

        # Timer for trying real time selection change stuff
        self.timerRange = None
        self.selTimer = Timer(notify=self.run)

        self.outer = VerticalPanel()
        self.topPanel = HorizontalPanel(BorderWidth=1)
        self.bottomPanel = HorizontalPanel()

        self.richText = richText
        self.basic = richText.getBasicFormatter()
        self.extended = richText.getExtendedFormatter()

        self.outer.add(self.topPanel)
        self.outer.add(self.bottomPanel)
        self.topPanel.setWidth("100%")
        self.topPanel.setHeight("20px")
        self.bottomPanel.setWidth("100%")

        kwargs['StyleName'] = kwargs.get('StyleName', "gwt-RichTextToolbar")

        Composite.__init__(self, self.outer, **kwargs)
        ClickHandler.__init__(self)
        ChangeHandler.__init__(self)

        if self.basic is not None:
            self.bold = self.createToggleButton(Images.bold,
                                            "bold")
            self.italic = self.createToggleButton(Images.italic,
                                            "italic")
            self.underline = self.createToggleButton(Images.underline,
                                            "underline")
            self.subscript = self.createToggleButton(Images.subscript,
                                            "subscript")
            self.superscript = self.createToggleButton(Images.superscript,
                                            "superscript")
            self.justifyLeft = self.createPushButton(Images.justifyLeft,
                                            "justify left")
            self.justifyCenter = self.createPushButton(Images.justifyCenter,
                                            "justify centre")
            self.justifyRight = self.createPushButton(Images.justifyRight,
                                            "justify right")
            self.topPanel.add(self.bold)
            self.topPanel.add(self.italic)
            self.topPanel.add(self.underline)
            self.topPanel.add(self.subscript)
            self.topPanel.add(self.superscript)
            self.topPanel.add(self.justifyLeft)
            self.topPanel.add(self.justifyCenter)
            self.topPanel.add(self.justifyRight)

        if self.extended is not None:
            self.strikethrough = self.createToggleButton(Images.strikeThrough,
                                            "strikethrough")
            self.indent = self.createPushButton(Images.indent,
                                            "indent")
            self.outdent = self.createPushButton(Images.outdent,
                                            "outdent")
            self.hr = self.createPushButton(Images.hr,
                                            "hr")
            self.ol = self.createPushButton(Images.ol,
                                            "ordered list")
            self.ul = self.createPushButton(Images.ul,
                                            "unordered list")
            self.insertImage = self.createPushButton(Images.insertImage,
                                            "insert image")
            self.createLink = self.createPushButton(Images.createLink,
                                            "create link")
            self.removeLink = self.createPushButton(Images.removeLink,
                                            "remove link")
            self.removeFormat = self.createPushButton(Images.removeFormat,
                                            "remove formatting")

            self.topPanel.add(self.strikethrough)
            self.topPanel.add(self.indent)
            self.topPanel.add(self.outdent)
            self.topPanel.add(self.hr)
            self.topPanel.add(self.ol)
            self.topPanel.add(self.ul)
            self.topPanel.add(self.insertImage)
            self.topPanel.add(self.createLink)
            self.topPanel.add(self.removeLink)
            self.topPanel.add(self.removeFormat)

        if self.basic is not None:
            self.hstyles = self.createHeadingStyleList("Headings")
            self.backColors = self.createColorList("Background")
            self.foreColors = self.createColorList("Foreground")
            self.fonts = self.createFontList()
            self.fontSizes = self.createFontSizes()
            self.bottomPanel.add(self.hstyles)
            self.bottomPanel.add(self.backColors)
            self.bottomPanel.add(self.foreColors)
            self.bottomPanel.add(self.fonts)
            self.bottomPanel.add(self.fontSizes)

        self.richText.addKeyboardListener(self)
        self.richText.addClickListener(self)
        self.richText.addFocusListener(self)
        self.richText.addMouseListener(self)
Exemplo n.º 6
0
    def __init__(self, richText, _parent, **kwargs):

        self.isInText = False
        self.lastText = ""
        self.trigger = False
        self.lastRange = None
        self._parent = _parent

        # Timer for trying real time selection change stuff
        self.timerRange = None
        self.selTimer = Timer(notify=self.run)

        self.outer = VerticalPanel()
        self.topPanel = HorizontalPanel(BorderWidth=1)
        self.bottomPanel = HorizontalPanel()

        self.richText = richText
        self.basic = richText.getBasicFormatter()
        self.extended = richText.getExtendedFormatter()

        self.outer.add(self.topPanel)
        self.outer.add(self.bottomPanel)
        self.topPanel.setWidth("100%")
        self.topPanel.setHeight("20px")
        self.bottomPanel.setWidth("100%")

        kwargs['StyleName'] = kwargs.get('StyleName', "gwt-RichTextToolbar")

        Composite.__init__(self, self.outer, **kwargs)
        ClickHandler.__init__(self)
        ChangeHandler.__init__(self)

        if self.basic is not None:
            self.bold = self.createToggleButton(Images.bold,
                                            "bold")
            self.italic = self.createToggleButton(Images.italic,
                                            "italic")
            self.underline = self.createToggleButton(Images.underline,
                                            "underline")
            self.subscript = self.createToggleButton(Images.subscript,
                                            "subscript")
            self.superscript = self.createToggleButton(Images.superscript,
                                            "superscript")
            self.justifyLeft = self.createPushButton(Images.justifyLeft,
                                            "justify left")
            self.justifyCenter = self.createPushButton(Images.justifyCenter,
                                            "justify centre")
            self.justifyRight = self.createPushButton(Images.justifyRight,
                                            "justify right")
            self.topPanel.add(self.bold)
            self.topPanel.add(self.italic)
            self.topPanel.add(self.underline)
            self.topPanel.add(self.subscript)
            self.topPanel.add(self.superscript)
            self.topPanel.add(self.justifyLeft)
            self.topPanel.add(self.justifyCenter)
            self.topPanel.add(self.justifyRight)

        if self.extended is not None:
            self.strikethrough = self.createToggleButton(Images.strikeThrough,
                                            "strikethrough")
            self.indent = self.createPushButton(Images.indent,
                                            "indent")
            self.outdent = self.createPushButton(Images.outdent,
                                            "outdent")
            self.hr = self.createPushButton(Images.hr,
                                            "hr")
            self.ol = self.createPushButton(Images.ol,
                                            "ordered list")
            self.ul = self.createPushButton(Images.ul,
                                            "unordered list")
            self.insertImage = self.createPushButton(Images.insertImage,
                                            "insert image")
            self.createLink = self.createPushButton(Images.createLink,
                                            "create link")
            self.removeLink = self.createPushButton(Images.removeLink,
                                            "remove link")
            self.removeFormat = self.createPushButton(Images.removeFormat,
                                            "remove formatting")

            self.topPanel.add(self.strikethrough)
            self.topPanel.add(self.indent)
            self.topPanel.add(self.outdent)
            self.topPanel.add(self.hr)
            self.topPanel.add(self.ol)
            self.topPanel.add(self.ul)
            self.topPanel.add(self.insertImage)
            self.topPanel.add(self.createLink)
            self.topPanel.add(self.removeLink)
            self.topPanel.add(self.removeFormat)

        if self.basic is not None:
            self.hstyles = self.createHeadingStyleList("Headings")
            self.backColors = self.createColorList("Background")
            self.foreColors = self.createColorList("Foreground")
            self.fonts = self.createFontList()
            self.fontSizes = self.createFontSizes()
            self.bottomPanel.add(self.hstyles)
            self.bottomPanel.add(self.backColors)
            self.bottomPanel.add(self.foreColors)
            self.bottomPanel.add(self.fonts)
            self.bottomPanel.add(self.fontSizes)

        self.richText.addKeyboardListener(self)
        self.richText.addClickListener(self)
        self.richText.addFocusListener(self)
        self.richText.addMouseListener(self)
Exemplo n.º 7
0
    def __init__(self, element, **kwargs):
        self.currentEvent = None

        FocusWidget.__init__(self, element, **kwargs)
        ChangeHandler.__init__(self)
        InputHandler.__init__(self)