Logo Search packages:      
Sourcecode: ocempgui version File versions  Download package

def themes::default::DefaultEngine::DefaultEngine::draw_radio (   self,
  surface,
  rect,
  checked,
  state,
  cls = None,
  style = None 
)

D.draw_radio (...) -> None

Creates a surface with a radio check box.

Creates a surface with radio check box using a width and height
of 14 pixels. The method uses a sunken border effect and makes
use of the 'lightcolor' and 'darkcolor' style entries for the
border.  Dependant on the passed 'state' argument, the method
will either use fixed color values of

(255, 255, 255) for the background and 
(0, 0, 0) for the check,

which is only drawn, if the 'checked' argument evaluates to
True. If the 'state' argument is set to STATE_INSENSITIVE the
'bgcolor' and 'fgcolor' style entries are used instead.

If no style is passed, the method will try to retrieve a style
using the get_style() method.

Definition at line 480 of file DefaultEngine.py.

00480                                                                               :
        """D.draw_radio (...) -> None

        Creates a surface with a radio check box.

        Creates a surface with radio check box using a width and height
        of 14 pixels. The method uses a sunken border effect and makes
        use of the 'lightcolor' and 'darkcolor' style entries for the
        border.  Dependant on the passed 'state' argument, the method
        will either use fixed color values of

        (255, 255, 255) for the background and 
        (0, 0, 0) for the check,

        which is only drawn, if the 'checked' argument evaluates to
        True. If the 'state' argument is set to STATE_INSENSITIVE the
        'bgcolor' and 'fgcolor' style entries are used instead.
        
        If no style is passed, the method will try to retrieve a style
        using the get_style() method.
        """
        if not style:
            style = self.style.get_style (cls)

        # We need some colors for the radio check.
        sh1 = (0, 0, 0)        # Border topleft.
        sh2 = (150, 150, 150)  # Border shadow top- and bottomleft.
        sh3 = (255, 255, 255)  # Outer border shadow bottomleft.
        bg = (255, 255, 255)   # Background color for the check.
        check = (0, 0, 0)      # Color of the radio check.

        if state == STATE_INSENSITIVE:
            bg = self.style.get_style_entry (cls, style, "bgcolor", state)
            check = self.style.get_style_entry (cls, style, "fgcolor", state)
            sh1 = check
            sh2 = self.style.get_style_entry (cls, style, "fgcolor", state)
            sh3 = (240, 240, 240)

        # The complete radio check will be drawn by manipulating pixels
        # of the box.
        # TODO: provide a handy matrix for this, so it can be merged
        # and changed quickly and vary in size.
        #                           11  13
        #     0 1 2 3 4 5 6 7 8 9 10  12  
        #    -----------------------------
        # 0  |x x x x x x x x x x x x x x|
        # 1  |x x x x x * * * * x x x x x|
        # 2  |x x x * * s s s s s * x x x|
        # 3  |x x * s s 0 0 0 0 0 s * x x|
        # 4  |x x * s 0 0 0 0 0 0 0 * x x|
        # 5  |x * s 0 0 0 # # # 0 0 0 * x|
        # 6  |x * s 0 0 # # # # # 0 0 * 8|
        # 7  |x * s 0 0 # # # # # 0 0 * 8|
        # 8  |x * s 0 0 # # # # # 0 0 * 8|
        # 9  |x x s 0 0 0 # # # 0 0 0 * 8|
        # 10 |x x * s 0 0 0 0 0 0 0 * 8 x|
        # 11 |x x x * * 0 0 0 0 0 * * 8 x|
        # 12 |x x x x x * * * * * 8 8 x x|
        # 13 |x x x x x x 8 8 8 8 x x x x|
        #    -----------------------------
        # x = default background color
        # * = border shadow (sh2)
        # s = topleft border (sh1)
        # 0 = background color (bg)
        # 8 = border shadow 2 (sh3)
        # # = check color (check)
        #
        array = pygame.surfarray.array3d (surface)

        array[rect.left + 1, rect.top + 5:rect.top + 9] = sh2
        array[rect.left + 2, rect.top + 3:rect.top + 5] = sh2
        array[rect.left + 2, rect.top + 5:rect.top + 10] = sh1
        array[rect.left + 2, rect.top + 10] = sh2
        array[rect.left + 3:rect.left + 5, rect.top + 2] = sh2
        array[rect.left + 3, rect.top + 3:rect.top + 5] = sh1
        array[rect.left + 3:rect.left + 12, rect.top + 5:rect.top + 10] = bg
        array[rect.left + 3, rect.top + 10] = sh1
        array[rect.left + 3:rect.left + 5, rect.top + 11] = sh2
        array[rect.left + 4, rect.top + 3] = sh1
        array[rect.left + 4:rect.left + 11, rect.top + 4] = bg
        array[rect.left + 4:rect.left + 11, rect.top + 10] = bg
        array[rect.left + 5:rect.left + 9, rect.top + 1] = sh2
        array[rect.left + 5:rect.left + 10, rect.top + 2] = sh1
        array[rect.left + 5:rect.left + 10, rect.top + 3] = bg
        array[rect.left + 5:rect.left + 10, rect.top + 11] = bg
        array[rect.left + 5:rect.left + 10, rect.top + 12] = sh2
        array[rect.left + 6:rect.left + 10, rect.top + 13] = sh3
        array[rect.left + 10, rect.top + 2] = sh2
        array[rect.left + 10, rect.top + 3] = sh1
        array[rect.left + 10:rect.left + 12, rect.top + 11] = sh2
        array[rect.left + 10:rect.left + 12, rect.top + 12] = sh3
        array[rect.left + 11, rect.top + 3:rect.top + 5] = sh2
        array[rect.left + 11, rect.top + 10] = sh2
        array[rect.left + 12, rect.top + 5:rect.top + 10] = sh2
        array[rect.left + 12, rect.top + 10:rect.top + 12] = sh3
        array[rect.left + 13, rect.top + 6:rect.top + 10] = sh3

        if checked:
            array[rect.left + 5:rect.left + 10,
                  rect.top + 6:rect.top + 9] = check
            array[rect.left + 6:rect.left + 9, rect.top + 5] = check
            array[rect.left + 6:rect.left + 9, rect.top + 9] = check

        pygame.surfarray.blit_array (surface, array)

    def draw_caption (self, width, title=None, state=STATE_NORMAL, cls=None,


Generated by  Doxygen 1.6.0   Back to index