Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

vos/gui/gui/input.cc

Go to the documentation of this file.
00001 /* $Id: input.cc,v 1.14 2003/07/23 00:17:20 reed Exp $ */
00002 
00003 /** @file input.cc Define Input, a MetaObject for "gui:widget.input" object types. */
00004 
00005 /*  Copyright (C) 2002 Reed Hedges <reed@interreality.org>
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
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 /* Constructor */
00032 Input::Input(MetaObject* s) : MetaObject(s), Widget(s)
00033 {
00034 }
00035 
00036 /* Destructor */
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 /* Initialize required subobjects: */
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 /* Return type string ("gui:widget.input") */
00070 
00071 const string Input::getType() {
00072     return string("gui:widget.input");
00073 }
00074 
00075 /* Register extenders with libvos MetaFactory */
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 /* Get and set Subproperties and other Subobjects */
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 /* Generators for factory */
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 

Generated on Tue Aug 12 03:55:43 2003 for Interreality Project - VOS by doxygen 1.3.2