|
19 | 19 | # this script.
|
20 | 20 | ITEMS = [ 'wxGridCellCoords',
|
21 | 21 |
|
| 22 | + 'wxGridBlockCoords', |
| 23 | + 'wxGridBlockDiffResult', |
| 24 | + 'wxGridBlocks', |
| 25 | + |
22 | 26 | 'wxGridCellRenderer',
|
23 | 27 | 'wxGridCellStringRenderer',
|
24 | 28 | 'wxGridCellAutoWrapStringRenderer',
|
@@ -133,6 +137,101 @@ def run():
|
133 | 137 | getItemCopy=True))
|
134 | 138 |
|
135 | 139 |
|
| 140 | + #----------------------------------------------------------------- |
| 141 | + c = module.find('wxGridBlockCoords') |
| 142 | + tools.addAutoProperties(c) |
| 143 | + |
| 144 | + c.find('operator!').ignore() |
| 145 | + c.addCppMethod('int', '__bool__', '()', "return self->operator!();") |
| 146 | + |
| 147 | + c.addCppMethod('PyObject*', 'Get', '()', """\ |
| 148 | + wxPyThreadBlocker blocker; |
| 149 | + return sipBuildResult(0, "(iiii)", self->GetTopRow(), self->GetLeftCol(), self->GetBottomRow(), self->GetRightCol()); |
| 150 | + """, |
| 151 | + pyArgsString="() -> (topRow, leftCol, bottomRow, rightCol)", |
| 152 | + briefDoc="Return the block coordinants as a tuple.") |
| 153 | + |
| 154 | + c.addPyMethod('__str__', '(self)', 'return str(self.Get())') |
| 155 | + c.addPyMethod('__repr__', '(self)', 'return "GridBlockCoords"+str(self.Get())') |
| 156 | + |
| 157 | + #----------------------------------------------------------------- |
| 158 | + c = module.find('wxGridBlockDiffResult') |
| 159 | + c.find('m_parts').ignore() |
| 160 | + |
| 161 | + c.addCppMethod('PyObject*', '_getParts', '()', |
| 162 | + """\ |
| 163 | + wxPyThreadBlocker blocker; |
| 164 | + PyObject* ret = PyTuple_New(4); |
| 165 | + if (ret) { |
| 166 | + PyTuple_SET_ITEM(ret, 0, wxPyConstructObject(&self->m_parts[0], "wxGridBlockCoords", false)); |
| 167 | + PyTuple_SET_ITEM(ret, 1, wxPyConstructObject(&self->m_parts[1], "wxGridBlockCoords", false)); |
| 168 | + PyTuple_SET_ITEM(ret, 2, wxPyConstructObject(&self->m_parts[2], "wxGridBlockCoords", false)); |
| 169 | + PyTuple_SET_ITEM(ret, 3, wxPyConstructObject(&self->m_parts[3], "wxGridBlockCoords", false)); |
| 170 | + } |
| 171 | + return ret; |
| 172 | + """) |
| 173 | + c.addProperty('m_parts', '_getParts') |
| 174 | + |
| 175 | + |
| 176 | + #----------------------------------------------------------------- |
| 177 | + c = module.find('wxGridBlocks') |
| 178 | + c.addPrivateDefaultCtor() |
| 179 | + |
| 180 | + c.addPyMethod('__iter__', '(self)', |
| 181 | + 'return PyGridBlocksIterator(self)', |
| 182 | + "Returns a Python iterator for acessing the collection of grid blocks.") |
| 183 | + |
| 184 | + # This class is the Python iterator that knows how to fetch blocks from the |
| 185 | + # wxGridBlocks object |
| 186 | + c.addPyCode("""\ |
| 187 | + class PyGridBlocksIterator(object): |
| 188 | + "A Python iterator for GridBlocks objects" |
| 189 | + def __init__(self, blocks): |
| 190 | + self._blocks = blocks |
| 191 | + self._iterator = self._blocks.begin() |
| 192 | +
|
| 193 | + def __next__(self): |
| 194 | + if self._iterator == self._blocks.end(): |
| 195 | + raise StopIteration |
| 196 | + obj = self._iterator._get() |
| 197 | + self._iterator = self._iterator._next() |
| 198 | + return obj |
| 199 | + """) |
| 200 | + |
| 201 | + |
| 202 | + # c.find('iterator').addCppMethod('wxGridBlocks::iterator', '_next', '()', |
| 203 | + # "return self->operator++();") |
| 204 | + # c.find('iterator').addCppMethod('const wxGridBlockCoords&', '_get', '()', |
| 205 | + # "return self->operator*();") |
| 206 | + |
| 207 | + # TODO: Doing these the normal way (above) breaks because it tries to use just |
| 208 | + # "iterator" for the self param type, instead of wxGridBlocks::iterator. |
| 209 | + # That should be fixable, but until then just add these methods the manual |
| 210 | + # sip way. |
| 211 | + c.find('iterator').addItem(etgtools.WigCode("""\ |
| 212 | + iterator& _next(); |
| 213 | + %MethodCode |
| 214 | + PyErr_Clear(); |
| 215 | + Py_BEGIN_ALLOW_THREADS |
| 216 | + sipRes = &sipCpp->operator++(); |
| 217 | + Py_END_ALLOW_THREADS |
| 218 | + if (PyErr_Occurred()) return 0; |
| 219 | + %End |
| 220 | +
|
| 221 | + const wxGridBlockCoords& _get() const; |
| 222 | + %MethodCode |
| 223 | + PyErr_Clear(); |
| 224 | + Py_BEGIN_ALLOW_THREADS |
| 225 | + sipRes = new ::wxGridBlockCoords(sipCpp->operator*()); |
| 226 | + Py_END_ALLOW_THREADS |
| 227 | + if (PyErr_Occurred()) return 0; |
| 228 | + %End |
| 229 | +
|
| 230 | + bool __eq__(const iterator& it) const; |
| 231 | + bool __ne__(const iterator& it) const; |
| 232 | + """)) |
| 233 | + |
| 234 | + |
136 | 235 | #-----------------------------------------------------------------
|
137 | 236 | c = module.find('wxGridSizesInfo')
|
138 | 237 | c.find('m_customSizes').ignore() # TODO: Add support for wxUnsignedToIntHashMap??
|
|
0 commit comments