Esempio n. 1
0
    def _paint ( self, event ):
        """ Handles redrawing the contents of the control.
        """
        from facets.ui.pyface.image_slice import paint_parent

        stacker = self.stacker
        g       = stacker.graphics.graphics_buffer()

        # Repaint the parent's theme (if necessary):
        paint_parent( g, stacker )

        # Calculate the size of the area to be repainted:
        cdx, cdy = stacker.client_size
        vdx, vdy = stacker.virtual_size
        wdx, wdy = max( cdx, vdx ), max( cdy, vdy )

        # Draw the background theme (if any):
        if self.theme is not None:
            self.theme.fill( g, 0, 0, wdx, wdy )

        # Draw each of the stacker items (using the appropriate orientation):
        items = self.items
        if len( items ) > 0:
            bx, by, bdx, bdy = bounds = stacker.visible_bounds
            low   = self._item_at( bx, by )
            high  = self._item_at( bx + bdx - 1, by + bdy - 1 ) + 1
            for i in xrange( low, high ):
                items[i].paint( g, bounds )

        g.copy()
Esempio n. 2
0
    def paint_bg ( self, g ):
        """ Paints the background into the supplied graphics object using the
            associated ImageSlice object and returns the image slice used (if
            any).
        """
        from facets.ui.pyface.image_slice import paint_parent

        # Repaint the parent's theme (if necessary):
        paint_parent( g, self.control )

        # Draw the background theme (if any):
        theme = self.theme
        if theme is not None:
            wdx, wdy = self.control.client_size
            theme.fill( g, 0, 0, wdx, wdy )
            if self.debug:
                slice   = theme.image_slice
                g.pen   = RED
                g.brush = None
                border  = theme.border
                g.draw_rectangle( border.left, border.top,
                                  wdx - border.right  - border.left,
                                  wdy - border.bottom - border.top )
                g.draw_rectangle( border.left + 3, border.top + 3,
                                  wdx - border.right  - border.left - 6,
                                  wdy - border.bottom - border.top  - 6 )
                content = theme.content
                x = slice.xleft + content.left
                y = slice.xtop  + content.top
                g.draw_rectangle( x - 1, y - 1,
                       wdx - slice.xright  - content.right  - x + 2,
                       wdy - slice.xbottom - content.bottom - y + 2 )

                label = theme.label
                if slice.xtop >= slice.xbottom:
                    y, dy = 0, slice.xtop
                else:
                    y, dy = wdy - slice.xbottom, slice.xbottom

                if dy >= 13:
                    x  = slice.xleft + label.left
                    y += label.top
                    g.draw_rectangle( x - 1, y - 1,
                        wdx - slice.xright - label.right - x + 2,
                        dy - label.bottom - label.top + 2 )
Esempio n. 3
0
    def _on_paint ( self, event ):
        """ Paint the background using the associated ImageSlice object.
        """
        control = self.adapter
        g       = control.graphics.graphics_buffer()

        # Draw the background:
        factory  = self.factory
        color    = factory.color
        if self._x is not None:
            if factory.active_color is not None:
                color = factory.active_color
        elif self._hover:
            if factory.hover_color is not None:
                color = factory.hover_color

        if color is None:
            paint_parent( g, control )
            brush = None
        else:
            brush = color

        color = factory.border_color
        if color is not None:
            pen = color
        else:
            pen = None

        if (pen is not None) or (brush is not None):
            wdx, wdy = control.client_size
            g.brush  = brush
            g.pen    = pen
            g.draw_rectangle( 0, 0, wdx, wdy )

        # Draw the current text value:
        g.text_background_color = None
        g.text_color            = factory.text_color
        g.font                  = control.font
        tx, ty, tdx, tdy        = self._get_text_bounds( g )
        g.draw_text( self.text, tx, ty )

        # Copy the buffer contents to the display:
        g.copy()
Esempio n. 4
0
    def _on_paint ( self, event ):
        """ Paint the background using the associated ImageSlice object.
        """
        control  = self.adapter
        g        = control.graphics.graphics_buffer()
        slice    = paint_parent( g, control )
        slice2   = self.image_slice
        if slice2 is not default_image_slice:
            wdx, wdy = control.client_size
            slice2.fill( g, 0, 0, wdx, wdy )
            slice = slice2
        elif slice is None:
            slice = slice2

        g.text_background_color = None
        g.text_color            = slice.content_color
        g.font                  = control.font
        tx, ty, tdx, tdy        = self._get_text_bounds()
        g.draw_text( self._get_text(), tx, ty )
        g.copy()
Esempio n. 5
0
    def _on_paint ( self, event ):
        """ Called when the widget needs repainting.
        """
        control  = self.control
        g        = control.graphics.graphics_buffer()
        paint_parent( g, control )

        wdx, wdy = control.client_size
        ox       = (wdx - self._dx) / 2
        oy       = (wdy - self._dy) / 2
        bd       = self._button_down
        style    = self.style

        disabled = (not control.enabled)
        image    = self.image
        if image is not None:
            bitmap = image.bitmap
            if disabled:
                bitmap = image.mono_bitmap

            g.draw_bitmap( bitmap, ox + self._ix, oy + self._iy )

        if self.label != '':
            if disabled:
                g.text_color = DisabledTextColor

            if bd and (style == 'button') and (not disabled):
                ox += 1
                oy += 1

            g.draw_text( self.label, ox + self._tx, oy + self._ty )

        pens  = self.pens
        is_rc = (style in ( 'radio', 'checkbox' ))
        if bd or (style == 'button') or (is_rc and self.selected):
            if is_rc:
                bd = 1 - bd

            g.brush = None
            g.pen   = pens[ bd ]
            g.draw_line( 1, 1, wdx - 1, 1 )
            g.draw_line( 1, 1, 1, wdy - 1 )
            g.draw_line( 2, 2, wdx - 2, 2 )
            g.draw_line( 2, 2, 2, wdy - 2 )
            g.pen = pens[ 1 - bd ]
            g.draw_line( wdx - 2, 2, wdx - 2, wdy - 1 )
            g.draw_line( 2, wdy - 2, wdx - 2, wdy - 2 )
            g.draw_line( wdx - 3, 3, wdx - 3, wdy - 2 )
            g.draw_line( 3, wdy - 3, wdx - 3, wdy - 3 )

        elif self._mouse_over and (not self.selected):
            g.brush = None
            g.pen   = pens[ bd ]
            g.draw_line( 0, 0, wdx, 0 )
            g.draw_line( 0, 1, 0, wdy )
            g.pen = pens[ 1 - bd ]
            g.draw_line( wdx - 1, 1, wdx - 1, wdy )
            g.draw_line( 1, wdy - 1, wdx - 1, wdy - 1 )

        g.copy()

#-- EOF ------------------------------------------------------------------------
Esempio n. 6
0
    def OnPaint ( self, event ):
        """ Paint the background using the associated ImageSlice object.
        """
        from facets.ui.pyface.image_slice import paint_parent

        paint_parent( self.adapter.graphics, self.adapter )