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
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
00034 Display::Display(MetaObject* s) : MetaObject(s),
00035 accessControl(&NoPropertyAccessControl::static_) {
00036 }
00037
00038 Display::~Display() {
00039 }
00040
00041
00042
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
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
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