[pywin32-checkins] pywin32/Pythonwin win32ctrlTree.cpp,1.5,1.6
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2008-02-12 04:41:02
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4204 Modified Files: win32ctrlTree.cpp Log Message: Treat HTREEITEM as a handle Index: win32ctrlTree.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ctrlTree.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32ctrlTree.cpp 3 Jun 2007 12:35:58 -0000 1.5 --- win32ctrlTree.cpp 12 Feb 2008 04:41:05 -0000 1.6 *************** *** 106,110 **** PyObject *fnname( PyObject *self, PyObject *args ) { \ HTREEITEM htree; \ ! if (!PyArg_ParseTuple( args, "i:" #mfcName, &htree)) \ return NULL; \ CTreeCtrl *pList = GetTreeCtrl(self); \ --- 106,113 ---- PyObject *fnname( PyObject *self, PyObject *args ) { \ HTREEITEM htree; \ ! PyObject *obtree; \ ! if (!PyArg_ParseTuple( args, "O:" #mfcName, &obtree)) \ ! return NULL; \ ! if (!PyWinObject_AsHANDLE(obtree, (HANDLE *)&htree)) \ return NULL; \ CTreeCtrl *pList = GetTreeCtrl(self); \ *************** *** 119,123 **** PyObject *fnname( PyObject *self, PyObject *args ) { \ HTREEITEM htree; \ ! if (!PyArg_ParseTuple( args, "i:" #mfcName, &htree)) \ return NULL; \ CTreeCtrl *pList = GetTreeCtrl(self); \ --- 122,129 ---- PyObject *fnname( PyObject *self, PyObject *args ) { \ HTREEITEM htree; \ ! PyObject *obtree; \ ! if (!PyArg_ParseTuple( args, "O:" #mfcName, &obtree)) \ ! return NULL; \ ! if (!PyWinObject_AsHANDLE(obtree, (HANDLE *)&htree)) \ return NULL; \ CTreeCtrl *pList = GetTreeCtrl(self); \ *************** *** 128,132 **** if (item==NULL) \ RETURN_ERR(#mfcName " failed"); \ ! return Py_BuildValue("i",item); \ } --- 134,138 ---- if (item==NULL) \ RETURN_ERR(#mfcName " failed"); \ ! return PyWinLong_FromHANDLE(item); \ } *************** *** 134,138 **** PyObject *fnname( PyObject *self, PyObject *args ) { \ HTREEITEM htree; int code;\ ! if (!PyArg_ParseTuple( args, "ii:" #mfcName, &htree, &code)) \ return NULL; \ CTreeCtrl *pList = GetTreeCtrl(self); \ --- 140,147 ---- PyObject *fnname( PyObject *self, PyObject *args ) { \ HTREEITEM htree; int code;\ ! PyObject *obtree; \ ! if (!PyArg_ParseTuple( args, "Oi:" #mfcName, &obtree, &code)) \ ! return NULL; \ ! if (!PyWinObject_AsHANDLE(obtree, (HANDLE *)&htree)) \ return NULL; \ CTreeCtrl *pList = GetTreeCtrl(self); \ *************** *** 143,147 **** if (item==NULL) \ RETURN_ERR(#mfcName " failed"); \ ! return Py_BuildValue("i",item); \ } --- 152,156 ---- if (item==NULL) \ RETURN_ERR(#mfcName " failed"); \ ! return PyWinLong_FromHANDLE(item); \ } *************** *** 157,172 **** if (item==NULL) \ RETURN_ERR(#mfcName " failed"); \ ! return Py_BuildValue("i",item); \ } #define MAKE_SET_ITEMS_INTS_METH(fnname, mfcName) \ PyObject *fnname( PyObject *self, PyObject *args ) { \ ! HTREEITEM item; int i1, i2;\ ! if (!PyArg_ParseTuple( args, "iii:" #mfcName, &item, &i1, &i2)) \ return NULL; \ CTreeCtrl *pList = GetTreeCtrl(self); \ if (!pList) return NULL; \ GUI_BGN_SAVE; \ ! BOOL ok = pList->mfcName(item, i1, i2); \ GUI_END_SAVE; \ if (!ok) \ --- 166,184 ---- if (item==NULL) \ RETURN_ERR(#mfcName " failed"); \ ! return PyWinLong_FromHANDLE(item); \ } #define MAKE_SET_ITEMS_INTS_METH(fnname, mfcName) \ PyObject *fnname( PyObject *self, PyObject *args ) { \ ! HTREEITEM hitem; int i1, i2;\ ! PyObject *obitem; \ ! if (!PyArg_ParseTuple( args, "Oii:" #mfcName, &obitem, &i1, &i2)) \ ! return NULL; \ ! if (!PyWinObject_AsHANDLE(obitem, (HANDLE *)&hitem)) \ return NULL; \ CTreeCtrl *pList = GetTreeCtrl(self); \ if (!pList) return NULL; \ GUI_BGN_SAVE; \ ! BOOL ok = pList->mfcName(hitem, i1, i2); \ GUI_END_SAVE; \ if (!ok) \ *************** *** 177,187 **** #define MAKE_BOOL_ITEM_ACTION(fnname, mfcName) \ PyObject *fnname( PyObject *self, PyObject *args ) { \ ! HTREEITEM item; \ ! if (!PyArg_ParseTuple( args, "i:" #mfcName, &item)) \ return NULL; \ CTreeCtrl *pList = GetTreeCtrl(self); \ if (!pList) return NULL; \ GUI_BGN_SAVE; \ ! BOOL ok = pList->mfcName(item); \ GUI_END_SAVE; \ if (!ok) \ --- 189,202 ---- #define MAKE_BOOL_ITEM_ACTION(fnname, mfcName) \ PyObject *fnname( PyObject *self, PyObject *args ) { \ ! HTREEITEM hitem; \ ! PyObject *obitem; \ ! if (!PyArg_ParseTuple( args, "O:" #mfcName, &obitem)) \ ! return NULL; \ ! if (!PyWinObject_AsHANDLE(obitem, (HANDLE *)&hitem)) \ return NULL; \ CTreeCtrl *pList = GetTreeCtrl(self); \ if (!pList) return NULL; \ GUI_BGN_SAVE; \ ! BOOL ok = pList->mfcName(hitem); \ GUI_END_SAVE; \ if (!ok) \ *************** *** 192,202 **** #define MAKE_BOOL_ITEM_INT_ACTION(fnname, mfcName) \ PyObject *fnname( PyObject *self, PyObject *args ) { \ ! HTREEITEM item; int code;\ ! if (!PyArg_ParseTuple( args, "ii:" #mfcName, &item, &code)) \ return NULL; \ CTreeCtrl *pList = GetTreeCtrl(self); \ if (!pList) return NULL; \ GUI_BGN_SAVE; \ ! BOOL ok = pList->mfcName(item, code); \ GUI_END_SAVE; \ if (!ok) \ --- 207,220 ---- #define MAKE_BOOL_ITEM_INT_ACTION(fnname, mfcName) \ PyObject *fnname( PyObject *self, PyObject *args ) { \ ! HTREEITEM hitem; int code;\ ! PyObject *obitem; \ ! if (!PyArg_ParseTuple( args, "Oi:" #mfcName, &obitem, &code)) \ ! return NULL; \ ! if (!PyWinObject_AsHANDLE(obitem, (HANDLE *)&hitem)) \ return NULL; \ CTreeCtrl *pList = GetTreeCtrl(self); \ if (!pList) return NULL; \ GUI_BGN_SAVE; \ ! BOOL ok = pList->mfcName(hitem, code); \ GUI_END_SAVE; \ if (!ok) \ *************** *** 397,400 **** --- 415,419 ---- int image, selImage, state, stateMask; LPARAM lParam; + PyObject *obParent=Py_None, *obInsertAfter=Py_None; HTREEITEM hParent, hInsertAfter; char *text; *************** *** 402,416 **** return NULL; ! if (PyArg_ParseTuple(args, "iziiiiOii:InsertItem", ! &mask, // @pyparmalt1 int|mask||Integer specifying which attributes to set ! &text, // @pyparmalt1 string|text||The text of the item. ! &image, // @pyparmalt1 int|image||The index of the image to use. ! &selImage, // @pyparmalt1 int|selectedImage||The index of the items selected image. ! &state, // @pyparmalt1 int|state||The initial state of the item. ! &stateMask, // @pyparmalt1 int|stateMask||Specifies which bits of the state are valid. ! &lParam, // @pyparmalt1 object|lParam||A user defined object for the item. ! &hParent, // @pyparmalt1 HTREEITEM|parent||The parent of the item. ! &hInsertAfter)) { // @pyparmalt1 HTREEITEM|parent||The parent of the item. ! GUI_BGN_SAVE; ret = pList->InsertItem(mask, text, image, selImage, state, stateMask, lParam, hParent, hInsertAfter); GUI_END_SAVE; --- 421,439 ---- return NULL; ! if (PyArg_ParseTuple(args, "iziiiiOOO:InsertItem", ! &mask, // @pyparmalt1 int|mask||Integer specifying which attributes to set ! &text, // @pyparmalt1 string|text||The text of the item. ! &image, // @pyparmalt1 int|image||The index of the image to use. ! &selImage, // @pyparmalt1 int|selectedImage||The index of the items selected image. ! &state, // @pyparmalt1 int|state||The initial state of the item. ! &stateMask, // @pyparmalt1 int|stateMask||Specifies which bits of the state are valid. ! &lParam, // @pyparmalt1 object|lParam||A user defined object for the item. ! &obParent, // @pyparmalt1 HTREEITEM|parent||The parent of the item. ! &obInsertAfter)) { // @pyparmalt1 HTREEITEM|parent||The parent of the item. ! if (!PyWinObject_AsHANDLE(obParent, (HANDLE *)&hParent)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obInsertAfter, (HANDLE *)&hInsertAfter)) ! return NULL; ! GUI_BGN_SAVE; ret = pList->InsertItem(mask, text, image, selImage, state, stateMask, lParam, hParent, hInsertAfter); GUI_END_SAVE; *************** *** 419,429 **** hParent = TVI_ROOT; hInsertAfter = TVI_LAST; ! if (PyArg_ParseTuple(args, "sii|ii:InsertItem", &text, // @pyparmalt2 string|text||The text for the item. &image, // @pyparmalt2 int|image||The index of the image to use. &selImage, // @pyparmalt2 int|selectedImage||The index of the items selected image. ! &hParent, // @pyparmalt2 HTREEITEM|parent|commctrl.TVI_ROOT|The parent of the item. ! &hInsertAfter)) { // @pyparmalt2 HTREEITEM|insertAfter|commctrl.TVI_LAST|The item to insert the new item after, or TVI_FIRST, TVI_LAST or TVI_SORT ! GUI_BGN_SAVE; ret = pList->InsertItem(text, image, selImage, hParent, hInsertAfter); GUI_END_SAVE; --- 442,458 ---- hParent = TVI_ROOT; hInsertAfter = TVI_LAST; ! if (PyArg_ParseTuple(args, "sii|OO:InsertItem", &text, // @pyparmalt2 string|text||The text for the item. &image, // @pyparmalt2 int|image||The index of the image to use. &selImage, // @pyparmalt2 int|selectedImage||The index of the items selected image. ! &obParent, // @pyparmalt2 HTREEITEM|parent|commctrl.TVI_ROOT|The parent of the item. ! &obInsertAfter)) { // @pyparmalt2 HTREEITEM|insertAfter|commctrl.TVI_LAST|The item to insert the new item after, or TVI_FIRST, TVI_LAST or TVI_SORT ! if (obParent!=Py_None) ! if (!PyWinObject_AsHANDLE(obParent, (HANDLE *)&hParent)) ! return NULL; ! if (obInsertAfter!=Py_None) ! if (!PyWinObject_AsHANDLE(obInsertAfter, (HANDLE *)&hInsertAfter)) ! return NULL; ! GUI_BGN_SAVE; ret = pList->InsertItem(text, image, selImage, hParent, hInsertAfter); GUI_END_SAVE; *************** *** 432,439 **** hParent = TVI_ROOT; hInsertAfter = TVI_LAST; ! if (PyArg_ParseTuple(args, "s|ii:InsertItem", ! &text, // @pyparmalt3 string|text||The text for the item. ! &hParent, // @pyparmalt3 HTREEITEM|parent|commctrl.TVI_ROOT|The parent of the item. ! &hInsertAfter)) {// @pyparmalt3 HTREEITEM|parent|commctrl.TVI_LAST|The parent of the item. GUI_BGN_SAVE; ret = pList->InsertItem(text, hParent, hInsertAfter); --- 461,474 ---- hParent = TVI_ROOT; hInsertAfter = TVI_LAST; ! if (PyArg_ParseTuple(args, "s|OO:InsertItem", ! &text, // @pyparmalt3 string|text||The text for the item. ! &obParent, // @pyparmalt3 HTREEITEM|parent|commctrl.TVI_ROOT|The parent of the item. ! &obInsertAfter)) {// @pyparmalt3 HTREEITEM|parent|commctrl.TVI_LAST|The parent of the item. ! if (obParent!=Py_None) ! if (!PyWinObject_AsHANDLE(obParent, (HANDLE *)&hParent)) ! return NULL; ! if (obInsertAfter!=Py_None) ! if (!PyWinObject_AsHANDLE(obInsertAfter, (HANDLE *)&hInsertAfter)) ! return NULL; GUI_BGN_SAVE; ret = pList->InsertItem(text, hParent, hInsertAfter); *************** *** 443,454 **** TV_INSERTSTRUCT tvItem; PyErr_Clear(); ! if (PyArg_ParseTuple(args, "iiO:InsertItem", ! &tvItem.hParent, // @pyparm HTREEITEM|hParent||The parent item. If commctrl.TVI_ROOT or 0, it is added to the root. ! &tvItem.hInsertAfter, // @pyparm HTREEITEM|hInsertAfter||The item to insert after. Can be an item or TVI_FIRST, TVI_LAST or TVI_SORT &obTVItem)) { // @pyparm <om PyCTreeCtrl.TV_ITEM tuple>|item||A tuple describing the new item. if (!ParseTV_ITEMTuple(obTVItem, &tvItem.item)) return NULL; ! GUI_BGN_SAVE; ret = pList->InsertItem(&tvItem); GUI_END_SAVE; --- 478,493 ---- TV_INSERTSTRUCT tvItem; PyErr_Clear(); ! if (PyArg_ParseTuple(args, "OOO:InsertItem", ! &obParent, // @pyparm HTREEITEM|hParent||The parent item. If commctrl.TVI_ROOT or 0, it is added to the root. ! &obInsertAfter, // @pyparm HTREEITEM|hInsertAfter||The item to insert after. Can be an item or TVI_FIRST, TVI_LAST or TVI_SORT &obTVItem)) { // @pyparm <om PyCTreeCtrl.TV_ITEM tuple>|item||A tuple describing the new item. + if (!PyWinObject_AsHANDLE(obParent, (HANDLE *)&tvItem.hParent)) + return NULL; + if (!PyWinObject_AsHANDLE(obInsertAfter, (HANDLE *)&tvItem.hInsertAfter)) + return NULL; if (!ParseTV_ITEMTuple(obTVItem, &tvItem.item)) return NULL; ! GUI_BGN_SAVE; ret = pList->InsertItem(&tvItem); GUI_END_SAVE; *************** *** 462,466 **** if (ret==NULL) RETURN_ERR("InsertItem failed"); ! return Py_BuildValue("i",ret); } --- 501,505 ---- if (ret==NULL) RETURN_ERR("InsertItem failed"); ! return PyWinLong_FromHANDLE(ret); } *************** *** 731,735 **** pList->HitTest( &i ); GUI_END_SAVE; ! return Py_BuildValue("ii", i.flags, i.hItem); // @rdesc The result is a tuple of (flags, hItem). // flags may be a combination of the following values: --- 770,774 ---- pList->HitTest( &i ); GUI_END_SAVE; ! return Py_BuildValue("iN", i.flags, PyWinLong_FromHANDLE(i.hItem)); // @rdesc The result is a tuple of (flags, hItem). // flags may be a combination of the following values: |