type.h

Go to the documentation of this file.
00001 
00005 /* Copyright, 2000 Nevrax Ltd.
00006  *
00007  * This file is part of NEVRAX NEL.
00008  * NEVRAX NEL is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012 
00013  * NEVRAX NEL is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * General Public License for more details.
00017 
00018  * You should have received a copy of the GNU General Public License
00019  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00021  * MA 02111-1307, USA.
00022  */
00023 
00024 #ifndef NL_TYPE_H
00025 #define NL_TYPE_H
00026 
00027 #include "nel/misc/types_nl.h"
00028 #include "nel/georges/u_type.h"
00029 #include "nel/georges/u_form_elm.h"
00030 #include "header.h"
00031 
00032 namespace NLGEORGES
00033 {
00034 
00035 class UFormElm;
00036 
00040 class CType : public UType
00041 {
00042     friend class CFormLoader;
00043 public:
00044 
00045     CType ();
00046     virtual ~CType ();
00047 
00048     // ** UI
00049     enum TUI
00050     {
00051         Edit,               // Default, for all types
00052         EditSpin,           // For number types
00053         NonEditableCombo,   // For all types
00054         FileBrowser,        // Browse file
00055         BigEdit,            // Edit a huge text
00056         ColorEdit,          // Edit a color
00057         IconWidget,         // Draw an icon
00058         UITypeCount
00059     };
00060 
00061     // Is a UI compatible with a type ?
00062     static bool uiCompatible (TType type, TUI ui);
00063 
00064     // ** IO functions
00065     void                write (xmlDocPtr doc, bool georges4CVS) const;
00066 
00067     // Header
00068     CFileHeader         Header;
00069 
00070     // Type of the type
00071     UType::TType        Type;
00072 
00073     // Type fo user interface
00074     TUI                 UIType;
00075 
00076     // Default value
00077     std::string         Default;
00078 
00079     // Min value
00080     std::string         Min;
00081 
00082     // Max value
00083     std::string         Max;
00084 
00085     // Increment step value
00086     std::string         Increment;
00087 
00088     // Evaluate a node
00089     bool                getValue (std::string &result, const class CForm *form, const class CFormElmAtom *node, const class CFormDfn &parentDfn,
00090                                     uint parentIndex, UFormElm::TEval evaluate, uint32 *where, uint32 round, const char *formName) const;
00091 
00092     // Definitions
00093     class CDefinition
00094     {
00095     public:
00096         // Label of the definition
00097         std::string     Label;
00098 
00099         // Value of the definition
00100         std::string     Value;
00101     };
00102 
00103     // Array of definition
00104     std::vector<CDefinition>    Definitions;
00105 
00106     // Get the type names
00107     static const char *getTypeName (UType::TType type);
00108     static const char *getUIName (TUI type);
00109 
00110     // From UType
00111     virtual TType               getType () const;
00112     virtual const std::string   &getDefault () const;
00113     virtual const std::string   &getMin () const;
00114     virtual const std::string   &getMax () const;
00115     virtual const std::string   &getIncrement () const;
00116     virtual uint                getNumDefinition () const;
00117     virtual bool                getDefinition (uint index, std::string &label, std::string &value) const;
00118     virtual const std::string   &getComment () const;
00119     virtual void                getDependencies (std::set<std::string> &dependencies) const;
00120 
00121 private:
00122 
00123     // Error handling
00124     virtual void        warning (bool exception, const char *formName, const char *formFilename, const char *function, const char *format, ... ) const;
00125     virtual void        warning2 (bool exception, const char *function, const char *format, ... ) const;
00126 
00127     // Type names
00128     static const char   *TypeNames[];
00129     static const char   *UITypeNames[];
00130 
00131     // CFormLoader call it
00132     void                read (xmlNodePtr root);
00133 
00134 };
00135 
00136 } // NLGEORGES
00137 
00138 #endif // NL_TYPE_H

Generated on Thu Jan 7 08:26:32 2010 for NeL by  doxygen 1.6.1