1
/***************************************************************
2
* Name: ThreadSearchConfPanel
3
* Purpose: This class implements the configuration panel used
4
* in modal dialog called on "Options" button click
5
* and by C::B on "Environment" settings window.
6
* Author: Jerome ANTOINE
8
* Copyright: Jerome ANTOINE
10
**************************************************************/
12
#include <sdk.h> // Code::Blocks SDK
14
#include <wx/checkbox.h>
15
#include <wx/radiobox.h>
17
#include <wx/statbox.h>
18
#include <wx/stattext.h>
21
#include "ThreadSearch.h"
22
#include "SearchInPanel.h"
23
#include "DirectoryParamsPanel.h"
24
#include "ThreadSearchConfPanel.h"
25
#include "ThreadSearchControlIds.h"
26
#include "ThreadSearchViewManagerBase.h"
27
#include "ThreadSearchFindData.h"
28
#include "InsertIndexManager.h"
30
// begin wxGlade: ::extracode
35
ThreadSearchConfPanel::ThreadSearchConfPanel(ThreadSearch& threadSearchPlugin, wxWindow* parent,wxWindowID id)
36
:m_ThreadSearchPlugin(threadSearchPlugin)
38
Create(parent,id,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL);
40
// begin wxGlade: ThreadSearchConfPanel::ThreadSearchConfPanel
41
SizerOptions_staticbox = new wxStaticBox(this, -1, wxT("Options"));
42
SizerThreadSearchOptions_staticbox = new wxStaticBox(this, -1, wxT("Thread search options"));
43
SizerThreadSearchLayoutGlobal_staticbox = new wxStaticBox(this, -1, wxT("Show/Hide"));
44
SizerListControlOptions_staticbox = new wxStaticBox(this, -1, wxT("List control options"));
45
SizerThreadSearchLayout_staticbox = new wxStaticBox(this, -1, wxT("Layout"));
46
SizerSearchIn_staticbox = new wxStaticBox(this, -1, wxT("Search in"));
47
m_pPnlSearchIn = new SearchInPanel(this, wxID_ANY);
48
m_pPnlDirParams = new DirectoryParamsPanel(this, wxID_ANY);
49
m_pChkWholeWord = new wxCheckBox(this, idChkWholeWord, wxT("Whole word"));
50
m_pChkStartWord = new wxCheckBox(this, idChkStartWord, wxT("Start word"));
51
m_pChkMatchCase = new wxCheckBox(this, idChkMatchCase, wxT("Match case"));
52
m_pChkRegExp = new wxCheckBox(this, idChkRegularExpression, wxT("Regular expression"));
53
m_pChkThreadSearchEnable = new wxCheckBox(this, idChkThreadSearchEnable, wxT("Enable 'Find occurrences' contextual menu item"));
54
m_pChkUseDefaultOptionsForThreadSearch = new wxCheckBox(this, idChkUseDefaultOptionsOnThreadSearch, wxT("Use default options when running 'Find occurrences' "));
55
m_pChkShowThreadSearchToolBar = new wxCheckBox(this, idChkViewThreadSearchToolBar, wxT("Show ThreadSearch toolbar."));
56
m_pChkShowThreadSearchWidgets = new wxCheckBox(this, idChkShowThreadSearchWidgets, wxT("Show search widgets in ThreadSearch Messages panel."));
57
m_pChkShowCodePreview = new wxCheckBox(this, idChkShowCodePreview, wxT("Show code preview editor."));
58
m_pChkDisplayLogHeaders = new wxCheckBox(this, idChkDisplayLogHeaders, wxT("Display header in log window."));
59
m_pChkDrawLogLines = new wxCheckBox(this, idChkDrawLogLines, wxT("Draw lines between log columns."));
60
const wxString m_pRadPanelManagement_choices[] = {
61
wxT("Messages notebook"),
64
m_pRadPanelManagement = new wxRadioBox(this, wxID_ANY, wxT("ThreadSearch panel management by"), wxDefaultPosition, wxDefaultSize, 2, m_pRadPanelManagement_choices, 1, wxRA_SPECIFY_ROWS);
65
const wxString m_pRadLoggerType_choices[] = {
69
m_pRadLoggerType = new wxRadioBox(this, wxID_ANY, wxT("Logger type"), wxDefaultPosition, wxDefaultSize, 2, m_pRadLoggerType_choices, 1, wxRA_SPECIFY_ROWS);
70
const wxString m_pRadSplitterWndMode_choices[] = {
74
m_pRadSplitterWndMode = new wxRadioBox(this, wxID_ANY, wxT("Splitter window mode"), wxDefaultPosition, wxDefaultSize, 2, m_pRadSplitterWndMode_choices, 1, wxRA_SPECIFY_ROWS);
75
const wxString m_pRadSortBy_choices[] = {
79
m_pRadSortBy = new wxRadioBox(this, wxID_ANY, wxT("Sort results by"), wxDefaultPosition, wxDefaultSize, 2, m_pRadSortBy_choices, 1, wxRA_SPECIFY_ROWS);
87
BEGIN_EVENT_TABLE(ThreadSearchConfPanel, wxPanel)
88
// begin wxGlade: ThreadSearchConfPanel::event_table
89
EVT_CHECKBOX(idChkThreadSearchEnable, ThreadSearchConfPanel::OnThreadSearchEnable)
90
EVT_CHECKBOX(idChkViewThreadSearchToolBar, ThreadSearchConfPanel::OnChkShowThreadSearchToolBarClick)
91
EVT_CHECKBOX(idChkShowCodePreview, ThreadSearchConfPanel::OnChkCodePreview)
92
EVT_CHECKBOX(idChkShowThreadSearchWidgets, ThreadSearchConfPanel::OnChkShowThreadSearchWidgetsClick)
97
void ThreadSearchConfPanel::OnThreadSearchEnable(wxCommandEvent &event)
99
m_pChkUseDefaultOptionsForThreadSearch->Enable(event.IsChecked());
104
void ThreadSearchConfPanel::OnChkShowThreadSearchToolBarClick(wxCommandEvent &event)
106
if ( (event.IsChecked() == false) && (m_pChkShowThreadSearchWidgets->GetValue() == false) )
108
if ( wxID_YES != cbMessageBox(wxT("Do you really want to hide both ThreadSearch toolbar and widgets ?"),
109
wxT("Sure ?"), wxICON_QUESTION|wxYES_NO) )
111
m_pChkShowThreadSearchToolBar->SetValue(true);
118
void ThreadSearchConfPanel::OnChkCodePreview(wxCommandEvent &event)
120
m_pRadSplitterWndMode->Enable(event.IsChecked());
125
void ThreadSearchConfPanel::OnChkShowThreadSearchWidgetsClick(wxCommandEvent &event)
127
if ( (event.IsChecked() == false) && (m_pChkShowThreadSearchToolBar->GetValue() == false) )
129
if ( wxID_YES != cbMessageBox(wxT("Do you really want to hide both ThreadSearch toolbar and widgets ?"),
130
wxT("Sure ?"), wxICON_QUESTION|wxYES_NO) )
132
m_pChkShowThreadSearchWidgets->SetValue(true);
139
// wxGlade: add ThreadSearchConfPanel event handlers
142
void ThreadSearchConfPanel::set_properties()
144
// begin wxGlade: ThreadSearchConfPanel::set_properties
145
m_pChkWholeWord->SetToolTip(wxT("Search text matches only whole words"));
146
m_pChkWholeWord->SetValue(1);
147
m_pChkStartWord->SetToolTip(wxT("Matches only word starting with search expression"));
148
m_pChkMatchCase->SetToolTip(wxT("Case sensitive search."));
149
m_pChkMatchCase->SetValue(1);
150
m_pChkRegExp->SetToolTip(wxT("Search expression is a regular expression"));
151
m_pChkThreadSearchEnable->SetValue(1);
152
m_pChkUseDefaultOptionsForThreadSearch->SetValue(1);
153
m_pChkShowThreadSearchToolBar->SetValue(1);
154
m_pChkShowThreadSearchWidgets->SetValue(1);
155
m_pChkShowCodePreview->SetValue(1);
156
m_pChkDisplayLogHeaders->SetValue(1);
157
m_pRadPanelManagement->SetSelection(0);
158
m_pRadLoggerType->SetSelection(0);
159
m_pRadSplitterWndMode->SetSelection(0);
160
m_pRadSortBy->SetSelection(0);
163
ThreadSearchFindData findData;
164
m_ThreadSearchPlugin.GetFindData(findData);
166
m_pChkWholeWord->SetValue(findData.GetMatchWord());
167
m_pChkStartWord->SetValue(findData.GetStartWord());
168
m_pChkMatchCase->SetValue(findData.GetMatchCase());
169
m_pChkRegExp->SetValue(findData.GetRegEx());
170
m_pChkThreadSearchEnable->SetValue(m_ThreadSearchPlugin.GetCtxMenuIntegration());
171
m_pChkUseDefaultOptionsForThreadSearch->SetValue(m_ThreadSearchPlugin.GetUseDefValsForThreadSearch());
172
m_pChkUseDefaultOptionsForThreadSearch->Enable(m_ThreadSearchPlugin.GetCtxMenuIntegration());
173
m_pChkDisplayLogHeaders->SetValue(m_ThreadSearchPlugin.GetDisplayLogHeaders());
174
m_pChkDrawLogLines->SetValue(m_ThreadSearchPlugin.GetDrawLogLines());
175
m_pChkShowThreadSearchToolBar->SetValue(m_ThreadSearchPlugin.IsToolbarVisible());
176
m_pChkShowThreadSearchWidgets->SetValue(m_ThreadSearchPlugin.GetShowSearchControls());
177
m_pChkShowCodePreview->SetValue(m_ThreadSearchPlugin.GetShowCodePreview());
180
switch (m_ThreadSearchPlugin.GetManagerType())
182
case ThreadSearchViewManagerBase::TypeLayout :
188
// case ThreadSearchViewManagerBase::TypeMessagesNotebook :
194
m_pRadPanelManagement->SetSelection(radIndex);
197
switch (m_ThreadSearchPlugin.GetLoggerType())
199
case ThreadSearchLoggerBase::TypeTree:
205
// case ThreadSearchLoggerBase::TypeList :
211
m_pRadLoggerType->SetSelection(radIndex);
214
switch (m_ThreadSearchPlugin.GetSplitterMode())
216
case wxSPLIT_HORIZONTAL:
222
// case wxSPLIT_VERTICAL:
228
m_pRadSplitterWndMode->SetSelection(radIndex);
229
m_pRadSplitterWndMode->Enable(m_ThreadSearchPlugin.GetShowCodePreview());
232
switch (m_ThreadSearchPlugin.GetFileSorting())
234
case InsertIndexManager::SortByFileName:
240
// case ThreadSearch::SortByFilePath :
246
m_pRadSortBy->SetSelection(radIndex);
248
m_pPnlDirParams->SetSearchDirHidden(findData.GetHiddenSearch());
249
m_pPnlDirParams->SetSearchDirRecursively(findData.GetRecursiveSearch());
250
m_pPnlDirParams->SetSearchDirPath(findData.GetSearchPath());
251
m_pPnlDirParams->SetSearchMask(findData.GetSearchMask());
253
m_pPnlSearchIn->SetSearchInOpenFiles(findData.MustSearchInOpenFiles());
254
m_pPnlSearchIn->SetSearchInProjectFiles(findData.MustSearchInProject());
255
m_pPnlSearchIn->SetSearchInWorkspaceFiles(findData.MustSearchInWorkspace());
256
m_pPnlSearchIn->SetSearchInDirectory(findData.MustSearchInDirectory());
260
void ThreadSearchConfPanel::do_layout()
262
// begin wxGlade: ThreadSearchConfPanel::do_layout
263
wxBoxSizer* SizerTop = new wxBoxSizer(wxVERTICAL);
264
wxStaticBoxSizer* SizerThreadSearchLayout = new wxStaticBoxSizer(SizerThreadSearchLayout_staticbox, wxVERTICAL);
265
wxFlexGridSizer* SizerThreadSearchGridLayout = new wxFlexGridSizer(4, 2, 0, 0);
266
wxStaticBoxSizer* SizerListControlOptions = new wxStaticBoxSizer(SizerListControlOptions_staticbox, wxVERTICAL);
267
wxStaticBoxSizer* SizerThreadSearchLayoutGlobal = new wxStaticBoxSizer(SizerThreadSearchLayoutGlobal_staticbox, wxVERTICAL);
268
wxStaticBoxSizer* SizerThreadSearchOptions = new wxStaticBoxSizer(SizerThreadSearchOptions_staticbox, wxVERTICAL);
269
wxStaticBoxSizer* SizerOptions = new wxStaticBoxSizer(SizerOptions_staticbox, wxHORIZONTAL);
270
wxStaticBoxSizer* SizerSearchIn = new wxStaticBoxSizer(SizerSearchIn_staticbox, wxVERTICAL);
271
SizerSearchIn->Add(m_pPnlSearchIn, 0, wxALL|wxEXPAND, 2);
272
SizerSearchIn->Add(m_pPnlDirParams, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 2);
273
SizerTop->Add(SizerSearchIn, 0, wxALL|wxEXPAND, 4);
274
SizerOptions->Add(m_pChkWholeWord, 0, wxALL|wxADJUST_MINSIZE, 4);
275
SizerOptions->Add(m_pChkStartWord, 0, wxALL|wxADJUST_MINSIZE, 4);
276
SizerOptions->Add(m_pChkMatchCase, 0, wxALL|wxADJUST_MINSIZE, 4);
277
SizerOptions->Add(m_pChkRegExp, 0, wxALL|wxADJUST_MINSIZE, 4);
278
SizerTop->Add(SizerOptions, 0, wxALL|wxEXPAND, 4);
279
SizerThreadSearchOptions->Add(m_pChkThreadSearchEnable, 0, wxALL|wxADJUST_MINSIZE, 4);
280
SizerThreadSearchOptions->Add(m_pChkUseDefaultOptionsForThreadSearch, 0, wxALL|wxADJUST_MINSIZE, 4);
281
wxStaticText* m_pStaDefaultOptions = new wxStaticText(this, wxID_ANY, wxT(" ('Whole word' = true, 'Start word' = false, 'Match case' = true, 'Regular expression' = false)"));
282
SizerThreadSearchOptions->Add(m_pStaDefaultOptions, 0, wxADJUST_MINSIZE, 0);
283
SizerTop->Add(SizerThreadSearchOptions, 0, wxALL|wxEXPAND, 4);
284
SizerThreadSearchLayoutGlobal->Add(m_pChkShowThreadSearchToolBar, 0, wxALL|wxADJUST_MINSIZE, 4);
285
SizerThreadSearchLayoutGlobal->Add(m_pChkShowThreadSearchWidgets, 0, wxALL|wxADJUST_MINSIZE, 4);
286
SizerThreadSearchLayoutGlobal->Add(m_pChkShowCodePreview, 0, wxALL|wxADJUST_MINSIZE, 4);
287
SizerThreadSearchGridLayout->Add(SizerThreadSearchLayoutGlobal, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4);
288
SizerListControlOptions->Add(m_pChkDisplayLogHeaders, 0, wxALL|wxADJUST_MINSIZE, 4);
289
SizerListControlOptions->Add(m_pChkDrawLogLines, 0, wxALL|wxADJUST_MINSIZE, 4);
290
SizerThreadSearchGridLayout->Add(SizerListControlOptions, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4);
291
SizerThreadSearchGridLayout->Add(m_pRadPanelManagement, 0, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4);
292
SizerThreadSearchGridLayout->Add(m_pRadLoggerType, 0, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4);
293
SizerThreadSearchGridLayout->Add(m_pRadSplitterWndMode, 0, wxALL|wxEXPAND, 4);
294
SizerThreadSearchGridLayout->Add(m_pRadSortBy, 0, wxALL|wxEXPAND, 4);
295
SizerThreadSearchGridLayout->AddGrowableCol(0);
296
SizerThreadSearchGridLayout->AddGrowableCol(1);
297
SizerThreadSearchLayout->Add(SizerThreadSearchGridLayout, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 0);
298
SizerTop->Add(SizerThreadSearchLayout, 0, wxALL|wxEXPAND, 4);
302
SizerTop->SetSizeHints(this);
307
void ThreadSearchConfPanel::OnApply()
309
ThreadSearchFindData findData;
311
// Inits variable data from user values
312
findData.SetFindText (wxEmptyString);
313
findData.SetHiddenSearch (m_pPnlDirParams->GetSearchDirHidden());
314
findData.SetRecursiveSearch(m_pPnlDirParams->GetSearchDirRecursively());
315
findData.SetSearchPath (m_pPnlDirParams->GetSearchDirPath());
316
findData.SetSearchMask (m_pPnlDirParams->GetSearchMask());
317
findData.SetMatchWord (m_pChkWholeWord->IsChecked());
318
findData.SetStartWord (m_pChkStartWord->IsChecked());
319
findData.SetMatchCase (m_pChkMatchCase->IsChecked());
320
findData.SetRegEx (m_pChkRegExp->IsChecked());
322
findData.UpdateSearchScope(ScopeOpenFiles, m_pPnlSearchIn->GetSearchInOpenFiles());
323
findData.UpdateSearchScope(ScopeProjectFiles, m_pPnlSearchIn->GetSearchInProjectFiles());
324
findData.UpdateSearchScope(ScopeWorkspaceFiles, m_pPnlSearchIn->GetSearchInWorkspaceFiles());
325
findData.UpdateSearchScope(ScopeDirectoryFiles, m_pPnlSearchIn->GetSearchInDirectory());
327
// Updates plug-in with new datas
328
m_ThreadSearchPlugin.SetFindData(findData);
329
m_ThreadSearchPlugin.SetCtxMenuIntegration(m_pChkThreadSearchEnable->IsChecked());
330
m_ThreadSearchPlugin.SetUseDefValsForThreadSearch(m_pChkUseDefaultOptionsForThreadSearch->IsChecked());
331
m_ThreadSearchPlugin.SetShowSearchControls(m_pChkShowThreadSearchWidgets->IsChecked());
332
m_ThreadSearchPlugin.SetShowCodePreview(m_pChkShowCodePreview->IsChecked());
333
m_ThreadSearchPlugin.SetDisplayLogHeaders(m_pChkDisplayLogHeaders->IsChecked());
334
m_ThreadSearchPlugin.SetDrawLogLines(m_pChkDrawLogLines->IsChecked());
336
int radIndex = m_pRadPanelManagement->GetSelection();
337
ThreadSearchViewManagerBase::eManagerTypes mgrType;
342
mgrType = ThreadSearchViewManagerBase::TypeLayout;
348
mgrType = ThreadSearchViewManagerBase::TypeMessagesNotebook;
352
m_ThreadSearchPlugin.SetManagerType(mgrType);
354
radIndex = m_pRadLoggerType->GetSelection();
355
ThreadSearchLoggerBase::eLoggerTypes lgrType;
360
lgrType = ThreadSearchLoggerBase::TypeTree;
366
lgrType = ThreadSearchLoggerBase::TypeList;
370
m_ThreadSearchPlugin.SetLoggerType(lgrType);
372
radIndex = m_pRadSortBy->GetSelection();
373
InsertIndexManager::eFileSorting sortingType;
378
sortingType = InsertIndexManager::SortByFileName;
384
sortingType = InsertIndexManager::SortByFilePath;
388
m_ThreadSearchPlugin.SetFileSorting(sortingType);
390
radIndex = m_pRadSplitterWndMode->GetSelection();
391
wxSplitMode splitterMode;
396
splitterMode = wxSPLIT_VERTICAL;
402
splitterMode = wxSPLIT_HORIZONTAL;
406
m_ThreadSearchPlugin.SetSplitterMode(splitterMode);
408
// Updates toolbar visibility
409
m_ThreadSearchPlugin.ShowToolBar(m_pChkShowThreadSearchToolBar->IsChecked());
411
// Notifies plug-in observers (ThreadSearchView)
412
m_ThreadSearchPlugin.Notify();