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_list.hh

Go to the documentation of this file.
00001 /* $Id: select_list.hh,v 1.12 2003/07/24 05:18:26 tetron Exp $ */
00002 
00003 
00004 /** @file select.boolean.hh Defines MetaObject class for select.boolean type (revision 0).
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 #ifndef _GUI_SELECT_LIST_HH_
00025 #define _GUI_SELECT_LIST_HH_
00026 
00027 #if defined(_WIN32) && defined(_MSC_VER)
00028 # ifdef VOSGUI_EXPORTS
00029 #  define VOSGUI_API __declspec(dllexport)
00030 # else
00031 #  define VOSGUI_API __declspec(dllimport)
00032 # endif
00033 #else
00034 # define VOSGUI_API
00035 #endif
00036 
00037 #include <vos/corelibs/vos/vos.hh>
00038 #include <vos/metaobjects/property/property.hh>
00039 #include <vos/gui/gui/select.hh>
00040 
00041 namespace VOSGUI {
00042 
00043 /** MetaObject implementing SelectList Object Type. 
00044  *  This control presents a list of objects. One or more may be selected,
00045  *  in which case they are added to the "selected" group.
00046  *
00047  *  @todo add subobjects representing columns, containing properties with
00048  *   text or images to be used in each column. support multiple view types.
00049  *   icons.
00050  *
00051  * @todo add property specifying order to try determining what text to display
00052  *  in list (e.g. "subobj(misc:title),property-contents,context-name"). or use
00053  *  a list of properties.  Or change the choices group to contain small structure 
00054  *  objects (linking to label and the actual object)
00055  *
00056  *  @warning You must call initialize() for this object to work correctly.
00057 */
00058 class VOSGUI_API SelectList : public virtual Select
00059 {
00060 
00061 protected:
00062     vRef<Vobject>   choices;
00063     vRef<Vobject>   selected;
00064 
00065 
00066 public:
00067 
00068     /** Constructor */
00069     SelectList(MetaObject* superobject);
00070 
00071     /** Destructor */
00072     virtual ~SelectList();
00073 
00074     /** Return type string ("gui:widget.select.list") */
00075     virtual const string getType();
00076 
00077     /** Register Extenders */
00078     static void registerExtenders();
00079 
00080     /** Get the selected objects  */
00081     deque<Vobject*> getSelected();
00082 
00083     /** Get the first selected object. This is convenient for use when
00084         multiple selection is off. (But does not make much sense when
00085         it is on).
00086         Returns 0 if there are no object selected.
00087     */
00088     Vobject* getFirstSelected();
00089 
00090 
00091 
00092     /** Add an object to list 
00093      * @param obj   The object to add.
00094      * @param title  Text to put in the list. 
00095      * @param pos   Position to add it at. See Vobject::insertChild() for
00096      *              the meaning of negative positions. If not specified, 
00097      *              the object will be added at the end. 
00098      *              Behavior of clients when there are "gaps" (the list
00099      *              is missing objects at some positions) is undefined. 
00100      * 
00101      */
00102     void add(Vobject* obj, const string& title = "item", int pos = -1);
00103 
00104     /** Remove (the first occurance of) an object from the list */
00105     void remove(Vobject* obj) throw (NoSuchObjectError);
00106 
00107     /** Set multiple selection property. This does not affect the behavior
00108      * of the add() method, rather it instructs client applications to
00109      * allow or disallow multiple selections.
00110      *
00111      * @param m If true, the property is set to "yes", and multiple 
00112      *          selections should be allowed. If false, only one selection 
00113      *          should be allowed. If no argument is given, multiple selection 
00114      *          will be turned on.
00115      *          This property is initially set to "yes".
00116      *
00117      * @param pac   Property access control policty to use on this property.
00118      *          If not given, defaults to NoPropertyAccessControl::static_
00119      *
00120      */
00121     void setMultiple(bool m = true, PropertyAccessControl* pac = 0);
00122 
00123     bool getMultiple();
00124 
00125     Property* getMultipleObj();
00126 
00127     /** Return the Vobject containing selected objects */
00128     Vobject* selectedObjectList();
00129 
00130     /** Set the selected objects container object. Don't call after
00131         initialize() or it won't work. */
00132     void setSelectedObj(Vobject* obj);
00133 
00134     /** Return the Vobject containing choices objects */
00135     Vobject* choicesObjectList();
00136 
00137     /** Set the choices container object. Don't call after
00138         initialize() or it won't work right. */
00139     void setChoicesObj(Vobject* obj);
00140 
00141     /** Find "gui:selected" and "gui:choices" subobjects. 
00142      * You MUST call this, or call setSelectedObj(), setChoicesObj() and
00143         setMultiple(), for things to work correctly. */
00144     virtual void initialize();
00145 
00146 
00147     /** Find a suitable label Property for an item (for internal use, 
00148         primarily). The following sources are tried, in this order:
00149         <ol>
00150             <li>The value of the item's "misc:label" subproperty</li>
00151             <li>The value of the item's "misc:title" subproperty</li>
00152             <li>The value of the item's "misc:name" subproperty</li>
00153             <li>The value of the item's "misc:nick" subproperty</li>
00154             <li>0</li>
00155         </ol>
00156         @todo Use a property to set the order of label sources.
00157     */
00158     Property* getItemLabel(Vobject& item);
00159             
00160         
00161 };
00162 
00163 
00164 
00165 /** Local version of SelectList. 
00166  * @warning You must call initialize() for this object to work properly. */
00167 class VOSGUI_API LocalSelectList : public virtual SelectList, public virtual LocalSelect
00168 {
00169 
00170 public:
00171 
00172     /** Constructor */
00173     LocalSelectList(MetaObject* superobject);
00174 
00175     /** Destructor */
00176     ~LocalSelectList();
00177 
00178     /** Static generator, for factory. */
00179     static MetaObject* new_LocalSelectList(MetaObject* superobject, const string& type);
00180 
00181     /** Creates required subobjects, and adds DoNothingListener to them
00182      * (this makes future operations faster). 
00183      * You MUST call this function (or setSelectedObj, setChoicesObj and
00184      * setMultiple) for things to work correctly.
00185      * @bug always sets the property access control on the "multiple" property
00186      *       to NoPropertyAccessControl::static_ 
00187      */
00188     virtual void initialize();
00189 
00190 
00191 };
00192 
00193 
00194 /** Remote version of SelectList. */
00195 class VOSGUI_API RemoteSelectList : public virtual SelectList, public virtual RemoteSelect
00196 {
00197 public:
00198 
00199     /** Constructor */
00200     RemoteSelectList(MetaObject* superobject);
00201 
00202     /** Destructor */
00203     virtual ~RemoteSelectList();
00204 
00205     /** Static generator, for factory. */
00206     static MetaObject* new_RemoteSelectList(MetaObject* superobject, const string& type);
00207 
00208 
00209 };
00210 
00211 } //namespace VOSGUI 
00212 
00213 #endif // #ifdef _GUI_SELECT_LIST_HH_
00214 

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