Code::Blocks  SVN r11506
ccoptionsdlg.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3  * http://www.gnu.org/licenses/gpl-3.0.html
4  *
5  * $Revision: 11194 $
6  * $Id: ccoptionsdlg.cpp 11194 2017-10-10 05:23:33Z fuscated $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/plugins/codecompletion/ccoptionsdlg.cpp $
8  */
9 
10 #include <sdk.h>
11 
12 #ifndef CB_PRECOMP
13  #include <wx/button.h>
14  #include <wx/checkbox.h>
15  #include <wx/colordlg.h>
16  #include <wx/combobox.h>
17  #include <wx/intl.h>
18  #include <wx/listbox.h>
19  #include <wx/radiobut.h>
20  #include <wx/regex.h>
21  #include <wx/slider.h>
22  #include <wx/spinctrl.h>
23  #include <wx/stattext.h>
24  #include <wx/treectrl.h>
25  #include <wx/xrc/xmlres.h>
26 
27  #include <cbstyledtextctrl.h>
28  #include <configmanager.h>
29  #include <globals.h>
30  #include <logmanager.h>
31  #include <manager.h>
32 #endif
33 
34 #include <editpairdlg.h>
35 
36 #include "cbcolourmanager.h"
37 #include "ccoptionsdlg.h"
38 #include "codecompletion.h"
39 #include "doxygen_parser.h" // For DocumentationHelper
40 
41 static const wxString g_SampleClasses =
42  _T("class A_class"
43  "{"
44  " public:"
45  " int someInt_A;"
46  " protected:"
47  " bool mSomeVar_A;"
48  " private:"
49  " char* mData_A;"
50  "};"
51  "class B_class"
52  "{"
53  " public:"
54  " int someInt_B;"
55  " protected:"
56  " bool mSomeVar_B;"
57  " private:"
58  " char* mData_B;"
59  "};"
60  "class C_class : public A_class"
61  "{"
62  " public:"
63  " int someInt_C;"
64  " protected:"
65  " bool mSomeVar_C;"
66  " private:"
67  " char* mData_C;"
68  "};"
69  "enum SomeEnum"
70  "{"
71  " optOne,"
72  " optTwo,"
73  " optThree"
74  "};"
75  "int x;"
76  "int y;"
77  "#define SOME_DEFINITION\n"
78  "#define SOME_DEFINITION_2\n\n");
79 
80 BEGIN_EVENT_TABLE(CCOptionsDlg, wxPanel)
81  EVT_UPDATE_UI(-1, CCOptionsDlg::OnUpdateUI)
82  EVT_BUTTON(XRCID("btnColour"), CCOptionsDlg::OnChooseColour)
83  EVT_COMMAND_SCROLL(XRCID("sldCCDelay"), CCOptionsDlg::OnCCDelayScroll)
84  EVT_BUTTON(XRCID("btnDocBgColor"), CCOptionsDlg::OnChooseColour)
85  EVT_BUTTON(XRCID("btnDocTextColor"), CCOptionsDlg::OnChooseColour)
86  EVT_BUTTON(XRCID("btnDocLinkColor"), CCOptionsDlg::OnChooseColour)
87 END_EVENT_TABLE()
88 
90  m_NativeParser(np),
91  m_CodeCompletion(cc),
92  m_Parser(np->GetParser()),
93  m_Documentation(dh)
94 {
95  ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("code_completion"));
96 
97  wxXmlResource::Get()->LoadPanel(this, parent, _T("dlgCCSettings"));
98 
99  // -----------------------------------------------------------------------
100  // Handle all options that are being directly applied from config
101  // -----------------------------------------------------------------------
102 
103  // Page "Code Completion"
104  XRCCTRL(*this, "chkNoSemantic", wxCheckBox)->SetValue(!cfg->ReadBool(_T("/semantic_keywords"), false));
105  XRCCTRL(*this, "chkAutoAddParentheses", wxCheckBox)->SetValue(cfg->ReadBool(_T("/auto_add_parentheses"), true));
106  XRCCTRL(*this, "chkDetectImpl", wxCheckBox)->SetValue(cfg->ReadBool(_T("/detect_implementation"),false));
107  XRCCTRL(*this, "chkAddDoxgenComment", wxCheckBox)->SetValue(cfg->ReadBool(_T("/add_doxgen_comment"), false));
108  XRCCTRL(*this, "chkEnableHeaders", wxCheckBox)->SetValue(cfg->ReadBool(_T("/enable_headers"), true));
109  XRCCTRL(*this, "spnMaxMatches", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/max_matches"), 16384));
110  XRCCTRL(*this, "txtFillupChars", wxTextCtrl)->SetValue(cfg->Read(_T("/fillup_chars"), wxEmptyString));
111  XRCCTRL(*this, "sldCCDelay", wxSlider)->SetValue(cfg->ReadInt(_T("/cc_delay"), 300) / 100);
112  UpdateCCDelayLabel();
113  XRCCTRL(*this, "chkKL_1", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set1"), true));
114  XRCCTRL(*this, "chkKL_2", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set2"), true));
115  XRCCTRL(*this, "chkKL_3", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set3"), false));
116  XRCCTRL(*this, "chkKL_4", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set4"), false));
117  XRCCTRL(*this, "chkKL_5", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set5"), false));
118  XRCCTRL(*this, "chkKL_6", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set6"), false));
119  XRCCTRL(*this, "chkKL_7", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set7"), false));
120  XRCCTRL(*this, "chkKL_8", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set8"), false));
121  XRCCTRL(*this, "chkKL_9", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set9"), false));
122 
123  // Page "C / C++ parser"
124  // NOTE (Morten#1#): Keep this in sync with files in the XRC file (settings.xrc) and nativeparser.cpp
125  XRCCTRL(*this, "spnThreadsNum", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/max_threads"), 1));
126  XRCCTRL(*this, "spnThreadsNum", wxSpinCtrl)->Enable(false);
127  XRCCTRL(*this, "spnParsersNum", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/max_parsers"), 5));
128 
129  // Page "C / C++ parser (adv.)"
130  // NOTE (Morten#1#): Keep this in sync with files in the XRC file (settings.xrc) and parser.cpp
131  XRCCTRL(*this, "txtCCFileExtHeader", wxTextCtrl)->SetValue(cfg->Read(_T("/header_ext"), _T("h,hpp,hxx,hh,h++,tcc,xpm")));
132  XRCCTRL(*this, "chkCCFileExtEmpty", wxCheckBox)->SetValue(cfg->ReadBool(_T("/empty_ext"), true));
133  XRCCTRL(*this, "txtCCFileExtSource", wxTextCtrl)->SetValue(cfg->Read(_T("/source_ext"), _T("c,cpp,cxx,cc,c++")));
134 
135  // Page "Symbol browser"
136 #if wxCHECK_VERSION(3, 0, 0)
137  // Do not disable the whole page, since there are some toolbar related options
138  // we only need to disable the wxTreeCtrl related options.
139  XRCCTRL(*this, "chkNoSB", wxCheckBox)->Disable();
140  XRCCTRL(*this, "chkInheritance", wxCheckBox)->Disable();
141  XRCCTRL(*this, "chkExpandNS", wxCheckBox)->Disable();
142  XRCCTRL(*this, "chkFloatCB", wxCheckBox)->Disable();
143  XRCCTRL(*this, "chkTreeMembers", wxCheckBox)->Disable();
144 #else
145  XRCCTRL(*this, "chkNoSB", wxCheckBox)->SetValue(!cfg->ReadBool(_T("/use_symbols_browser"), true));
146 #endif // wxCHECK_VERSION
147  XRCCTRL(*this, "chkFloatCB", wxCheckBox)->SetValue(cfg->ReadBool(_T("/as_floating_window"), false));
148 
149  // The toolbar section
150  wxCheckBox *scopeFilter = XRCCTRL(*this, "chkScopeFilter", wxCheckBox);
151  scopeFilter->SetValue(cfg->ReadBool(_T("/scope_filter"), true));
152  wxSpinCtrl *spinScopeLength = XRCCTRL(*this, "spnChoiceScopeLength", wxSpinCtrl);
153  spinScopeLength->Enable(scopeFilter->GetValue());
154  spinScopeLength->SetValue(cfg->ReadInt(_T("/toolbar_scope_length"), 280));
155  XRCCTRL(*this, "spnChoiceFunctionLength", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/toolbar_function_length"), 660));
156 
157  // -----------------------------------------------------------------------
158  // Handle all options that are being handled by m_Parser
159  // -----------------------------------------------------------------------
160 
161  // Page "Code Completion"
162  XRCCTRL(*this, "chkUseSmartSense", wxCheckBox)->SetValue(!m_Parser.Options().useSmartSense);
163  XRCCTRL(*this, "chkWhileTyping", wxCheckBox)->SetValue(m_Parser.Options().whileTyping);
164 
165  // Page "C / C++ parser"
166  XRCCTRL(*this, "chkLocals", wxCheckBox)->SetValue(m_Parser.Options().followLocalIncludes);
167  XRCCTRL(*this, "chkGlobals", wxCheckBox)->SetValue(m_Parser.Options().followGlobalIncludes);
168  XRCCTRL(*this, "chkPreprocessor", wxCheckBox)->SetValue(m_Parser.Options().wantPreprocessor);
169  XRCCTRL(*this, "chkComplexMacros", wxCheckBox)->SetValue(m_Parser.Options().parseComplexMacros);
170  XRCCTRL(*this, "chkPlatformCheck", wxCheckBox)->SetValue(m_Parser.Options().platformCheck);
171 
172  XRCCTRL(*this, "rdoOneParserPerWorkspace", wxRadioButton)->SetValue( m_NativeParser->IsParserPerWorkspace());
173  XRCCTRL(*this, "rdoOneParserPerProject", wxRadioButton)->SetValue(!m_NativeParser->IsParserPerWorkspace());
174 
175  // Page "Symbol browser"
176  XRCCTRL(*this, "chkInheritance", wxCheckBox)->SetValue(m_Parser.ClassBrowserOptions().showInheritance);
177  XRCCTRL(*this, "chkExpandNS", wxCheckBox)->SetValue(m_Parser.ClassBrowserOptions().expandNS);
178  XRCCTRL(*this, "chkTreeMembers", wxCheckBox)->SetValue(m_Parser.ClassBrowserOptions().treeMembers);
179 
180  // Page Documentation
181  XRCCTRL(*this, "chkDocumentation", wxCheckBox)->SetValue(m_Documentation->IsEnabled());
182 
184  XRCCTRL(*this, "btnDocBgColor", wxButton)->SetBackgroundColour(colours->GetColour(wxT("cc_docs_back")));
185  XRCCTRL(*this, "btnDocTextColor", wxButton)->SetBackgroundColour(colours->GetColour(wxT("cc_docs_fore")));
186  XRCCTRL(*this, "btnDocLinkColor", wxButton)->SetBackgroundColour(colours->GetColour(wxT("cc_docs_link")));
187 
188 // m_Parser.ParseBuffer(g_SampleClasses, true);
189 // m_Parser.BuildTree(*XRCCTRL(*this, "treeClasses", wxTreeCtrl));
190 }
191 
193 {
194 }
195 
197 {
198  ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("code_completion"));
199 
200  // -----------------------------------------------------------------------
201  // Handle all options that are being directly applied / written from UI:
202  // -----------------------------------------------------------------------
203 
204  // Page "Code Completion"
205  cfg->Write(_T("/semantic_keywords"), (bool)!XRCCTRL(*this, "chkNoSemantic", wxCheckBox)->GetValue());
206  cfg->Write(_T("/use_SmartSense"), (bool) XRCCTRL(*this, "chkUseSmartSense", wxCheckBox)->GetValue());
207  cfg->Write(_T("/while_typing"), (bool) XRCCTRL(*this, "chkWhileTyping", wxCheckBox)->GetValue());
208  cfg->Write(_T("/auto_add_parentheses"), (bool) XRCCTRL(*this, "chkAutoAddParentheses", wxCheckBox)->GetValue());
209  cfg->Write(_T("/detect_implementation"),(bool) XRCCTRL(*this, "chkDetectImpl", wxCheckBox)->GetValue());
210  cfg->Write(_T("/add_doxgen_comment"), (bool) XRCCTRL(*this, "chkAddDoxgenComment", wxCheckBox)->GetValue());
211  cfg->Write(_T("/enable_headers"), (bool) XRCCTRL(*this, "chkEnableHeaders", wxCheckBox)->GetValue());
212  cfg->Write(_T("/max_matches"), (int) XRCCTRL(*this, "spnMaxMatches", wxSpinCtrl)->GetValue());
213  cfg->Write(_T("/fillup_chars"), XRCCTRL(*this, "txtFillupChars", wxTextCtrl)->GetValue());
214  cfg->Write(_T("/cc_delay"), (int) XRCCTRL(*this, "sldCCDelay", wxSlider)->GetValue() * 100);
215  cfg->Write(_T("/lexer_keywords_set1"), (bool) XRCCTRL(*this, "chkKL_1", wxCheckBox)->GetValue());
216  cfg->Write(_T("/lexer_keywords_set2"), (bool) XRCCTRL(*this, "chkKL_2", wxCheckBox)->GetValue());
217  cfg->Write(_T("/lexer_keywords_set3"), (bool) XRCCTRL(*this, "chkKL_3", wxCheckBox)->GetValue());
218  cfg->Write(_T("/lexer_keywords_set4"), (bool) XRCCTRL(*this, "chkKL_4", wxCheckBox)->GetValue());
219  cfg->Write(_T("/lexer_keywords_set5"), (bool) XRCCTRL(*this, "chkKL_5", wxCheckBox)->GetValue());
220  cfg->Write(_T("/lexer_keywords_set6"), (bool) XRCCTRL(*this, "chkKL_6", wxCheckBox)->GetValue());
221  cfg->Write(_T("/lexer_keywords_set7"), (bool) XRCCTRL(*this, "chkKL_7", wxCheckBox)->GetValue());
222  cfg->Write(_T("/lexer_keywords_set8"), (bool) XRCCTRL(*this, "chkKL_8", wxCheckBox)->GetValue());
223  cfg->Write(_T("/lexer_keywords_set9"), (bool) XRCCTRL(*this, "chkKL_9", wxCheckBox)->GetValue());
224 
225  // Page "C / C++ parser"
226  cfg->Write(_T("/parser_follow_local_includes"), (bool) XRCCTRL(*this, "chkLocals", wxCheckBox)->GetValue());
227  cfg->Write(_T("/parser_follow_global_includes"), (bool) XRCCTRL(*this, "chkGlobals", wxCheckBox)->GetValue());
228  cfg->Write(_T("/want_preprocessor"), (bool) XRCCTRL(*this, "chkPreprocessor", wxCheckBox)->GetValue());
229  cfg->Write(_T("/parse_complex_macros"), (bool) XRCCTRL(*this, "chkComplexMacros", wxCheckBox)->GetValue());
230  cfg->Write(_T("/platform_check"), (bool) XRCCTRL(*this, "chkPlatformCheck", wxCheckBox)->GetValue());
231 
232  cfg->Write(_T("/max_threads"), (int) XRCCTRL(*this, "spnThreadsNum", wxSpinCtrl)->GetValue());
233  cfg->Write(_T("/parser_per_workspace"), (bool) XRCCTRL(*this, "rdoOneParserPerWorkspace", wxRadioButton)->GetValue());
234  cfg->Write(_T("/max_parsers"), (int) XRCCTRL(*this, "spnParsersNum", wxSpinCtrl)->GetValue());
235 
236  // Page "C / C++ parser (adv.)"
237  cfg->Write(_T("/header_ext"), XRCCTRL(*this, "txtCCFileExtHeader", wxTextCtrl)->GetValue());
238  cfg->Write(_T("/empty_ext"), (bool) XRCCTRL(*this, "chkCCFileExtEmpty", wxCheckBox)->GetValue());
239  cfg->Write(_T("/source_ext"), XRCCTRL(*this, "txtCCFileExtSource", wxTextCtrl)->GetValue());
240 
241 #if !wxCHECK_VERSION(3, 0, 0)
242  // Page "Symbol browser"
243  cfg->Write(_T("/use_symbols_browser"), (bool)!XRCCTRL(*this, "chkNoSB", wxCheckBox)->GetValue());
244  cfg->Write(_T("/browser_show_inheritance"), (bool) XRCCTRL(*this, "chkInheritance", wxCheckBox)->GetValue());
245  cfg->Write(_T("/browser_expand_ns"), (bool) XRCCTRL(*this, "chkExpandNS", wxCheckBox)->GetValue());
246  cfg->Write(_T("/as_floating_window"), (bool) XRCCTRL(*this, "chkFloatCB", wxCheckBox)->GetValue());
247  cfg->Write(_T("/browser_tree_members"), (bool) XRCCTRL(*this, "chkTreeMembers", wxCheckBox)->GetValue());
248 #endif // wxCHECK_VERSION
249 
250  // The toolbar section
251  cfg->Write(_T("/scope_filter"), (bool) XRCCTRL(*this, "chkScopeFilter", wxCheckBox)->GetValue());
252  cfg->Write(_T("/toolbar_scope_length"), (int)XRCCTRL(*this, "spnChoiceScopeLength", wxSpinCtrl)->GetValue());
253  cfg->Write(_T("/toolbar_function_length"), (int)XRCCTRL(*this, "spnChoiceFunctionLength", wxSpinCtrl)->GetValue());
254 
255  // Page "Documentation"
256  cfg->Write(_T("/use_documentation_helper"), (bool) XRCCTRL(*this, "chkDocumentation", wxCheckBox)->GetValue());
257  cfg->Write(_T("/documentation_helper_background_color"), (wxColour) XRCCTRL(*this, "btnDocBgColor", wxButton)->GetBackgroundColour());
258  cfg->Write(_T("/documentation_helper_text_color"), (wxColour) XRCCTRL(*this, "btnDocTextColor", wxButton)->GetBackgroundColour());
259  cfg->Write(_T("/documentation_helper_link_color"), (wxColour) XRCCTRL(*this, "btnDocLinkColor", wxButton)->GetBackgroundColour());
260  // -----------------------------------------------------------------------
261  // Handle all options that are being be read by m_Parser.ReadOptions():
262  // -----------------------------------------------------------------------
263 
264  // Force parser to read its options that we write in the config
265  // Also don't forget to update the Parser option according UI!
267 
268  // Page "Code Completion"
269  m_Parser.Options().useSmartSense = !XRCCTRL(*this, "chkUseSmartSense", wxCheckBox)->GetValue();
270  m_Parser.Options().whileTyping = XRCCTRL(*this, "chkWhileTyping", wxCheckBox)->GetValue();
271 
272  // Page "C / C++ parser"
273  m_Parser.Options().followLocalIncludes = XRCCTRL(*this, "chkLocals", wxCheckBox)->GetValue();
274  m_Parser.Options().followGlobalIncludes = XRCCTRL(*this, "chkGlobals", wxCheckBox)->GetValue();
275  m_Parser.Options().wantPreprocessor = XRCCTRL(*this, "chkPreprocessor", wxCheckBox)->GetValue();
276  m_Parser.Options().parseComplexMacros = XRCCTRL(*this, "chkComplexMacros", wxCheckBox)->GetValue();
277  m_Parser.Options().platformCheck = XRCCTRL(*this, "chkPlatformCheck", wxCheckBox)->GetValue();
278 
279  // Page "Symbol browser"
280  m_Parser.ClassBrowserOptions().showInheritance = XRCCTRL(*this, "chkInheritance", wxCheckBox)->GetValue();
281  m_Parser.ClassBrowserOptions().expandNS = XRCCTRL(*this, "chkExpandNS", wxCheckBox)->GetValue();
282  m_Parser.ClassBrowserOptions().treeMembers = XRCCTRL(*this, "chkTreeMembers", wxCheckBox)->GetValue();
283 
284  // Page "Documentation"
286 
287  m_Parser.Options().storeDocumentation = XRCCTRL(*this, "chkDocumentation", wxCheckBox)->GetValue();
288  m_Documentation->SetEnabled( XRCCTRL(*this, "chkDocumentation", wxCheckBox)->GetValue() );
289 
291  wxColor colour = XRCCTRL(*this, "btnDocBgColor", wxButton)->GetBackgroundColour();
292  colours->SetColour(wxT("cc_docs_back"), colour);
293  colour = XRCCTRL(*this, "btnDocTextColor", wxButton)->GetBackgroundColour();
294  colours->SetColour(wxT("cc_docs_text"), colour);
295  colour = XRCCTRL(*this, "btnDocLinkColor", wxButton)->GetBackgroundColour();
296  colours->SetColour(wxT("cc_docs_link"), colour);
297 
298  // Now write the parser options and re-read them again to make sure they are up-to-date
303 }
304 
306 {
307  wxColourData data;
308  wxWindow* sender = FindWindowById(event.GetId());
309  data.SetColour(sender->GetBackgroundColour());
310 
311  wxColourDialog dlg(this, &data);
312  PlaceWindow(&dlg);
313  if (dlg.ShowModal() == wxID_OK)
314  {
315  wxColour colour = dlg.GetColourData().GetColour();
316  sender->SetBackgroundColour(colour);
317  }
318 }
319 
321 {
323 }
324 
326 {
327  // ccmanager's config
328  ConfigManager* ccmcfg = Manager::Get()->GetConfigManager(_T("ccmanager"));
329  bool en = ccmcfg->ReadBool(_T("/code_completion"), true);
330  bool aap = XRCCTRL(*this, "chkAutoAddParentheses", wxCheckBox)->GetValue();
331 
332  // Page "Code Completion"
333  XRCCTRL(*this, "chkUseSmartSense", wxCheckBox)->Enable(en);
334  XRCCTRL(*this, "chkWhileTyping", wxCheckBox)->Enable(en);
335  XRCCTRL(*this, "chkAutoAddParentheses", wxCheckBox)->Enable(en);
336  XRCCTRL(*this, "chkDetectImpl", wxCheckBox)->Enable(en && aap);
337  XRCCTRL(*this, "chkAddDoxgenComment", wxCheckBox)->Enable(en);
338  XRCCTRL(*this, "chkEnableHeaders", wxCheckBox)->Enable(en);
339  XRCCTRL(*this, "chkNoSemantic", wxCheckBox)->Enable(en);
340  XRCCTRL(*this, "lblMaxMatches", wxStaticText)->Enable(en);
341  XRCCTRL(*this, "spnMaxMatches", wxSpinCtrl)->Enable(en);
342  XRCCTRL(*this, "lblFillupChars", wxStaticText)->Enable(en);
343  XRCCTRL(*this, "txtFillupChars", wxTextCtrl)->Enable(en);
344  XRCCTRL(*this, "sldCCDelay", wxSlider)->Enable(en);
345 
346  // keyword sets
347  XRCCTRL(*this, "chkKL_1", wxCheckBox)->Enable(en);
348  XRCCTRL(*this, "chkKL_2", wxCheckBox)->Enable(en);
349  XRCCTRL(*this, "chkKL_3", wxCheckBox)->Enable(en);
350  XRCCTRL(*this, "chkKL_4", wxCheckBox)->Enable(en);
351  XRCCTRL(*this, "chkKL_5", wxCheckBox)->Enable(en);
352  XRCCTRL(*this, "chkKL_6", wxCheckBox)->Enable(en);
353  XRCCTRL(*this, "chkKL_7", wxCheckBox)->Enable(en);
354  XRCCTRL(*this, "chkKL_8", wxCheckBox)->Enable(en);
355  XRCCTRL(*this, "chkKL_9", wxCheckBox)->Enable(en);
356 
357  // Page "C / C++ parser"
358  XRCCTRL(*this, "chkLocals", wxCheckBox)->Enable(en);
359  XRCCTRL(*this, "chkGlobals", wxCheckBox)->Enable(en);
360  XRCCTRL(*this, "chkPreprocessor", wxCheckBox)->Enable(en);
361  XRCCTRL(*this, "chkComplexMacros", wxCheckBox)->Enable(en);
362  XRCCTRL(*this, "chkPlatformCheck", wxCheckBox)->Enable(en);
363 
364  en = XRCCTRL(*this, "rdoOneParserPerWorkspace", wxRadioButton)->GetValue();
365  XRCCTRL(*this, "lblParsersNum", wxStaticText)->Enable(!en);
366  XRCCTRL(*this, "spnParsersNum", wxSpinCtrl)->Enable(!en);
367 
368  // Page "C / C++ parser (adv.)"
369  // FIXME (ollydbg#1#01/07/15): should code_completion option affect our parser's behaviour?
370  en = ccmcfg->ReadBool(_T("/code_completion"), true);
371  XRCCTRL(*this, "txtCCFileExtHeader", wxTextCtrl)->Enable(en);
372  XRCCTRL(*this, "chkCCFileExtEmpty", wxCheckBox)->Enable(en);
373  XRCCTRL(*this, "txtCCFileExtSource", wxTextCtrl)->Enable(en);
374 
375  // Page "Symbol browser"
376 #if !wxCHECK_VERSION(3, 0, 0)
377  en = !XRCCTRL(*this, "chkNoSB", wxCheckBox)->GetValue();
378  XRCCTRL(*this, "chkInheritance", wxCheckBox)->Enable(en);
379  XRCCTRL(*this, "chkExpandNS", wxCheckBox)->Enable(en);
380  XRCCTRL(*this, "chkFloatCB", wxCheckBox)->Enable(en);
381  XRCCTRL(*this, "chkTreeMembers", wxCheckBox)->Enable(en);
382 #endif // !wxCHECK_VERSION
383 
384  // Toolbar section
385  wxCheckBox *scopeFilter = XRCCTRL(*this, "chkScopeFilter", wxCheckBox);
386  XRCCTRL(*this, "spnChoiceScopeLength", wxSpinCtrl)->Enable(scopeFilter->GetValue());
387 
388  // Page "Documentation"
389  en = XRCCTRL(*this, "chkDocumentation", wxCheckBox)->GetValue();
390  XRCCTRL(*this, "btnDocBgColor", wxButton)->Enable(en);
391  XRCCTRL(*this, "btnDocTextColor", wxButton)->Enable(en);
392  XRCCTRL(*this, "btnDocLinkColor", wxButton)->Enable(en);
393 }
394 
396 {
397  int position = XRCCTRL(*this, "sldCCDelay", wxSlider)->GetValue();
398  wxString lbl;
399  if (position >= 10)
400  lbl.Printf(_("%d.%d sec"), position / 10, position % 10);
401  else
402  lbl.Printf(_("%d ms"), position * 100);
403  XRCCTRL(*this, "lblDelay", wxStaticText)->SetLabel(lbl);
404 }
405 
407 {
408  // cut off any leading / trailing spaces
409  from.Trim(true).Trim(false);
410  to.Trim(true).Trim(false);
411 
412  if (to.IsEmpty())
413  {
414  // Allow removing a token, but ask the user if that's OK.
415  if (cbMessageBox( _("This setup will replace the token with an empty string.\n"
416  "This will *remove* the token and probably break CC for some cases.\n"
417  "Do you really want to *remove* that token?"),
418  _("Confirmation"),
420  {
421  return true;
422  }
423  }
424  else if (to.Contains(from))
425  {
426  cbMessageBox(_("Replacement token cannot contain search token.\n"
427  "This would cause an infinite loop otherwise."),
428  _("Error"), wxICON_ERROR);
429  return false;
430  }
431 
432  wxRegEx re(_T("[A-Za-z_]+[0-9]*[A-Za-z_]*"));
433  if (!re.Matches(from))
434  {
435  cbMessageBox(_("Search token can only contain alphanumeric characters and underscores."),
436  _("Error"), wxICON_ERROR);
437  return false;
438  }
439  if (!re.Matches(to))
440  {
441  // Allow replacing with special characters only if the user says it's ok.
442  if (cbMessageBox( _("You are replacing a token with a string that contains\n"
443  "characters other than alphanumeric and underscores.\n"
444  "This could make parsing the file impossible.\n"
445  "Are you sure?"),
446  _("Confirmation"),
448  {
449  return false;
450  }
451  }
452 
453  return true;
454 }
virtual BrowserOptions & ClassBrowserOptions()
Definition: parser_base.h:175
#define wxICON_QUESTION
bool whileTyping
use real AI(scope sequence match) or not(plain text match)
Definition: parser_base.h:116
virtual void WriteOptions()
write Parse options to configure file
Definition: parser_base.h:171
bool useSmartSense
handle preprocessor directive in Tokenizer class
Definition: parser_base.h:115
void OnUpdateUI(wxUpdateUIEvent &event)
ConfigManager * GetConfigManager(const wxString &name_space) const
Definition: manager.cpp:474
int ReadInt(const wxString &name, int defaultVal=0)
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
Definition: manager.cpp:182
bool followLocalIncludes
Definition: parser_base.h:111
virtual void OnApply()
Called when the user chooses to apply the configuration.
#define wxICON_ERROR
wxColour & GetColour()
ParserBase & m_Parser
Definition: ccoptionsdlg.h:41
bool ReadBool(const wxString &name, bool defaultVal=false)
bool storeDocumentation
this will check for the platform of the project/target when adding include folders to the parser ...
Definition: parser_base.h:119
DocumentationHelper * m_Documentation
Definition: ccoptionsdlg.h:42
bool showInheritance
whether the base class or derive class information is shown as a child node default: false ...
Definition: parser_base.h:72
bool platformCheck
this will let the Tokenizer to recursive expand macros
Definition: parser_base.h:118
bool Matches(const wxString &text, int flags=0) const
#define _T(string)
void SetEnabled(bool enabled)
#define wxYES_NO
void UpdateCCDelayLabel()
virtual ParserOptions & Options()
Definition: parser_base.h:174
#define wxT(string)
NativeParser * m_NativeParser
Definition: ccoptionsdlg.h:39
wxPanel * LoadPanel(wxWindow *parent, const wxString &name)
Code completion plugin has those features: show tool-tip when the mouse hover over the variables/func...
bool expandNS
whether a namespaces node is auto-expand auto-expand means the child of the namespace is automaticall...
Definition: parser_base.h:79
bool Contains(const wxString &str) const
void Write(const wxString &name, const wxString &value, bool ignoreEmpty=false)
void RereadOptions(ConfigManager *cfg)
wxColour GetColour(const wxString &id) const
void OnChooseColour(wxCommandEvent &event)
virtual int ShowModal()
wxString Read(const wxString &key, const wxString &defaultVal=wxEmptyString)
bool wantPreprocessor
case sensitive in MarkItemsByAI
Definition: parser_base.h:114
wxString wxEmptyString
virtual void SetValue(const wxString &text)
const wxString & _(const wxString &string)
wxString & Trim(bool fromRight=true)
int cbMessageBox(const wxString &message, const wxString &caption=wxEmptyString, int style=wxOK, wxWindow *parent=NULL, int x=-1, int y=-1)
Call global cbMessageBox with m_parentDialog as parent window when no parent window specified...
bool followGlobalIncludes
parse XXX.h in directive #include "XXX.h"
Definition: parser_base.h:112
void RereadParserOptions()
when user changes the CC option, we should re-read the option
NativeParser class is just like a manager class to control Parser objects.
Definition: nativeparser.h:55
ColourManager * GetColourManager() const
Definition: manager.cpp:489
bool IsEmpty() const
DLLIMPORT void PlaceWindow(wxTopLevelWindow *w, cbPlaceDialogMode mode=pdlBest, bool enforce=false)
Definition: globals.cpp:1177
bool treeMembers
show members in the bottom tree.
Definition: parser_base.h:82
CodeCompletion * m_CodeCompletion
Definition: ccoptionsdlg.h:40
bool parseComplexMacros
reparse the active editor while editing
Definition: parser_base.h:117
void SetColour(const wxString &id, const wxColour &colour)
static wxXmlResource * Get()
bool ValidateReplacementToken(wxString &from, wxString &to)
void RereadOptions()
read CC&#39;s options, mostly happens the user change some setting and press APPLY
virtual bool GetValue() const
wxColourData & GetColourData()
virtual void ReadOptions()
read Parser options from configure file
Definition: parser_base.h:169
int Printf(const wxString &pszFormat,...)
void WriteOptions(ConfigManager *cfg)
void SetColour(const wxColour &colour)
virtual void SetValue(bool state)
void OnCCDelayScroll(wxScrollEvent &event)
virtual ~CCOptionsDlg()