1//--------------------------------------------------------------------------- 2// This file is generated by wxPython's SIP generator. Do not edit by hand. 3// 4// Copyright: (c) 2018 by Total Control Software 5// License: wxWindows License 6// 7// This file will be included by _core.sip 8// 9//--------------------------------------------------------------------------- 10 11//--------------------------------------------------------------------------- 12 13class wxPosition 14{ 15 %Docstring 16 Position() 17 Position(row, col) 18 19 This class represents the position of an item in any kind of grid of 20 rows and columns such as wxGridBagSizer, or wxHVScrolledWindow. 21 %End 22 %TypeHeaderCode 23 #include <wx/position.h> 24 %End 25 26public: 27 wxPosition(); 28 29 wxPosition( 30 int row, 31 int col 32 ); 33 34 bool operator==( 35 const wxPosition & pos 36 ) const; 37 38 bool operator!=( 39 const wxPosition & pos 40 ) const; 41 42 wxPosition & operator+=( 43 const wxPosition & pos 44 ); 45 46 wxPosition & operator+=( 47 const wxSize & size 48 ); 49 50 wxPosition & operator-=( 51 const wxPosition & pos 52 ); 53 54 wxPosition & operator-=( 55 const wxSize & size 56 ); 57 58 wxPosition operator+( 59 const wxPosition & pos 60 ) const; 61 62 wxPosition operator+( 63 const wxSize & size 64 ) const; 65 66 wxPosition operator-( 67 const wxPosition & pos 68 ) const; 69 70 wxPosition operator-( 71 const wxSize & size 72 ) const; 73 74 int GetCol() const; 75 %Docstring 76 GetCol() -> int 77 78 A synonym for GetColumn(). 79 %End 80 81 int GetColumn() const; 82 %Docstring 83 GetColumn() -> int 84 85 Get the current row value. 86 %End 87 88 int GetRow() const; 89 %Docstring 90 GetRow() -> int 91 92 Get the current row value. 93 %End 94 95 void SetCol( 96 int column 97 ); 98 %Docstring 99 SetCol(column) 100 101 A synonym for SetColumn(). 102 %End 103 104 void SetColumn( 105 int column 106 ); 107 %Docstring 108 SetColumn(column) 109 110 Set a new column value. 111 %End 112 113 void SetRow( 114 int row 115 ); 116 %Docstring 117 SetRow(row) 118 119 Set a new row value. 120 %End 121 122 PyObject* Get(); 123 %Docstring 124 Get() -> (row,col) 125 126 Return the row and col properties as a tuple. 127 %End 128 %MethodCode 129 PyErr_Clear(); 130 Py_BEGIN_ALLOW_THREADS 131 sipRes = _wxPosition_Get(sipCpp); 132 Py_END_ALLOW_THREADS 133 if (PyErr_Occurred()) sipIsErr = 1; 134 %End 135 %TypeCode 136 PyObject* _wxPosition_Get(wxPosition* self) 137 { 138 wxPyThreadBlocker blocker; 139 return sipBuildResult(0, "(ii)", self->GetRow(), self->GetCol()); 140 } 141 %End 142 143 public: 144 145 146 %Property(name=Col, get=GetCol, set=SetCol) 147 %Property(name=Column, get=GetColumn, set=SetColumn) 148 %Property(name=Row, get=GetRow, set=SetRow) 149 %ConvertToTypeCode 150 // is it just a typecheck? 151 if (!sipIsErr) { 152 // is it already an instance of wxPosition? 153 if (sipCanConvertToType(sipPy, sipType_wxPosition, SIP_NO_CONVERTORS)) 154 return 1; 155 156 if (wxPyNumberSequenceCheck(sipPy, 2)) { 157 return 1; 158 } 159 return 0; 160 } 161 162 // otherwise do the conversion 163 if (sipCanConvertToType(sipPy, sipType_wxPosition, SIP_NO_CONVERTORS)) { 164 // Just fetch the existing instance 165 *sipCppPtr = reinterpret_cast<wxPosition*>(sipConvertToType( 166 sipPy, sipType_wxPosition, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr)); 167 return 0; // not a new instance 168 } 169 170 // or create a new instance 171 PyObject* o1 = PySequence_ITEM(sipPy, 0); 172 PyObject* o2 = PySequence_ITEM(sipPy, 1); 173 *sipCppPtr = new wxPosition(wxPyInt_AsLong(o1), wxPyInt_AsLong(o2)); 174 Py_DECREF(o1); 175 Py_DECREF(o2); 176 return SIP_TEMPORARY; 177 %End 178}; // end of class wxPosition 179 180 181%Extract(id=pycode_core) 182def _Position_GetIM(self): 183 """ 184 Returns an immutable representation of the ``wx.Position`` object, based on ``namedtuple``. 185 186 This new object is hashable and can be used as a dictionary key, 187 be added to sets, etc. It can be converted back into a real ``wx.Position`` 188 with a simple statement like this: ``obj = wx.Position(imObj)``. 189 """ 190 return _im_Position(*self.Get()) 191Position.GetIM = _Position_GetIM 192del _Position_GetIM 193%End 194 195%Extract(id=pycode_core) 196def _Position___str__(self): 197 return str(self.Get()) 198Position.__str__ = _Position___str__ 199del _Position___str__ 200%End 201 202%Extract(id=pycode_core) 203def _Position___repr__(self): 204 return "wx.Position"+str(self.Get()) 205Position.__repr__ = _Position___repr__ 206del _Position___repr__ 207%End 208 209%Extract(id=pycode_core) 210def _Position___len__(self): 211 return len(self.Get()) 212Position.__len__ = _Position___len__ 213del _Position___len__ 214%End 215 216%Extract(id=pycode_core) 217def _Position___nonzero__(self): 218 return self.Get() != (0,0) 219Position.__nonzero__ = _Position___nonzero__ 220del _Position___nonzero__ 221%End 222 223%Extract(id=pycode_core) 224def _Position___bool__(self): 225 return self.Get() != (0,0) 226Position.__bool__ = _Position___bool__ 227del _Position___bool__ 228%End 229 230%Extract(id=pycode_core) 231def _Position___reduce__(self): 232 return (Position, self.Get()) 233Position.__reduce__ = _Position___reduce__ 234del _Position___reduce__ 235%End 236 237%Extract(id=pycode_core) 238def _Position___getitem__(self, idx): 239 return self.Get()[idx] 240Position.__getitem__ = _Position___getitem__ 241del _Position___getitem__ 242%End 243 244%Extract(id=pycode_core) 245def _Position___setitem__(self, idx, val): 246 if idx == 0: self.Row = val 247 elif idx == 1: self.Col = val 248 else: raise IndexError 249Position.__setitem__ = _Position___setitem__ 250del _Position___setitem__ 251%End 252 253%Extract(id=pycode_core) 254Position.__safe_for_unpickling__ = True 255 256%End 257 258%Extract(id=pycode_core) 259Position.IM = property(Position.GetIM) 260%End 261 262%Extract(id=pycode_core) 263from collections import namedtuple 264_im_Position = namedtuple('_im_Position', ['Row', 'Col']) 265del namedtuple 266 267%End 268 269 270//--------------------------------------------------------------------------- 271 272