Commits

Anonymous committed 9754ddb

Cumulative bug fixes for pygame.draw challenge compat, see changelog

  • Participants
  • Parent commits 6160987
  • Branches ctypes-soc

Comments (0)

Files changed (7)

  - Fix typemask list argument in event functions
  - 'dict' attribute added to Event 
  - Fix user-posted event handling
+ - Fix pygame.Surface.subsurface
+ - Fix pygame.key.get_mods
+ - Add KMOD_* constants
+ - Allow (but ignore) keyword arguments to Font initializer
+ - Cleanup module namespace in pygame.draw
 
 SDL-ctypes 0.07
 ---------------

File pygame/constants.py

 K_z                     = SDL.constants.SDLK_z
 #END GENERATED CONSTANTS
 
+KMOD_NONE               = SDL.constants.KMOD_NONE
+KMOD_LSHIFT             = SDL.constants.KMOD_LSHIFT
+KMOD_RSHIFT             = SDL.constants.KMOD_RSHIFT
+KMOD_LCTRL              = SDL.constants.KMOD_LCTRL
+KMOD_RCTRL              = SDL.constants.KMOD_RCTRL
+KMOD_LALT               = SDL.constants.KMOD_LALT
+KMOD_RALT               = SDL.constants.KMOD_RALT
+KMOD_LMETA              = SDL.constants.KMOD_LMETA
+KMOD_RMETA              = SDL.constants.KMOD_RMETA
+KMOD_NUM                = SDL.constants.KMOD_NUM
+KMOD_CAPS               = SDL.constants.KMOD_CAPS
+KMOD_MODE               = SDL.constants.KMOD_MODE
+
+KMOD_CTRL               = SDL.constants.KMOD_CTRL
+KMOD_SHIFT              = SDL.constants.KMOD_SHIFT
+KMOD_ALT                = SDL.constants.KMOD_ALT
+KMOD_META               = SDL.constants.KMOD_META

File pygame/draw.py

 __docformat__ = 'restructuredtext'
 __version__ = '$Id$'
 
-from copy import copy
+import copy
 import math
 
 from SDL import *
                 color >> 8 & 0xff)
 
 def _get_rect(rect):
-    rect = copy(pygame.rect._rect_from_object(rect))
+    rect = copy.copy(pygame.rect._rect_from_object(rect))
     rect.normalize()
     return rect._r
 

File pygame/font.py

 class Font(object):
     __slots__ = ['_font', '_rw']
 
-    def __init__(self, file, size):
+    def __init__(self, file, size, **kwargs):
         '''Create a new Font object from a file.
 
         Load a new font from a given filename or a python file object. The
             `size` : int
                 Size of font, in points.
 
+        :note: additional keyword arguments are permitted but ignored,
+            this is for compatibility with Pygame.
         '''
         if not _font_initialized:
             raise pygame.base.error, 'font not initialized'
 
-        if not file:
+        # XXX not quite the same as Pygame, which checks for font 
+        # in working dir before treating it as the default resource.
+        if not file or file == _font_defaultname:
             file = pygame.pkgdata.getResource(_font_defaultname)
-            size *= 0.6875  # XXX Peter's phone number??
+            size *= 0.6875  # XXX compatibility with previous default font sizes
 
         size = int(max(1, size))
 

File pygame/key.py

     '''
     pygame.display._video_init_check()
 
-    return SDL_GetModeState()
+    return SDL_GetModState()
 
 def set_mods(mods):
     '''Temporarily set which modifier keys are pressed.

File pygame/rect.py

                self._r.x + self._r.w > other.x and \
                self._r.y + self._r.h > other.y
 
-    def collidepoint(self, x, y):
+    def collidepoint(self, *args):
+        if len(args) == 1:
+            x, y = args[0]
+        else:
+            x, y = args
         return x >= self._r.x and \
                y >= self._r.y and \
                x < self._r.x + self._r.w and \

File pygame/surface.py

         return pygame.rect.Rect(SDL_GetClipRect(self._surf))
 
 
-    def subsurface(self, rect):
+    def subsurface(self, *rect):
         '''Create a new surface that references its parent.
 
         Returns a new Surface that shares its pixels with its new parent. The
 
         rect = pygame.rect._rect_from_object(rect)._r
         if rect.x < 0 or rect.y < 0 or \
-           rect.x + rect.w > surf.w or rect.y + rect.y > surf.h:
+           rect.x + rect.w > surf.w or rect.y + rect.h > surf.h:
             raise ValueError, 'subsurface rectangle outside surface area'
 
         self.lock()
         orig_clip = SDL_GetClipRect(subsurface)
         sub_clip = SDL_GetClipRect(dst)
         sub_clip.x += suboffsetx
-        sub_clip.y += suboffset.y
+        sub_clip.y += suboffsety
         SDL_SetClipRect(subsurface, sub_clip)
         dstrect.x += suboffsetx
         dstrect.y += suboffsety