~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/plugins/debuggergdb/threadsdlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3
 
 * http://www.gnu.org/licenses/gpl-3.0.html
4
 
 *
5
 
 * $Revision$
6
 
 * $Id$
7
 
 * $HeadURL$
8
 
 */
9
 
 
10
 
#include <sdk.h>
11
 
#include "threadsdlg.h"
12
 
#include "debuggergdb.h"
13
 
#include "debuggerdriver.h"
14
 
#include <wx/intl.h>
15
 
#include <wx/xrc/xmlres.h>
16
 
#include <wx/menu.h>
17
 
#include <globals.h>
18
 
 
19
 
static const int idSwitch = wxNewId();
20
 
 
21
 
BEGIN_EVENT_TABLE(ThreadsDlg, wxPanel)
22
 
    EVT_LIST_ITEM_RIGHT_CLICK(XRCID("lstThreads"), ThreadsDlg::OnListRightClick)
23
 
    EVT_MENU(idSwitch, ThreadsDlg::OnSwitchThread)
24
 
END_EVENT_TABLE()
25
 
 
26
 
ThreadsDlg::ThreadsDlg(wxWindow* parent, DebuggerGDB* debugger)
27
 
    : m_pDbg(debugger)
28
 
{
29
 
    //ctor
30
 
    wxXmlResource::Get()->LoadPanel(this, parent, _T("dlgThreads"));
31
 
//    SetWindowStyle(GetWindowStyle() | wxFRAME_FLOAT_ON_PARENT);
32
 
 
33
 
    wxListCtrl* lst = XRCCTRL(*this, "lstThreads", wxListCtrl);
34
 
 
35
 
    wxFont font(8, wxMODERN, wxNORMAL, wxNORMAL);
36
 
    lst->SetFont(font);
37
 
    Clear();
38
 
}
39
 
 
40
 
ThreadsDlg::~ThreadsDlg()
41
 
{
42
 
    //dtor
43
 
}
44
 
 
45
 
void ThreadsDlg::Clear()
46
 
{
47
 
    wxListCtrl* lst = XRCCTRL(*this, "lstThreads", wxListCtrl);
48
 
    lst->ClearAll();
49
 
    lst->Freeze();
50
 
    lst->DeleteAllItems();
51
 
    lst->InsertColumn(0, _("Active"), wxLIST_FORMAT_LEFT, 64);
52
 
    lst->InsertColumn(1, _("Number"), wxLIST_FORMAT_RIGHT, 64);
53
 
    lst->InsertColumn(2, _("Info"), wxLIST_FORMAT_LEFT);
54
 
    lst->Thaw();
55
 
}
56
 
 
57
 
void ThreadsDlg::AddThread(const wxString& active_mark, const wxString& thread_num, const wxString& thread_info)
58
 
{
59
 
//    Manager::Get()->GetLogManager()->DebugLog(_T("Add: mark=%s, num=%s, info=%s"), active_mark.c_str(), thread_num.c_str(), thread_info.c_str());
60
 
    wxListCtrl* lst = XRCCTRL(*this, "lstThreads", wxListCtrl);
61
 
    lst->Freeze();
62
 
    lst->InsertItem(lst->GetItemCount(), active_mark);
63
 
    int idx = lst->GetItemCount() - 1;
64
 
    lst->SetItem(idx, 1, thread_num);
65
 
    lst->SetItem(idx, 2, thread_info);
66
 
 
67
 
    lst->SetColumnWidth(2, wxLIST_AUTOSIZE);
68
 
    lst->Thaw();
69
 
}
70
 
 
71
 
void ThreadsDlg::OnListRightClick(wxListEvent& event)
72
 
{
73
 
    wxListCtrl* lst = XRCCTRL(*this, "lstThreads", wxListCtrl);
74
 
 
75
 
    wxMenu m;
76
 
    m.Append(idSwitch, _("Switch to this thread"));
77
 
    lst->PopupMenu(&m);
78
 
}
79
 
 
80
 
void ThreadsDlg::OnSwitchThread(wxCommandEvent& event)
81
 
{
82
 
    wxListCtrl* lst = XRCCTRL(*this, "lstThreads", wxListCtrl);
83
 
    if (lst->GetSelectedItemCount() == 0)
84
 
        return;
85
 
 
86
 
    // find selected item index
87
 
    int index = lst->GetNextItem(-1,
88
 
                                 wxLIST_NEXT_ALL,
89
 
                                 wxLIST_STATE_SELECTED);
90
 
 
91
 
    wxString active = lst->GetItemText(index);
92
 
    if (active == _T("*"))
93
 
        return; // same thread
94
 
 
95
 
    wxString thread;
96
 
    wxListItem info;
97
 
    info.m_itemId = index;
98
 
    info.m_col = 1;
99
 
    info.m_mask = wxLIST_MASK_TEXT;
100
 
    if (lst->GetItem(info))
101
 
        thread = info.m_text;
102
 
    else
103
 
        return;
104
 
 
105
 
    unsigned long thread_num;
106
 
    if (thread.ToULong(&thread_num, 10))
107
 
        if (m_pDbg->GetState().HasDriver())
108
 
            m_pDbg->GetState().GetDriver()->SwitchThread(thread_num);
109
 
}
 
