1
/***************************************************************
3
* Purpose: ThreadSearch Code::Blocks plugin
4
* Most of the interactions with C::B are handled here.
5
* Author: Jerome ANTOINE
7
* Copyright: Jerome ANTOINE
9
**************************************************************/
11
#ifndef THREAD_SEARCH_H
12
#define THREAD_SEARCH_H
14
#include <wx/string.h>
15
#include <wx/splitter.h>
17
#include <cbplugin.h> // for "class cbPlugin"
18
#include <globals.h> // for "ModuleType"
20
#include "ThreadSearchFindData.h"
21
#include "ThreadSearchViewManagerBase.h"
22
#include "ThreadSearchLoggerBase.h"
23
#include "InsertIndexManager.h"
24
#include "codesnippetsevent.h"
35
class wxUpdateUIEvent;
38
class cbConfigurationPanel;
41
class ThreadSearchView;
42
class SnipSearchAppFrame;
45
// ----------------------------------------------------------------------------
46
class ThreadSearch : public cbPlugin
47
// ----------------------------------------------------------------------------
49
friend class ThreadSearchFrame;
56
ThreadSearch(wxWindow* parent);
59
virtual ~ThreadSearch();
61
/** Invoke configuration dialog. */
62
virtual int Configure();
64
/** Return the plugin's configuration priority.
65
* This is a number (default is 50) that is used to sort plugins
66
* in configuration dialogs. Lower numbers mean the plugin's
67
* configuration is put higher in the list.
69
virtual int GetConfigurationPriority() const { return 50; }
71
/** Return the configuration group for this plugin. Default is cgUnknown.
72
* Notice that you can logically OR more than one configuration groups,
73
* so you could set it, for example, as "cgCompiler | cgContribPlugin".
75
virtual int GetConfigurationGroup() const { return cgContribPlugin; }
77
/** Return plugin's configuration panel.
78
* @param parent The parent window.
79
* @return A pointer to the plugin's cbConfigurationPanel. It is deleted by the caller.
81
virtual cbConfigurationPanel* GetConfigurationPanel(wxWindow* parent);
83
/** Return plugin's configuration panel for projects.
84
* The panel returned from this function will be added in the project's
85
* configuration dialog.
86
* @param parent The parent window.
87
* @param project The project that is being edited.
88
* @return A pointer to the plugin's cbConfigurationPanel. It is deleted by the caller.
90
virtual cbConfigurationPanel* GetProjectConfigurationPanel(wxWindow* WXUNUSED(parent), cbProject* WXUNUSED(project)){ return 0; }
92
/** This method is called by Code::Blocks and is used by the plugin
93
* to add any menu items it needs on Code::Blocks's menu bar.\n
94
* It is a pure virtual method that needs to be implemented by all
95
* plugins. If the plugin does not need to add items on the menu,
97
* @param menuBar the wxMenuBar to create items in
99
virtual void BuildMenu(wxMenuBar* menuBar);
101
/** This method is called by Code::Blocks core modules (EditorManager,
102
* ProjectManager etc) and is used by the plugin to add any menu
103
* items it needs in the module's popup menu. For example, when
104
* the user right-clicks on a project file in the project tree,
105
* ProjectManager prepares a popup menu to display with context
106
* sensitive options for that file. Before it displays this popup
107
* menu, it asks all attached plugins (by asking PluginManager to call
108
* this method), if they need to add any entries
109
* in that menu. This method is called.\n
110
* If the plugin does not need to add items in the menu,
112
* @param type the module that's preparing a popup menu
113
* @param menu pointer to the popup menu
114
* @param data pointer to FileTreeData object (to access/modify the file tree)
116
virtual void BuildModuleMenu(const ModuleType type, wxMenu* pMenu, const FileTreeData* data = 0);
118
/** This method is called by Code::Blocks and is used by the plugin
119
* to add any toolbar items it needs on Code::Blocks's toolbar.\n
120
* It is a pure virtual method that needs to be implemented by all
121
* plugins. If the plugin does not need to add items on the toolbar,
123
* @param toolBar the wxToolBar to create items on
124
* @return The plugin should return true if it needed the toolbar, false if not
126
virtual bool BuildToolBar(wxToolBar* toolBar);
128
/** This method is called to update observers.
129
* The pattern has not been implemented as there is only one observer
130
* (the ThreadSearchView) that already holds a reference on the plugin.
135
void SetCtxMenuIntegration(bool ctxMenuIntegration) {m_CtxMenuIntegration = ctxMenuIntegration;}
136
void SetUseDefValsForThreadSearch(bool useDefVals) {m_UseDefValsForThreadSearch = useDefVals;}
137
void SetShowSearchControls(bool showSearchControls) {m_ShowSearchControls = showSearchControls;}
138
void SetShowDirControls(bool showDirControls) {m_ShowDirControls = showDirControls;}
139
void SetShowCodePreview(bool showCodePreview) {m_ShowCodePreview = showCodePreview;}
140
void SetDisplayLogHeaders(bool displayLogHeaders) {m_DisplayLogHeaders = displayLogHeaders;}
141
void SetDrawLogLines(bool drawLogLines) {m_DrawLogLines = drawLogLines;}
142
void SetFindData(const ThreadSearchFindData& findData) {m_FindData = findData;}
144
void SetManagerType (ThreadSearchViewManagerBase::eManagerTypes mgrType);
145
void SetLoggerType (ThreadSearchLoggerBase::eLoggerTypes lgrType) {m_LoggerType = lgrType;}
146
void SetSplitterMode(wxSplitMode splitterMode) {m_SplitterMode = splitterMode;}
147
void SetFileSorting (InsertIndexManager::eFileSorting fileSorting) {m_FileSorting = fileSorting;}
150
bool GetCtxMenuIntegration() const {return m_CtxMenuIntegration;}
151
bool GetUseDefValsForThreadSearch() const {return m_UseDefValsForThreadSearch;}
152
bool GetShowSearchControls() const {return m_ShowSearchControls;}
153
bool GetShowDirControls() const {return m_ShowDirControls;}
154
bool GetShowCodePreview() const {return m_ShowCodePreview;}
155
bool GetDisplayLogHeaders() const {return m_DisplayLogHeaders;}
156
bool GetDrawLogLines() const {return m_DrawLogLines;}
157
void GetFindData(ThreadSearchFindData& findData) const {findData = m_FindData;}
158
ThreadSearchFindData& GetFindData() {return m_FindData;}
159
ThreadSearchViewManagerBase::eManagerTypes GetManagerType() const {return m_pViewManager->GetManagerType();}
160
ThreadSearchLoggerBase::eLoggerTypes GetLoggerType() const {return m_LoggerType;}
161
long GetSplitterMode() const {return m_SplitterMode;}
162
InsertIndexManager::eFileSorting GetFileSorting() const {return m_FileSorting;}
163
wxString GetCodeSnippetsIndex(){return m_CodeSnippetsIndexFilename;}
164
void SplitThreadSearchWindow();
165
void UnsplitThreadSearchWindow();
166
void ResetNotebookSashPosition();
167
void UserResizingWindow(wxSizeEvent &event);
169
/** This method runs a threaded search for text param.
170
* @param text : text to look after
171
* @param isCtxSearch : bool that tells if it is a ctx search
172
* to set, if necessary, the default ctx search options
174
void RunThreadSearch(const wxString& text, bool isCtxSearch = false);
176
/** This method is a callback called by ThreadSearchView destructor.
177
* Either view is destroyed by C::B InfoPane if plugin is used in
178
* the Messages Notebook or by plugin instance if view is not displayed
179
* or used in the layout.
181
void OnThreadSearchViewDestruction();
183
/** This method shows/hide the ThreadSearch toolbar.
184
* @param show : show = true/hide = false toolbar
186
void ShowToolBar(bool show);
188
/** Method used to know is toolbar is visible. */
189
bool IsToolbarVisible();
191
//wxLogWindow* m_pLog; //(pecan 2007/7/26)
192
//wxWindow* m_pAppWindow;
193
wxFont m_Conf_font; //(pecan 2008/3/06)
194
wxBoxSizer* m_pMainSizer;
195
MainPanel* m_pMainPanel;
196
wxSplitterWindow* m_pMainSplitter;
197
//-wxTextCtrl* m_pText;
198
cbAuiNotebook* m_pEdNotebook;
199
wxWindow* m_pThreadSearchViewParentBak;
200
wxWindow* m_pEdNotebookParentBak;
201
wxWindow* m_pParent; //parent window/frame //(pecan 2008/4/03)
202
bool m_bSashWindowResizing; // Resizing ThreadSearchFrame
205
/** Any descendent plugin should override this virtual method and
206
* perform any necessary initialization. This method is called by
207
* Code::Blocks (PluginManager actually) when the plugin has been
208
* loaded and should attach in Code::Blocks. When Code::Blocks
209
* starts up, it finds and <em>loads</em> all plugins but <em>does
210
* not</em> activate (attaches) them. It then activates all plugins
211
* that the user has selected to be activated on start-up.\n
212
* This means that a plugin might be loaded but <b>not</b> activated...\n
213
* Think of this method as the actual constructor...
215
virtual void OnAttach();
217
/** Any descendent plugin should override this virtual method and
218
* perform any necessary de-initialization. This method is called by
219
* Code::Blocks (PluginManager actually) when the plugin has been
220
* loaded, attached and should de-attach from Code::Blocks.\n
221
* Think of this method as the actual destructor...
222
* @param appShutDown If true, the application is shutting down. In this
223
* case *don't* use Manager::Get()->Get...() functions or the
224
* behaviour is undefined...
226
virtual void OnRelease(bool appShutDown);
228
/** This method loads the plugin configuration from default.conf using
229
* the standard ConfigManager
230
* @param showPanel : reference that will be true after the call if
231
* the panel is managed by the MessageManager during last save.
232
* @param sashPosition : position of the splitter window.
233
* @param mgrType : type of view manager (Messages notebook, layout)
235
virtual void LoadConfig(bool &showPanel, int &sashPosition,
236
ThreadSearchViewManagerBase::eManagerTypes& mgrType,
237
wxArrayString& searchPatterns);
239
/** This method saves the plugin configuration to default.conf using
240
* the standard ConfigManager
241
* @param ShowPanel : boolean telling if ThreadSearch panel is managed
242
* by the MessageManager.
243
* @param sashPosition : position of the splitter window.
244
* @param mgrType : Type of view manager (Messages notebook, layout)
246
virtual void SaveConfig(bool showPanel, int sashPosition,
247
ThreadSearchViewManagerBase::eManagerTypes mgrType,
248
const wxArrayString& searchPatterns);
251
/** Event handler called when user clicks on the 'Thread search'
252
* item of the 'View' menu.
254
void OnMnuViewThreadSearch(wxCommandEvent& event);
256
/** Event handler called when user clicks on the 'Thread Search'
257
* item of the 'Search' menu.
259
void OnMnuSearchThreadSearch(wxCommandEvent& event);
261
/** Event handler called when user clicks on the 'Find occurrences of'
262
* item of the contextual menu.
264
void OnCtxThreadSearch(wxCommandEvent& event);
266
/** Event handler called to update the 'Thread search'
267
* item of the View menu. Checked if 'Thread search' panel
268
* is present in the message notebook.
270
void OnMnuViewThreadSearchUpdateUI(wxUpdateUIEvent& event);
272
/** Event handler called to update the 'Thread search'
273
* item of the 'Search' menu.
275
void OnMnuSearchThreadSearchUpdateUI(wxUpdateUIEvent& event);
277
// Toolbar controls events management
278
void OnBtnOptionsClick(wxCommandEvent& event);
279
void OnBtnSearchClick (wxCommandEvent& event);
280
void OnCboSearchExprEnter(wxCommandEvent &event);
282
/** Removes the 'Thread search' item added in BuildMenu method.
284
void RemoveMenuItems();
286
/** Internal Method refactored from BuildMenu
288
//-static bool GetCursorWord(wxString& sWord);
289
bool GetCursorWord(wxString& sWord);
291
/** Adds the 'Find occurrences of' at the right place, ie just after
292
* the 'Find implementation' item if possible
294
int GetInsertionMenuIndex(const wxMenu* const pCtxMenu);
296
// The following method are there to make it possible to copy
297
// and paste from and to view graphical widgets.
298
void OnMnuEditCopy(wxCommandEvent& event);
299
void OnMnuEditCopyUpdateUI(wxUpdateUIEvent& event);
300
void OnMnuEditPaste(wxCommandEvent& event);
302
void OnSashPositionChanged(wxSplitterEvent& event);
303
void OnIdle(wxIdleEvent& event);
304
void OnCodeSnippetsNewIndex(CodeSnippetsEvent& event);
307
wxString m_SearchedWord; // Word under cursor on right click
308
ThreadSearchFindData m_FindData; // Search structure containing all useful inforamtions
309
ThreadSearchView* m_pThreadSearchView; // Panel added to Messages notebook
310
ThreadSearchViewManagerBase* m_pViewManager; // View manager. Used to add, remove, show and hide view.
311
// Used on a derived class (message notebook or layout manager).
312
wxToolBar* m_pToolbar; // Panel added to Messages notebook
313
bool m_CtxMenuIntegration; // Tells if 'Find occurrences' item must be present in contextual menu
314
bool m_UseDefValsForThreadSearch; // Tells if default values (whole word = true, match case = true)
315
// are used for 'Find occurrences' ctx menu command
316
bool m_ShowSearchControls; // True if user wants to use message tab controls
317
bool m_ShowDirControls; // True if user wants to display directory specific controls
318
bool m_ShowCodePreview; // True if user wants to benefit from code preview
319
ThreadSearchLoggerBase::eLoggerTypes m_LoggerType; // Logger type, can be a list or a tree
320
bool m_DisplayLogHeaders; // Show/Hide column headers in wxListCtrl logger
321
bool m_DrawLogLines; // Draw lines between columns in wxListCtrl logger
322
bool m_OnReleased; // For multiple simultaneous calls of OnRelease
323
wxComboBox* m_pCboSearchExpr;
324
wxSplitMode m_SplitterMode; // Sets vertical or horizontal display for code
325
// preview and search results (logger)
326
InsertIndexManager::eFileSorting m_FileSorting; // Sorts file by name or by path
328
bool m_bSashPositionChanged; // Last postion of editor notebook sash
329
int m_EdNotebookSashPosition;
330
wxString m_CodeSnippetsIndexFilename; // CodeSnippets Index XML filename
332
DECLARE_EVENT_TABLE();
335
#endif // THREAD_SEARCH_H