~ubuntu-branches/ubuntu/karmic/codelite/karmic-backports

« back to all changes in this revision

Viewing changes to LiteEditor/debuggersettingsdlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ubuntu Archive Backport
  • Date: 2010-03-10 00:42:25 UTC
  • mfrom: (10.1.3 lucid)
  • Revision ID: james.westby@ubuntu.com-20100310004225-ccjgjj2vvdy4q7qs
Tags: 2.2.0.3681+dfsg-0ubuntu1~karmic1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
//////////////////////////////////////////////////////////////////////////////
24
24
//////////////////////////////////////////////////////////////////////////////
25
25
 #include "debuggersettingsdlg.h"
 
26
#include "windowattrmanager.h"
26
27
#include "editor_config.h"
27
28
#include "debuggermanager.h"
28
29
#include "macros.h"
33
34
 
34
35
//-------------------------------------------------------------------
35
36
DebuggerPage::DebuggerPage(wxWindow *parent, wxString title)
36
 
                : wxPanel(parent)
 
37
                : DebuggerPageBase(parent)
37
38
                , m_title(title)
38
39
{
39
 
        wxBoxSizer *sz = new wxBoxSizer(wxVERTICAL);
40
 
        SetSizer(sz);
41
 
 
42
 
        wxFlexGridSizer* fgSizer2;
43
 
        fgSizer2 = new wxFlexGridSizer( 2, 2, 0, 0 );
44
 
 
45
 
        fgSizer2->AddGrowableCol( 1 );
46
 
        fgSizer2->SetFlexibleDirection( wxBOTH );
47
 
        fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
48
 
        sz->Add(fgSizer2, 0, wxEXPAND|wxALL);
49
 
 
50
 
        wxStaticText *m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("Debugger Path:"), wxDefaultPosition, wxDefaultSize, 0 );
51
 
        m_staticText2->Wrap( -1 );
52
 
        fgSizer2->Add( m_staticText2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
53
 
 
54
 
        m_filePicker = new FilePicker( this );
55
 
        fgSizer2->Add( m_filePicker, 0, wxALL|wxEXPAND, 5 );
56
 
 
57
 
        m_checkBoxEnableLog = new wxCheckBox( this, wxID_ANY, wxT("Enable full debugger logging"), wxDefaultPosition, wxDefaultSize, 0 );
58
 
        sz->Add(m_checkBoxEnableLog, 0, wxEXPAND|wxALL, 5);
59
 
 
60
 
        m_checkBoxEnablePendingBreakpoints = new wxCheckBox(this, wxID_ANY, wxT("Enable pending breakpoint"), wxDefaultPosition, wxDefaultSize, 0 );
61
 
        sz->Add(m_checkBoxEnablePendingBreakpoints, 0, wxEXPAND|wxALL, 5);
62
 
 
63
 
        m_checkBreakAtWinMain = new wxCheckBox(this, wxID_ANY, wxT("Automatically set breakpoint at main"), wxDefaultPosition, wxDefaultSize, 0 );
64
 
        sz->Add(m_checkBreakAtWinMain, 0, wxEXPAND|wxALL, 5);
65
 
 
66
 
        m_checkResolveStarThis = new wxCheckBox(this, wxID_ANY, wxT("Resolve '*this' in the 'Locals' view"), wxDefaultPosition, wxDefaultSize, 0 );
67
 
        sz->Add(m_checkResolveStarThis, 0, wxEXPAND|wxALL, 5);
68
 
 
69
 
        m_checkShowTerminal = new wxCheckBox(this, wxID_ANY, wxT("Show debugger terminal"), wxDefaultPosition, wxDefaultSize, 0 );
70
 
        sz->Add(m_checkShowTerminal, 0, wxEXPAND|wxALL, 5);
71
 
 
72
 
        m_checkUseRelativePaths = new wxCheckBox(this, wxID_ANY, wxT("Use file name only for breakpoints (NO full paths)"), wxDefaultPosition, wxDefaultSize, 0 );
73
 
        sz->Add(m_checkUseRelativePaths, 0, wxEXPAND|wxALL, 5);
74
 
 
75
 
        sz->Layout();
76
 
 
77
40
        DebuggerInformation info;
78
41
        if(DebuggerMgr::Get().GetDebuggerInformation(m_title, info)){
79
 
                m_filePicker->SetPath(info.path);
 
42
                m_textCtrDbgPath->SetValue(info.path);
80
43
                m_checkBoxEnableLog->SetValue(info.enableDebugLog);
81
44
                m_checkBoxEnablePendingBreakpoints->SetValue(info.enablePendingBreakpoints);
82
45
                m_checkBreakAtWinMain->SetValue(info.breakAtWinMain);
83
 
                m_checkResolveStarThis->SetValue(info.resolveThis);
84
46
                m_checkShowTerminal->SetValue(info.showTerminal);
85
47
                m_checkUseRelativePaths->SetValue(info.useRelativeFilePaths);
 
48
                m_catchThrow->SetValue(info.catchThrow);
 
49
                m_spinCtrlNumElements->SetValue(info.maxDisplayStringSize);
 
50
                m_showTooltips->SetValue(info.showTooltips);
 
51
                m_textCtrlStartupCommands->SetValue( info.startupCommands );
 
52
 
 
53
                m_checkBoxExpandLocals->SetValue(info.resolveLocals);
 
54
#ifdef __WXMSW__
 
55
                m_checkBoxDebugAssert->SetValue(info.debugAsserts);
 
56
#endif
86
57
        }
 
58
 
 
59
#ifndef __WXMSW__
 
60
        m_checkBoxDebugAssert->SetValue(false);
 
61
        m_checkBoxDebugAssert->Enable(false);
 
62
#endif
 
63
 
87
64
}
88
65
 
