Code::Blocks  SVN r11506
wiz.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: 11148 $
6  * $Id: wiz.cpp 11148 2017-08-15 19:14:30Z pecanh $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/plugins/scriptedwizard/wiz.cpp $
8  */
9 
10 #include <sdk.h>
11 #ifndef CB_PRECOMP
12  #include <wx/button.h>
13  #include <wx/checkbox.h>
14  #include <wx/checklst.h>
15  #include <wx/combobox.h>
16  #include <wx/dir.h>
17  #include <wx/image.h>
18  #include <wx/intl.h>
19  #include <wx/listbox.h>
20  #include <wx/panel.h>
21  #include <wx/radiobox.h>
22  #include <wx/sizer.h>
23  #include <wx/spinctrl.h>
24  #include <wx/stattext.h>
25  #include <wx/wizard.h>
26  #include <wx/xrc/xmlres.h>
27 
28  #include <wx/wxscintilla.h> // CB Header
29  #include <cbexception.h>
30  #include <cbproject.h>
31  #include <compiler.h>
32  #include <compilerfactory.h>
33  #include <configmanager.h>
34  #include <filefilters.h>
35  #include <globals.h>
36  #include <infowindow.h>
37  #include <manager.h>
38  #include <projectbuildtarget.h>
39  #include <projectmanager.h>
40  #include <scriptingmanager.h>
41 #endif // CB_PRECOMP
43 
44 #include "wiz.h"
45 #include "wizpage.h"
46 
47 #include <wx/arrimpl.cpp>
48 WX_DEFINE_OBJARRAY(Wizards); // TODO: find out why this causes a shadow warning for 'Item'
49 
50 namespace
51 {
52  PluginRegistrant<Wiz> reg(_T("ScriptedWizard"));
53 }
54 
55 // scripting support
57 
59  : m_pWizard(nullptr),
60  m_pWizProjectPathPanel(nullptr),
61  m_pWizFilePathPanel(nullptr),
62  m_pWizCompilerPanel(nullptr),
63  m_pWizBuildTargetPanel(nullptr),
64  m_LaunchIndex(0)
65 {
66  //ctor
67 }
68 
70 {
71  //dtor
72 }
73 
75 {
76  // make sure the VM is initialized
78 
79  if (!SquirrelVM::GetVMPtr())
80  {
81  cbMessageBox(_("Project wizard disabled: scripting not initialized"), _("Error"), wxICON_ERROR);
82  return;
83  }
84 
85  // read configuration
87 
88  // run main wizard script
89  // this registers all available wizard scripts with us
90 
91  // user script first
92  wxString templatePath = ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/");
93  wxString script = templatePath + _T("/config.script");
94  if (wxFileExists(script))
95  {
97  try
98  {
99  SqPlus::SquirrelFunction<void> f("RegisterWizards");
100  f();
101  }
102  catch (SquirrelError& e)
103  {
105  }
106  }
107  else
108  {
109  // global script next
110  templatePath = ConfigManager::GetFolder(sdDataGlobal) + _T("/templates/wizard/");
111  script = templatePath + _T("/config.script");
112  if (wxFileExists(script))
113  {
115  try
116  {
117  SqPlus::SquirrelFunction<void> f("RegisterWizards");
118  f();
119  }
120  catch (SquirrelError& e)
121  {
123  }
124  }
125  }
126 
127  // default compiler settings (returned if no compiler page is added in the wizard)
128  wxString sep = wxString(wxFILE_SEP_PATH);
130  m_WantDebug = true;
131  m_DebugName = _T("Debug");
132  m_DebugOutputDir = _T("bin") + sep + _T("Debug") + sep;
133  m_DebugObjOutputDir = _T("obj") + sep + _T("Debug") + sep;
134  m_WantRelease = true;
135  m_ReleaseName = _T("Release");
136  m_ReleaseOutputDir = _T("bin") + sep + _T("Release") + sep;
137  m_ReleaseObjOutputDir = _T("obj") + sep + _T("Release") + sep;
138 }
139 
140 int Wiz::GetCount() const
141 {
142  // return the number of template wizards contained in this plugin
143  return m_Wizards.GetCount();
144 }
145 
147 {
148  //return this wizard's output type
149  //make sure you set this!
150  cbAssert(index >= 0 && index < GetCount());
151  return m_Wizards[index].output_type;
152 }
153 
154 wxString Wiz::GetTitle(int index) const
155 {
156  //return this wizard's title
157  //this will appear in the new-project dialog
158  //make sure you set this!
159  cbAssert(index >= 0 && index < GetCount());
160  return m_Wizards[index].title;
161 }
162 
164 {
165  //return this wizard's description
166  //make sure you set this!
167  cbAssert(index >= 0 && index < GetCount());
168  return _("A generic scripted wizard");
169 }
170 
171 wxString Wiz::GetCategory(int index) const
172 {
173  //return this wizard's category
174  //try to match an existing category
175  //make sure you change this!
176  cbAssert(index >= 0 && index < GetCount());
177  return m_Wizards[index].cat;
178 }
179 
180 const wxBitmap& Wiz::GetBitmap(int index) const
181 {
182  //return this wizard's bitmap
183  //this will appear in the new-project dialog
184  cbAssert(index >= 0 && index < GetCount());
185  return m_Wizards[index].templatePNG;
186 }
187 
189 {
190  //return this wizard's script relative filename
191  cbAssert(index >= 0 && index < GetCount());
192  return m_Wizards[index].script;
193 }
194 
196 {
197  if (m_pWizard)
198  m_pWizard->Destroy();
199  m_pWizard = nullptr;
200  m_Pages.Clear();
201 
202 // if the ABI is not sufficient, we 're in trouble the next time the wizard runs...
203 #if wxABI_VERSION > 20601
204  if (!m_LastXRC.IsEmpty())
206 #endif
207 
208  m_pWizProjectPathPanel = nullptr;
209  m_pWizCompilerPanel = nullptr;
210  m_pWizBuildTargetPanel = nullptr;
211  m_pWizFilePathPanel = nullptr;
212 }
213 
214 CompileTargetBase* Wiz::Launch(int index, wxString* pFilename)
215 {
216  cbAssert(index >= 0 && index < GetCount());
217 
218  // clear previous script's context
219  static const wxString clearout_wizscripts = _T("function BeginWizard(){};\n"
220  "function SetupProject(project){return false;};\n"
221  "function SetupTarget(target,is_debug){return false;};\n"
222  "function SetupCustom(){return false;};\n"
223  "function CreateFiles(){return _T(\"\");};\n"
224  "function GetFilesDir(){return _T(\"\");};\n"
225  "function GetGeneratedFile(index){return _T(\"\");};\n"
226  "function GetTargetName() { return _T(\"\"); }\n");
227  Manager::Get()->GetScriptingManager()->LoadBuffer(clearout_wizscripts, _T("ClearWizState"));
228 
229  // early check: build target wizards need an active project
230  if (m_Wizards[index].output_type == totTarget &&
231  !Manager::Get()->GetProjectManager()->GetActiveProject())
232  {
233  cbMessageBox(_("You need to open (or create) a project first!"), _("Error"), wxICON_ERROR);
234  return nullptr;
235  }
236 
237  m_LaunchIndex = index;
238 
239  wxString global_commons = ConfigManager::GetFolder(sdDataGlobal) + _T("/templates/wizard/common_functions.script");
240  wxString user_commons = ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/common_functions.script");
241 
242  m_LastXRC = m_Wizards[index].xrc;
243  if ( wxFileExists(m_LastXRC) )
244  {
245  if ( !wxXmlResource::Get()->Load(m_LastXRC) )
246  cbMessageBox(m_Wizards[index].title + _(" has failed to load XRC resource..."), _("Error"), wxICON_ERROR);
247  }
248  else
249  m_LastXRC.Clear();
250 
251  // create wizard
252  m_pWizard = new wxWizard;
253  m_pWizard->Create(Manager::Get()->GetAppWindow(), wxID_ANY,
254  m_Wizards[index].title,
255  m_Wizards[index].wizardPNG,
258 
259  if (!Manager::Get()->GetScriptingManager()->LoadScript(global_commons) && // load global common functions
260  !Manager::Get()->GetScriptingManager()->LoadScript(user_commons)) // and/or load user common functions
261  {
262  // any errors have been displayed by ScriptingManager
263  Clear();
264  InfoWindow::Display(_("Error"), _("Failed to load the common functions script.\nPlease check the debug log for details..."));
265  return nullptr;
266  }
267 
268  // locate the script
269  wxString script = ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/") + m_Wizards[index].script;
270  if (!wxFileExists(script))
271  script = ConfigManager::GetFolder(sdDataGlobal) + _T("/templates/wizard/") + m_Wizards[index].script;
272 
273  if (!Manager::Get()->GetScriptingManager()->LoadScript(script)) // build and run script
274  {
275  // any errors have been displayed by ScriptingManager
276  Clear();
277  InfoWindow::Display(_("Error"), _("Failed to load the wizard's script.\nPlease check the debug log for details..."));
278  return nullptr;
279  }
280 
281  // Set wizard folder name for GetWizardScriptFolder() calls
283  wxArrayString scriptDirs = wxFileName(script).GetDirs();
284  if (scriptDirs.GetCount())
285  m_WizardScriptFolder = scriptDirs[scriptDirs.GetCount()-1];
286 
287  // call BeginWizard()
288  try
289  {
290  SqPlus::SquirrelFunction<void> f("BeginWizard");
291  f();
292  }
293  catch (SquirrelError& e)
294  {
296  Clear();
297  return nullptr;
298  }
299  catch (cbException& e)
300  {
301  e.ShowErrorMessage(false);
302  Clear();
303  return nullptr;
304  }
305 
306  // check if *any* pages were added
307  if (m_Pages.GetCount() == 0)
308  {
309  cbMessageBox(m_Wizards[index].title + _(" has failed to run..."), _("Error"), wxICON_ERROR);
310  Clear();
311  return nullptr;
312  }
313 
314  // check if *mandatory* pages (i.e. used by the following code) were added
315  // currently, project path is a mandatory page for new projects...
316  if (m_Wizards[index].output_type == totProject && !m_pWizProjectPathPanel)
317  {
318  cbMessageBox(_("This wizard is missing the following mandatory wizard page:\n\n"
319  "Project path selection\n"
320  "Execution aborted..."), _("Error"), wxICON_ERROR);
321  Clear();
322  return nullptr;
323  }
324 
325  // build the wizard pages
326  Finalize();
327 
328  // run wizard
329  CompileTargetBase* base = nullptr; // ret value
330  if (m_pWizard->RunWizard(m_Pages[0]))
331  {
332  // ok, wizard done
333  switch (m_Wizards[index].output_type)
334  {
335  case totProject: base = RunProjectWizard(pFilename); break;
336  case totTarget: base = RunTargetWizard(pFilename); break;
337  case totFiles: base = RunFilesWizard(pFilename); break;
338  case totCustom: base = RunCustomWizard(pFilename); break;
339  default: break;
340  }
341  }
342  Clear();
343  return base;
344 }
345 
347 {
348  cbProject* theproject = nullptr;
349 
350  // first get the project filename
351  wxString prjname = GetProjectFullFilename();
352 
353  // create the dir for the project
354  wxFileName fname(prjname);
355  wxString prjdir = fname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
356  if (!CreateDirRecursively(prjdir))
357  {
358  cbMessageBox(_("Couldn't create the project directory:\n") + prjdir, _("Error"), wxICON_ERROR);
359  Clear();
360  return nullptr;
361  }
362 
363  // now create the project
364  // make sure to respect the compiler chosen by the user for the project, too
367  // create the project with the (probably) updated compiler
368  theproject = Manager::Get()->GetProjectManager()->NewProject(prjname);
369  // setup the old default compiler again
371  if (!theproject)
372  {
373  cbMessageBox(_("Couldn't create the new project:\n") + prjdir, _("Error"), wxICON_ERROR);
374  Clear();
375  return nullptr;
376  }
377 
378  // set the project title and project-wide compiler
379  theproject->SetTitle(GetProjectTitle());
380  theproject->SetCompilerID(GetCompilerID());
381 
382  // create the targets
383  if (GetWantDebug())
384  {
385  ProjectBuildTarget* target = theproject->AddBuildTarget(GetDebugName());
386  if (target)
387  {
388  target->SetCompilerID(GetCompilerID());
389  target->SetIncludeInTargetAll(false);
390 // target->SetOutputFilename(GetDebugOutputDir() + wxFILE_SEP_PATH + GetProjectName() + ext);
392  }
393  }
394 
395  if (GetWantRelease())
396  {
397  ProjectBuildTarget* target = theproject->AddBuildTarget(GetReleaseName());
398  if (target)
399  {
400  target->SetCompilerID(GetCompilerID());
401  target->SetIncludeInTargetAll(false);
402 // target->SetOutputFilename(GetReleaseOutputDir() + wxFILE_SEP_PATH + GetProjectName() + ext);
404  }
405  }
406 
407  // if no targets were created (due to user misconfiguration probably),
408  // create a "default" target
409  if (theproject->GetBuildTargetsCount() == 0)
410  {
411  ProjectBuildTarget* target = theproject->AddBuildTarget(_T("default"));
412  if (target)
413  {
414  target->SetCompilerID(GetCompilerID());
415  target->SetIncludeInTargetAll(false);
416  }
417  }
418 
419  // add all the template files
420  // first get the dirs with the files by calling GetFilesDir()
421  wxString srcdir;
422  try
423  {
424  SqPlus::SquirrelFunction<wxString&> f("GetFilesDir");
425  if (!f.func.IsNull())
426  srcdir = f();
427  if (!srcdir.IsEmpty())
428  {
429  // now break them up (remember: semicolon-separated list of dirs)
430  wxArrayString tmpsrcdirs = GetArrayFromString(srcdir, _T(";"), true);
431  // and copy files from each source dir we got
432  for (size_t i = 0; i < tmpsrcdirs.GetCount(); ++i)
433  CopyFiles(theproject, prjdir, tmpsrcdirs[i]);
434  }
435  }
436  catch (SquirrelError& e)
437  {
439  Clear();
440  return nullptr;
441  }
442 
443  // add generated files
444  try
445  {
446  SqPlus::SquirrelFunction<wxString&> f("GetGeneratedFile");
447  if (!f.func.IsNull())
448  {
449  wxArrayString files;
450  wxArrayString contents;
451  int idx = 0;
452  // safety limit to avoid infinite loops because of badly written scripts: 50 files
453  while (idx < 50)
454  {
455  wxString fileAndContents = f(idx++);
456  if (fileAndContents.IsEmpty())
457  break;
458  wxString tmpFile = fileAndContents.BeforeFirst(_T(';'));
459  wxString tmpContents = fileAndContents.AfterFirst(_T(';'));
460  tmpFile.Trim();
461  tmpContents.Trim();
462  if (tmpFile.IsEmpty() || tmpContents.IsEmpty())
463  break;
464  files.Add(tmpFile);
465  contents.Add(tmpContents);
466  };
467 
468  if (files.GetCount() != 0 && contents.GetCount() == files.GetCount())
469  {
470  // prepare the list of targets to add this file to (i.e. all of them)
471  wxArrayInt targetIndices;
472  for (int x = 0; x < theproject->GetBuildTargetsCount(); ++x)
473  targetIndices.Add(x);
474 
475  theproject->BeginAddFiles();
476 
477  // ok, we have to generate some files here
478  size_t count = files.GetCount();
479  for (size_t i = 0; i < count; ++i)
480  {
481  // GenerateFile() performs sanity and security checks
482  wxString actual = GenerateFile(theproject->GetBasePath(), files[i], contents[i]);
483 
484  if (!actual.IsEmpty())
485  {
486  // Add the file only if it does not exist
487  if (theproject->GetFileByFilename(files[i], true, true) == NULL)
488  {
489  Manager::Get()->GetLogManager()->DebugLog(_T("Generated file ") + actual);
490  // add it to the project
491  Manager::Get()->GetProjectManager()->AddFileToProject(actual, theproject, targetIndices);
492  }
493  else
494  {
495  Manager::Get()->GetLogManager()->DebugLog(F(_T("File %s exists"), actual.wx_str()));
496  }
497  }
498  }
499 
500  theproject->EndAddFiles();
501  }
502  }
503  }
504  catch (SquirrelError& e)
505  {
507  Clear();
508  return nullptr;
509  }
510 
511 // if (srcdir.IsEmpty())
512 // cbMessageBox(_("The wizard didn't provide any files to copy!"), _("Warning"), wxICON_WARNING);
513 
514  // ask the script to setup the new project (edit targets, setup options, etc)
515  // call SetupProject()
516  try
517  {
518  SqPlus::SquirrelFunction<bool> f("SetupProject");
519  if (!f(theproject))
520  {
521  cbMessageBox(wxString::Format(_("Couldn't setup project options:\n%s"),
522  prjdir.c_str()),
523  _("Error"), wxICON_ERROR);
524  Clear();
525  return nullptr;
526  }
527  }
528  catch (SquirrelError& e)
529  {
531  Clear();
532  return nullptr;
533  }
534 
535  // save the project and...
536  theproject->Save();
537 
538  if (pFilename)
539  *pFilename = theproject->GetFilename();
540 
541  // finally, make sure everything looks ok
544  return theproject;
545 }
546 
548 {
549  cbProject* theproject = Manager::Get()->GetProjectManager()->GetActiveProject(); // can't fail; if no project, the wizard didn't even run
550 
551  bool isDebug = false;
552  wxString targetName;
553 
555  {
556  targetName = GetTargetName();
557  isDebug = GetTargetEnableDebug();
558  }
559  else
560  {
561  // Call GetTargetName() to ask the script to tell us
562  // the name of the new target that should be added.
563  try
564  {
565  SqPlus::SquirrelFunction<wxString&> f("GetTargetName");
566  targetName = f();
567  if (targetName == wxEmptyString)
568  {
569  cbMessageBox(_("GetTargetName returned empty string. Failing!"), _("Error"), wxICON_ERROR);
570  Clear();
571  return nullptr;
572  }
573  }
574  catch (SquirrelError& e)
575  {
577  Clear();
578  return nullptr;
579  }
580  isDebug = false;
581  }
582 
583  ProjectBuildTarget* target = theproject->AddBuildTarget(targetName);
584  if (!target)
585  {
586  cbMessageBox(_("Failed to create build target!"), _("Error"), wxICON_ERROR);
587  Clear();
588  return nullptr;
589  }
590 
591  // Setup the compiler and other target parameters only if there is a BuildTarget panel.
592  // If not leave all this task to the script.
594  {
595  // check the compiler Id
596  wxString CompilerId = GetTargetCompilerID();
597  if(CompilerId == wxEmptyString)
598  { // no compiler had been specified
599  // fall back 1 : the poject one
600  CompilerId = theproject->GetCompilerID();
601  if(CompilerId == wxEmptyString)
602  { // even the project does not have one
603  // fall back 2 : CB default
605  cbMessageBox( _("No compiler had been specified. The new target will use the default compiler."),
606  _("Fallback compiler selected"),
608  Manager::Get()->GetAppWindow());
609  }
610  else
611  {
612  cbMessageBox( _("No compiler had been specified. The new target will use the same compiler as the project."),
613  _("Fallback compiler selected"),
615  Manager::Get()->GetAppWindow());
616  }
617  }
618  // setup the target
619  target->SetCompilerID(CompilerId);
620  target->SetIncludeInTargetAll(false);
623  }
624  // Assign this target to all project files
625  for (FilesList::iterator it = theproject->GetFilesList().begin(); it != theproject->GetFilesList().end(); ++it)
626  {
627  ProjectFile* pf = *it;
628  if (pf)
629  pf->AddBuildTarget(targetName);
630  }
631 
632  // add all the template files (if any)
633  // first get the dirs with the files by calling GetFilesDir()
634 // wxString srcdir;
635 // try
636 // {
637 // SqPlus::SquirrelFunction<wxString&> f("GetFilesDir");
638 // srcdir = f();
639 // if (!srcdir.IsEmpty())
640 // {
641 // // now break them up (remember: semicolon-separated list of dirs)
642 // wxArrayString tmpsrcdirs = GetArrayFromString(srcdir, _T(";"), true);
643 // // and copy files from each source dir we got
644 // for (size_t i = 0; i < tmpsrcdirs.GetCount(); ++i)
645 // CopyFiles(theproject, prjdir, tmpsrcdirs[i]);
646 // }
647 // }
648 // catch (SquirrelError& e)
649 // {
650 // Manager::Get()->GetScriptingManager()->DisplayErrors(&e);
651 // Clear();
652 // return nullptr;
653 // }
654 
655  // ask the script to setup the new target (setup options, etc)
656  // call SetupTarget()
657  try
658  {
659  SqPlus::SquirrelFunction<bool> f("SetupTarget");
660  if (!f(target, isDebug))
661  {
662  cbMessageBox(_("Couldn't setup target options:"), _("Error"), wxICON_ERROR);
663  Clear();
664  return nullptr;
665  }
666  }
667  catch (SquirrelError& e)
668  {
670  Clear();
671  return nullptr;
672  }
673 
674  return target;
675 }
676 
678 {
679  try
680  {
681  SqPlus::SquirrelFunction<wxString&> f("CreateFiles");
682  wxString files = f();
683  if (files.IsEmpty())
684  cbMessageBox(_("Wizard failed..."), _("Error"), wxICON_ERROR);
685  else
686  {
687  const wxString &filename = files.BeforeFirst(_T(';'));
688  if (pFilename)
689  *pFilename = filename;
690  EditorBase *editor = Manager::Get()->GetEditorManager()->GetEditor(filename);
691  if (editor && editor->IsBuiltinEditor())
692  static_cast<cbEditor*>(editor)->SetEditorStyle();
693  }
694  }
695  catch (SquirrelError& e)
696  {
698  }
699  Clear();
700  return nullptr;
701 }
702 
704 {
705  try
706  {
707  SqPlus::SquirrelFunction<bool> f("SetupCustom");
708  if (!f())
709  cbMessageBox(_("Wizard failed..."), _("Error"), wxICON_ERROR);
710  }
711  catch (SquirrelError& e)
712  {
714  }
715  Clear();
716  return nullptr;
717 }
718 
719 wxString Wiz::GenerateFile(const wxString& basePath, const wxString& filename, const wxString& contents)
720 {
721  wxFileName fname(filename);
722 
723  // extension sanity check
724  FileType ft = FileTypeOf(fname.GetFullPath());
725  switch (ft)
726  {
727  case ftCodeBlocksProject:
729  case ftExecutable:
730  case ftDynamicLib:
731  case ftStaticLib:
732  case ftResourceBin:
733  case ftObject:
734 // case ftOther:
735  Manager::Get()->GetLogManager()->DebugLog(_T("Attempt to generate a file with forbidden extension!\nFile: ") + fname.GetFullPath());
736  return wxEmptyString;
737  default: break;
738  }
739 
740  // make sure filename is relative
741  if (!fname.IsRelative())
742  fname.MakeRelativeTo(basePath);
743 
744  // make sure filename is located inside the project path (should already be)
745  const wxArrayString& Dirs = fname.GetDirs();
746  int IntDirCount = 0;
747  for ( size_t i=0; i<Dirs.Count(); i++ )
748  {
749  if ( Dirs[i] == _T("..") )
750  {
751  if ( IntDirCount-- == 0 )
752  {
753  // attempt to create file outside the project dir
754  // remove any path info from the filename
755  fname = fname.GetFullName();
756  Manager::Get()->GetLogManager()->DebugLog(F(_T("Attempt to generate a file outside the project base dir:\nOriginal: %s\nConverted to:%s"), filename.wx_str(), fname.GetFullPath().wx_str()));
757  break;
758  }
759  }
760  else if ( Dirs[i] != _T(".") )
761  IntDirCount++;
762  }
763 
764  fname = basePath + wxFILE_SEP_PATH + fname.GetFullPath();
765  if ( fname.FileExists() )
766  {
767  wxString query_overwrite;
768  query_overwrite.Printf(
769  _T("Warning:\n")
770  _T("The wizard is about to OVERWRITE the following existing file:\n")+
771  fname.GetFullPath()+_T("\n\n") +
772  _T("Are you sure that you want to OVERWRITE the file?\n\n")+
773  _T("(If you answer 'No' the existing file will be kept.)"));
774  if (cbMessageBox(query_overwrite, _T("Confirmation"),
776  {
777  return fname.GetFullPath();
778  }
779  }
780 
781  // create the file with the passed contents
782  wxFileName::Mkdir(fname.GetPath(),0777,wxPATH_MKDIR_FULL);
783  wxFile f(fname.GetFullPath(), wxFile::write);
784 
785  if ( cbWrite(f, contents + GetEOLStr(), wxFONTENCODING_UTF8) )
786  return fname.GetFullPath(); // success
787 
788  return wxEmptyString; // failed
789 }
790 
791 void Wiz::CopyFiles(cbProject* theproject, const wxString& prjdir, const wxString& srcdir)
792 {
793  // first get the dir with the files
794  wxArrayString filesList;
795  wxString enumdirs = ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/") + srcdir;
796  if ( !wxDirExists(enumdirs + _T("/")) )
797  enumdirs = ConfigManager::GetFolder(sdDataGlobal) + _T("/templates/wizard/") + srcdir;
798  wxString basepath = wxFileName(enumdirs).GetFullPath();
799 
800  if ( wxDirExists(enumdirs + _T("/")) )
801  {
802  // recursively enumerate all files under srcdir
803  wxDir::GetAllFiles(enumdirs, &filesList);
804  }
805 
806  // prepare the list of targets to add this file to (i.e. all of them)
807  wxArrayInt targetIndices;
808  for (int x = 0; x < theproject->GetBuildTargetsCount(); ++x)
809  targetIndices.Add(x);
810 
811  theproject->BeginAddFiles();
812 
813  // now get each file and copy it to the destination directory,
814  // adding it to all targets in the project
815  for (unsigned int i = 0; i < filesList.GetCount(); ++i)
816  {
817  wxString srcfile = filesList[i];
818 
819  wxString dstfile = srcfile;
820  // fixup destination filename (remove srcdir from path)
821  dstfile.Replace(basepath, prjdir);
822 
823  // make sure the destination directory exists
824  wxFileName fname(dstfile);
825  wxString dstdir = fname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
826  CreateDirRecursively(dstdir);
827 
828  // copy the file
829  bool do_copy = true; // default case: file most likely does *not* exist
830  if (wxFileName::FileExists(dstfile))
831  {
832  wxString query_overwrite;
833  query_overwrite.Printf(
834  _T("Warning:\n")
835  _T("The wizard is about to OVERWRITE the following existing file:\n")+
836  wxFileName(dstfile).GetFullPath()+_T("\n\n")+
837  _T("Are you sure that you want to OVERWRITE the file?\n\n")+
838  _T("(If you answer 'No' the existing file will be kept.)"));
839  if (cbMessageBox(query_overwrite, _T("Confirmation"),
841  {
842  do_copy = false; // keep the old (existing) file
843  }
844  }
845  if (do_copy) wxCopyFile(srcfile, dstfile, true);
846 
847  // and add it to the project
848  fname.MakeRelativeTo(prjdir);
849  Manager::Get()->GetProjectManager()->AddFileToProject(fname.GetFullPath(), theproject, targetIndices);
850  }
851 
852  theproject->EndAddFiles();
853 }
854 
856 // Scripting - BEGIN
858 
860 {
861  wxString f = ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/") + filename;
862  if (!wxFileExists(f))
863  f = ConfigManager::GetFolder(sdDataGlobal) + _T("/templates/wizard/") + filename;
864  return f;
865 }
866 
868 {
870  return m_Wizards[m_LaunchIndex].output_type;
871 }
872 
874 {
876  if (page)
877  {
878  wxComboBox* win = dynamic_cast<wxComboBox*>(page->FindWindowByName(name, page));
879  if (win && win->GetCount() == 0)
880  {
881  for (size_t i = 0; i < CompilerFactory::GetCompilersCount(); ++i)
882  {
883  Compiler* compiler = CompilerFactory::GetCompiler(i);
884  if (compiler)
885  win->Append(compiler->GetName());
886  }
888  if (compiler)
889  win->SetSelection(win->FindString(compiler->GetName()));
890  }
891  }
892 }
893 
894 void Wiz::FillContainerWithCompilers(const wxString& name, const wxString& compilerID, const wxString& validCompilerIDs)
895 {
897  if (page)
898  {
899  wxItemContainer* win = dynamic_cast<wxItemContainer*>(page->FindWindowByName(name, page));
900  if (win && win->GetCount() == 0)
901  {
902  Wizard::FillCompilerControl(win, compilerID, validCompilerIDs);
903  }
904  }
905 }
906 
907 void Wiz::FillContainerWithSelectCompilers( const wxString& name, const wxString& validCompilerIDs )
908 {
909  // Fill the named window with compilers matching a mask/filter
910  // Example: FillContainerWithSelectCompilers(_T("GenericChoiceList"), _T("*arm*;rx*;mips*"));
911 
913  if (page)
914  {
915  wxItemContainer* win = dynamic_cast<wxItemContainer*>( page->FindWindowByName( name.IsEmpty() ? _T("GenericChoiceList") : name , page ) );
916  if (win)
917  {
918  wxArrayString valids = GetArrayFromString(validCompilerIDs, _T(";"), true);
919  win->Clear();
920  for (size_t i = 0; i < CompilerFactory::GetCompilersCount(); ++i)
921  {
922  Compiler* compiler = CompilerFactory::GetCompiler(i);
923  if (compiler)
924  {
925  for (size_t n = 0; n < valids.GetCount(); ++n)
926  {
927  // match not only if IDs match, but if ID inherits from it too
928  if (CompilerFactory::CompilerInheritsFrom(compiler, valids[n]))
929  {
930  win->Append(compiler->GetName());
931  break;
932  }
933  }
934  }
935  }
937  if (compiler)
938  win->SetSelection(win->FindString(compiler->GetName()));
939  }
940  }
941 }
942 
943 void Wiz::AppendContainerWithSelectCompilers( const wxString& name, const wxString& validCompilerIDs )
944 {
945  // Add to the named window the compilers matching a mask/filter
946  // Example: AppendContainerWithSelectCompilers(_T("GenericChoiceList"), _T("*arm*;rx*;mips*"));
947 
949  if (page)
950  {
951  wxItemContainer* win = dynamic_cast<wxItemContainer*>( page->FindWindowByName( name.IsEmpty() ? _T("GenericChoiceList") : name , page ) );
952  if (win)
953  {
954  wxArrayString valids = GetArrayFromString(validCompilerIDs, _T(";"), true);
955  size_t iItemsCount = win->GetCount();
956  wxString nameInItems = _T(";");
957  for( size_t i = 0; i < iItemsCount; ++i )
958  {
959  nameInItems += win->GetString(i) + _T(";");
960  }
961  for (size_t i = 0; i < CompilerFactory::GetCompilersCount(); ++i)
962  {
963  Compiler* compiler = CompilerFactory::GetCompiler(i);
964  if (compiler)
965  {
966  wxString compilerName = compiler->GetName();
967  if( wxNOT_FOUND != nameInItems.Find( _T(";") + compilerName + _T(";") ) )
968  continue;
969  for (size_t n = 0; n < valids.GetCount(); ++n)
970  {
971  // match not only if IDs match, but if ID inherits from it too
972  if (CompilerFactory::CompilerInheritsFrom(compiler, valids[n]))
973  {
974  win->Append( compilerName );
975  nameInItems += compilerName + _T(";");
976  break;
977  }
978  }
979  }
980  }
981  }
982  }
983 }
984 
985 void Wiz::EnableWindow(const wxString& name, bool enable)
986 {
988  if (page)
989  {
990  wxWindow* win = page->FindWindowByName(name, page);
991  if (win)
992  win->Enable(enable);
993  }
994 }
995 
996 void Wiz::SetComboboxSelection(const wxString& name, int sel)
997 {
999  if (page)
1000  {
1001  wxItemContainer* win = dynamic_cast<wxItemContainer*>(page->FindWindowByName(name, page));
1002  if (win)
1003  win->SetSelection(sel);
1004  }
1005 }
1006 
1007 void Wiz::SetComboboxValue(const wxString& name, const wxString& value)
1008 {
1010  if (page)
1011  {
1012  wxComboBox* win = dynamic_cast<wxComboBox*>(page->FindWindowByName(name, page));
1013  if (win)
1014  win->SetValue(value);
1015  }
1016 }
1017 
1019 {
1021  if (page)
1022  {
1023  wxComboBox* win = dynamic_cast<wxComboBox*>(page->FindWindowByName(name, page));
1024  if (win)
1025  return win->GetValue();
1026  }
1027  return wxEmptyString;
1028 }
1029 
1030 
1032 {
1033  int id = GetComboboxSelection(name);
1034  Compiler* compiler = CompilerFactory::GetCompiler(id);
1035  if (compiler)
1036  return compiler->GetID();
1037  return wxEmptyString;
1038 }
1039 
1041 {
1043  if (page)
1044  {
1045  wxItemContainer* win = dynamic_cast<wxItemContainer*>(page->FindWindowByName(name, page));
1046  if (win)
1047  return win->GetStringSelection();
1048  }
1049  return wxEmptyString;
1050 }
1051 
1053 {
1055  if (page)
1056  {
1057  wxItemContainer* win = dynamic_cast<wxItemContainer*>(page->FindWindowByName(name, page));
1058  if (win)
1059  return win->GetSelection();
1060  }
1061  return -1;
1062 }
1063 
1065 {
1067  if (page)
1068  {
1069  wxRadioBox* win = dynamic_cast<wxRadioBox*>(page->FindWindowByName(name, page));
1070  if (win)
1071  return win->GetSelection();
1072  }
1073  return -1;
1074 }
1075 
1076 void Wiz::SetRadioboxSelection(const wxString& name, int sel)
1077 {
1079  if (page)
1080  {
1081  wxRadioBox* win = dynamic_cast<wxRadioBox*>(page->FindWindowByName(name, page));
1082  if (win)
1083  win->SetSelection(sel);
1084  }
1085 }
1086 
1088 {
1090  if (page)
1091  {
1092  wxListBox* win = dynamic_cast<wxListBox*>(page->FindWindowByName(name, page));
1093  if (win)
1094  return win->GetSelection();
1095  }
1096  return -1;
1097 }
1098 
1099 
1101 {
1103  if (page)
1104  {
1105  wxListBox* lbox = dynamic_cast<wxListBox*>(page->FindWindowByName(name, page));
1106  if (lbox)
1107  {
1108  wxString result;
1109  size_t i;
1110  wxArrayInt selections;
1111  lbox->GetSelections(selections);
1112  for (i = 0; i < selections.GetCount(); ++i)
1113  result.Append(wxString::Format(_T("%d;"), selections[i]));
1114  return result;
1115  }
1116  }
1117  return wxEmptyString;
1118 }
1119 
1120 
1122 {
1124  if (page)
1125  {
1126  wxListBox* lbox = dynamic_cast<wxListBox*>(page->FindWindowByName(name, page));
1127  if (lbox)
1128  {
1129  wxString result;
1130  size_t i;
1131  wxArrayInt selections;
1132  lbox->GetSelections(selections);
1133  for (i = 0; i < selections.GetCount(); ++i)
1134  result.Append(lbox->GetString(selections[i]) + _T(";"));
1135  return result;
1136  }
1137  }
1138  return wxEmptyString;
1139 }
1140 
1141 
1142 void Wiz::SetListboxSelection(const wxString& name, int sel)
1143 {
1145  if (page)
1146  {
1147  wxListBox* win = dynamic_cast<wxListBox*>(page->FindWindowByName(name, page));
1148  if (win)
1149  win->SetSelection(sel);
1150  }
1151 }
1152 
1154 {
1156  if (page)
1157  {
1158  wxCheckListBox* clb = dynamic_cast<wxCheckListBox*>(page->FindWindowByName(name, page));
1159  if (clb)
1160  {
1161  wxString result;
1162  unsigned int i;
1163  for (i = 0; i < clb->GetCount(); ++i)
1164  {
1165  if (clb->IsChecked(i))
1166  result.Append(wxString::Format(_T("%u;"), i));
1167  }
1168  return result;
1169  }
1170  }
1171  return wxEmptyString;
1172 }
1173 
1175 {
1177  if (page)
1178  {
1179  wxCheckListBox* clb = dynamic_cast<wxCheckListBox*>(page->FindWindowByName(name, page));
1180  if (clb)
1181  {
1182  wxString result;
1183  unsigned int i;
1184  for (i = 0; i < clb->GetCount(); ++i)
1185  {
1186  if (clb->IsChecked(i))
1187  result.Append(wxString::Format(_T("%s;"), clb->GetString(i).wx_str()));
1188  }
1189  return result;
1190  }
1191  }
1192  return wxEmptyString;
1193 }
1194 
1195 bool Wiz::IsCheckListboxItemChecked(const wxString& name, unsigned int item)
1196 {
1198  if (page)
1199  {
1200  wxCheckListBox* clb = dynamic_cast<wxCheckListBox*>(page->FindWindowByName(name, page));
1201  if (clb)
1202  return clb->IsChecked(item);
1203  }
1204  return false;
1205 }
1206 
1207 void Wiz::CheckCheckListboxItem(const wxString& name, unsigned int item, bool check)
1208 {
1210  if (page)
1211  {
1212  wxCheckListBox* clb = dynamic_cast<wxCheckListBox*>(page->FindWindowByName(name, page));
1213  if (clb)
1214  clb->Check(item, check);
1215  }
1216 }
1217 
1218 void Wiz::CheckCheckbox(const wxString& name, bool check)
1219 {
1221  if (page)
1222  {
1223  wxCheckBox* win = dynamic_cast<wxCheckBox*>(page->FindWindowByName(name, page));
1224  if (win)
1225  win->SetValue(check);
1226  }
1227 }
1228 
1230 {
1232  if (page)
1233  {
1234  wxCheckBox* win = dynamic_cast<wxCheckBox*>(page->FindWindowByName(name, page));
1235  if (win)
1236  return win->IsChecked();
1237  }
1238  return false;
1239 }
1240 
1241 void Wiz::SetTextControlValue(const wxString& name, const wxString& value)
1242 {
1244  if (page)
1245  {
1246  wxTextCtrl* win = dynamic_cast<wxTextCtrl*>(page->FindWindowByName(name, page));
1247  if (win)
1248  win->SetValue(value);
1249  }
1250 }
1251 
1253 {
1255  if (page)
1256  {
1257  wxTextCtrl* win = dynamic_cast<wxTextCtrl*>(page->FindWindowByName(name, page));
1258  if (win)
1259  return win->GetValue();
1260  }
1261  return wxEmptyString;
1262 }
1263 
1264 void Wiz::SetSpinControlValue(const wxString& name, int value)
1265 {
1267  if (page)
1268  {
1269  wxSpinCtrl* win = dynamic_cast<wxSpinCtrl*>(page->FindWindowByName(name, page));
1270  if (win)
1271  win->SetValue(value);
1272  }
1273 }
1274 
1276 {
1278  if (page)
1279  {
1280  wxSpinCtrl* win = dynamic_cast<wxSpinCtrl*>(page->FindWindowByName(name, page));
1281  if (win)
1282  return win->GetValue();
1283  }
1284  return -1;
1285 }
1286 
1287 void Wiz::AddInfoPage(const wxString& pageId, const wxString& intro_msg)
1288 {
1289  // we don't track this; can add more than one
1290  WizPageBase* page = new WizInfoPanel(pageId, intro_msg, m_pWizard, m_Wizards[m_LaunchIndex].wizardPNG);
1291  if (!page->SkipPage())
1292  m_Pages.Add(page);
1293  else
1294  delete page;
1295 }
1296 
1297 void Wiz::AddFilePathPage(bool showHeaderGuard)
1298 {
1299  if (m_pWizFilePathPanel)
1300  return; // already added
1301  m_pWizFilePathPanel = new WizFilePathPanel(showHeaderGuard, m_pWizard, m_Wizards[m_LaunchIndex].wizardPNG);
1302  if (!m_pWizFilePathPanel->SkipPage())
1304  else
1305  {
1306  delete m_pWizFilePathPanel;
1307  m_pWizFilePathPanel = nullptr;
1308  }
1309 }
1310 
1312 {
1314  return; // already added
1318  else
1319  {
1320  delete m_pWizProjectPathPanel;
1321  m_pWizProjectPathPanel = nullptr;
1322  }
1323 }
1324 
1325 void Wiz::AddCompilerPage(const wxString& compilerID, const wxString& validCompilerIDs, bool allowCompilerChange, bool allowConfigChange)
1326 {
1327  if (m_pWizCompilerPanel)
1328  return; // already added
1329  m_pWizCompilerPanel = new WizCompilerPanel(compilerID, validCompilerIDs, m_pWizard, m_Wizards[m_LaunchIndex].wizardPNG, allowCompilerChange, allowConfigChange);
1330  if (!m_pWizCompilerPanel->SkipPage())
1332  else
1333  {
1334  delete m_pWizCompilerPanel;
1335  m_pWizCompilerPanel = nullptr;
1336  }
1337 }
1338 
1339 void Wiz::AddBuildTargetPage(const wxString& targetName, bool isDebug, bool showCompiler, const wxString& compilerID, const wxString& validCompilerIDs, bool allowCompilerChange)
1340 {
1342  return; // already added
1343  m_pWizBuildTargetPanel = new WizBuildTargetPanel(targetName, isDebug, m_pWizard, m_Wizards[m_LaunchIndex].wizardPNG, showCompiler, compilerID, validCompilerIDs, allowCompilerChange);
1346  else
1347  {
1348  delete m_pWizBuildTargetPanel;
1349  m_pWizBuildTargetPanel = nullptr;
1350  }
1351 }
1352 
1353 void Wiz::AddGenericSingleChoiceListPage(const wxString& pageName, const wxString& descr, const wxString& choices, int defChoice)
1354 {
1355  // we don't track this; can add more than one
1356  WizPageBase* page = new WizGenericSingleChoiceList(pageName, descr, GetArrayFromString(choices, _T(";")), defChoice, m_pWizard, m_Wizards[m_LaunchIndex].wizardPNG);
1357  if (!page->SkipPage())
1358  m_Pages.Add(page);
1359  else
1360  delete page;
1361 }
1362 
1363 void Wiz::AddGenericSelectPathPage(const wxString& pageId, const wxString& descr, const wxString& label, const wxString& defValue)
1364 {
1365  // we don't track this; can add more than one
1366  WizPageBase* page = new WizGenericSelectPathPanel(pageId, descr, label, defValue, m_pWizard, m_Wizards[m_LaunchIndex].wizardPNG);
1367  if (!page->SkipPage())
1368  m_Pages.Add(page);
1369  else
1370  delete page;
1371 }
1372 
1373 void Wiz::AddPage(const wxString& panelName)
1374 {
1375  WizPage* page = new WizPage(panelName, m_pWizard, m_Wizards[m_LaunchIndex].wizardPNG);
1376  if (!page->SkipPage())
1377  m_Pages.Add(page);
1378  else
1379  delete page;
1380 }
1381 
1383 {
1384  // chain pages
1385  for (size_t i = 1; i < m_Pages.GetCount(); ++i)
1387 
1388  // allow the wizard to size itself around the pages
1389  for (size_t i = 0; i < m_Pages.GetCount(); ++i)
1390  m_pWizard->GetPageAreaSizer()->Add(m_Pages[i]);
1391 
1392  m_pWizard->Fit();
1393 }
1394 
1396  const wxString& title,
1397  const wxString& cat,
1398  const wxString& script,
1399  const wxString& templatePNG,
1400  const wxString& wizardPNG,
1401  const wxString& xrc)
1402 {
1403  // check that this isn't registered already
1404  // keys are otype and title
1405  for (size_t i = 0; i < m_Wizards.GetCount(); ++i)
1406  {
1407  WizardInfo& info = m_Wizards[i];
1408  if (info.output_type == otype && info.title == title)
1409  {
1410  Manager::Get()->GetLogManager()->DebugLog(F(_T("Wizard already registered. Skipping... (%s)"), title.wx_str()));
1411  return;
1412  }
1413  }
1414 
1415  // locate the images and XRC
1416  wxString tpng = ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/") + templatePNG;
1417  if (!wxFileExists(tpng))
1418  tpng = ConfigManager::GetFolder(sdDataGlobal) + _T("/templates/wizard/") + templatePNG;
1419  wxString wpng = ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/") + wizardPNG;
1420  if (!wxFileExists(wpng))
1421  wpng = ConfigManager::GetFolder(sdDataGlobal) + _T("/templates/wizard/") + wizardPNG;
1422  wxString _xrc = ConfigManager::GetFolder(sdDataUser) + _T("/templates/wizard/") + xrc;
1423  if (!wxFileExists(_xrc))
1424  _xrc = ConfigManager::GetFolder(sdDataGlobal) + _T("/templates/wizard/") + xrc;
1425 
1426  WizardInfo info;
1427  info.output_type = otype;
1428  info.title = title;
1429  info.cat = cat;
1430  info.script = script;
1432 
1433  // wx3.0 asserts when the image is smaller than 32x32, so we need to resize it.
1434  if (info.templatePNG.Ok() && (info.templatePNG.GetWidth() != 32 || info.templatePNG.GetHeight() != 32))
1435  {
1436  Manager::Get()->GetLogManager()->LogWarning(F(_("Resizing image '%s' to fit 32x32 (original size is %dx%d)"),
1437  tpng.wx_str(), info.templatePNG.GetWidth(),
1438  info.templatePNG.GetHeight()));
1439  wxImage temp = info.templatePNG.ConvertToImage();
1440  temp.Resize(wxSize(32, 32), wxPoint(0, 0), -1, -1, -1);
1441  info.templatePNG = wxBitmap(temp);
1442  }
1443 
1445  info.xrc = _xrc;
1446  m_Wizards.Add(info);
1447 
1448  wxString typS;
1449  switch (otype)
1450  {
1451  case totProject: typS = _T("Project"); break;
1452  case totTarget: typS = _T("Build-target"); break;
1453  case totFiles: typS = _T("File(s)"); break;
1454  case totUser: typS = _T("User"); break;
1455  case totCustom: typS = _T("Custom"); break;
1456  default: break;
1457  }
1458 
1459  Manager::Get()->GetLogManager()->DebugLog(F(typS + _T(" wizard added for '%s'"), title.wx_str()));
1460 }
1461 
1463 {
1465  return m_pWizProjectPathPanel->GetPath();
1466  return wxEmptyString;
1467 }
1468 
1470 {
1472  return m_pWizProjectPathPanel->GetName();
1473  return wxEmptyString;
1474 }
1475 
1477 {
1480  return wxEmptyString;
1481 }
1482 
1484 {
1486  return m_pWizProjectPathPanel->GetTitle();
1487  return wxEmptyString;
1488 }
1489 
1491 {
1496  return m_DefCompilerID;
1497 }
1498 
1500 {
1501  if (m_pWizCompilerPanel)
1503  return m_WantDebug;
1504 }
1505 
1507 {
1508  if (m_pWizCompilerPanel)
1510  return m_DebugName;
1511 }
1512 
1514 {
1515  if (m_pWizCompilerPanel)
1517  return m_DebugOutputDir;
1518 }
1519 
1521 {
1522  if (m_pWizCompilerPanel)
1524  return m_DebugObjOutputDir;
1525 }
1526 
1528 {
1529  if (m_pWizCompilerPanel)
1531  return m_WantRelease;
1532 }
1533 
1535 {
1536  if (m_pWizCompilerPanel)
1538  return m_ReleaseName;
1539 }
1540 
1542 {
1543  if (m_pWizCompilerPanel)
1545  return m_ReleaseOutputDir;
1546 }
1547 
1549 {
1550  if (m_pWizCompilerPanel)
1552  return m_ReleaseObjOutputDir;
1553 }
1554 
1556 {
1559  return wxEmptyString;
1560 }
1561 
1563 {
1566  return false;
1567 }
1568 
1570 {
1573  return wxEmptyString;
1574 }
1575 
1577 {
1580  return wxEmptyString;
1581 }
1582 
1584 {
1587  return wxEmptyString;
1588 }
1589 
1591 {
1592  if (m_pWizFilePathPanel)
1593  return m_pWizFilePathPanel->GetFilename();
1594  return wxEmptyString;
1595 }
1596 
1598 {
1599  if (m_pWizFilePathPanel)
1601  return wxEmptyString;
1602 }
1603 
1605 {
1606  if (m_pWizFilePathPanel)
1608  return false;
1609 }
1610 
1612 {
1613  if (m_pWizFilePathPanel)
1615  return -1;
1616 }
1617 
1619 {
1620  if (m_pWizFilePathPanel)
1622 }
1623 
1624 void Wiz::SetCompilerDefault(cb_unused const wxString& defCompilerID)
1625 {
1626  // default compiler settings (returned if no compiler page is added in the wizard)
1628 }
1629 
1630 void Wiz::SetDebugTargetDefaults(bool wantDebug,
1631  const wxString& debugName,
1632  const wxString& debugOut,
1633  const wxString& debugObjOut)
1634 {
1635  // default compiler settings (returned if no compiler page is added in the wizard)
1636  m_WantDebug = wantDebug;
1637  m_DebugName = debugName;
1638  m_DebugOutputDir = debugOut;
1639  m_DebugObjOutputDir = debugObjOut;
1640 }
1641 
1642 void Wiz::SetReleaseTargetDefaults(bool wantRelease,
1643  const wxString& releaseName,
1644  const wxString& releaseOut,
1645  const wxString& releaseObjOut)
1646 {
1647  // default compiler settings (returned if no compiler page is added in the wizard)
1648  m_WantRelease = wantRelease;
1649  m_ReleaseName = releaseName;
1650  m_ReleaseOutputDir = releaseOut;
1651  m_ReleaseObjOutputDir = releaseObjOut;
1652 }
1653 
1654 int Wiz::FillContainerWithChoices( const wxString& name, const wxString& choices )
1655 {
1656  // Fill the named window with a semi-colon separated set of strings
1657  // Eg: FillContainerWithChoices(_T("GenericChoiceList"), _T("this;that;another"));
1658 
1660  if (page)
1661  {
1662  wxItemContainer* win = dynamic_cast<wxItemContainer*>( page->FindWindowByName( name.IsEmpty() ? _T("GenericChoiceList") : name , page ) );
1663  if (win)
1664  {
1665  win->Clear();
1666  wxArrayString items = GetArrayFromString( choices, _T(";") );
1667  unsigned int nItems = items.GetCount();
1668  for ( unsigned int i = 0; i < nItems; i++ )
1669  {
1670  win->Append( items[i] );
1671  }
1672 
1673  return 0;
1674  }
1675  }
1676  return -1;
1677 }
1678 
1679 int Wiz::AppendContainerWithChoices( const wxString& name, const wxString& choices )
1680 {
1681  // Add to the named window, a semi-colon separated set of strings
1682  // Eg: AppendContainerWithChoices(_T("GenericChoiceList"), _T("this;that;another"));
1683 
1685  if (page)
1686  {
1687  wxItemContainer* win = dynamic_cast<wxItemContainer*>( page->FindWindowByName( name.IsEmpty() ? _T("GenericChoiceList") : name , page ) );
1688  if (win)
1689  {
1690  wxArrayString items = GetArrayFromString( choices, _T(";") );
1691  size_t iItemsCount = win->GetCount();
1692  wxString nameInItems = _T(";");
1693  for( size_t i = 0; i < iItemsCount; ++i )
1694  {
1695  nameInItems += win->GetString(i) + _T(";");
1696  }
1697  unsigned int nItems = items.GetCount();
1698  for ( unsigned int i = 0; i < nItems; i++ )
1699  {
1700  wxString tItemsName = items[i];
1701  if( wxNOT_FOUND != nameInItems.Find( _T(";") + tItemsName + _T(";") ) )
1702  continue;
1703  win->Append( tItemsName );
1704  nameInItems += tItemsName + _T(";");
1705  }
1706 
1707  return 0;
1708  }
1709  }
1710  return -1;
1711 }
1712 
1714 {
1715  // Return the name only of the current wizard folder (this is not a path)
1716  //ie., would return only _T("arm") for ...\trunk\src\output\share\CodeBlocks\templates\wizard\arm
1717 
1718  return m_WizardScriptFolder;
1719 }
1720 
1721 
1723 {
1724  SqPlus::SQClassDef<Wiz>("Wiz").
1725  // register new wizards
1726  func(&Wiz::AddWizard, "AddWizard").
1727  // add wizard pages
1728  func(&Wiz::AddInfoPage, "AddInfoPage").
1729  func(&Wiz::AddProjectPathPage, "AddProjectPathPage").
1730  func(&Wiz::AddFilePathPage, "AddFilePathPage").
1731  func(&Wiz::AddCompilerPage, "AddCompilerPage").
1732  func(&Wiz::AddBuildTargetPage, "AddBuildTargetPage").
1733  func(&Wiz::AddGenericSingleChoiceListPage, "AddGenericSingleChoiceListPage").
1734  func(&Wiz::AddGenericSelectPathPage, "AddGenericSelectPathPage").
1735  func(&Wiz::AddPage, "AddPage").
1736  // compiler defaults
1737  func(&Wiz::SetCompilerDefault, "SetCompilerDefault").
1738  func(&Wiz::SetDebugTargetDefaults, "SetDebugTargetDefaults").
1739  func(&Wiz::SetReleaseTargetDefaults, "SetReleaseTargetDefaults").
1740  // GUI controls
1741  func(&Wiz::EnableWindow, "EnableWindow").
1742  func(&Wiz::SetTextControlValue, "SetTextControlValue").
1743  func(&Wiz::GetTextControlValue, "GetTextControlValue").
1744  func(&Wiz::SetSpinControlValue, "SetSpinControlValue").
1745  func(&Wiz::GetSpinControlValue, "GetSpinControlValue").
1746  func(&Wiz::CheckCheckbox, "CheckCheckbox").
1747  func(&Wiz::IsCheckboxChecked, "IsCheckboxChecked").
1748  func(&Wiz::FillComboboxWithCompilers, "FillComboboxWithCompilers").
1749  func(&Wiz::GetCompilerFromCombobox, "GetCompilerFromCombobox").
1750  func(&Wiz::FillContainerWithCompilers, "FillContainerWithCompilers").
1751  // these three are deprecated, the ItemContainer versions should be used instead as they are more generic.
1752  func(&Wiz::GetComboboxStringSelection, "GetComboboxStringSelection").
1753  func(&Wiz::GetComboboxSelection, "GetComboboxSelection").
1754  func(&Wiz::SetComboboxSelection, "SetComboboxSelection").
1755  func(&Wiz::SetComboboxValue, "SetComboboxValue").
1756  func(&Wiz::GetComboboxValue, "GetComboboxValue").
1757  func(&Wiz::GetComboboxStringSelection, "GetItemContainerStringSelection").
1758  func(&Wiz::GetComboboxSelection, "GetItemContainerSelection").
1759  func(&Wiz::SetComboboxSelection, "SetItemContainerSelection").
1760  func(&Wiz::GetRadioboxSelection, "GetRadioboxSelection").
1761  func(&Wiz::SetRadioboxSelection, "SetRadioboxSelection").
1762  func(&Wiz::GetListboxSelection, "GetListboxSelection").
1763  func(&Wiz::GetListboxSelections, "GetListboxSelections").
1764  func(&Wiz::GetListboxStringSelections, "GetListboxStringSelections").
1765  func(&Wiz::SetListboxSelection, "SetListboxSelection").
1766  func(&Wiz::GetCheckListboxChecked, "GetCheckListboxChecked").
1767  func(&Wiz::GetCheckListboxStringChecked, "GetCheckListboxStringChecked").
1768  func(&Wiz::IsCheckListboxItemChecked, "IsCheckListboxItemChecked").
1769  func(&Wiz::CheckCheckListboxItem, "CheckCheckListboxItem").
1770  // get various common info
1771  func(&Wiz::GetWizardType, "GetWizardType").
1772  func(&Wiz::FindTemplateFile, "FindTemplateFile").
1773  // project path page
1774  func(&Wiz::GetProjectPath, "GetProjectPath").
1775  func(&Wiz::GetProjectName, "GetProjectName").
1776  func(&Wiz::GetProjectFullFilename, "GetProjectFullFilename").
1777  func(&Wiz::GetProjectTitle, "GetProjectTitle").
1778  // compiler page
1779  func(&Wiz::GetCompilerID, "GetCompilerID").
1780  // + debug target
1781  func(&Wiz::GetWantDebug, "GetWantDebug").
1782  func(&Wiz::GetDebugName, "GetDebugName").
1783  func(&Wiz::GetDebugOutputDir, "GetDebugOutputDir").
1784  func(&Wiz::GetDebugObjectOutputDir, "GetDebugObjectOutputDir").
1785  // + release target
1786  func(&Wiz::GetWantRelease, "GetWantRelease").
1787  func(&Wiz::GetReleaseName, "GetReleaseName").
1788  func(&Wiz::GetReleaseOutputDir, "GetReleaseOutputDir").
1789  func(&Wiz::GetReleaseObjectOutputDir, "GetReleaseObjectOutputDir").
1790  // build target page
1791  func(&Wiz::GetTargetCompilerID, "GetTargetCompilerID").
1792  func(&Wiz::GetTargetEnableDebug, "GetTargetEnableDebug").
1793  func(&Wiz::GetTargetName, "GetTargetName").
1794  func(&Wiz::GetTargetOutputDir, "GetTargetOutputDir").
1795  func(&Wiz::GetTargetObjectOutputDir, "GetTargetObjectOutputDir").
1796  // file path page
1797  func(&Wiz::GetFileName, "GetFileName").
1798  func(&Wiz::GetFileHeaderGuard, "GetFileHeaderGuard").
1799  func(&Wiz::GetFileAddToProject, "GetFileAddToProject").
1800  func(&Wiz::GetFileTargetIndex, "GetFileTargetIndex").
1801  func(&Wiz::SetFilePathSelectionFilter, "SetFilePathSelectionFilter").
1802 
1803  // Fill the named window with compilers matching a mask/filter
1804  func(&Wiz::FillContainerWithSelectCompilers, "FillContainerWithSelectCompilers").
1805 
1806  // Add to the named window the compilers matching a mask/filter
1807  func(&Wiz::AppendContainerWithSelectCompilers, "AppendContainerWithSelectCompilers").
1808 
1809  // Fill the named window with a semi-colon separated set of strings
1810  func(&Wiz::FillContainerWithChoices, "FillContainerWithChoices").
1811 
1812  // Add to the named window, a semi-colon separated set of strings
1813  func(&Wiz::AppendContainerWithChoices, "AppendContainerWithChoices").
1814 
1815  // Return the name only of the current wizard folder (this is not a path)
1816  func(&Wiz::GetWizardScriptFolder, "GetWizardScriptFolder");
1817 
1818  SqPlus::BindVariable(this, "Wizard", SqPlus::VAR_ACCESS_READ_ONLY);
1819 }
1820 
1822 // Scripting - END
wxTreeItemId GetProjectNode()
Definition: cbproject.h:311
wxString m_DebugObjOutputDir
Definition: wiz.h:194
ProjectFile * GetFileByFilename(const wxString &filename, bool isRelative=true, bool isUnixFilename=false)
Access a file of the project.
Definition: cbproject.cpp:1049
wxString F(const wxChar *msg,...)
sprintf-like function
Definition: logmanager.h:20
DLLIMPORT wxArrayString GetArrayFromString(const wxString &text, const wxString &separator=DEFAULT_ARRAY_SEP, bool trimSpaces=true)
Definition: globals.cpp:134
static void Display(const wxString &title, const wxString &message, unsigned int delay=5000, unsigned int hysteresis=1)
Definition: infowindow.cpp:294
wxString GetDescription(int index) const
Definition: wiz.cpp:163
wxString m_DefCompilerID
Definition: wiz.h:190
wxString GetTargetOutputDir()
Definition: wiz.cpp:1576
wxString GetComboboxValue(const wxString &name)
Definition: wiz.cpp:1018
wxString GetFileName()
Definition: wiz.cpp:1590
DECLARE_INSTANCE_TYPE(Wiz)
static wxString GetFolder(SearchDirs dir)
Access one of Code::Blocks&#39; folders.
bool Create(wxWindow *parent, int id=wxID_ANY, const wxString &title=wxEmptyString, const wxBitmap &bitmap=wxNullBitmap, const wxPoint &pos=wxDefaultPosition, long style=wxDEFAULT_DIALOG_STYLE)
wxString GetTextControlValue(const wxString &name)
Definition: wiz.cpp:1252
Wiz()
Definition: wiz.cpp:58
#define wxICON_QUESTION
wxWizardPageSimple & Chain(wxWizardPageSimple *next)
Data folder in user&#39;s dir.
Definition: configmanager.h:75
wxString GetTargetObjectOutputDir()
Definition: wiz.cpp:1583
Definition: wiz.h:38
wxString GetWizardScriptFolder(void)
Definition: wiz.cpp:1713
CompileTargetBase * RunFilesWizard(wxString *pFilename)
Definition: wiz.cpp:677
wxString GetProjectName()
Definition: wiz.cpp:1469
virtual void SetObjectOutput(const wxString &dirname)
Set the target&#39;s objects output dir.
wxString GetScriptFilename(int index) const
Definition: wiz.cpp:188
void SetDebugTargetDefaults(bool wantDebug, const wxString &debugName, const wxString &debugOut, const wxString &debugObjOut)
Definition: wiz.cpp:1630
void SetFilePathSelectionFilter(const wxString &filter)
Definition: wizpage.cpp:297
wxString m_ReleaseObjOutputDir
Definition: wiz.h:198
int GetRadioboxSelection(const wxString &name)
Definition: wiz.cpp:1064
virtual void RebuildTree()=0
Rebuild the project manager&#39;s tree.
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 AddGenericSingleChoiceListPage(const wxString &pageName, const wxString &descr, const wxString &choices, int defChoice)
Definition: wiz.cpp:1353
wxString GetDebugOutputDir()
Definition: wiz.cpp:1513
void SetReleaseTargetDefaults(bool wantRelease, const wxString &releaseName, const wxString &releaseOut, const wxString &releaseObjOut)
Definition: wiz.cpp:1642
wxString m_DebugOutputDir
Definition: wiz.h:193
virtual bool RunWizard(wxWizardPage *firstPage)
void FillContainerWithCompilers(const wxString &name, const wxString &compilerID, const wxString &validCompilerIDs)
Definition: wiz.cpp:894
virtual wxString GetString(unsigned int n) const
wxString GetTargetName() const
Definition: wizpage.cpp:664
WizCompilerPanel * m_pWizCompilerPanel
Definition: wiz.h:184
wxString m_ReleaseOutputDir
Definition: wiz.h:197
#define wxICON_ERROR
DLLIMPORT wxBitmap cbLoadBitmap(const wxString &filename, wxBitmapType bitmapType=wxBITMAP_TYPE_PNG)
This function loads a bitmap from disk.
Definition: globals.cpp:1102
TemplateOutputType output_type
Definition: wiz.h:26
virtual FilesList & GetFilesList()
Provides an easy way to iterate all the files belonging in this target.
Definition: cbproject.h:685
bool wxFileExists(const wxString &filename)
void LogWarning(const wxString &msg, int i=app_log)
Definition: logmanager.h:141
static Compiler * GetDefaultCompiler()
wxString GetPath() const
Definition: wizpage.cpp:343
wxString GetReleaseObjectOutputDir() const
Definition: wizpage.cpp:575
int GetListboxSelection(const wxString &name)
Definition: wiz.cpp:1087
wxString GetCompilerID() const
Definition: wizpage.cpp:646
CompileTargetBase * RunTargetWizard(wxString *pFilename)
Definition: wiz.cpp:547
wxString GetFilename() const
Definition: wizpage.h:85
wxString GetProjectFullFilename()
Definition: wiz.cpp:1476
wxCStrData c_str() const
bool wxDirExists(const wxString &dirname)
static Compiler * GetCompiler(size_t index)
bool GetWantRelease() const
Definition: wizpage.cpp:557
TemplateOutputType GetWizardType()
Definition: wiz.cpp:867
#define wxNO_DEFAULT
#define _T(string)
FileType
Known file types.
Definition: globals.h:49
static const wxString & GetDefaultCompilerID()
void AddProjectPathPage()
Definition: wiz.cpp:1311
void OnAttach()
Any descendent plugin should override this virtual method and perform any necessary initialization...
Definition: wiz.cpp:74
void SetComboboxSelection(const wxString &name, int sel)
Definition: wiz.cpp:996
wxString GetListboxSelections(const wxString &name)
Definition: wiz.cpp:1100
#define wxYES_NO
virtual wxImage ConvertToImage() const
bool GetWantRelease()
Definition: wiz.cpp:1527
const wxBitmap & GetBitmap(int index) const
Definition: wiz.cpp:180
bool m_WantDebug
Definition: wiz.h:191
void EndAddFiles()
Notify that file(s) addition finished.
Definition: cbproject.cpp:600
cbProjectManagerUI & GetUI()
virtual void SetIncludeInTargetAll(bool buildIt)
Deprecated, do not use at all! Set if this target should be built when the virtual target "All" is se...
CompileTargetBase * RunProjectWizard(wxString *pFilename)
Definition: wiz.cpp:346
WizPages m_Pages
Definition: wiz.h:181
DLLIMPORT FileType FileTypeOf(const wxString &filename)
Definition: globals.cpp:285
wxString m_DebugName
Definition: wiz.h:192
#define wxICON_INFORMATION
wxString GetCheckListboxStringChecked(const wxString &name)
Definition: wiz.cpp:1174
virtual wxSizer * GetPageAreaSizer() const
wxString GetTargetOutputDir() const
Definition: wizpage.cpp:670
bool IsChecked(unsigned int item) const
static size_t GetAllFiles(const wxString &dirname, wxArrayString *files, const wxString &filespec=wxEmptyString, int flags=wxDIR_DEFAULT)
bool GetWantDebug()
Definition: wiz.cpp:1499
wxString AfterFirst(wxUniChar ch) const
wxString GetReleaseOutputDir() const
Definition: wizpage.cpp:569
#define wxNOT_FOUND
Represents a file in a Code::Blocks project.
Definition: projectfile.h:39
bool GetWantDebug() const
Definition: wizpage.cpp:533
void BeginAddFiles()
Notify that file(s) will be added shortly.
Definition: cbproject.cpp:593
virtual void SetCompilerID(const wxString &id)
! Set the flag if the host app should be run in terminal
void Finalize()
Definition: wiz.cpp:1382
wxString GetCheckListboxChecked(const wxString &name)
Definition: wiz.cpp:1153
EditorManager * GetEditorManager() const
Definition: manager.cpp:434
template produces custom output (entirely up to the wizard used)
Definition: globals.h:150
void EnableWindow(const wxString &name, bool enable)
Definition: wiz.cpp:985
int GetSpinControlValue(const wxString &name)
Definition: wiz.cpp:1275
int m_LaunchIndex
Definition: wiz.h:186
bool IsCheckboxChecked(const wxString &name)
Definition: wiz.cpp:1229
wxString GetDebugName() const
Definition: wizpage.cpp:539
const wxArrayString & GetDirs() const
wxBitmap wizardPNG
Definition: wiz.h:31
wxString BeforeFirst(wxUniChar ch, wxString *rest=NULL) const
virtual void SetSelection(int n)
void AddFilePathPage(bool showHeaderGuard)
Definition: wiz.cpp:1297
ProjectManager * GetProjectManager() const
Functions returning pointers to the respective sub-manager instances.
Definition: manager.cpp:429
const wxString & GetID() const
Get this compiler&#39;s unique ID.
Definition: compiler.h:351
bool LoadScript(const wxString &filename)
Loads a script.
bool MakeRelativeTo(const wxString &pathBase=wxEmptyString, wxPathFormat format=wxPATH_NATIVE)
void SetCompilerID(const wxString &id) override
! Set the flag if the host app should be run in terminal
Definition: cbproject.cpp:129
Represents a Code::Blocks project.
Definition: cbproject.h:96
template outputs a new file (or files)
Definition: globals.h:149
CompileTargetBase * Launch(int index, wxString *pFilename=0)
When this is called, the wizard must get to work ;).
Definition: wiz.cpp:214
cbProject * NewProject(const wxString &filename=wxEmptyString)
Create a new empty project.
wxString GetHeaderGuard() const
Definition: wizpage.h:86
virtual const wxString & GetFilename() const
wxString GetReleaseName()
Definition: wiz.cpp:1534
void FillComboboxWithCompilers(const wxString &name)
Definition: wiz.cpp:873
void AddWizard(TemplateOutputType otype, const wxString &title, const wxString &cat, const wxString &script, const wxString &templatePNG, const wxString &wizardPNG, const wxString &xrc)
Definition: wiz.cpp:1395
null_pointer_t nullptr
Definition: nullptr.cpp:16
bool GetTargetEnableDebug()
Definition: wiz.cpp:1562
wxString GenerateFile(const wxString &basePath, const wxString &filename, const wxString &contents)
Definition: wiz.cpp:719
bool GetEnableDebug() const
Definition: wizpage.cpp:658
void FillContainerWithSelectCompilers(const wxString &name, const wxString &validCompilerIDs)
Definition: wiz.cpp:907
int GetCount() const
Definition: wiz.cpp:140
virtual int GetWidth() const
void AddInfoPage(const wxString &pageId, const wxString &intro_msg)
Definition: wiz.cpp:1287
int GetComboboxSelection(const wxString &name)
Definition: wiz.cpp:1052
wxString GetReleaseObjectOutputDir()
Definition: wiz.cpp:1548
size_t Replace(const wxString &strOld, const wxString &strNew, bool replaceAll=true)
void Check(unsigned int item, bool check=true)
wxString GetName() const
Definition: wizpage.cpp:349
void AppendContainerWithSelectCompilers(const wxString &name, const wxString &validCompilerIDs)
Definition: wiz.cpp:943
wxString GetFileHeaderGuard()
Definition: wiz.cpp:1597
const wxPoint wxDefaultPosition
static void SetDefaultCompiler(size_t index)
wxString xrc
Definition: wiz.h:32
static const wxString sep
virtual cbTreeCtrl * GetTree()=0
Retrieve a pointer to the project manager&#39;s tree (GUI).
Definition: wiz.h:24
Base class that all "editors" should inherit from.
Definition: editorbase.h:30
LogManager * GetLogManager() const
Definition: manager.cpp:439
cbProject * GetActiveProject()
Retrieve the active project.
bool wxCopyFile(const wxString &file1, const wxString &file2, bool overwrite=true)
virtual wxString GetBasePath() const
Read the target&#39;s base path, e.g. if GetFilename() returns "/usr/local/bin/xxx", base path will retur...
void SetListboxSelection(const wxString &name, int sel)
Definition: wiz.cpp:1142
WizBuildTargetPanel * m_pWizBuildTargetPanel
Definition: wiz.h:185
WizProjectPathPanel * m_pWizProjectPathPanel
Definition: wiz.h:182
void DisplayErrors(SquirrelError *exception=nullptr, bool clearErrors=true)
Display error dialog.
wxString GetComboboxStringSelection(const wxString &name)
Definition: wiz.cpp:1040
wxBitmap templatePNG
Definition: wiz.h:30
virtual void SetWorkingDir(const wxString &dirname)
Set the target&#39;s working dir on execution (valid only for executable targets)
const wxStringCharType * wx_str() const
#define wxDEFAULT_DIALOG_STYLE
DLLIMPORT bool cbWrite(wxFile &file, const wxString &buff, wxFontEncoding encoding=wxFONTENCODING_SYSTEM)
Writes a wxString to a non-unicode file. File must be open. File is closed automatically.
Definition: globals.cpp:705
virtual bool IsBuiltinEditor() const
Is this a built-in editor?
Definition: editorbase.cpp:209
wxString wxEmptyString
#define wxOK
TemplateOutputType GetOutputType(int index) const
Definition: wiz.cpp:146
WX_DEFINE_OBJARRAY(Wizards)
virtual void SetValue(const wxString &text)
virtual bool SkipPage() const
Definition: wizpage.h:39
bool m_WantRelease
Definition: wiz.h:195
wxString title
Definition: wiz.h:27
const wxString & _(const wxString &string)
wxString GetTargetName()
Definition: wiz.cpp:1569
wxString & Trim(bool fromRight=true)
bool Mkdir(int perm=wxS_DIR_DEFAULT, int flags=0) const
EditorBase * GetEditor(int index)
void ShowErrorMessage(bool safe=true)
Display exception error message.
Definition: cbexception.cpp:31
int GetBuildTargetsCount()
Definition: cbproject.h:200
Plugin registration object.
Definition: cbplugin.h:1099
wxString GetReleaseOutputDir()
Definition: wiz.cpp:1541
#define cbAssert(expr)
Definition: cbexception.h:48
TemplateOutputType
Template output types.
Definition: globals.h:145
static bool CompilerInheritsFrom(const wxString &id, const wxString &from_id)
wxString GetTargetCompilerID()
Definition: wiz.cpp:1555
void FillCompilerControl(wxItemContainer *control, const wxString &compilerID, const wxString &validCompilerIDs)
Definition: wizpage.cpp:38
wxArray< int > wxArrayInt
wxString GetDebugName()
Definition: wiz.cpp:1506
bool IsChecked() const
virtual void Expand(const wxTreeItemId &item)
wxString GetTitle(int index) const
Definition: wiz.cpp:154
void SetSpinControlValue(const wxString &name, int value)
Definition: wiz.cpp:1264
Abstract base class for compilers.
Definition: compiler.h:274
bool IsCheckListboxItemChecked(const wxString &name, unsigned int item)
Definition: wiz.cpp:1195
void CopyFiles(cbProject *theproject, const wxString &prjdir, const wxString &srcdir)
Definition: wiz.cpp:791
int GetFileTargetIndex()
Definition: wiz.cpp:1611
wxString & Append(const char *psz)
wxString GetCompilerFromCombobox(const wxString &name)
Definition: wiz.cpp:1031
bool IsEmpty() const
~Wiz()
Definition: wiz.cpp:69
void CheckCheckListboxItem(const wxString &name, unsigned int item, bool check)
Definition: wiz.cpp:1207
void Clear()
wxString GetPath(int flags=wxPATH_GET_VOLUME, wxPathFormat format=wxPATH_NATIVE) const
virtual const wxString & GetCompilerID() const
Read the target&#39;s compiler.
void RegisterWizard()
Definition: wiz.cpp:1722
DLLIMPORT wxString GetEOLStr(int eolMode=-1)
Reads settings if eolMode is -1 Expected input (defined in sdk/wxscintilla/include/wx/wxscintilla.h) is: wxSCI_EOL_CRLF=0, wxSCI_EOL_CR=1, or wxSCI_EOL_LF=2.
Definition: globals.cpp:812
bool IsRelative(wxPathFormat format=wxPATH_NATIVE) const
wxString GetDebugObjectOutputDir()
Definition: wiz.cpp:1520
wxString GetTargetObjectOutputDir() const
Definition: wizpage.cpp:676
wxString GetFullName() const
int GetValue() const
void SetComboboxValue(const wxString &name, const wxString &value)
Definition: wiz.cpp:1007
virtual const wxString & GetName() const
Get the compiler&#39;s name.
Definition: compiler.h:293
bool GetFileAddToProject()
Definition: wiz.cpp:1604
void DebugLog(const wxString &msg, Logger::level lv=Logger::info)
Definition: logmanager.h:146
template adds a new target in a project
Definition: globals.h:148
virtual int GetHeight() const
void AddPage(const wxString &panelName)
Definition: wiz.cpp:1373
wxWizard * m_pWizard
Definition: wiz.h:180
Wizards m_Wizards
Definition: wiz.h:179
int FillContainerWithChoices(const wxString &name, const wxString &choices)
Definition: wiz.cpp:1654
wxString GetProjectPath()
Definition: wiz.cpp:1462
wxString GetListboxStringSelections(const wxString &name)
Definition: wiz.cpp:1121
size_t Add(const wxString &str, size_t copies=1)
void SetCompilerDefault(const wxString &defCompilerID)
Definition: wiz.cpp:1624
bool Unload(const wxString &filename)
template is a user-saved project template
Definition: globals.h:151
void SetTitle(const wxString &title) override
Changes project title.
Definition: cbproject.cpp:1650
Represents a Code::Blocks project build target.
static size_t GetCompilersCount()
void Clear()
Definition: wiz.cpp:195
size_t GetCount() const
template outputs a new project
Definition: globals.h:147
int Find(wxUniChar ch, bool fromEnd=false) const
void CheckCheckbox(const wxString &name, bool check)
Definition: wiz.cpp:1218
wxString FindTemplateFile(const wxString &filename)
Definition: wiz.cpp:859
static wxXmlResource * Get()
int AppendContainerWithChoices(const wxString &name, const wxString &choices)
Definition: wiz.cpp:1679
wxString GetCategory(int index) const
Definition: wiz.cpp:171
DLLIMPORT bool CreateDirRecursively(const wxString &full_path, int perms=0755)
Definition: globals.cpp:610
wxString GetCompilerID() const
Definition: wizpage.cpp:524
ProjectBuildTarget * AddBuildTarget(const wxString &targetName)
Add a new build target.
Definition: cbproject.cpp:1150
ScriptingManager * GetScriptingManager() const
Definition: manager.cpp:469
wxString GetCompilerID()
Definition: wiz.cpp:1490
Data folder in base dir.
Definition: configmanager.h:81
wxString GetFullFileName() const
Definition: wizpage.cpp:355
bool FileExists() const
void AddBuildTarget(const wxString &targetName)
Make this file belong to an additional build target.
Definition: projectfile.cpp:78
#define wxRESIZE_BORDER
CompileTargetBase * RunCustomWizard(wxString *pFilename)
Definition: wiz.cpp:703
void AddBuildTargetPage(const wxString &targetName, bool isDebug, bool showCompiler=false, const wxString &compilerID=wxEmptyString, const wxString &validCompilerIDs=_T("*"), bool allowCompilerChange=true)
Definition: wiz.cpp:1339
void SetFilePathSelectionFilter(const wxString &filter)
Definition: wiz.cpp:1618
wxString m_ReleaseName
Definition: wiz.h:196
int Printf(const wxString &pszFormat,...)
void AddGenericSelectPathPage(const wxString &pageId, const wxString &descr, const wxString &label, const wxString &defValue)
Definition: wiz.cpp:1363
void SetRadioboxSelection(const wxString &name, int sel)
Definition: wiz.cpp:1076
wxString GetDebugObjectOutputDir() const
Definition: wizpage.cpp:551
bool GetAddToProject() const
Definition: wizpage.h:87
bool Save()
Save the project.
Definition: cbproject.cpp:482
wxString m_WizardScriptFolder
Definition: wiz.h:199
wxString GetFullPath(wxPathFormat format=wxPATH_NATIVE) const
wxImage & Resize(const wxSize &size, const wxPoint &pos, int red=-1, int green=-1, int blue=-1)
WizFilePathPanel * m_pWizFilePathPanel
Definition: wiz.h:183
bool LoadBuffer(const wxString &buffer, const wxString &debugName=_T("CommandLine"))
Loads a string buffer.
wxString script
Definition: wiz.h:29
int AddFileToProject(const wxString &filename, cbProject *project=nullptr, int target=-1)
Add a file to a project.
#define NULL
Definition: prefix.cpp:59
virtual wxWizardPage * GetCurrentPage() const
virtual void SetValue(bool state)
wxString m_LastXRC
Definition: wiz.h:187
Code::Blocks error handling unit.
Definition: cbexception.h:23
virtual int GetSelection() const
wxString GetProjectTitle()
Definition: wiz.cpp:1483
wxString cat
Definition: wiz.h:28
static wxString Format(const wxString &format,...)
wxString GetReleaseName() const
Definition: wizpage.cpp:563
virtual unsigned int GetCount() const
wxString GetTitle() const
Definition: wizpage.cpp:361
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 AddCompilerPage(const wxString &compilerID, const wxString &validCompilerIDs, bool allowCompilerChange=true, bool allowConfigChange=true)
Definition: wiz.cpp:1325
int GetTargetIndex() const
Definition: wizpage.cpp:288
wxString GetDebugOutputDir() const
Definition: wizpage.cpp:545
void SetTextControlValue(const wxString &name, const wxString &value)
Definition: wiz.cpp:1241
Base class for build target classes Each Code::Blocks project consists of at least one target...