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

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

D.draw_check (...) -> None

Creates a surface with a check box.

Creates a surface with 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 382 of file DefaultEngine.py.

00382                                                                               :
        """D.draw_check (...) -> None

        Creates a surface with a check box.

        Creates a surface with 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.
        """
        self_style = self.style
        if not style:
            style = self_style.get_style (cls)

        # Some colors we need.
        bg = (255, 255, 255) # Default background color.
        check = (0, 0, 0)    # Check color.
        sh = (150, 150, 150) # Check shadow to make it look smooth.

        array = pygame.surfarray.array3d (surface)

        # Draw the borders and fill the rest.
        dark = self_style.get_style_entry (cls, style, "darkcolor",state)
        light = self_style.get_style_entry (cls, style, "lightcolor", state)

        array[rect.left:rect.left + 2, rect.top:rect.bottom] = dark
        array[rect.left:rect.right, rect.top:rect.top + 2] = dark
        array[rect.right - 2:rect.right, rect.top:rect.bottom] = light
        array[rect.left:rect.right, rect.bottom - 2:rect.bottom] = light
        array[rect.left, rect.bottom - 2] = dark
        array[rect.right - 2, rect.top] = dark

        if state == STATE_INSENSITIVE:
            array[rect.left + 2:rect.right - 2,
                  rect.top + 2:rect.bottom - 2] = \
                  self_style.get_style_entry (cls, style, "bgcolor", state)
            check = self_style.get_style_entry (cls, style, "fgcolor", state)
            sh = check
        else:
            array[rect.left + 2:rect.right - 2,
                  rect.top + 2:rect.bottom - 2] = bg
        
        if checked:
            # Place a check into the drawn box by direct pixel
            # manipulation.
            # 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  |* * * * * * * * * * * * * *|
            # 1  |* * * * * * * * * * * * * *|
            # 2  |* * 0 0 0 0 0 0 0 0 0 0 * *|
            # 3  |* * 0 0 0 0 0 0 0 0 # # * *|
            # 4  |* * 0 0 0 0 0 0 0 # # # * *|
            # 5  |* * 0 0 0 0 0 0 # # # 0 * *|
            # 6  |* * 0 0 # # 0 # # # 0 0 * *|
            # 7  |* * 0 # # # 0 # # 0 0 0 * *|
            # 8  |* * 0 0 # # # # # 0 0 0 * *|
            # 9  |* * 0 0 0 # # # 0 0 0 0 * *|
            # 10 |* * 0 0 0 0 0 # 0 0 0 0 * *|
            # 11 |* * 0 0 0 0 0 0 0 0 0 0 * *|
            # 12 |* * * * * * * * * * * * * *|
            # 13 |* * * * * * * * * * * * * *|
            #    -----------------------------
            # * = border shadow
            # 0 = unset
            # # = set with a specific color.
            #
            array[rect.left + 3, rect.top + 7] = sh
            array[rect.left + 4, rect.top + 6] = sh
            array[rect.left + 4, rect.top + 7:rect.top + 9] = check
            array[rect.left + 5, rect.top + 6] = sh
            array[rect.left + 5, rect.top + 7:rect.top + 9] = check
            array[rect.left + 5, rect.top + 9] = sh
            array[rect.left + 6, rect.top + 7] = sh
            array[rect.left + 6, rect.top + 8:rect.top + 10] = check
            array[rect.left + 7, rect.top + 6] = sh
            array[rect.left + 7, rect.top + 7:rect.top + 11] = check
            array[rect.left + 8, rect.top + 5:rect.top + 9] = check
            array[rect.left + 9, rect.top + 4:rect.top + 7] = check
            array[rect.left + 10, rect.top + 3:rect.top + 6] = check
            array[rect.left + 11, rect.top + 3:rect.top + 5] = sh
           
        pygame.surfarray.blit_array (surface, array)

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


Generated by  Doxygen 1.6.0   Back to index