Changed how the stock objects (wx.RED, wx.RED_PEN, wx.RED_BRUSH, etc.)

are initialized.  They are now created as a wrapper object that
initializes itself on first use (when an attribute of the object is
requested.)  This was needed because of similar delayed initialization
functionality that was implemented in wxWidgets, but the end result is
cleaner for wxPython as well, and allowed me to remove some ugly code
under the covers.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38802 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2006-04-18 21:49:48 +00:00
parent 5d7b75542e
commit 99a001dd43
14 changed files with 326 additions and 337 deletions

View File

@ -112,7 +112,7 @@ class wxTreeListHeaderWindow : public wxWindow
{
protected:
wxTreeListMainWindow *m_owner;
wxCursor *m_currentCursor;
const wxCursor *m_currentCursor;
wxCursor *m_resizeCursor;
bool m_isDragging;

View File

@ -114,6 +114,22 @@ not a top-level window.
Added GetResourcesDir and GetLocalizedResourcesDir to
wx.StandardPaths.
Added a GetReceivedFormat method to wx.DataObjectComposite. You can
use this to find out what format of data object was recieved from the
source of the clipboard or DnD operation, and then you'll know which
of the component data objects to use to access the data.
Changed how the stock objects (wx.RED, wx.RED_PEN, wx.RED_BRUSH, etc.)
are initialized. They are now created as a wrapper object that
initializes itself on first use (when an attribute of the object is
requested.) This was needed because of similar delayed initialization
functionality that was implemented in wxWidgets, but the end result is
cleaner for wxPython as well, and allowed me to remove some ugly code
under the covers.
2.6.3.2
@ -183,7 +199,8 @@ need to modify any of the \*.i files or to add your own, then you will
want to be sure to use a matching SWIG. See wxPython/SWIG/README.txt
in the source tarball for details.
wx.Image.Copy now also copies the alpha channel.
wx.Image.Copy, Mirror, and GetSubImage now also do the right thing
with the alpha channel.
wxMSW: Fixed problem in wx.TextCtrl where using SetValue and
wx.TE_RICH2 would cause the control to be shown if it was hidden.
@ -240,6 +257,10 @@ zoomed plot and move it around with a mouse drag.
XRCed updated to allow wxMenuBar to be created inside a wxFrame.
Added wx.StandardPaths.GetDocumentsDir() (patch 1214360)

View File

@ -104,7 +104,6 @@ typedef wxPoint2DDouble wxPoint2D;
void __wxPyPreStart(PyObject*);
void __wxPyCleanup();
PyObject* __wxPySetDictionary(PyObject*, PyObject* args);
PyObject* __wxPyFixStockObjects(PyObject*, PyObject* args);
void wxSetDefaultPyEncoding(const char* encoding);
const char* wxGetDefaultPyEncoding();

View File

@ -424,40 +424,7 @@
%rename(IMAGE_LIST_SMALL) wxIMAGE_LIST_SMALL;
%rename(IMAGE_LIST_STATE) wxIMAGE_LIST_STATE;
%rename(ImageList) wxImageList;
%rename(NORMAL_FONT) wxNORMAL_FONT;
%rename(SMALL_FONT) wxSMALL_FONT;
%rename(ITALIC_FONT) wxITALIC_FONT;
%rename(SWISS_FONT) wxSWISS_FONT;
%rename(RED_PEN) wxRED_PEN;
%rename(CYAN_PEN) wxCYAN_PEN;
%rename(GREEN_PEN) wxGREEN_PEN;
%rename(BLACK_PEN) wxBLACK_PEN;
%rename(WHITE_PEN) wxWHITE_PEN;
%rename(TRANSPARENT_PEN) wxTRANSPARENT_PEN;
%rename(BLACK_DASHED_PEN) wxBLACK_DASHED_PEN;
%rename(GREY_PEN) wxGREY_PEN;
%rename(MEDIUM_GREY_PEN) wxMEDIUM_GREY_PEN;
%rename(LIGHT_GREY_PEN) wxLIGHT_GREY_PEN;
%rename(BLUE_BRUSH) wxBLUE_BRUSH;
%rename(GREEN_BRUSH) wxGREEN_BRUSH;
%rename(WHITE_BRUSH) wxWHITE_BRUSH;
%rename(BLACK_BRUSH) wxBLACK_BRUSH;
%rename(TRANSPARENT_BRUSH) wxTRANSPARENT_BRUSH;
%rename(CYAN_BRUSH) wxCYAN_BRUSH;
%rename(RED_BRUSH) wxRED_BRUSH;
%rename(GREY_BRUSH) wxGREY_BRUSH;
%rename(MEDIUM_GREY_BRUSH) wxMEDIUM_GREY_BRUSH;
%rename(LIGHT_GREY_BRUSH) wxLIGHT_GREY_BRUSH;
%rename(BLACK) wxBLACK;
%rename(WHITE) wxWHITE;
%rename(RED) wxRED;
%rename(BLUE) wxBLUE;
%rename(GREEN) wxGREEN;
%rename(CYAN) wxCYAN;
%rename(LIGHT_GREY) wxLIGHT_GREY;
%rename(STANDARD_CURSOR) wxSTANDARD_CURSOR;
%rename(HOURGLASS_CURSOR) wxHOURGLASS_CURSOR;
%rename(CROSS_CURSOR) wxCROSS_CURSOR;
%rename(StockGDI) wxStockGDI;
%rename(NullBitmap) wxNullBitmap;
%rename(NullIcon) wxNullIcon;
%rename(NullCursor) wxNullCursor;
@ -466,14 +433,11 @@
%rename(NullPalette) wxNullPalette;
%rename(NullFont) wxNullFont;
%rename(NullColour) wxNullColour;
%rename(GDIObjListBase) wxGDIObjListBase;
%rename(PenList) wxPenList;
%rename(BrushList) wxBrushList;
%rename(ColourDatabase) wxColourDatabase;
%rename(FontList) wxFontList;
%rename(TheFontList) wxTheFontList;
%rename(ThePenList) wxThePenList;
%rename(TheBrushList) wxTheBrushList;
%rename(TheColourDatabase) wxTheColourDatabase;
%rename(ColourDatabase) wxColourDatabase;
%rename(Effects) wxEffects;
%rename(CONTROL_DISABLED) wxCONTROL_DISABLED;
%rename(CONTROL_FOCUSED) wxCONTROL_FOCUSED;

View File

@ -3,5 +3,40 @@
MaskColour
NORMAL_FONT
SMALL_FONT
ITALIC_FONT
SWISS_FONT
RED_PEN
CYAN_PEN
GREEN_PEN
BLACK_PEN
WHITE_PEN
TRANSPARENT_PEN
BLACK_DASHED_PEN
GREY_PEN
MEDIUM_GREY_PEN
LIGHT_GREY_PEN
BLUE_BRUSH
GREEN_BRUSH
WHITE_BRUSH
BLACK_BRUSH
TRANSPARENT_BRUSH
CYAN_BRUSH
RED_BRUSH
GREY_BRUSH
MEDIUM_GREY_BRUSH
LIGHT_GREY_BRUSH
BLACK
WHITE
RED
BLUE
GREEN
CYAN
LIGHT_GREY
STANDARD_CURSOR
HOURGLASS_CURSOR
CROSS_CURSOR
wxTheFontList
wxTheBrushList
wxTheColourDatabase

View File

@ -123,7 +123,6 @@ items or or of 3-tuples (flags, keyCode, cmdID)
%immutable;
// See also wxPy_ReinitStockObjects in helpers.cpp
const wxAcceleratorTable wxNullAcceleratorTable;
%mutable;

View File

@ -280,10 +280,5 @@ from _windows import *
from _controls import *
from _misc import *
# Fixup the stock objects since they can't be used yet. (They will be
# restored in wx.PyApp.OnInit.)
_core_._wxPyFixStockObjects()
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------

View File

@ -1013,7 +1013,6 @@ range -1.0..1.0 where -1.0 is -360 degrees and 1.0 is 360 degrees", "");
// See also wxPy_ReinitStockObjects in helpers.cpp
%immutable;
const wxImage wxNullImage;
%mutable;

View File

@ -295,7 +295,6 @@ public:
//---------------------------------------------------------------------------
// See also wxPy_ReinitStockObjects in helpers.cpp
wxMimeTypesManager* const wxTheMimeTypesManager;

View File

@ -17,50 +17,139 @@
%newgroup
// See also wxPy_ReinitStockObjects in helpers.cpp
class wxStockGDI
{
public:
enum Item {
BRUSH_BLACK,
BRUSH_BLUE,
BRUSH_CYAN,
BRUSH_GREEN,
BRUSH_GREY,
BRUSH_LIGHTGREY,
BRUSH_MEDIUMGREY,
BRUSH_RED,
BRUSH_TRANSPARENT,
BRUSH_WHITE,
COLOUR_BLACK,
COLOUR_BLUE,
COLOUR_CYAN,
COLOUR_GREEN,
COLOUR_LIGHTGREY,
COLOUR_RED,
COLOUR_WHITE,
CURSOR_CROSS,
CURSOR_HOURGLASS,
CURSOR_STANDARD,
FONT_ITALIC,
FONT_NORMAL,
FONT_SMALL,
FONT_SWISS,
PEN_BLACK,
PEN_BLACKDASHED,
PEN_CYAN,
PEN_GREEN,
PEN_GREY,
PEN_LIGHTGREY,
PEN_MEDIUMGREY,
PEN_RED,
PEN_TRANSPARENT,
PEN_WHITE,
ITEMCOUNT
};
wxStockGDI();
virtual ~wxStockGDI();
static void DeleteAll();
static wxStockGDI& instance();
static const wxBrush* GetBrush(Item item);
static const wxColour* GetColour(Item item);
static const wxCursor* GetCursor(Item item);
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)
_wxPyStockPen = _wxPyMakeDelayedInitWrapper(StockGDI.GetPen)
_wxPyStockBrush = _wxPyMakeDelayedInitWrapper(StockGDI.GetBrush)
_wxPyStockCursor = _wxPyMakeDelayedInitWrapper(StockGDI.GetCursor)
_wxPyStockColour = _wxPyMakeDelayedInitWrapper(StockGDI.GetColour)
_wxPyStockFont = _wxPyMakeDelayedInitWrapper(_wxPyFontInit)
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)
}
%immutable;
%threadWrapperOff;
wxFont* const wxNORMAL_FONT;
wxFont* const wxSMALL_FONT;
wxFont* const wxITALIC_FONT;
wxFont* const wxSWISS_FONT;
wxPen* const wxRED_PEN;
wxPen* const wxCYAN_PEN;
wxPen* const wxGREEN_PEN;
wxPen* const wxBLACK_PEN;
wxPen* const wxWHITE_PEN;
wxPen* const wxTRANSPARENT_PEN;
wxPen* const wxBLACK_DASHED_PEN;
wxPen* const wxGREY_PEN;
wxPen* const wxMEDIUM_GREY_PEN;
wxPen* const wxLIGHT_GREY_PEN;
wxBrush* const wxBLUE_BRUSH;
wxBrush* const wxGREEN_BRUSH;
wxBrush* const wxWHITE_BRUSH;
wxBrush* const wxBLACK_BRUSH;
wxBrush* const wxTRANSPARENT_BRUSH;
wxBrush* const wxCYAN_BRUSH;
wxBrush* const wxRED_BRUSH;
wxBrush* const wxGREY_BRUSH;
wxBrush* const wxMEDIUM_GREY_BRUSH;
wxBrush* const wxLIGHT_GREY_BRUSH;
wxColour* const wxBLACK;
wxColour* const wxWHITE;
wxColour* const wxRED;
wxColour* const wxBLUE;
wxColour* const wxGREEN;
wxColour* const wxCYAN;
wxColour* const wxLIGHT_GREY;
wxCursor* const wxSTANDARD_CURSOR;
wxCursor* const wxHOURGLASS_CURSOR;
wxCursor* const wxCROSS_CURSOR;
const wxBitmap wxNullBitmap;
const wxIcon wxNullIcon;
const wxCursor wxNullCursor;
@ -74,36 +163,92 @@ 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)()
// }
//---------------------------------------------------------------------------
class wxPenList : public wxObject {
class wxGDIObjListBase {
public:
void AddPen(wxPen* pen);
wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
void RemovePen(wxPen* pen);
int GetCount();
wxGDIObjListBase();
~wxGDIObjListBase();
};
//---------------------------------------------------------------------------
class wxBrushList : public wxObject {
class wxPenList : public wxGDIObjListBase {
public:
void AddBrush(wxBrush *brush);
wxBrush * FindOrCreateBrush(const wxColour& colour, int style=wxSOLID);
void RemoveBrush(wxBrush *brush);
wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
int GetCount();
void AddPen(wxPen* pen);
void RemovePen(wxPen* pen);
%pythoncode {
AddPen = wx._deprecated(AddPen)
RemovePen = wx._deprecated(RemovePen)
}
// int GetCount();
};
class wxBrushList : public wxGDIObjListBase {
public:
wxBrush * FindOrCreateBrush(const wxColour& colour, int style=wxSOLID);
void AddBrush(wxBrush *brush);
void RemoveBrush(wxBrush *brush);
%pythoncode {
AddBrush = wx._deprecated(AddBrush)
RemoveBrush = wx._deprecated(RemoveBrush)
}
// int GetCount();
};
class wxFontList : public wxGDIObjListBase {
public:
wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
bool underline = false,
const wxString& facename = wxPyEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
void AddFont(wxFont* font);
void RemoveFont(wxFont *font);
%pythoncode {
AddFont = wx._deprecated(AddFont)
RemoveFont = wx._deprecated(RemoveFont)
}
// int GetCount();
};
//---------------------------------------------------------------------------
MustHaveApp(wxColourDatabase);
class wxColourDatabase : public wxObject {
class wxColourDatabase {
public:
wxColourDatabase();
~wxColourDatabase();
@ -123,35 +268,23 @@ public:
}
};
//---------------------------------------------------------------------------
class wxFontList : public wxObject {
public:
void AddFont(wxFont* font);
wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
bool underline = false, const wxString& facename = wxPyEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
void RemoveFont(wxFont *font);
int GetCount();
};
//---------------------------------------------------------------------------
%newgroup
%inline {
wxFontList* _wxPyInitTheFontList() { return wxTheFontList; }
wxPenList* _wxPyInitThePenList() { return wxThePenList; }
wxBrushList* _wxPyInitTheBrushList() { return wxTheBrushList; }
wxColourDatabase* _wxPyInitTheColourDatabase() { return wxTheColourDatabase; }
}
// See also wxPy_ReinitStockObjects in helpers.cpp
%immutable;
wxFontList* const wxTheFontList;
wxPenList* const wxThePenList;
wxBrushList* const wxTheBrushList;
wxColourDatabase* const wxTheColourDatabase;
%mutable;
%pythoncode {
wxTheFontList = _wxPyMakeDelayedInitWrapper(_wxPyInitTheFontList)()
wxThePenList = _wxPyMakeDelayedInitWrapper(_wxPyInitThePenList)()
wxTheBrushList = _wxPyMakeDelayedInitWrapper(_wxPyInitTheBrushList)()
wxTheColourDatabase = _wxPyMakeDelayedInitWrapper(_wxPyInitTheColourDatabase)()
}
//---------------------------------------------------------------------------

View File

@ -89,7 +89,6 @@ public:
%immutable;
// See also wxPy_ReinitStockObjects in helpers.cpp
const wxValidator wxDefaultValidator;
%mutable;

View File

@ -28,7 +28,6 @@
%include __core_rename.i
%native(_wxPySetDictionary) __wxPySetDictionary;
%native(_wxPyFixStockObjects) __wxPyFixStockObjects;
%pythoncode {

View File

@ -457,10 +457,6 @@ void wxPyApp::_BootstrapApp()
// wxSystemOptions::SetOption(wxT("mac.textcontrol-use-mlte"), 1);
// The stock objects were all NULL when they were loaded into
// SWIG generated proxies, so re-init those now...
wxPy_ReinitStockObjects(3);
wxPyEndBlockThreads(blocked);
haveInitialized = true;
}
@ -588,9 +584,6 @@ void __wxPyPreStart(PyObject* moduleDict)
// Ensure that the build options in the DLL (or whatever) match this build
wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "wxPython");
// Init the stock objects to a non-NULL value so SWIG doesn't create them as None
wxPy_ReinitStockObjects(1);
wxInitAllImageHandlers();
}
@ -717,163 +710,6 @@ PyObject* __wxPySetDictionary(PyObject* /* self */, PyObject* args)
//---------------------------------------------------------------------------
// The stock objects are no longer created when the wx._core_ module is
// imported, but only after the app object has been created. The
// wxPy_ReinitStockObjects function will be called 3 times to pass the stock
// objects though various stages of evolution:
//
// pass 1: Set all the pointers to a non-NULL value so the Python proxy
// object will be created (otherwise SWIG will just use None.)
//
// pass 2: After the module has been imported and the python proxys have
// been created, then set the __class__ to be _wxPyUnbornObject so
// it will catch any access to the object and will raise an exception.
//
// pass 3: Finally, from BootstrapApp patch things up so the stock objects
// can be used.
PyObject* __wxPyFixStockObjects(PyObject* /* self */, PyObject* args)
{
wxPy_ReinitStockObjects(2);
RETURN_NONE();
}
static void rsoPass2(const char* name)
{
static PyObject* unbornObjectClass = NULL;
PyObject* obj;
if (unbornObjectClass == NULL) {
unbornObjectClass = PyDict_GetItemString(wxPython_dict, "_wxPyUnbornObject");
Py_INCREF(unbornObjectClass);
}
// Find the object instance
obj = PyDict_GetItemString(wxPython_dict, (char*)dropwx(name));
wxCHECK_RET(obj != NULL, wxT("Unable to find stock object"));
wxCHECK_RET(wxPySwigInstance_Check(obj), wxT("Not a swig instance"));
// Change its class
PyObject_SetAttrString(obj, "__class__", unbornObjectClass);
}
static void rsoPass3(const char* name, const char* classname, void* ptr)
{
PyObject* obj;
PyObject* classobj;
PyObject* ptrobj;
// Find the object instance
obj = PyDict_GetItemString(wxPython_dict, (char*)dropwx(name));
wxCHECK_RET(obj != NULL, wxT("Unable to find stock object"));
wxCHECK_RET(wxPySwigInstance_Check(obj), wxT("Not a swig instance"));
// Find the class object and put it back in the instance
classobj = PyDict_GetItemString(wxPython_dict, (char*)dropwx(classname));
wxCHECK_RET(classobj != NULL, wxT("Unable to find stock class object"));
PyObject_SetAttrString(obj, "__class__", classobj);
// Rebuild the .this swigified pointer with the new value of the C++ pointer
ptrobj = wxPyMakeSwigPtr(ptr, wxString(classname, *wxConvCurrent));
PyObject_SetAttrString(obj, "this", ptrobj);
Py_DECREF(ptrobj);
}
void wxPy_ReinitStockObjects(int pass)
{
// If there is already an App object then wxPython is probably embedded in
// a wx C++ application, so there is no need to do all this.
static bool embedded = false;
if ((pass == 1 || pass == 2) && wxTheApp) {
embedded = true;
return;
}
if (pass == 3 && embedded)
return;
#define REINITOBJ(name, classname) \
if (pass == 1) { name = (classname*)0xC0C0C0C0; } \
else if (pass == 2) { rsoPass2(#name); } \
else if (pass == 3) { rsoPass3(#name, #classname, (void*)name); }
#define REINITOBJ2(name, classname) \
if (pass == 1) { } \
else if (pass == 2) { rsoPass2(#name); } \
else if (pass == 3) { rsoPass3(#name, #classname, (void*)&name); }
REINITOBJ(wxNORMAL_FONT, wxFont);
REINITOBJ(wxSMALL_FONT, wxFont);
REINITOBJ(wxITALIC_FONT, wxFont);
REINITOBJ(wxSWISS_FONT, wxFont);
REINITOBJ(wxRED_PEN, wxPen);
REINITOBJ(wxCYAN_PEN, wxPen);
REINITOBJ(wxGREEN_PEN, wxPen);
REINITOBJ(wxBLACK_PEN, wxPen);
REINITOBJ(wxWHITE_PEN, wxPen);
REINITOBJ(wxTRANSPARENT_PEN, wxPen);
REINITOBJ(wxBLACK_DASHED_PEN, wxPen);
REINITOBJ(wxGREY_PEN, wxPen);
REINITOBJ(wxMEDIUM_GREY_PEN, wxPen);
REINITOBJ(wxLIGHT_GREY_PEN, wxPen);
REINITOBJ(wxBLUE_BRUSH, wxBrush);
REINITOBJ(wxGREEN_BRUSH, wxBrush);
REINITOBJ(wxWHITE_BRUSH, wxBrush);
REINITOBJ(wxBLACK_BRUSH, wxBrush);
REINITOBJ(wxTRANSPARENT_BRUSH, wxBrush);
REINITOBJ(wxCYAN_BRUSH, wxBrush);
REINITOBJ(wxRED_BRUSH, wxBrush);
REINITOBJ(wxGREY_BRUSH, wxBrush);
REINITOBJ(wxMEDIUM_GREY_BRUSH, wxBrush);
REINITOBJ(wxLIGHT_GREY_BRUSH, wxBrush);
REINITOBJ(wxBLACK, wxColour);
REINITOBJ(wxWHITE, wxColour);
REINITOBJ(wxRED, wxColour);
REINITOBJ(wxBLUE, wxColour);
REINITOBJ(wxGREEN, wxColour);
REINITOBJ(wxCYAN, wxColour);
REINITOBJ(wxLIGHT_GREY, wxColour);
REINITOBJ(wxSTANDARD_CURSOR, wxCursor);
REINITOBJ(wxHOURGLASS_CURSOR, wxCursor);
REINITOBJ(wxCROSS_CURSOR, wxCursor);
REINITOBJ2(wxNullBitmap, wxBitmap);
REINITOBJ2(wxNullIcon, wxIcon);
REINITOBJ2(wxNullCursor, wxCursor);
REINITOBJ2(wxNullPen, wxPen);
REINITOBJ2(wxNullBrush, wxBrush);
REINITOBJ2(wxNullPalette, wxPalette);
REINITOBJ2(wxNullFont, wxFont);
REINITOBJ2(wxNullColour, wxColour);
REINITOBJ(wxTheFontList, wxFontList);
REINITOBJ(wxThePenList, wxPenList);
REINITOBJ(wxTheBrushList, wxBrushList);
REINITOBJ(wxTheColourDatabase, wxColourDatabase);
REINITOBJ2(wxDefaultValidator, wxValidator);
REINITOBJ2(wxNullImage, wxImage);
REINITOBJ2(wxNullAcceleratorTable, wxAcceleratorTable);
#undef REINITOBJ
#undef REINITOBJ2
}
//---------------------------------------------------------------------------
// Check for existence of a wxApp, setting an exception if there isn't one.

View File

@ -490,6 +490,53 @@ wxIMAGE_LIST_NORMAL = wx._gdi.IMAGE_LIST_NORMAL
wxIMAGE_LIST_SMALL = wx._gdi.IMAGE_LIST_SMALL
wxIMAGE_LIST_STATE = wx._gdi.IMAGE_LIST_STATE
wxImageList = wx._gdi.ImageList
wxStockGDI = wx._gdi.StockGDI
wxStockGDI_DeleteAll = wx._gdi.StockGDI_DeleteAll
wxStockGDI_instance = wx._gdi.StockGDI_instance
wxStockGDI_GetBrush = wx._gdi.StockGDI_GetBrush
wxStockGDI_GetColour = wx._gdi.StockGDI_GetColour
wxStockGDI_GetCursor = wx._gdi.StockGDI_GetCursor
wxStockGDI_GetPen = wx._gdi.StockGDI_GetPen
wxNullBitmap = wx._gdi.NullBitmap
wxNullIcon = wx._gdi.NullIcon
wxNullCursor = wx._gdi.NullCursor
wxNullPen = wx._gdi.NullPen
wxNullBrush = wx._gdi.NullBrush
wxNullPalette = wx._gdi.NullPalette
wxNullFont = wx._gdi.NullFont
wxNullColour = wx._gdi.NullColour
wxGDIObjListBase = wx._gdi.GDIObjListBase
wxPenList = wx._gdi.PenList
wxBrushList = wx._gdi.BrushList
wxFontList = wx._gdi.FontList
wxColourDatabase = wx._gdi.ColourDatabase
_wxPyInitTheFontList = wx._gdi._wxPyInitTheFontList
_wxPyInitThePenList = wx._gdi._wxPyInitThePenList
_wxPyInitTheBrushList = wx._gdi._wxPyInitTheBrushList
_wxPyInitTheColourDatabase = wx._gdi._wxPyInitTheColourDatabase
wxEffects = wx._gdi.Effects
wxCONTROL_DISABLED = wx._gdi.CONTROL_DISABLED
wxCONTROL_FOCUSED = wx._gdi.CONTROL_FOCUSED
wxCONTROL_PRESSED = wx._gdi.CONTROL_PRESSED
wxCONTROL_ISDEFAULT = wx._gdi.CONTROL_ISDEFAULT
wxCONTROL_ISSUBMENU = wx._gdi.CONTROL_ISSUBMENU
wxCONTROL_EXPANDED = wx._gdi.CONTROL_EXPANDED
wxCONTROL_CURRENT = wx._gdi.CONTROL_CURRENT
wxCONTROL_SELECTED = wx._gdi.CONTROL_SELECTED
wxCONTROL_CHECKED = wx._gdi.CONTROL_CHECKED
wxCONTROL_CHECKABLE = wx._gdi.CONTROL_CHECKABLE
wxCONTROL_UNDETERMINED = wx._gdi.CONTROL_UNDETERMINED
wxCONTROL_FLAGS_MASK = wx._gdi.CONTROL_FLAGS_MASK
wxCONTROL_DIRTY = wx._gdi.CONTROL_DIRTY
wxSplitterRenderParams = wx._gdi.SplitterRenderParams
wxRendererVersion = wx._gdi.RendererVersion
wxRendererVersion_IsCompatible = wx._gdi.RendererVersion_IsCompatible
wxRendererNative = wx._gdi.RendererNative
wxRendererNative_Get = wx._gdi.RendererNative_Get
wxRendererNative_GetGeneric = wx._gdi.RendererNative_GetGeneric
wxRendererNative_GetDefault = wx._gdi.RendererNative_GetDefault
wxRendererNative_Set = wx._gdi.RendererNative_Set
wxMaskColour = wx._gdi.MaskColour
wxNORMAL_FONT = wx._gdi.NORMAL_FONT
wxSMALL_FONT = wx._gdi.SMALL_FONT
wxITALIC_FONT = wx._gdi.ITALIC_FONT
@ -524,44 +571,8 @@ wxLIGHT_GREY = wx._gdi.LIGHT_GREY
wxSTANDARD_CURSOR = wx._gdi.STANDARD_CURSOR
wxHOURGLASS_CURSOR = wx._gdi.HOURGLASS_CURSOR
wxCROSS_CURSOR = wx._gdi.CROSS_CURSOR
wxNullBitmap = wx._gdi.NullBitmap
wxNullIcon = wx._gdi.NullIcon
wxNullCursor = wx._gdi.NullCursor
wxNullPen = wx._gdi.NullPen
wxNullBrush = wx._gdi.NullBrush
wxNullPalette = wx._gdi.NullPalette
wxNullFont = wx._gdi.NullFont
wxNullColour = wx._gdi.NullColour
wxPenList = wx._gdi.PenList
wxBrushList = wx._gdi.BrushList
wxColourDatabase = wx._gdi.ColourDatabase
wxFontList = wx._gdi.FontList
wxTheFontList = wx._gdi.TheFontList
wxThePenList = wx._gdi.ThePenList
wxTheBrushList = wx._gdi.TheBrushList
wxTheColourDatabase = wx._gdi.TheColourDatabase
wxEffects = wx._gdi.Effects
wxCONTROL_DISABLED = wx._gdi.CONTROL_DISABLED
wxCONTROL_FOCUSED = wx._gdi.CONTROL_FOCUSED
wxCONTROL_PRESSED = wx._gdi.CONTROL_PRESSED
wxCONTROL_ISDEFAULT = wx._gdi.CONTROL_ISDEFAULT
wxCONTROL_ISSUBMENU = wx._gdi.CONTROL_ISSUBMENU
wxCONTROL_EXPANDED = wx._gdi.CONTROL_EXPANDED
wxCONTROL_CURRENT = wx._gdi.CONTROL_CURRENT
wxCONTROL_SELECTED = wx._gdi.CONTROL_SELECTED
wxCONTROL_CHECKED = wx._gdi.CONTROL_CHECKED
wxCONTROL_CHECKABLE = wx._gdi.CONTROL_CHECKABLE
wxCONTROL_UNDETERMINED = wx._gdi.CONTROL_UNDETERMINED
wxCONTROL_FLAGS_MASK = wx._gdi.CONTROL_FLAGS_MASK
wxCONTROL_DIRTY = wx._gdi.CONTROL_DIRTY
wxSplitterRenderParams = wx._gdi.SplitterRenderParams
wxRendererVersion = wx._gdi.RendererVersion
wxRendererVersion_IsCompatible = wx._gdi.RendererVersion_IsCompatible
wxRendererNative = wx._gdi.RendererNative
wxRendererNative_Get = wx._gdi.RendererNative_Get
wxRendererNative_GetGeneric = wx._gdi.RendererNative_GetGeneric
wxRendererNative_GetDefault = wx._gdi.RendererNative_GetDefault
wxRendererNative_Set = wx._gdi.RendererNative_Set
wxMaskColour = wx._gdi.MaskColour
wxTheFontList = wx._gdi.wxTheFontList
wxTheBrushList = wx._gdi.wxTheBrushList
wxTheColourDatabase = wx._gdi.wxTheColourDatabase