File: outline.cpp

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 (177 lines) | stat: -rw-r--r-- 5,036 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
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright            : (C) 2008 by Eran Ifrah
// file name            : symbolview.cpp
//
// -------------------------------------------------------------------------
// 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.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

#include <set>
#include <wx/app.h>
#include <wx/wupdlock.h>
#include "event_notifier.h"
#include <wx/settings.h>
#include "outline_settings.h"
#include "iconfigtool.h"
#include "detachedpanesinfo.h"
#include <wx/menu.h>
#include <wx/log.h>
#include <wx/tokenzr.h>
#include "macros.h"
#include "workspace.h"
#include "ctags_manager.h"
#include "outline.h"
#include "fileextmanager.h"
#include <wx/busyinfo.h>
#include <wx/utils.h>
#include <wx/xrc/xmlres.h>
#include "parse_thread.h"
#include "outline_symbol_tree.h"

//--------------------------------------------
//Plugin Interface
//--------------------------------------------

static SymbolViewPlugin* thePlugin = NULL;

//Define the plugin entry point
extern "C" EXPORT IPlugin *CreatePlugin(IManager *manager)
{
    if (thePlugin == 0) {
        thePlugin = new SymbolViewPlugin(manager);
    }
    return thePlugin;
}

extern "C" EXPORT PluginInfo GetPluginInfo()
{
    PluginInfo info;
    info.SetAuthor(wxT("Eran Ifrah"));
    info.SetName(wxT("Outline"));
    info.SetDescription(_("Show Current the Layout of the current file"));
    info.SetVersion(wxT("v1.0"));
    return info;
}

extern "C" EXPORT int GetPluginInterfaceVersion()
{
    return PLUGIN_INTERFACE_VERSION;
}


//--------------------------------------------
//Constructors/Destructors
//--------------------------------------------

SymbolViewPlugin::SymbolViewPlugin(IManager *manager)
    : IPlugin(manager)
{
    m_longName = _("Outline Plugin");
    m_shortName = wxT("Outline");
    
    OutlineSettings os;
    os.Load();
    
    Notebook *book = m_mgr->GetWorkspacePaneNotebook();
    if( IsPaneDetached() ) {
        // Make the window child of the main panel (which is the grand parent of the notebook)
        DockablePane *cp = new DockablePane(book->GetParent()->GetParent(), book, wxT("Outline"), wxNullBitmap, wxSize(200, 200));
        m_view = new OutlineTab(cp, m_mgr);
        cp->SetChildNoReparent(m_view);

    } else {
        m_view = new OutlineTab(book, m_mgr);
        book->AddPage(m_view, wxT("Outline"), false);
    }
}

SymbolViewPlugin::~SymbolViewPlugin()
{
    thePlugin = NULL;
}

clToolBar *SymbolViewPlugin::CreateToolBar(wxWindow *parent)
{
    return NULL;
}

void SymbolViewPlugin::CreatePluginMenu(wxMenu *pluginsMenu)
{
    wxUnusedVar(pluginsMenu);
}

void SymbolViewPlugin::HookPopupMenu(wxMenu *menu, MenuType type)
{
    if (type == MenuTypeEditor) {

    } else if (type == MenuTypeFileExplorer) {

    } else if (type == MenuTypeFileView_Workspace) {

    } else if (type == MenuTypeFileView_Project) {

    } else if (type == MenuTypeFileView_Folder) {

    } else if (type == MenuTypeFileView_File) {
    }
}

void SymbolViewPlugin::UnPlug()
{
    size_t where = m_mgr->GetWorkspacePaneNotebook()->GetPageIndex(m_view);
    if ( where != Notebook::npos ) {
        // this window might be floating
        m_mgr->GetWorkspacePaneNotebook()->RemovePage(where);
    }

    m_view->Destroy();
    m_view = NULL;
}

bool SymbolViewPlugin::IsPaneDetached()
{
    DetachedPanesInfo dpi;
    m_mgr->GetConfigTool()->ReadObject(wxT("DetachedPanesList"), &dpi);
    wxArrayString detachedPanes = dpi.GetPanes();
    return detachedPanes.Index(wxT("Outline")) != wxNOT_FOUND;
}

int SymbolViewPlugin::DoFindTabIndex()
{
    std::vector<wxWindow*> windows;
    Notebook *book = m_mgr->GetWorkspacePaneNotebook();
    
#if !CL_USE_NATIVEBOOK

    book->GetEditorsInOrder(windows);
    
#else
    
    for(size_t i=0; i<book->GetPageCount(); i++) {
        windows.push_back( book->GetPage(i) );
    }
    
#endif
    for(size_t i=0; i<windows.size(); i++) {
        if(windows.at(i) == m_view )
            return i;
    }
    return wxNOT_FOUND;
}