~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/FortranProject/fpoptionsdlg.cpp

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
6
#include <sdk.h>
 
7
#include "fpoptionsdlg.h"
 
8
#include "fortranproject.h"
 
9
#include <wx/intl.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>
 
19
#include <wx/regex.h>
 
20
#include <configmanager.h>
 
21
#include <manager.h>
 
22
#include <globals.h>
 
23
 
 
24
 
 
25
BEGIN_EVENT_TABLE(FPOptionsDlg, wxPanel)
 
26
    EVT_UPDATE_UI(-1, FPOptionsDlg::OnUpdateUI)
 
27
    EVT_LISTBOX(XRCID("lbAIStatements"), FPOptionsDlg::OnAISelectionChanged)
 
28
END_EVENT_TABLE()
 
29
 
 
30
FPOptionsDlg::FPOptionsDlg(wxWindow* parent, NativeParserF* np, FortranProject* fp)
 
31
    : m_pNativeParser(np),
 
32
    m_pFortranProject(fp)
 
33
{
 
34
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("fortran_project"));
 
35
 
 
36
    wxXmlResource::Get()->LoadPanel(this, parent, _T("dlgFPSettings"));
 
37
 
 
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));
 
44
 
 
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));
 
51
 
 
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));
 
61
 
 
62
    XRCCTRL(*this, "rbCase", wxRadioBox)->SetSelection(cfg->ReadInt(_T("/keywords_case"), 0));
 
63
 
 
64
    XRCCTRL(*this, "chkCallTipsArrays", wxCheckBox)->SetValue(cfg->ReadBool(_T("/call_tip_arrays"), true));
 
65
 
 
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));
 
71
 
 
72
    XRCCTRL(*this, "rboxDocWindow", wxRadioBox)->SetSelection(cfg->ReadInt(_T("/show_docs_window"), 1));
 
73
 
 
74
    XRCCTRL(*this, "cbAIDisable", wxCheckBox)->SetValue(!cfg->ReadBool(_T("/ainsert_enable"), true));
 
75
    FillAutoInsert();
 
76
}
 
77
 
 
78
FPOptionsDlg::~FPOptionsDlg()
 
79
{
 
80
}
 
81
 
 
82
void FPOptionsDlg::FillAutoInsert()
 
83
{
 
84
    const std::map<wxString,wxString>* ainames = m_AInsert.GetNameMap();
 
85
    std::map<wxString,wxString>::const_iterator it;
 
86
 
 
87
    for (it = ainames->begin(); it != ainames->end(); ++it)
 
88
    {
 
89
        XRCCTRL(*this, "lbAIStatements", wxListBox)->Append(it->second);
 
90
    }
 
91
    m_AISelIdx = 0;
 
92
    XRCCTRL(*this, "lbAIStatements", wxListBox)->SetSelection(m_AISelIdx);
 
93
    ShowCurrientAInsert(m_AISelIdx);
 
94
}
 
95
 
 
96
void FPOptionsDlg::ShowCurrientAInsert(int idx)
 
97
{
 
98
    m_AISelIdx = -1;
 
99
 
 
100
    wxString sel = XRCCTRL(*this, "lbAIStatements", wxListBox)->GetString(idx);
 
101
    wxArrayString aitstr;
 
102
    wxArrayString alignstr;
 
103
    bool isen;
 
104
    if (!m_AInsert.GetItemChoices(sel, aitstr, alignstr, isen))
 
105
        return;
 
106
 
 
107
    XRCCTRL(*this, "cbAIInsert", wxChoice)->Clear();
 
108
    for (size_t i=0; i<aitstr.Count(); i++)
 
109
    {
 
110
        XRCCTRL(*this, "cbAIInsert", wxChoice)->Append(aitstr[i]);
 
111
    }
 
112
 
 
113
    XRCCTRL(*this, "cbAIAlign", wxChoice)->Clear();
 
114
    if (alignstr.Count() > 0)
 
115
    {
 
116
        XRCCTRL(*this, "cbAIAlign", wxChoice)->Enable(true);
 
117
        m_cbAIAlign_wasEnabled = true;
 
118
        for (size_t i=0; i<alignstr.Count(); i++)
 
119
        {
 
120
            XRCCTRL(*this, "cbAIAlign", wxChoice)->Append(alignstr[i]);
 
121
        }
 
122
    }
 
123
    else
 
124
    {
 
125
        XRCCTRL(*this, "cbAIAlign", wxChoice)->Enable(false);
 
126
        m_cbAIAlign_wasEnabled = false;
 
127
    }
 
128
 
 
129
    XRCCTRL(*this, "cbAIAddName", wxCheckBox)->Enable(isen);
 
130
    m_cbAIAddName_wasEnabled = isen;
 
131
 
 
132
    int aiType;
 
133
    bool doAddName;
 
134
    bool alignToStatement;
 
135
    if (!m_AInsert.GetItemValues(sel, aiType, doAddName, alignToStatement))
 
136
        return;
 
137
 
 
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);
 
