~ubuntu-branches/ubuntu/maverick/codelite/maverick

« back to all changes in this revision

Viewing changes to LiteEditor/workspace_pane.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-07-29 19:42:47 UTC
  • mfrom: (1.1.9 upstream) (18.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100729194247-cuibfk03wog33nxq
Tags: 2.6.0.4189~dfsg-1
* New upstream release.
* Bump Standards.
* Refresh patches.
* Add license information about files under ./Debugger/

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
#endif
86
86
 
87
87
    // add notebook for tabs
88
 
        long bookStyle = wxVB_LEFT | wxAUI_NB_SCROLL_BUTTONS;
 
88
        long bookStyle = wxVB_LEFT | wxAUI_NB_WINDOWLIST_BUTTON;
89
89
        m_book = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, bookStyle);
90
90
 
91
91
        // Calculate the widthest tab (the one with the 'Workspcae' label)
95
95
 
96
96
        mainSizer->Add(m_book, 1, wxEXPAND | wxALL, 0);
97
97
 
 
98
        // Add the parsing progress controls
 
99
        m_staticText = new wxStaticText(this, wxID_ANY, wxT("Parsing workspace..."));
 
100
        mainSizer->Add(m_staticText, 0, wxEXPAND|wxALL, 2);
 
101
 
 
102
        m_parsingProgress = new wxGauge(this, wxID_ANY, 100, wxDefaultPosition, wxSize(-1, 15), wxGA_HORIZONTAL|wxGA_SMOOTH);
 
103
        mainSizer->Add(m_parsingProgress, 0, wxEXPAND|wxALL, 1);
 
104
        m_parsingProgress->Hide();
 
105
        m_staticText->Hide();
 
106
 
98
107
    // create tabs (possibly detached)
99
108
        DetachedPanesInfo dpi;
100
109
        EditorConfigST::Get()->ReadObject(wxT("DetachedPanesList"), &dpi);
127
136
                m_book->AddPage(m_explorer, name, false);
128
137
        }
129
138
 
130
 
        // Add the Outline tab
131
 
        name = wxT("Outline");
132
 
        if(IS_DETACHED(name)) {
133
 
                DockablePane *cp = new DockablePane(GetParent(), m_book,  name, wxNullBitmap, wxSize(200, 200));
134
 
                m_winStack = new WindowStack(cp);
135
 
                cp->SetChildNoReparent(m_winStack);
136
 
        } else {
137
 
                m_winStack = new WindowStack(m_book);
138
 
                m_book->AddPage(m_winStack, name, false);
139
 
        }
140
 
 
141
139
        // Add the Open Windows Panel (Tabs)
142
140
        name = wxT("Tabs");
