Code::Blocks  SVN r11506
externaldepsdlg.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  *
5  * $Revision: 10912 $
6  * $Id: externaldepsdlg.cpp 10912 2016-09-25 16:10:13Z fuscated $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/sdk/externaldepsdlg.cpp $
8  */
9 
10 #include "sdk_precomp.h"
11 
12 #ifndef CB_PRECOMP
13  #include "cbproject.h"
14  #include "projectbuildtarget.h"
15  #include <wx/xrc/xmlres.h>
16  #include <wx/button.h>
17  #include <wx/listbox.h>
18  #include "globals.h"
19 #endif
20 
21 #include "externaldepsdlg.h"
22 #include <wx/msgdlg.h>
23 #include "editpathdlg.h"
24 
25 BEGIN_EVENT_TABLE(ExternalDepsDlg, wxScrollingDialog)
26  EVT_UPDATE_UI(-1, ExternalDepsDlg::OnUpdateUI)
27  EVT_LISTBOX_DCLICK(XRCID("lstAdditionalFiles"), ExternalDepsDlg::OnEditAdditional)
28  EVT_LISTBOX_DCLICK(XRCID("lstExternalFiles"), ExternalDepsDlg::OnEditExternal)
29  EVT_BUTTON(XRCID("btnAddAdditional"), ExternalDepsDlg::OnAddAdditional)
30  EVT_BUTTON(XRCID("btnEditAdditional"), ExternalDepsDlg::OnEditAdditional)
31  EVT_BUTTON(XRCID("btnDelAdditional"), ExternalDepsDlg::OnDelAdditional)
32  EVT_BUTTON(XRCID("btnAddExternal"), ExternalDepsDlg::OnAddExternal)
33  EVT_BUTTON(XRCID("btnEditExternal"), ExternalDepsDlg::OnEditExternal)
34  EVT_BUTTON(XRCID("btnDelExternal"), ExternalDepsDlg::OnDelExternal)
35 END_EVENT_TABLE()
36 
38  : m_pProject(project),
39  m_pTarget(target)
40 {
41  //ctor
42  wxXmlResource::Get()->LoadObject(this, parent, _T("dlgExternalDeps"),_T("wxScrollingDialog"));
43  XRCCTRL(*this, "wxID_CANCEL", wxButton)->SetDefault();
44  FillAdditional();
45  FillExternal();
46 }
47 
49 {
50  //dtor
51 }
52 
54 {
55  wxListBox* lst = XRCCTRL(*this, "lstAdditionalFiles", wxListBox);
56  lst->Clear();
58  for (unsigned int i = 0; i < array.GetCount(); ++i)
59  {
60  lst->Append(array[i]);
61  }
62 }
63 
65 {
66  wxListBox* lst = XRCCTRL(*this, "lstExternalFiles", wxListBox);
67  lst->Clear();
69  for (unsigned int i = 0; i < array.GetCount(); ++i)
70  {
71  lst->Append(array[i]);
72  }
73 }
74 
75 void ExternalDepsDlg::EndModal(int retCode)
76 {
77  wxString deps;
78  wxListBox* lst = XRCCTRL(*this, "lstExternalFiles", wxListBox);
79  for (unsigned int i = 0; i < (unsigned int)lst->GetCount(); ++i)
80  {
81  deps << lst->GetString(i) << _T(';');
82  }
84 
85  wxString files;
86  lst = XRCCTRL(*this, "lstAdditionalFiles", wxListBox);
87  for (unsigned int i = 0; i < (unsigned int)lst->GetCount(); ++i)
88  {
89  files << lst->GetString(i) << _T(';');
90  }
92 
93  return wxScrollingDialog::EndModal(retCode);
94 }
95 
96 //void ExternalDepsDlg::DoAdd(const wxString& listbox, const wxString& message)
97 #define DoAdd(listbox,message) \
98 { \
99  wxListBox* lst = XRCCTRL(*this, listbox, wxListBox); \
100  EditPathDlg dlg(this, \
101  m_pProject->GetBasePath(), \
102  m_pProject->GetBasePath(), \
103  message, \
104  wxEmptyString, \
105  false); \
106  PlaceWindow(&dlg); \
107  if (dlg.ShowModal() == wxID_OK) \
108  lst->Append(dlg.GetPath()); \
109 }
110 
111 //void ExternalDepsDlg::DoEdit(const wxString& listbox, const wxString& message)
112 #define DoEdit(listbox,message) \
113 { \
114  wxListBox* lst = XRCCTRL(*this, listbox, wxListBox); \
115  int sel = lst->GetSelection(); \
116  if (sel == -1) \
117  return; \
118  EditPathDlg dlg(this, \
119  lst->GetStringSelection(), \
120  m_pProject->GetBasePath(), \
121  message, \
122  wxEmptyString, \
123  false); \
124  PlaceWindow(&dlg); \
125  if (dlg.ShowModal() == wxID_OK) \
126  lst->SetString(sel, dlg.GetPath()); \
127 }
128 
129 //void ExternalDepsDlg::DoDel(const wxString& listbox)
130 #define DoDel(listbox) \
131 { \
132  wxListBox* lst = XRCCTRL(*this, listbox, wxListBox); \
133  int sel = lst->GetSelection(); \
134  if (sel == -1) \
135  return; \
136  if (cbMessageBox(_("Are you sure you want to remove this file?"), _("Remove file"), wxYES_NO | wxNO_DEFAULT, this) == wxID_NO) \
137  return; \
138  lst->Delete(sel); \
139 }
140 
142 {
143  DoAdd("lstAdditionalFiles", _("Add additional output file"));
144 }
145 
147 {
148  DoEdit("lstAdditionalFiles", _("Edit additional output file"));
149 }
150 
152 {
153  DoDel("lstAdditionalFiles");
154 }
155 
157 {
158  DoAdd("lstExternalFiles", _("Add external dependency file"));
159 }
160 
162 {
163  DoEdit("lstExternalFiles", _("Edit external dependency file"));
164 }
165 
167 {
168  DoDel("lstExternalFiles");
169 }
170 
172 {
173  int selAdd = XRCCTRL(*this, "lstAdditionalFiles", wxListBox)->GetSelection();
174  int selExt = XRCCTRL(*this, "lstExternalFiles", wxListBox)->GetSelection();
175 
176  XRCCTRL(*this, "btnEditAdditional", wxButton)->Enable(selAdd != -1);
177  XRCCTRL(*this, "btnDelAdditional", wxButton)->Enable(selAdd != -1);
178  XRCCTRL(*this, "btnEditExternal", wxButton)->Enable(selExt != -1);
179  XRCCTRL(*this, "btnDelExternal", wxButton)->Enable(selExt != -1);
180 }
DLLIMPORT wxArrayString GetArrayFromString(const wxString &text, const wxString &separator=DEFAULT_ARRAY_SEP, bool trimSpaces=true)
Definition: globals.cpp:134
void EndModal(int retCode)
Definition: sc_dialog.cpp:112
~ExternalDepsDlg() override
void OnAddExternal(wxCommandEvent &event)
virtual const wxString & GetAdditionalOutputFiles() const
void OnEditExternal(wxCommandEvent &event)
virtual const wxString & GetExternalDeps() const
#define _T(string)
void EndModal(int retCode) override
void OnDelAdditional(wxCommandEvent &event)
Represents a Code::Blocks project.
Definition: cbproject.h:96
void OnEditAdditional(wxCommandEvent &event)
virtual void SetExternalDeps(const wxString &deps)
Set a list of all the external files this targets depends on.
void OnDelExternal(wxCommandEvent &event)
const wxString & _(const wxString &string)
void OnAddAdditional(wxCommandEvent &event)
Represents a Code::Blocks project build target.
size_t GetCount() const
static wxXmlResource * Get()
#define DoAdd(listbox, message)
#define DoDel(listbox)
void OnUpdateUI(wxUpdateUIEvent &event)
virtual void SetAdditionalOutputFiles(const wxString &files)
Set a list of all additional output files this targets creates, besides its main output.
wxObject * LoadObject(wxWindow *parent, const wxString &name, const wxString &classname)
#define DoEdit(listbox, message)
ProjectBuildTarget * m_pTarget