89
66
DebuggerPage::~DebuggerPage()
90
67
{
91
68
}
92
69
 
 
70
void DebuggerPage::OnBrowse(wxCommandEvent& e)
 
71
{
 
72
        wxUnusedVar(e);
 
73
        wxString newfilepath, filepath(m_textCtrDbgPath->GetValue());
 
74
        if ((!filepath.IsEmpty()) && wxFileName::FileExists(filepath)) {
 
75
                newfilepath = wxFileSelector(wxT("Select file:"), filepath.c_str());
 
76
        } else {
 
77
                newfilepath = wxFileSelector(wxT("Select file:"));
 
78
        }
 
79
 
 
80
        if (!newfilepath.IsEmpty()) {
 
81
                m_textCtrDbgPath->SetValue(newfilepath);
 
82
        }
 
83
}
 
84
 
 
85
void DebuggerPage::OnDebugAssert(wxCommandEvent& e)
 
86
{
 
87
        if ( e.IsChecked() ) {
 
88
                m_checkBoxEnablePendingBreakpoints->SetValue(true);
 
89
        }
 
90
}
 
91
 
93
92
//-------------------------------------------------------------------
94
93
 
95
94
DebuggerSettingsDlg::DebuggerSettingsDlg( wxWindow* parent )
104
103
        Centre();
105
104
 
106
105
        m_listCtrl1->SetFocus();
 
106
        GetSizer()->Fit(this);
 
107
        WindowAttrManager::Load(this, wxT("DbgSettingsDlg"), NULL);
107
108
}
108
109
 
109
110
void DebuggerSettingsDlg::Initialize()
116
117
        }
117
118
 
118
119
        m_listCtrl1->InsertColumn(0, wxT("Type"));
119
 
        m_listCtrl1->InsertColumn(1, wxT("Command"));
120
 
        m_listCtrl1->InsertColumn(2, wxT("Sub Menu?"));
 
120
        m_listCtrl1->InsertColumn(1, wxT("Expression"));
 
121
        m_listCtrl1->InsertColumn(2, wxT("Debugger Command"));
121
122
 
122
123
        //add items from the saved items
123
124
        DebuggerConfigTool::Get()->ReadObject(wxT("DebuggerCommands"), &m_data);
126
127
        std::vector<DebuggerCmdData> cmds = m_data.GetCmds();
127
128
        for (size_t i=0; i<cmds.size(); i++) {
128
129
                DebuggerCmdData cmd = cmds.at(i);
129
 
                wxString subMenu(wxT("No"));
130
 
 
131
 
                if (cmd.GetIsSubMenu()) {
132
 
                        subMenu = wxT("Yes");
133
 
                }
134
130
 
135
131
                long item = AppendListCtrlRow(m_listCtrl1);
136
132
                SetColumnText(m_listCtrl1, item, 0, cmd.GetName());
137
133
                SetColumnText(m_listCtrl1, item, 1, cmd.GetCommand());
138
 
                SetColumnText(m_listCtrl1, item, 2, subMenu);
 
134
                SetColumnText(m_listCtrl1, item, 2, cmd.GetDbgCommand());
139
135
        }
