~ubuntu-branches/ubuntu/wily/ginkgocadx/wily-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/wx/propgrid/propdev.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Tille
  • Date: 2011-05-02 08:09:26 UTC
  • Revision ID: james.westby@ubuntu.com-20110502080926-bql5wep49c7hg91t
Tags: upstream-2.4.1.1
ImportĀ upstreamĀ versionĀ 2.4.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////////////////////
 
2
// Name:        propdev.h
 
3
// Purpose:     wxPropertyGrid Internal Header
 
4
// Author:      Jaakko Salli
 
5
// Modified by:
 
6
// Created:     ?-?-2004
 
7
// RCS-ID:      $Id:
 
8
// Copyright:   (c) Jaakko Salli
 
9
// Licence:     wxWindows license
 
10
/////////////////////////////////////////////////////////////////////////////
 
11
 
 
12
#ifndef _WX_PROPGRID_PROPDEV_H_
 
13
#define _WX_PROPGRID_PROPDEV_H_
 
14
 
 
15
// -----------------------------------------------------------------------
 
16
 
 
17
 
 
18
class wxArrayEditorDialog;
 
19
 
 
20
// -----------------------------------------------------------------------
 
21
 
 
22
// These are intuitive substitutes for base property classes.
 
23
typedef wxPGProperty                wxBasePropertyClass;
 
24
typedef wxPGProperty                wxBaseParentPropertyClass;
 
25
 
 
26
// -----------------------------------------------------------------------
 
27
 
 
28
#ifndef SWIG
 
29
 
 
30
// This is required for sharing common global variables.
 
31
// TODO: Automatic locking mechanism?
 
32
class EXTAPI wxPGGlobalVarsClass
 
33
{
 
34
public:
 
35
 
 
36
    wxPGGlobalVarsClass();
 
37
    ~wxPGGlobalVarsClass();
 
38
 
 
39
    wxString            m_pDefaultImageWildcard; // Used by advprops, but here to make things easier.
 
40
 
 
41
    //wxArrayPtrVoid      m_arrEditorClasses; // List of editor class instances.
 
42
    wxPGHashMapS2P      m_mapEditorClasses; // Map of editor class instances (keys are name string).
 
43
 
 
44
#if wxUSE_VALIDATORS
 
45
    wxArrayPtrVoid      m_arrValidators; // These wxValidators need to be freed
 
46
#endif
 
47
 
 
48
    //wxPGHashMapS2P      m_dictValueType; // Valuename -> Value type object instance.
 
49
 
 
50
/*#if wxPG_VALUETYPE_IS_STRING
 
51
    wxPGHashMapS2P      m_dictValueTypeByClass; // VTClassname -> Value type object instance.
 
52
#endif*/
 
53
 
 
54
    wxPGHashMapS2P      m_dictPropertyClassInfo; // PropertyName -> ClassInfo
 
55
 
 
56
    wxPGChoices*        m_fontFamilyChoices;
 
57
 
 
58
    wxPGCellRenderer*   m_defaultRenderer;  // Replace with your own to affect all properties using
 
59
                                            // default renderer.
 
60
 
 
61
    wxPGVariantDataClassInfo wxVariantClassInfo_long;  // These are for fast variant type comparison
 
62
    wxPGVariantDataClassInfo wxVariantClassInfo_string;
 
63
    wxPGVariantDataClassInfo wxVariantClassInfo_double;
 
64
    wxPGVariantDataClassInfo wxVariantClassInfo_bool;
 
65
    wxPGVariantDataClassInfo wxVariantClassInfo_arrstring;
 
66
    wxPGVariantDataClassInfo wxVariantClassInfo_wxobject;
 
67
    wxPGVariantDataClassInfo wxVariantClassInfo_list;
 
68
#if wxCHECK_VERSION(2,8,0)
 
69
    wxPGVariantDataClassInfo wxVariantClassInfo_wxColour;
 
70
#endif
 
71
#if wxUSE_DATETIME
 
72
    wxPGVariantDataClassInfo wxVariantClassInfo_datetime;
 
73
#endif
 
74
 
 
75
    wxPGChoices         m_boolChoices;
 
76
 
 
77
#if wxVARIANT_REFCOUNTED
 
78
    wxVariant           m_vEmptyString;
 
79
    wxVariant           m_vZero;
 
80
    wxVariant           m_vMinusOne;
 
81
    wxVariant           m_vTrue;
 
82
    wxVariant           m_vFalse;
 
83
#endif
 
84
 
 
85
    // Cached constant strings
 
86
    wxPGCachedString    m_strDefaultValue;
 
87
    wxPGCachedString    m_strMin;
 
88
    wxPGCachedString    m_strMax;
 
89
    wxPGCachedString    m_strUnits;
 
90
    wxPGCachedString    m_strInlineHelp;
 
91
 
 
92
    bool                m_autoGetTranslation; // If true then some things are automatically translated
 
93
 
 
94
    int                 m_offline; // > 0 if errors cannot or should not be shown in statusbar etc.
 
95
 
 
96
    int                 m_extraStyle;  // global extra style
 
97
 
 
98
#ifdef __WXDEBUG__
 
99
    int                 m_warnings;
 
100
#endif
 
101
 
 
102
    int HasExtraStyle( int style ) const { return (m_extraStyle & style); }
 
103
 
 
104
/*#if wxUSE_THREADS
 
105
    wxCriticalSection   m_critSect; // To allow different property grids to be addressed from different threads
 
106
#endif*/
 
107
};
 
