~ubuntu-branches/ubuntu/lucid/codelite/lucid

« back to all changes in this revision

Viewing changes to LiteEditor/debuggerpane.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-01-12 15:46:55 UTC
  • Revision ID: james.westby@ubuntu.com-20090112154655-sdynrljcb6u167yw
Tags: upstream-1.0.2674+dfsg
ImportĀ upstreamĀ versionĀ 1.0.2674+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//////////////////////////////////////////////////////////////////////////////
 
2
//////////////////////////////////////////////////////////////////////////////
 
3
//
 
4
// copyright            : (C) 2008 by Eran Ifrah
 
5
// file name            : debuggerpane.cpp
 
6
//
 
7
// -------------------------------------------------------------------------
 
8
// A
 
9
//              _____           _      _     _ _
 
10
//             /  __ \         | |    | |   (_) |
 
11
//             | /  \/ ___   __| | ___| |    _| |_ ___
 
12
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
 
13
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
 
14
//              \____/\___/ \__,_|\___\_____/_|\__\___|
 
15
//
 
16
//                                                  F i l e
 
17
//
 
18
//    This program is free software; you can redistribute it and/or modify
 
19
//    it under the terms of the GNU General Public License as published by
 
20
//    the Free Software Foundation; either version 2 of the License, or
 
21
//    (at your option) any later version.
 
22
//
 
23
//////////////////////////////////////////////////////////////////////////////
 
24
//////////////////////////////////////////////////////////////////////////////
 
25
#include <wx/aui/framemanager.h>
 
26
#include "dockablepane.h"
 
27
#include "editor_config.h"
 
28
#include "detachedpanesinfo.h"
 
29
 #include "wx/dcbuffer.h"
 
30
#include "memoryview.h"
 
31
#include "debuggerpane.h"
 
32
#include "localvarstree.h"
 
33
#include "simpletable.h"
 
34
#include "listctrlpanel.h"
 
35
#include "wx/xrc/xmlres.h"
 
36
#include "manager.h"
 
37
#include "breakpointdlg.h"
 
38
#include "threadlistpanel.h"
 
39
 
 
40
const wxString DebuggerPane::LOCALS = wxT("Locals");
 
41
const wxString DebuggerPane::WATCHES = wxT("Watches");
 
42
const wxString DebuggerPane::FRAMES = wxT("Call Stack");
 
43
const wxString DebuggerPane::BREAKPOINTS = wxT("Breakpoints");
 
44
const wxString DebuggerPane::THREADS = wxT("Threads");
 
45
const wxString DebuggerPane::MEMORY = wxT("Memory");
 
46
 
 
47
/*#define ADD_DEBUGGER_PAGE(win, name, bmp) \
 
48
        if( detachedPanes.Index(name) != wxNOT_FOUND ) {\
 
49
                wxAuiPaneInfo info;\
 
50
                DockablePane *pane = new DockablePane(GetParent(), m_book, win, name, bmp, wxSize(200, 200));\
 
51
                m_mgr->AddPane(pane, info.Name(name).Caption(name));\
 
52
        } else {\
 
53
                m_book->AddPage(win, name, bmp, false);\
 
54
        }*/
 
55
 
 
56
#define ADD_DEBUGGER_PAGE(win, name, bmp) \
 
57
        if( detachedPanes.Index(name) != wxNOT_FOUND ) {\
 
58
                new DockablePane(GetParent(), m_book, win, name, bmp, wxSize(200, 200));\
 
59
        } else {\
 
60
                m_book->AddPage(win, name, name, bmp, false);\
 
61
        }
 
62
 
 
63
BEGIN_EVENT_TABLE(DebuggerPane, wxPanel)
 
64
        EVT_PAINT(DebuggerPane::OnPaint)
 
65
        EVT_ERASE_BACKGROUND(DebuggerPane::OnEraseBg)
 
66
        EVT_SIZE(DebuggerPane::OnSize)
 
67
        EVT_BOOK_PAGE_CHANGED(wxID_ANY, DebuggerPane::OnPageChanged)
 
68
END_EVENT_TABLE()
 
69
 
 
70
DebuggerPane::DebuggerPane(wxWindow *parent, const wxString &caption, wxAuiManager *mgr)
 
71
                : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(400, 300))
 
72
                , m_caption(caption)
 