140
136
        m_listCtrl1->SetColumnWidth(0, 100);
141
137
        m_listCtrl1->SetColumnWidth(1, 200);
153
149
                DebuggerMgr::Get().GetDebuggerInformation(page->m_title, info);
154
150
 
155
151
                //populate the information and save it
156
 
                info.enableDebugLog = page->m_checkBoxEnableLog->GetValue();
 
152
                info.enableDebugLog           = page->m_checkBoxEnableLog->GetValue();
157
153
                info.enablePendingBreakpoints = page->m_checkBoxEnablePendingBreakpoints->GetValue();
158
 
                info.path = page->m_filePicker->GetPath();
159
 
                info.name = page->m_title;
160
 
                info.breakAtWinMain = page->m_checkBreakAtWinMain->IsChecked();
161
 
                info.resolveThis = page->m_checkResolveStarThis->IsChecked();
162
 
                info.showTerminal = page->m_checkShowTerminal->IsChecked();
163
 
                info.consoleCommand = EditorConfigST::Get()->GetOptions()->GetProgramConsoleCommand();
164
 
                info.useRelativeFilePaths = page->m_checkUseRelativePaths->IsChecked();
165
 
 
 
154
                info.path                     = page->m_textCtrDbgPath->GetValue();
 
155
                info.name                     = page->m_title;
 
156
                info.breakAtWinMain           = page->m_checkBreakAtWinMain->IsChecked();
 
157
                info.showTerminal             = page->m_checkShowTerminal->IsChecked();
 
158
                info.consoleCommand           = EditorConfigST::Get()->GetOptions()->GetProgramConsoleCommand();
 
159
                info.useRelativeFilePaths     = page->m_checkUseRelativePaths->IsChecked();
 
160
                info.catchThrow               = page->m_catchThrow->IsChecked();
 
161
                info.showTooltips             = page->m_showTooltips->IsChecked();
 
162
                info.startupCommands          = page->m_textCtrlStartupCommands->GetValue();
 
163
                info.maxDisplayStringSize     = page->m_spinCtrlNumElements->GetValue();
 
164
                info.resolveLocals            = page->m_checkBoxExpandLocals->IsChecked();
 
165
#ifdef __WXMSW__
 
166
                info.debugAsserts             = page->m_checkBoxDebugAssert->IsChecked();
 
167
#endif
166
168
                DebuggerMgr::Get().SetDebuggerInformation(page->m_title, info);
167
169
        }
168
170
 
171
173
        std::vector<DebuggerCmdData> cmdArr;
172
174
        for(int i=0; i<count; i++){
173
175
                DebuggerCmdData cmd;
174
 
                cmd.SetName( GetColumnText(m_listCtrl1, i, 0) );
175
 
                cmd.SetCommand( GetColumnText(m_listCtrl1, i, 1) );
176
 
 
177
 
                cmd.SetIsSubMenu( false );
178
 
                if(GetColumnText(m_listCtrl1, i, 2) == wxT("Yes")){
179
 
                        cmd.SetIsSubMenu( true );
180
 
                }
181
 
 
 
176
                cmd.SetName      ( GetColumnText(m_listCtrl1, i, 0) );
 
177
                cmd.SetCommand   ( GetColumnText(m_listCtrl1, i, 1) );
 
178
                cmd.SetDbgCommand( GetColumnText(m_listCtrl1, i, 2) );
182
179
                cmdArr.push_back(cmd);
183
180
        }
184
181
        m_data.SetCmds(cmdArr);
200
197
        DbgCommandDlg *dlg = new DbgCommandDlg(this);
201
198
        if (dlg->ShowModal() == wxID_OK) {
202
199
                //add new command to the table
203
 
                wxString name = dlg->GetName();
204
 
                wxString cmd  = dlg->GetCommand();
205
 
                wxString subMenu;
206
 
                if (dlg->IsSubMenu()) {
207
 
                        subMenu = wxT("Yes");
208
 
                } else {
209
 
                        subMenu = wxT("No");
210
 
                }
211
 
 
 
200
                wxString name       = dlg->GetName();
 
201
                wxString expression = dlg->GetExpression();
 
202
                wxString dbgCmd     = dlg->GetDbgCommand();
212
203
                long item;
213
204
                wxListItem info;
214
205
 
218
209
                        wxString existingName = GetColumnText(m_listCtrl1, i, 0);
219
210
                        if(name == existingName){
220
211
                                dlg->Destroy();
221
 
                                wxString msg;
222
 
                                wxMessageBox(_("Debugger shortcut with the same name already exist"), wxT("CodeLite"), wxOK | wxICON_INFORMATION);
 
212
                                wxMessageBox(_("Debugger type with the same name already exist"), wxT("CodeLite"), wxOK | wxICON_INFORMATION);
223
213
                                return;
224
214
                        }
225
215
                }
