Code::Blocks  SVN r11506
debuggersettingspanel.cpp
Go to the documentation of this file.
1 #include "sdk.h"
3 
4 #ifndef CB_PRECOMP
5  //(*InternalHeadersPCH(DebuggerSettingsPanel)
6  #include <wx/string.h>
7  #include <wx/intl.h>
8  //*)
9 
10  #include <wx/textdlg.h>
11 
12  #include "cbplugin.h"
13  #include "debuggermanager.h"
14 #endif
15 //(*InternalHeaders(DebuggerSettingsPanel)
16 //*)
17 
18 #include "debuggersettingsdlg.h"
19 
20 //(*IdInit(DebuggerSettingsPanel)
25 //*)
26 
27 BEGIN_EVENT_TABLE(DebuggerSettingsPanel,wxPanel)
28  //(*EventTable(DebuggerSettingsPanel)
29  //*)
30 END_EVENT_TABLE()
31 
33  m_dialog(dialog),
34  m_plugin(plugin)
35 {
36  //(*Initialize(DebuggerSettingsPanel)
37  wxBoxSizer* buttonSizer;
38  wxTextCtrl* textInfo;
39  wxButton* butReset;
40  wxButton* butCreate;
41  wxBoxSizer* mainSizer;
42  wxStaticBoxSizer* infoSizer;
43  wxButton* butDelete;
44 
45  Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("wxID_ANY"));
46  mainSizer = new wxBoxSizer(wxVERTICAL);
47  buttonSizer = new wxBoxSizer(wxHORIZONTAL);
48  butCreate = new wxButton(this, ID_BUTTON_CREATE, _("Create Config"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON_CREATE"));
49  buttonSizer->Add(butCreate, 1, wxALIGN_BOTTOM, 5);
50  butDelete = new wxButton(this, ID_BUTTON_DELETE, _("Delete Config"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON_DELETE"));
51  buttonSizer->Add(butDelete, 1, wxLEFT|wxALIGN_BOTTOM, 5);
52  butReset = new wxButton(this, ID_BUTTON_RESET, _("Reset defaults"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON_RESET"));
53  buttonSizer->Add(butReset, 1, wxLEFT|wxALIGN_BOTTOM, 5);
54  mainSizer->Add(buttonSizer, 0, wxALL|wxEXPAND|wxSHAPED, 0);
55  infoSizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Info"));
56  textInfo = new wxTextCtrl(this, ID_TEXTCTRL_INFO, wxEmptyString, wxDefaultPosition, wxSize(186,243), 0, wxDefaultValidator, _T("ID_TEXTCTRL_INFO"));
57  textInfo->Disable();
58  infoSizer->Add(textInfo, 1, wxEXPAND, 5);
59  mainSizer->Add(infoSizer, 1, wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 0);
60  SetSizer(mainSizer);
61  mainSizer->Fit(this);
62  mainSizer->SetSizeHints(this);
63 
64  Connect(ID_BUTTON_CREATE,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&DebuggerSettingsPanel::OnButtonCreate);
65  Connect(ID_BUTTON_DELETE,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&DebuggerSettingsPanel::OnButtonDelete);
66  Connect(ID_BUTTON_RESET,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&DebuggerSettingsPanel::OnButtonReset);
67  //*)
68 
69  // If this debugger plugin is used to debug some program at the moment
70  // - disable the buttons for managing its configurations.
71  if (plugin && plugin->IsRunning())
72  {
73  butCreate->Disable();
74  butDelete->Disable();
75  butReset->Disable();
76  }
77 }
78 
80 {
81  //(*Destroy(DebuggerSettingsPanel)
82  //*)
83 }
84 
86 {
87  wxTextEntryDialog dialog(this, _("Please specify a name for the configuration"), _("Create config"));
88  PlaceWindow(&dialog);
89  while (dialog.ShowModal() == wxID_OK)
90  {
91  wxString name = dialog.GetValue();
92  if (!name.empty())
93  {
94  if (m_dialog->CreateConfig(this, m_plugin, name))
95  break;
96  else
97  cbMessageBox(_("Name is not unique! Choose different one."), _("Error"), wxICON_ERROR, this);
98  }
99  }
100 }
101 
103 {
105 }
106 
108 {
109  if (cbMessageBox(_("Are you sure you want to reset the settings for the selected plugin?"), _("Reset settings"),
111  {
112  return;
113  }
114  m_dialog->ResetConfig(this, m_plugin);
115 }
wxSize Fit(wxWindow *window)
static const long ID_BUTTON_RESET
int wxNewId()
#define wxICON_QUESTION
const wxValidator wxDefaultValidator
Base class for debugger plugins.
Definition: cbplugin.h:397
DebuggerSettingsDlg * m_dialog
static const long ID_TEXTCTRL_INFO
void OnButtonCreate(wxCommandEvent &event)
#define wxICON_ERROR
cbDebuggerPlugin * m_plugin
#define _T(string)
void OnButtonDelete(wxCommandEvent &event)
bool empty() const
void DeleteConfig(wxWindow *panel, cbDebuggerPlugin *plugin)
#define wxTAB_TRAVERSAL
wxSizerItem * Add(wxWindow *window, const wxSizerFlags &flags)
static const long ID_BUTTON_DELETE
const wxSize wxDefaultSize
const wxPoint wxDefaultPosition
virtual int ShowModal()
void OnButtonReset(wxCommandEvent &event)
wxString wxEmptyString
const wxString & _(const wxString &string)
DLLIMPORT void PlaceWindow(wxTopLevelWindow *w, cbPlaceDialogMode mode=pdlBest, bool enforce=false)
Definition: globals.cpp:1177
void SetSizeHints(wxWindow *window)
bool CreateConfig(wxWindow *panel, cbDebuggerPlugin *plugin, const wxString &name)
#define wxYES
DLLIMPORT int cbMessageBox(const wxString &message, const wxString &caption=wxEmptyString, int style=wxOK, wxWindow *parent=NULL, int x=-1, int y=-1)
wxMessageBox wrapper.
Definition: globals.cpp:1395
void ResetConfig(wxWindow *panel, cbDebuggerPlugin *plugin)
static const long ID_BUTTON_CREATE