Changeset 4404 for libcaca


Ignore:
Timestamp:
Jun 1, 2010, 8:21:41 PM (9 years ago)
Author:
Alex Foulon
Message:
  • Fix get_dirty_rect function.
  • Add exceptions for missing methods.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/python/caca/canvas.py

    r4403 r4404  
    6969            raise CanvasError, "Failed to create canvas"
    7070
     71    def manage(self, *args, **kw):
     72        """ Not implemented.
     73        """
     74        raise CanvasError, "Not implemented"
     75
     76    def unmanage(self, *args, **kw):
     77        """ Not implemented.
     78        """
     79        raise CanvasError, "Not implemented"
     80
    7181    def set_size(self, width, height):
    7282        """ Resize a canvas.
     
    98108        return _lib.caca_get_canvas_height(self)
    99109
    100     def get_chars(self):
    101         """ Get the canvas character array, return python list.
    102         """
    103         chlist = []
    104         #get canvas size
    105         w, h = self.get_width(), self.get_height()
    106 
    107         _lib.caca_get_canvas_chars.argtypes = [_Canvas]
    108         _lib.caca_get_canvas_chars.restype  = \
    109                     ctypes.POINTER(ctypes.c_uint8 * (w * h))
    110 
    111         plist = _lib.caca_get_canvas_chars(self)
    112 
    113         #build character list
    114         for item in plist.contents:
    115             if item != 0:
    116                 chlist.append(chr(item))
    117 
    118         return chlist
     110    def get_chars(self, *args, **kw):
     111        """ Not implemented.
     112        """
     113        raise CanvasError, "Not implemented"
     114
     115    def get_attrs(self, *args, **kw):
     116        """ Not implemented.
     117        """
     118        raise CanvasError, "Not implemented"
    119119
    120120    def gotoxy(self, x, y):
     
    201201        return _lib.caca_printf(self, x, y, fmt, *args)
    202202
     203    def vprintf(self, *args, **kw):
     204        """ Not implemented.
     205        """
     206        raise CanvasError, "Not implemented"
     207
    203208    def clear(self):
    204209        """ Clear the canvas.
     
    294299
    295300    def get_dirty_rect(self, idx):
    296         """ Get a canvas's dirty rectangle.
     301        """ Get a canvas's dirty rectangle. Return python dictionnary with
     302            coords as keys: x, y, width, height.
    297303
    298304            idx -- the requested rectangle index
    299305        """
    300         x = ctypes.POINTER(ctypes.c_int)
    301         y = ctypes.POINTER(ctypes.c_int)
    302         w = ctypes.POINTER(ctypes.c_int)
    303         h = ctypes.POINTER(ctypes.c_int)
     306        #initialize dictionnary and pointers
     307        dct = None
     308        x = ctypes.c_int()
     309        y = ctypes.c_int()
     310        width  = ctypes.c_int()
     311        height = ctypes.c_int()
    304312
    305313        _lib.caca_get_dirty_rect.argtypes = [
     
    310318        _lib.caca_get_dirty_rect.restype  = ctypes.c_int
    311319
    312         _lib.caca_get_dirty_rect(self, idx, x, y, w, h)
    313 
    314         return [x.contents.value, y.contents.value,
    315                 w.contents.value, h.contents.value]
     320        if _lib.caca_get_dirty_rect(self, idx, x, y, width, height) > -1:
     321            dct = {
     322                'x': x.value, 'y': y.value,
     323                'width': width.value, 'height': height.value,
     324            }
     325
     326        return dct
    316327
    317328    def add_dirty_rect(self, x, y, width, height):
Note: See TracChangeset for help on using the changeset viewer.