143
141
        if(IS_DETACHED(name)) {
171
169
        wxTheApp->Connect(wxEVT_WORKSPACE_LOADED,         wxCommandEventHandler(WorkspacePane::OnWorkspaceConfig),     NULL, this);
172
170
        wxTheApp->Connect(wxEVT_WORKSPACE_CONFIG_CHANGED, wxCommandEventHandler(WorkspacePane::OnWorkspaceConfig),     NULL, this);
173
171
        wxTheApp->Connect(wxEVT_WORKSPACE_CLOSED,         wxCommandEventHandler(WorkspacePane::OnWorkspaceClosed),     NULL, this);
174
 
        wxTheApp->Connect(wxEVT_PROJ_FILE_ADDED,          wxCommandEventHandler(WorkspacePane::OnProjectFileAdded),    NULL, this);
175
 
        wxTheApp->Connect(wxEVT_PROJ_FILE_REMOVED,        wxCommandEventHandler(WorkspacePane::OnProjectFileRemoved),  NULL, this);
176
 
        wxTheApp->Connect(wxEVT_SYNBOL_TREE_UPDATE_ITEM,  wxCommandEventHandler(WorkspacePane::OnSymbolsUpdated),      NULL, this);
177
 
        wxTheApp->Connect(wxEVT_SYNBOL_TREE_DELETE_ITEM,  wxCommandEventHandler(WorkspacePane::OnSymbolsDeleted),      NULL, this);
178
 
        wxTheApp->Connect(wxEVT_SYNBOL_TREE_ADD_ITEM,     wxCommandEventHandler(WorkspacePane::OnSymbolsAdded),        NULL, this);
179
 
        wxTheApp->Connect(wxEVT_FILE_RETAGGED,            wxCommandEventHandler(WorkspacePane::OnFileRetagged),        NULL, this);
180
 
        wxTheApp->Connect(wxEVT_ACTIVE_EDITOR_CHANGED,    wxCommandEventHandler(WorkspacePane::OnActiveEditorChanged), NULL, this);
181
 
        wxTheApp->Connect(wxEVT_EDITOR_CLOSING,           wxCommandEventHandler(WorkspacePane::OnEditorClosing),       NULL, this);
182
 
        wxTheApp->Connect(wxEVT_ALL_EDITORS_CLOSED,       wxCommandEventHandler(WorkspacePane::OnAllEditorsClosed),    NULL, this);
183
 
 
184
172
    wxTheApp->Connect(XRCID("configuration_manager"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (WorkspacePane::OnConfigurationManager),   NULL, this);
185
173
    wxTheApp->Connect(XRCID("configuration_manager"), wxEVT_UPDATE_UI,             wxUpdateUIEventHandler(WorkspacePane::OnConfigurationManagerUI), NULL, this);
186
174
}
187
175
 
188
 
 
189
 
extern wxImageList* CreateSymbolTreeImages();
190
 
 
191
 
void WorkspacePane::ShowCurrentOutline()
192
 
{
193
 
    LEditor *editor = Frame::Get()->GetMainBook()->GetActiveEditor();
194
 
    if (!editor || editor->GetProjectName().IsEmpty()) {
195
 
        m_winStack->SelectNone();
196
 
        return;
197
 
    }
198
 
    wxString path = editor->GetFileName().GetFullPath();
199
 
    if (m_winStack->GetSelectedKey() != path) {
200
 
        m_winStack->Freeze();
201
 
        if (m_winStack->Find(path) == NULL) {
202
 
            CppSymbolTree *tree = new CppSymbolTree(m_winStack, wxID_ANY);
203
 
            tree->SetSymbolsImages(CreateSymbolTreeImages());
204
 
            tree->BuildTree(path);
205
 
            m_winStack->Add(tree, path);
206
 
        }
207
 
        m_winStack->Select(path);
208
 
        m_winStack->Thaw();
209
 
    }
210
 
}
211
 
 
212
 
void WorkspacePane::OnActiveEditorChanged(wxCommandEvent& e)
213
 
{
214
 
    e.Skip();
215
 
    ShowCurrentOutline();
216
 
}
217
 
 
218
 
void WorkspacePane::OnAllEditorsClosed(wxCommandEvent& e)
219
 
{
220
 
    e.Skip();
221
 
    m_winStack->Clear();
222
 
}
223
 
 
224
 
void WorkspacePane::OnEditorClosing(wxCommandEvent& e)
225
 
{
226
 
    e.Skip();
227
 
    IEditor *editor = (IEditor*) e.GetClientData();
228
 
    if (editor && !editor->GetProjectName().IsEmpty()) {
229
 
        m_winStack->Delete(editor->GetFileName().GetFullPath());
230
 
    }
231
 
}
232
 
 
233
 
void WorkspacePane::OnFileRetagged(wxCommandEvent& e)
234
 
{
235
 
    e.Skip();
236
 
    std::vector<wxFileName> *files = (std::vector<wxFileName>*) e.GetClientData();
237
 
        if (files && !files->empty()) {
238
 
        m_winStack->Freeze();
239
 
        // toss out any out-of-date outlines
240
 
        for (size_t i = 0; i < files->size(); i++) {
241
 
            m_winStack->Delete(files->at(i).GetFullPath());
242
 
        }
243
 
        ShowCurrentOutline(); // in case active editor's file was one of them
244
 
        m_winStack->Thaw();
245
 
    }
246
 
}
247
 
 
248
 
void WorkspacePane::OnProjectFileAdded(wxCommandEvent& e)
249
 
{
250
 
    e.Skip();
251
 
    ShowCurrentOutline(); // in case the active editor's file is now tagged
252
 
}
253
 
 
254
 
void WorkspacePane::OnProjectFileRemoved(wxCommandEvent& e)
255
 
{
256
 
    e.Skip();
257
 
    wxArrayString *files = (wxArrayString*) e.GetClientData();
258
 
        if (files && !files->IsEmpty()) {
259
 
        for (size_t i = 0; i < files->Count(); i++) {
260
 
            m_winStack->Delete(files->Item(i));
261
 
        }
262
 
        ShowCurrentOutline(); // in case active editor's file is no longer tagged
263
 
    }
264
 
}
265
 
 
266
 
void WorkspacePane::OnSymbolsAdded(wxCommandEvent& e)
267
 
{
268
 
    e.Skip();
269
 
    ParseThreadEventData *data = (ParseThreadEventData*) e.GetClientData();
270
 
        if (data && !data->GetItems().empty()) {
271
 
        CppSymbolTree *tree = (CppSymbolTree*) m_winStack->Find(data->GetFileName());
272
 
        if (tree) {
273
 
            tree->AddSymbols(data->GetItems());
274
 
        }
275
 
    }
276
 
}
277
 
 
278
 
void WorkspacePane::OnSymbolsDeleted(wxCommandEvent& e)
279
 
{
280
 
    e.Skip();
281
 
    ParseThreadEventData *data = (ParseThreadEventData*) e.GetClientData();
282
 
        if (data && !data->GetItems().empty()) {
283
 
        CppSymbolTree *tree = (CppSymbolTree*) m_winStack->Find(data->GetFileName());
284
 
        if (tree) {
285
 
            tree->DeleteSymbols(data->GetItems());
286
 
        }
287
 
    }
288
 
}
289
 
 
290
 
void WorkspacePane::OnSymbolsUpdated(wxCommandEvent& e)
291
 
{
292
 
    e.Skip();
293
 
    ParseThreadEventData *data = (ParseThreadEventData*) e.GetClientData();
294
 
        if (data && !data->GetItems().empty()) {
295
 
        CppSymbolTree *tree = (CppSymbolTree*) m_winStack->Find(data->GetFileName());
296
 
        if (tree) {
297
 
            tree->UpdateSymbols(data->GetItems());
298
 
        }
299
 
    }
300
 
}
301
 
 
302
176
void WorkspacePane::OnWorkspaceConfig(wxCommandEvent& e)
303
177
{
304
178
    e.Skip();
324
198
    e.Skip();
325
199
    m_workspaceConfig->Clear();
326
200
    m_workspaceConfig->Enable(false);
327
 
    m_winStack->Clear();
328
201
}
329
202
 
330
203
void WorkspacePane::OnConfigurationManagerUI(wxUpdateUIEvent& e)
362
235
        BuildMatrixPtr matrix = ManagerST::Get()->GetWorkspaceBuildMatrix();
363
236
        m_workspaceConfig->SetStringSelection(matrix->GetSelectedConfigurationName());
364
237
}
 
238
 
 
239
void WorkspacePane::ClearProgress()
 
240
{
 
241
        m_parsingProgress->SetValue(0);
 
242
        m_parsingProgress->Hide();
 
243
 
 
244
        m_staticText->SetLabel(wxT("Parsing workspace..."));
 
245
        m_staticText->Hide();
 
246
        Layout();
 
247
}
 
248
 
 
249
void WorkspacePane::UpdateProgress(int val)
 
250
{
 
251
        if(m_parsingProgress->IsShown() == false) {
 
252
                m_parsingProgress->Show();
 
253
                m_staticText->Show();
 
254
                Layout();
 
255
        }
 
256
 
 
257
        m_staticText->SetLabel(wxString::Format(wxT("Parsing workspace: %d%% completed"), val));
 
258
        m_parsingProgress->SetValue(val);
 
259
        m_parsingProgress->Update();
 
260
}
 
261