~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/plugins/astyle/astyleconfigdlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
4
4
 *
5
 
 * $Revision: 4909 $
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 $
 
5
 * $Revision: 5778 $
 
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 $
8
8
 */
9
9
 
10
10
#include <sdk.h>
27
27
#endif
28
28
 
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)
37
41
END_EVENT_TABLE()
57
61
 
58
62
  switch (style)
59
63
  {
60
 
    case aspsAnsi:
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);
63
 
      break;
64
 
 
 
64
#define AS_ALLMAN "\
 
65
int Foo(bool isBar)\n\
 
66
{\n\
 
67
    if (isBar)\n\
 
68
    {\n\
 
69
        bar();\n\
 
70
        return 1;\n\
 
71
    }\n\
 
72
    else\n\
 
73
        return 0;\n\
 
74
}"
 
75
    case aspsAllman:
 
76
      sample = _T(AS_ALLMAN);
 
77
      XRCCTRL(*this, "rbAllman", wxRadioButton)->SetValue(true);
 
78
      break;
 
79
#undef AS_ALLMAN
 
80
#define AS_JAVA "\
 
81
int Foo(bool isBar) {\n\
 
82
    if (isBar) {\n\
 
83
        bar();\n\
 
84
        return 1;\n\
 
85
    } else\n\
 
86
        return 0;\n\
 
87
}"
 
88
    case aspsJava:
 
89
      sample = _T(AS_JAVA);
 
90
      XRCCTRL(*this, "rbJava", wxRadioButton)->SetValue(true);
 
91
      break;
 
92
#undef AS_JAVA
 
93
#define AS_KR "\
 
94
int Foo(bool isBar)\n\
 
95
{\n\
 
96
    if (isBar) {\n\
 
97
        bar();\n\
 
98
        return 1;\n\
 
99
    } else\n\
 
100
        return 0;\n\
 
101
}"
65
102
    case aspsKr:
66
 
      sample = _T("namespace foospace {\n    int Foo() {\n        if (isBar) {\n            bar();\n            return 1;\n        } else\n            return 0;\n    }\n}");
 
103
      sample = _T(AS_KR);
67
104
      XRCCTRL(*this, "rbKr", wxRadioButton)->SetValue(true);
68
105
      break;
69
 
 
 
106
#undef AS_KR
 
107
#define AS_STROUSTRUP "\
 
108
int Foo(bool isBar)\n\
 
109
{\n\
 
110
    if (isBar) {\n\
 
111
        bar();\n\
 
112
        return 1;\n\
 
113
    } else\n\
 
114
        return 0;\n\
 
115
}"
 
116
    case aspsStroustrup:
 
117
      sample = _T(AS_STROUSTRUP);
 
118
      XRCCTRL(*this, "rbStroustrup", wxRadioButton)->SetValue(true);
 
119
      break;
 
120
#undef AS_STROUSTRUP
 
121
#define AS_WHITESMITH "\
 
122
int Foo(bool isBar)\n\
 
123
    {\n\
 
124
    if (isBar)\n\
 
125
        {\n\
 
126
        bar();\n\
 
127
        return 1;\n\
 
128
        }\n\
 
129
    else\n\
 
130
        return 0;\n\
 
131
    }"
 
132
    case aspsWhitesmith:
 
133
      sample = _T(AS_WHITESMITH);
 
134
      XRCCTRL(*this, "rbWhitesmith", wxRadioButton)->SetValue(true);
 
135
      break;
 
136
#undef AS_WHITESMITH
 
137
#define AS_BANNER "\
 
138
int Foo(bool isBar) {\n\
 
139
    if (isBar) {\n\
 
140
        bar();\n\
 
141
        return 1;\n\
 
142
        }\n\
 
143
    else\n\
 
144
        return 0;\n\
 
145
    }"
 
146
    case aspsBanner:
 
147
      sample = _T(AS_BANNER);
 
148
      XRCCTRL(*this, "rbBanner", wxRadioButton)->SetValue(true);
 
149
      break;
 
150
#undef AS_BANNER
 
151
#define AS_GNU "\
 
152
int Foo(bool isBar)\n\
 
153
{\n\
 
154
  if (isBar)\n\
 
155
    {\n\
 
156
      bar();\n\
 
157
      return 1;\n\
 
158
    }\n\
 
159
  else\n\
 
160
    return 0;\n\
 
161
}"
 
