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/select_value.hh

Go to the documentation of this file.
00001 /* $Id: select_value.hh,v 1.6 2003/07/24 05:18:25 tetron Exp $ 
00002 
00003     Copyright (C) 2003 Reed Hedges <reed@zerohour.net>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00018 
00019 */ 
00020 
00021 #ifndef _GUI_SELECT_VALUE_HH_
00022 #define _GUI_SELECT_VALUE_HH_
00023 
00024 #if defined(_WIN32) && defined(_MSC_VER)
00025 # ifdef VOSGUI_EXPORTS
00026 #  define VOSGUI_API __declspec(dllexport)
00027 # else
00028 #  define VOSGUI_API __declspec(dllimport)
00029 # endif
00030 #else
00031 # define VOSGUI_API
00032 #endif
00033 
00034 #include <vos/corelibs/vos/vos.hh>
00035 #include <vos/metaobjects/property/property.hh>
00036 #include <vos/gui/gui/select.hh>
00037 
00038 namespace VOSGUI {
00039 
00040 /** MetaObject implementing SelectValue Object Type. 
00041  *  This control presents a choice of values for a property, one of which
00042  *  may be selected using a radio button or popup menu.
00043  *
00044  * @todo add property specifying order to try determining what text to display
00045  *  in value (e.g. "subobj(misc:title),property-contents,context-name"). or use
00046  *  a value of properties.  Or change the choices group to contain small structure 
00047  *  objects (linking to label and the actual object)
00048  *
00049  *  @warning You must call initialize() for this object to work correctly.
00050 */
00051 class VOSGUI_API SelectValue : public virtual Select
00052 {
00053 
00054 protected:
00055     vRef<Vobject>   choices;
00056     vRef<Property>  selected;
00057 
00058 
00059 public:
00060 
00061     /** Constructor */
00062     SelectValue(MetaObject* superobject);
00063 
00064     /** Destructor */
00065     virtual ~SelectValue();
00066 
00067     /** Return type string ("gui:widget.select.value") */
00068     virtual const std::string getType();
00069 
00070     /** Register Extenders */
00071     static void registerExtenders();
00072 
00073     /** Get the property containing the value  */
00074     //@{
00075     Property* getSelectedObj();
00076     inline Property* getTargetObj() {
00077         return getSelectedObj();
00078     }
00079     //@}
00080 
00081     /** Set the property containing the chosen value */
00082     //@{
00083     void setSelectedObj(Property* p);
00084     inline void setTargetObj(Property* p) {
00085         setSelectedObj(p);
00086     }
00087     //@}
00088 
00089 
00090 
00091     /** Get the selected value */
00092     std::string getValue();
00093 
00094     /** Get the selected value */
00095     void getValue(std::string& v);
00096 
00097     /** Set the selected value */
00098     void setValue(const std::string& v);
00099 
00100     /** Add a value choice */
00101     void add(const std::string& label, Property* property);
00102 
00103     /** Add a value choice */
00104     void add(Property* property);
00105 
00106     /** Add a value choice */
00107     void add(const std::string& label, const std::string& value,
00108             PropertyAccessControl* defaultValueAC = &NoPropertyAccessControl::static_);
00109 
00110 
00111     /** Add a value choice */
00112     void add(const std::string& value,
00113             PropertyAccessControl* defaultValueAC = &NoPropertyAccessControl::static_);
00114 
00115     /** Remove (the first occurance of) an object from the value */
00116     void remove(const std::string& value) throw (NoSuchObjectError);
00117 
00118     /** Set and get the style of the object */
00119     //@{
00120     void setStyle(const std::string& style, PropertyAccessControl* pac = 0);
00121     void setPopup(PropertyAccessControl* pac = 0);
00122     void setRadio(PropertyAccessControl* pac = 0);
00123     std::string getStyle();
00124     Property* getStyleObj();
00125     //@}
00126 
00127     /** If style is "radio", you can specify the orientation and maximum size
00128         of the radio box */
00129     //@{
00130     void setRadioOrientation(const std::string& ori, PropertyAccessControl* pac = 0);
00131     std::string getRadioOrientation();
00132     void setRadioSize(int n, PropertyAccessControl* pac = 0);
00133     int getRadioSize();
00134     //@}
00135 
00136     /** Return the Vobject containing choices objects */
00137     Vobject* getChoicesObj();
00138 
00139     /** Set the choices container object. Don't call after
00140         initialize() or it won't work right. */
00141     void setChoicesObj(Vobject* obj);
00142 
00143     /** Find/create certain subobjects. 
00144      * You MUST call this for things to work correctly. */
00145     virtual void initialize();
00146 
00147 };
00148 
00149 
00150 
00151 /** Local version of SelectValue. 
00152  * @warning You must call initialize() for this object to work properly. */
00153 class VOSGUI_API LocalSelectValue : public virtual SelectValue, public virtual LocalSelect
00154 {
00155 
00156 public:
00157 
00158     /** Constructor */
00159     LocalSelectValue(MetaObject* superobject);
00160 
00161     /** Destructor */
00162     ~LocalSelectValue();
00163 
00164     /** Static generator, for factory. */
00165     static MetaObject* new_LocalSelectValue(MetaObject* superobject, const std::string& type);
00166 
00167     /** Creates required subobjects, and adds DoNothingListener to them
00168      * (this makes future operations faster). 
00169      * You MUST call this function (or setSelectedObj, setChoicesObj and
00170      * setMultiple) for things to work correctly.
00171      * @bug always sets the property access control on the "multiple" property
00172      *       to NoPropertyAccessControl::static_ 
00173      */
00174     virtual void initialize();
00175 
00176 
00177 };
00178 
00179 
00180 /** Remote version of SelectValue. */
00181 class VOSGUI_API RemoteSelectValue : public virtual SelectValue, public virtual RemoteSelect
00182 {
00183 public:
00184 
00185     /** Constructor */
00186     RemoteSelectValue(MetaObject* superobject);
00187 
00188     /** Destructor */
00189     virtual ~RemoteSelectValue();
00190 
00191     /** Static generator, for factory. */
00192     static MetaObject* new_RemoteSelectValue(MetaObject* superobject, const std::string& type);
00193 
00194 
00195 };
00196 
00197 } //namespace VOSGUI 
00198 
00199 #endif // #ifdef _GUI_SELECT_VALUE_HH_
00200 

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