Code::Blocks  SVN r11506
cpuregistersdlg.cpp
Go to the documentation of this file.
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: 10769 $
6  * $Id: cpuregistersdlg.cpp 10769 2016-02-06 14:26:58Z mortenmacfly $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/src/cpuregistersdlg.cpp $
8  */
9 
10 #include "sdk.h"
11 
12 #include "cpuregistersdlg.h"
13 #include <wx/intl.h>
14 #include <wx/sizer.h>
15 #include <wx/listctrl.h>
16 
17 BEGIN_EVENT_TABLE(CPURegistersDlg, wxPanel)
18 // EVT_BUTTON(XRCID("btnRefresh"), CPURegistersDlg::OnRefresh)
19 END_EVENT_TABLE()
20 
22  wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
23 {
24  wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
25  m_pList = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL);
26  sizer->Add(m_pList, 1, wxGROW);
27  SetSizer(sizer);
28  Layout();
29 
31  m_pList->SetFont(font);
32 
33  Clear();
34 }
35 
37 {
38  m_pList->ClearAll();
39  m_pList->Freeze();
41  m_pList->InsertColumn(0, _("Register"), wxLIST_FORMAT_LEFT);
43  m_pList->InsertColumn(2, _("Interpreted"), wxLIST_FORMAT_LEFT);
44  m_pList->Thaw();
45 }
46 
48 {
49  for (int i = 0; i < m_pList->GetItemCount(); ++i)
50  {
51  if (m_pList->GetItemText(i).CmpNoCase(reg_name) == 0)
52  return i;
53  }
54  return -1;
55 }
56 
57 void CPURegistersDlg::SetRegisterValue(const wxString& reg_name, const wxString& hexValue, const wxString& interpreted)
58 {
59  // find existing register
60  int idx = RegisterIndex(reg_name);
61  if (idx == -1)
62  {
63  // if it doesn't exist, add it
64  idx = m_pList->GetItemCount();
65  m_pList->InsertItem(idx, reg_name);
66  }
67 
68  m_pList->SetItem(idx, 1, hexValue);
69  m_pList->SetItem(idx, 2, interpreted);
70 
71 #if defined(__WXMSW__) || wxCHECK_VERSION(3, 1, 0)
72  const int autoSizeMode = wxLIST_AUTOSIZE_USEHEADER;
73 #else
74  const int autoSizeMode = wxLIST_AUTOSIZE;
75 #endif
76 
77  for (int i = 0; i < 3; ++i)
78  {
79  m_pList->SetColumnWidth(i, autoSizeMode);
80  }
81 }
82 
84 {
85  m_pList->Enable(enable);
86 }
void EnableWindow(bool enable)
#define wxLC_REPORT
int CmpNoCase(const wxString &s) const
long InsertItem(wxListItem &info)
wxSizerItem * Add(wxWindow *window, const wxSizerFlags &flags)
int RegisterIndex(const wxString &reg_name)
void SetRegisterValue(const wxString &reg_name, const wxString &hexValue, const wxString &interpreted)
bool DeleteAllItems()
int GetItemCount() const
wxString GetItemText(long item, int col=0) const
#define wxLC_SINGLE_SEL
const wxString & _(const wxString &string)
long InsertColumn(long col, const wxListItem &info)
wxListCtrl * m_pList
bool SetItem(wxListItem &info)
bool SetColumnWidth(int col, int width)
void ClearAll()