2
2
* This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3
3
* http://www.gnu.org/licenses/gpl-3.0.html
6
* $Id: astyleconfigdlg.cpp 4909 2008-02-27 13:15:26Z mortenmacfly $
7
* $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/plugins/astyle/astyleconfigdlg.cpp $
6
* $Id: astyleconfigdlg.cpp 5778 2009-09-13 21:32:50Z jenslody $
7
* $HeadURL: svn+ssh://jenslody@svn.berlios.de/svnroot/repos/codeblocks/trunk/src/plugins/astyle/astyleconfigdlg.cpp $
29
29
BEGIN_EVENT_TABLE(AstyleConfigDlg, wxPanel)
30
EVT_RADIOBUTTON(XRCID("rbAnsi"), AstyleConfigDlg::OnStyleChange)
30
EVT_RADIOBUTTON(XRCID("rbAllman"), AstyleConfigDlg::OnStyleChange)
31
EVT_RADIOBUTTON(XRCID("rbJava"), AstyleConfigDlg::OnStyleChange)
31
32
EVT_RADIOBUTTON(XRCID("rbKr"), AstyleConfigDlg::OnStyleChange)
33
EVT_RADIOBUTTON(XRCID("rbStroustrup"), AstyleConfigDlg::OnStyleChange)
34
EVT_RADIOBUTTON(XRCID("rbWhitesmith"), AstyleConfigDlg::OnStyleChange)
35
EVT_RADIOBUTTON(XRCID("rbBanner"), AstyleConfigDlg::OnStyleChange)
36
EVT_RADIOBUTTON(XRCID("rbGNU"), AstyleConfigDlg::OnStyleChange)
32
37
EVT_RADIOBUTTON(XRCID("rbLinux"), AstyleConfigDlg::OnStyleChange)
33
EVT_RADIOBUTTON(XRCID("rbGNU"), AstyleConfigDlg::OnStyleChange)
34
EVT_RADIOBUTTON(XRCID("rbJava"), AstyleConfigDlg::OnStyleChange)
38
EVT_RADIOBUTTON(XRCID("rbHorstmann"), AstyleConfigDlg::OnStyleChange)
35
39
EVT_RADIOBUTTON(XRCID("rbCustom"), AstyleConfigDlg::OnStyleChange)
36
40
EVT_BUTTON(XRCID("Preview"), AstyleConfigDlg::OnPreview)
61
sample = _T("namespace foospace\n{\n int Foo()\n {\n if (isBar)\n {\n bar();\n return 1;\n }\n else\n return 0;\n }\n}");
62
XRCCTRL(*this, "rbAnsi", wxRadioButton)->SetValue(true);
65
int Foo(bool isBar)\n\
76
sample = _T(AS_ALLMAN);
77
XRCCTRL(*this, "rbAllman", wxRadioButton)->SetValue(true);
81
int Foo(bool isBar) {\n\
90
XRCCTRL(*this, "rbJava", wxRadioButton)->SetValue(true);
94
int Foo(bool isBar)\n\
66
sample = _T("namespace foospace {\n int Foo() {\n if (isBar) {\n bar();\n return 1;\n } else\n return 0;\n }\n}");
67
104
XRCCTRL(*this, "rbKr", wxRadioButton)->SetValue(true);
107
#define AS_STROUSTRUP "\
108
int Foo(bool isBar)\n\
117
sample = _T(AS_STROUSTRUP);
118
XRCCTRL(*this, "rbStroustrup", wxRadioButton)->SetValue(true);
121
#define AS_WHITESMITH "\
122
int Foo(bool isBar)\n\
133
sample = _T(AS_WHITESMITH);
134
XRCCTRL(*this, "rbWhitesmith", wxRadioButton)->SetValue(true);
138
int Foo(bool isBar) {\n\
147
sample = _T(AS_BANNER);
148
XRCCTRL(*this, "rbBanner", wxRadioButton)->SetValue(true);
152
int Foo(bool isBar)\n\
164
XRCCTRL(*this, "rbGNU", wxRadioButton)->SetValue(true);
168
int Foo(bool isBar)\n\
71
sample = _T("namespace foospace\n{\n int Foo()\n {\n if (isBar) {\n bar();\n return 1;\n } else\n return 0;\n }\n}");
177
sample = _T(AS_LINUX);
72
178
XRCCTRL(*this, "rbLinux", wxRadioButton)->SetValue(true);
76
sample = _T("namespace foospace\n {\n int Foo()\n {\n if (isBar)\n {\n bar();\n return 1;\n }\n else\n return 0;\n }\n }");
77
XRCCTRL(*this, "rbGNU", wxRadioButton)->SetValue(true);
81
sample = _T("namespace foospace {\n int Foo() {\n if (isBar) {\n bar();\n return 1;\n } else\n return 0;\n }\n}");
82
XRCCTRL(*this, "rbJava", wxRadioButton)->SetValue(true);
181
#define AS_HORSTMANN "\
182
int Foo(bool isBar)\n\
191
sample = _T(AS_HORSTMANN);
192
XRCCTRL(*this, "rbHorstmann", wxRadioButton)->SetValue(true);
86
196
XRCCTRL(*this, "rbCustom", wxRadioButton)->SetValue(true);
106
216
XRCCTRL(*this, "chkIndentNamespaces", wxCheckBox)->Enable(!en);
107
217
XRCCTRL(*this, "chkIndentLabels", wxCheckBox)->Enable(!en);
108
218
XRCCTRL(*this, "chkIndentPreprocessor", wxCheckBox)->Enable(!en);
109
XRCCTRL(*this, "cmbBreakType", wxComboBox)->Enable(!en);
219
XRCCTRL(*this, "cmbBracketFormatMode", wxComboBox)->Enable(!en);
220
XRCCTRL(*this, "cmbPointerAlign", wxComboBox)->Enable(!en);
110
221
XRCCTRL(*this, "chkBreakClosing", wxCheckBox)->Enable(!en);
111
222
XRCCTRL(*this, "chkBreakBlocks", wxCheckBox)->Enable(!en);
112
223
XRCCTRL(*this, "chkBreakElseIfs", wxCheckBox)->Enable(!en);
123
234
void AstyleConfigDlg::OnStyleChange(wxCommandEvent& event)
125
if (event.GetId() == XRCID("rbAnsi"))
236
if (event.GetId() == XRCID("rbAllman"))
237
SetStyle(aspsAllman);
238
else if (event.GetId() == XRCID("rbJava"))
127
240
else if (event.GetId() == XRCID("rbKr"))
128
241
SetStyle(aspsKr);
242
else if (event.GetId() == XRCID("rbStroustrup"))
243
SetStyle(aspsStroustrup);
244
else if (event.GetId() == XRCID("rbWhitesmith"))
245
SetStyle(aspsWhitesmith);
246
else if (event.GetId() == XRCID("rbBanner"))
247
SetStyle(aspsBanner);
248
else if (event.GetId() == XRCID("rbGNU"))
129
250
else if (event.GetId() == XRCID("rbLinux"))
130
251
SetStyle(aspsLinux);
131
else if (event.GetId() == XRCID("rbGNU"))
133
else if (event.GetId() == XRCID("rbJava"))
252
else if (event.GetId() == XRCID("rbHorstmann"))
253
SetStyle(aspsHorstmann);
135
254
else if (event.GetId() == XRCID("rbCustom"))
136
255
SetStyle(aspsCustom);
183
302
XRCCTRL(*this, "chkIndentNamespaces", wxCheckBox)->SetValue(cfg->ReadBool(_T("/indent_namespaces"), false));
184
303
XRCCTRL(*this, "chkIndentLabels", wxCheckBox)->SetValue(cfg->ReadBool(_T("/indent_labels"), false));
185
304
XRCCTRL(*this, "chkIndentPreprocessor", wxCheckBox)->SetValue(cfg->ReadBool(_T("/indent_preprocessor"), false));
186
XRCCTRL(*this, "cmbBreakType", wxComboBox)->SetValue(cfg->Read(_T("/break_type"), _T("None")));
305
XRCCTRL(*this, "cmbBracketFormatMode", wxComboBox)->SetValue(cfg->Read(_T("/bracket_format_mode"), _T("None")));
306
XRCCTRL(*this, "cmbPointerAlign", wxComboBox)->SetValue(cfg->Read(_T("/pointer_align"), _T("None")));
187
307
XRCCTRL(*this, "chkBreakClosing", wxCheckBox)->SetValue(cfg->ReadBool(_T("/break_closing"), false));
188
308
XRCCTRL(*this, "chkBreakBlocks", wxCheckBox)->SetValue(cfg->ReadBool(_T("/break_blocks"), false));
189
309
XRCCTRL(*this, "chkBreakElseIfs", wxCheckBox)->SetValue(cfg->ReadBool(_T("/break_elseifs"), false));
204
324
ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("astyle"));
207
if (XRCCTRL(*this, "rbAnsi", wxRadioButton)->GetValue())
327
if (XRCCTRL(*this, "rbAllman", wxRadioButton)->GetValue())
329
else if (XRCCTRL(*this, "rbJava", wxRadioButton)->GetValue())
209
331
else if (XRCCTRL(*this, "rbKr", wxRadioButton)->GetValue())
333
else if (XRCCTRL(*this, "rbStroustrup", wxRadioButton)->GetValue())
334
style = aspsStroustrup;
335
else if (XRCCTRL(*this, "rbWhitesmith", wxRadioButton)->GetValue())
336
style = aspsWhitesmith;
337
else if (XRCCTRL(*this, "rbBanner", wxRadioButton)->GetValue())
339
else if (XRCCTRL(*this, "rbGNU", wxRadioButton)->GetValue())
211
341
else if (XRCCTRL(*this, "rbLinux", wxRadioButton)->GetValue())
213
else if (XRCCTRL(*this, "rbGNU", wxRadioButton)->GetValue())
215
else if (XRCCTRL(*this, "rbJava", wxRadioButton)->GetValue())
343
else if (XRCCTRL(*this, "rbHorstmann", wxRadioButton)->GetValue())
344
style = aspsHorstmann;
217
345
else if (XRCCTRL(*this, "rbCustom", wxRadioButton)->GetValue())
220
348
cfg->Write(_T("/style"), style);
221
349
cfg->Write(_T("/indentation"), XRCCTRL(*this, "spnIndentation", wxSpinCtrl)->GetValue());
229
357
cfg->Write(_T("/indent_namespaces"), XRCCTRL(*this, "chkIndentNamespaces", wxCheckBox)->GetValue());
230
358
cfg->Write(_T("/indent_labels"), XRCCTRL(*this, "chkIndentLabels", wxCheckBox)->GetValue());
231
359
cfg->Write(_T("/indent_preprocessor"), XRCCTRL(*this, "chkIndentPreprocessor", wxCheckBox)->GetValue());
232
cfg->Write(_T("/break_type"), XRCCTRL(*this, "cmbBreakType", wxComboBox)->GetValue());
360
cfg->Write(_T("/bracket_format_mode"), XRCCTRL(*this, "cmbBracketFormatMode", wxComboBox)->GetValue());
361
cfg->Write(_T("/pointer_align"), XRCCTRL(*this, "cmbPointerAlign", wxComboBox)->GetValue());
233
362
cfg->Write(_T("/break_closing"), XRCCTRL(*this, "chkBreakClosing", wxCheckBox)->GetValue());
234
363
cfg->Write(_T("/break_blocks"), XRCCTRL(*this, "chkBreakBlocks", wxCheckBox)->GetValue());
235
364
cfg->Write(_T("/break_elseifs"), XRCCTRL(*this, "chkBreakElseIfs", wxCheckBox)->GetValue());