X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d24a34bb5d3f17472179b38bcb0be253551fce65..18ba9da6b94a34129b6b04494033905a213a0114:/utils/wxPython/src/gtk/wx.py diff --git a/utils/wxPython/src/gtk/wx.py b/utils/wxPython/src/gtk/wx.py index bfc81f6d92..9ca948c728 100644 --- a/utils/wxPython/src/gtk/wx.py +++ b/utils/wxPython/src/gtk/wx.py @@ -34,66 +34,90 @@ class wxPyAppPtr(wxEvtHandlerPtr): def __init__(self,this): self.this = this self.thisown = 0 - def GetAppName(self): - val = wxc.wxPyApp_GetAppName(self.this) + def __del__(self,wxc=wxc): + if self.thisown == 1 : + wxc.delete_wxPyApp(self) + def GetAppName(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_GetAppName,(self,) + _args, _kwargs) return val - def GetClassName(self): - val = wxc.wxPyApp_GetClassName(self.this) + def GetClassName(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_GetClassName,(self,) + _args, _kwargs) return val - def GetExitOnFrameDelete(self): - val = wxc.wxPyApp_GetExitOnFrameDelete(self.this) + def GetExitOnFrameDelete(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_GetExitOnFrameDelete,(self,) + _args, _kwargs) return val - def GetPrintMode(self): - val = wxc.wxPyApp_GetPrintMode(self.this) + def GetPrintMode(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_GetPrintMode,(self,) + _args, _kwargs) return val - def GetTopWindow(self): - val = wxc.wxPyApp_GetTopWindow(self.this) - val = wxWindowPtr(val) + def GetTopWindow(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_GetTopWindow,(self,) + _args, _kwargs) + if val: val = wxWindowPtr(val) return val - def GetVendorName(self): - val = wxc.wxPyApp_GetVendorName(self.this) + def GetVendorName(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_GetVendorName,(self,) + _args, _kwargs) return val - def Dispatch(self): - val = wxc.wxPyApp_Dispatch(self.this) + def Dispatch(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_Dispatch,(self,) + _args, _kwargs) return val - def ExitMainLoop(self): - val = wxc.wxPyApp_ExitMainLoop(self.this) + def ExitMainLoop(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_ExitMainLoop,(self,) + _args, _kwargs) return val - def Initialized(self): - val = wxc.wxPyApp_Initialized(self.this) + def Initialized(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_Initialized,(self,) + _args, _kwargs) return val - def MainLoop(self): - val = wxc.wxPyApp_MainLoop(self.this) + def MainLoop(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_MainLoop,(self,) + _args, _kwargs) return val - def Pending(self): - val = wxc.wxPyApp_Pending(self.this) + def Pending(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_Pending,(self,) + _args, _kwargs) return val - def SetAppName(self,arg0): - val = wxc.wxPyApp_SetAppName(self.this,arg0) + def ProcessIdle(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_ProcessIdle,(self,) + _args, _kwargs) return val - def SetClassName(self,arg0): - val = wxc.wxPyApp_SetClassName(self.this,arg0) + def SetAppName(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_SetAppName,(self,) + _args, _kwargs) return val - def SetExitOnFrameDelete(self,arg0): - val = wxc.wxPyApp_SetExitOnFrameDelete(self.this,arg0) + def SetClassName(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_SetClassName,(self,) + _args, _kwargs) return val - def SetPrintMode(self,arg0): - val = wxc.wxPyApp_SetPrintMode(self.this,arg0) + def SetExitOnFrameDelete(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_SetExitOnFrameDelete,(self,) + _args, _kwargs) return val - def SetTopWindow(self,arg0): - val = wxc.wxPyApp_SetTopWindow(self.this,arg0.this) + def SetPrintMode(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_SetPrintMode,(self,) + _args, _kwargs) return val - def SetVendorName(self,arg0): - val = wxc.wxPyApp_SetVendorName(self.this,arg0) + def SetTopWindow(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_SetTopWindow,(self,) + _args, _kwargs) return val - def AfterMainLoop(self): - val = wxc.wxPyApp_AfterMainLoop(self.this) + def SetVendorName(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_SetVendorName,(self,) + _args, _kwargs) + return val + def GetStdIcon(self, *_args, **_kwargs): + val = apply(wxc.wxPyApp_GetStdIcon,(self,) + _args, _kwargs) + if val: val = wxIconPtr(val) ; val.thisown = 1 return val def __repr__(self): - return "" + return "" % (self.this,) class wxPyApp(wxPyAppPtr): - def __init__(self) : - self.this = wxc.new_wxPyApp() + def __init__(self,*_args,**_kwargs): + self.this = apply(wxc.new_wxPyApp,_args,_kwargs) + self.thisown = 1 + + + + +class __wxPyCleanupPtr : + def __init__(self,this): + self.this = this + self.thisown = 0 + def __del__(self,wxc=wxc): + if self.thisown == 1 : + wxc.delete___wxPyCleanup(self) + def __repr__(self): + return "" % (self.this,) +class __wxPyCleanup(__wxPyCleanupPtr): + def __init__(self,*_args,**_kwargs): + self.this = apply(wxc.new___wxPyCleanup,_args,_kwargs) self.thisown = 1 @@ -103,6 +127,20 @@ class wxPyApp(wxPyAppPtr): #-------------- FUNCTION WRAPPERS ------------------ +ptrcast = wxc.ptrcast + +ptrvalue = wxc.ptrvalue + +ptrset = wxc.ptrset + +ptrcreate = wxc.ptrcreate + +ptrfree = wxc.ptrfree + +ptradd = wxc.ptradd + +ptrmap = wxc.ptrmap + _wxStart = wxc._wxStart _wxSetDictionary = wxc._wxSetDictionary @@ -177,6 +215,7 @@ wxPASSWORD = wxc.wxPASSWORD wxTE_PROCESS_ENTER = wxc.wxTE_PROCESS_ENTER wxTE_PASSWORD = wxc.wxTE_PASSWORD wxTE_READONLY = wxc.wxTE_READONLY +wxTE_RICH = wxc.wxTE_RICH wxTE_MULTILINE = wxc.wxTE_MULTILINE wxCB_SIMPLE = wxc.wxCB_SIMPLE wxCB_DROPDOWN = wxc.wxCB_DROPDOWN @@ -209,6 +248,8 @@ wxBU_NOAUTODRAW = wxc.wxBU_NOAUTODRAW wxTR_HAS_BUTTONS = wxc.wxTR_HAS_BUTTONS wxTR_EDIT_LABELS = wxc.wxTR_EDIT_LABELS wxTR_LINES_AT_ROOT = wxc.wxTR_LINES_AT_ROOT +wxTR_MULTIPLE = wxc.wxTR_MULTIPLE +wxTR_HAS_VARIABLE_ROW_HEIGHT = wxc.wxTR_HAS_VARIABLE_ROW_HEIGHT wxLC_ICON = wxc.wxLC_ICON wxLC_SMALL_ICON = wxc.wxLC_SMALL_ICON wxLC_LIST = wxc.wxLC_LIST @@ -333,7 +374,12 @@ wxACCEL_SHIFT = wxc.wxACCEL_SHIFT wxPD_AUTO_HIDE = wxc.wxPD_AUTO_HIDE wxPD_APP_MODAL = wxc.wxPD_APP_MODAL wxPD_CAN_ABORT = wxc.wxPD_CAN_ABORT +wxPD_ELAPSED_TIME = wxc.wxPD_ELAPSED_TIME +wxPD_ESTIMATED_TIME = wxc.wxPD_ESTIMATED_TIME +wxPD_REMAINING_TIME = wxc.wxPD_REMAINING_TIME wxNO_DEFAULT = wxc.wxNO_DEFAULT +wxMENU_TEAROFF = wxc.wxMENU_TEAROFF +wxNO_FULL_REPAINT_ON_RESIZE = wxc.wxNO_FULL_REPAINT_ON_RESIZE wxDEFAULT = wxc.wxDEFAULT wxDECORATIVE = wxc.wxDECORATIVE wxROMAN = wxc.wxROMAN @@ -609,6 +655,9 @@ wxEVT_NC_LEFT_DCLICK = wxc.wxEVT_NC_LEFT_DCLICK wxEVT_NC_MIDDLE_DCLICK = wxc.wxEVT_NC_MIDDLE_DCLICK wxEVT_NC_RIGHT_DCLICK = wxc.wxEVT_NC_RIGHT_DCLICK wxEVT_CHAR = wxc.wxEVT_CHAR +wxEVT_KEY_DOWN = wxc.wxEVT_KEY_DOWN +wxEVT_KEY_UP = wxc.wxEVT_KEY_UP +wxEVT_CHAR_HOOK = wxc.wxEVT_CHAR_HOOK wxEVT_SCROLL_TOP = wxc.wxEVT_SCROLL_TOP wxEVT_SCROLL_BOTTOM = wxc.wxEVT_SCROLL_BOTTOM wxEVT_SCROLL_LINEUP = wxc.wxEVT_SCROLL_LINEUP @@ -630,8 +679,6 @@ wxEVT_END_SESSION = wxc.wxEVT_END_SESSION wxEVT_QUERY_END_SESSION = wxc.wxEVT_QUERY_END_SESSION wxEVT_ACTIVATE_APP = wxc.wxEVT_ACTIVATE_APP wxEVT_POWER = wxc.wxEVT_POWER -wxEVT_CHAR_HOOK = wxc.wxEVT_CHAR_HOOK -wxEVT_KEY_UP = wxc.wxEVT_KEY_UP wxEVT_ACTIVATE = wxc.wxEVT_ACTIVATE wxEVT_CREATE = wxc.wxEVT_CREATE wxEVT_DESTROY = wxc.wxEVT_DESTROY @@ -811,6 +858,12 @@ def EVT_CHAR(win, func): def EVT_CHAR_HOOK(win, func): win.Connect(-1, -1, wxEVT_CHAR_HOOK, func) +def EVT_KEY_DOWN(win, func): + win.Connect(-1, -1, wxEVT_KEY_DOWN, func) + +def EVT_KEY_UP(win, func): + win.Connect(-1, -1, wxEVT_KEY_UP, func) + def EVT_MENU_HIGHLIGHT(win, id, func): win.Connect(id, -1, wxEVT_MENU_HIGHLIGHT, func) @@ -1302,6 +1355,38 @@ class wxAcceleratorTable(wxAcceleratorTablePtr): self.this = miscc.new_wxAcceleratorTable(arg0) self.thisown = 1 +#---------------------------------------------------------------------- +# This helper function will take a wxPython object and convert it to +# another wxPython object type. This will not be able to create objects +# that are derived from wxPython classes by the user, only those that are +# actually part of wxPython and directly corespond to C++ objects. +# +# This is useful in situations where some method returns a generic +# type such as wxWindow, but you know that it is actually some +# derived type such as a wxTextCtrl. You can't call wxTextCtrl specific +# methods on a wxWindow object, but you can use this function to +# create a wxTextCtrl object that will pass the same pointer to +# the C++ code. You use it like this: +# +# textCtrl = wxPyTypeCast(window, "wxTextCtrl") +# +# +# WARNING: Using this function to type cast objects into types that +# they are not is not recommended and is likely to cause your +# program to crash... Hard. +# + +def wxPyTypeCast(obj, typeStr): + if hasattr(obj, "this"): + newPtr = ptrcast(obj.this, typeStr+"_p") + else: + newPtr = ptrcast(obj, typeStr+"_p") + theClass = globals()[typeStr+"Ptr"] + theObj = theClass(newPtr) + theObj.thisown = obj.thisown + return theObj + + #---------------------------------------------------------------------- ## class wxPyStdOutWindow: @@ -1360,8 +1445,8 @@ class wxApp(wxPyApp): if filename: sys.stdout = sys.stderr = open(filename, 'a') else: - #raise self.error, 'wxPyStdOutWindow not yet implemented.' - self.stdioWin = sys.stdout = sys.stderr = wxPyStdOutWindow() + raise self.error, 'wxPyStdOutWindow not yet implemented.' + #self.stdioWin = sys.stdout = sys.stderr = wxPyStdOutWindow() def RestoreStdio(self): sys.stdout, sys.stderr = self.saveStdio @@ -1370,3 +1455,10 @@ class wxApp(wxPyApp): #---------------------------------------------------------------------------- +# DO NOT hold any other references to this object. This is how we know when +# to cleanup system resources that wxWin is holding... +__cleanMeUp = __wxPyCleanup() +#---------------------------------------------------------------------------- + + +