142
    m_AISelIdx = idx;
 
143
}
 
144
 
 
145
void FPOptionsDlg::OnAISelectionChanged(wxCommandEvent& event)
 
146
{
 
147
    int idx = XRCCTRL(*this, "lbAIStatements", wxListBox)->GetSelection();
 
148
    if (idx != wxNOT_FOUND)
 
149
    {
 
150
        ReadAIChoice();
 
151
        ShowCurrientAInsert(idx);
 
152
    }
 
153
}
 
154
 
 
155
void FPOptionsDlg::ReadAIChoice()
 
156
{
 
157
    wxString sel = XRCCTRL(*this, "lbAIStatements", wxListBox)->GetString(m_AISelIdx);
 
158
 
 
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();
 
163
 
 
164
    m_AInsert.EditRule(sel, aiType, doAddName, alignToStatement);
 
165
}
 
166
 
 
167
void FPOptionsDlg::OnUpdateUI(wxUpdateUIEvent& event)
 
168
{
 
169
    bool en = !XRCCTRL(*this, "chkNoCC", wxCheckBox)->GetValue();
 
170
 
 
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);
 
185
 
 
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);
 
190
 
 
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);
 
196
 
 
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);
 
202
 
 
203
 
 
204
 
 
205
    if (en && m_cbAIAlign_wasEnabled)
 
206
        XRCCTRL(*this, "cbAIAlign", wxChoice)->Enable(en);
 
207
    else if (!en)
 
208
        XRCCTRL(*this, "cbAIAlign", wxChoice)->Enable(en);
 
209
 
 
210
    if (en && m_cbAIAddName_wasEnabled)
 
211
        XRCCTRL(*this, "cbAIAddName", wxCheckBox)->Enable(en);
 
212
    else if (!en)
 
213
        XRCCTRL(*this, "cbAIAddName", wxCheckBox)->Enable(en);
 
214
}
 
215
 
 
216
void FPOptionsDlg::OnApply()
 
217
{
 
218
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("fortran_project"));
 
219
 
 
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());
 
222
 
 
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());
 
229
 
 
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());
 
236
 
 
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());
 
246
 
 
247
    cfg->Write(_T("/keywords_case"), (int)XRCCTRL(*this, "rbCase", wxRadioBox)->GetSelection());
 
248
 
 
249
    cfg->Write(_T("/call_tip_arrays"), (bool)XRCCTRL(*this, "chkCallTipsArrays", wxCheckBox)->GetValue());
 
250
 
 
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());
 
256
 
 
257
    cfg->Write(_T("/show_docs_window"), (int)XRCCTRL(*this, "rboxDocWindow", wxRadioBox)->GetSelection());
 
258
 
 
259
    cfg->Write(_T("/ainsert_enable"), (bool)!XRCCTRL(*this, "cbAIDisable", wxCheckBox)->GetValue());
 
260
    ReadAIChoice();
 
261
    m_AInsert.WriteAIOptions();
 
262
 
 
263
    m_pNativeParser->RereadOptions();
 
264
    m_pFortranProject->RereadOptions();
 
265
}