00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <vos/corelibs/vos/vos.hh>
00026 #include <vos/metaobjects/property/property.hh>
00027 #include "input.hh"
00028
00029 using namespace VOSGUI;
00030
00031
00032 Input::Input(MetaObject* s) : MetaObject(s), Widget(s)
00033 {
00034 }
00035
00036
00037 Input::~Input() {
00038 }
00039
00040
00041 LocalInput::LocalInput(MetaObject* s) : Input(s), MetaObject(s), LocalWidget(s), Widget(s)
00042 {
00043 }
00044
00045 LocalInput::~LocalInput() {
00046 }
00047
00048
00049
00050 void LocalInput::initialize(PropertyAccessControl* ac) {
00051 LocalWidget::initialize(ac);
00052 try {
00053 vRef<Vobject> v = findObject("gui:target");
00054 } catch(NoSuchObjectError) {
00055 setTarget("undefined", "text/plain");
00056 }
00057 }
00058
00059
00060
00061 RemoteInput::RemoteInput(MetaObject* s) : Input(s), MetaObject(s), Widget(s), RemoteWidget(s)
00062 {
00063
00064 }
00065
00066 RemoteInput::~RemoteInput() {
00067 }
00068
00069
00070
00071 const string Input::getType() {
00072 return string("gui:widget.input");
00073 }
00074
00075
00076 void Input::registerExtenders() {
00077 LocalSite::addLocalObjectExtension(typeid(LocalInput).name(), &LocalInput::new_LocalInput);
00078 LocalSite::addLocalObjectExtension(typeid(Input).name(), &LocalInput::new_LocalInput);
00079 LocalSite::addLocalObjectExtension("gui:widget.input", &LocalInput::new_LocalInput);
00080 RemoteSite::addRemoteObjectExtension(typeid(RemoteInput).name(), &RemoteInput::new_RemoteInput);
00081 RemoteSite::addRemoteObjectExtension(typeid(Input).name(), &RemoteInput::new_RemoteInput);
00082 RemoteSite::addRemoteObjectExtension("gui:widget.input", &RemoteInput::new_RemoteInput);
00083 }
00084
00085
00086
00087 string Input::getTarget() {
00088 string s;
00089 vRef<Vobject> v = findObject("gui:target");
00090 Property* p = meta_cast<Property*>(&v);
00091 if(!p) throw bad_cast();
00092 p->read(s);
00093 return s;
00094 }
00095
00096 string Input::getTargetDatatype() {
00097 vRef<Vobject> v = findObject("gui:target");
00098 Property* p = meta_cast<Property*>(&v);
00099 if(!p) throw bad_cast();
00100 return p->getDataType();
00101 }
00102
00103 void Input::setTarget(const string& value, const string& datatype, PropertyAccessControl* ac) {
00104 if(ac == 0)
00105 ac = accessControl;
00106 Property::setProperty(*this, "gui:target", value, datatype, ac);
00107 }
00108
00109 Property* Input::getTargetObj() {
00110 Property* p = meta_cast<Property*>(&findObject("gui:target"));
00111 if(!p) throw bad_cast();
00112 return p;
00113 }
00114
00115 void Input::setTargetObj(Property* newobj) {
00116 assert(newobj);
00117 try {
00118 vRef<ParentChildRelation> pcr = findChild("gui:target");
00119 setChild(pcr->position, "gui:target", newobj);
00120 } catch (NoSuchObjectError) {
00121 insertChild(-1, "gui:target", newobj);
00122 }
00123 }
00124
00125 bool Input::getMultiline() {
00126 return Property::getBoolProperty(*this, "gui:multiline", false);
00127 }
00128
00129 void Input::setMultiline(bool value, PropertyAccessControl* ac) {
00130 if(ac == 0)
00131 ac = accessControl;
00132 Property::setProperty(*this, "gui:multiline", (value?"yes":"no"), "text/x-yes-no", ac);
00133 }
00134
00135 Property* Input::getMultilineObj() {
00136 Property* p = meta_cast<Property*>(&findObject("gui:multiline"));
00137 if(!p) throw bad_cast();
00138 return p;
00139 }
00140
00141 void Input::setMultilineObj(Property* newobj) {
00142 try {
00143 vRef<ParentChildRelation> pcr = findChild("gui:multiline");
00144 setChild(pcr->position, "gui:multiline", newobj);
00145 } catch (NoSuchObjectError) {
00146 insertChild(-1, "gui:multiline", newobj);
00147 }
00148 }
00149
00150
00151
00152
00153
00154 MetaObject* LocalInput::new_LocalInput(MetaObject *s, const string& type) {
00155 LocalInput* o = new LocalInput(s);
00156 return o;
00157 }
00158
00159 MetaObject* RemoteInput::new_RemoteInput(MetaObject *s, const string& type) {
00160 return new RemoteInput(s);
00161 }
00162