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

« back to all changes in this revision

Viewing changes to src/plugins/contrib/codesnippets/Search/ThreadSearchView.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:      ThreadSearchView
 
3
 * Purpose:   This class implements the panel that is added to
 
4
 *            Code::Blocks Message notebook or layout.
 
5
 *            It runs the search worker thread and receives
 
6
 *            ThreadSearchEvent from it to update the list log.
 
7
 * Author:    Jerome ANTOINE
 
8
 * Created:   2007-10-08
 
9
 * Copyright: Jerome ANTOINE
 
10
 * License:   GPL
 
11
 **************************************************************/
 
12
 
 
13
#ifndef THREAD_SEARCH_VIEW_H
 
14
#define THREAD_SEARCH_VIEW_H
 
15
 
 
16
#include <wx/string.h>
 
17
#include <wx/thread.h>
 
18
#include <wx/timer.h>
 
19
#include <wx/dynarray.h>
 
20
#include <wx/datetime.h>
 
21
#include <wx/panel.h>
 
22
#include <wx/arrstr.h>
 
23
 
 
24
#include "editormanager.h"
 
25
#include "cbproject.h"
 
26
#include "projectmanager.h"
 
27
 
 
28
#include "ThreadSearchLoggerBase.h"
 
29
 
 
30
class wxToolBar;
 
31
class wxStaticBox;
 
32
class wxComboBox;
 
33
class wxButton;
 
34
class wxStaticText;
 
35
class cbStyledTextCtrl;
 
36
class wxPanel;
 
37
class wxMouseEvent;
 
38
class wxCommandEvent;
 
39
class wxSplitterEvent;
 
40
class wxScintillaEvent;
 
41
class wxContextMenuEvent;
 
42
class wxSplitterWindow;
 
43
class wxStaticBoxSizer;
 
44
class wxBoxSizer;
 
45
 
 
46
class ThreadSearch;
 
47
class ThreadSearchEvent;
 
48
class ThreadSearchThread;
 
49
class ThreadSearchFindData;
 
50
class SearchInPanel;
 
51
class DirectoryParamsPanel;
 
