X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3ca6a5f04692678cd2d9f3ea0843fc3f5a0b254f..77436c4cbac2269e564dc4fcf4494a58feca0af4:/wxPython/src/windows.i?ds=sidebyside diff --git a/wxPython/src/windows.i b/wxPython/src/windows.i index 6e95e8e5ab..d5a7222622 100644 --- a/wxPython/src/windows.i +++ b/wxPython/src/windows.i @@ -16,6 +16,7 @@ %{ #include "helpers.h" #include +#include %} //---------------------------------------------------------------------- @@ -31,10 +32,17 @@ %pragma(python) code = "import wx" + +%{ + static wxString wxPyEmptyStr(""); +%} + //--------------------------------------------------------------------------- -class wxEvtHandler { +class wxEvtHandler : public wxObject { public: + wxEvtHandler(); + bool ProcessEvent(wxEvent& event); void AddPendingEvent(wxEvent& event); //bool SearchEventTable(wxEventTable& table, wxEvent& event); @@ -63,13 +71,11 @@ public: (wxObjectEventFunction) &wxPyCallback::EventThunker); } - } - %pragma(python) addtoclass = " - _prop_list_ = {} - " - +// %pragma(python) addtoclass = " +// _prop_list_ = {} +// " // %pragma(python) addtoclass = " // def __getattr__(self, name): // pl = self._prop_list_ @@ -105,24 +111,18 @@ public: wxWindow* GetWindow(); void SetWindow(wxWindow* window); - // Properties list - %pragma(python) addtoclass = " - _prop_list_ = { - 'window' : ('GetWindow', 'SetWindow'), - } - _prop_list_.update(wxEvtHandler._prop_list_) - " -}; + static bool IsSilent(); + static void SetBellOnError(int doIt = TRUE); -%inline %{ - bool wxValidator_IsSilent() { - return wxValidator::IsSilent(); - } +// // Properties list +// %pragma(python) addtoclass = " +// _prop_list_ = { +// 'window' : ('GetWindow', 'SetWindow'), +// } +// _prop_list_.update(wxEvtHandler._prop_list_) +// " +}; - void wxValidator_SetBellOnError(int doIt = TRUE) { - wxValidator::SetBellOnError(doIt); - } -%} //---------------------------------------------------------------------- %{ @@ -131,7 +131,6 @@ class wxPyValidator : public wxValidator { public: wxPyValidator() { } -// wxPyValidator(const wxPyValidator& other); ~wxPyValidator() { } @@ -159,12 +158,12 @@ public: return ptr; } + DEC_PYCALLBACK_BOOL_WXWIN(Validate); DEC_PYCALLBACK_BOOL_(TransferToWindow); DEC_PYCALLBACK_BOOL_(TransferFromWindow); PYPRIVATE; -// PyObject* m_data; }; IMP_PYCALLBACK_BOOL_WXWIN(wxPyValidator, wxValidator, Validate); @@ -178,12 +177,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxPyValidator, wxValidator); class wxPyValidator : public wxValidator { public: wxPyValidator(); -// ~wxPyValidator(); - - %addmethods { void Destroy() { delete self; } } void _setSelf(PyObject* self, PyObject* _class, int incref=TRUE); - %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyValidator, 0)" + %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyValidator, 1)" }; @@ -195,8 +191,8 @@ class wxWindow : public wxEvtHandler { public: wxWindow(wxWindow* parent, const wxWindowID id, - const wxPoint& pos = wxPyDefaultPosition, - const wxSize& size = wxPyDefaultSize, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, char* name = "panel"); @@ -210,6 +206,8 @@ public: void CentreOnScreen(int direction = wxBOTH ); void CenterOnScreen(int direction = wxBOTH ); + void Clear(); + // (uses apply'ed INOUT typemap, see above) %name(ClientToScreenXY)void ClientToScreen(int* x, int* y); wxPoint ClientToScreen(const wxPoint& pt); @@ -217,6 +215,7 @@ public: bool Close(int force = FALSE); bool Destroy(); void DestroyChildren(); + bool IsBeingDeleted(); #ifdef __WXMSW__ void DragAcceptFiles(bool accept); #endif @@ -329,6 +328,10 @@ public: void SetPosition(const wxPoint& pos) { self->Move(pos); } + + void SetRect(const wxRect& rect, int sizeFlags=wxSIZE_AUTO) { + self->SetSize(rect, sizeFlags); + } } void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1); @@ -337,6 +340,7 @@ public: //void SetPalette(wxPalette* palette); void SetCursor(const wxCursor&cursor); void SetEventHandler(wxEvtHandler* handler); + void SetExtraStyle(long exStyle); void SetTitle(const wxString& title); bool Show(bool show); bool TransferDataFromWindow(); @@ -379,42 +383,55 @@ public: return val " + void Freeze(); + void Thaw(); - // Properties list - %pragma(python) addtoclass = " - _prop_list_ = { - 'size' : ('GetSize', 'SetSize'), - 'enabled' : ('IsEnabled', 'Enable'), - 'background' : ('GetBackgroundColour', 'SetBackgroundColour'), - 'foreground' : ('GetForegroundColour', 'SetForegroundColour'), - 'children' : ('GetChildren', None), - 'charHeight' : ('GetCharHeight', None), - 'charWidth' : ('GetCharWidth', None), - 'clientSize' : ('GetClientSize', 'SetClientSize'), - 'font' : ('GetFont', 'SetFont'), - 'grandParent' : ('GetGrandParent', None), - 'handle' : ('GetHandle', None), - 'label' : ('GetLabel', 'SetLabel'), - 'name' : ('GetName', 'SetName'), - 'parent' : ('GetParent', None), - 'position' : ('GetPosition', 'SetPosition'), - 'title' : ('GetTitle', 'SetTitle'), - 'style' : ('GetWindowStyleFlag', 'SetWindowStyleFlag'), - 'visible' : ('IsShown', 'Show'), - 'toolTip' : ('GetToolTip', 'SetToolTip'), - 'sizer' : ('GetSizer', 'SetSizer'), - 'validator' : ('GetValidator', 'SetValidator'), - 'dropTarget' : ('GetDropTarget', 'SetDropTarget'), - 'caret' : ('GetCaret', 'SetCaret'), - 'autoLayout' : ('GetAutoLayout', 'SetAutoLayout'), - 'constraints' : ('GetConstraints', 'SetConstraints'), + wxString GetHelpText(); + void SetHelpText(const wxString& helpText); - } - _prop_list_.update(wxEvtHandler._prop_list_) - " + bool ScrollLines(int lines); + bool ScrollPages(int pages); + bool LineUp(); + bool LineDown(); + bool PageUp(); + bool PageDown(); + + + +// // Properties list +// %pragma(python) addtoclass = " +// _prop_list_ = { +// 'size' : ('GetSize', 'SetSize'), +// 'enabled' : ('IsEnabled', 'Enable'), +// 'background' : ('GetBackgroundColour', 'SetBackgroundColour'), +// 'foreground' : ('GetForegroundColour', 'SetForegroundColour'), +// 'children' : ('GetChildren', None), +// 'charHeight' : ('GetCharHeight', None), +// 'charWidth' : ('GetCharWidth', None), +// 'clientSize' : ('GetClientSize', 'SetClientSize'), +// 'font' : ('GetFont', 'SetFont'), +// 'grandParent' : ('GetGrandParent', None), +// 'handle' : ('GetHandle', None), +// 'label' : ('GetLabel', 'SetLabel'), +// 'name' : ('GetName', 'SetName'), +// 'parent' : ('GetParent', None), +// 'position' : ('GetPosition', 'SetPosition'), +// 'title' : ('GetTitle', 'SetTitle'), +// 'style' : ('GetWindowStyleFlag', 'SetWindowStyleFlag'), +// 'visible' : ('IsShown', 'Show'), +// 'toolTip' : ('GetToolTip', 'SetToolTip'), +// 'sizer' : ('GetSizer', 'SetSizer'), +// 'validator' : ('GetValidator', 'SetValidator'), +// 'dropTarget' : ('GetDropTarget', 'SetDropTarget'), +// 'caret' : ('GetCaret', 'SetCaret'), +// 'autoLayout' : ('GetAutoLayout', 'SetAutoLayout'), +// 'constraints' : ('GetConstraints', 'SetConstraints'), + +// } +// _prop_list_.update(wxEvtHandler._prop_list_) +// " }; -//%clear int* x, int* y; @@ -432,7 +449,6 @@ def wxDLG_SZE(win, size_width, height=None): return win.ConvertDialogSizeToPixels(wxSize(size_width, height)) " -#ifdef __WXMSW__ %inline %{ wxWindow* wxWindow_FindFocus() { return wxWindow::FindFocus(); @@ -440,6 +456,7 @@ def wxDLG_SZE(win, size_width, height=None): %} +#ifdef __WXMSW__ %inline %{ wxWindow* wxWindow_FromHWND(unsigned long hWnd) { wxWindow* win = new wxWindow; @@ -469,8 +486,8 @@ class wxPanel : public wxWindow { public: wxPanel(wxWindow* parent, const wxWindowID id, - const wxPoint& pos = wxPyDefaultPosition, - const wxSize& size = wxPyDefaultSize, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL, const char* name = "panel"); @@ -480,14 +497,6 @@ public: wxButton* GetDefaultItem(); void SetDefaultItem(wxButton *btn); - // fix some SWIG trouble... - %pragma(python) addtoclass = " - def GetDefaultItem(self): - import controls - val = windowsc.wxPanel_GetDefaultItem(self.this) - val = controls.wxButtonPtr(val) - return val -" }; //--------------------------------------------------------------------------- @@ -497,8 +506,8 @@ public: wxDialog(wxWindow* parent, const wxWindowID id, const wxString& title, - const wxPoint& pos = wxPyDefaultPosition, - const wxSize& size = wxPyDefaultSize, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE, const char* name = "dialogBox"); @@ -517,16 +526,25 @@ public: int GetReturnCode(); void SetReturnCode(int retCode); + + wxSizer* CreateTextSizer( const wxString &message ); + wxSizer* CreateButtonSizer( long flags ); + }; //--------------------------------------------------------------------------- + +// TODO: Add wrappers for the wxScrollHelper class, make wxScrolledWindow +// derive from it and wxPanel. + + class wxScrolledWindow : public wxPanel { public: wxScrolledWindow(wxWindow* parent, const wxWindowID id = -1, - const wxPoint& pos = wxPyDefaultPosition, - const wxSize& size = wxPyDefaultSize, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxHSCROLL | wxVSCROLL, char* name = "scrolledWindow"); @@ -547,11 +565,16 @@ public: void SetScrollPageSize(int orient, int pageSize); void SetTargetWindow(wxWindow* window); void GetViewStart(int* OUTPUT, int* OUTPUT); - void ViewStart(int* OUTPUT, int* OUTPUT); + %pragma(python) addtoclass = "ViewStart = GetViewStart" void CalcScrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT); void CalcUnscrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT); + void SetScale(double xs, double ys); + double GetScaleX(); + double GetScaleY(); + + void AdjustScrollbars(); }; //---------------------------------------------------------------------- @@ -628,7 +651,7 @@ public: class wxMenuBar : public wxWindow { public: - wxMenuBar(); + wxMenuBar(long style = 0); bool Append(wxMenu *menu, const wxString& title); bool Insert(size_t pos, wxMenu *menu, const wxString& title); @@ -639,6 +662,7 @@ public: void EnableTop(size_t pos, bool enable); void SetLabelTop(size_t pos, const wxString& label); wxString GetLabelTop(size_t pos); + int FindMenu(const wxString& title); int FindMenuItem(const wxString& menuString, const wxString& itemString); %name(FindItemById)wxMenuItem* FindItem(int id/*, wxMenu **menu = NULL*/); void Enable(int id, bool enable); @@ -657,7 +681,7 @@ public: //---------------------------------------------------------------------- -class wxMenuItem { +class wxMenuItem : public wxObject { public: wxMenuItem(wxMenu* parentMenu=NULL, int id=wxID_SEPARATOR, const wxString& text = wxPyEmptyStr, @@ -687,6 +711,30 @@ public: wxAcceleratorEntry *GetAccel(); void SetAccel(wxAcceleratorEntry *accel); + static wxString GetLabelFromText(const wxString& text); + + // wxOwnerDrawn methods +#ifdef __WXMSW__ + void SetFont(const wxFont& font); + wxFont& GetFont(); + void SetTextColour(const wxColour& colText); + wxColour GetTextColour(); + void SetBackgroundColour(const wxColour& colBack); + wxColour GetBackgroundColour(); + void SetBitmaps(const wxBitmap& bmpChecked, + const wxBitmap& bmpUnchecked = wxNullBitmap); + void SetBitmap(const wxBitmap& bmpChecked); + const wxBitmap& GetBitmap(bool bChecked = TRUE); + void SetMarginWidth(int nWidth); + int GetMarginWidth(); + static int GetDefaultMarginWidth(); + //void SetName(const wxString& strName); + //const wxString& GetName(); + //void SetCheckable(bool checkable); + //bool IsCheckable(); + bool IsOwnerDrawn(); + void ResetOwnerDrawn(); +#endif }; //---------------------------------------------------------------------------