~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/plugins/contrib/codesnippets/Search/ThreadSearch.h

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************
 
2
 * Name:      ThreadSearch
 
3
 * Purpose:   ThreadSearch Code::Blocks plugin
 
4
 *            Most of the interactions with C::B are handled here.
 
5
 * Author:    Jerome ANTOINE
 
6
 * Created:   2007-10-08
 
7
 * Copyright: Jerome ANTOINE
 
8
 * License:   GPL
 
9
 **************************************************************/
 
10
 
 
11
#ifndef THREAD_SEARCH_H
 
12
#define THREAD_SEARCH_H
 
13
 
 
14
#include <wx/string.h>
 
15
#include <wx/splitter.h>
 
16
 
 
17
#include <cbplugin.h> // for "class cbPlugin"
 
18
#include <globals.h> // for "ModuleType"
 
19
 
 
20
#include "ThreadSearchFindData.h"
 
21
#include "ThreadSearchViewManagerBase.h"
 
22
#include "ThreadSearchLoggerBase.h"
 
23
#include "InsertIndexManager.h"
 
24
#include "codesnippetsevent.h"
 
25
 
 
26
class wxBoxSizer;
 
27
class wxWindow;
 
28
class wxMenu;
 
29
class wxMenuBar;
 
30
class wxToolBar;
 
31
class wxLogWindow;
 
32
class wxComboBox;
 
33
class FileTreeData;
 
34
class wxCommandEvent;
 
35
class wxUpdateUIEvent;
 
36
class cbAuiNotebook;
 
37
 
 
38
class cbConfigurationPanel;
 
39
class cbProject;
 
40
 
 
41
class ThreadSearchView;
 
42
class SnipSearchAppFrame;
 
43
class MainPanel;
 
44
 
 
45
// ----------------------------------------------------------------------------
 
46
class ThreadSearch : public cbPlugin
 
47
// ----------------------------------------------------------------------------
 
48
{
 
49
    friend class ThreadSearchFrame;
 
50
 
 
51
private:
 
52
        /** Constructor. */
 
53
        ThreadSearch();
 
54
public:
 
55
        /** Constructor. */
 
56
        ThreadSearch(wxWindow* parent);
 
57
 
 
58
        /** Destructor. */
 
59
        virtual ~ThreadSearch();
 
60
 
 
61
        /** Invoke configuration dialog. */
 
62
        virtual int Configure();
 
63
 
 
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.
 
68
          */
 
69
        virtual int GetConfigurationPriority() const { return 50; }
 
70
 
 
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".
 
74
          */
 
75
        virtual int GetConfigurationGroup() const { return cgContribPlugin; }
 
76
 
 
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.
 
80
          */
 
81
        virtual cbConfigurationPanel* GetConfigurationPanel(wxWindow* parent);
 
82
 
 
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.
 
89
          */
 
90
        virtual cbConfigurationPanel* GetProjectConfigurationPanel(wxWindow* WXUNUSED(parent), cbProject* WXUNUSED(project)){ return 0; }
 
91
 
 
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,
 
96
          * just do nothing ;)
 
97
          * @param menuBar the wxMenuBar to create items in
 
98
          */
 
99
        virtual void BuildMenu(wxMenuBar* menuBar);
 
100
 
 
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,
 
111
          * just do nothing ;)
 
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)
 
115
          */
 
116
        virtual void BuildModuleMenu(const ModuleType type, wxMenu* pMenu, const FileTreeData* data = 0);
 
117
 
 
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,
 
122
          * just do nothing ;)
 
123
          * @param toolBar the wxToolBar to create items on
 
124
          * @return The plugin should return true if it needed the toolbar, false if not
 
125
          */
 
126
        virtual bool BuildToolBar(wxToolBar* toolBar);
 
127
 
 
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.
 
131
          */
 
132
        void Notify();
 
133
 
 
134
        // Setters
 
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;}
 
143
 
 
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;}
 
148
 
 
149
        // Getters
 
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);
 
168
 
 
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
 
173
          */
 