52
 
 
53
 
 
54
class ThreadSearchView: public wxPanel {
 
55
 
 
56
    friend class ThreadSearch;
 
57
public:
 
58
    // begin wxGlade: ThreadSearchView::ids
 
59
    // end wxGlade
 
60
 
 
61
        /** Constructor. */
 
62
    ThreadSearchView( ThreadSearch& threadSearchPlugin);
 
63
 
 
64
    /** Destructor. */
 
65
    ~ThreadSearchView();
 
66
 
 
67
        virtual void Clear();
 
68
 
 
69
        /** Runs the worker thread search.
 
70
          * @param aFindData : structure containing all search parameters :
 
71
          *                    text, whole word, case, directory...
 
72
          */
 
73
        void ThreadedSearch(const ThreadSearchFindData& aFindData);
 
74
 
 
75
        /** No comment
 
76
          * @return true if a search is running, false otherwise
 
77
          */
 
78
        bool IsSearchRunning();
 
79
 
 
80
        /** This function is called from ThreadSearchThread::OnExit.
 
81
          * This must not be called directly.
 
82
          */
 
83
        void OnThreadExit();
 
84
 
 
85
        /** Makes instance update its graphical widgets.
 
86
          * Should be called by ThreadSearch instance after m_ThreadSearchPlugin modification
 
87
          */
 
88
        void Update();
 
89
 
 
90
        /** Loads file in code preview and makes line visible.
 
91
          * @param file : file path
 
92
          * @param line : line to display in the preview editor
 
93
          * @return true if success
 
94
          */
 
95
        bool UpdatePreview(const wxString& file, long line);
 
96
 
 
97
        /** Sets/gets the splitter window sash position. */
 
98
        void SetSashPosition(int position, const bool redraw = true);
 
99
        int  GetSashPosition() const;
 
100
 
 
101
        /** Sets/gets the search history */
 
102
        void          SetSearchHistory(const wxArrayString& searchPatterns);
 
103
        wxArrayString GetSearchHistory() const;
 
104
 
 
105
        /** SetLoggerType
 
106
          * Sets the logger type. If value is different from current one,
 
107
          * m_pLogger is destroyed and rebuilt on the fly.
 
108
          * @param lgrType : type of logger, can be a wxListCtrl or a wxTreeCtrl
 
109
          */
 
110
        void SetLoggerType(ThreadSearchLoggerBase::eLoggerTypes lgrType);
 
111
 
 
112
        /** PostThreadSearchEvent
 
113
          * @param event : event sent by the worker thread (ThreadSearchThread)
 
114
          * Thread safe mechanism. Clone the worker thread event to the mutex protected events array.
 
115
          */
 
116
        void PostThreadSearchEvent(const ThreadSearchEvent& event);
 
117
 
 
118
        /** SetToolBar
 
119
          * C::B plugins manager provides a toolbar instance to ThreadSearch instance
 
120
          * during init. This instance is referenced in ThreadSearchView by m_pToolBar.
 
121
          */
 
122
        void SetToolBar(wxToolBar* pToolBar) {m_pToolBar = pToolBar;}
 
123
 
 
124
        /** This method shows/hide the search graphical controls.
 
125
          * @param show : show = true/hide = false toolbar
 
126
          */
 
127
        void ShowSearchControls(bool show);
 
128
 
 
129
        /** This method applies splitter settings
 
130
          * @param showCodePreview : show = true/hide = false preview editor (=~ splitted or not)
 
131
          * @param splitterMode : wxSPLIT_HORIZONTAL or wxSPLIT_VERTICAL
 
132
          */
 
133
        void ApplySplitterSettings(bool showCodePreview, long splitterMode);
 
134
    ThreadSearch* GetThreadSearchPlugin(){return &m_ThreadSearchPlugin;}   //(pecan 2008/4/11)
 
135
 
 
136
private:
 
137
    // begin wxGlade: ThreadSearchView::methods
 
138
    void set_properties();
 
139
    void do_layout();
 
140
    // end wxGlade
 
141
 
 
142
        /** ClearThreadSearchEventsArray
 
143
          * Removes all events sent by the worker thread and stored in the array.
 
144
          * Thread safe method.
 
145
          @return true if clear successful. Not successful if Mutex is not caught.
 
146
          */
 
147
    bool ClearThreadSearchEventsArray();
 
148
 
 
149
    /** StopThread
 
150
      * Called to stop the thread and manage all required operations.
 
151
      * @return true if successful.
 
152
      */
 
153
    bool StopThread();
 
154
 
 
155
    // BEGIN Duplicated from cbeditor.cpp to apply folding options
 
156
        void SetMarkerStyle(int marker, int markerType, wxColor fore, wxColor back);
 
157
        void UnderlineFoldedLines(bool underline);
 
158
        void SetFoldingIndicator(int id);
 
159
        // END Duplicated from cbeditor.cpp to apply folding options
 
160
 
 
161
        ThreadSearchThread* m_pFindThread;             // Worker thread pointer. Must be allocated on the heap.
 
162
        ThreadSearch&       m_ThreadSearchPlugin;      // Thread search plugin reference. 'Subject' in the observer pattern.
 
163
        wxString            m_PreviewFilePath;         // File currently previewed path. Used to avoid reloading files.
 
164
        wxDateTime          m_PreviewFileDate;         // File currently previewed modification time. Used to avoid reloading files.
 
165
 
 
166
        wxMutex             m_MutexSearchEventsArray;  // Mutex used for multi thread access to m_ThreadSearchEventsArray
 
167
        wxArrayPtrVoid      m_ThreadSearchEventsArray; // Used to store events sent by the worker thread.
 
168
        wxTimer             m_Timer;                   // Used for events update
 
169
        long                m_StoppingThread;          // Used not to do more than one thread termination.
 
170
 
 
171
        bool                m_bNotebookSizerSet;       // sizer added for wxAuiNotebook
 
172
        wxWindow*           m_pParent;                 // parent window/frame //(pecan 2008/4/03)
 
173
        wxFrame*            m_pTSFrame;                // ThreadSearchFrame pointer
 
174
 
 
175
protected:
 
176
        // Graphical widgets managed by wxGlade
 
177
    // begin wxGlade: ThreadSearchView::attributes
 
178
    wxStaticBox* m_pSizerSearchDirItems_staticbox;
 
179
    wxComboBox* m_pCboSearchExpr;
 
180
    wxButton* m_pBtnSearch;
 
181
    wxButton* m_pBtnOptions;
 
182
    //?wxStaticText* m_pStaTxtSearchIn;
 
183
    //?SearchInPanel* m_pPnlSearchIn;
 
184
    wxButton* m_pBtnShowDirItems;
 
185
    DirectoryParamsPanel* m_pPnlDirParams;
 
186
    cbStyledTextCtrl* m_pSearchPreview;
 
187
    wxPanel* m_pPnlPreview;
 
188
    ThreadSearchLoggerBase* m_pLogger;
 
189
    wxPanel* m_pPnlListLog;
 
190
    wxSplitterWindow* m_pSplitter;
 
191
    // end wxGlade
 
192
    wxStaticBoxSizer* m_pSizerSearchDirItems;
 
193
    wxBoxSizer*       m_pSizerSearchItems;
 
194
    wxToolBar*        m_pToolBar;
 
195
 
 
196
        DECLARE_EVENT_TABLE()
 
197
 
 
198
        /** AddExpressionToSearchCombos
 
199
          * Inserts expression to search combo in first position.
 
200
          * If expression is already listed, it is removed before insertion.
 
201
          * Used to keep the search history in the combo box.
 
202
          * @param expression : searched text.
 
203
          */
 
204
        void AddExpressionToSearchCombos(const wxString& expression);
 
205
 
 
206
        /// enum defining the possible labels to update Search buttons (view and toolbars)
 
207
        /// Undefined can be used to skip label update
 
208
        enum eSearchButtonLabel {
 
209
                search,
 
210
                cancel,
 
211
                skip
 
212
        };
 
213
 
 
214
        /** UpdateSearchButtons
 
215
          * Updates wxButtons and wxBitmap buttons according to new label.
 
216
          * @param enable : true : enable; false : disable
 
217
          * @param label  : see eSearchButtonLabel declaration
 
218
          */
 
219
        void UpdateSearchButtons(bool enable, eSearchButtonLabel label = skip);
 
220
 
 
221
        /** Method used to enable/disable the graphical widgets related
 
222
          * to search parameters. Disabled when thread is running.
 
223
          * @param enable : true : enable; false : disable
 
224
          */
 
225
        void EnableControls(bool enable);
 
226
 
 
227
public:
 
228
    void OnThreadSearchErrorEvent(const ThreadSearchEvent& event);
 
229
    void OnCboSearchExprEnter(wxCommandEvent &event); // wxGlade: <event_handler>
 
230
    void OnBtnSearchClick(wxCommandEvent &event); // wxGlade: <event_handler>
 
231
    void OnBtnOptionsClick(wxCommandEvent &event); // wxGlade: <event_handler>
 
232
    void OnBtnShowDirItemsClick(wxCommandEvent &event); // wxGlade: <event_handler>
 
233
    void OnSplitterDoubleClick(wxSplitterEvent &event); // wxGlade: <event_handler>
 
234
 
 
235
        void OnMarginClick(wxScintillaEvent& event);
 
236
        void OnContextMenu(wxContextMenuEvent& event);
 
237
    void OnLoggerClick      (const wxString& file, long line);  // Called by ThreadSearchLoggerBase derived instance
 
238
                                                                                                                                // when user clicks on a search result
 
239
    void OnLoggerDoubleClick(const wxString& file, long line);  // Called by ThreadSearchLoggerBase derived instance
 
240
                                                                                                                                // when user double clicks on a search result
 
241
 
 
242
        void OnChkSearchOpenFiles(wxCommandEvent &event);
 
243
        void OnChkSearchSnippetFiles(wxCommandEvent &event);
 
244
        void OnChkSearchWorkspaceFiles(wxCommandEvent &event);
 
245
        void OnChkSearchDirectoryFiles(wxCommandEvent &event);
 
246
        void OnChkSearchDirRecurse(wxCommandEvent &event);
 
247
        void OnChkSearchDirHidden(wxCommandEvent &event);
 
248
 
 
249
        void OnTxtSearchMaskTextEvent(wxCommandEvent &event);
 
250
        void OnTxtSearchDirPathTextEvent(wxCommandEvent &event);
 
251
 
 
252
        void OnTmrListCtrlUpdate(wxTimerEvent& event);
 
253
 
 
254
}; // wxGlade: end class
 
255
 
 
256
 
 
257
#endif // THREAD_SEARCH_VIEW_H