~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmithSTC/stedit/include/wx/stedit/stenoteb.h

  • 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
// Name:        stenoteb.h
 
3
// Purpose:     wxSTEditorNotebook
 
4
// Author:      John Labenski, parts taken from wxGuide by Otto Wyss
 
5
// Modified by:
 
6
// Created:     11/05/2002
 
7
// Copyright:   (c) John Labenski, Otto Wyss
 
8
// Licence:     wxWidgets licence
 
9
///////////////////////////////////////////////////////////////////////////////
 
10
 
 
11
/// @file stenoteb.h
 
12
/// @brief wxSTEditorNotebook, a wxNotebook for managing wxSTEditorSplitters.
 
13
 
 
14
#ifndef _STENOTEB_H_
 
15
#define _STENOTEB_H_
 
16
 
 
17
#include <wx/notebook.h>
 
18
#include "wx/stedit/stedefs.h"
 
19
 
 
20
class WXDLLIMPEXP_FWD_STEDIT wxArrayFileName;
 
21
class WXDLLIMPEXP_FWD_STEDIT wxSTEditorTreeCtrl;
 
22
 
 
23
//-----------------------------------------------------------------------------
 
24
/// @class wxSTEditorNotebook
 
25
/// @brief A wxNotebook of wxSTEditorSplitters.
 
26
///
 
27
/// Updates the tab names and can keep them sorted provides a menu to add,
 
28
/// close, goto, save, pages.
 
29
//-----------------------------------------------------------------------------
 
30
 
 
31
class WXDLLIMPEXP_STEDIT wxSTEditorNotebook : public wxNotebook
 