108
 
 
109
#if wxCHECK_VERSION(2,9,0)
 
110
 
 
111
#define wxPGIsVariantType(VARIANT, T) \
 
112
    ((VARIANT).GetData() && typeid(*(VARIANT).GetData()) == *wxPGGlobalVars->wxVariantClassInfo_##T)
 
113
 
 
114
#define wxPGIsVariantClassInfo(CLASSINFO, T) \
 
115
    (*CLASSINFO == *wxPGGlobalVars->wxVariantClassInfo_##T)
 
116
 
 
117
#else
 
118
 
 
119
#define wxPGIsVariantType(VARIANT, T) \
 
120
    ((VARIANT).GetData() && wxPGVariantDataGetClassInfo((VARIANT).GetData()) == wxPGGlobalVars->wxVariantClassInfo_##T)
 
121
 
 
122
#define wxPGIsVariantClassInfo(CLASSINFO, T) \
 
123
    (CLASSINFO == wxPGGlobalVars->wxVariantClassInfo_##T)
 
124
 
 
125
#endif
 
126
 
 
127
#if wxVARIANT_REFCOUNTED
 
128
    #define wxPGVariant_EmptyString     (wxPGGlobalVars->m_vEmptyString)
 
129
    #define wxPGVariant_Zero            (wxPGGlobalVars->m_vZero)
 
130
    #define wxPGVariant_MinusOne        (wxPGGlobalVars->m_vMinusOne)
 
131
    #define wxPGVariant_True            (wxPGGlobalVars->m_vTrue)
 
132
    #define wxPGVariant_False           (wxPGGlobalVars->m_vFalse)
 
133
#else
 
134
    #define wxPGVariant_EmptyString     wxEmptyString
 
135
    #define wxPGVariant_Zero            ((long)0)
 
136
    #define wxPGVariant_MinusOne        ((long)-1)
 
137
    #define wxPGVariant_True            true
 
138
    #define wxPGVariant_False           false
 
139
#endif
 
140
 
 
141
#define wxPGVariant_Bool(A)     (A?wxPGVariant_True:wxPGVariant_False)
 
142
 
 
143
 
 
144
#if wxVARIANT_REFCOUNTED
 
145
    #define wxPGVariantAssign(A, B) A = B
 
146
#else
 
147
//
 
148
// Does A = B, so that the operation should not
 
149
// fail due to dataclass mismatch with typename
 
150
// match.
 
151
    #define wxPGVariantAssign(A, B) \
 
152
        { \
 
153
            A.MakeNull(); \
 
154
            A = B; \
 
155
        }
 
156
 
 
157
#endif
 
158
 
 
159
 
 
160
extern EXTAPI wxPGGlobalVarsClass* wxPGGlobalVars;
 
161
 
 
162
#endif
 
163
 
 
164
// -----------------------------------------------------------------------
 
165
 
 
166
 
 
167
#ifndef SWIG
 
168
 
 
169
//
 
170
// Tokenizer macros.
 
171
// NOTE: I have made two versions - worse ones (performance and consistency
 
172
//   wise) use wxStringTokenizer and better ones (may have unfound bugs)
 
173
//   use custom code.
 
174
//
 
175
 
 
176
#include <wx/tokenzr.h>
 
177
 
 
178
// TOKENIZER1 can be done with wxStringTokenizer
 
179
#define WX_PG_TOKENIZER1_BEGIN(WXSTRING,DELIMITER) \
 
180
    wxStringTokenizer tkz(WXSTRING,DELIMITER,wxTOKEN_RET_EMPTY); \
 
181
    while ( tkz.HasMoreTokens() ) \
 
182
    { \
 
183
        wxString token = tkz.GetNextToken(); \
 
184
        token.Trim(true); \
 
185
        token.Trim(false);
 
186
 
 
187
#define WX_PG_TOKENIZER1_END() \
 
188
    }
 
189
 
 
190
 
 
191
//
 
192
// 2nd version: tokens are surrounded by DELIMITERs (for example, C-style strings).
 
193
// TOKENIZER2 must use custom code (a class) for full compliancy
 
194
// with " surrounded strings with \" inside.
 
195
//
 
196
// class implementation is in propgrid.cpp
 
197
//
 
198
 
 
199
class EXTAPI wxPGStringTokenizer
 
200
{
 
201
public:
 
202
    wxPGStringTokenizer( const wxString& str, wxChar delimeter );
 
203
    ~wxPGStringTokenizer();
 
204
 
 
205
    bool HasMoreTokens(); // not const so we can do some stuff in it
 
206
    wxString GetNextToken();
 
207
 
 
208
protected:
 
209
#ifndef SWIG
 
210
 
 
211
    const wxString*             m_str;
 
212
    wxString::const_iterator    m_curPos;
 
213
    wxString                    m_readyToken;
 
214
    wxUniChar                   m_delimeter;
 
215
#endif
 
216
};
 
217
 
 
218
#define WX_PG_TOKENIZER2_BEGIN(WXSTRING,DELIMITER) \
 
219
    wxPGStringTokenizer tkz(WXSTRING,DELIMITER); \
 
220
    while ( tkz.HasMoreTokens() ) \
 
221
    { \
 
222
        wxString token = tkz.GetNextToken();
 
223
 
 
224
#define WX_PG_TOKENIZER2_END() \
 
225
    }
 
226
 
 
227
#endif
 
228
 
 
229
#ifndef __wxPG_SOURCE_FILE__
 
230
    // Reduce compile time, but still include in user app
 
231
    #include "props.h"
 
232
#endif
 
233
 
 
234
// -----------------------------------------------------------------------
 
235
 
 
236
#if !wxCHECK_VERSION(2,8,0)
 
237
 
 
238
// There is no wxString::EndsWith() in wxWidgets 2.6.
 
239
bool wxPG_String_EndsWith(const wxString& str, const wxChar *suffix, wxString *rest = NULL);
 
240
 
 
241
#else
 
242
 
 
243
inline bool wxPG_String_EndsWith(const wxString& str, const wxChar *suffix, wxString *rest = NULL)
 
244
{
 
245
    return str.EndsWith(suffix, rest);
 
246
}
 
247
 
 
248
#endif
 
249
 
 
250
// -----------------------------------------------------------------------
 
251
 
 
252
#endif // _WX_PROPGRID_PROPDEV_H_