X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8edf1c75f0667d3568e224910fa858cf05234942..4d2962b127e734c37095f72a578457bea84c89da:/wxPython/src/mac/gdi.py diff --git a/wxPython/src/mac/gdi.py b/wxPython/src/mac/gdi.py index eb0df57fe3..3bbd5f9bf4 100644 --- a/wxPython/src/mac/gdi.py +++ b/wxPython/src/mac/gdi.py @@ -45,10 +45,31 @@ _gdi.GDIObject_swigregister(GDIObjectPtr) #--------------------------------------------------------------------------- class Colour(core.Object): + """ + A colour is an object representing a combination of Red, Green, and Blue (RGB) + intensity values, and is used to determine drawing colours, window colours, + etc. Valid RGB values are in the range 0 to 255. + + In wxPython there are typemaps that will automatically convert from a colour + name, or from a "#RRGGBB" colour hex value string to a wx.Colour object when + calling C++ methods that expect a wxColour. This means that the following are + all equivallent: + + win.SetBackgroundColour(wxColour(0,0,255)) + win.SetBackgroundColour("BLUE") + win.SetBackgroundColour("#0000FF") + + You can retrieve the various current system colour settings with + wx.SystemSettings.GetColour. + """ def __repr__(self): return "<%s.%s; proxy of C++ wxColour instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): - """__init__(unsigned char red=0, unsigned char green=0, unsigned char blue=0) -> Colour""" + """ + __init__(unsigned char red=0, unsigned char green=0, unsigned char blue=0) -> Colour + + Constructs a colour from red, green and blue values. + """ newobj = _gdi.new_Colour(*args, **kwargs) self.this = newobj.this self.thisown = 1 @@ -60,45 +81,104 @@ class Colour(core.Object): except: pass def Red(*args, **kwargs): - """Red() -> unsigned char""" + """ + Red() -> unsigned char + + Returns the red intensity. + """ return _gdi.Colour_Red(*args, **kwargs) def Green(*args, **kwargs): - """Green() -> unsigned char""" + """ + Green() -> unsigned char + + Returns the green intensity. + """ return _gdi.Colour_Green(*args, **kwargs) def Blue(*args, **kwargs): - """Blue() -> unsigned char""" + """ + Blue() -> unsigned char + + Returns the blue intensity. + """ return _gdi.Colour_Blue(*args, **kwargs) def Ok(*args, **kwargs): - """Ok() -> bool""" + """ + Ok() -> bool + + Returns True if the colour object is valid (the colour has been + initialised with RGB values). + """ return _gdi.Colour_Ok(*args, **kwargs) def Set(*args, **kwargs): - """Set(unsigned char red, unsigned char green, unsigned char blue)""" + """ + Set(unsigned char red, unsigned char green, unsigned char blue) + + Sets the RGB intensity values. + """ return _gdi.Colour_Set(*args, **kwargs) def SetRGB(*args, **kwargs): - """SetRGB(unsigned long colRGB)""" + """ + SetRGB(unsigned long colRGB) + + Sets the RGB intensity values from a packed RGB value. + """ return _gdi.Colour_SetRGB(*args, **kwargs) + def SetFromName(*args, **kwargs): + """ + SetFromName(String colourName) + + Sets the RGB intensity values using a colour name listed in wx.TheColourDatabase. + """ + return _gdi.Colour_SetFromName(*args, **kwargs) + + def GetPixel(*args, **kwargs): + """ + GetPixel() -> long + + Returns a pixel value which is platform-dependent. On Windows, a + COLORREF is returned. On X, an allocated pixel value is returned. + -1 is returned if the pixel is invalid (on X, unallocated). + """ + return _gdi.Colour_GetPixel(*args, **kwargs) + def __eq__(*args, **kwargs): - """__eq__(Colour colour) -> bool""" + """ + __eq__(Colour colour) -> bool + + Compare colours for equality + """ return _gdi.Colour___eq__(*args, **kwargs) def __ne__(*args, **kwargs): - """__ne__(Colour colour) -> bool""" - return _gdi.Colour___ne__(*args, **kwargs) + """ + __ne__(Colour colour) -> bool - def InitFromName(*args, **kwargs): - """InitFromName(String colourName)""" - return _gdi.Colour_InitFromName(*args, **kwargs) + Compare colours for inequality + """ + return _gdi.Colour___ne__(*args, **kwargs) def Get(*args, **kwargs): - """Get() -> PyObject""" + """ + Get() -> (r, g, b) + + Returns the RGB intensity values as a tuple. + """ return _gdi.Colour_Get(*args, **kwargs) + def GetRGB(*args, **kwargs): + """ + GetRGB() -> unsigned long + + Return the colour as a packed RGB value + """ + return _gdi.Colour_GetRGB(*args, **kwargs) + asTuple = Get def __str__(self): return str(self.asTuple()) def __repr__(self): return 'wx.Colour' + str(self.asTuple()) @@ -115,13 +195,21 @@ class ColourPtr(Colour): _gdi.Colour_swigregister(ColourPtr) def NamedColour(*args, **kwargs): - """NamedColour(String colorName) -> Colour""" + """ + NamedColour(String colorName) -> Colour + + Constructs a colour object using a colour name listed in wx.TheColourDatabase. + """ val = _gdi.new_NamedColour(*args, **kwargs) val.thisown = 1 return val def ColourRGB(*args, **kwargs): - """ColourRGB(unsigned long colRGB) -> Colour""" + """ + ColourRGB(unsigned long colRGB) -> Colour + + Constructs a colour from a packed RGB value. + """ val = _gdi.new_ColourRGB(*args, **kwargs) val.thisown = 1 return val @@ -235,6 +323,14 @@ class Pen(GDIObject): """GetDashes() -> PyObject""" return _gdi.Pen_GetDashes(*args, **kwargs) + def __eq__(*args, **kwargs): + """__eq__(Pen other) -> bool""" + return _gdi.Pen___eq__(*args, **kwargs) + + def __ne__(*args, **kwargs): + """__ne__(Pen other) -> bool""" + return _gdi.Pen___ne__(*args, **kwargs) + def __nonzero__(self): return self.Ok() class PenPtr(Pen): @@ -556,9 +652,10 @@ class Mask(core.Object): return "<%s.%s; proxy of C++ wxMask instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): """ - __init__(Bitmap bitmap) -> Mask + __init__(Bitmap bitmap, Colour colour=NullColour) -> Mask - Constructs a mask from a monochrome bitmap. + Constructs a mask from a bitmap and a colour in that bitmap that indicates + the transparent portions of the mask, by default BLACK is used. """ newobj = _gdi.new_Mask(*args, **kwargs) self.this = newobj.this @@ -572,17 +669,7 @@ class MaskPtr(Mask): self.__class__ = Mask _gdi.Mask_swigregister(MaskPtr) -def MaskColour(*args, **kwargs): - """ - MaskColour(Bitmap bitmap, Colour colour) -> Mask - - Constructs a mask from a bitmap and a colour in that bitmap that indicates the - background. - """ - val = _gdi.new_MaskColour(*args, **kwargs) - val.thisown = 1 - return val - +MaskColour = Mask class Icon(GDIObject): def __repr__(self): return "<%s.%s; proxy of C++ wxIcon instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) @@ -755,10 +842,30 @@ def IconBundleFromIcon(*args, **kwargs): return val class Cursor(GDIObject): + """ + A cursor is a small bitmap usually used for denoting where the + mouse pointer is, with a picture that might indicate the + interpretation of a mouse click. + + A single cursor object may be used in many windows (any subwindow + type). The wxWindows convention is to set the cursor for a + window, as in X, rather than to set it globally as in MS Windows, + although a global wx.SetCursor function is also available for use + on MS Windows. + """ def __repr__(self): return "<%s.%s; proxy of C++ wxCursor instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): - """__init__(String cursorName, long flags, int hotSpotX=0, int hotSpotY=0) -> Cursor""" + """ + __init__(String cursorName, long type, int hotSpotX=0, int hotSpotY=0) -> Cursor + + Construct a Cursor from a file. Specify the type of file using + wx.BITAMP_TYPE* constants, and specify the hotspot if not using a + .cur file. + + This cursor is not available on wxGTK, use wx.StockCursor, + wx.CursorFromImage, or wx.CursorFromBits instead. + """ newobj = _gdi.new_Cursor(*args, **kwargs) self.this = newobj.this self.thisown = 1 @@ -783,23 +890,33 @@ class CursorPtr(Cursor): _gdi.Cursor_swigregister(CursorPtr) def StockCursor(*args, **kwargs): - """StockCursor(int id) -> Cursor""" + """ + StockCursor(int id) -> Cursor + + Create a cursor using one of the stock cursors. Note that not + all cursors are available on all platforms. + """ val = _gdi.new_StockCursor(*args, **kwargs) val.thisown = 1 return val def CursorFromImage(*args, **kwargs): - """CursorFromImage(Image image) -> Cursor""" - val = _gdi.new_CursorFromImage(*args, **kwargs) - val.thisown = 1 - return val - -def CursorFromBits(*args, **kwargs): """ - CursorFromBits(PyObject bits, int width, int height, int hotSpotX=-1, - int hotSpotY=-1, PyObject maskBits=0) -> Cursor + CursorFromImage(Image image) -> Cursor + + Constructs a cursor from a wxImage. The cursor is monochrome, + colors with the RGB elements all greater than 127 will be + foreground, colors less than this background. The mask (if any) + will be used as transparent. + + In MSW the foreground will be white and the background black. The + cursor is resized to 32x32 In GTK, the two most frequent colors + will be used for foreground and background. The cursor will be + displayed at the size of the image. On MacOS the cursor is + resized to 16x16 and currently only shown as black/white (mask + respected). """ - val = _gdi.new_CursorFromBits(*args, **kwargs) + val = _gdi.new_CursorFromImage(*args, **kwargs) val.thisown = 1 return val @@ -1412,11 +1529,11 @@ class Font(GDIObject): def __nonzero__(self): return self.Ok() def __eq__(*args, **kwargs): - """__eq__(Font font) -> bool""" + """__eq__(Font other) -> bool""" return _gdi.Font___eq__(*args, **kwargs) def __ne__(*args, **kwargs): - """__ne__(Font font) -> bool""" + """__ne__(Font other) -> bool""" return _gdi.Font___ne__(*args, **kwargs) def GetPointSize(*args, **kwargs): @@ -2086,8 +2203,8 @@ _gdi.EncodingConverter_swigregister(EncodingConverterPtr) def GetTranslation(*args): """ - GetTranslation(String sz) -> String - GetTranslation(String sz1, String sz2, size_t n) -> String + GetTranslation(String str) -> String + GetTranslation(String str, String strPlural, size_t n) -> String """ return _gdi.GetTranslation(*args) @@ -2436,6 +2553,10 @@ class DC(core.Object): """ return _gdi.DC_GetMultiLineTextExtent(*args, **kwargs) + def GetPartialTextExtents(*args, **kwargs): + """GetPartialTextExtents(String text) -> wxArrayInt""" + return _gdi.DC_GetPartialTextExtents(*args, **kwargs) + def GetSize(*args, **kwargs): """ GetSize() -> Size @@ -2814,14 +2935,23 @@ def MemoryDCFromDC(*args, **kwargs): class BufferedDC(MemoryDC): def __repr__(self): return "<%s.%s; proxy of C++ wxBufferedDC instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) - def __init__(self, *args, **kwargs): - """__init__(DC dc, Bitmap buffer) -> BufferedDC""" - newobj = _gdi.new_BufferedDC(*args, **kwargs) + def __init__(self, *args): + """ + __init__(DC dc, Bitmap buffer) -> BufferedDC + __init__(DC dc, Size area) -> BufferedDC + """ + newobj = _gdi.new_BufferedDC(*args) self.this = newobj.this self.thisown = 1 del newobj.thisown self._dc = args[0] # save a ref so the other dc will not be deleted before self + def __del__(self, destroy=_gdi.delete_BufferedDC): + """__del__()""" + try: + if self.thisown: destroy(self) + except: pass + def UnMask(*args, **kwargs): """UnMask()""" return _gdi.BufferedDC_UnMask(*args, **kwargs) @@ -2834,9 +2964,9 @@ class BufferedDCPtr(BufferedDC): self.__class__ = BufferedDC _gdi.BufferedDC_swigregister(BufferedDCPtr) -def BufferedDCInternalBuffer(*args, **kwargs): +def BufferedDCInternalBuffer(*args): """BufferedDCInternalBuffer(DC dc, Size area) -> BufferedDC""" - val = _gdi.new_BufferedDCInternalBuffer(*args, **kwargs) + val = _gdi.new_BufferedDCInternalBuffer(*args) val.thisown = 1 val._dc = args[0] # save a ref so the other dc will not be deleted before self return val