Code::Blocks  SVN r11506
newfromtemplatedlg.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: 11437 $
6  * $Id: newfromtemplatedlg.cpp 11437 2018-08-07 07:13:40Z fuscated $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/sdk/newfromtemplatedlg.cpp $
8  */
9 
10 #include "sdk_precomp.h"
11 
12 #ifndef CB_PRECOMP
13  #include <wx/button.h>
14  #include <wx/choice.h>
15  #include <wx/imaglist.h>
16  #include <wx/intl.h>
17  #include <wx/listbox.h>
18  #include <wx/listctrl.h>
19  #include <wx/menu.h>
20  #include <wx/string.h>
21  #include <wx/settings.h>
22  #include <wx/xrc/xmlres.h>
23 
24  #include "cbeditor.h"
25  #include "configmanager.h"
26  #include "editormanager.h"
27  #include "globals.h"
28  #include "manager.h"
29 #endif
30 #include "cbstyledtextctrl.h"
31 
32 #include <wx/listbook.h>
33 #include <wx/radiobox.h>
34 
35 #include "newfromtemplatedlg.h"
36 #include "projecttemplateloader.h"
37 
39 {
40  ListItemData(ProjectTemplateLoader* t = nullptr, cbWizardPlugin* p = nullptr, int i = 0) : pt(t), plugin(p), wizPluginIndex(i) {}
41  ListItemData(const ListItemData& rhs) : pt(rhs.pt), plugin(rhs.plugin) {}
45 };
46 
47 static int idEditWizardScript = wxNewId();
49 static int idInfoWizardScript = wxNewId();
51 
52 BEGIN_EVENT_TABLE(NewFromTemplateDlg, wxScrollingDialog)
53  EVT_UPDATE_UI(-1, NewFromTemplateDlg::OnUpdateUI)
54 
55  // projects
56  EVT_LIST_ITEM_RIGHT_CLICK(XRCID("listProjects"), NewFromTemplateDlg::OnListRightClick)
57  EVT_LIST_ITEM_ACTIVATED(XRCID("listProjects"), NewFromTemplateDlg::OnListActivate)
58  EVT_CHOICE(XRCID("cmbProjectCategories"), NewFromTemplateDlg::OnCategoryChanged)
59 
60  // targets
61  EVT_LIST_ITEM_RIGHT_CLICK(XRCID("listTargets"), NewFromTemplateDlg::OnListRightClick)
62  EVT_LIST_ITEM_ACTIVATED(XRCID("listTargets"), NewFromTemplateDlg::OnListActivate)
63  EVT_CHOICE(XRCID("cmbTargetCategories"), NewFromTemplateDlg::OnCategoryChanged)
64 
65  // files
66  EVT_LIST_ITEM_RIGHT_CLICK(XRCID("listFiles"), NewFromTemplateDlg::OnListRightClick)
67  EVT_LIST_ITEM_ACTIVATED(XRCID("listFiles"), NewFromTemplateDlg::OnListActivate)
68  EVT_CHOICE(XRCID("cmbFileCategories"), NewFromTemplateDlg::OnCategoryChanged)
69 
70  // workspaces
71  EVT_LIST_ITEM_RIGHT_CLICK(XRCID("listCustoms"), NewFromTemplateDlg::OnListRightClick)
72  EVT_LIST_ITEM_ACTIVATED(XRCID("listCustoms"), NewFromTemplateDlg::OnListActivate)
73  EVT_CHOICE(XRCID("cmbCustomCategories"), NewFromTemplateDlg::OnCategoryChanged)
74 
75  // context menu for wizard scripts
76  EVT_MENU(idEditWizardScript, NewFromTemplateDlg::OnEditScript)
77  EVT_MENU(idDiscardWizardScript, NewFromTemplateDlg::OnDiscardScript)
78  EVT_MENU(idEditGlobalWizardScript, NewFromTemplateDlg::OnEditGlobalScript)
79 
80  EVT_RADIOBOX(XRCID("rbView"), NewFromTemplateDlg::OnViewChange)
81  EVT_MENU(idInfoWizardScript, NewFromTemplateDlg::OnHelp)
82 END_EVENT_TABLE()
83 
85  : m_Template(nullptr),
86  m_pWizard(nullptr),
87  m_WizardIndex(-1)
88 {
89  //ctor
90  wxXmlResource::Get()->LoadObject(this, nullptr, _T("dlgNewFromTemplate"),_T("wxScrollingDialog"));
92 
93  wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
95 
96  // create image lists
97  XRCCTRL(*this, "listProjects", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_NORMAL);
98  XRCCTRL(*this, "listProjects", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_SMALL);
99  XRCCTRL(*this, "listTargets", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_NORMAL);
100  XRCCTRL(*this, "listTargets", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_SMALL);
101  XRCCTRL(*this, "listFiles", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_NORMAL);
102  XRCCTRL(*this, "listFiles", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_SMALL);
103  XRCCTRL(*this, "listCustoms", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_NORMAL);
104  XRCCTRL(*this, "listCustoms", wxListCtrl)->SetImageList(new wxImageList(32, 32), wxIMAGE_LIST_SMALL);
105 
106  // load view prefs
107  XRCCTRL(*this, "rbView", wxRadioBox)->SetSelection(Manager::Get()->GetConfigManager(_T("new_from_template"))->ReadInt(_T("/view"), 0));
108  ChangeView();
109 
110  BuildCategories();
111  BuildList();
112 
113  // fill user templates list
114  XRCCTRL(*this, "lstUser", wxListBox)->Clear();
115  for (unsigned int i = 0; i < user_templates.GetCount(); ++i)
116  {
117  XRCCTRL(*this, "lstUser", wxListBox)->Append(user_templates[i]);
118  }
119 
120  lb->SetSelection((int)initial);
121 }
122 
124 {
125  //dtor
126  delete XRCCTRL(*this, "listProjects", wxListCtrl)->GetImageList(wxIMAGE_LIST_NORMAL);
127  delete XRCCTRL(*this, "listProjects", wxListCtrl)->GetImageList(wxIMAGE_LIST_SMALL);
128  delete XRCCTRL(*this, "listTargets", wxListCtrl)->GetImageList(wxIMAGE_LIST_NORMAL);
129  delete XRCCTRL(*this, "listTargets", wxListCtrl)->GetImageList(wxIMAGE_LIST_SMALL);
130  delete XRCCTRL(*this, "listFiles", wxListCtrl)->GetImageList(wxIMAGE_LIST_NORMAL);
131  delete XRCCTRL(*this, "listFiles", wxListCtrl)->GetImageList(wxIMAGE_LIST_SMALL);
132  delete XRCCTRL(*this, "listCustoms", wxListCtrl)->GetImageList(wxIMAGE_LIST_NORMAL);
133  delete XRCCTRL(*this, "listCustoms", wxListCtrl)->GetImageList(wxIMAGE_LIST_SMALL);
134 
135  XRCCTRL(*this, "listProjects", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_NORMAL);
136  XRCCTRL(*this, "listProjects", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_SMALL);
137  XRCCTRL(*this, "listTargets", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_NORMAL);
138  XRCCTRL(*this, "listTargets", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_SMALL);
139  XRCCTRL(*this, "listFiles", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_NORMAL);
140  XRCCTRL(*this, "listFiles", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_SMALL);
141  XRCCTRL(*this, "listCustoms", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_NORMAL);
142  XRCCTRL(*this, "listCustoms", wxListCtrl)->SetImageList(nullptr, wxIMAGE_LIST_SMALL);
143 
144  ClearList();
145 }
146 
148 {
149  ClearListFor(XRCCTRL(*this, "listProjects", wxListCtrl));
150  ClearListFor(XRCCTRL(*this, "listTargets", wxListCtrl));
151  ClearListFor(XRCCTRL(*this, "listFiles", wxListCtrl));
152  ClearListFor(XRCCTRL(*this, "listCustoms", wxListCtrl));
153 }
154 
156 {
157  if (!list)
158  return;
159  for (int i = 0; i < list->GetItemCount(); ++i)
160  {
161  ListItemData* data = (ListItemData*)list->GetItemData(i);
162  delete data;
163  }
164  list->ClearAll();
165 }
166 
168 {
169  BuildCategoriesFor(totProject, XRCCTRL(*this, "cmbProjectCategories", wxChoice));
170  BuildCategoriesFor(totTarget, XRCCTRL(*this, "cmbTargetCategories", wxChoice));
171  BuildCategoriesFor(totFiles, XRCCTRL(*this, "cmbFileCategories", wxChoice));
172  BuildCategoriesFor(totCustom, XRCCTRL(*this, "cmbCustomCategories", wxChoice));
173 }
174 
176 {
177  if (!cat)
178  return;
179  cat->Clear();
180  cat->Append(_("<All categories>"));
181 
182  // wizards
183  for (unsigned int i = 0; i < m_Wizards.GetCount(); ++i)
184  {
185  cbWizardPlugin* plugin = (cbWizardPlugin*)m_Wizards[i];
186  for (int w = 0; w < plugin->GetCount(); ++w)
187  {
188  if (plugin->GetOutputType(w) != otype)
189  continue;
190 
191  if (cat->FindString(plugin->GetCategory(w)) == wxNOT_FOUND)
192  cat->Append(plugin->GetCategory(w));
193  }
194  }
195  cat->SetSelection(0);
196 }
197 
198 #if wxCHECK_VERSION(3, 0, 0)
199 inline int wxCALLBACK SortTemplates(wxIntPtr item1, wxIntPtr item2, cb_unused wxIntPtr sortData)
200 #else
201 inline int wxCALLBACK SortTemplates(long item1, long item2, cb_unused long sortData)
202 #endif
203 {
204  ListItemData* data1 = reinterpret_cast<ListItemData*>(item1);
205  ListItemData* data2 = reinterpret_cast<ListItemData*>(item2);
206 
207  if (!data1 && data2)
208  return 1;
209  if (data1 && !data2)
210  return -1;
211  if (data1 && data2)
212  {
213  wxString name1 = data1->pt ? data1->pt->m_Title : data1->plugin->GetTitle(data1->wizPluginIndex);
214  wxString name2 = data2->pt ? data2->pt->m_Title : data2->plugin->GetTitle(data2->wizPluginIndex);
215 
216  return name1.CompareTo(name2.wx_str());
217  }
218  return 0;
219 }
220 
222 {
223  BuildListFor(totProject, XRCCTRL(*this, "listProjects", wxListCtrl), XRCCTRL(*this, "cmbProjectCategories", wxChoice));
224  BuildListFor(totTarget, XRCCTRL(*this, "listTargets", wxListCtrl), XRCCTRL(*this, "cmbTargetCategories", wxChoice));
225  BuildListFor(totFiles, XRCCTRL(*this, "listFiles", wxListCtrl), XRCCTRL(*this, "cmbFileCategories", wxChoice));
226  BuildListFor(totCustom, XRCCTRL(*this, "listCustoms", wxListCtrl), XRCCTRL(*this, "cmbCustomCategories", wxChoice));
227 }
228 
230 {
231  if (!list || !cat)
232  return;
233  ClearListFor(list);
236 
237  wxBitmap bmp;
238  bool all = cat->GetSelection() == 0;
239 
240  // wizards
241  for (unsigned int i = 0; i < m_Wizards.GetCount(); ++i)
242  {
243  cbWizardPlugin* plugin = (cbWizardPlugin*)m_Wizards[i];
244  for (int w = 0; w < plugin->GetCount(); ++w)
245  {
246  if (plugin->GetOutputType(w) != otype)
247  continue;
248 
249  if (all || plugin->GetCategory(w).Matches(cat->GetStringSelection()))
250  {
251  int iconIndex;
252  if (plugin->GetBitmap(w).Ok())
253  {
254  iconIndex = list->GetImageList(wxIMAGE_LIST_NORMAL)->Add(plugin->GetBitmap(w));
255  list->GetImageList(wxIMAGE_LIST_SMALL)->Add(plugin->GetBitmap(w));
256  }
257  else
258  iconIndex = -2;
259  int index = list->InsertItem(0, plugin->GetTitle(w), iconIndex);
260  if (index != -1)
261  {
262  list->SetItemData(index, (wxIntPtr)(new ListItemData(nullptr, plugin, w)));
263  // if the script exists in the user's configuration, mark that it's been customized
264  wxString script = ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/") + plugin->GetScriptFilename(w);
265  if (wxFileExists(script))
266  {
267  list->SetItemTextColour(index, *wxRED);
268  }
269  }
270  }
271  }
272  }
273 
274  list->SortItems(SortTemplates, (wxIntPtr)0);
275 }
276 
278 {
279  wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
280  size_t page = lb->GetSelection();
281 
282  switch (page)
283  {
284  case 0: return XRCCTRL(*this, "listProjects", wxListCtrl); // projects
285  case 1: return XRCCTRL(*this, "listTargets", wxListCtrl); // targets
286  case 2: return XRCCTRL(*this, "listFiles", wxListCtrl); // files
287  case 3: return XRCCTRL(*this, "listCustoms", wxListCtrl); // workspaces
288  default: return nullptr;
289  }
290 }
291 
293 {
294  wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
295  size_t page = lb->GetSelection();
296 
297  switch (page)
298  {
299  case 0: return XRCCTRL(*this, "cmbProjectCategories", wxChoice); // projects
300  case 1: return XRCCTRL(*this, "cmbTargetCategories", wxChoice); // targets
301  case 2: return XRCCTRL(*this, "cmbFileCategories", wxChoice); // files
302  case 3: return XRCCTRL(*this, "cmbCustomCategories", wxChoice); // workspaces
303  default: return nullptr;
304  }
305 }
306 
308 {
309  wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
310  size_t page = lb->GetSelection();
311 
312  switch (page)
313  {
314  case 0: return totProject;
315  case 1: return totTarget;
316  case 2: return totFiles;
317  case 3: return totCustom;
318  default: return totProject;
319  }
320 }
321 
323 {
324  m_pWizard = nullptr;
325  m_WizardIndex = -1;
326  wxListCtrl* list = GetVisibleListCtrl();
327  if (!list)
328  return nullptr;
329  long index = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
330  if (index == -1)
331  return nullptr;
332  ListItemData* data = (ListItemData*)list->GetItemData(index);
333  m_pWizard = data->plugin;
334  m_WizardIndex = data->wizPluginIndex;
335  return m_pWizard;
336 }
337 
339 {
340  wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
341  size_t page = lb->GetSelection();
342  return page == lb->GetPageCount() - 1 &&
343  XRCCTRL(*this, "lstUser", wxListBox)->GetSelection() != -1;
344 }
345 
347 {
348  int sel = XRCCTRL(*this, "lstUser", wxListBox)->GetSelection();
349  return sel != -1 ? XRCCTRL(*this, "lstUser", wxListBox)->GetString(sel) : _T("");
350 }
351 
353 {
354  if (filename.IsEmpty())
355  return;
356 
357  // edited before?
358  bool first_time = false;
359  wxString script = ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/") + filename;
360  if (!wxFileExists(script))
361  {
362  first_time = true;
363  script = ConfigManager::GetFolder(sdDataGlobal) + _T("/templates/wizard/") + filename;
364  }
365 
366  cbEditor* ed = Manager::Get()->GetEditorManager()->Open(script);
367  if (ed)
368  {
369  ed->GetControl()->SetFocus();
370  if (first_time)
371  {
372  // first time editing this script; change the filename to point to the user's dir
373  ed->SetFilename(ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/") + filename);
374  ed->SetModified(true);
375  // also make sure the destination directory exists
376  CreateDirRecursively(ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/") + filename);
377  }
379  return;
380  }
381  cbMessageBox(_("Couldn't open script:\n") + script, _("Error"), wxICON_ERROR, this);
382 }
383 
385 {
386  int sel = XRCCTRL(*this, "rbView", wxRadioBox)->GetSelection();
387  int style = sel == 0 ? wxLC_ICON : wxLC_LIST;
388 
389  XRCCTRL(*this, "listProjects", wxListCtrl)->SetSingleStyle(style);
390  XRCCTRL(*this, "listTargets", wxListCtrl)->SetSingleStyle(style);
391  XRCCTRL(*this, "listFiles", wxListCtrl)->SetSingleStyle(style);
392  XRCCTRL(*this, "listCustoms", wxListCtrl)->SetSingleStyle(style);
393 
394  // in non-windows platforms, the above clears the control contents too
395  // so rebuild them
396 #ifndef __WXMSW__
397  BuildListFor(totProject, XRCCTRL(*this, "listProjects", wxListCtrl), XRCCTRL(*this, "cmbProjectCategories", wxChoice));
398  BuildListFor(totTarget, XRCCTRL(*this, "listTargets", wxListCtrl), XRCCTRL(*this, "cmbTargetCategories", wxChoice));
399  BuildListFor(totFiles, XRCCTRL(*this, "listFiles", wxListCtrl), XRCCTRL(*this, "cmbFileCategories", wxChoice));
400  BuildListFor(totCustom, XRCCTRL(*this, "listCustoms", wxListCtrl), XRCCTRL(*this, "cmbCustomCategories", wxChoice));
401 #endif
402 }
403 
405 {
406  wxListCtrl* list = GetVisibleListCtrl();
407  if (!list)
408  return;
409  wxMenu* menu = new wxMenu;
410  ListItemData* data = reinterpret_cast<ListItemData*>(event.GetData());
411 
412  if (data && data->plugin)
413  {
414  menu->Append(idEditWizardScript, _("Edit this script"));
415 
416  // if the script exists in the user's configuration, it has been customized
417  wxString script = ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/") + data->plugin->GetScriptFilename(data->wizPluginIndex);
418  if (wxFileExists(script))
419  {
420  menu->Append(idDiscardWizardScript, _("Discard modifications of this script"));
421  menu->Append(idInfoWizardScript, _("Why is this script marked red?"));
422  menu->AppendSeparator();
423  }
424  }
425  menu->Append(idEditGlobalWizardScript, _("Edit global registration script"));
426  list->PopupMenu(menu);
427  delete menu;
428 }
429 
431 {
432  EndModal(wxID_OK);
433 }
434 
436 {
437  BuildListFor(GetVisibleOutputType(), GetVisibleListCtrl(), GetVisibleCategory());
438 }
439 
441 {
442  wxListCtrl* list = GetVisibleListCtrl();
443  if (!list)
444  return;
445  long index = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
446  if (index == -1)
447  return;
448  ListItemData* data = (ListItemData*)list->GetItemData(index);
449  cbWizardPlugin* wiz = data->plugin;
450  EditScript(wiz->GetScriptFilename(data->wizPluginIndex));
451 }
452 
454 {
455  wxListCtrl* list = GetVisibleListCtrl();
456  if (!list)
457  return;
458  long index = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
459  if (index == -1)
460  return;
461  ListItemData* data = (ListItemData*)list->GetItemData(index);
462  if (!data)
463  return;
464 
465  wxString script = ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/") + data->plugin->GetScriptFilename(data->wizPluginIndex);
466  if (wxFileExists(script))
467  {
468  if (cbMessageBox(_("Are you sure you want to discard all local modifications to this script?"),
469  _("Confirmation"), wxICON_QUESTION | wxYES_NO, this) == wxID_YES)
470  {
471  if (wxRemoveFile(script))
473  }
474  }
475 }
476 
478 {
479  cbMessageBox(_("Any changes you make to the global wizard registration script will "
480  "take effect after you restart Code::Blocks."),
481  _("Information"), wxICON_INFORMATION, this);
482  EditScript(_T("config.script"));
483 }
484 
486 {
487  ChangeView();
488 }
489 
491 {
492  cbMessageBox(_("When you edit a wizard's script, you actually edit a copy of it which "
493  "is automatically placed inside your user configuration directory.\n"
494  "This means that if a new version of the script is released, Code::Blocks "
495  "will still use your customized script, not the globally installed version.\n\n"
496  "These customized wizard scripts are coloured red just to remind you "
497  "that they are exactly that: customized scripts.\n"
498  "So, if you update your Code::Blocks copy and find that an updated wizard's "
499  "behaviour doesn't change, check if you have customized it. If you have, "
500  "the only way to re-enable the globally installed script is to remove "
501  "the customized one.\n\n"
502  "On this computer, the customized scripts are located under:\n") +
503  ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/"),
504  _("Help"),
505  wxICON_INFORMATION, this);
506 }
507 
509 {
510  wxListbook* lb = XRCCTRL(*this, "nbMain", wxListbook);
511  size_t page = lb->GetSelection();
512 
513  XRCCTRL(*this, "wxID_OK", wxButton)->Enable((page != lb->GetPageCount() - 1 && GetSelectedTemplate()) || SelectedUserTemplate());
514 }
515 
517 {
518  // save view prefs
519  int sel = XRCCTRL(*this, "rbView", wxRadioBox)->GetSelection();
520  Manager::Get()->GetConfigManager(_T("new_from_template"))->Write(_T("/view"), (int)sel);
521 
522  GetSelectedTemplate();
524 }
void EndModal(int retCode)
Definition: sc_dialog.cpp:112
void OnViewChange(wxCommandEvent &event)
static wxString GetFolder(SearchDirs dir)
Access one of Code::Blocks&#39; folders.
bool Matches(const wxString &mask) const
int wxNewId()
PluginManager * GetPluginManager() const
Definition: manager.cpp:444
bool wxRemoveFile(const wxString &file)
#define wxICON_QUESTION
virtual int GetSelection() const=0
Data folder in user&#39;s dir.
Definition: configmanager.h:75
ConfigManager * GetConfigManager(const wxString &name_space) const
Definition: manager.cpp:474
void ClearListFor(wxListCtrl *list)
wxChoice * GetVisibleCategory()
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
Definition: manager.cpp:182
void EditScript(const wxString &filename)
long GetNextItem(long item, int geometry=wxLIST_NEXT_ALL, int state=wxLIST_STATE_DONTCARE) const
virtual wxString GetScriptFilename(int index) const =0
void OnListRightClick(wxListEvent &event)
ProjectTemplateLoader * pt
bool SelectedUserTemplate() const
virtual int GetSelection() const
void EndModal(int retCode) override
#define wxICON_ERROR
wxString GetSelectedUserTemplate() const
bool wxFileExists(const wxString &filename)
virtual wxString GetTitle(int index) const =0
static int idEditGlobalWizardScript
void OnListActivate(wxListEvent &event)
virtual size_t GetPageCount() const
wxMenuItem * Append(int id, const wxString &item=wxEmptyString, const wxString &helpString=wxEmptyString, wxItemKind kind=wxITEM_NORMAL)
#define wxLIST_STATE_SELECTED
cbWizardPlugin * GetSelectedTemplate()
#define _T(string)
#define wxYES_NO
void OnCategoryChanged(wxCommandEvent &event)
#define wxICON_INFORMATION
void SetModified(bool modified=true) override
Set the editor&#39;s modification state to modified.
Definition: cbeditor.cpp:861
virtual wxString GetCategory(int index) const =0
#define wxLC_LIST
void OnDiscardScript(wxCommandEvent &event)
#define wxNOT_FOUND
virtual int SetSelection(size_t page)=0
wxListCtrl * GetVisibleListCtrl()
EditorManager * GetEditorManager() const
Definition: manager.cpp:434
template produces custom output (entirely up to the wizard used)
Definition: globals.h:150
ListItemData(ProjectTemplateLoader *t=nullptr, cbWizardPlugin *p=nullptr, int i=0)
No icons, just text.
Definition: globals.h:300
long InsertItem(wxListItem &info)
void Write(const wxString &name, const wxString &value, bool ignoreEmpty=false)
template outputs a new file (or files)
Definition: globals.h:149
bool SetItemData(long item, long data)
cbStyledTextCtrl * GetControl() const
Returns a pointer to the underlying cbStyledTextCtrl object (which itself is the wxWindows implementa...
Definition: cbeditor.cpp:842
static int idInfoWizardScript
void BuildListFor(TemplateOutputType otype, wxListCtrl *list, const wxChoice *cat)
virtual const wxBitmap & GetBitmap(int index) const =0
virtual int GetCount() const =0
wxColour * wxRED
void SetItemTextColour(long item, const wxColour &col)
#define wxLC_ICON
void OnUpdateUI(wxUpdateUIEvent &event)
wxMenuItem * AppendSeparator()
virtual void SetFilename(const wxString &filename)
Sets the editor&#39;s filename.
Definition: editorbase.h:50
static wxColour GetColour(wxSystemColour index)
void BuildCategoriesFor(TemplateOutputType otype, wxChoice *cat)
cbWizardPlugin * plugin
const wxStringCharType * wx_str() const
int GetItemCount() const
int wxCALLBACK SortTemplates(wxIntPtr item1, wxIntPtr item2, cb_unused wxIntPtr sortData)
void OnEditScript(wxCommandEvent &event)
virtual TemplateOutputType GetOutputType(int index) const =0
cbEditor * Open(const wxString &filename, int pos=0, ProjectFile *data=nullptr)
ListItemData(const ListItemData &rhs)
const wxString & _(const wxString &string)
TemplateOutputType
Template output types.
Definition: globals.h:145
bool SortItems(wxListCtrlCompare fnSortCallBack, wxIntPtr data)
A file editor.
Definition: cbeditor.h:43
bool IsEmpty() const
wxUIntPtr GetItemData(long item) const
template adds a new target in a project
Definition: globals.h:148
DLLIMPORT void SetSettingsIconsStyle(wxListCtrl *lc, SettingsIconsStyle style)
Set the icons style for the supplied list control.
Definition: globals.cpp:1125
void OnHelp(wxCommandEvent &event)
TemplateOutputType GetVisibleOutputType() const
PluginsArray GetOffersFor(PluginType type)
int Add(const wxBitmap &bitmap, const wxBitmap &mask=wxNullBitmap)
template outputs a new project
Definition: globals.h:147
static wxXmlResource * Get()
DLLIMPORT bool CreateDirRecursively(const wxString &full_path, int perms=0755)
Definition: globals.cpp:610
void ClearAll()
ssize_t wxIntPtr
Data folder in base dir.
Definition: configmanager.h:81
Base class for wizard plugins.
Definition: cbplugin.h:967
static int idDiscardWizardScript
virtual void SetSelection(int n)
wxListView * GetListView() const
static int idEditWizardScript
wxImageList * GetImageList(int which) const
void OnEditGlobalScript(wxCommandEvent &event)
wxObject * LoadObject(wxWindow *parent, const wxString &name, const wxString &classname)
bool RemoveAll()
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
virtual int FindString(const wxString &s, bool bCase=false) const