73
                , m_initDone(false)
 
74
                , m_mgr(mgr)
 
75
{
 
76
        CreateGUIControls();
 
77
}
 
78
 
 
79
DebuggerPane::~DebuggerPane()
 
80
{
 
81
}
 
82
 
 
83
void DebuggerPane::OnPageChanged(NotebookEvent &event)
 
84
{
 
85
        if (m_initDone) {
 
86
                if (event.GetEventObject() == m_book) {
 
87
                        ManagerST::Get()->UpdateDebuggerPane();
 
88
                } else {
 
89
                        event.Skip();
 
90
                }
 
91
        }
 
92
}
 
93
 
 
94
void DebuggerPane::CreateGUIControls()
 
95
{
 
96
        wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
 
97
        SetSizer(mainSizer);
 
98
 
 
99
        m_book = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVB_TOP);
 
100
        mainSizer->Add(m_book, 1, wxEXPAND|wxALL, 1);
 
101
 
 
102
        // load list of detached panes
 
103
        wxArrayString detachedPanes;
 
104
        DetachedPanesInfo dpi;
 
105
        EditorConfigST::Get()->ReadObject(wxT("DetachedPanesList"), &dpi);
 
106
        detachedPanes = dpi.GetPanes();
 
107
 
 
108
        m_localsTree = new LocalVarsTree(m_book, wxID_ANY);
 
109
        ADD_DEBUGGER_PAGE(m_localsTree, LOCALS, wxXmlResource::Get()->LoadBitmap(wxT("locals_view")));
 
110
 
 
111
        //add the watches view
 
112
        m_watchesTable = new SimpleTable(m_book);
 
113
        ADD_DEBUGGER_PAGE(m_watchesTable, WATCHES, wxXmlResource::Get()->LoadBitmap(wxT("watches")));
 
114
 
 
115
        m_frameList = new ListCtrlPanel(m_book);
 
116
        ADD_DEBUGGER_PAGE(m_frameList, FRAMES, wxXmlResource::Get()->LoadBitmap(wxT("frames")));
 
117
 
 
118
        m_breakpoints = new BreakpointDlg(m_book);
 
119
        ADD_DEBUGGER_PAGE(m_breakpoints, BREAKPOINTS, wxXmlResource::Get()->LoadBitmap(wxT("breakpoint")));
 
120
 
 
121
        m_threads = new ThreadListPanel(m_book);
 
122
        ADD_DEBUGGER_PAGE(m_threads, THREADS, wxXmlResource::Get()->LoadBitmap(wxT("threads")));
 
123
 
 
124
        m_memory = new MemoryView(m_book);
 
125
        ADD_DEBUGGER_PAGE(m_memory, MEMORY, wxXmlResource::Get()->LoadBitmap(wxT("memory_view")));
 
126
 
 
127
        m_initDone = true;
 
128
}
 
129
 
 
130
void DebuggerPane::SelectTab(const wxString &tabName)
 
131
{
 
132
        for (size_t i=0; i< m_book->GetPageCount(); i++) {
 
133
                if (m_book->GetPageText(i) == tabName) {
 
134
                        m_book->SetSelection(i);
 
135
                        break;
 
136
                }
 
137
        }
 
138
}
 
139
 
 
140
void DebuggerPane::Clear()
 
141
{
 
142
        GetLocalsTree()->Clear();
 
143
        GetWatchesTable()->Clear();
 
144
        GetFrameListView()->Clear();
 
145
        GetThreadsView()->Clear();
 
146
        GetMemoryView()->Clear();
 
147
}
 
148
 
 
149
void DebuggerPane::OnEraseBg(wxEraseEvent &e)
 
150
{
 
151
        wxUnusedVar(e);
 
152
}
 
153
 
 
154
void DebuggerPane::OnPaint(wxPaintEvent &e)
 
155
{
 
156
        wxUnusedVar(e);
 
157
        wxBufferedPaintDC dc(this);
 
158
        dc.SetPen( wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW) );
 
159
        dc.SetBrush( *wxTRANSPARENT_BRUSH );
 
160
 
 
161
        dc.DrawRectangle( wxRect(GetSize()) );
 
162
}
 
163
 
 
164
void DebuggerPane::OnSize(wxSizeEvent &e)
 
165
{
 
166
        Refresh();
 
167
        e.Skip();
 
168
}