174
        void RunThreadSearch(const wxString& text, bool isCtxSearch = false);
 
175
 
 
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.
 
180
          */
 
181
        void OnThreadSearchViewDestruction();
 
182
 
 
183
        /** This method shows/hide the ThreadSearch toolbar.
 
184
          * @param show : show = true/hide = false toolbar
 
185
          */
 
186
        void ShowToolBar(bool show);
 
187
 
 
188
        /** Method used to know is toolbar is visible. */
 
189
        bool IsToolbarVisible();
 
190
 
 
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
 
203
 
 
204
protected:
 
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...
 
214
          */
 
215
        virtual void OnAttach();
 
216
 
 
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...
 
225
          */
 
226
        virtual void OnRelease(bool appShutDown);
 
227
 
 
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)
 
234
          */
 
235
        virtual void LoadConfig(bool &showPanel, int &sashPosition,
 
236
                                                        ThreadSearchViewManagerBase::eManagerTypes& mgrType,
 
237
                                                        wxArrayString& searchPatterns);
 
238
 
 
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)
 
245
          */
 
246
        virtual void SaveConfig(bool showPanel, int sashPosition,
 
247
                                                        ThreadSearchViewManagerBase::eManagerTypes mgrType,
 
248
                                                        const wxArrayString& searchPatterns);
 
249
 
 
250
private:
 
251
        /** Event handler called when user clicks on the 'Thread search'
 
252
          * item of the 'View' menu.
 
253
          */
 
254
        void OnMnuViewThreadSearch(wxCommandEvent& event);
 
255
 
 
256
        /** Event handler called when user clicks on the 'Thread Search'
 
257
          * item of the 'Search' menu.
 
258
          */
 
259
        void OnMnuSearchThreadSearch(wxCommandEvent& event);
 
260
 
 
261
        /** Event handler called when user clicks on the 'Find occurrences of'
 
262
          * item of the contextual menu.
 
263
          */
 
264
        void OnCtxThreadSearch(wxCommandEvent& event);
 
265
 
 
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.
 
269
          */
 
270
        void OnMnuViewThreadSearchUpdateUI(wxUpdateUIEvent& event);
 
271
 
 
272
        /** Event handler called to update the 'Thread search'
 
273
          * item of the 'Search' menu.
 
274
          */
 
275
        void OnMnuSearchThreadSearchUpdateUI(wxUpdateUIEvent& event);
 
276
 
 
277
        // Toolbar controls events management
 
278
        void OnBtnOptionsClick(wxCommandEvent& event);
 
279
        void OnBtnSearchClick (wxCommandEvent& event);
 
280
        void OnCboSearchExprEnter(wxCommandEvent &event);
 
281
 
 
282
        /** Removes the 'Thread search' item added in BuildMenu method.
 
283
          */
 
284
        void RemoveMenuItems();
 
285
 
 
286
        /** Internal Method refactored from BuildMenu
 
287
          */
 
288
        //-static bool GetCursorWord(wxString& sWord);
 
289
        bool GetCursorWord(wxString& sWord);
 
290
 
 
291
        /** Adds the 'Find occurrences of' at the right place, ie just after
 
292
          * the 'Find implementation' item if possible
 
293
          */
 
294
        int GetInsertionMenuIndex(const wxMenu* const pCtxMenu);
 
295
 
 
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);
 
301
 
 
302
    void OnSashPositionChanged(wxSplitterEvent& event);
 
303
    void OnIdle(wxIdleEvent& event);
 
304
    void OnCodeSnippetsNewIndex(CodeSnippetsEvent& event);
 
305
 
 
306
        // Member variables
 
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
 
327
 
 
328
    bool                                 m_bSashPositionChanged;      // Last postion of editor notebook sash
 
329
    int                                  m_EdNotebookSashPosition;
 
330
    wxString                             m_CodeSnippetsIndexFilename; // CodeSnippets Index XML filename
 
331
 
 
332
        DECLARE_EVENT_TABLE();
 
333
};
 
334
 
 
335
#endif // THREAD_SEARCH_H