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/display.cc

Go to the documentation of this file.
00001 /* $Id: display.cc,v 1.7 2003/08/05 14:23:15 reed Exp $ */
00002 
00003 
00004 /*
00005 
00006     Copyright (C) 2002 Reed Hedges
00007 
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Lesser General Public
00010     License as published by the Free Software Foundation; either
00011     version 2 of the License, or (at your option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Lesser General Public License for more details.
00017 
00018     You should have received a copy of the GNU Lesser General Public
00019     License along with this library; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00021 */
00022 
00023 
00024 /** @file container.cc Code: a MetaObject for Display object types. */
00025 
00026 #include <vos/corelibs/vos/vos.hh>
00027 #include <vos/metaobjects/property/property.hh>
00028 #include "container.hh"
00029 #include "display.hh"
00030 
00031 using namespace VOSGUI;
00032 
00033 /* Constructor */
00034 Display::Display(MetaObject* s) : MetaObject(s),
00035     accessControl(&NoPropertyAccessControl::static_) {
00036 }
00037 
00038 Display::~Display() {
00039 }
00040 
00041 
00042 /* Get/Set default AC */
00043 void Display::setPropertyAccessControl(PropertyAccessControl* ac) {
00044     accessControl = ac;
00045 }
00046 
00047 PropertyAccessControl* Display::getPropertyAccessControl() {
00048     return accessControl;
00049 }
00050 
00051 void Display::initialize(PropertyAccessControl* ac) {
00052     setPropertyAccessControl(ac);
00053 }
00054 
00055 void Display::initialize() {
00056     initialize(&NoPropertyAccessControl::static_);
00057 }
00058 
00059 
00060 LocalDisplay::LocalDisplay(MetaObject* s) : Display(s), MetaObject(s) {
00061 }
00062 
00063 
00064 
00065 RemoteDisplay::RemoteDisplay(MetaObject* s) : Display(s), MetaObject(s) {
00066 }
00067 
00068 
00069 const string Display::getType() {
00070     return string("gui:display");
00071 }
00072 
00073 /* Register extenders with libvos MetaFactory */
00074 void Display::registerExtenders() {
00075     LocalSite::addLocalObjectExtension(typeid(LocalDisplay).name(), &LocalDisplay::new_LocalDisplay);
00076     LocalSite::addLocalObjectExtension(typeid(Display).name(), &LocalDisplay::new_LocalDisplay);
00077     LocalSite::addLocalObjectExtension("gui:display", &LocalDisplay::new_LocalDisplay);
00078     RemoteSite::addRemoteObjectExtension(typeid(RemoteDisplay).name(), &RemoteDisplay::new_RemoteDisplay);
00079     RemoteSite::addRemoteObjectExtension(typeid(Display).name(), &RemoteDisplay::new_RemoteDisplay);
00080     RemoteSite::addRemoteObjectExtension("gui:display", &RemoteDisplay::new_RemoteDisplay);
00081 }
00082 
00083 
00084 
00085 /* Get and set Subproperties and other Subobjects */
00086 
00087 string Display::getAppInfo() {
00088     string s;
00089     vRef<Vobject> v = findObject("gui:display-app-info");
00090     Property* p = meta_cast<Property*>(&v);
00091     if(!p) throw bad_cast();
00092     p->read(s);
00093     return s;
00094 }
00095 
00096 void Display::setAppInfo(const string& value, PropertyAccessControl* ac) {
00097     if(!ac)
00098         ac = accessControl;
00099     Property::setProperty(*this, "gui:display-app-info", value, "text/plain", ac);
00100 }
00101 
00102 
00103 string Display::getUserId() {
00104     string s;
00105     vRef<Vobject> v = findObject("gui:display-user-id");
00106     Property* p = meta_cast<Property*>(&v);
00107     if(!p) throw bad_cast();
00108     p->read(s);
00109     return s;
00110 }
00111 
00112 void Display::setUserId(const string& value, PropertyAccessControl* ac) {
00113     if(!ac)
00114         ac = accessControl;
00115     Property::setProperty(*this, "gui:display-user-id", value, "text/plain", ac);
00116 }
00117 
00118 bool Display::getAppDedicated() {
00119     string s;
00120     try {
00121         vRef<Vobject> v = findObject("gui:display-app-dedicated");
00122         Property* p = meta_cast<Property*>(&v);
00123         if(!p) throw bad_cast();
00124         p->read(s);
00125     } catch(Vobject::NoSuchObjectError) {
00126        return false;
00127     } catch(bad_cast) {
00128         return false;
00129     }
00130     if(s == "no")
00131         return false;
00132     else
00133         return true;
00134 }
00135 
00136 void Display::setAppDedicated(bool value, PropertyAccessControl* ac) {
00137     if(!ac)
00138         ac = accessControl;
00139     Property::setProperty(*this, "gui:display-app-dedicated", value?"yes":"no", "text/x-yes-no", ac);
00140 }
00141 
00142 
00143 void Display::addWindow(Container* c, const string& contextName) {
00144     try {
00145         ParentChildRelation& rel = c->findParent(*this);
00146         c->raise();
00147     } catch(NoSuchObjectError) {
00148         if(contextName == "")
00149             insertChild(-1, c->getName(), c); 
00150         else
00151             insertChild(-1, contextName, c);
00152     }
00153 }
00154 
00155 void Display::removeWindow(Container* c) {
00156     LOG("VOSGUI::Display", 2, "Removing child from display...");
00157     ParentChildRelation& rel = c->findParent(*this);
00158     removeChild(rel.position);
00159 }
00160 
00161 void Display::addSubDisplay(Display* c, const string& contextName) {
00162     if(contextName == "")
00163         insertChild(-1, c->getName(), c); 
00164     else
00165         insertChild(-1, contextName, c);
00166 }
00167 
00168 void Display::removeSubDisplay(Display* c) {
00169     ParentChildRelation& rel = c->findParent(*this);
00170     removeChild(rel.position);
00171 }
00172 
00173 
00174 MetaObject* LocalDisplay::new_LocalDisplay(MetaObject *s, const string& type) {
00175     return new LocalDisplay(s);
00176 }
00177 
00178 MetaObject* RemoteDisplay::new_RemoteDisplay(MetaObject *s, const string& type) {
00179     return new RemoteDisplay(s);
00180 }
00181 

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