~ubuntu-branches/ubuntu/hardy/codeblocks/hardy-backports

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmith/properties/wxsenumproperty.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* This file is part of wxSmith plugin for Code::Blocks Studio
 
3
* Copyright (C) 2006-2007  Bartlomiej Swiecki
 
4
*
 
5
* wxSmith is free software; you can redistribute it and/or modify
 
6
* it under the terms of the GNU General Public License as published by
 
7
* the Free Software Foundation; either version 3 of the License, or
 
8
* (at your option) any later version.
 
9
*
 
10
* wxSmith is distributed in the hope that it will be useful,
 
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
13
* GNU General Public License for more details.
 
14
*
 
15
* You should have received a copy of the GNU General Public License
 
16
* along with wxSmith. If not, see <http://www.gnu.org/licenses/>.
 
17
*
 
18
* $Revision: 4850 $
 
19
* $Id: wxsenumproperty.h 4850 2008-01-29 21:45:49Z byo $
 
20
* $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/plugins/contrib/wxSmith/properties/wxsenumproperty.h $
 
21
*/
 
22
 
 
23
#ifndef WXSENUMPROPERTY_H
 
24
#define WXSENUMPROPERTY_H
 
25
 
 
26
#include "wxsproperty.h"
 
27
 
 
28
/** \brief Property with enumerated values
 
29
 *
 
30
 * Enum property works almost the same as long property but it uses
 
31
 * predefined values from given set.
 
32
 * Note that this class is abstract and should be used as base class for others.
 
33
 */
 
34
class wxsEnumProperty: public wxsProperty
 
35
{
 
36
        public:
 
37
 
 
38
        /** \brief Ctor
 
39
         *  \param PGName           name of property used in Property Grid
 
40
         *  \param DataName         name of property used in data structures
 
41
         *  \param Offset           offset of long integer holding enumerated value (taken from wxsOFFSET macro)
 
42
         *  \param Values           array of long integer values which can be enumerated
 
43
         *  \param Names            array of names used for items in Values array, ending with 0
 
44
         *  \param UpdateEnteries   posting true here notifies, that arrays may change while property is shown in property grid
 
45
         *  \param Default          defaut value applied on read errors
 
46
         *  \param UseNamesInXml    if true, names will be stored inside xml node instead of values
 
47
         *  \param Priority         priority of this property
 
48
         */
 
49
                wxsEnumProperty(
 
50
            const wxString& PGName,
 
51
            const wxString& DataName,
 
52
            long Offset,
 
53
            const long* Values,
 
54
            const wxChar** Names,
 
55
            bool UpdateEnteries=false,
 
56
            long Default=0,
 
57
            bool UseNamesInXml=false,
 
58
            int Priority=100);
 
59
 
 
60
    protected:
 
61
 
 
62
        virtual const wxString GetTypeName() { return _T(""); }
 
63
        virtual void PGCreate(wxsPropertyContainer* Object,wxPropertyGridManager* Grid,wxPGId Parent);
 
64
        virtual bool PGRead(wxsPropertyContainer* Object,wxPropertyGridManager* Grid, wxPGId Id, long Index);
 
65
        virtual bool PGWrite(wxsPropertyContainer* Object,wxPropertyGridManager* Grid, wxPGId Id, long Index);
 
66
        virtual bool XmlRead(wxsPropertyContainer* Object,TiXmlElement* Element);
 
67
        virtual bool XmlWrite(wxsPropertyContainer* Object,TiXmlElement* Element);
 
68
        virtual bool PropStreamRead(wxsPropertyContainer* Object,wxsPropertyStream* Stream);
 
69
        virtual bool PropStreamWrite(wxsPropertyContainer* Object,wxsPropertyStream* Stream);
 
70
 
 
71
        private:
 
72
        long Offset;
 
73
        long Default;
 
74
        bool UpdateEnteries;
 
75
        const long* Values;
 
76
        const wxChar** Names;
 
77
        bool UseNamesInXml;
 
78
};
 
79
 
 
80
/** \addtogroup properties_macros
 
81
 *  \{ */
 
82
 
 
83
/** \brief Macro automatically declaring enum property
 
84
 *  \param ClassName name of class holding this property
 
85
 *  \param VarName name of variable of type long inside class
 
86
 *  \param PGName name used in property grid
 
87
 *  \param DataName name used in Xml / Data Streams
 
88
 *  \param Values global array of long values for enums
 
89
 *  \param Names global array of names (stored as wxChar*) for enums, ended with 0 entry
 
90
 *  \param Default value applied on read errors / validation failures
 
91
 */
 
92
#define WXS_ENUM(ClassName,VarName,PGName,DataName,Values,Names,Default) \
 
93
    { static wxsEnumProperty _Property(PGName,DataName,wxsOFFSET(ClassName,VarName),Values,Names,false,Default,true); \
 
94
      Property(_Property); }
 
95
 
 
96
/** \brief Macro automatically declaring enum property with custom priority
 
97
 *  \param ClassName name of class holding this property
 
98
 *  \param VarName name of variable of type long inside class
 
99
 *  \param PGName name used in property grid
 
100
 *  \param DataName name used in Xml / Data Streams
 
101
 *  \param Values global array of long values for enums
 
102
 *  \param Names global array of names (stored as wxChar*) for enums, ended with 0 entry
 
103
 *  \param Default value applied on read errors / validation failures
 
104
 *  \param Priority priority of this property
 
105
 */
 
106
#define WXS_ENUM_P(ClassName,VarName,PGName,DataName,Values,Names,Default,Priority) \
 
107
    { static wxsEnumProperty _Property(PGName,DataName,wxsOFFSET(ClassName,VarName),Values,Names,false,Default,true,Priority); \
 
108
      Property(_Property); }
 
109
 
 
110
/** \} */
 
111
 
 
112
#endif