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

Go to the documentation of this file.
00001 /* $Id: label.cc,v 1.8 2003/07/24 16:12:13 reed Exp $ */
00002 
00003 
00004 /* This file was generated by otd2cpp.pl
00005 
00006 Copyright (C) 2002 Peter Amstutz <tetron@interreality.org>
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 label.cc Code: a MetaObject for Label object types. */
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 /* Constructor */
00034 Label::Label(MetaObject* s) : MetaObject(s), Widget(s)
00035 {
00036 }
00037 
00038 /* Destructor */
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 /* Initialize required subobjects: */
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 /* Return type string ("gui:widget.label") */
00066 
00067 const string Label::getType() {
00068     return string("gui:widget.label");
00069 }
00070 
00071 /* Register extenders with libvos MetaFactory */
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 /* Generators for factory */
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 

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