mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
bazaar: BoostPyTest: Callbacks improvements, CtrlCore / TopWindow export at 80%, virtual methods and eval examples, ValueMap export; ValueCtrl: ValueMap and ErrorValue editor
git-svn-id: svn://ultimatepp.org/upp/trunk@3421 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
a5dd6dbe7b
commit
ac648bbee1
10 changed files with 730 additions and 115 deletions
|
|
@ -18,9 +18,15 @@ public:
|
|||
~BoostPyTest();
|
||||
|
||||
void ExitHandler();
|
||||
void CBi(int i);
|
||||
|
||||
#if PUREVIRTEST
|
||||
#else
|
||||
World w;
|
||||
#endif
|
||||
Progress pr;
|
||||
|
||||
Callback1<int> cbi;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ LAYOUT(BoostPyTestLayout, 672, 380)
|
|||
ITEM(PyConsoleCtrl, con, HSizePosZ(0, 248).VSizePosZ(0, 0))
|
||||
ITEM(SliderCtrl, sl, RightPosZ(8, 232).TopPosZ(12, 48))
|
||||
ITEM(ValueCtrl, vc, RightPosZ(8, 232).TopPosZ(76, 56))
|
||||
ITEM(ValueCtrl, vc2, RightPosZ(8, 232).BottomPosZ(112, 56))
|
||||
ITEM(EditString, es, RightPosZ(8, 232).TopPosZ(148, 19))
|
||||
ITEM(Label, dv___5, SetLabel(t_("eval:")).RightPosZ(210, 30).BottomPosZ(173, 19))
|
||||
ITEM(EditString, ev, RightPosZ(8, 200).BottomPosZ(173, 19))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@
|
|||
//CAUTION special module definitions to reduce compile time
|
||||
#include "modules.cppi"
|
||||
|
||||
void BoostPyTest::CBi(int i)
|
||||
{
|
||||
RLOG(i);
|
||||
}
|
||||
|
||||
BoostPyTest::BoostPyTest()
|
||||
{
|
||||
CtrlLayout(*this, "Boost Test");
|
||||
|
|
@ -36,9 +41,11 @@ BoostPyTest::BoostPyTest()
|
|||
//is only caused on boost python module declarations
|
||||
main_namespace["hello"] = hello_module;
|
||||
|
||||
#if PUREVIRTEST
|
||||
#else
|
||||
w.set("Welcom on earth");
|
||||
scope(hello_module).attr("earth") = ptr(&w);
|
||||
|
||||
#endif
|
||||
|
||||
object upp_module = import("upp");
|
||||
main_namespace["upp"] = upp_module;
|
||||
|
|
@ -56,13 +63,20 @@ BoostPyTest::BoostPyTest()
|
|||
|
||||
scope(upp_module).attr("pr") = ptr(&pr);
|
||||
|
||||
cbi = THISBACK(CBi);
|
||||
scope(upp_module).attr("cbi") = ptr(&cbi);
|
||||
|
||||
object o = eval("100 + upp.sl.data", main_namespace, main_namespace);
|
||||
int data = extract<int>(o);
|
||||
|
||||
//the additional import is needless
|
||||
String sc =
|
||||
|
||||
#if PUREVIRTEST
|
||||
#else
|
||||
"p = hello.World()\n"
|
||||
"p.set('Some Greet Text')\n"
|
||||
"print p.get()\n"
|
||||
#endif
|
||||
|
||||
"upp.sl.data = 75\n"
|
||||
"print upp.sl.data\n"
|
||||
|
|
@ -77,10 +91,13 @@ BoostPyTest::BoostPyTest()
|
|||
"c = upp.Color(123,124,125)\n"
|
||||
"print c\n"
|
||||
|
||||
#if PUREVIRTEST
|
||||
#else
|
||||
"pp = p\n"
|
||||
"p.set('Hi')\n"
|
||||
"print p\n"
|
||||
"print pp\n"
|
||||
#endif
|
||||
|
||||
//"upp.vc.data = c\n"
|
||||
|
||||
|
|
@ -109,6 +126,35 @@ BoostPyTest::BoostPyTest()
|
|||
"sl2.whenaction = ff\n"
|
||||
"sl2.data = 12\n"
|
||||
"upp.app.add(sl2)\n"
|
||||
|
||||
"print 'USE DEBUG TO SEE THE INVOKATIONS in WrapWorld'\n"
|
||||
#if PUREVIRTEST
|
||||
"class MyPureWorld(hello.World):\n"
|
||||
" def vir(self, a):\n"
|
||||
" return 'MyPurePyWorld'\n"
|
||||
"mw = MyPureWorld()\n"
|
||||
"print mw.vir(8)\n"
|
||||
"print hello.invworld(mw,7)\n"
|
||||
#else
|
||||
"w = hello.World()\n"
|
||||
"print hello.invworld(w,7)\n"
|
||||
"print w.vir(7)\n"
|
||||
|
||||
"class MyWorld(hello.World):\n"
|
||||
" def vir(self, a):\n"
|
||||
" return 'MyPyWorld'\n"
|
||||
"mw = MyWorld()\n"
|
||||
"print mw.vir(8)\n"
|
||||
"print hello.invworld(mw,7)\n"
|
||||
#endif
|
||||
|
||||
"class MyUWorld(hello.Universe):\n"
|
||||
" def vir(self, a):\n"
|
||||
" return 'MyPyUWorld'\n"
|
||||
"mu = MyUWorld()\n"
|
||||
"print mu.vir(8)\n"
|
||||
"print hello.invworld(mu,7)\n"
|
||||
|
||||
;
|
||||
con.cmd.SetData(sc);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,25 +3,102 @@ using namespace boost::python;
|
|||
//#include <iostream>
|
||||
//using namespace std;
|
||||
|
||||
|
||||
class WorldWrap : public World, public wrapper<World> {
|
||||
public:
|
||||
virtual std::string vir(int a) const {
|
||||
//if pure virtual
|
||||
#if PUREVIRTEST
|
||||
return this->get_override("vir")(a);
|
||||
#else
|
||||
//from c++ calls to WorldWrap instaces as World instance (i.e. InvokeWorld)
|
||||
//calls python derived function if present, or base function.
|
||||
if(override f = this->get_override("vir"))
|
||||
return f(a);
|
||||
return World::vir(a);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if PUREVIRTEST
|
||||
#else
|
||||
//from python calls this, if not derived in python
|
||||
//if vir derived in python, gets called directly
|
||||
std::string default_vir(int a) const {
|
||||
return World::vir(a);
|
||||
}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
std::string InvokeWorld(const World& w, int a) //for testing the instances from python env
|
||||
{
|
||||
return w.vir(a);
|
||||
}
|
||||
|
||||
class UniverseWrap : public Universe, public wrapper<Universe> {
|
||||
public:
|
||||
virtual std::string vir(int a) const {
|
||||
//if pure virtual
|
||||
#if PUREVIRTEST
|
||||
return this->get_override("vir")(a);
|
||||
#else
|
||||
//from c++ calls to WorldWrap instaces as World instance (i.e. InvokeWorld)
|
||||
//calls python derived function if present, or base function.
|
||||
if(override f = this->get_override("vir"))
|
||||
return f(a);
|
||||
return Universe::vir(a);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if PUREVIRTEST
|
||||
#else
|
||||
//from python calls this, if not derived in python
|
||||
//if vir derived in python, gets called directly
|
||||
std::string default_vir(int a) const {
|
||||
return Universe::vir(a);
|
||||
}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void export_world()
|
||||
{
|
||||
ONCELOCK
|
||||
{
|
||||
class_<World, boost::noncopyable>("World", "A simple world")
|
||||
class_<WorldWrap, boost::noncopyable>("World", "A simple world"
|
||||
#if 0 //PUREVIRTEST, not needed though abstract, otherwise it cant instantiate in python
|
||||
, no_init
|
||||
#endif
|
||||
)
|
||||
//.def(init<const World&>())
|
||||
.def("__str__", &World::get) //somehow works only for print not for general return as string echo
|
||||
.def("greet", &World::greet)
|
||||
.def("get", &World::get)
|
||||
.def("set", &World::set)
|
||||
#if PUREVIRTEST
|
||||
.def("vir", pure_virtual(&World::vir))
|
||||
#else
|
||||
.def("vir", &World::vir, &WorldWrap::default_vir)
|
||||
#endif
|
||||
;
|
||||
|
||||
class_<Universe, bases<World>, boost::noncopyable >("Universe", "A simple Universe")
|
||||
//.def(init<const World&>())
|
||||
def("invworld", &InvokeWorld);
|
||||
|
||||
class_<UniverseWrap, bases<World>, boost::noncopyable >("Universe", "A simple Universe")
|
||||
//.def(init<const Universe&>())
|
||||
.def("__str__", &Universe::getg) //somehow works only for print not for general return as string echo
|
||||
.def("getg", &Universe::getg)
|
||||
.def("setg", &Universe::setg)
|
||||
#if 1
|
||||
//somehow does not override the World export of vir
|
||||
#if PUREVIRTEST
|
||||
.def("vir", pure_virtual(&Universe::vir))
|
||||
#else
|
||||
.def("vir", &Universe::vir, &UniverseWrap::default_vir)
|
||||
#endif
|
||||
#endif
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,11 @@
|
|||
|
||||
#include <Py/Py.h>
|
||||
|
||||
struct World
|
||||
#define PUREVIRTEST 0
|
||||
|
||||
class World
|
||||
{
|
||||
public:
|
||||
void set(std::string msg) { this->msg = msg; }
|
||||
std::string get() const { return msg; }
|
||||
std::string msg;
|
||||
|
|
@ -14,6 +17,12 @@ struct World
|
|||
PySys_WriteStdout("%.100s", msg.data());
|
||||
}
|
||||
|
||||
virtual std::string vir(int a = 2) const
|
||||
#if PUREVIRTEST
|
||||
= 0;
|
||||
#else
|
||||
{ return "virtual World"; }
|
||||
#endif
|
||||
World() {}
|
||||
protected:
|
||||
World(const World& w) {
|
||||
|
|
@ -21,12 +30,15 @@ protected:
|
|||
}
|
||||
};
|
||||
|
||||
struct Universe : public World
|
||||
class Universe : public World
|
||||
{
|
||||
public:
|
||||
double g;
|
||||
void setg(double _g) { g = _g; }
|
||||
double getg() const { return g; }
|
||||
|
||||
virtual std::string vir(int a = 3) const { return "virtual Universe"; }
|
||||
|
||||
Universe() { g = 9.81; }
|
||||
|
||||
#if 0
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ using namespace boost::python;
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
//Callback
|
||||
|
||||
struct CallbackActionPy : public CallbackAction {
|
||||
object o;
|
||||
void Execute() { call<void>(o.ptr()); }
|
||||
virtual void Execute() { call<void>(o.ptr()); }
|
||||
CallbackActionPy(PyObject *callable) : o(handle<>(borrowed(callable))) {}
|
||||
};
|
||||
|
||||
bool CallbackIsValid(const Callback& c) { return c; }
|
||||
|
||||
struct Callback_to_python //FIXME translation of Callback internals to python
|
||||
{
|
||||
static PyObject* convert(const Callback& s) { return incref(object(s).ptr()); }
|
||||
|
|
@ -18,17 +18,14 @@ struct Callback_to_python //FIXME translation of Callback internals to python
|
|||
|
||||
struct Callback_from_python
|
||||
{
|
||||
Callback_from_python()
|
||||
{
|
||||
converter::registry::push_back(&convertible, &construct, type_id<Callback>());
|
||||
}
|
||||
Callback_from_python() { converter::registry::push_back(&convertible, &construct, type_id<Callback>()); }
|
||||
|
||||
static void* convertible(PyObject* po)
|
||||
{
|
||||
if(po == Py_None) return po;
|
||||
if(extract<Callback&>(po).check()) return po;
|
||||
if(PyFunction_Check(po)) return po;
|
||||
if(PyCallable_Check(po) && PyMethod_Self(po)) return po;
|
||||
if(extract<Callback&>(po).check()) return po;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -36,32 +33,125 @@ struct Callback_from_python
|
|||
{
|
||||
void* d = ((converter::rvalue_from_python_storage<Callback>*)data)->storage.bytes;
|
||||
|
||||
if(po == Py_None)
|
||||
{
|
||||
new(d) Callback();
|
||||
}
|
||||
else
|
||||
if(PyFunction_Check(po))
|
||||
{
|
||||
new(d) Callback(new CallbackActionPy(po));
|
||||
}
|
||||
else
|
||||
if(PyCallable_Check(po) && PyMethod_Self(po))
|
||||
{
|
||||
new(d) Callback(new CallbackActionPy(po));
|
||||
}
|
||||
if(po == Py_None) { new(d) Callback(); }
|
||||
#if 1 //actually isnt used anywhere so far
|
||||
else
|
||||
if(extract<Callback&>(po).check())
|
||||
{
|
||||
Callback& c = extract<Callback&>(po);
|
||||
new(d) Callback(c);
|
||||
}
|
||||
else if(extract<Callback&>(po).check()) {
|
||||
Callback& c = extract<Callback&>(po); new(d) Callback(c); }
|
||||
#endif
|
||||
else
|
||||
{
|
||||
throw_error_already_set(); //FIXME dont know type, which to throw?
|
||||
}
|
||||
else if(PyFunction_Check(po)) { new(d) Callback(new CallbackActionPy(po)); }
|
||||
else if(PyCallable_Check(po) && PyMethod_Self(po)) { new(d) Callback(new CallbackActionPy(po)); }
|
||||
else { throw_error_already_set(); } //FIXME dont know type, which to throw?
|
||||
|
||||
data->convertible = d;
|
||||
}
|
||||
};
|
||||
|
||||
//Gate
|
||||
|
||||
struct GateActionPy : public GateAction {
|
||||
object o;
|
||||
virtual bool Execute() { return call<bool>(o.ptr()); }
|
||||
GateActionPy(PyObject *callable) : o(handle<>(borrowed(callable))) {}
|
||||
};
|
||||
|
||||
struct Gate_from_python
|
||||
{
|
||||
Gate_from_python() { converter::registry::push_back(&convertible, &construct, type_id<Gate>()); }
|
||||
|
||||
static void* convertible(PyObject* po)
|
||||
{
|
||||
if(po == Py_None) return po;
|
||||
if(PyFunction_Check(po)) return po;
|
||||
if(PyCallable_Check(po) && PyMethod_Self(po)) return po;
|
||||
if(extract<Gate&>(po).check()) return po;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void construct(PyObject* po, converter::rvalue_from_python_stage1_data* data)
|
||||
{
|
||||
void* d = ((converter::rvalue_from_python_storage<Gate>*)data)->storage.bytes;
|
||||
|
||||
if(po == Py_None) { new(d) Gate(); }
|
||||
else if(PyFunction_Check(po)) { new(d) Gate(new GateActionPy(po)); }
|
||||
else if(PyCallable_Check(po) && PyMethod_Self(po)) { new(d) Gate(new GateActionPy(po)); }
|
||||
#if 1 //actually isnt used anywhere so far
|
||||
else if(extract<Gate&>(po).check()) { Gate& c = extract<Gate&>(po); new(d) Gate(c); }
|
||||
#endif
|
||||
else { throw_error_already_set(); } //FIXME dont know type, which to throw?
|
||||
|
||||
data->convertible = d;
|
||||
}
|
||||
};
|
||||
|
||||
///
|
||||
|
||||
struct Callback1Action_int_Py : public Callback1Action<int> {
|
||||
object o;
|
||||
virtual void Execute(int p1) { call<void>(o.ptr(), "i", p1); }
|
||||
Callback1Action_int_Py(PyObject *callable) : o(handle<>(borrowed(callable))) {}
|
||||
};
|
||||
|
||||
struct Callback1_int_from_python
|
||||
{
|
||||
Callback1_int_from_python() { converter::registry::push_back(&convertible, &construct, type_id<Callback1<int> >()); }
|
||||
|
||||
static void* convertible(PyObject* po)
|
||||
{
|
||||
if(po == Py_None) return po;
|
||||
if(PyFunction_Check(po)) return po;
|
||||
if(PyCallable_Check(po) && PyMethod_Self(po)) return po;
|
||||
if(extract<Callback1<int>&>(po).check()) return po;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void construct(PyObject* po, converter::rvalue_from_python_stage1_data* data)
|
||||
{
|
||||
void* d = ((converter::rvalue_from_python_storage<Callback1<int> >*)data)->storage.bytes;
|
||||
|
||||
if(po == Py_None) { new(d) Callback1<int>(); }
|
||||
else if(PyFunction_Check(po)) { new(d) Callback1<int>(new Callback1Action_int_Py(po)); }
|
||||
else if(PyCallable_Check(po) && PyMethod_Self(po)) { new(d) Callback1<int>(new Callback1Action_int_Py(po)); }
|
||||
#if 1 //actually isnt used anywhere so far
|
||||
else if(extract<Callback1<int>&>(po).check()) { Callback1<int>& c = extract<Callback1<int>&>(po); new(d) Callback1<int>(c); }
|
||||
#endif
|
||||
else { throw_error_already_set(); } //FIXME dont know type, which to throw?
|
||||
|
||||
data->convertible = d;
|
||||
}
|
||||
};
|
||||
|
||||
//Gate1<int>
|
||||
|
||||
struct Gate1Action_int_Py : public Gate1Action<int> {
|
||||
object o;
|
||||
virtual bool Execute(int p1) { return call<bool>(o.ptr(), "i", p1); }
|
||||
Gate1Action_int_Py(PyObject *callable) : o(handle<>(borrowed(callable))) {}
|
||||
};
|
||||
|
||||
struct Gate1_int_from_python
|
||||
{
|
||||
Gate1_int_from_python() { converter::registry::push_back(&convertible, &construct, type_id<Gate1<int> >()); }
|
||||
|
||||
static void* convertible(PyObject* po)
|
||||
{
|
||||
if(po == Py_None) return po;
|
||||
if(PyFunction_Check(po)) return po;
|
||||
if(PyCallable_Check(po) && PyMethod_Self(po)) return po;
|
||||
if(extract<Gate1<int>&>(po).check()) return po;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void construct(PyObject* po, converter::rvalue_from_python_stage1_data* data)
|
||||
{
|
||||
void* d = ((converter::rvalue_from_python_storage<Gate1<int> >*)data)->storage.bytes;
|
||||
|
||||
if(po == Py_None) { new(d) Gate1<int>(); }
|
||||
else if(PyFunction_Check(po)) { new(d) Gate1<int>(new Gate1Action_int_Py(po)); }
|
||||
else if(PyCallable_Check(po) && PyMethod_Self(po)) { new(d) Gate1<int>(new Gate1Action_int_Py(po)); }
|
||||
#if 1 //actually isnt used anywhere so far
|
||||
else if(extract<Gate1<int>&>(po).check()) { Gate1<int>& c = extract<Gate1<int>&>(po); new(d) Gate1<int>(c); }
|
||||
#endif
|
||||
else { throw_error_already_set(); } //FIXME dont know type, which to throw?
|
||||
|
||||
data->convertible = d;
|
||||
}
|
||||
|
|
@ -77,9 +167,31 @@ ONCELOCK
|
|||
class_<Callback>("Callback", "Upp Callback")
|
||||
.def(init<const Callback&>())
|
||||
.def("clear", &Callback::Clear)
|
||||
.def("valid", &CallbackIsValid)
|
||||
.def("valid", &Callback::operator bool)
|
||||
.def("__call__", &Callback::Execute)
|
||||
;
|
||||
|
||||
class_<Gate>("Gate", "Upp Gate")
|
||||
.def(init<const Gate&>())
|
||||
.def("clear", &Gate::Clear)
|
||||
.def("valid", &Gate::operator bool)
|
||||
.def("__call__", &Gate::Execute)
|
||||
;
|
||||
|
||||
class_<Callback1<int> >("Callback1<int>", "Upp Callback1<int>")
|
||||
.def(init<const Callback1<int>&>())
|
||||
.def("clear", &Callback1<int>::Clear)
|
||||
.def("valid", &Callback1<int>::operator bool)
|
||||
.def("__call__", &Callback1<int>::Execute)
|
||||
;
|
||||
|
||||
class_<Gate1<int> >("Gate1<int>", "Upp Gate1<int>")
|
||||
.def(init<const Gate1<int>&>())
|
||||
.def("clear", &Gate1<int>::Clear)
|
||||
.def("valid", &Gate1<int>::operator bool)
|
||||
.def("__call__", &Gate1<int>::Execute)
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ struct Value_to_python
|
|||
case DOUBLE_V: return incref(object(double(v)).ptr());
|
||||
case STRING_V: return incref(object(String(v)).ptr());
|
||||
case VALUEARRAY_V: return incref(object(ValueArray(v)).ptr());
|
||||
case VALUEMAP_V: return incref(object(ValueMap(v)).ptr());
|
||||
case COLOR_V: return incref(object(Color(v)).ptr());
|
||||
case POINT_V: return incref(object(Point(v)).ptr());
|
||||
case SIZE_V: return incref(object(Size(v)).ptr());
|
||||
|
|
@ -35,8 +36,8 @@ struct Value_from_python
|
|||
static void* convertible(PyObject* po)
|
||||
{
|
||||
if(po == Py_None) return po;
|
||||
if(PyInt_Check(po)) return po;
|
||||
if(PyBool_Check(po)) return po;
|
||||
if(PyInt_Check(po)) return po;
|
||||
if(PyLong_Check(po)) return po;
|
||||
if(PyFloat_Check(po)) return po;
|
||||
if(PyString_Check(po)) return po;
|
||||
|
|
@ -232,10 +233,12 @@ struct ValueMap_from_python
|
|||
Index<Value> k;
|
||||
Vector<Value> vv;
|
||||
dict dt(handle<>(borrowed(po)));
|
||||
list lk = dt.keys();
|
||||
list lv = dt.values();
|
||||
for(int i = 0; i < len(dt); i++)
|
||||
{
|
||||
k.Add(Null); //FIXME
|
||||
vv.Add(Null); //extract<Value>(dt[i]));
|
||||
k.Add(extract<Value>(lk[i]));
|
||||
vv.Add(extract<Value>(lv[i]));
|
||||
}
|
||||
new(d) ValueMap(k, vv);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ void export_Logc()
|
|||
{
|
||||
ONCELOCK
|
||||
{
|
||||
enum_<Ctrl::PlacementConstants>("choice")
|
||||
enum_<Ctrl::PlacementConstants>("placementcontstants")
|
||||
.value("center", Ctrl::CENTER)
|
||||
.value("middle", Ctrl::MIDDLE)
|
||||
.value("left", Ctrl::LEFT)
|
||||
|
|
@ -46,29 +46,10 @@ ONCELOCK
|
|||
}
|
||||
|
||||
//virtuals
|
||||
bool CtrlAccept(Ctrl& c) { return c.Accept(); }
|
||||
void CtrlReject(Ctrl& c) { c.Reject(); }
|
||||
|
||||
void CtrlSetModify(Ctrl& c, bool b) { if (b) c.SetModify(); else c.ClearModify(); }
|
||||
bool CtrlIsModified(const Ctrl& c) { return c.IsModified(); }
|
||||
|
||||
Size CtrlGetMinSize(Ctrl& c) { return c.GetMinSize(); }
|
||||
Size CtrlGetStdSize(Ctrl& c) { return c.GetStdSize(); }
|
||||
Rect CtrlGetVoidRect(Ctrl& c) { return c.GetVoidRect(); }
|
||||
|
||||
Value CtrlGetData(const Ctrl& c) { return c.GetData(); }
|
||||
void CtrlSetData(Ctrl& c, const Value& data) { c.SetData(data); }
|
||||
|
||||
void CtrlClose(Ctrl& c) { c.Close(); }
|
||||
|
||||
//return ignorers
|
||||
void CtrlWantFocus(Ctrl& c, bool b) { c.WantFocus(b); }
|
||||
void CtrlInitFocus(Ctrl& c, bool b) { c.InitFocus(b); }
|
||||
void CtrlSetEditable(Ctrl& c, bool b) { c.SetEditable(b); }
|
||||
void CtrlSetPos(Ctrl& c, const Ctrl::LogPos& p) { c.SetPos(p); }
|
||||
void CtrlSetTip(Ctrl& c, const String& s) { c.Tip(s); }
|
||||
void CtrlTransparent(Ctrl& c, bool b) { c.Transparent(b); }
|
||||
|
||||
void CtrlLeftPos(Ctrl& c, int a, int size) { c.LeftPos(a, size); }
|
||||
void CtrlRightPos(Ctrl& c, int a, int size) { c.RightPos(a, size); }
|
||||
void CtrlTopPos(Ctrl& c, int a, int size) { c.TopPos(a, size); }
|
||||
|
|
@ -79,17 +60,143 @@ void CtrlHCenterPos(Ctrl& c, int size, int delta) { c.HCenterPos(size, delta); }
|
|||
void CtrlVCenterPos(Ctrl& c, int size, int delta) { c.HCenterPos(size, delta); }
|
||||
void CtrlSizePos(Ctrl& c) { c.SizePos(); }
|
||||
|
||||
void CtrlLeftPosZ(Ctrl& c, int a, int size) { c.LeftPosZ(a, size); }
|
||||
void CtrlRightPosZ(Ctrl& c, int a, int size) { c.RightPosZ(a, size); }
|
||||
void CtrlTopPosZ(Ctrl& c, int a, int size) { c.TopPosZ(a, size); }
|
||||
void CtrlBottomPosZ(Ctrl& c, int a, int size) { c.BottomPosZ(a, size); }
|
||||
void CtrlHSizePosZ(Ctrl& c, int a, int b) { c.HSizePosZ(a, b); }
|
||||
void CtrlVSizePosZ(Ctrl& c, int a, int b) { c.VSizePosZ(a, b); }
|
||||
void CtrlHCenterPosZ(Ctrl& c, int size, int delta) { c.HCenterPosZ(size, delta); }
|
||||
void CtrlVCenterPosZ(Ctrl& c, int size, int delta) { c.HCenterPosZ(size, delta); }
|
||||
|
||||
void CtrlIgnoreMouse(Ctrl& c, bool b) { c.IgnoreMouse(b); }
|
||||
void CtrlWantFocus(Ctrl& c, bool b) { c.WantFocus(b); }
|
||||
void CtrlInitFocus(Ctrl& c, bool b) { c.InitFocus(b); }
|
||||
void CtrlSetEditable(Ctrl& c, bool b) { c.SetEditable(b); }
|
||||
void CtrlSetPos(Ctrl& c, const Ctrl::LogPos& p) { c.SetPos(p); }
|
||||
void CtrlSetTip(Ctrl& c, const String& s) { c.Tip(s); }
|
||||
void CtrlTransparent(Ctrl& c, bool b) { c.Transparent(b); }
|
||||
|
||||
void CtrlSetInfo(Ctrl& c, const String& s) { c.Info(s); }
|
||||
|
||||
//other
|
||||
void CtrlSetCapture(Ctrl& c, bool b) { if(b) c.SetCapture(); else c.ReleaseCapture(); }
|
||||
void CtrlSetFocus(Ctrl& c, bool b) { if(b) c.SetFocus(); else if(c.GetParent()) c.GetParent()->SetFocus(); }
|
||||
void CtrlSetBackPaint(Ctrl& c, bool b) { c.BackPaint(b?(Ctrl::FULLBACKPAINT):(Ctrl::NOBACKPAINT)); }
|
||||
bool CtrlIsBackPaint(const Ctrl& c) { return (c.GetBackPaint()!=Ctrl::NOBACKPAINT); }
|
||||
|
||||
String CtrlToString(const Ctrl& c)
|
||||
{
|
||||
return c.Name();
|
||||
return String().Cat() << String(typeid(c).name()) << ": " << AsString(c.GetData());
|
||||
}
|
||||
|
||||
//
|
||||
enum PaintEnum {
|
||||
_NOBACKPAINT = Ctrl::NOBACKPAINT,
|
||||
_FULLBACKPAINT = Ctrl::FULLBACKPAINT,
|
||||
_TRANSPARENTBACKPAINT = Ctrl::TRANSPARENTBACKPAINT,
|
||||
_EXCLUDEPAINT = Ctrl::EXCLUDEPAINT,
|
||||
};
|
||||
|
||||
class CtrlWrap : public Ctrl, public wrapper<Ctrl> {
|
||||
public:
|
||||
typedef Ctrl C;
|
||||
|
||||
virtual bool Accept() { if(override f = this->get_override("accept")) return f(); return C::Accept(); }
|
||||
bool default_Accept() { return C::Accept(); }
|
||||
|
||||
virtual void Reject() { if(override f = this->get_override("reject")) f(); C::Reject(); }
|
||||
void default_Reject() { C::Reject(); }
|
||||
|
||||
virtual void SetData(const Value& data) { if(override f = this->get_override("setdata")) f(data); C::SetData(data); }
|
||||
void default_SetData(const Value& data) { C::SetData(data); }
|
||||
|
||||
virtual Value GetData() const { if(override f = this->get_override("getdata")) return f(); return C::GetData(); }
|
||||
Value default_GetData() const { return C::GetData(); }
|
||||
|
||||
virtual void SetModify() { if(override f = this->get_override("setmodify")) f(); C::SetModify(); }
|
||||
void default_SetModify() { C::SetModify(); }
|
||||
|
||||
virtual void ClearModify() { if(override f = this->get_override("clearmodify")) f(); C::ClearModify(); }
|
||||
void default_ClearModify() { C::ClearModify(); }
|
||||
|
||||
virtual bool IsModified() const { if(override f = this->get_override("ismodified")) return f(); return C::IsModified(); }
|
||||
bool default_IsModified() const { return C::IsModified(); }
|
||||
|
||||
virtual void CancelMode() { if(override f = this->get_override("cancelmode")) f(); C::CancelMode(); }
|
||||
void default_CancelMode() { C::CancelMode(); }
|
||||
|
||||
virtual void Activate() { if(override f = this->get_override("activate")) f(); C::Activate(); }
|
||||
void default_Activate() { C::Activate(); }
|
||||
|
||||
virtual void Deactivate() { if(override f = this->get_override("deactivate")) f(); C::Deactivate(); }
|
||||
void default_Deactivate() { C::Deactivate(); }
|
||||
|
||||
virtual void LeftDown(Point p, dword keyflags) { if(override f = this->get_override("leftdown")) f(p, keyflags); C::LeftDown(p, keyflags); }
|
||||
void default_LeftDown(Point p, dword keyflags) { C::LeftDown(p, keyflags); }
|
||||
|
||||
//more of interface to come
|
||||
|
||||
virtual bool Key(dword key, int count) { if(override f = this->get_override("key")) return f(key, count); return C::Key(key, count); }
|
||||
bool default_Key(dword key, int count) { return C::Key(key, count); }
|
||||
|
||||
virtual void GotFocus() { if(override f = this->get_override("gotfocus")) f(); C::GotFocus(); }
|
||||
void default_GotFocus() { C::GotFocus(); }
|
||||
|
||||
virtual void LostFocus() { if(override f = this->get_override("lostfocus")) f(); C::LostFocus(); }
|
||||
void default_LostFocus() { C::LostFocus(); }
|
||||
|
||||
virtual void ChildGotFocus() { if(override f = this->get_override("childgotfocus")) f(); C::ChildGotFocus(); }
|
||||
void default_ChildGotFocus() { C::ChildGotFocus(); }
|
||||
|
||||
virtual void ChildLostFocus() { if(override f = this->get_override("childlostfocus")) f(); C::ChildLostFocus(); }
|
||||
void default_ChildLostFocus() { C::ChildLostFocus(); }
|
||||
|
||||
virtual void ChildAdded(Ctrl *child) { if(override f = this->get_override("childadded")) f(child); C::ChildAdded(child); }
|
||||
void default_ChildAdded(Ctrl *child) { C::ChildAdded(child); }
|
||||
|
||||
virtual void ChildRemoved(Ctrl *child) { if(override f = this->get_override("childremoved")) f(child); C::ChildRemoved(child); }
|
||||
void default_ChildRemoved(Ctrl *child) { C::ChildRemoved(child); }
|
||||
|
||||
virtual void State(int reason) { if(override f = this->get_override("state")) f(reason); C::State(reason); }
|
||||
void default_State(int reason) { C::State(reason); }
|
||||
|
||||
virtual void Layout() { if(override f = this->get_override("layout")) f(); C::Layout(); }
|
||||
void default_Layout() { C::Layout(); }
|
||||
|
||||
virtual Size GetMinSize() const { if(override f = this->get_override("getminsize")) return f(); return C::GetMinSize(); }
|
||||
Size default_GetMinSize() const { return C::GetMinSize(); }
|
||||
|
||||
virtual Size GetStdSize() const { if(override f = this->get_override("getstdsize")) return f(); return C::GetStdSize(); }
|
||||
Size default_GetStdSize() const { return C::GetStdSize(); }
|
||||
|
||||
virtual Size GetMaxSize() const { if(override f = this->get_override("getmaxsize")) return f(); return C::GetMaxSize(); }
|
||||
Size default_GetMaxSize() const { return C::GetMaxSize(); }
|
||||
|
||||
virtual bool IsShowEnabled() const { if(override f = this->get_override("isshowenabled")) return f(); return C::IsShowEnabled(); }
|
||||
bool default_IsShowEnabled() const { return C::IsShowEnabled(); }
|
||||
|
||||
virtual Rect GetOpaqueRect() const { if(override f = this->get_override("getopaquerect")) return f(); return C::GetOpaqueRect(); }
|
||||
Rect default_GetOpaqueRect() const { return C::GetOpaqueRect(); }
|
||||
|
||||
virtual Rect GetVoidRect() const { if(override f = this->get_override("getvoidrect")) return f(); return C::GetVoidRect(); }
|
||||
Rect default_GetVoidRect() const { return C::GetVoidRect(); }
|
||||
|
||||
virtual void Updated() { if(override f = this->get_override("updated")) f(); C::Updated(); }
|
||||
void default_Updated() { C::Updated(); }
|
||||
|
||||
virtual void Close() { if(override f = this->get_override("close")) f(); C::Close(); }
|
||||
void default_Close() { C::Close(); }
|
||||
|
||||
virtual String GetDesc() const { if(override f = this->get_override("getdesc")) return f(); return C::GetDesc(); }
|
||||
String default_GetDesc() const { return C::GetDesc(); }
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual void Dump() const { if(override f = this->get_override("dump")) f(); C::Dump(); }
|
||||
void default_Dump() const { C::Dump(); }
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
void export_CtrlCore()
|
||||
{
|
||||
|
|
@ -97,7 +204,71 @@ ONCELOCK
|
|||
{
|
||||
export_Core();
|
||||
export_LogPos();
|
||||
class_<Ctrl, boost::noncopyable>("Ctrl", "Upp Ctrl")
|
||||
|
||||
enum_<Ctrl::StateReason>("statereason")
|
||||
.value("focus", Ctrl::FOCUS)
|
||||
.value("activate", Ctrl::ACTIVATE)
|
||||
.value("deactivate", Ctrl::DEACTIVATE)
|
||||
.value("show", Ctrl::SHOW)
|
||||
.value("enable", Ctrl::ENABLE)
|
||||
.value("editable", Ctrl::EDITABLE)
|
||||
.value("open", Ctrl::OPEN)
|
||||
.value("close", Ctrl::CLOSE)
|
||||
.value("position", Ctrl::POSITION)
|
||||
.value("layoutpos", Ctrl::LAYOUTPOS)
|
||||
;
|
||||
|
||||
enum_<Ctrl::MouseEvents>("mouseevents")
|
||||
.value("button", Ctrl::BUTTON)
|
||||
.value("action", Ctrl::ACTION)
|
||||
|
||||
.value("mouseenter", Ctrl::MOUSEENTER)
|
||||
.value("mousemove", Ctrl::MOUSEMOVE)
|
||||
.value("mouseleave", Ctrl::MOUSELEAVE)
|
||||
.value("cursorimage", Ctrl::CURSORIMAGE)
|
||||
.value("mousewheel", Ctrl::MOUSEWHEEL)
|
||||
|
||||
.value("down", Ctrl::DOWN)
|
||||
.value("up", Ctrl::UP)
|
||||
.value("double", Ctrl::DOUBLE)
|
||||
.value("repeat", Ctrl::REPEAT)
|
||||
.value("drag", Ctrl::DRAG)
|
||||
.value("hold", Ctrl::HOLD)
|
||||
.value("tripple", Ctrl::TRIPLE)
|
||||
|
||||
.value("leftbutton", Ctrl::LEFTDOWN)
|
||||
.value("leftdouble", Ctrl::LEFTDOUBLE)
|
||||
.value("leftrepeat", Ctrl::LEFTREPEAT)
|
||||
.value("leftup", Ctrl::LEFTUP)
|
||||
.value("leftdrag", Ctrl::LEFTDRAG)
|
||||
.value("lefthold", Ctrl::LEFTHOLD)
|
||||
.value("lefttripple", Ctrl::LEFTTRIPLE)
|
||||
|
||||
.value("rightdown", Ctrl::RIGHTDOWN)
|
||||
.value("rightdouble", Ctrl::RIGHTDOUBLE)
|
||||
.value("rightrepeat", Ctrl::RIGHTREPEAT)
|
||||
.value("rightup", Ctrl::RIGHTUP)
|
||||
.value("rightdrag", Ctrl::RIGHTDRAG)
|
||||
.value("righthold", Ctrl::RIGHTHOLD)
|
||||
.value("righttripple", Ctrl::RIGHTTRIPLE)
|
||||
|
||||
.value("middledown", Ctrl::MIDDLEDOWN)
|
||||
.value("middledouble", Ctrl::MIDDLEDOUBLE)
|
||||
.value("middlerepeat", Ctrl::MIDDLEREPEAT)
|
||||
.value("middleup", Ctrl::MIDDLEUP)
|
||||
.value("middledrag", Ctrl::MIDDLEDRAG)
|
||||
.value("middlehold", Ctrl::MIDDLEHOLD)
|
||||
.value("middletripple", Ctrl::MIDDLETRIPLE)
|
||||
;
|
||||
|
||||
enum_<PaintEnum>("paintenum")
|
||||
.value("nobackpaint", _NOBACKPAINT)
|
||||
.value("fullbackpaint", _FULLBACKPAINT)
|
||||
.value("transparentbackpaint", _TRANSPARENTBACKPAINT)
|
||||
.value("excludepaint", _EXCLUDEPAINT)
|
||||
;
|
||||
|
||||
class_<CtrlWrap, boost::noncopyable>("Ctrl", "Upp Ctrl")
|
||||
|
||||
.def("posleft", &Ctrl::PosLeft)
|
||||
.staticmethod("posleft")
|
||||
|
|
@ -112,26 +283,91 @@ ONCELOCK
|
|||
.def("poscenter", (Ctrl::Logc (*)(int, int))&Ctrl::PosCenter)
|
||||
.staticmethod("poscenter")
|
||||
|
||||
.def("accept", &CtrlAccept)
|
||||
.def("reject", &CtrlReject)
|
||||
.def("accept", &Ctrl::Accept, &CtrlWrap::default_Accept)
|
||||
.def("reject", &Ctrl::Reject, &CtrlWrap::default_Reject)
|
||||
|
||||
.def("setdata", &Ctrl::SetData, &CtrlWrap::default_SetData)
|
||||
.def("getdata", &Ctrl::GetData, &CtrlWrap::default_GetData)
|
||||
.add_property("data", &CtrlGetData, &CtrlSetData) //FIXME is not how it should work, but for testing the C++ side interface
|
||||
|
||||
.def("setmodify", &Ctrl::SetModify, &CtrlWrap::default_SetModify)
|
||||
.def("clearmodify", &Ctrl::ClearModify, &CtrlWrap::default_ClearModify)
|
||||
.def("ismodified", &Ctrl::IsModified, &CtrlWrap::default_IsModified)
|
||||
.def("resetmodify", &Ctrl::ResetModify)
|
||||
.def("ismodifiedset", &Ctrl::IsModifySet)
|
||||
|
||||
.def("cancelmode", &Ctrl::CancelMode, &CtrlWrap::default_CancelMode)
|
||||
.def("activate", &Ctrl::Activate, &CtrlWrap::default_Activate)
|
||||
.def("deactivate", &Ctrl::Deactivate, &CtrlWrap::default_Deactivate)
|
||||
|
||||
.def("leftdown", &Ctrl::LeftDown, &CtrlWrap::default_LeftDown)
|
||||
//...
|
||||
.def("key", &Ctrl::Key, &CtrlWrap::default_Key)
|
||||
|
||||
.def("gotfocus", &Ctrl::GotFocus, &CtrlWrap::default_GotFocus)
|
||||
.def("lostfocus", &Ctrl::LostFocus, &CtrlWrap::default_LostFocus)
|
||||
|
||||
.def("childgotfocus", &Ctrl::ChildGotFocus, &CtrlWrap::default_ChildGotFocus)
|
||||
.def("childlostfocus", &Ctrl::ChildLostFocus, &CtrlWrap::default_ChildLostFocus)
|
||||
.def("childadded", &Ctrl::ChildAdded, &CtrlWrap::default_ChildAdded)
|
||||
.def("childremoved", &Ctrl::ChildRemoved, &CtrlWrap::default_ChildRemoved)
|
||||
|
||||
.def("state", &Ctrl::State, &CtrlWrap::default_State)
|
||||
.def("layout", &Ctrl::Layout, &CtrlWrap::default_Layout)
|
||||
|
||||
.def("getminsize", &Ctrl::GetMinSize, &CtrlWrap::default_GetMinSize)
|
||||
.def("getstdsize", &Ctrl::GetStdSize, &CtrlWrap::default_GetStdSize)
|
||||
.def("getminsize", &Ctrl::GetMaxSize, &CtrlWrap::default_GetMaxSize)
|
||||
|
||||
.def("isshowenabled", &Ctrl::IsShowEnabled, &CtrlWrap::default_IsShowEnabled)
|
||||
|
||||
.def("getopaquerect", &Ctrl::GetOpaqueRect, &CtrlWrap::default_GetOpaqueRect)
|
||||
.def("getvoidrect", &Ctrl::GetVoidRect, &CtrlWrap::default_GetVoidRect)
|
||||
|
||||
.def("updated", &Ctrl::Updated, &CtrlWrap::default_Updated)
|
||||
.def("close", &Ctrl::Close, &CtrlWrap::default_Close)
|
||||
|
||||
.def("getdesc", &Ctrl::GetDesc, &CtrlWrap::default_GetDesc)
|
||||
|
||||
.add_property("data", &CtrlGetData, &CtrlSetData)
|
||||
.def_readwrite("whenaction", &Ctrl::WhenAction)
|
||||
|
||||
.add_property("modify", &CtrlIsModified, &CtrlSetModify)
|
||||
.def("resetmodify", &Ctrl::ResetModify)
|
||||
.def("addchild", (void (Ctrl::*)(Ctrl*))&Ctrl::AddChild)
|
||||
.def("addchildafter", (void (Ctrl::*)(Ctrl*, Ctrl*))&Ctrl::AddChild)
|
||||
.def("addchildbefore", &Ctrl::AddChildBefore)
|
||||
.def("removechild", &Ctrl::RemoveChild)
|
||||
|
||||
/// dangerous, since it doesnt care where the objects are owned..this info gets lost in python then.
|
||||
/// if the object is detroyd the object created from these calls in python wont know, and crash
|
||||
.def("getparent", &Ctrl::GetParent, return_value_policy<reference_existing_object>())
|
||||
.def("getfirstchild", &Ctrl::GetFirstChild, return_value_policy<reference_existing_object>())
|
||||
.def("getlastchild", &Ctrl::GetLastChild, return_value_policy<reference_existing_object>())
|
||||
.def("getnext", &Ctrl::GetNext, return_value_policy<reference_existing_object>())
|
||||
.def("getprev", &Ctrl::GetPrev, return_value_policy<reference_existing_object>())
|
||||
///
|
||||
.def("ischild", &Ctrl::IsChild)
|
||||
|
||||
.add_property("foreground", &Ctrl::IsForeground, &Ctrl::SetForeground)
|
||||
|
||||
.def("childfrompoint", &Ctrl::ChildFromPoint, return_value_policy<reference_existing_object>())
|
||||
|
||||
.add_property("isopen", &Ctrl::IsOpen)
|
||||
|
||||
.def("shutdown", &Ctrl::Shutdown)
|
||||
.def("isshutdown", &Ctrl::IsShutdown)
|
||||
|
||||
.add_property("pos", &Ctrl::GetPos, &CtrlSetPos)
|
||||
.add_property("rect", &Ctrl::GetRect, (void (Ctrl::*)(const Rect&))&Ctrl::SetRect)
|
||||
.add_property("size", &Ctrl::GetSize)
|
||||
|
||||
.add_property("minsize", &CtrlGetMinSize)
|
||||
.add_property("stdsize", &CtrlGetStdSize)
|
||||
.add_property("voidrect", &CtrlGetVoidRect)
|
||||
|
||||
.add_property("inview", &Ctrl::InView)
|
||||
.add_property("inframe", &Ctrl::InFrame)
|
||||
|
||||
.def("refreshlayout", &Ctrl::RefreshLayout)
|
||||
.def("refreshlayoutdeep", &Ctrl::RefreshLayoutDeep)
|
||||
.def("refreshparentlayout", &Ctrl::RefreshParentLayout)
|
||||
.def("updatelayout", &Ctrl::UpdateLayout)
|
||||
.def("updateparentlayout", &Ctrl::UpdateParentLayout)
|
||||
|
||||
.def("leftpos", &CtrlLeftPos)
|
||||
.def("rightpos", &CtrlRightPos)
|
||||
.def("toppos", &CtrlTopPos)
|
||||
|
|
@ -142,32 +378,62 @@ ONCELOCK
|
|||
.def("vcenterpos", &CtrlVCenterPos)
|
||||
.def("sizepos", &CtrlSizePos)
|
||||
|
||||
.def("leftposz", &CtrlLeftPosZ)
|
||||
.def("rightposz", &CtrlRightPosZ)
|
||||
.def("topposz", &CtrlTopPosZ)
|
||||
.def("bottomposz", &CtrlBottomPosZ)
|
||||
.def("hsizeposz", &CtrlHSizePosZ)
|
||||
.def("vsizeposz", &CtrlVSizePosZ)
|
||||
.def("hcenterposz", &CtrlHCenterPosZ)
|
||||
.def("vcenterposz", &CtrlVCenterPosZ)
|
||||
|
||||
.def("getscreenrect", &Ctrl::GetScreenRect)
|
||||
.def("getview", &Ctrl::GetView)
|
||||
.def("getscreenview", &Ctrl::GetScreenView)
|
||||
.def("getvisiblescreenrect", &Ctrl::GetVisibleScreenRect)
|
||||
.def("getvisiblescreenview", &Ctrl::GetVisibleScreenView)
|
||||
.def("getworkarea", (Rect (Ctrl::*)() const)&Ctrl::GetWorkArea)
|
||||
|
||||
.def("refresh", (void (Ctrl::*)())&Ctrl::Refresh)
|
||||
.def("isfullrefresh", &Ctrl::IsFullRefresh)
|
||||
|
||||
.def("sync", (void (Ctrl::*)())&Ctrl::Sync)
|
||||
|
||||
//.add_property("ignoremouse", &Ctrl::IgnoreMouse, &CtrlIgnoreMouse)
|
||||
.add_property("capture", &Ctrl::HasCapture, &CtrlSetCapture)
|
||||
.add_property("focus", &Ctrl::HasFocus, &CtrlSetFocus)
|
||||
.add_property("wantfocus", &CtrlWantFocus, &Ctrl::IsWantFocus)
|
||||
.def("hasfocusdeep", &Ctrl::HasFocusDeep)
|
||||
.add_property("wantfocus", &Ctrl::IsWantFocus, &CtrlWantFocus)
|
||||
.add_property("initfocus", &Ctrl::IsInitFocus, &CtrlInitFocus)
|
||||
|
||||
.def("cancelmodedeep", &Ctrl::CancelModeDeep)
|
||||
|
||||
.add_property("show", &Ctrl::IsVisible, &Ctrl::Show)
|
||||
.add_property("shown", &Ctrl::IsShown)
|
||||
.add_property("enable", &Ctrl::IsEnabled, &Ctrl::Enable)
|
||||
.add_property("edit", &Ctrl::IsEditable, &CtrlSetEditable)
|
||||
|
||||
.def("updaterefresh", &Ctrl::UpdateRefresh)
|
||||
.def("update", &Ctrl::Update)
|
||||
.def("action", &Ctrl::Action)
|
||||
.def("refresh", (void (Ctrl::*)(void))&Ctrl::Refresh)
|
||||
|
||||
.def("close", &CtrlClose)
|
||||
.add_property("isopen", &Ctrl::IsOpen)
|
||||
|
||||
.def("updateaction", &Ctrl::UpdateAction)
|
||||
.def("updateactionrefresh", &Ctrl::UpdateActionRefresh)
|
||||
|
||||
.add_property("backpaint", &CtrlIsBackPaint, &CtrlSetBackPaint)
|
||||
.add_property("transparent", &Ctrl::IsTransparent, &CtrlTransparent)
|
||||
|
||||
.add_property("info", &Ctrl::GetInfo, &CtrlSetInfo)
|
||||
.add_property("tip", &Ctrl::GetTip, &CtrlSetTip)
|
||||
|
||||
.def("add", &Ctrl::Add)
|
||||
.def("addchild", (void (Ctrl::*)(Ctrl*))&Ctrl::AddChild)
|
||||
.def("addchildafter", (void (Ctrl::*)(Ctrl*, Ctrl*))&Ctrl::AddChild)
|
||||
.def("addchildbefore", &Ctrl::AddChildBefore)
|
||||
.def("remove", &Ctrl::Remove)
|
||||
|
||||
.def("setalpha", &Ctrl::SetAlpha)
|
||||
.def("ispopup", &Ctrl::IsPopUp)
|
||||
|
||||
#ifdef _DEBUG
|
||||
.def("dump", (void (Ctrl::*)() const)&Ctrl::Dump, &CtrlWrap::default_Dump)
|
||||
#endif
|
||||
.def("__str__", &CtrlToString)
|
||||
;
|
||||
|
||||
|
|
@ -175,6 +441,44 @@ ONCELOCK
|
|||
}
|
||||
}
|
||||
|
||||
class TopWindowWrap : public TopWindow, public wrapper<TopWindow> {
|
||||
public:
|
||||
typedef TopWindow C;
|
||||
|
||||
virtual bool Accept() { if(override f = this->get_override("accept")) return f(); return C::Accept(); }
|
||||
bool default_Accept() { return C::Accept(); }
|
||||
|
||||
virtual void Reject() { if(override f = this->get_override("reject")) f(); C::Reject(); }
|
||||
void default_Reject() { C::Reject(); }
|
||||
|
||||
virtual void Activate() { if(override f = this->get_override("activate")) f(); C::Activate(); }
|
||||
void default_Activate() { C::Activate(); }
|
||||
|
||||
virtual void Deactivate() { if(override f = this->get_override("deactivate")) f(); C::Deactivate(); }
|
||||
void default_Deactivate() { C::Deactivate(); }
|
||||
|
||||
virtual bool Key(dword key, int count) { if(override f = this->get_override("key")) return f(); return C::Key(key, count); }
|
||||
bool default_Key(dword key, int count) { return C::Key(key, count); }
|
||||
|
||||
virtual Size GetMinSize() const { if(override f = this->get_override("getminsize")) return f(); return C::GetMinSize(); }
|
||||
Size default_GetMinSize() const { return C::GetMinSize(); }
|
||||
|
||||
virtual Size GetStdSize() const { if(override f = this->get_override("getstdsize")) return f(); return C::GetStdSize(); }
|
||||
Size default_GetStdSize() const { return C::GetStdSize(); }
|
||||
|
||||
virtual bool IsShowEnabled() const { if(override f = this->get_override("isshowenabled")) return f(); return C::IsShowEnabled(); }
|
||||
bool default_IsShowEnabled() const { return C::IsShowEnabled(); }
|
||||
|
||||
virtual void Close() { if(override f = this->get_override("close")) f(); C::Close(); }
|
||||
void default_Close() { C::Close(); }
|
||||
|
||||
virtual void ChildGotFocus() { if(override f = this->get_override("childgotfocus")) f(); C::ChildGotFocus(); }
|
||||
void default_ChildGotFocus() { C::ChildGotFocus(); }
|
||||
|
||||
virtual String GetDesc() const { if(override f = this->get_override("getdesc")) return f(); return C::GetDesc(); }
|
||||
String default_GetDesc() const { return C::GetDesc(); }
|
||||
};
|
||||
|
||||
//virtuals
|
||||
void TopWindowClose(TopWindow& c) { c.Close(); }
|
||||
|
||||
|
|
@ -220,7 +524,22 @@ ONCELOCK
|
|||
.value("idexit", _IDEXIT)
|
||||
;
|
||||
|
||||
class_<TopWindow, bases<Ctrl>, boost::noncopyable>("TopWindow", "Upp TopWindow", no_init)
|
||||
class_<TopWindowWrap, bases<Ctrl>, boost::noncopyable>("TopWindow", "Upp TopWindow", no_init)
|
||||
|
||||
.def("accept", &TopWindow::Accept, &TopWindowWrap::default_Accept)
|
||||
.def("reject", &TopWindow::Reject, &TopWindowWrap::default_Reject)
|
||||
.def("activate", &TopWindow::Activate, &TopWindowWrap::default_Activate)
|
||||
.def("deactivate", &TopWindow::Deactivate, &TopWindowWrap::default_Deactivate)
|
||||
.def("key", &TopWindow::Key, &TopWindowWrap::default_Key)
|
||||
.def("getminsize", &TopWindow::GetMinSize, &TopWindowWrap::default_GetMinSize)
|
||||
.def("getstdsize", &TopWindow::GetStdSize, &TopWindowWrap::default_GetStdSize)
|
||||
.def("isshowenabled", &TopWindow::IsShowEnabled, &TopWindowWrap::default_IsShowEnabled)
|
||||
.def("close", &TopWindow::Close, &TopWindowWrap::default_Close)
|
||||
.def("getdesc", &TopWindow::GetDesc, &TopWindowWrap::default_GetDesc)
|
||||
.def("childgotfocus", &TopWindow::ChildGotFocus, &TopWindowWrap::default_ChildGotFocus)
|
||||
|
||||
.def_readwrite("whenclose", &TopWindow::WhenClose)
|
||||
|
||||
.def("backup", &TopWindow::Backup)
|
||||
.def("restore", &TopWindow::Restore)
|
||||
.def("break", &TopWindow::Break)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ INITBLOCK
|
|||
map.Add(int(WSTRING_V),Instancer<Ctrl>::Typed<RichTextCtrl>::GetInstancer());
|
||||
map.Add(int(INT64_V), Instancer<Ctrl>::Typed< WithEnterAction<EditInt64> >::GetInstancer());
|
||||
|
||||
//map.Add(int(BOOL_V), Instancer<Ctrl>::Typed<Option>::GetInstancer());
|
||||
map.Add(int(BOOL_V), &OptionInstancer);
|
||||
|
||||
map.Add(int(COLOR_V), Instancer<Ctrl>::Typed<ColorPusher>::GetInstancer());
|
||||
|
|
@ -26,9 +25,9 @@ INITBLOCK
|
|||
map.Add(int(LOGPOS_V), Instancer<Ctrl>::Typed<LogPosCtrl>::GetInstancer());
|
||||
map.Add(int(VALUE_V), Instancer<Ctrl>::Typed<ValuePacker>::GetInstancer());
|
||||
map.Add(int(VALUEARRAY_V), Instancer<Ctrl>::Typed<ValueArrayCtrl>::GetInstancer());
|
||||
map.Add(int(VALUEMAP_V),Instancer<Ctrl>::Typed<ValueMapCtrl>::GetInstancer());
|
||||
map.Add(int(VOID_V), Instancer<Ctrl>::Typed<ValueCtrl>::GetInstancer());
|
||||
//map.Add(int(VALUEMAP_V),Instancer<Ctrl>::Typed<>::GetInstancer());
|
||||
//map.Add(int(ERROR_V), Instancer<Ctrl>::Typed<>::GetInstancer());
|
||||
map.Add(int(ERROR_V), Instancer<Ctrl>::Typed<ErrorValueCtrl>::GetInstancer());
|
||||
//map.Add(int(UNKNOWN_V), Instancer<Ctrl>::Typed<>::GetInstancer());
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +46,7 @@ String VTypeToString(int vtype)
|
|||
CASEENUMPRINT( BOOL_V )
|
||||
|
||||
CASEENUMPRINT( COLOR_V )
|
||||
//CASEENUMPRINT( FONT_V )
|
||||
CASEENUMPRINT( FONT_V )
|
||||
|
||||
CASEENUMPRINT( LOGPOS_V )
|
||||
CASEENUMPRINT( VALUE_V )
|
||||
|
|
@ -140,7 +139,9 @@ ValuePopUp::ValuePopUp()
|
|||
type.Add(int(LOGPOS_V), "LOGPOS_V");
|
||||
//type.Add(int(VALUE_V), "VALUE_V");
|
||||
type.Add(int(VALUEARRAY_V), "VALUEARRAY_V");
|
||||
//type.Add(int(VALUEMAP_V), "VALUEMAP_V");
|
||||
type.Add(int(VALUEMAP_V), "VALUEMAP_V");
|
||||
type.Add(int(ERROR_V), "ERROR_V");
|
||||
|
||||
type <<= THISBACK(TypeAction);
|
||||
|
||||
ok <<= THISBACK(Acceptor);
|
||||
|
|
|
|||
|
|
@ -63,23 +63,7 @@ protected:
|
|||
Value v,vs;
|
||||
};
|
||||
|
||||
class DataRedir : public ParentCtrl
|
||||
{
|
||||
public:
|
||||
typedef DataRedir CLASSNAME;
|
||||
virtual void SetData(const Value& v) { if(!ctrl) return; ctrl->SetData(v); }
|
||||
virtual Value GetData() const { if(!ctrl) return Value(); return ctrl->GetData(); }
|
||||
void ChildAdded(Ctrl* child) { ctrl = child; }
|
||||
void ChildRemoved(Ctrl* child) { if(ctrl == child) ctrl = NULL; }
|
||||
|
||||
protected:
|
||||
Ptr<Ctrl> ctrl;
|
||||
};
|
||||
|
||||
NAMESPACE_UPP
|
||||
template<> inline bool IsNull(const Value& v) { return v.IsNull(); }
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
//for nested Value in Value
|
||||
class ValuePacker : public ValueCtrl
|
||||
{
|
||||
public:
|
||||
|
|
@ -96,10 +80,10 @@ public:
|
|||
//String ss = AsString(v);
|
||||
return v;
|
||||
}
|
||||
virtual void SetData(const Value& _v)
|
||||
virtual void SetData(const Value& v)
|
||||
{
|
||||
if(_v.Is<Value>()) ValueCtrl::SetData(RawValue<Value>::Extract(_v));
|
||||
else ValueCtrl::SetData(_v);
|
||||
if(v.Is<Value>()) ValueCtrl::SetData(RawValue<Value>::Extract(v));
|
||||
else ValueCtrl::SetData(v);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -120,21 +104,73 @@ public:
|
|||
vv << Get(i, 0);
|
||||
return ValueArray(vv);
|
||||
}
|
||||
virtual void SetData(const Value& _v)
|
||||
virtual void SetData(const Value& v)
|
||||
{
|
||||
Clear();
|
||||
if(_v.Is<ValueArray>())
|
||||
if(v.Is<ValueArray>())
|
||||
{
|
||||
ValueArray va = _v;
|
||||
for(int i = 0; i < va.GetCount(); i++)
|
||||
Set(i, 0, va.Get(i));
|
||||
ValueArray va = v;
|
||||
const Vector<Value>& vv = va.Get();
|
||||
for(int i = 0; i < vv.GetCount(); i++)
|
||||
Set(i, 0, vv[i]);
|
||||
}
|
||||
else
|
||||
Set(0, 0, _v);
|
||||
Set(0, 0, v);
|
||||
}
|
||||
protected:
|
||||
static void CreateValueCtrl(One<Ctrl>& ctrl) { ctrl.Create<ValueCtrl>(); }
|
||||
};
|
||||
|
||||
class ValueMapCtrl : public ArrayCtrl
|
||||
{
|
||||
public:
|
||||
typedef ValueMapCtrl CLASSNAME;
|
||||
ValueMapCtrl()
|
||||
{
|
||||
AddColumn("Key").Ctrls(&CreateValueCtrl).HeaderTab();
|
||||
AddColumn("Value").Ctrls(&CreateValueCtrl).HeaderTab();
|
||||
Appending().Inserting().Removing();
|
||||
WhenCtrlsAction = Proxy(WhenAction);
|
||||
}
|
||||
virtual Value GetData() const
|
||||
{
|
||||
Index<Value> k;
|
||||
Vector<Value> vv;
|
||||
for(int i = 0; i < GetCount(); i++)
|
||||
{
|
||||
k << Get(i, 0); vv << Get(i, 1);
|
||||
}
|
||||
return ValueMap(k, vv);
|
||||
}
|
||||
|
||||
virtual void SetData(const Value& v)
|
||||
{
|
||||
Clear();
|
||||
if(v.Is<ValueMap>())
|
||||
{
|
||||
ValueMap vm = v;
|
||||
const Index<Value>& k = vm.GetKeys();
|
||||
ValueArray va = vm.GetValues();
|
||||
const Vector<Value>& vv = va.Get();
|
||||
for(int i = 0; i < k.GetCount(); i++)
|
||||
{
|
||||
Set(i, 0, k[i]); Set(i, 1, vv[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
Set(0, 0, v);
|
||||
}
|
||||
|
||||
protected:
|
||||
static void CreateValueCtrl(One<Ctrl>& ctrl) { ctrl.Create<ValueCtrl>(); }
|
||||
};
|
||||
|
||||
class ErrorValueCtrl : public WithEnterAction<EditString>
|
||||
{
|
||||
public:
|
||||
typedef ErrorValueCtrl CLASSNAME;
|
||||
virtual Value GetData() const { return ErrorValue(EditString::GetData()); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue