~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/Valgrind/valgrind_config.cpp

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "valgrind_config.h"
 
2
 
 
3
//(*InternalHeaders(ValgrindConfigurationPanel)
 
4
#include <wx/checkbox.h>
 
5
#include <wx/sizer.h>
 
6
#include <wx/button.h>
 
7
#include <wx/string.h>
 
8
#include <wx/intl.h>
 
9
#include <wx/stattext.h>
 
10
#include <wx/textctrl.h>
 
11
//*)
 
12
#include <wx/filedlg.h>
 
13
 
 
14
#include <configmanager.h>
 
15
 
 
16
//(*IdInit(ValgrindConfigurationPanel)
 
17
const long ValgrindConfigurationPanel::IdExecutablePath = wxNewId();
 
18
const long ValgrindConfigurationPanel::IdBrowseButton = wxNewId();
 
19
const long ValgrindConfigurationPanel::IdMemCheckArgs = wxNewId();
 
20
const long ValgrindConfigurationPanel::IdFullMemCheck = wxNewId();
 
21
const long ValgrindConfigurationPanel::IdTrackOrigins = wxNewId();
 
22
const long ValgrindConfigurationPanel::IdShowReachable = wxNewId();
 
23
const long ValgrindConfigurationPanel::IdCachegrindArgs = wxNewId();
 
24
//*)
 
25
 
 
26
BEGIN_EVENT_TABLE(ValgrindConfigurationPanel,cbConfigurationPanel)
 
27
        //(*EventTable(ValgrindConfigurationPanel)
 
28
        //*)
 
29
END_EVENT_TABLE()
 
30
 
 
31
ValgrindConfigurationPanel::ValgrindConfigurationPanel(wxWindow *parent)
 
32
{
 
33
        BuildContent(parent);
 
34
        LoadSettings();
 
35
}
 
36
 
 
37
void ValgrindConfigurationPanel::BuildContent(wxWindow *parent)
 
38
{
 
39
        //(*Initialize(ValgrindConfigurationPanel)
 
40
        wxStaticText* CacheGrindArgs;
 
41
        wxButton* BrowseButton;
 
42
        wxStaticText* MemCheckArgs;
 
43
        wxStaticText* StaticText1;
 
44
        wxBoxSizer* MemCheckArgSizer;
 
45
        wxStaticBoxSizer* MemCheckOptSizer;
 
46
        wxBoxSizer* MainSizer;
 
47
        wxStaticBoxSizer* CachegrindOptSizer;
 
48
        wxBoxSizer* ExecSizer;
 
49
 
 
50
        Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("wxID_ANY"));
 
51
        MainSizer = new wxBoxSizer(wxVERTICAL);
 
52
        ExecSizer = new wxBoxSizer(wxHORIZONTAL);
 
