~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmith/wxwidgets/defitems/wxsrichtextstylelistbox.cpp

  • 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
/** \file wxsrichtextstylelistbox.cpp
 
2
*
 
3
* This file is part of wxSmith plugin for Code::Blocks Studio
 
4
* Copyright (C) 2010 Gary Harris
 
5
*
 
6
* wxSmith is free software; you can redistribute it and/or modify
 
7
* it under the terms of the GNU General Public License as published by
 
8
* the Free Software Foundation; either version 3 of the License, or
 
9
* (at your option) any later version.
 
10
*
 
11
* wxSmith is distributed in the hope that it will be useful,
 
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
14
* GNU General Public License for more details.
 
15
*
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with wxSmith. If not, see <http://www.gnu.org/licenses/>.
 
18
*
 
19
*/
 
20
 
 
21
#include <wx/richtext/richtextstyles.h>
 
22
#include "wxsrichtextstylelistbox.h"
 
23
 
 
24
namespace
 
25
{
 
26
    wxsRegisterItem<wxsRichTextStyleListBox> Reg(_T("RichTextStyleListBox"),wxsTWidget,_T("Standard"),155);
 
27
 
 
28
    WXS_ST_BEGIN(wxsRichTextStyleListBoxStyles,_T(""))
 
29
        WXS_ST_CATEGORY("wxsRichTextStyleListBox")
 
30
        WXS_ST_DEFAULTS()
 
31
    WXS_ST_END()
 
32
}
 
33
 
 
34
/*! \brief Ctor
 
35
 *
 
36
 * \param Data wxsItemResData*    The control's resource data.
 
37
 *
 
38
 */
 
39
wxsRichTextStyleListBox::wxsRichTextStyleListBox(wxsItemResData* Data):
 
40
    wxsWidget(
 
41
        Data,
 
42
        &Reg.Info,
 
43
        NULL,
 
44
        wxsRichTextStyleListBoxStyles),
 
45
    m_sControl(wxEmptyString),
 
46
    m_sStyleSheet(wxEmptyString),
 
47
    m_iStyleType(wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH),
 
48
    m_bApplyOnSelection(false)
 
49
{}
 
50
 
 
51
/*! \brief Create the initial control.
 
52
 *
 
53
 * \return void
 
54
 *
 
55
 */
 
56
void wxsRichTextStyleListBox::OnBuildCreatingCode()
 
57
{
 
58
    switch ( GetLanguage() )
 
59
    {
 
60
        case wxsCPP:
 
61
        {
 
62
            AddHeader(_T("<wx/richtext/richtextstyles.h>"),GetInfo().ClassName,hfInPCH);
 
63
 
 
64
            Codef(_T("%C(%W, %I, %P, %S, %T);\n"));
 
65
 
 
66
            wxString sVarName = GetVarName();
 
67
            // Add the control and stylesheet setting calls at the bottom of the code, hopefully after the control and stylesheet have been declared.
 
68
            if(!m_sControl.IsEmpty()){
 
69
                AddEventCode(wxString::Format(_("// Set the wxRichtTextCtrl for %s. \n"), sVarName.wx_str()));
 
70
                AddEventCode(wxString::Format(wxT("%s->SetRichTextCtrl(%s);\n"), sVarName.wx_str(), m_sControl.wx_str()));
 
71
            }
 
72
            if(!m_sStyleSheet.IsEmpty()){
 
73
                AddEventCode(wxString::Format(_("// Set the wxRichTextStyleSheet for %s. \n"), sVarName.wx_str()));
 
74
                AddEventCode(wxString::Format(wxT("%s->SetStyleSheet(%s);\n"), sVarName.wx_str(), m_sStyleSheet.wx_str()));
 
75
                AddEventCode(wxString::Format(wxT("%s->UpdateStyles();\n"), sVarName.wx_str()));
 
76
            }
 
77
 
 
78
            // wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH is the default value.
 
79
            switch(m_iStyleType){
 
80
                case wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL:
 
81
                    Codef(_T("%ASetStyleType(%s);\n"), wxT("wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL"));
 
82
                    break;
 
83
                case wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER:
 
84
                    Codef(_T("%ASetStyleType(%s);\n"), wxT("wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER"));
 
85
                    break;
 
86
                case wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST:
 
87
                    Codef(_T("%ASetStyleType(%s);\n"), wxT("wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST"));
 
88
                    break;
 
89
            }
 
90
            // Default is false.
 
91
            if(m_bApplyOnSelection){
 
92
                Codef( _T("%ASetApplyOnSelection(%b);\n"), m_bApplyOnSelection);
 
93
            }
 
94
 
 
95
            BuildSetupWindowCode();
 
96
            return;
 
97
        }
 
98
 
 
99
        default:
 
100
        {
 
101
            wxsCodeMarks::Unknown(_T("wxsRichTextStyleListBox::OnBuildCreatingCode"),GetLanguage());
 
102
        }
 
103
    }
 
104
}
 
