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 <vos/metaobjects/property/fileproperty.hh>
00029 #include "label.hh"
00030
00031 using namespace VOSGUI;
00032
00033
00034 Label::Label(MetaObject* s) : MetaObject(s), Widget(s)
00035 {
00036 }
00037
00038
00039 Label::~Label() {
00040 }
00041
00042
00043 LocalLabel::LocalLabel(MetaObject* s) : Label(s), MetaObject(s), Widget(s), LocalWidget(s)
00044 {
00045 }
00046
00047 LocalLabel::~LocalLabel() {
00048 }
00049
00050
00051
00052 void LocalLabel::initialize(PropertyAccessControl* ac) {
00053 LocalWidget::initialize(ac);
00054 vRef<LocalSite> localsite = Site::getDefaultPeer();
00055 try {
00056 vRef<Vobject> v = findObject("gui:label");
00057 } catch(NoSuchObjectError) {
00058 setLabel("undefined", "text/plain");
00059 }
00060 }
00061
00062
00063
00064
00065
00066
00067 const string Label::getType() {
00068 return string("gui:widget.label");
00069 }
00070
00071
00072 void Label::registerExtenders() {
00073 LocalSite::addLocalObjectExtension(typeid(LocalLabel).name(), &LocalLabel::new_LocalLabel);
00074 LocalSite::addLocalObjectExtension(typeid(Label).name(), &LocalLabel::new_LocalLabel);
00075 LocalSite::addLocalObjectExtension("gui:widget.label", &LocalLabel::new_LocalLabel);
00076 }
00077
00078
00079
00080
00081
00082 MetaObject* LocalLabel::new_LocalLabel(MetaObject *s, const string& type) {
00083 LocalLabel* o = new LocalLabel(s);
00084 return o;
00085 }
00086
00087
00088
00089 void Label::setLabelToFile(const string& filename, const string& datatype, PropertyAccessControl* ac) {
00090
00091 if (!ac)
00092 ac = accessControl;
00093
00094 int i;
00095 for(i = filename.size()-1; i > 0 && filename[i] != '/'; i--);
00096 if(filename[i] == '/') i++;
00097
00098 vRef<FileProperty> fp = Site::getDefaultPeer()->
00099 createMetaObject<FileProperty>(filename.substr(i).c_str());
00100 if(&fp) {
00101 fp->setFileBackend(filename, datatype);
00102 fp->insertPropertyAccessControl(-1, ac);
00103 int pos = -1;
00104 try {
00105 vRef<ParentChildRelation> pcr = findChild("gui:label");
00106 pos = pcr->position;
00107 } catch(NoSuchObjectError) {
00108 } catch(AccessControlError) {
00109 } catch(RemoteError) {
00110 }
00111 if(pos > -1) setChild(pos, "gui:label", &fp);
00112 else insertChild(-1, "gui:label", &fp);
00113 } else {
00114 LOG("VOSGUI::Label", 2, "Hey, You don't seem to have the FileProperty plugin initialized!");
00115 }
00116 }
00117