~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmith/wxwidgets/properties/wxsfontproperty.h

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

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: 10025 $
 
19
* $Id: wxsfontproperty.h 10025 2014-11-06 09:23:37Z jenslody $
 
20
* $HeadURL: http://svn.code.sf.net/p/codeblocks/code/branches/release-16.xx/src/plugins/contrib/wxSmith/wxwidgets/properties/wxsfontproperty.h $
 
21
*/
 
22
 
 
23
#ifndef WXSFONTPROPERTY_H
 
24
#define WXSFONTPROPERTY_H
 
25
 
 
26
#include "../../properties/wxsproperties.h"
 
27
#include "../wxscodercontext.h"
 
28
 
 
29
/** \brief Structure holding font configuration */
 
30
struct wxsFontData
 
31
{
 
32
    long Size;
 
33
    wxFontStyle Style;
 
34
    wxFontWeight Weight;
 
35
    bool Underlined;
 
36
    wxFontFamily Family;
 
37
    wxArrayString Faces;
 
38
    wxString Encoding;
 
39
    wxString SysFont;
 
40
    double RelativeSize;
 
41
 
 
42
    bool IsDefault : 1;
 
43
    bool HasSize : 1;
 
44
    bool HasStyle : 1;
 
45
    bool HasWeight : 1;
 
46
    bool HasUnderlined : 1;
 
47
    bool HasFamily : 1;
 
48
    bool HasEncoding : 1;
 
49
    bool HasSysFont : 1;
 
50
    bool HasRelativeSize : 1;
 
51
 
 
52
    /** \brief Function building font from font data */
 
53
    wxFont BuildFont();
 
54
 
 
55
    /** \brief Function generating code which will build font object with specified name
 
56
     * \return Code building font or empty string if font is default
 
57
     */
 
58
    wxString BuildFontCode(const wxString& FontName,wxsCoderContext* Context);
 
59
 
 
60
    /** \brief Ctor - initializes all values to default ones */
 
61
    wxsFontData():
 
62
        Size(12),
 
63
        Style(wxFONTSTYLE_NORMAL),
 
64
        Weight(wxFONTWEIGHT_NORMAL),
 
65
        Underlined(false),
 
66
        Family(wxFONTFAMILY_DEFAULT),
 
67
        IsDefault(true),
 
68
        HasSize(false),
 
69
        HasStyle(false),
 
70
        HasWeight(false),
 
71
        HasUnderlined(false),
 
72
        HasFamily(false),
 
73
        HasEncoding(false),
 
74
        HasSysFont(false),
 
75
        HasRelativeSize(false)
 
76
    {}
 
77
 
 
78
};
 
79
 
 
80
/** \brief Property for editing font properties
 
81
 */
 
82
class wxsFontProperty: public wxsCustomEditorProperty
 
83
{
 
84
    public:
 
85
 
 
86
        /** \brief Ctor
 
87
         *  \param PGName       name of property in Property Grid
 
88
         *  \param DataName     name of property in data stuctures
 
89
         *  \param Offset       offset of wxsFontData structure (returned from wxsOFFSET macro)
 
90
         *  \param Priority     priority of this property
 
91
         */
 
92
        wxsFontProperty(
 
93
            const wxString& PGName,
 
94
            const wxString& DataName,
 
95
            long Offset,
 
96
            int Priority=100);
 
97
 
 
98
        /** \brief Returning type name */
 
99
        virtual const wxString GetTypeName() { return _T("wxFont"); }
 
100
 
 
101
        /** \brief Showing editor for this property */
 
102
        virtual bool ShowEditor(wxsPropertyContainer* Object);
 
103
 
 
104
    protected:
 
105
 
 
106
        virtual bool XmlRead(wxsPropertyContainer* Object,TiXmlElement* Element);
 
107
        virtual bool XmlWrite(wxsPropertyContainer* Object,TiXmlElement* Element);
 
108
        virtual bool PropStreamRead(wxsPropertyContainer* Object,wxsPropertyStream* Stream);
 
109
        virtual bool PropStreamWrite(wxsPropertyContainer* Object,wxsPropertyStream* Stream);
 
110
        virtual wxString GetStr(wxsPropertyContainer* Object);
 
111
 
 
112
    private:
 
113
 
 
114
        long Offset;
 
115
};
 
116
 
 
117
/** \addtogroup ext_properties_macros
 
118
 *  \{ */
 
119
 
 
120
/** \brief Macro automatically declaring font property
 
121
 *  \param ClassName name of class holding this property
 
122
 *  \param VarName name of wxsFontData variable inside class
 
123
 *  \param PGName name used in property grid
 
124
 *  \param DataName name used in Xml / Data Streams
 
125
 */
 
126
#define WXS_FONT(ClassName,VarName,PGName,DataName) \
 
127
    { static wxsFontProperty _Property(PGName,DataName,wxsOFFSET(ClassName,VarName)); \
 
128
      Property(_Property); }
 
129
 
 
130
/** \brief Macro automatically declaring font property
 
131
 *  \param ClassName name of class holding this property
 
132
 *  \param VarName name of wxsFontData variable inside class
 
133
 *  \param PGName name used in property grid
 
134
 *  \param DataName name used in Xml / Data Streams
 
135
 *  \param Priority priority of this property
 
136
 */
 
137
#define WXS_FONT_P(ClassName,VarName,PGName,DataName,Priority) \
 
138
    { static wxsFontProperty _Property(PGName,DataName,wxsOFFSET(ClassName,VarName),Priority); \
 
139
      Property(_Property); }
 
140
 
 
141
/** \} */
 
142
 
 
143
 
 
144
#endif