53
        StaticText1 = new wxStaticText(this, wxID_ANY, _("Executable:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
 
54
        ExecSizer->Add(StaticText1, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
 
55
        m_ExecutablePath = new wxTextCtrl(this, IdExecutablePath, _("valgrind"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("IdExecutablePath"));
 
56
        ExecSizer->Add(m_ExecutablePath, 1, wxALL|wxEXPAND, 5);
 
57
        BrowseButton = new wxButton(this, IdBrowseButton, _("..."), wxDefaultPosition, wxSize(29,28), 0, wxDefaultValidator, _T("IdBrowseButton"));
 
58
        ExecSizer->Add(BrowseButton, 0, wxALL|wxALIGN_BOTTOM, 5);
 
59
        MainSizer->Add(ExecSizer, 0, wxALL|wxEXPAND, 0);
 
60
        MemCheckOptSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("MemCheck options"));
 
61
        MemCheckArgSizer = new wxBoxSizer(wxHORIZONTAL);
 
62
        MemCheckArgs = new wxStaticText(this, wxID_ANY, _("Args:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
 
63
        MemCheckArgSizer->Add(MemCheckArgs, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
 
64
        m_MemCheckArgs = new wxTextCtrl(this, IdMemCheckArgs, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("IdMemCheckArgs"));
 
65
        MemCheckArgSizer->Add(m_MemCheckArgs, 1, wxALL|wxEXPAND, 5);
 
66
        MemCheckOptSizer->Add(MemCheckArgSizer, 0, wxALL|wxEXPAND, 0);
 
67
        m_FullMemCheck = new wxCheckBox(this, IdFullMemCheck, _("Full MemCheck"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("IdFullMemCheck"));
 
68
        m_FullMemCheck->SetValue(true);
 
69
        MemCheckOptSizer->Add(m_FullMemCheck, 1, wxTOP|wxLEFT|wxRIGHT|wxEXPAND, 5);
 
70
        m_TrackOrigins = new wxCheckBox(this, IdTrackOrigins, _("Track Origins"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("IdTrackOrigins"));
 
71
        m_TrackOrigins->SetValue(true);
 
72
        MemCheckOptSizer->Add(m_TrackOrigins, 1, wxTOP|wxLEFT|wxRIGHT|wxEXPAND, 5);
 
73
        m_ShowReachable = new wxCheckBox(this, IdShowReachable, _("Show reachable"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("IdShowReachable"));
 
74
        m_ShowReachable->SetValue(false);
 
75
        MemCheckOptSizer->Add(m_ShowReachable, 1, wxTOP|wxLEFT|wxRIGHT|wxEXPAND, 5);
 
76
        MainSizer->Add(MemCheckOptSizer, 0, wxALL|wxEXPAND, 5);
 
77
        CachegrindOptSizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Cachegrind options"));
 
78
        CacheGrindArgs = new wxStaticText(this, wxID_ANY, _("Args:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
 
79
        CachegrindOptSizer->Add(CacheGrindArgs, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
 
80
        m_CachegrindArgs = new wxTextCtrl(this, IdCachegrindArgs, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("IdCachegrindArgs"));
 
81
        CachegrindOptSizer->Add(m_CachegrindArgs, 1, wxALL|wxEXPAND, 5);
 
82
        MainSizer->Add(CachegrindOptSizer, 0, wxALL|wxEXPAND, 5);
 
83
        SetSizer(MainSizer);
 
84
        MainSizer->Fit(this);
 
85
        MainSizer->SetSizeHints(this);
 
86
 
 
87
        Connect(IdBrowseButton,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ValgrindConfigurationPanel::OnBrowseButtonClick);
 
88
        //*)
 
89
}
 
90
 
 
91
ValgrindConfigurationPanel::~ValgrindConfigurationPanel()
 
92
{
 
93
        //(*Destroy(ValgrindConfigurationPanel)
 
94
        //*)
 
95
}
 
96
 
 
97
void ValgrindConfigurationPanel::LoadSettings()
 
98
{
 
99
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("valgrind"));
 
100
 
 
101
    m_ExecutablePath->SetValue(cfg->Read(wxT("/exec_path"), wxT("valgrind")));
 
102
 
 
103
    m_MemCheckArgs->SetValue(cfg->Read(wxT("/memcheck_args"), wxEmptyString));
 
104
    m_FullMemCheck->SetValue(cfg->ReadBool(wxT("/memcheck_full"), true));
 
105
    m_TrackOrigins->SetValue(cfg->ReadBool(wxT("/memcheck_track_origins"), true));
 
106
    m_ShowReachable->SetValue(cfg->ReadBool(wxT("/memcheck_reachable"), false));
 
107
 
 
108
    m_CachegrindArgs->SetValue(cfg->Read(wxT("/cachegrind_args"), wxEmptyString));
 
109
}
 
110
 
 
111
void ValgrindConfigurationPanel::OnApply()
 
112
{
 
113
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("valgrind"));
 
114
 
 
115
    cfg->Write(wxT("/exec_path"), m_ExecutablePath->GetValue());
 
116
 
 
117
    cfg->Write(wxT("/memcheck_args"), m_MemCheckArgs->GetValue());
 
118
    cfg->Write(wxT("/memcheck_full"), m_FullMemCheck->GetValue());
 
119
    cfg->Write(wxT("/memcheck_track_origins"), m_TrackOrigins->GetValue());
 
120
    cfg->Write(wxT("/memcheck_reachable"), m_ShowReachable->GetValue());
 
121
 
 
122
    cfg->Write(wxT("/cachegrind_args"), m_CachegrindArgs->GetValue());
 
123
}
 
124
 
 
125
void ValgrindConfigurationPanel::OnBrowseButtonClick(wxCommandEvent& /*event*/)
 
126
{
 
127
    wxFileDialog dialog(this, wxT("Choose path"));
 
128
    if (dialog.ShowModal() == wxID_OK)
 
129
    {
 
130
        m_ExecutablePath->SetValue(dialog.GetPath());
 
131
    }
 
132
}