105
 
 
106
/*! \brief    Build the control preview.
 
107
 *
 
108
 * \param parent wxWindow*    The parent window.
 
109
 * \param flags long                The control flags.
 
110
 * \return wxObject*                 The constructed control.
 
111
 *
 
112
 */
 
113
wxObject* wxsRichTextStyleListBox::OnBuildPreview(wxWindow* Parent,long Flags)
 
114
{
 
115
    wxRichTextStyleListBox *Preview = new wxRichTextStyleListBox(Parent, GetId(), Pos(Parent), Size(Parent), Style());
 
116
 
 
117
//    if(!m_sControl.IsEmpty()){
 
118
//        Preview->SetRichTextCtrl(m_sControl);
 
119
//    }
 
120
//    if(!m_sStyleSheet.IsEmpty()){
 
121
//        Preview->SetStyleSheet(m_sStyleSheet);
 
122
//        Preview->UpdateStyles();
 
123
//    }
 
124
 
 
125
    // wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH is the default value.
 
126
    switch(m_iStyleType){
 
127
        case wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL:
 
128
            Preview->SetStyleType(wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL);
 
129
            break;
 
130
        case wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER:
 
131
            Preview->SetStyleType(wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER);
 
132
            break;
 
133
        case wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST:
 
134
            Preview->SetStyleType(wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST);
 
135
            break;
 
136
    }
 
137
    if(m_bApplyOnSelection){
 
138
        Preview->SetApplyOnSelection(m_bApplyOnSelection);
 
139
    }
 
140
 
 
141
    return SetupWindow(Preview,Flags);
 
142
}
 
143
 
 
144
/*! \brief Enumerate the control's properties.
 
145
 *
 
146
 * \param flags long    The control flags.
 
147
 * \return void
 
148
 *
 
149
 */
 
150
void wxsRichTextStyleListBox::OnEnumWidgetProperties(long Flags)
 
151
{
 
152
    static const long StyleStates[] = {wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL,
 
153
                                                                wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER,
 
154
                                                                wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST,
 
155
                                                                wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH};
 
156
    static const wxChar* StyleNames[]  = {wxT("wxRICHTEXT_STYLE_ALL"), wxT("wxRICHTEXT_STYLE_CHARACTER"), wxT("wxRICHTEXT_STYLE_LIST"), wxT("wxRICHTEXT_STYLE_PARAGRAPH"), NULL};
 
157
 
 
158
    WXS_SHORT_STRING(wxsRichTextStyleListBox, m_sControl, _("Control"), _T("control"), wxEmptyString, true)
 
159
    WXS_SHORT_STRING(wxsRichTextStyleListBox, m_sStyleSheet, _("Style Sheet"), _T("style_sheet"), wxEmptyString, true)
 
160
    WXS_ENUM(wxsRichTextStyleListBox, m_iStyleType, _("Style Type"), _T("style_type"), StyleStates, StyleNames, wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH)
 
161
    WXS_BOOL(wxsRichTextStyleListBox, m_bApplyOnSelection, _("Apply On Selection"), _T("apply_on_selection"), false);
 
162
}