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
7
#include "fpoptionsdlg.h"
8
#include "fortranproject.h"
10
#include <wx/listbox.h>
11
#include <wx/xrc/xmlres.h>
12
#include <wx/spinctrl.h>
13
#include <wx/checkbox.h>
14
#include <wx/combobox.h>
15
#include <wx/treectrl.h>
16
#include <wx/slider.h>
17
#include <wx/button.h>
18
#include <wx/stattext.h>
20
#include <configmanager.h>
25
BEGIN_EVENT_TABLE(FPOptionsDlg, wxPanel)
26
EVT_UPDATE_UI(-1, FPOptionsDlg::OnUpdateUI)
27
EVT_LISTBOX(XRCID("lbAIStatements"), FPOptionsDlg::OnAISelectionChanged)
30
FPOptionsDlg::FPOptionsDlg(wxWindow* parent, NativeParserF* np, FortranProject* fp)
31
: m_pNativeParser(np),
34
ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("fortran_project"));
36
wxXmlResource::Get()->LoadPanel(this, parent, _T("dlgFPSettings"));
38
XRCCTRL(*this, "chkNoCC", wxCheckBox)->SetValue(!cfg->ReadBool(_T("/use_code_completion"), true));
39
XRCCTRL(*this, "chkSmartCodeCompletion", wxCheckBox)->SetValue(cfg->ReadBool(_T("/use_smart_code_completion"), true));
40
XRCCTRL(*this, "chkOnlyUseAssociated", wxCheckBox)->SetValue(cfg->ReadBool(_T("/only_use_associated"), true));
41
XRCCTRL(*this, "chkShowHiddenEntities", wxCheckBox)->SetValue(cfg->ReadBool(_T("/show_hidden_entities"), false));
42
XRCCTRL(*this, "chkShowTypeVariables", wxCheckBox)->SetValue(cfg->ReadBool(_T("/show_type_variables"), true));
43
XRCCTRL(*this, "spnMaxMatches", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/max_matches"), 16384));
45
XRCCTRL(*this, "chkNoSB", wxCheckBox)->SetValue(!cfg->ReadBool(_T("/use_symbols_browser"), true));
46
XRCCTRL(*this, "chkFloatSB", wxCheckBox)->SetValue(cfg->ReadBool(_T("/as_floating_window"), false));
47
XRCCTRL(*this, "chkBottomTree", wxCheckBox)->SetValue(cfg->ReadBool(_T("/visible_bottom_tree"), true));
48
XRCCTRL(*this, "chkSortSB", wxCheckBox)->SetValue(cfg->ReadBool(_T("/browser_sort_alphabetically"), true));
49
XRCCTRL(*this, "chkLocVarSB", wxCheckBox)->SetValue(cfg->ReadBool(_T("/browser_show_local_variables"), false));
50
XRCCTRL(*this, "chkInclSepar", wxCheckBox)->SetValue(cfg->ReadBool(_T("/browser_show_include_files_separately"), true));
52
XRCCTRL(*this, "chkKL_1", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set1"), true));
53
XRCCTRL(*this, "chkKL_2", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set2"), true));
54
XRCCTRL(*this, "chkKL_3", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set3"), false));
55
XRCCTRL(*this, "chkKL_4", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set4"), false));
56
XRCCTRL(*this, "chkKL_5", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set5"), false));
57
XRCCTRL(*this, "chkKL_6", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set6"), false));
58
XRCCTRL(*this, "chkKL_7", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set7"), false));
59
XRCCTRL(*this, "chkKL_8", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set8"), false));
60
XRCCTRL(*this, "chkKL_9", wxCheckBox)->SetValue(cfg->ReadBool(_T("/lexer_keywords_set9"), false));
62
XRCCTRL(*this, "rbCase", wxRadioBox)->SetSelection(cfg->ReadInt(_T("/keywords_case"), 0));
64
XRCCTRL(*this, "chkCallTipsArrays", wxCheckBox)->SetValue(cfg->ReadBool(_T("/call_tip_arrays"), true));
66
XRCCTRL(*this, "chkNoFortranInfo", wxCheckBox)->SetValue(!cfg->ReadBool(_T("/use_log_window"), true));
67
XRCCTRL(*this, "chkComAbove", wxCheckBox)->SetValue(cfg->ReadBool(_T("/include_comments_above"), true));
68
XRCCTRL(*this, "chkComBelow", wxCheckBox)->SetValue(cfg->ReadBool(_T("/include_comments_below"), true));
69
XRCCTRL(*this, "chkDeclarLog", wxCheckBox)->SetValue(cfg->ReadBool(_T("/include_declarations_log"), true));
70
XRCCTRL(*this, "chkLogComRight", wxCheckBox)->SetValue(cfg->ReadBool(_T("/include_log_comments_variable"), true));
72
XRCCTRL(*this, "rboxDocWindow", wxRadioBox)->SetSelection(cfg->ReadInt(_T("/show_docs_window"), 1));
74
XRCCTRL(*this, "cbAIDisable", wxCheckBox)->SetValue(!cfg->ReadBool(_T("/ainsert_enable"), true));
78
FPOptionsDlg::~FPOptionsDlg()
82
void FPOptionsDlg::FillAutoInsert()
84
const std::map<wxString,wxString>* ainames = m_AInsert.GetNameMap();
85
std::map<wxString,wxString>::const_iterator it;
87
for (it = ainames->begin(); it != ainames->end(); ++it)
89
XRCCTRL(*this, "lbAIStatements", wxListBox)->Append(it->second);
92
XRCCTRL(*this, "lbAIStatements", wxListBox)->SetSelection(m_AISelIdx);
93
ShowCurrientAInsert(m_AISelIdx);
96
void FPOptionsDlg::ShowCurrientAInsert(int idx)
100
wxString sel = XRCCTRL(*this, "lbAIStatements", wxListBox)->GetString(idx);
101
wxArrayString aitstr;
102
wxArrayString alignstr;
104
if (!m_AInsert.GetItemChoices(sel, aitstr, alignstr, isen))
107
XRCCTRL(*this, "cbAIInsert", wxChoice)->Clear();
108
for (size_t i=0; i<aitstr.Count(); i++)
110
XRCCTRL(*this, "cbAIInsert", wxChoice)->Append(aitstr[i]);
113
XRCCTRL(*this, "cbAIAlign", wxChoice)->Clear();
114
if (alignstr.Count() > 0)
116
XRCCTRL(*this, "cbAIAlign", wxChoice)->Enable(true);
117
m_cbAIAlign_wasEnabled = true;
118
for (size_t i=0; i<alignstr.Count(); i++)
120
XRCCTRL(*this, "cbAIAlign", wxChoice)->Append(alignstr[i]);
125
XRCCTRL(*this, "cbAIAlign", wxChoice)->Enable(false);
126
m_cbAIAlign_wasEnabled = false;
129
XRCCTRL(*this, "cbAIAddName", wxCheckBox)->Enable(isen);
130
m_cbAIAddName_wasEnabled = isen;
134
bool alignToStatement;
135
if (!m_AInsert.GetItemValues(sel, aiType, doAddName, alignToStatement))
138
XRCCTRL(*this, "cbAIInsert", wxChoice)->SetSelection(aiType);
139
int ats = alignToStatement? 0: 1;
140
XRCCTRL(*this, "cbAIAlign", wxChoice)->SetSelection(ats);
141
XRCCTRL(*this, "cbAIAddName", wxCheckBox)->SetValue(doAddName);
145
void FPOptionsDlg::OnAISelectionChanged(wxCommandEvent& event)
147
int idx = XRCCTRL(*this, "lbAIStatements", wxListBox)->GetSelection();
148
if (idx != wxNOT_FOUND)
151
ShowCurrientAInsert(idx);
155
void FPOptionsDlg::ReadAIChoice()
157
wxString sel = XRCCTRL(*this, "lbAIStatements", wxListBox)->GetString(m_AISelIdx);
159
int aiType = XRCCTRL(*this, "cbAIInsert", wxChoice)->GetSelection();
160
int iAlign = XRCCTRL(*this, "cbAIAlign", wxChoice)->GetSelection();
161
bool alignToStatement = iAlign==0 ? true : false;
162
bool doAddName = XRCCTRL(*this, "cbAIAddName", wxCheckBox)->GetValue();
164
m_AInsert.EditRule(sel, aiType, doAddName, alignToStatement);
167
void FPOptionsDlg::OnUpdateUI(wxUpdateUIEvent& event)
169
bool en = !XRCCTRL(*this, "chkNoCC", wxCheckBox)->GetValue();
171
XRCCTRL(*this, "chkSmartCodeCompletion", wxCheckBox)->Enable(en);
172
XRCCTRL(*this, "chkOnlyUseAssociated", wxCheckBox)->Enable(en);
173
XRCCTRL(*this, "chkShowHiddenEntities", wxCheckBox)->Enable(en);
174
XRCCTRL(*this, "spnMaxMatches", wxSpinCtrl)->Enable(en);
175
XRCCTRL(*this, "rbCase", wxRadioBox)->Enable(en);
176
XRCCTRL(*this, "chkKL_1", wxCheckBox)->Enable(en);
177
XRCCTRL(*this, "chkKL_2", wxCheckBox)->Enable(en);
178
XRCCTRL(*this, "chkKL_3", wxCheckBox)->Enable(en);
179
XRCCTRL(*this, "chkKL_4", wxCheckBox)->Enable(en);
180
XRCCTRL(*this, "chkKL_5", wxCheckBox)->Enable(en);
181
XRCCTRL(*this, "chkKL_6", wxCheckBox)->Enable(en);
182
XRCCTRL(*this, "chkKL_7", wxCheckBox)->Enable(en);
183
XRCCTRL(*this, "chkKL_8", wxCheckBox)->Enable(en);
184
XRCCTRL(*this, "chkKL_9", wxCheckBox)->Enable(en);
186
en = !XRCCTRL(*this, "chkNoSB", wxCheckBox)->GetValue();
187
XRCCTRL(*this, "chkFloatSB", wxCheckBox)->Enable(en);
188
XRCCTRL(*this, "chkBottomTree", wxCheckBox)->Enable(en);
189
XRCCTRL(*this, "chkSortSB", wxCheckBox)->Enable(en);
191
en = !XRCCTRL(*this, "chkNoFortranInfo", wxCheckBox)->GetValue();
192
XRCCTRL(*this, "chkComAbove", wxCheckBox)->Enable(en);
193
XRCCTRL(*this, "chkComBelow", wxCheckBox)->Enable(en);
194
XRCCTRL(*this, "chkDeclarLog", wxCheckBox)->Enable(en);
195
XRCCTRL(*this, "chkLogComRight", wxCheckBox)->Enable(en);
197
en = !XRCCTRL(*this, "cbAIDisable", wxCheckBox)->GetValue();
198
XRCCTRL(*this, "lbAIStatements", wxListBox)->Enable(en);
199
XRCCTRL(*this, "stAIText1", wxStaticText)->Enable(en);
200
XRCCTRL(*this, "stAIText2", wxStaticText)->Enable(en);
201
XRCCTRL(*this, "cbAIInsert", wxChoice)->Enable(en);
205
if (en && m_cbAIAlign_wasEnabled)
206
XRCCTRL(*this, "cbAIAlign", wxChoice)->Enable(en);
208
XRCCTRL(*this, "cbAIAlign", wxChoice)->Enable(en);
210
if (en && m_cbAIAddName_wasEnabled)
211
XRCCTRL(*this, "cbAIAddName", wxCheckBox)->Enable(en);
213
XRCCTRL(*this, "cbAIAddName", wxCheckBox)->Enable(en);
216
void FPOptionsDlg::OnApply()
218
ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("fortran_project"));
220
// force parser to read its options that we write in the config
221
cfg->Write(_T("/use_code_completion"), (bool)!XRCCTRL(*this, "chkNoCC", wxCheckBox)->GetValue());
223
// set all other member options
224
cfg->Write(_T("/use_smart_code_completion"), (bool)XRCCTRL(*this, "chkSmartCodeCompletion", wxCheckBox)->GetValue());
225
cfg->Write(_T("/only_use_associated"), (bool)XRCCTRL(*this, "chkOnlyUseAssociated", wxCheckBox)->GetValue());
226
cfg->Write(_T("/show_hidden_entities"), (bool)XRCCTRL(*this, "chkShowHiddenEntities", wxCheckBox)->GetValue());
227
cfg->Write(_T("/show_type_variables"), (bool)XRCCTRL(*this, "chkShowTypeVariables", wxCheckBox)->GetValue());
228
cfg->Write(_T("/max_matches"), (int)XRCCTRL(*this, "spnMaxMatches", wxSpinCtrl)->GetValue());
230
cfg->Write(_T("/use_symbols_browser"), (bool)!XRCCTRL(*this, "chkNoSB", wxCheckBox)->GetValue());
231
cfg->Write(_T("/as_floating_window"), (bool)XRCCTRL(*this, "chkFloatSB", wxCheckBox)->GetValue());
232
cfg->Write(_T("/visible_bottom_tree"), (bool)XRCCTRL(*this, "chkBottomTree", wxCheckBox)->GetValue());
233
cfg->Write(_T("/browser_sort_alphabetically"), (bool)XRCCTRL(*this, "chkSortSB", wxCheckBox)->GetValue());
234
cfg->Write(_T("/browser_show_local_variables"), (bool)XRCCTRL(*this, "chkLocVarSB", wxCheckBox)->GetValue());
235
cfg->Write(_T("/browser_show_include_files_separately"), (bool)XRCCTRL(*this, "chkInclSepar", wxCheckBox)->GetValue());
237
cfg->Write(_T("/lexer_keywords_set1"), (bool)XRCCTRL(*this, "chkKL_1", wxCheckBox)->GetValue());
238
cfg->Write(_T("/lexer_keywords_set2"), (bool)XRCCTRL(*this, "chkKL_2", wxCheckBox)->GetValue());
239
cfg->Write(_T("/lexer_keywords_set3"), (bool)XRCCTRL(*this, "chkKL_3", wxCheckBox)->GetValue());
240
cfg->Write(_T("/lexer_keywords_set4"), (bool)XRCCTRL(*this, "chkKL_4", wxCheckBox)->GetValue());
241
cfg->Write(_T("/lexer_keywords_set5"), (bool)XRCCTRL(*this, "chkKL_5", wxCheckBox)->GetValue());
242
cfg->Write(_T("/lexer_keywords_set6"), (bool)XRCCTRL(*this, "chkKL_6", wxCheckBox)->GetValue());
243
cfg->Write(_T("/lexer_keywords_set7"), (bool)XRCCTRL(*this, "chkKL_7", wxCheckBox)->GetValue());
244
cfg->Write(_T("/lexer_keywords_set8"), (bool)XRCCTRL(*this, "chkKL_8", wxCheckBox)->GetValue());
245
cfg->Write(_T("/lexer_keywords_set9"), (bool)XRCCTRL(*this, "chkKL_9", wxCheckBox)->GetValue());
247
cfg->Write(_T("/keywords_case"), (int)XRCCTRL(*this, "rbCase", wxRadioBox)->GetSelection());
249
cfg->Write(_T("/call_tip_arrays"), (bool)XRCCTRL(*this, "chkCallTipsArrays", wxCheckBox)->GetValue());
251
cfg->Write(_T("/use_log_window"), (bool)!XRCCTRL(*this, "chkNoFortranInfo", wxCheckBox)->GetValue());
252
cfg->Write(_T("/include_comments_above"), (bool)XRCCTRL(*this, "chkComAbove", wxCheckBox)->GetValue());
253
cfg->Write(_T("/include_comments_below"), (bool)XRCCTRL(*this, "chkComBelow", wxCheckBox)->GetValue());
254
cfg->Write(_T("/include_declarations_log"), (bool)XRCCTRL(*this, "chkDeclarLog", wxCheckBox)->GetValue());
255
cfg->Write(_T("/include_log_comments_variable"), (bool)XRCCTRL(*this, "chkLogComRight", wxCheckBox)->GetValue());
257
cfg->Write(_T("/show_docs_window"), (int)XRCCTRL(*this, "rboxDocWindow", wxRadioBox)->GetSelection());
259
cfg->Write(_T("/ainsert_enable"), (bool)!XRCCTRL(*this, "cbAIDisable", wxCheckBox)->GetValue());
261
m_AInsert.WriteAIOptions();
263
m_pNativeParser->RereadOptions();
264
m_pFortranProject->RereadOptions();