X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/99a001dd43b3b2b23ea5787c7a94c5328e3c3375..e393c3fb102d565111b5cf280136a6e8b50bab85:/wxPython/src/_stockobjs.i diff --git a/wxPython/src/_stockobjs.i b/wxPython/src/_stockobjs.i index 08a5956c28..8eb9289ffa 100644 --- a/wxPython/src/_stockobjs.i +++ b/wxPython/src/_stockobjs.i @@ -70,81 +70,102 @@ public: static const wxPen* GetPen(Item item); virtual const wxFont* GetFont(Item item); -}; - -%pythoncode { -%# This function makes a class used to do delayed initialization of some -%# stock wx objects. When they are used the first time then an init function -%# is called to make the real instance, which is then used to replace the -%# original instance and class seen by the programmer. -def _wxPyMakeDelayedInitWrapper(initFunc): - class _wxPyStockObjectWrapper(object): - def __init__(self, *args): - self._args = args - def __getattr__(self, name): - obj = initFunc(*self._args) - self.__class__ = obj.__class__ - self.__dict__ = obj.__dict__ - return getattr(self, name) - def __str__(self): - return self.__getattr__("__str__")() - def __repr__(self): - return self.__getattr__("__repr__")() - return _wxPyStockObjectWrapper - -def _wxPyFontInit(id): - return StockGDI.instance().GetFont(id) + %pythoncode { + def _initStockObjects(): + import wx + wx.ITALIC_FONT.this = StockGDI.instance().GetFont(StockGDI.FONT_ITALIC).this + wx.NORMAL_FONT.this = StockGDI.instance().GetFont(StockGDI.FONT_NORMAL).this + wx.SMALL_FONT.this = StockGDI.instance().GetFont(StockGDI.FONT_SMALL).this + wx.SWISS_FONT.this = StockGDI.instance().GetFont(StockGDI.FONT_SWISS).this -_wxPyStockPen = _wxPyMakeDelayedInitWrapper(StockGDI.GetPen) -_wxPyStockBrush = _wxPyMakeDelayedInitWrapper(StockGDI.GetBrush) -_wxPyStockCursor = _wxPyMakeDelayedInitWrapper(StockGDI.GetCursor) -_wxPyStockColour = _wxPyMakeDelayedInitWrapper(StockGDI.GetColour) -_wxPyStockFont = _wxPyMakeDelayedInitWrapper(_wxPyFontInit) + wx.BLACK_DASHED_PEN.this = StockGDI.GetPen(StockGDI.PEN_BLACKDASHED).this + wx.BLACK_PEN.this = StockGDI.GetPen(StockGDI.PEN_BLACK).this + wx.CYAN_PEN.this = StockGDI.GetPen(StockGDI.PEN_CYAN).this + wx.GREEN_PEN.this = StockGDI.GetPen(StockGDI.PEN_GREEN).this + wx.GREY_PEN.this = StockGDI.GetPen(StockGDI.PEN_GREY).this + wx.LIGHT_GREY_PEN.this = StockGDI.GetPen(StockGDI.PEN_LIGHTGREY).this + wx.MEDIUM_GREY_PEN.this = StockGDI.GetPen(StockGDI.PEN_MEDIUMGREY).this + wx.RED_PEN.this = StockGDI.GetPen(StockGDI.PEN_RED).this + wx.TRANSPARENT_PEN.this = StockGDI.GetPen(StockGDI.PEN_TRANSPARENT).this + wx.WHITE_PEN.this = StockGDI.GetPen(StockGDI.PEN_WHITE).this + + wx.BLACK_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_BLACK).this + wx.BLUE_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_BLUE).this + wx.CYAN_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_CYAN).this + wx.GREEN_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_GREEN).this + wx.GREY_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_GREY).this + wx.LIGHT_GREY_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_LIGHTGREY).this + wx.MEDIUM_GREY_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_MEDIUMGREY).this + wx.RED_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_RED).this + wx.TRANSPARENT_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_TRANSPARENT).this + wx.WHITE_BRUSH.this = StockGDI.GetBrush(StockGDI.BRUSH_WHITE).this + + wx.BLACK.this = StockGDI.GetColour(StockGDI.COLOUR_BLACK).this + wx.BLUE.this = StockGDI.GetColour(StockGDI.COLOUR_BLUE).this + wx.CYAN.this = StockGDI.GetColour(StockGDI.COLOUR_CYAN).this + wx.GREEN.this = StockGDI.GetColour(StockGDI.COLOUR_GREEN).this + wx.LIGHT_GREY.this = StockGDI.GetColour(StockGDI.COLOUR_LIGHTGREY).this + wx.RED.this = StockGDI.GetColour(StockGDI.COLOUR_RED).this + wx.WHITE.this = StockGDI.GetColour(StockGDI.COLOUR_WHITE).this + + wx.CROSS_CURSOR.this = StockGDI.GetCursor(StockGDI.CURSOR_CROSS).this + wx.HOURGLASS_CURSOR.this = StockGDI.GetCursor(StockGDI.CURSOR_HOURGLASS).this + wx.STANDARD_CURSOR.this = StockGDI.GetCursor(StockGDI.CURSOR_STANDARD).this + wx.TheFontList.this = _wxPyInitTheFontList().this + wx.ThePenList.this = _wxPyInitThePenList().this + wx.TheBrushList.this = _wxPyInitTheBrushList().this + wx.TheColourDatabase.this = _wxPyInitTheColourDatabase().this -ITALIC_FONT = _wxPyStockCursor(StockGDI.FONT_ITALIC) -NORMAL_FONT = _wxPyStockCursor(StockGDI.FONT_NORMAL) -SMALL_FONT = _wxPyStockCursor(StockGDI.FONT_SMALL) -SWISS_FONT = _wxPyStockCursor(StockGDI.FONT_SWISS) - -BLACK_DASHED_PEN = _wxPyStockPen(StockGDI.PEN_BLACKDASHED) -BLACK_PEN = _wxPyStockPen(StockGDI.PEN_BLACK) -CYAN_PEN = _wxPyStockPen(StockGDI.PEN_CYAN) -GREEN_PEN = _wxPyStockPen(StockGDI.PEN_GREEN) -GREY_PEN = _wxPyStockPen(StockGDI.PEN_GREY) -LIGHT_GREY_PEN = _wxPyStockPen(StockGDI.PEN_LIGHTGREY) -MEDIUM_GREY_PEN = _wxPyStockPen(StockGDI.PEN_MEDIUMGREY) -RED_PEN = _wxPyStockPen(StockGDI.PEN_RED) -TRANSPARENT_PEN = _wxPyStockPen(StockGDI.PEN_TRANSPARENT) -WHITE_PEN = _wxPyStockPen(StockGDI.PEN_WHITE) - -BLACK_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_BLACK) -BLUE_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_BLUE) -CYAN_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_CYAN) -GREEN_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_GREEN) -GREY_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_GREY) -LIGHT_GREY_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_LIGHTGREY) -MEDIUM_GREY_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_MEDIUMGREY) -RED_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_RED) -TRANSPARENT_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_TRANSPARENT) -WHITE_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_WHITE) - -BLACK = _wxPyStockColour(StockGDI.COLOUR_BLACK) -BLUE = _wxPyStockColour(StockGDI.COLOUR_BLUE) -CYAN = _wxPyStockColour(StockGDI.COLOUR_CYAN) -GREEN = _wxPyStockColour(StockGDI.COLOUR_GREEN) -LIGHT_GREY = _wxPyStockColour(StockGDI.COLOUR_LIGHTGREY) -RED = _wxPyStockColour(StockGDI.COLOUR_RED) -WHITE = _wxPyStockColour(StockGDI.COLOUR_WHITE) - -CROSS_CURSOR = _wxPyStockCursor(StockGDI.CURSOR_CROSS) -HOURGLASS_CURSOR = _wxPyStockCursor(StockGDI.CURSOR_HOURGLASS) -STANDARD_CURSOR = _wxPyStockCursor(StockGDI.CURSOR_STANDARD) - -} + + _initStockObjects = staticmethod(_initStockObjects) + } +}; +%pythoncode { +%# Create an uninitialized instance for the stock objects, they will +%# be initialized later when the wx.App object is created. +ITALIC_FONT = Font.__new__(Font) +NORMAL_FONT = Font.__new__(Font) +SMALL_FONT = Font.__new__(Font) +SWISS_FONT = Font.__new__(Font) + +BLACK_DASHED_PEN = Pen.__new__(Pen) +BLACK_PEN = Pen.__new__(Pen) +CYAN_PEN = Pen.__new__(Pen) +GREEN_PEN = Pen.__new__(Pen) +GREY_PEN = Pen.__new__(Pen) +LIGHT_GREY_PEN = Pen.__new__(Pen) +MEDIUM_GREY_PEN = Pen.__new__(Pen) +RED_PEN = Pen.__new__(Pen) +TRANSPARENT_PEN = Pen.__new__(Pen) +WHITE_PEN = Pen.__new__(Pen) + +BLACK_BRUSH = Brush.__new__(Brush) +BLUE_BRUSH = Brush.__new__(Brush) +CYAN_BRUSH = Brush.__new__(Brush) +GREEN_BRUSH = Brush.__new__(Brush) +GREY_BRUSH = Brush.__new__(Brush) +LIGHT_GREY_BRUSH = Brush.__new__(Brush) +MEDIUM_GREY_BRUSH = Brush.__new__(Brush) +RED_BRUSH = Brush.__new__(Brush) +TRANSPARENT_BRUSH = Brush.__new__(Brush) +WHITE_BRUSH = Brush.__new__(Brush) + +BLACK = Colour.__new__(Colour) +BLUE = Colour.__new__(Colour) +CYAN = Colour.__new__(Colour) +GREEN = Colour.__new__(Colour) +LIGHT_GREY = Colour.__new__(Colour) +RED = Colour.__new__(Colour) +WHITE = Colour.__new__(Colour) + +CROSS_CURSOR = Cursor.__new__(Cursor) +HOURGLASS_CURSOR = Cursor.__new__(Cursor) +STANDARD_CURSOR = Cursor.__new__(Cursor) +} %immutable; @@ -163,29 +184,6 @@ const wxColour wxNullColour; %mutable; -// %inline { -// const wxBitmap& _wxPyInitNullBitmap() { return wxNullBitmap; } -// const wxIcon& _wxPyInitNullIcon() { return wxNullIcon; } -// const wxCursor& _wxPyInitNullCursor() { return wxNullCursor; } -// const wxPen& _wxPyInitNullPen() { return wxNullPen; } -// const wxBrush& _wxPyInitNullBrush() { return wxNullBrush; } -// const wxPalette& _wxPyInitNullPalette() { return wxNullPalette; } -// const wxFont& _wxPyInitNullFont() { return wxNullFont; } -// const wxColour& _wxPyInitNullColour() { return wxNullColour; } -// } - -// %pythoncode { -// NullBitmap = _wxPyMakeDelayedInitWrapper(_wxPyInitNullBitmap)() -// NullIcon = _wxPyMakeDelayedInitWrapper(_wxPyInitNullIcon)() -// NullCursor = _wxPyMakeDelayedInitWrapper(_wxPyInitNullCursor)() -// NullPen = _wxPyMakeDelayedInitWrapper(_wxPyInitNullPen)() -// NullBrush = _wxPyMakeDelayedInitWrapper(_wxPyInitNullBrush)() -// NullPalette = _wxPyMakeDelayedInitWrapper(_wxPyInitNullPalette)() -// NullFont = _wxPyMakeDelayedInitWrapper(_wxPyInitNullFont)() -// NullColour = _wxPyMakeDelayedInitWrapper(_wxPyInitNullColour)() -// } - - //--------------------------------------------------------------------------- @@ -280,12 +278,16 @@ public: } %pythoncode { -wxTheFontList = _wxPyMakeDelayedInitWrapper(_wxPyInitTheFontList)() -wxThePenList = _wxPyMakeDelayedInitWrapper(_wxPyInitThePenList)() -wxTheBrushList = _wxPyMakeDelayedInitWrapper(_wxPyInitTheBrushList)() -wxTheColourDatabase = _wxPyMakeDelayedInitWrapper(_wxPyInitTheColourDatabase)() + +%# Create an uninitialized instance for the stock objects, they will +%# be initialized later when the wx.App object is created. +TheFontList = FontList.__new__(FontList) +ThePenList = PenList.__new__(PenList) +TheBrushList = BrushList.__new__(BrushList) +TheColourDatabase = ColourDatabase.__new__(ColourDatabase) } + //--------------------------------------------------------------------------- %pythoncode { NullColor = NullColour }