1
/*
 
2
 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
 
3
 * http://www.gnu.org/licenses/gpl-3.0.html
 
4
 *
 
5
 * $Revision: 5931 $
 
6
 * $Id: threadsdlg.cpp 5931 2009-11-21 15:58:42Z biplab $
 
7
 * $HeadURL: svn+ssh://jenslody@svn.berlios.de/svnroot/repos/codeblocks/trunk/src/plugins/debuggergdb/threadsdlg.cpp $
 
8
 */
 
9
 
 
10
#include <sdk.h>
 
11
#include "threadsdlg.h"
 
12
#include "debuggergdb.h"
 
13
#include "debuggerdriver.h"
 
14
#include <wx/intl.h>
 
15
#include <wx/xrc/xmlres.h>
 
16
#include <wx/menu.h>
 
17
#include <globals.h>
 
18
 
 
19
static const int idSwitch = wxNewId();
 
20
 
 
21
BEGIN_EVENT_TABLE(ThreadsDlg, wxPanel)
 
22
    EVT_LIST_ITEM_RIGHT_CLICK(XRCID("lstThreads"), ThreadsDlg::OnListRightClick)
 
23
    EVT_MENU(idSwitch, ThreadsDlg::OnSwitchThread)
 
24
END_EVENT_TABLE()
 
25
 
 
26
ThreadsDlg::ThreadsDlg(wxWindow* parent, DebuggerGDB* debugger)
 
27
    : m_pDbg(debugger)
 
28
{
 
29
    //ctor
 
30
    wxXmlResource::Get()->LoadPanel(this, parent, _T("dlgThreads"));
 
31
//    SetWindowStyle(GetWindowStyle() | wxFRAME_FLOAT_ON_PARENT);
 
32
 
 
33
    wxListCtrl* lst = XRCCTRL(*this, "lstThreads", wxListCtrl);
 
34
 
 
35
    wxFont font(8, wxMODERN, wxNORMAL, wxNORMAL);
 
36
    lst->SetFont(font);
 
37
    Clear();
 
38
}
 
39
 
 
40
ThreadsDlg::~ThreadsDlg()
 
41
{
 
42
    //dtor
 
43
}
 
44
 
 
45
void ThreadsDlg::Clear()
 
46
{
 
47
    wxListCtrl* lst = XRCCTRL(*this, "lstThreads", wxListCtrl);
 
48
    lst->ClearAll();
 
49
    lst->Freeze();
 
50
    lst->DeleteAllItems();
 
51
    lst->InsertColumn(0, _("Active"), wxLIST_FORMAT_LEFT, 64);
 
52
    lst->InsertColumn(1, _("Number"), wxLIST_FORMAT_RIGHT, 64);
 
53
    lst->InsertColumn(2, _("Info"), wxLIST_FORMAT_LEFT);
 
54
    lst->Thaw();
 
55
}
 
56
 
 
57
void ThreadsDlg::AddThread(const wxString& active_mark, const wxString& thread_num, const wxString& thread_info)
 
58
{
 
59
//    Manager::Get()->GetLogManager()->DebugLog(_T("Add: mark=%s, num=%s, info=%s"), active_mark.c_str(), thread_num.c_str(), thread_info.c_str());
 
60
    wxListCtrl* lst = XRCCTRL(*this, "lstThreads", wxListCtrl);
 
61
    lst->Freeze();
 
62
    lst->InsertItem(lst->GetItemCount(), active_mark);
 
63
    int idx = lst->GetItemCount() - 1;
 
64
    lst->SetItem(idx, 1, thread_num);
 
65
    lst->SetItem(idx, 2, thread_info);
 
66
 
 
67
    lst->SetColumnWidth(2, wxLIST_AUTOSIZE);
 
68
    lst->Thaw();
 
69
}
 
70
 
 
71
void ThreadsDlg::OnListRightClick(wxListEvent& event)
 
72
{
 
73
    wxListCtrl* lst = XRCCTRL(*this, "lstThreads", wxListCtrl);
 
74
 
 
75
    wxMenu m;
 
76
    m.Append(idSwitch, _("Switch to this thread"));
 
77
    lst->PopupMenu(&m);
 
78
}
 
79
 
 
80
void ThreadsDlg::OnSwitchThread(wxCommandEvent& event)
 
81
{
 
82
    wxListCtrl* lst = XRCCTRL(*this, "lstThreads", wxListCtrl);
 
83
    if (lst->GetSelectedItemCount() == 0)
 
84
        return;
 
85
 
 
86
    // find selected item index
 
87
    int index = lst->GetNextItem(-1,
 
88
                                 wxLIST_NEXT_ALL,
 
89
                                 wxLIST_STATE_SELECTED);
 
90
 
 
91
    wxString active = lst->GetItemText(index);
 
92
    if (active == _T("*"))
 
93
        return; // same thread
 
94
 
 
95
    wxString thread;
 
96
    wxListItem info;
 
97
    info.m_itemId = index;
 
98
    info.m_col = 1;
 
99
    info.m_mask = wxLIST_MASK_TEXT;
 
100
    if (lst->GetItem(info))
 
101
        thread = info.m_text;
 
102
    else
 
103
        return;
 
104
 
 
105
    unsigned long thread_num;
 
106
    if (thread.ToULong(&thread_num, 10))
 
107
        if (m_pDbg->GetState().HasDriver())
 
108
            m_pDbg->GetState().GetDriver()->SwitchThread(thread_num);
 
109
}