1
/** \file wxsrichtextstylelistbox.cpp
3
* This file is part of wxSmith plugin for Code::Blocks Studio
4
* Copyright (C) 2010 Gary Harris
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.
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.
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/>.
21
#include <wx/richtext/richtextstyles.h>
22
#include "wxsrichtextstylelistbox.h"
26
wxsRegisterItem<wxsRichTextStyleListBox> Reg(_T("RichTextStyleListBox"),wxsTWidget,_T("Standard"),155);
28
WXS_ST_BEGIN(wxsRichTextStyleListBoxStyles,_T(""))
29
WXS_ST_CATEGORY("wxsRichTextStyleListBox")
36
* \param Data wxsItemResData* The control's resource data.
39
wxsRichTextStyleListBox::wxsRichTextStyleListBox(wxsItemResData* Data):
44
wxsRichTextStyleListBoxStyles),
45
m_sControl(wxEmptyString),
46
m_sStyleSheet(wxEmptyString),
47
m_iStyleType(wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH),
48
m_bApplyOnSelection(false)
51
/*! \brief Create the initial control.
56
void wxsRichTextStyleListBox::OnBuildCreatingCode()
58
switch ( GetLanguage() )
62
AddHeader(_T("<wx/richtext/richtextstyles.h>"),GetInfo().ClassName,hfInPCH);
64
Codef(_T("%C(%W, %I, %P, %S, %T);\n"));
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()));
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()));
78
// wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH is the default value.
80
case wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL:
81
Codef(_T("%ASetStyleType(%s);\n"), wxT("wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL"));
83
case wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER:
84
Codef(_T("%ASetStyleType(%s);\n"), wxT("wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER"));
86
case wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST:
87
Codef(_T("%ASetStyleType(%s);\n"), wxT("wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST"));
91
if(m_bApplyOnSelection){
92
Codef( _T("%ASetApplyOnSelection(%b);\n"), m_bApplyOnSelection);
95
BuildSetupWindowCode();
101
wxsCodeMarks::Unknown(_T("wxsRichTextStyleListBox::OnBuildCreatingCode"),GetLanguage());
106
/*! \brief Build the control preview.
108
* \param parent wxWindow* The parent window.
109
* \param flags long The control flags.
110
* \return wxObject* The constructed control.
113
wxObject* wxsRichTextStyleListBox::OnBuildPreview(wxWindow* Parent,long Flags)
115
wxRichTextStyleListBox *Preview = new wxRichTextStyleListBox(Parent, GetId(), Pos(Parent), Size(Parent), Style());
117
// if(!m_sControl.IsEmpty()){
118
// Preview->SetRichTextCtrl(m_sControl);
120
// if(!m_sStyleSheet.IsEmpty()){
121
// Preview->SetStyleSheet(m_sStyleSheet);
122
// Preview->UpdateStyles();
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);
130
case wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER:
131
Preview->SetStyleType(wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER);
133
case wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST:
134
Preview->SetStyleType(wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST);
137
if(m_bApplyOnSelection){
138
Preview->SetApplyOnSelection(m_bApplyOnSelection);
141
return SetupWindow(Preview,Flags);
144
/*! \brief Enumerate the control's properties.
146
* \param flags long The control flags.
150
void wxsRichTextStyleListBox::OnEnumWidgetProperties(long Flags)
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};
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);