File: mainbook.h

package info (click to toggle)
codelite 6.1.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 48,992 kB
  • ctags: 43,502
  • sloc: cpp: 334,263; ansic: 18,441; xml: 4,713; yacc: 2,653; lex: 2,449; python: 1,188; sh: 385; makefile: 40
file content (193 lines) | stat: -rw-r--r-- 7,307 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright            : (C) 2008 by Eran Ifrah
// file name            : mainbook.h
//
// -------------------------------------------------------------------------
// A
//              _____           _      _     _ _
//             /  __ \         | |    | |   (_) |
//             | /  \/ ___   __| | ___| |    _| |_ ___
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
//              \____/\___/ \__,_|\___\_____/_|\__\___|
//
//                                                  F i l e
//
//    This program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 2 of the License, or
//    (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef MAINBOOK_H
#define MAINBOOK_H

#include <set>
#include <wx/panel.h>
#include "sessionmanager.h"
#include "navbar.h"
#include "quickfindbar.h"
#include "notebook_ex.h"
#include "filehistory.h"
#include "message_pane.h"
#include "cl_command_event.h"
#include "editorframe.h"

class FilesModifiedDlg;
enum OF_extra { OF_None = 0x00000001, OF_AddJump = 0x00000002, OF_PlaceNextToCurrent = 0x00000004 };

class MessagePane;
class MainBook : public wxPanel
{
private:
    FileHistory m_recentFiles;
    NavBar* m_navBar;
    Notebook* m_book;
    QuickFindBar* m_quickFindBar;
    MessagePane* m_messagePane;
    bool m_useBuffereLimit;
    EditorFrame::List_t m_detachedEditors;
    bool m_isWorkspaceReloading;
    bool m_reloadingDoRaise; // Prevents multiple Raises() during RestoreSession()
    FilesModifiedDlg* m_filesModifiedDlg;

public:
    enum {
        kGetAll_Default = 0x00000000,         // booked editors only
        kGetAll_RetainOrder = 0x00000001,     // Order must keep
        kGetAll_IncludeDetached = 0x00000002, // return both booked editors and detached
        kGetAll_DetachedOnly = 0x00000004,    // return detached editors only
    };

private:
    FilesModifiedDlg *GetFilesModifiedDlg();
    void CreateGuiControls();
    void ConnectEvents();

    void OnMouseDClick(NotebookEvent& e);
    void OnPageClosing(NotebookEvent& e);
    void OnPageClosed(NotebookEvent& e);
    void OnPageChanged(NotebookEvent& e);
    void OnClosePage(NotebookEvent& e);
    void OnPageChanging(NotebookEvent& e);
    void OnProjectFileAdded(clCommandEvent& e);
    void OnProjectFileRemoved(clCommandEvent& e);
    void OnWorkspaceLoaded(wxCommandEvent& e);
    void OnWorkspaceClosed(wxCommandEvent& e);
    void OnDebugEnded(wxCommandEvent& e);
    void OnStringHighlight(wxCommandEvent& e);
    void OnInitDone(wxCommandEvent& e);
    void OnDetachedEditorClosed(clCommandEvent& e);

    bool AskUserToSave(LEditor* editor);
    bool DoSelectPage(wxWindow* win);
    void DoPositionFindBar(int where);
    void DoHandleFrameMenu(LEditor* editor);
    void DoEraseDetachedEditor(IEditor* editor);
    void OnWorkspaceReloadStarted(clCommandEvent& e);
    void OnWorkspaceReloadEnded(clCommandEvent& e);

public:
    MainBook(wxWindow* parent);
    ~MainBook();

    const EditorFrame::List_t& GetDetachedEditors() const { return m_detachedEditors; }
    void DetachActiveEditor();
    void ClearFileHistory();
    void GetRecentlyOpenedFiles(wxArrayString& files);
    FileHistory& GetRecentlyOpenedFilesClass() { return m_recentFiles; }

    void ShowQuickBarForPlugins() { m_quickFindBar->ShowForPlugins(); }

    void ShowQuickBar(bool s = true) { m_quickFindBar->Show(s); }
    void ShowQuickBar(const wxString& findWhat) { m_quickFindBar->Show(findWhat); }
    void ShowMessage(const wxString& message,
                     bool showHideButton = true,
                     const wxBitmap& bmp = wxNullBitmap,
                     const ButtonDetails& btn1 = ButtonDetails(),
                     const ButtonDetails& btn2 = ButtonDetails(),
                     const ButtonDetails& btn3 = ButtonDetails(),
                     const CheckboxDetails& cb = CheckboxDetails());

    void ShowNavBar(bool s = true);
    void UpdateNavBar(LEditor* editor);
    bool IsNavBarShown() { return m_navBar->IsShown(); }

    void SaveSession(SessionEntry& session, wxArrayInt& intArr);
    void RestoreSession(SessionEntry& session);

    LEditor* GetActiveEditor(bool includeDetachedEditors = false);
    void GetAllEditors(LEditor::Vec_t& editors, size_t flags);
    LEditor* FindEditor(const wxString& fileName);
    bool CloseEditor(const wxString& fileName) { return ClosePage(FindEditor(fileName)); }

    wxWindow* GetCurrentPage();
    wxWindow* GetPage(size_t page);
    size_t GetPageCount() const;
    wxWindow* FindPage(const wxString& text);

    LEditor* NewEditor();

    LEditor* OpenFile(const wxString& file_name,
                      const wxString& projectName = wxEmptyString,
                      int lineno = wxNOT_FOUND,
                      long position = wxNOT_FOUND,
                      OF_extra extra = OF_AddJump,
                      bool preserveSelection = true);
    LEditor* OpenFile(const BrowseRecord& rec)
    {
        return OpenFile(rec.filename, rec.project, rec.lineno, rec.position, OF_None, false);
    }

    bool AddPage(wxWindow* win,
                 const wxString& text,
                 const wxBitmap& bmp = wxNullBitmap,
                 bool selected = false,
                 size_t insert_at_index = wxNOT_FOUND);
    bool SelectPage(wxWindow* win);

    bool UserSelectFiles(std::vector<std::pair<wxFileName, bool> >& files,
                         const wxString& title,
                         const wxString& caption,
                         bool cancellable = true);

    bool SaveAll(bool askUser, bool includeUntitled);

    void ReloadExternallyModified(bool prompt);

    bool ClosePage(const wxString& text);

    bool ClosePage(wxWindow* win);
    bool CloseAllButThis(wxWindow* win);
    bool CloseAll(bool cancellable);

    // These 3 functions are meant to be used with CallAfter
    void ClosePageVoid(wxWindow* win);

    void CloseAllButThisVoid(wxWindow* win);

    void CloseAllVoid(bool cancellable);

    wxString GetPageTitle(wxWindow* win) const;
    void SetPageTitle(wxWindow* page, const wxString& name);
    long GetBookStyle();

    void ApplySettingsChanges();
    void UnHighlightAll();
    void DelAllBreakpointMarkers();
    void SetViewEOL(bool visible);
    void SetViewWordWrap(bool b);
    void HighlightWord(bool hl);
    void ShowWhitespace(int ws);
    void UpdateColours();
    void UpdateBreakpoints();
    void MarkEditorReadOnly(LEditor* editor, bool ro);

    void SetUseBuffereLimit(bool useBuffereLimit) { this->m_useBuffereLimit = useBuffereLimit; }
    bool GetUseBuffereLimit() const { return m_useBuffereLimit; }
};

#endif // MAINBOOK_H