2005-04-15, 20:25
i 'd like to have a method in object controllist to select an item...
i make some changes and prepared a diff...
*** controllist.cpp 2005-04-15 19:19:55.516992600 +0200
--- controllist_setitem.cpp 2005-04-15 20:23:31.016983500 +0200
***************
*** 211,240 ****
--- 211,267 ----
self->vecitems.push_back(plistitem);
// create message
cguimessage msg(gui_msg_label_add, self->iparentid, self->icontrolid);
msg.setlpvoid(plistitem->item);
// send message
pyguilock();
if (self->pguicontrol) self->pguicontrol->onmessage(msg);
pyguiunlock();
py_incref(py_none);
return py_none;
}
+ /*
+ * controllist_selectitem(int item)
+ * select an item by index
+ */
+ pydoc_strvar(selectitem,
+ "selectitem(item) -- select an item by index\n"
+ "\n"
+ "item is the index on the item to select.");
+
+ pyobject* controllist_selectitem(controllist *self, pyobject *args)
+ {
+ long itemindex;
+
+ if (!pyarg_parsetuple(args, "l", itemindex)) return null;
+
+ // create message
+ cguimessage msg(gui_msg_item_selected, self->iparentid, self->icontrolid, itemindex);
+
+ // send message
+ pyguilock();
+ if (self->pguicontrol) self->pguicontrol->onmessage(msg);
+ pyguiunlock();
+
+ py_incref(py_none);
+ return py_none;
+ }
+
pydoc_strvar(reset,
"reset() -- clear all listitems in this control list.");
pyobject* controllist_reset(controllist *self, pyobject *args)
{
// create message
controllist *pcontrol = (controllist*)self;
cguimessage msg(gui_msg_label_reset, pcontrol->iparentid, pcontrol->icontrolid);
// send message
pyguilock();
if (pcontrol->pguicontrol) pcontrol->pguicontrol->onmessage(msg);
pyguiunlock();
// delete all items from vector
***************
*** 376,405 ****
--- 403,433 ----
// send message
pyguilock();
if ((self->vecitems.size() > 0) && pcontrol->pguicontrol)
{
pcontrol->pguicontrol->onmessage(msg);
plistitem = (pyobject*)self->vecitems[msg.getparam1()];
}
pyguiunlock();
py_incref(plistitem);
return plistitem;
}
pymethoddef controllist_methods[] = {
{"additem", (pycfunction)controllist_additem, meth_varargs, additem},
+ {"selectitem", (pycfunction)controllist_selectitem, meth_varargs, selectitem},
{"reset", (pycfunction)controllist_reset, meth_varargs, reset},
{"getspincontrol", (pycfunction)controllist_getspincontrol, meth_varargs, getspincontrol},
{"getselectedposition", (pycfunction)controllist_getselectedposition, meth_varargs, getselectedposition},
{"getselecteditem", (pycfunction)controllist_getselecteditem, meth_varargs, getselecteditem},
{"setimagedimensions", (pycfunction)controllist_setimagedimensions, meth_varargs, setimagedimensions},
{"setitemheight", (pycfunction)controllist_setitemheight, meth_varargs, setitemheight},
{"setspace", (pycfunction)controllist_setspace, meth_varargs, setspace},
{null, null, 0, null}
};
pydoc_strvar(controllist,
"controllist class.\n"
"\n"
"controllist(\n"
" x, y, width, height, font, textcolor,\n"
i make some changes and prepared a diff...
*** controllist.cpp 2005-04-15 19:19:55.516992600 +0200
--- controllist_setitem.cpp 2005-04-15 20:23:31.016983500 +0200
***************
*** 211,240 ****
--- 211,267 ----
self->vecitems.push_back(plistitem);
// create message
cguimessage msg(gui_msg_label_add, self->iparentid, self->icontrolid);
msg.setlpvoid(plistitem->item);
// send message
pyguilock();
if (self->pguicontrol) self->pguicontrol->onmessage(msg);
pyguiunlock();
py_incref(py_none);
return py_none;
}
+ /*
+ * controllist_selectitem(int item)
+ * select an item by index
+ */
+ pydoc_strvar(selectitem,
+ "selectitem(item) -- select an item by index\n"
+ "\n"
+ "item is the index on the item to select.");
+
+ pyobject* controllist_selectitem(controllist *self, pyobject *args)
+ {
+ long itemindex;
+
+ if (!pyarg_parsetuple(args, "l", itemindex)) return null;
+
+ // create message
+ cguimessage msg(gui_msg_item_selected, self->iparentid, self->icontrolid, itemindex);
+
+ // send message
+ pyguilock();
+ if (self->pguicontrol) self->pguicontrol->onmessage(msg);
+ pyguiunlock();
+
+ py_incref(py_none);
+ return py_none;
+ }
+
pydoc_strvar(reset,
"reset() -- clear all listitems in this control list.");
pyobject* controllist_reset(controllist *self, pyobject *args)
{
// create message
controllist *pcontrol = (controllist*)self;
cguimessage msg(gui_msg_label_reset, pcontrol->iparentid, pcontrol->icontrolid);
// send message
pyguilock();
if (pcontrol->pguicontrol) pcontrol->pguicontrol->onmessage(msg);
pyguiunlock();
// delete all items from vector
***************
*** 376,405 ****
--- 403,433 ----
// send message
pyguilock();
if ((self->vecitems.size() > 0) && pcontrol->pguicontrol)
{
pcontrol->pguicontrol->onmessage(msg);
plistitem = (pyobject*)self->vecitems[msg.getparam1()];
}
pyguiunlock();
py_incref(plistitem);
return plistitem;
}
pymethoddef controllist_methods[] = {
{"additem", (pycfunction)controllist_additem, meth_varargs, additem},
+ {"selectitem", (pycfunction)controllist_selectitem, meth_varargs, selectitem},
{"reset", (pycfunction)controllist_reset, meth_varargs, reset},
{"getspincontrol", (pycfunction)controllist_getspincontrol, meth_varargs, getspincontrol},
{"getselectedposition", (pycfunction)controllist_getselectedposition, meth_varargs, getselectedposition},
{"getselecteditem", (pycfunction)controllist_getselecteditem, meth_varargs, getselecteditem},
{"setimagedimensions", (pycfunction)controllist_setimagedimensions, meth_varargs, setimagedimensions},
{"setitemheight", (pycfunction)controllist_setitemheight, meth_varargs, setitemheight},
{"setspace", (pycfunction)controllist_setspace, meth_varargs, setspace},
{null, null, 0, null}
};
pydoc_strvar(controllist,
"controllist class.\n"
"\n"
"controllist(\n"
" x, y, width, height, font, textcolor,\n"