def setWidth(self, width, unit=None):
        if unit is not None:
            from muntjac.terminal.gwt.server.component_size_validator import \
                ComponentSizeValidator  # FIXME: circular import

            # child tree repaints may be needed, due to our fall back support
            # for invalid relative sizes
            dirtyChildren = None
            childrenMayBecomeUndefined = False
            if (self.getWidth() == self.SIZE_UNDEFINED
                    and width != self.SIZE_UNDEFINED):
                # children currently in invalid state may need repaint
                dirtyChildren = self.getInvalidSizedChildren(False)

            elif ((width == self.SIZE_UNDEFINED
                    and self.getWidth() != self.SIZE_UNDEFINED)
                  or (unit == self.UNITS_PERCENTAGE
                    and self.getWidthUnits() != self.UNITS_PERCENTAGE
                    and not ComponentSizeValidator.parentCanDefineWidth(self))):

                # relative width children may get to invalid state if width
                # becomes invalid. Width may also become invalid if units become
                # percentage due to the fallback support
                childrenMayBecomeUndefined = True
                dirtyChildren = self.getInvalidSizedChildren(False)

            super(AbstractComponentContainer, self).setWidth(width, unit)
            self.repaintChangedChildTrees(dirtyChildren,
                    childrenMayBecomeUndefined, False)
        else:
            super(AbstractComponentContainer, self).setWidth(width)
    def setWidth(self, width, unit=None):
        if unit is not None:
            from muntjac.terminal.gwt.server.component_size_validator import \
                ComponentSizeValidator  # FIXME: circular import

            # child tree repaints may be needed, due to our fall back support
            # for invalid relative sizes
            dirtyChildren = None
            childrenMayBecomeUndefined = False
            if (self.getWidth() == self.SIZE_UNDEFINED
                    and width != self.SIZE_UNDEFINED):
                # children currently in invalid state may need repaint
                dirtyChildren = self.getInvalidSizedChildren(False)

            elif ((width == self.SIZE_UNDEFINED
                   and self.getWidth() != self.SIZE_UNDEFINED) or
                  (unit == self.UNITS_PERCENTAGE
                   and self.getWidthUnits() != self.UNITS_PERCENTAGE
                   and not ComponentSizeValidator.parentCanDefineWidth(self))):

                # relative width children may get to invalid state if width
                # becomes invalid. Width may also become invalid if units become
                # percentage due to the fallback support
                childrenMayBecomeUndefined = True
                dirtyChildren = self.getInvalidSizedChildren(False)

            super(AbstractComponentContainer, self).setWidth(width, unit)
            self.repaintChangedChildTrees(dirtyChildren,
                                          childrenMayBecomeUndefined, False)
        else:
            super(AbstractComponentContainer, self).setWidth(width)
Пример #3
0
    def paint(self, target):
        # Paints the component into a UIDL stream.
        tag = target.getTag(self)
        if ((not target.startTag(self, tag))
                or self._repaintRequestListenersNotified):

            # Paint the contents of the component

            # Only paint content of visible components.
            if self.isVisible():
                from muntjac.terminal.gwt.server.component_size_validator \
                    import ComponentSizeValidator  # FIXME: circular import

                if (self.getHeight() >= 0
                    and (self.getHeightUnits() != self.UNITS_PERCENTAGE
                    or ComponentSizeValidator.parentCanDefineHeight(self))):

                    target.addAttribute('height', '' + self.getCSSHeight())

                if (self.getWidth() >= 0
                    and (self.getWidthUnits() != self.UNITS_PERCENTAGE
                    or ComponentSizeValidator.parentCanDefineWidth(self))):

                    target.addAttribute('width', '' + self.getCSSWidth())

                if self._styles is not None and len(self._styles) > 0:
                    target.addAttribute('style', self.getStyle())

                if self.isReadOnly():
                    target.addAttribute('readonly', True)

                if self.isImmediate():
                    target.addAttribute('immediate', True)

                if not self.isEnabled():
                    target.addAttribute('disabled', True)

                if self.getCaption() is not None:
                    target.addAttribute('caption', self.getCaption())

                if self.getIcon() is not None:
                    target.addAttribute('icon', self.getIcon())

                if (self.getDescription() is not None
                        and len(self.getDescription()) > 0):
                    target.addAttribute('description', self.getDescription())

                if self._eventIdentifiers is not None:
                    target.addAttribute('eventListeners',
                            list(self._eventIdentifiers))

                self.paintContent(target)

                error = self.getErrorMessage()
                if error is not None:
                    error.paint(target)
            else:
                target.addAttribute('invisible', True)
        else:
            # Contents have not changed, only cached presentation can be used
            target.addAttribute('cached', True)
        target.endTag(tag)

        self._repaintRequestListenersNotified = False