162
    case aspsGnu:
 
163
      sample = _T(AS_GNU);
 
164
      XRCCTRL(*this, "rbGNU", wxRadioButton)->SetValue(true);
 
165
      break;
 
166
#undef AS_GNU
 
167
#define AS_LINUX "\
 
168
int Foo(bool isBar)\n\
 
169
{\n\
 
170
        if (isBar) {\n\
 
171
                bar();\n\
 
172
                return 1;\n\
 
173
        } else\n\
 
174
                return 0;\n\
 
175
}"
70
176
    case aspsLinux:
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);
73
179
      break;
74
 
 
75
 
    case aspsGnu:
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);
78
 
      break;
79
 
 
80
 
    case aspsJava:
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);
83
 
      break;
84
 
 
 
180
#undef AS_LINUX
 
181
#define AS_HORSTMANN "\
 
182
int Foo(bool isBar)\n\
 
183
{  if (isBar)\n\
 
184
   {  bar();\n\
 
185
      return 1;\n\
 
186
   }\n\
 
187
   else\n\
 
188
      return 0;\n\
 
189
}"
 
190
    case aspsHorstmann:
 
191
      sample = _T(AS_HORSTMANN);
 
192
      XRCCTRL(*this, "rbHorstmann", wxRadioButton)->SetValue(true);
 
193
      break;
 
194
#undef AS_HORSTMANN
85
195
    default:
86
196
      XRCCTRL(*this, "rbCustom", wxRadioButton)->SetValue(true);
87
197
      break;
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);
122
233
 
123
234
void AstyleConfigDlg::OnStyleChange(wxCommandEvent& event)
124
235
{
125
 
  if (event.GetId() == XRCID("rbAnsi"))
126
 
    SetStyle(aspsAnsi);
 
236
  if (event.GetId() == XRCID("rbAllman"))
 
237
    SetStyle(aspsAllman);
 
238
  else if (event.GetId() == XRCID("rbJava"))
 
239
    SetStyle(aspsJava);
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"))
 
249
    SetStyle(aspsGnu);
129
250
  else if (event.GetId() == XRCID("rbLinux"))
130
251
    SetStyle(aspsLinux);
131
 
  else if (event.GetId() == XRCID("rbGNU"))
132
 
    SetStyle(aspsGnu);
133
 
  else if (event.GetId() == XRCID("rbJava"))
134
 
    SetStyle(aspsJava);
 
252
  else if (event.GetId() == XRCID("rbHorstmann"))
 
253
    SetStyle(aspsHorstmann);
135
254
  else if (event.GetId() == XRCID("rbCustom"))
136
255
    SetStyle(aspsCustom);
137
256
}
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"));
205
325
  int style = 0;
206
326
 
207
 
  if (XRCCTRL(*this, "rbAnsi", wxRadioButton)->GetValue())
208
 
    style = 0;
 
327
  if (XRCCTRL(*this, "rbAllman", wxRadioButton)->GetValue())
 
328
    style = aspsAllman;
 
329
  else if (XRCCTRL(*this, "rbJava", wxRadioButton)->GetValue())
 
330
    style = aspsJava;
209
331
  else if (XRCCTRL(*this, "rbKr", wxRadioButton)->GetValue())
210
 
    style = 1;
 
332
    style = aspsKr;
 
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())
 
338
    style = aspsBanner;
 
339
  else if (XRCCTRL(*this, "rbGNU", wxRadioButton)->GetValue())
 
340
    style = aspsGnu;
211
341
  else if (XRCCTRL(*this, "rbLinux", wxRadioButton)->GetValue())
212
 
    style = 2;
213
 
  else if (XRCCTRL(*this, "rbGNU", wxRadioButton)->GetValue())
214
 
    style = 3;
215
 
  else if (XRCCTRL(*this, "rbJava", wxRadioButton)->GetValue())
216
 
    style = 4;
 
342
    style = aspsLinux;
 
343
  else if (XRCCTRL(*this, "rbHorstmann", wxRadioButton)->GetValue())
 
344
    style = aspsHorstmann;
217
345
  else if (XRCCTRL(*this, "rbCustom", wxRadioButton)->GetValue())
218
 
    style = 5;
 
346
    style = aspsCustom;
219
347
 
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());