forked from alpha0010/ClangLib
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathclangccsettingsdlg.cpp
467 lines (399 loc) · 25.3 KB
/
clangccsettingsdlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
/*
* This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
* http://www.gnu.org/licenses/gpl-3.0.html
*
* $Revision: 10473 $
* $Id: ClangCodeCompletionSettingsDlg.cpp 10473 2015-08-30 23:29:27Z ollydbg $
* $HeadURL: svn://svn.code.sf.net/p/codeblocks/code/trunk/src/plugins/codecompletion/ClangCodeCompletionSettingsDlg.cpp $
*/
#include <sdk.h>
#ifndef CB_PRECOMP
#include <wx/button.h>
#include <wx/checkbox.h>
#include <wx/colordlg.h>
#include <wx/combobox.h>
#include <wx/intl.h>
#include <wx/listbox.h>
#include <wx/radiobut.h>
#include <wx/regex.h>
#include <wx/slider.h>
#include <wx/spinctrl.h>
#include <wx/stattext.h>
#include <wx/treectrl.h>
#include <wx/xrc/xmlres.h>
#include <cbstyledtextctrl.h>
#include <configmanager.h>
#include <globals.h>
#include <logmanager.h>
#include <manager.h>
#endif
#include <vector>
#include <editpairdlg.h>
#include "cbcolourmanager.h"
#include "clangccsettingsdlg.h"
#include "clangplugin.h"
static const wxString g_SampleClasses =
_T("class A_class"
"{"
" public:"
" int someInt_A;"
" protected:"
" bool mSomeVar_A;"
" private:"
" char* mData_A;"
"};"
"class B_class"
"{"
" public:"
" int someInt_B;"
" protected:"
" bool mSomeVar_B;"
" private:"
" char* mData_B;"
"};"
"class C_class : public A_class"
"{"
" public:"
" int someInt_C;"
" protected:"
" bool mSomeVar_C;"
" private:"
" char* mData_C;"
"};"
"enum SomeEnum"
"{"
" optOne,"
" optTwo,"
" optThree"
"};"
"int x;"
"int y;"
"#define SOME_DEFINITION\n"
"#define SOME_DEFINITION_2\n\n");
BEGIN_EVENT_TABLE(ClangSettingsDlg, wxPanel)
EVT_UPDATE_UI(-1, ClangSettingsDlg::OnUpdateUI)
EVT_BUTTON(XRCID("btnColour"), ClangSettingsDlg::OnChooseColour)
EVT_COMMAND_SCROLL(XRCID("sldCCDelay"), ClangSettingsDlg::OnCCDelayScroll)
EVT_BUTTON(XRCID("btnDocBgColor"), ClangSettingsDlg::OnChooseColour)
EVT_BUTTON(XRCID("btnDocTextColor"), ClangSettingsDlg::OnChooseColour)
EVT_BUTTON(XRCID("btnDocLinkColor"), ClangSettingsDlg::OnChooseColour)
END_EVENT_TABLE()
ClangSettingsDlg::ClangSettingsDlg(wxWindow* parent, ClangPlugin* pPlugin /*, NativeParser* np, CodeCompletion* cc, DocumentationHelper* dh*/)
: m_pPlugin(pPlugin)
{
ConfigManager* cfg = Manager::Get()->GetConfigManager(CLANG_CONFIGMANAGER);
wxXmlResource::Get()->LoadPanel(this, parent, _T("dlgClangSettings"));
// -----------------------------------------------------------------------
// Handle all options that are being directly applied from config
// -----------------------------------------------------------------------
// Page "Code Completion"
//XRCCTRL(*this, "chkNoSemantic", wxCheckBox)->SetValue(!cfg->ReadBool(_T("/semantic_keywords"), false));
XRCCTRL(*this, "chkCodeCompletion", wxCheckBox)->SetValue(cfg->ReadBool(ClangCodeCompletion::SettingName, true));
XRCCTRL(*this, "chkAutoAddParentheses", wxCheckBox)->SetValue(cfg->ReadBool(_T("/auto_add_parentheses"), true));
XRCCTRL(*this, "chkDetectImpl", wxCheckBox)->SetValue(cfg->ReadBool(_T("/detect_implementation"),false));
XRCCTRL(*this, "chkAddDoxgenComment", wxCheckBox)->SetValue(cfg->ReadBool(_T("/add_doxgen_comment"), false));
//XRCCTRL(*this, "chkEnableHeaders", wxCheckBox)->SetValue(cfg->ReadBool(_T("/enable_headers"), true));
XRCCTRL(*this, "spnMaxMatches", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/max_matches"), 1024));
XRCCTRL(*this, "txtFillupChars", wxTextCtrl)->SetValue(cfg->Read(_T("/fillup_chars"), wxEmptyString));
XRCCTRL(*this, "sldCCDelay", wxSlider)->SetValue(cfg->ReadInt(_T("/cc_delay"), 300) / 100);
UpdateCCDelayLabel();
//XRCCTRL(*this, "chkKL_1", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set1"), true));
//XRCCTRL(*this, "chkKL_2", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set2"), true));
//XRCCTRL(*this, "chkKL_3", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set3"), false));
//XRCCTRL(*this, "chkKL_4", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set4"), false));
//XRCCTRL(*this, "chkKL_5", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set5"), false));
//XRCCTRL(*this, "chkKL_6", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set6"), false));
//XRCCTRL(*this, "chkKL_7", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set7"), false));
//XRCCTRL(*this, "chkKL_8", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set8"), false));
//XRCCTRL(*this, "chkKL_9", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set9"), false));
// Page "Diagnostics"
XRCCTRL(*this, "chkDiagnostics", wxCheckBox)->SetValue(cfg->ReadBool(_T("/diagnostics"), true));
XRCCTRL(*this, "chkInlineDiagnostics", wxCheckBox)->SetValue(cfg->ReadBool(_T("/diagnostics_show_inline"), true));
XRCCTRL(*this, "chkDiagnosticWarnings", wxCheckBox)->SetValue(cfg->ReadBool(_T("/diagnostics_show_warnings"), true));
XRCCTRL(*this, "chkDiagnosticErrors", wxCheckBox)->SetValue(cfg->ReadBool(_T("/diagnostics_show_errors"), true));
XRCCTRL(*this, "chkDiagnosticNotes", wxCheckBox)->SetValue(cfg->ReadBool(_T("/diagnostics_show_notes"), false));
XRCCTRL(*this, "chkClangOptionNoAttributes",wxCheckBox)->SetValue(cfg->ReadBool(_T("/cmdoption_wnoattributes"), false));
XRCCTRL(*this, "chkClangOptionExtraTokens", wxCheckBox)->SetValue(cfg->ReadBool(_T("/cmdoption_wextratokens"), false));
// Page "C / C++ parser"
// NOTE (Morten#1#): Keep this in sync with files in the XRC file (settings.xrc) and nativeparser.cpp
//XRCCTRL(*this, "spnThreadsNum", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/max_threads"), 1));
//XRCCTRL(*this, "spnThreadsNum", wxSpinCtrl)->Enable(false);
//XRCCTRL(*this, "spnParsersNum", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/max_parsers"), 5));
// Page "C / C++ parser (adv.)"
// NOTE (Morten#1#): Keep this in sync with files in the XRC file (settings.xrc) and parser.cpp
//XRCCTRL(*this, "txtCCFileExtHeader", wxTextCtrl)->SetValue(cfg->Read(_T("/header_ext"), _T("h,hpp,hxx,hh,h++,tcc,xpm")));
//XRCCTRL(*this, "chkCCFileExtEmpty", wxCheckBox)->SetValue(cfg->ReadBool(_T("/empty_ext"), true));
//XRCCTRL(*this, "txtCCFileExtSource", wxTextCtrl)->SetValue(cfg->Read(_T("/source_ext"), _T("c,cpp,cxx,cc,c++")));
// Page "Symbol browser"
//XRCCTRL(*this, "chkNoSB", wxCheckBox)->SetValue(!cfg->ReadBool(_T("/use_symbols_browser"), true));
//XRCCTRL(*this, "chkFloatCB", wxCheckBox)->SetValue(cfg->ReadBool(_T("/as_floating_window"), false));
//XRCCTRL(*this, "chkScopeFilter", wxCheckBox)->SetValue(cfg->ReadBool(_T("/scope_filter"), true));
// -----------------------------------------------------------------------
// Handle all options that are being handled by m_Parser
// -----------------------------------------------------------------------
#if 0
// Page "Code Completion"
XRCCTRL(*this, "chkUseSmartSense", wxCheckBox)->SetValue(!m_Parser.Options().useSmartSense);
XRCCTRL(*this, "chkWhileTyping", wxCheckBox)->SetValue(m_Parser.Options().whileTyping);
// Page "C / C++ parser"
XRCCTRL(*this, "chkLocals", wxCheckBox)->SetValue(m_Parser.Options().followLocalIncludes);
XRCCTRL(*this, "chkGlobals", wxCheckBox)->SetValue(m_Parser.Options().followGlobalIncludes);
XRCCTRL(*this, "chkPreprocessor", wxCheckBox)->SetValue(m_Parser.Options().wantPreprocessor);
XRCCTRL(*this, "chkComplexMacros", wxCheckBox)->SetValue(m_Parser.Options().parseComplexMacros);
XRCCTRL(*this, "chkPlatformCheck", wxCheckBox)->SetValue(m_Parser.Options().platformCheck);
XRCCTRL(*this, "rdoOneParserPerWorkspace", wxRadioButton)->SetValue( m_NativeParser->IsParserPerWorkspace());
XRCCTRL(*this, "rdoOneParserPerProject", wxRadioButton)->SetValue(!m_NativeParser->IsParserPerWorkspace());
// Page "Symbol browser"
XRCCTRL(*this, "chkInheritance", wxCheckBox)->SetValue(m_Parser.ClassBrowserOptions().showInheritance);
XRCCTRL(*this, "chkExpandNS", wxCheckBox)->SetValue(m_Parser.ClassBrowserOptions().expandNS);
XRCCTRL(*this, "chkTreeMembers", wxCheckBox)->SetValue(m_Parser.ClassBrowserOptions().treeMembers);
// Page Documentation
//CCTRL(*this, "chkDocumentation", wxCheckBox)->SetValue(m_Documentation->IsEnabled());
#endif
ColourManager *colours = Manager::Get()->GetColourManager();
XRCCTRL(*this, "btnDocBgColor", wxButton)->SetBackgroundColour(colours->GetColour(wxT("cc_docs_back")));
XRCCTRL(*this, "btnDocTextColor", wxButton)->SetBackgroundColour(colours->GetColour(wxT("cc_docs_fore")));
XRCCTRL(*this, "btnDocLinkColor", wxButton)->SetBackgroundColour(colours->GetColour(wxT("cc_docs_link")));
// Page "Advanced"
XRCCTRL(*this, "chkClangOptionParseAllComments", wxCheckBox)->SetValue(cfg->ReadBool(_T("/cmdoption_fparseallcomments"), false));
XRCCTRL(*this, "txtClangExtraOptions", wxTextCtrl)->SetValue(cfg->Read(_T("/cmdoption_extra"), wxEmptyString ));
// m_Parser.ParseBuffer(g_SampleClasses, true);
// m_Parser.BuildTree(*XRCCTRL(*this, "treeClasses", wxTreeCtrl));
}
ClangSettingsDlg::~ClangSettingsDlg()
{
}
void ClangSettingsDlg::OnApply()
{
ConfigManager* cfg = Manager::Get()->GetConfigManager(CLANG_CONFIGMANAGER);
// -----------------------------------------------------------------------
// Handle all options that are being directly applied / written from UI:
// -----------------------------------------------------------------------
// Page "Code Completion"
//cfg->Write(_T("/semantic_keywords"), (bool)!XRCCTRL(*this, "chkNoSemantic", wxCheckBox)->GetValue());
//cfg->Write(_T("/use_SmartSense"), (bool) XRCCTRL(*this, "chkUseSmartSense", wxCheckBox)->GetValue());
cfg->Write(ClangCodeCompletion::SettingName, (bool) XRCCTRL(*this, "chkCodeCompletion", wxCheckBox)->GetValue());
cfg->Write(_T("/while_typing"), (bool) XRCCTRL(*this, "chkWhileTyping", wxCheckBox)->GetValue());
//cfg->Write(_T("/auto_add_parentheses"), (bool) XRCCTRL(*this, "chkAutoAddParentheses", wxCheckBox)->GetValue());
//cfg->Write(_T("/detect_implementation"),(bool) XRCCTRL(*this, "chkDetectImpl", wxCheckBox)->GetValue());
//cfg->Write(_T("/add_doxgen_comment"), (bool) XRCCTRL(*this, "chkAddDoxgenComment", wxCheckBox)->GetValue());
//cfg->Write(_T("/enable_headers"), (bool) XRCCTRL(*this, "chkEnableHeaders", wxCheckBox)->GetValue());
cfg->Write(_T("/max_matches"), (int) XRCCTRL(*this, "spnMaxMatches", wxSpinCtrl)->GetValue());
cfg->Write(_T("/fillup_chars"), XRCCTRL(*this, "txtFillupChars", wxTextCtrl)->GetValue());
cfg->Write(_T("/cc_delay"), (int) XRCCTRL(*this, "sldCCDelay", wxSlider)->GetValue() * 100);
//cfg->Write(_T("/lexer_keywords_set1"), (bool) XRCCTRL(*this, "chkKL_1", wxCheckBox)->GetValue());
//cfg->Write(_T("/lexer_keywords_set2"), (bool) XRCCTRL(*this, "chkKL_2", wxCheckBox)->GetValue());
//cfg->Write(_T("/lexer_keywords_set3"), (bool) XRCCTRL(*this, "chkKL_3", wxCheckBox)->GetValue());
//cfg->Write(_T("/lexer_keywords_set4"), (bool) XRCCTRL(*this, "chkKL_4", wxCheckBox)->GetValue());
//cfg->Write(_T("/lexer_keywords_set5"), (bool) XRCCTRL(*this, "chkKL_5", wxCheckBox)->GetValue());
//cfg->Write(_T("/lexer_keywords_set6"), (bool) XRCCTRL(*this, "chkKL_6", wxCheckBox)->GetValue());
//cfg->Write(_T("/lexer_keywords_set7"), (bool) XRCCTRL(*this, "chkKL_7", wxCheckBox)->GetValue());
//cfg->Write(_T("/lexer_keywords_set8"), (bool) XRCCTRL(*this, "chkKL_8", wxCheckBox)->GetValue());
//cfg->Write(_T("/lexer_keywords_set9"), (bool) XRCCTRL(*this, "chkKL_9", wxCheckBox)->GetValue());
// Page "C / C++ parser"
//cfg->Write(_T("/parser_follow_local_includes"), (bool) XRCCTRL(*this, "chkLocals", wxCheckBox)->GetValue());
//cfg->Write(_T("/parser_follow_global_includes"), (bool) XRCCTRL(*this, "chkGlobals", wxCheckBox)->GetValue());
//cfg->Write(_T("/want_preprocessor"), (bool) XRCCTRL(*this, "chkPreprocessor", wxCheckBox)->GetValue());
//cfg->Write(_T("/parse_complex_macros"), (bool) XRCCTRL(*this, "chkComplexMacros", wxCheckBox)->GetValue());
//cfg->Write(_T("/platform_check"), (bool) XRCCTRL(*this, "chkPlatformCheck", wxCheckBox)->GetValue());
//cfg->Write(_T("/max_threads"), (int) XRCCTRL(*this, "spnThreadsNum", wxSpinCtrl)->GetValue());
//cfg->Write(_T("/parser_per_workspace"), (bool) XRCCTRL(*this, "rdoOneParserPerWorkspace", wxRadioButton)->GetValue());
//cfg->Write(_T("/max_parsers"), (int) XRCCTRL(*this, "spnParsersNum", wxSpinCtrl)->GetValue());
// Page "C / C++ parser (adv.)"
//cfg->Write(_T("/header_ext"), XRCCTRL(*this, "txtCCFileExtHeader", wxTextCtrl)->GetValue());
//cfg->Write(_T("/empty_ext"), (bool) XRCCTRL(*this, "chkCCFileExtEmpty", wxCheckBox)->GetValue());
//cfg->Write(_T("/source_ext"), XRCCTRL(*this, "txtCCFileExtSource", wxTextCtrl)->GetValue());
// Page "Symbol browser"
//cfg->Write(_T("/use_symbols_browser"), (bool)!XRCCTRL(*this, "chkNoSB", wxCheckBox)->GetValue());
//cfg->Write(_T("/browser_show_inheritance"), (bool) XRCCTRL(*this, "chkInheritance", wxCheckBox)->GetValue());
//cfg->Write(_T("/browser_expand_ns"), (bool) XRCCTRL(*this, "chkExpandNS", wxCheckBox)->GetValue());
//cfg->Write(_T("/as_floating_window"), (bool) XRCCTRL(*this, "chkFloatCB", wxCheckBox)->GetValue());
//cfg->Write(_T("/browser_tree_members"), (bool) XRCCTRL(*this, "chkTreeMembers", wxCheckBox)->GetValue());
//cfg->Write(_T("/scope_filter"), (bool) XRCCTRL(*this, "chkScopeFilter", wxCheckBox)->GetValue());
// Page "Diagnostics"
cfg->Write(_T("/diagnostics"), (bool) XRCCTRL(*this, "chkDiagnostics", wxCheckBox)->GetValue());
cfg->Write(_T("/diagnostics_show_inline"), (bool) XRCCTRL(*this, "chkInlineDiagnostics", wxCheckBox)->GetValue());
cfg->Write(_T("/diagnostics_show_warnings"),(bool) XRCCTRL(*this, "chkDiagnosticWarnings", wxCheckBox)->GetValue());
cfg->Write(_T("/diagnostics_show_errors"), (bool) XRCCTRL(*this, "chkDiagnosticErrors", wxCheckBox)->GetValue());
cfg->Write(_T("/diagnostics_show_notes"), (bool) XRCCTRL(*this, "chkDiagnosticNotes", wxCheckBox)->GetValue());
cfg->Write(_T("/cmdoption_wnoattributes"), (bool) XRCCTRL(*this, "chkClangOptionNoAttributes", wxCheckBox)->GetValue());
cfg->Write(_T("/cmdoption_wextratokens"), (bool) XRCCTRL(*this, "chkClangOptionExtraTokens", wxCheckBox)->GetValue());
// Page "Documentation"
//cfg->Write(_T("/use_documentation_helper"), (bool) XRCCTRL(*this, "chkDocumentation", wxCheckBox)->GetValue());
cfg->Write(_T("/documentation_helper_background_color"), (wxColour) XRCCTRL(*this, "btnDocBgColor", wxButton)->GetBackgroundColour());
cfg->Write(_T("/documentation_helper_text_color"), (wxColour) XRCCTRL(*this, "btnDocTextColor", wxButton)->GetBackgroundColour());
cfg->Write(_T("/documentation_helper_link_color"), (wxColour) XRCCTRL(*this, "btnDocLinkColor", wxButton)->GetBackgroundColour());
// Page "Advanced"
cfg->Write(_T("/cmdoption_fparseallcomments"), (bool) XRCCTRL(*this, "chkClangOptionParseAllComments", wxCheckBox)->GetValue());
cfg->Write(_T("/cmdoption_extra"), XRCCTRL(*this, "txtClangExtraOptions", wxTextCtrl)->GetValue());
// -----------------------------------------------------------------------
// Handle all options that are being be read by m_Parser.ReadOptions():
// -----------------------------------------------------------------------
#if 0
// Force parser to read its options that we write in the config
// Also don't forget to update the Parser option according UI!
m_Parser.ReadOptions();
// Page "Code Completion"
m_Parser.Options().useSmartSense = !XRCCTRL(*this, "chkUseSmartSense", wxCheckBox)->GetValue();
m_Parser.Options().whileTyping = XRCCTRL(*this, "chkWhileTyping", wxCheckBox)->GetValue();
// Page "C / C++ parser"
m_Parser.Options().followLocalIncludes = XRCCTRL(*this, "chkLocals", wxCheckBox)->GetValue();
m_Parser.Options().followGlobalIncludes = XRCCTRL(*this, "chkGlobals", wxCheckBox)->GetValue();
m_Parser.Options().wantPreprocessor = XRCCTRL(*this, "chkPreprocessor", wxCheckBox)->GetValue();
m_Parser.Options().parseComplexMacros = XRCCTRL(*this, "chkComplexMacros", wxCheckBox)->GetValue();
m_Parser.Options().platformCheck = XRCCTRL(*this, "chkPlatformCheck", wxCheckBox)->GetValue();
// Page "Symbol browser"
m_Parser.ClassBrowserOptions().showInheritance = XRCCTRL(*this, "chkInheritance", wxCheckBox)->GetValue();
m_Parser.ClassBrowserOptions().expandNS = XRCCTRL(*this, "chkExpandNS", wxCheckBox)->GetValue();
m_Parser.ClassBrowserOptions().treeMembers = XRCCTRL(*this, "chkTreeMembers", wxCheckBox)->GetValue();
// Page "Documentation"
m_Documentation->RereadOptions(cfg);
m_Parser.Options().storeDocumentation = XRCCTRL(*this, "chkDocumentation", wxCheckBox)->GetValue();
m_Documentation->SetEnabled( XRCCTRL(*this, "chkDocumentation", wxCheckBox)->GetValue() );
#endif
ColourManager *colours = Manager::Get()->GetColourManager();
wxColor colour = XRCCTRL(*this, "btnDocBgColor", wxButton)->GetBackgroundColour();
colours->SetColour(wxT("cc_docs_back"), colour);
colour = XRCCTRL(*this, "btnDocTextColor", wxButton)->GetBackgroundColour();
colours->SetColour(wxT("cc_docs_text"), colour);
colour = XRCCTRL(*this, "btnDocLinkColor", wxButton)->GetBackgroundColour();
colours->SetColour(wxT("cc_docs_link"), colour);
#if 0
// Now write the parser options and re-read them again to make sure they are up-to-date
m_Parser.WriteOptions();
m_NativeParser->RereadParserOptions();
m_Documentation->WriteOptions(cfg);
m_CodeCompletion->RereadOptions();
#endif
m_pPlugin->UpdateComponents();
}
void ClangSettingsDlg::OnChooseColour(wxCommandEvent& event)
{
wxColourData data;
wxWindow* sender = FindWindowById(event.GetId());
data.SetColour(sender->GetBackgroundColour());
wxColourDialog dlg(this, &data);
PlaceWindow(&dlg);
if (dlg.ShowModal() == wxID_OK)
{
wxColour colour = dlg.GetColourData().GetColour();
sender->SetBackgroundColour(colour);
}
}
void ClangSettingsDlg::OnCCDelayScroll(cb_unused wxScrollEvent& event)
{
UpdateCCDelayLabel();
}
void ClangSettingsDlg::OnUpdateUI(cb_unused wxUpdateUIEvent& event)
{
// ccmanager's config
ConfigManager* ccmcfg = Manager::Get()->GetConfigManager(CLANG_CONFIGMANAGER);
bool en = ccmcfg->ReadBool(ClangCodeCompletion::SettingName, true);
bool aap = XRCCTRL(*this, "chkAutoAddParentheses", wxCheckBox)->GetValue();
// Page "Code Completion"
//XRCCTRL(*this, "chkUseSmartSense", wxCheckBox)->Enable(en);
XRCCTRL(*this, "chkWhileTyping", wxCheckBox)->Enable(en);
XRCCTRL(*this, "chkAutoAddParentheses", wxCheckBox)->Enable(en);
XRCCTRL(*this, "chkDetectImpl", wxCheckBox)->Enable(en && aap);
XRCCTRL(*this, "chkAddDoxgenComment", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkEnableHeaders", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkNoSemantic", wxCheckBox)->Enable(en);
XRCCTRL(*this, "lblMaxMatches", wxStaticText)->Enable(en);
XRCCTRL(*this, "spnMaxMatches", wxSpinCtrl)->Enable(en);
XRCCTRL(*this, "lblFillupChars", wxStaticText)->Enable(en);
XRCCTRL(*this, "txtFillupChars", wxTextCtrl)->Enable(en);
XRCCTRL(*this, "sldCCDelay", wxSlider)->Enable(en);
// keyword sets
//XRCCTRL(*this, "chkKL_1", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkKL_2", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkKL_3", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkKL_4", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkKL_5", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkKL_6", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkKL_7", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkKL_8", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkKL_9", wxCheckBox)->Enable(en);
// Page "C / C++ parser"
//XRCCTRL(*this, "chkLocals", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkGlobals", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkPreprocessor", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkComplexMacros", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkPlatformCheck", wxCheckBox)->Enable(en);
//en = XRCCTRL(*this, "rdoOneParserPerWorkspace", wxRadioButton)->GetValue();
//XRCCTRL(*this, "lblParsersNum", wxStaticText)->Enable(!en);
//XRCCTRL(*this, "spnParsersNum", wxSpinCtrl)->Enable(!en);
// Page "C / C++ parser (adv.)"
// FIXME (ollydbg#1#01/07/15): should code_completion option affect our parser's behaviour?
//en = ccmcfg->ReadBool(_T("/code_completion"), true);
//XRCCTRL(*this, "txtCCFileExtHeader", wxTextCtrl)->Enable(en);
//XRCCTRL(*this, "chkCCFileExtEmpty", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "txtCCFileExtSource", wxTextCtrl)->Enable(en);
// Page "Symbol browser"
//en = !XRCCTRL(*this, "chkNoSB", wxCheckBox)->GetValue();
//XRCCTRL(*this, "chkInheritance", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkExpandNS", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkFloatCB", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkTreeMembers", wxCheckBox)->Enable(en);
//XRCCTRL(*this, "chkScopeFilter", wxCheckBox)->Enable(en);
// Page "Documentation"
//en = XRCCTRL(*this, "chkDocumentation", wxCheckBox)->GetValue();
//XRCCTRL(*this, "btnDocBgColor", wxButton)->Enable(en);
//XRCCTRL(*this, "btnDocTextColor", wxButton)->Enable(en);
//XRCCTRL(*this, "btnDocLinkColor", wxButton)->Enable(en);
}
void ClangSettingsDlg::UpdateCCDelayLabel()
{
int position = XRCCTRL(*this, "sldCCDelay", wxSlider)->GetValue();
wxString lbl;
if (position >= 10)
lbl.Printf(_("%d.%d sec"), position / 10, position % 10);
else
lbl.Printf(_("%d ms"), position * 100);
XRCCTRL(*this, "lblDelay", wxStaticText)->SetLabel(lbl);
}
bool ClangSettingsDlg::ValidateReplacementToken(wxString& from, wxString& to)
{
// cut off any leading / trailing spaces
from.Trim(true).Trim(false);
to.Trim(true).Trim(false);
if (to.IsEmpty())
{
// Allow removing a token, but ask the user if that's OK.
if (cbMessageBox( _("This setup will replace the token with an empty string.\n"
"This will *remove* the token and probably break CC for some cases.\n"
"Do you really want to *remove* that token?"),
_("Confirmation"),
wxICON_QUESTION | wxYES_NO ) == wxID_YES)
{
return true;
}
}
else if (to.Contains(from))
{
cbMessageBox(_("Replacement token cannot contain search token.\n"
"This would cause an infinite loop otherwise."),
_("Error"), wxICON_ERROR);
return false;
}
wxRegEx re(_T("[A-Za-z_]+[0-9]*[A-Za-z_]*"));
if (!re.Matches(from))
{
cbMessageBox(_("Search token can only contain alphanumeric characters and underscores."),
_("Error"), wxICON_ERROR);
return false;
}
if (!re.Matches(to))
{
// Allow replacing with special characters only if the user says it's ok.
if (cbMessageBox( _("You are replacing a token with a string that contains\n"
"characters other than alphanumeric and underscores.\n"
"This could make parsing the file impossible.\n"
"Are you sure?"),
_("Confirmation"),
wxICON_QUESTION | wxYES_NO ) != wxID_YES)
{
return false;
}
}
return true;
}