Пример #4
0
    def paint(self, target):
        """Paints the Paintable into a UIDL stream. This method creates the
        UIDL sequence describing it and outputs it to the given UIDL stream.

        It is called when the contents of the component should be painted in
        response to the component first being shown or having been altered so
        that its visual representation is changed.

        B{Do not override this to paint your component.} Override
        L{paintContent} instead.

        @param target:
                  the target UIDL stream where the component should paint
                  itself to.
        @raise PaintException:
                  if the paint operation failed.
        """
        tag = target.getTag(self)
        if ((not target.startTag(self, tag))
                or self._repaintRequestListenersNotified):

            # Paint the contents of the component

            # Only paint content of visible components.
            if self.isVisible():
                from muntjac.terminal.gwt.server.component_size_validator \
                    import ComponentSizeValidator  # FIXME: circular import

                if (self.getHeight() >= 0 and
                    (self.getHeightUnits() != self.UNITS_PERCENTAGE
                     or ComponentSizeValidator.parentCanDefineHeight(self))):

                    target.addAttribute('height', '' + self.getCSSHeight())

                if (self.getWidth() >= 0 and
                    (self.getWidthUnits() != self.UNITS_PERCENTAGE
                     or ComponentSizeValidator.parentCanDefineWidth(self))):

                    target.addAttribute('width', '' + self.getCSSWidth())

                if self._styles is not None and len(self._styles) > 0:
                    target.addAttribute('style', self.getStyle())

                if self.isReadOnly():
                    target.addAttribute('readonly', True)

                if self.isImmediate():
                    target.addAttribute('immediate', True)

                if not self.isEnabled():
                    target.addAttribute('disabled', True)

                if self.getCaption() is not None:
                    target.addAttribute('caption', self.getCaption())

                if self.getIcon() is not None:
                    target.addAttribute('icon', self.getIcon())

                if (self.getDescription() is not None
                        and len(self.getDescription()) > 0):
                    target.addAttribute('description', self.getDescription())

                if self._eventIdentifiers is not None:
                    target.addAttribute('eventListeners',
                                        list(self._eventIdentifiers))

                self.paintContent(target)

                error = self.getErrorMessage()
                if error is not None:
                    error.paint(target)
            else:
                target.addAttribute('invisible', True)
        else:
            # Contents have not changed, only cached presentation can be used
            target.addAttribute('cached', True)
        target.endTag(tag)

        self._repaintRequestListenersNotified = False
Пример #5
0
    def paint(self, target):
        """Paints the Paintable into a UIDL stream. This method creates the
        UIDL sequence describing it and outputs it to the given UIDL stream.

        It is called when the contents of the component should be painted in
        response to the component first being shown or having been altered so
        that its visual representation is changed.

        B{Do not override this to paint your component.} Override
        L{paintContent} instead.

        @param target:
                  the target UIDL stream where the component should paint
                  itself to.
        @raise PaintException:
                  if the paint operation failed.
        """
        tag = target.getTag(self)
        if ((not target.startTag(self, tag))
                or self._repaintRequestListenersNotified):

            # Paint the contents of the component

            # Only paint content of visible components.
            if self.isVisible():
                from muntjac.terminal.gwt.server.component_size_validator \
                    import ComponentSizeValidator  # FIXME: circular import

                if (self.getHeight() >= 0
                    and (self.getHeightUnits() != self.UNITS_PERCENTAGE
                    or ComponentSizeValidator.parentCanDefineHeight(self))):

                    target.addAttribute('height', '' + self.getCSSHeight())

                if (self.getWidth() >= 0
                    and (self.getWidthUnits() != self.UNITS_PERCENTAGE
                    or ComponentSizeValidator.parentCanDefineWidth(self))):

                    target.addAttribute('width', '' + self.getCSSWidth())

                if self._styles is not None and len(self._styles) > 0:
                    target.addAttribute('style', self.getStyle())

                if self.isReadOnly():
                    target.addAttribute('readonly', True)

                if self.isImmediate():
                    target.addAttribute('immediate', True)

                if not self.isEnabled():
                    target.addAttribute('disabled', True)

                if self.getCaption() is not None:
                    target.addAttribute('caption', self.getCaption())

                if self.getIcon() is not None:
                    target.addAttribute('icon', self.getIcon())

                if (self.getDescription() is not None
                        and len(self.getDescription()) > 0):
                    target.addAttribute('description', self.getDescription())

                if self._eventIdentifiers is not None:
                    target.addAttribute('eventListeners',
                            list(self._eventIdentifiers))

                self.paintContent(target)

                error = self.getErrorMessage()
                if error is not None:
                    error.paint(target)
            else:
                target.addAttribute('invisible', True)
        else:
            # Contents have not changed, only cached presentation can be used
            target.addAttribute('cached', True)
        target.endTag(tag)

        self._repaintRequestListenersNotified = False