32
{
 
33
public:
 
34
    wxSTEditorNotebook() : wxNotebook() { Init(); }
 
35
    wxSTEditorNotebook( wxWindow *parent, wxWindowID id,
 
36
                        const wxPoint& pos = wxDefaultPosition,
 
37
                        const wxSize& size = wxDefaultSize,
 
38
                        long style = 0,
 
39
                        const wxString& name = wxT("wxSTEditorNotebook") ) : wxNotebook()
 
40
    {
 
41
        Init();
 
42
        Create( parent, id, pos, size, style, name );
 
43
    }
 
44
 
 
45
    virtual ~wxSTEditorNotebook();
 
46
    virtual bool Destroy();
 
47
 
 
48
    bool Create( wxWindow *parent, wxWindowID id,
 
49
                 const wxPoint& pos = wxDefaultPosition,
 
50
                 const wxSize& size = wxDefaultSize,
 
51
                 long style = 0,
 
52
                 const wxString& name = wxT("wxSTEditorNotebook") );
 
53
 
 
54
    /// Create and set the wxSTEditorOptions, call this after creation.
 
55
    virtual void CreateOptions(const wxSTEditorOptions& options);
 
56
    /// Get the editor option values.
 
57
    const wxSTEditorOptions& GetOptions() const { return m_options; }
 
58
    /// Get the editor option values.
 
59
    wxSTEditorOptions& GetOptions() { return m_options; }
 
60
    /// Set the options, the options will now be refed copies of the ones you send in.
 
61
    /// This can be used to detach the options for a particular editor from
 
62
    /// the rest of them.
 
63
    void SetOptions(const wxSTEditorOptions& options) { m_options = options; }
 
64
 
 
65
    /// Get the wxSTEditorTreeCtrl to manage.
 
66
    wxSTEditorTreeCtrl* GetSTEditorTreeCtrl() { return m_editorTreeCtrl; }
 
67
    /// Set a wxSTEditorTreeCtrl to manage.
 
68
    void SetSTEditorTreeCtrl(wxSTEditorTreeCtrl* editorTreeCtrl) { m_editorTreeCtrl = editorTreeCtrl; }
 
69
 
 
70
    /// enable/disable sending wxSTEditor events from children editors.
 
71
    void SetSendSTEEvents(bool send);
 
72
 
 
73
    /// Get the editor at the page (last focused), if -1 then get the current editor, else NULL.
 
74
    wxSTEditor *GetEditor(int page = -1);
 
75
    /// Get the splitter at this page, if -1 then get current splitter, else NULL.
 
76
    wxSTEditorSplitter *GetEditorSplitter(int page = -1);
 
77
 
 
78
    /// Find the page that this editor is in or -1 for none.
 
79
    int FindEditorPage(const wxSTEditor* editor);
 
80
    /// Find the page who's editor has this filename, returns first found or -1 for not found.
 
81
    int FindEditorPageByFileName(const wxFileName& fileName);
 
82
    /// Find the page who's editor has this id, returns first found or -1 for not found.
 
83
    int FindEditorPageById(wxWindowID win_id);
 
84
 
 
85
    /// Insert a blank wxSTEditorSplitter into the notebook.
 
86
    /// nPage = -1 means at end or if sorted then alphabetically.
 
87
    wxSTEditorSplitter* InsertEditorSplitter(int nPage, wxWindowID win_id,
 
88
                                             const wxString& title,
 
89
                                             bool bSelect = false);
 
90
    /// Insert a splitter of your own creation.
 
91
    bool InsertEditorSplitter(int nPage, wxSTEditorSplitter* splitter,
 
92
                              bool bSelect = false);
 
93
 
 
94
    /// Get/Set the maximum number of pages to allow, default is STN_NOTEBOOK_PAGES_MAX_DEFAULT.
 
95
    /// Absolute max is STN_NOTEBOOK_PAGES_MAX, menu IDs will confict if greater.
 
96
    size_t GetMaxPageCount() const { return m_stn_max_page_count; }
 
97
    void SetMaxPageCount(size_t count) { m_stn_max_page_count = (int)count; }
 
98
 
 
99
    /// Strip the path off the wxSTEditor::GetFileName() to use as tab name.
 
100
    wxString FileNameToTabName(const wxSTEditor* editor) const;
 
101
 
 
102
    /// Delete a page and if query_save_if_modified & modified call
 
103
    ///   wxSTEditor::QuerySaveIfModified().
 
104
    /// If !STN_ALLOW_NO_PAGES then add back a new blank page.
 
105
    /// @returns success - not canceled and anything done.
 
106
    bool ClosePage(int n, bool query_save_if_modified = true);
 
107
    /// Delete all pages.
 
108
    /// @param query_save_if_modified & modified call wxSTEditor::QuerySaveIfModified().
 
109
    /// @param except_this_page If > 0 then keep this page open, else close all.
 
110
    /// If !STN_ALLOW_NO_PAGES then add back a new blank page.
 
111
    /// @returns success - not canceled and anything done.
 
112
    bool CloseAllPages(bool query_save_if_modified = true, int except_this_page = -1);
 
113
 
 
114
    /// Add a new page with the given name, if name is "" popup dialog to ask name.
 
115
    virtual bool NewPage( const wxString& title = wxEmptyString );
 
116
    /// Load a single file into a new page, if fileName is empty use wxFileSelector.
 
117
    virtual bool LoadFile( const wxFileName&,
 
118
                           const wxString &extensions = wxEmptyString,
 
119
                           const wxString& encoding = wxEmptyString);
 
120
    /// Load file(s) into new page(s), if filenames is NULL, use wxFileDialog.
 
121
    virtual bool LoadFiles( wxArrayString *fileNames = NULL,
 
122
                            const wxString &extensions = wxEmptyString  );
 
123
    bool LoadFiles( const wxArrayFileName *fileNames,
 
124
                    const wxString &extensions = wxEmptyString  );
 
125
    /// Save all the opened files if modified.
 
126
    virtual void SaveAllFiles();
 
127
 
 
128
    /// Runs through all pages and if IsModified() popup a message box asking if the user wants to save the file.
 
129
    /// If the user presses wxID_YES the file is automatically saved.
 
130
    /// Note: Use EVT_CLOSE in frame before hiding the frame.
 
131
    ///       Check for wxCloseEvent::CanVeto and if it can't be vetoed use the
 
132
    ///       style wxYES_NO only since it can't be canceled.
 
133
    /// @returns false if wxCANCEL was pressed, else true.
 
134
    bool QuerySaveIfModified(int style = wxYES_NO|wxCANCEL);
 
135
 
 
136
    /// Tests wxSTEditor::CanSave() for each page.
 
137
    bool CanSaveAll();
 
138
 
 
139
    /// Update all the menu/tool items in the wxSTEditorOptions.
 
140
    virtual void UpdateAllItems();
 
141
    /// Update popupmenu, menubar, toolbar if any.
 
142
    virtual void UpdateItems(wxMenu *menu=NULL, wxMenuBar *menuBar=NULL, wxToolBar *toolBar=NULL);
 
143
 
 
144
    /// Find a string starting at the current page and incrementing pages
 
145
    ///   until one is found or wxNOT_FOUND (-1) for none found.
 
146
    /// Action is of type STE_FindStringType selects, goto, or do nothing.
 
147
    /// @returns The position in the page, use GetSelection to get new page number.
 
148
    int FindString(const wxString &str, STE_TextPos start_pos, int flags, int action);
 
149
    /// Replace all occurances of the find string with the replace string in all pages.
 
150
    /// If flags = -1 uses wxSTEditor::GetFindFlags().
 
151
    /// Pages will be filled with the number of different pages that have been modified.
 
152
    /// @returns The number of replacements.
 
153
    int ReplaceAllStrings(const wxString &findString,
 
154
                          const wxString &replaceString,
 
155
                          int flags = -1, int *pages = NULL);
 
156
 
 
157
    // -----------------------------------------------------------------------
 
158
    // implementation
 
159
 
 
160
    /// Create a wxSTEditorSplitter as needed for new pages, override if desired.
 
161
    virtual wxSTEditorSplitter *CreateSplitter(wxWindowID id = wxID_ANY);
 
162
 
 
163
    /// Sort the tabs, currently only STN_ALPHABETICAL_TABS is understood.
 
164
    void SortTabs(int style = STN_ALPHABETICAL_TABS);
 
165
 
 
166
    /// Update the goto and close submenus of the notebook tab popup menu.
 
167
    void UpdateGotoCloseMenu(wxMenu* menu, int startID);
 
168
 
 
169
    /// @name Overridden wxNotebook methods.
 
170
    /// These send EVT_STNOTEBOOK_PAGE_CHANGED events to help update UI (these just call base class).
 
171
    /// @{
 
172
 
 
173
    virtual bool AddPage(wxWindow *page, const wxString& text,
 
174
                         bool bSelect = false, int imageId = -1);
 
175
    virtual bool InsertPage(size_t nPage, wxNotebookPage *pPage,
 
176
                            const wxString& strText, bool bSelect = false,
 
177
                            int imageId = -1);
 
178
    virtual int  GetSelection() const;
 
179
    virtual int  SetSelection(size_t nPage);
 
180
    virtual bool DeletePage(size_t nPage);
 
181
    virtual bool RemovePage(size_t nPage);
 
182
    virtual bool DeleteAllPages();
 
183
 
 
184
    // Override for 2.6 compatibility
 
185
    //virtual bool InsertPage(int nPage, wxNotebookPage *pPage,
 
186
    //                        const wxString& strText, bool bSelect = false,
 
187
    //                        int imageId = -1) { return InsertPage((size_t)nPage, pPage, strText, bSelect, imageId); }
 
188
    //virtual int  SetSelection(int nPage) { return SetSelection((size_t)nPage); } /// Override for 2.6 compatibility
 
189
    //virtual bool DeletePage(int nPage)   { return DeletePage((size_t)nPage); } /// Override for 2.6 compatibility
 
190
    //virtual bool RemovePage(int nPage)   { return RemovePage((size_t)nPage); } /// Override for 2.6 compatibility
 
191
 
 
192
    /// @}
 
193
 
 
194
    void OnMenu(wxCommandEvent &event);
 
195
    virtual bool HandleMenuEvent(wxCommandEvent &event);
 
196
    void OnSTEState(wxSTEditorEvent &event);
 
197
#if defined(__WXMSW__) && (wxVERSION_NUMBER >= 2900)
 
198
    void OnLeftUp(wxMouseEvent &event);
 
199
#endif
 
200
    void OnRightUp(wxMouseEvent &event);
 
201
    void OnMiddleUp(wxMouseEvent &event);
 
202
    void OnPageChanged(wxNotebookEvent &event);
 
203
    void OnFindDialog(wxFindDialogEvent& event);
 
204
 
 
205
    void UpdatePageState();
 
206
 
 
207
protected:
 
208
    wxSTEditorOptions m_options;
 
209
 
 
210
    wxSTEditorTreeCtrl* m_editorTreeCtrl;
 
211
 
 
212
    int m_stn_selection;
 
213
    int m_stn_page_count;
 
214
    int m_stn_max_page_count;
 
215
 
 
216
    wxSTERecursionGuardFlag m_rGuard_OnMenu;
 
217
    wxSTERecursionGuardFlag m_rGuard_HandleMenuEvent;
 
218
    wxSTERecursionGuardFlag m_rGuard_OnFindDialog;
 
219
    wxSTERecursionGuardFlag m_rGuard_UpdatePageState;
 
220
 
 
221
private:
 
222
    void Init();
 
223
    DECLARE_EVENT_TABLE()
 
224
    DECLARE_DYNAMIC_CLASS(wxSTEditorNotebook)
 
225
};
 
226
 
 
227
#endif  // _STENOTEB_H_