47 #include <wx/arrimpl.cpp> 60 m_pWizProjectPathPanel(
nullptr),
63 m_pWizBuildTargetPanel(
nullptr),
79 if (!SquirrelVM::GetVMPtr())
93 wxString script = templatePath +
_T(
"/config.script");
99 SqPlus::SquirrelFunction<void> f(
"RegisterWizards");
102 catch (SquirrelError& e)
111 script = templatePath + _T(
"/config.script");
117 SqPlus::SquirrelFunction<void> f(
"RegisterWizards");
120 catch (SquirrelError& e)
168 return _(
"A generic scripted wizard");
203 #if wxABI_VERSION > 20601 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");
231 !
Manager::Get()->GetProjectManager()->GetActiveProject())
259 if (!
Manager::Get()->GetScriptingManager()->LoadScript(global_commons) &&
260 !
Manager::Get()->GetScriptingManager()->LoadScript(user_commons))
264 InfoWindow::Display(
_(
"Error"),
_(
"Failed to load the common functions script.\nPlease check the debug log for details..."));
273 if (!
Manager::Get()->GetScriptingManager()->LoadScript(script))
277 InfoWindow::Display(
_(
"Error"),
_(
"Failed to load the wizard's script.\nPlease check the debug log for details..."));
290 SqPlus::SquirrelFunction<void> f(
"BeginWizard");
293 catch (SquirrelError& e)
318 cbMessageBox(
_(
"This wizard is missing the following mandatory wizard page:\n\n" 319 "Project path selection\n" 355 wxString prjdir = fname.
GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
424 SqPlus::SquirrelFunction<wxString&> f(
"GetFilesDir");
425 if (!f.func.IsNull())
432 for (
size_t i = 0; i < tmpsrcdirs.
GetCount(); ++i)
433 CopyFiles(theproject, prjdir, tmpsrcdirs[i]);
436 catch (SquirrelError& e)
446 SqPlus::SquirrelFunction<wxString&> f(
"GetGeneratedFile");
447 if (!f.func.IsNull())
455 wxString fileAndContents = f(idx++);
465 contents.
Add(tmpContents);
473 targetIndices.Add(x);
479 for (
size_t i = 0; i < count; ++i)
504 catch (SquirrelError& e)
518 SqPlus::SquirrelFunction<bool> f(
"SetupProject");
528 catch (SquirrelError& e)
551 bool isDebug =
false;
565 SqPlus::SquirrelFunction<wxString&> f(
"GetTargetName");
574 catch (SquirrelError& e)
605 cbMessageBox(
_(
"No compiler had been specified. The new target will use the default compiler."),
606 _(
"Fallback compiler selected"),
612 cbMessageBox(
_(
"No compiler had been specified. The new target will use the same compiler as the project."),
613 _(
"Fallback compiler selected"),
659 SqPlus::SquirrelFunction<bool> f(
"SetupTarget");
660 if (!f(target, isDebug))
667 catch (SquirrelError& e)
681 SqPlus::SquirrelFunction<wxString&> f(
"CreateFiles");
689 *pFilename = filename;
692 static_cast<cbEditor*>(editor)->SetEditorStyle();
695 catch (SquirrelError& e)
707 SqPlus::SquirrelFunction<bool> f(
"SetupCustom");
711 catch (SquirrelError& e)
747 for (
size_t i=0; i<Dirs.Count(); i++ )
749 if ( Dirs[i] ==
_T(
"..") )
751 if ( IntDirCount-- == 0 )
760 else if ( Dirs[i] !=
_T(
".") )
764 fname = basePath + wxFILE_SEP_PATH + fname.
GetFullPath();
770 _T(
"The wizard is about to OVERWRITE the following existing file:\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.)"));
809 targetIndices.Add(x);
815 for (
unsigned int i = 0; i < filesList.
GetCount(); ++i)
821 dstfile.
Replace(basepath, prjdir);
825 wxString dstdir = fname.
GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
835 _T(
"The wizard is about to OVERWRITE the following existing file:\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.)"));
845 if (do_copy)
wxCopyFile(srcfile, dstfile,
true);
879 if (win && win->GetCount() == 0)
885 win->Append(compiler->
GetName());
889 win->SetSelection(win->FindString(compiler->
GetName()));
900 if (win && win->GetCount() == 0)
925 for (
size_t n = 0; n < valids.
GetCount(); ++n)
930 win->Append(compiler->
GetName());
938 win->SetSelection(win->FindString(compiler->
GetName()));
955 size_t iItemsCount = win->GetCount();
957 for(
size_t i = 0; i < iItemsCount; ++i )
959 nameInItems += win->GetString(i) +
_T(
";");
969 for (
size_t n = 0; n < valids.
GetCount(); ++n)
974 win->Append( compilerName );
975 nameInItems += compilerName +
_T(
";");
990 wxWindow* win = page->FindWindowByName(name, page);
1003 win->SetSelection(sel);
1014 win->SetValue(value);
1025 return win->GetValue();
1036 return compiler->
GetID();
1047 return win->GetStringSelection();
1059 return win->GetSelection();
1094 return win->GetSelection();
1111 lbox->GetSelections(selections);
1112 for (i = 0; i < selections.GetCount(); ++i)
1132 lbox->GetSelections(selections);
1133 for (i = 0; i < selections.GetCount(); ++i)
1134 result.
Append(lbox->GetString(selections[i]) +
_T(
";"));
1149 win->SetSelection(sel);
1163 for (i = 0; i < clb->
GetCount(); ++i)
1184 for (i = 0; i < clb->
GetCount(); ++i)
1214 clb->
Check(item, check);
1248 win->SetValue(value);
1259 return win->GetValue();
1385 for (
size_t i = 1; i <
m_Pages.GetCount(); ++i)
1389 for (
size_t i = 0; i <
m_Pages.GetCount(); ++i)
1405 for (
size_t i = 0; i <
m_Wizards.GetCount(); ++i)
1667 unsigned int nItems = items.
GetCount();
1668 for (
unsigned int i = 0; i < nItems; i++ )
1670 win->Append( items[i] );
1691 size_t iItemsCount = win->GetCount();
1693 for(
size_t i = 0; i < iItemsCount; ++i )
1695 nameInItems += win->GetString(i) +
_T(
";");
1697 unsigned int nItems = items.
GetCount();
1698 for (
unsigned int i = 0; i < nItems; i++ )
1703 win->Append( tItemsName );
1704 nameInItems += tItemsName +
_T(
";");
1724 SqPlus::SQClassDef<Wiz>(
"Wiz").
1818 SqPlus::BindVariable(
this,
"Wizard", SqPlus::VAR_ACCESS_READ_ONLY);
wxTreeItemId GetProjectNode()
wxString m_DebugObjOutputDir
ProjectFile * GetFileByFilename(const wxString &filename, bool isRelative=true, bool isUnixFilename=false)
Access a file of the project.
wxString F(const wxChar *msg,...)
sprintf-like function
DLLIMPORT wxArrayString GetArrayFromString(const wxString &text, const wxString &separator=DEFAULT_ARRAY_SEP, bool trimSpaces=true)
static void Display(const wxString &title, const wxString &message, unsigned int delay=5000, unsigned int hysteresis=1)
wxString GetDescription(int index) const
wxString GetTargetOutputDir()
wxString GetComboboxValue(const wxString &name)
DECLARE_INSTANCE_TYPE(Wiz)
static wxString GetFolder(SearchDirs dir)
Access one of Code::Blocks' 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)
wxWizardPageSimple & Chain(wxWizardPageSimple *next)
Data folder in user's dir.
wxString GetTargetObjectOutputDir()
wxString GetWizardScriptFolder(void)
CompileTargetBase * RunFilesWizard(wxString *pFilename)
wxString GetProjectName()
virtual void SetObjectOutput(const wxString &dirname)
Set the target's objects output dir.
wxString GetScriptFilename(int index) const
void SetDebugTargetDefaults(bool wantDebug, const wxString &debugName, const wxString &debugOut, const wxString &debugObjOut)
void SetFilePathSelectionFilter(const wxString &filter)
wxString m_ReleaseObjOutputDir
int GetRadioboxSelection(const wxString &name)
virtual void RebuildTree()=0
Rebuild the project manager's tree.
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
void AddGenericSingleChoiceListPage(const wxString &pageName, const wxString &descr, const wxString &choices, int defChoice)
wxString GetDebugOutputDir()
void SetReleaseTargetDefaults(bool wantRelease, const wxString &releaseName, const wxString &releaseOut, const wxString &releaseObjOut)
wxString m_DebugOutputDir
virtual bool RunWizard(wxWizardPage *firstPage)
void FillContainerWithCompilers(const wxString &name, const wxString &compilerID, const wxString &validCompilerIDs)
virtual wxString GetString(unsigned int n) const
wxString GetTargetName() const
WizCompilerPanel * m_pWizCompilerPanel
wxString m_ReleaseOutputDir
DLLIMPORT wxBitmap cbLoadBitmap(const wxString &filename, wxBitmapType bitmapType=wxBITMAP_TYPE_PNG)
This function loads a bitmap from disk.
TemplateOutputType output_type
virtual FilesList & GetFilesList()
Provides an easy way to iterate all the files belonging in this target.
bool wxFileExists(const wxString &filename)
void LogWarning(const wxString &msg, int i=app_log)
static Compiler * GetDefaultCompiler()
wxString GetReleaseObjectOutputDir() const
int GetListboxSelection(const wxString &name)
wxString GetCompilerID() const
CompileTargetBase * RunTargetWizard(wxString *pFilename)
wxString GetFilename() const
wxString GetProjectFullFilename()
bool wxDirExists(const wxString &dirname)
static Compiler * GetCompiler(size_t index)
bool GetWantRelease() const
TemplateOutputType GetWizardType()
FileType
Known file types.
static const wxString & GetDefaultCompilerID()
void AddProjectPathPage()
void OnAttach()
Any descendent plugin should override this virtual method and perform any necessary initialization...
void SetComboboxSelection(const wxString &name, int sel)
wxString GetListboxSelections(const wxString &name)
virtual wxImage ConvertToImage() const
const wxBitmap & GetBitmap(int index) const
void EndAddFiles()
Notify that file(s) addition finished.
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)
DLLIMPORT FileType FileTypeOf(const wxString &filename)
#define wxICON_INFORMATION
wxString GetCheckListboxStringChecked(const wxString &name)
virtual wxSizer * GetPageAreaSizer() const
wxString GetTargetOutputDir() const
bool IsChecked(unsigned int item) const
static size_t GetAllFiles(const wxString &dirname, wxArrayString *files, const wxString &filespec=wxEmptyString, int flags=wxDIR_DEFAULT)
wxString AfterFirst(wxUniChar ch) const
wxString GetReleaseOutputDir() const
Represents a file in a Code::Blocks project.
bool GetWantDebug() const
void BeginAddFiles()
Notify that file(s) will be added shortly.
virtual void SetCompilerID(const wxString &id)
! Set the flag if the host app should be run in terminal
wxString GetCheckListboxChecked(const wxString &name)
EditorManager * GetEditorManager() const
template produces custom output (entirely up to the wizard used)
void EnableWindow(const wxString &name, bool enable)
int GetSpinControlValue(const wxString &name)
bool IsCheckboxChecked(const wxString &name)
wxString GetDebugName() const
const wxArrayString & GetDirs() const
wxString BeforeFirst(wxUniChar ch, wxString *rest=NULL) const
virtual void SetSelection(int n)
void AddFilePathPage(bool showHeaderGuard)
ProjectManager * GetProjectManager() const
Functions returning pointers to the respective sub-manager instances.
const wxString & GetID() const
Get this compiler's unique ID.
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
Represents a Code::Blocks project.
template outputs a new file (or files)
CompileTargetBase * Launch(int index, wxString *pFilename=0)
When this is called, the wizard must get to work ;).
cbProject * NewProject(const wxString &filename=wxEmptyString)
Create a new empty project.
virtual const wxString & GetFilename() const
wxString GetReleaseName()
void FillComboboxWithCompilers(const wxString &name)
void AddWizard(TemplateOutputType otype, const wxString &title, const wxString &cat, const wxString &script, const wxString &templatePNG, const wxString &wizardPNG, const wxString &xrc)
bool GetTargetEnableDebug()
wxString GenerateFile(const wxString &basePath, const wxString &filename, const wxString &contents)
bool GetEnableDebug() const
void FillContainerWithSelectCompilers(const wxString &name, const wxString &validCompilerIDs)
virtual int GetWidth() const
void AddInfoPage(const wxString &pageId, const wxString &intro_msg)
int GetComboboxSelection(const wxString &name)
wxString GetReleaseObjectOutputDir()
size_t Replace(const wxString &strOld, const wxString &strNew, bool replaceAll=true)
void Check(unsigned int item, bool check=true)
void AppendContainerWithSelectCompilers(const wxString &name, const wxString &validCompilerIDs)
const wxPoint wxDefaultPosition
static void SetDefaultCompiler(size_t index)
virtual cbTreeCtrl * GetTree()=0
Retrieve a pointer to the project manager's tree (GUI).
Base class that all "editors" should inherit from.
LogManager * GetLogManager() const
cbProject * GetActiveProject()
Retrieve the active project.
bool wxCopyFile(const wxString &file1, const wxString &file2, bool overwrite=true)
virtual wxString GetBasePath() const
Read the target's base path, e.g. if GetFilename() returns "/usr/local/bin/xxx", base path will retur...
void SetListboxSelection(const wxString &name, int sel)
WizBuildTargetPanel * m_pWizBuildTargetPanel
WizProjectPathPanel * m_pWizProjectPathPanel
void DisplayErrors(SquirrelError *exception=nullptr, bool clearErrors=true)
Display error dialog.
wxString GetComboboxStringSelection(const wxString &name)
virtual void SetWorkingDir(const wxString &dirname)
Set the target'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.
virtual bool IsBuiltinEditor() const
Is this a built-in editor?
TemplateOutputType GetOutputType(int index) const
WX_DEFINE_OBJARRAY(Wizards)
virtual void SetValue(const wxString &text)
virtual bool SkipPage() const
const wxString & _(const wxString &string)
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.
int GetBuildTargetsCount()
Plugin registration object.
wxString GetReleaseOutputDir()
TemplateOutputType
Template output types.
static bool CompilerInheritsFrom(const wxString &id, const wxString &from_id)
wxString GetTargetCompilerID()
void FillCompilerControl(wxItemContainer *control, const wxString &compilerID, const wxString &validCompilerIDs)
wxArray< int > wxArrayInt
virtual void Expand(const wxTreeItemId &item)
wxString GetTitle(int index) const
void SetSpinControlValue(const wxString &name, int value)
Abstract base class for compilers.
bool IsCheckListboxItemChecked(const wxString &name, unsigned int item)
void CopyFiles(cbProject *theproject, const wxString &prjdir, const wxString &srcdir)
wxString & Append(const char *psz)
wxString GetCompilerFromCombobox(const wxString &name)
void CheckCheckListboxItem(const wxString &name, unsigned int item, bool check)
wxString GetPath(int flags=wxPATH_GET_VOLUME, wxPathFormat format=wxPATH_NATIVE) const
virtual const wxString & GetCompilerID() const
Read the target's compiler.
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.
bool IsRelative(wxPathFormat format=wxPATH_NATIVE) const
wxString GetDebugObjectOutputDir()
wxString GetTargetObjectOutputDir() const
wxString GetFullName() const
void SetComboboxValue(const wxString &name, const wxString &value)
virtual const wxString & GetName() const
Get the compiler's name.
bool GetFileAddToProject()
void DebugLog(const wxString &msg, Logger::level lv=Logger::info)
template adds a new target in a project
virtual int GetHeight() const
void AddPage(const wxString &panelName)
int FillContainerWithChoices(const wxString &name, const wxString &choices)
wxString GetProjectPath()
wxString GetListboxStringSelections(const wxString &name)
size_t Add(const wxString &str, size_t copies=1)
void SetCompilerDefault(const wxString &defCompilerID)
bool Unload(const wxString &filename)
template is a user-saved project template
void SetTitle(const wxString &title) override
Changes project title.
Represents a Code::Blocks project build target.
static size_t GetCompilersCount()
template outputs a new project
int Find(wxUniChar ch, bool fromEnd=false) const
void CheckCheckbox(const wxString &name, bool check)
wxString FindTemplateFile(const wxString &filename)
static wxXmlResource * Get()
int AppendContainerWithChoices(const wxString &name, const wxString &choices)
wxString GetCategory(int index) const
DLLIMPORT bool CreateDirRecursively(const wxString &full_path, int perms=0755)
wxString GetCompilerID() const
ProjectBuildTarget * AddBuildTarget(const wxString &targetName)
Add a new build target.
ScriptingManager * GetScriptingManager() const
wxString GetFullFileName() const
void AddBuildTarget(const wxString &targetName)
Make this file belong to an additional build target.
CompileTargetBase * RunCustomWizard(wxString *pFilename)
void AddBuildTargetPage(const wxString &targetName, bool isDebug, bool showCompiler=false, const wxString &compilerID=wxEmptyString, const wxString &validCompilerIDs=_T("*"), bool allowCompilerChange=true)
void SetFilePathSelectionFilter(const wxString &filter)
int Printf(const wxString &pszFormat,...)
void AddGenericSelectPathPage(const wxString &pageId, const wxString &descr, const wxString &label, const wxString &defValue)
void SetRadioboxSelection(const wxString &name, int sel)
wxString GetDebugObjectOutputDir() const
bool GetAddToProject() const
bool Save()
Save the project.
wxString m_WizardScriptFolder
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
bool LoadBuffer(const wxString &buffer, const wxString &debugName=_T("CommandLine"))
Loads a string buffer.
int AddFileToProject(const wxString &filename, cbProject *project=nullptr, int target=-1)
Add a file to a project.
virtual wxWizardPage * GetCurrentPage() const
virtual void SetValue(bool state)
Code::Blocks error handling unit.
virtual int GetSelection() const
wxString GetProjectTitle()
static wxString Format(const wxString &format,...)
wxString GetReleaseName() const
virtual unsigned int GetCount() const
wxString GetTitle() const
DLLIMPORT int cbMessageBox(const wxString &message, const wxString &caption=wxEmptyString, int style=wxOK, wxWindow *parent=NULL, int x=-1, int y=-1)
wxMessageBox wrapper.
void AddCompilerPage(const wxString &compilerID, const wxString &validCompilerIDs, bool allowCompilerChange=true, bool allowConfigChange=true)
int GetTargetIndex() const
wxString GetDebugOutputDir() const
void SetTextControlValue(const wxString &name, const wxString &value)
Base class for build target classes Each Code::Blocks project consists of at least one target...