228
218
                info.SetColumn(0);
229
219
                item = m_listCtrl1->InsertItem(info);
230
220
 
231
 
                SetColumnText(m_listCtrl1, item, 0, name);
232
 
                SetColumnText(m_listCtrl1, item, 1, cmd);
233
 
                SetColumnText(m_listCtrl1, item, 2, subMenu);
 
221
                SetColumnText(m_listCtrl1, item, 0, name       );
 
222
                SetColumnText(m_listCtrl1, item, 1, expression );
 
223
                SetColumnText(m_listCtrl1, item, 2, dbgCmd);
234
224
 
235
225
                m_listCtrl1->SetColumnWidth(0, 100);
236
 
                m_listCtrl1->SetColumnWidth(1, 400);
237
 
                m_listCtrl1->SetColumnWidth(2, 100);
 
226
                m_listCtrl1->SetColumnWidth(1, 200);
 
227
                m_listCtrl1->SetColumnWidth(1, 200);
238
228
        }
239
229
        dlg->Destroy();
240
230
}
277
267
        }
278
268
 
279
269
        //popup edit dialog
280
 
        DbgCommandDlg *dlg = new DbgCommandDlg(this);
281
 
        wxString name = GetColumnText(m_listCtrl1, m_selectedItem, 0);
282
 
        wxString cmd  = GetColumnText(m_listCtrl1, m_selectedItem, 1);
283
 
        wxString sm   = GetColumnText(m_listCtrl1, m_selectedItem, 2);
284
 
 
285
 
        bool subMenu(false);
286
 
        if (sm == wxT("Yes")) {
287
 
                subMenu = true;
288
 
        }
289
 
 
290
 
        dlg->SetName(name);
291
 
        dlg->SetCommand(cmd);
292
 
        dlg->SetAsSubMenu(subMenu);
293
 
 
294
 
        if (dlg->ShowModal() == wxID_OK) {
295
 
                //update the item
296
 
                sm = wxT("No");
297
 
                if (dlg->IsSubMenu()) {
298
 
                        sm = wxT("Yes");
299
 
                }
300
 
 
301
 
                SetColumnText(m_listCtrl1, m_selectedItem, 0, dlg->GetName());
302
 
                SetColumnText(m_listCtrl1, m_selectedItem, 1, dlg->GetCommand());
303
 
                SetColumnText(m_listCtrl1, m_selectedItem, 2, sm);
304
 
        }
305
 
 
306
 
        dlg->Destroy();
 
270
        DbgCommandDlg dlg(this);
 
271
 
 
272
        wxString name  = GetColumnText(m_listCtrl1, m_selectedItem, 0);
 
273
        wxString expr  = GetColumnText(m_listCtrl1, m_selectedItem, 1);
 
274
        wxString dbgCmd= GetColumnText(m_listCtrl1, m_selectedItem, 2);
 
275
 
 
276
        dlg.SetName(name);
 
277
        dlg.SetExpression(expr);
 
278
        dlg.SetDbgCommand(dbgCmd);
 
279
 
 
280
        if (dlg.ShowModal() == wxID_OK) {
 
281
                SetColumnText(m_listCtrl1, m_selectedItem, 0, dlg.GetName());
 
282
                SetColumnText(m_listCtrl1, m_selectedItem, 1, dlg.GetExpression());
 
283
                SetColumnText(m_listCtrl1, m_selectedItem, 2, dlg.GetDbgCommand());
 
284
        }
307
285
}
308
286
 
309
287
void DebuggerSettingsDlg::DoDeleteItem()
314
292
        m_listCtrl1->DeleteItem(m_selectedItem);
315
293
        m_selectedItem = wxNOT_FOUND;
316
294
}
 
295
 
 
296
DebuggerSettingsDlg::~DebuggerSettingsDlg()
 
297
{
 
298
        WindowAttrManager::Save(this, wxT("DbgSettingsDlg"), NULL);
 
299
}