Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Proposed patch to ScriptedWizard with Extensions by YWX
Pecan:
This is a patch to implement the ScripedWizard extension by YWX
He added:
Wiz::FillContainerWithSelCompilers()
Wiz::AppendContainerWithSelCompilers()
Wiz::FillContainerWithChoices()
Wiz::AppendContainerWithChoices()
Wiz::GetWizardScriptFolder()
This patch has been tested on both Windows (10) and Linux (Mint) by pecan
using the ArmNoneEabiWizard plugin at
https://github.com/ywx/cbArmNoneEabiWizard/releases
--- Code: ---Index: src/plugins/scriptedwizard/resources/manifest.xml
===================================================================
--- src/plugins/scriptedwizard/resources/manifest.xml (revision 11053)
+++ src/plugins/scriptedwizard/resources/manifest.xml (working copy)
@@ -3,12 +3,17 @@
<SdkVersion major="1" minor="10" release="0" />
<Plugin name="ScriptedWizard">
<Value title="Scripted wizard" />
- <Value version="0.9" />
- <Value description="A generic scripted wizard" />
+ <Value version="1.1" />
+ <Value description="An extended generic scripted wizard
+Add Wiz::FillContainerWithSelCompilers()
+ Wiz::AppendContainerWithSelCompilers()
+ Wiz::FillContainerWithChoices()
+ Wiz::AppendContainerWithChoices()
+ Wiz::GetWizardScriptFolder()" />
<Value author="Yiannis An. Mandravellos" />
<Value authorEmail="info@codeblocks.org" />
<Value authorWebsite="http://www.codeblocks.org" />
- <Value thanksTo="" />
+ <Value thanksTo="YWX for extended additions." />
<Value license="GPL" />
</Plugin>
</CodeBlocks_plugin_manifest_file>
Index: src/plugins/scriptedwizard/wiz.cpp
===================================================================
--- src/plugins/scriptedwizard/wiz.cpp (revision 11053)
+++ src/plugins/scriptedwizard/wiz.cpp (working copy)
@@ -277,6 +277,8 @@
InfoWindow::Display(_("Error"), _("Failed to load the wizard's script.\nPlease check the debug log for details..."));
return nullptr;
}
+ m_WizardScriptFolder = script.BeforeLast( _T('/') );
+ m_WizardScriptFolder = m_WizardScriptFolder.AfterLast( _T('/') );
// call BeginWizard()
try
@@ -680,7 +682,7 @@
{
const wxString &filename = files.BeforeFirst(_T(';'));
if (pFilename)
- *pFilename = filename;
+ *pFilename = files.BeforeFirst(_T(';'));
EditorBase *editor = Manager::Get()->GetEditorManager()->GetEditor(filename);
if (editor && editor->IsBuiltinEditor())
static_cast<cbEditor*>(editor)->SetEditorStyle();
@@ -898,6 +900,78 @@
}
}
+void Wiz::FillContainerWithSelCompilers( const wxString& name, const wxString& validCompilerIDs )
+{
+ wxWizardPage* page = m_pWizard->GetCurrentPage();
+ if (page)
+ {
+ wxItemContainer* win = dynamic_cast<wxItemContainer*>( page->FindWindowByName( name.IsEmpty() ? _T("GenericChoiceList") : name , page ) );
+ if (win)
+ {
+ wxArrayString valids = GetArrayFromString(validCompilerIDs, _T(";"), true);
+ win->Clear();
+ for (size_t i = 0; i < CompilerFactory::GetCompilersCount(); ++i)
+ {
+ Compiler* compiler = CompilerFactory::GetCompiler(i);
+ if (compiler)
+ {
+ for (size_t n = 0; n < valids.GetCount(); ++n)
+ {
+ // match not only if IDs match, but if ID inherits from it too
+ if (CompilerFactory::CompilerInheritsFrom(compiler, valids[n]))
+ {
+ win->Append(compiler->GetName());
+ break;
+ }
+ }
+ }
+ }
+ Compiler* compiler = CompilerFactory::GetDefaultCompiler();
+ if (compiler)
+ win->SetSelection(win->FindString(compiler->GetName()));
+ }
+ }
+}
+
+void Wiz::AppendContainerWithSelCompilers( const wxString& name, const wxString& validCompilerIDs )
+{
+ wxWizardPage* page = m_pWizard->GetCurrentPage();
+ if (page)
+ {
+ wxItemContainer* win = dynamic_cast<wxItemContainer*>( page->FindWindowByName( name.IsEmpty() ? _T("GenericChoiceList") : name , page ) );
+ if (win)
+ {
+ wxArrayString valids = GetArrayFromString(validCompilerIDs, _T(";"), true);
+ size_t iItemsCount = win->GetCount();
+ wxString nameInItems = _T(";");
+ for( size_t i = 0; i < iItemsCount; ++i )
+ {
+ nameInItems += win->GetString(i) + _T(";");
+ }
+ for (size_t i = 0; i < CompilerFactory::GetCompilersCount(); ++i)
+ {
+ Compiler* compiler = CompilerFactory::GetCompiler(i);
+ if (compiler)
+ {
+ wxString compilerName = compiler->GetName();
+ if( wxNOT_FOUND != nameInItems.Find( _T(";") + compilerName + _T(";") ) )
+ continue;
+ for (size_t n = 0; n < valids.GetCount(); ++n)
+ {
+ // match not only if IDs match, but if ID inherits from it too
+ if (CompilerFactory::CompilerInheritsFrom(compiler, valids[n]))
+ {
+ win->Append( compilerName );
+ nameInItems += compilerName + _T(";");
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
void Wiz::EnableWindow(const wxString& name, bool enable)
{
wxWizardPage* page = m_pWizard->GetCurrentPage();
@@ -1567,6 +1641,66 @@
m_ReleaseObjOutputDir = releaseObjOut;
}
+
+int Wiz::FillContainerWithChoices( const wxString& name, const wxString& choices )
+{
+ wxWizardPage* page = m_pWizard->GetCurrentPage();
+ if (page)
+ {
+ wxItemContainer* win = dynamic_cast<wxItemContainer*>( page->FindWindowByName( name.IsEmpty() ? _T("GenericChoiceList") : name , page ) );
+ if (win)
+ {
+ win->Clear();
+ wxArrayString items = GetArrayFromString( choices, _T(";") );
+ unsigned int nItems = items.GetCount();
+ for ( unsigned int i = 0; i < nItems; i++ )
+ {
+ win->Append( items[i] );
+ }
+
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int Wiz::AppendContainerWithChoices( const wxString& name, const wxString& choices )
+{
+ wxWizardPage* page = m_pWizard->GetCurrentPage();
+ if (page)
+ {
+ wxItemContainer* win = dynamic_cast<wxItemContainer*>( page->FindWindowByName( name.IsEmpty() ? _T("GenericChoiceList") : name , page ) );
+ if (win)
+ {
+ wxArrayString items = GetArrayFromString( choices, _T(";") );
+ size_t iItemsCount = win->GetCount();
+ wxString nameInItems = _T(";");
+ for( size_t i = 0; i < iItemsCount; ++i )
+ {
+ nameInItems += win->GetString(i) + _T(";");
+ }
+ unsigned int nItems = items.GetCount();
+ for ( unsigned int i = 0; i < nItems; i++ )
+ {
+ wxString tItemsName = items[i];
+ if( wxNOT_FOUND != nameInItems.Find( _T(";") + tItemsName + _T(";") ) )
+ continue;
+ win->Append( tItemsName );
+ nameInItems += tItemsName + _T(";");
+ }
+
+ return 0;
+ }
+ }
+ return -1;
+}
+
+wxString Wiz::GetWizardScriptFolder(void)
+{
+ return m_WizardScriptFolder;
+}
+
+
void Wiz::RegisterWizard()
{
SqPlus::SQClassDef<Wiz>("Wiz").
@@ -1646,8 +1780,15 @@
func(&Wiz::GetFileHeaderGuard, "GetFileHeaderGuard").
func(&Wiz::GetFileAddToProject, "GetFileAddToProject").
func(&Wiz::GetFileTargetIndex, "GetFileTargetIndex").
- func(&Wiz::SetFilePathSelectionFilter, "SetFilePathSelectionFilter");
+ func(&Wiz::SetFilePathSelectionFilter, "SetFilePathSelectionFilter").
+ // extender
+ func(&Wiz::FillContainerWithSelCompilers, "FillContainerWithSelCompilers").
+ func(&Wiz::AppendContainerWithSelCompilers, "AppendContainerWithSelCompilers").
+ func(&Wiz::FillContainerWithChoices, "FillContainerWithChoices").
+ func(&Wiz::AppendContainerWithChoices, "AppendContainerWithChoices").
+ func(&Wiz::GetWizardScriptFolder, "GetWizardScriptFolder");
+
SqPlus::BindVariable(this, "Wizard", SqPlus::VAR_ACCESS_READ_ONLY);
}
Index: src/plugins/scriptedwizard/wiz.h
===================================================================
--- src/plugins/scriptedwizard/wiz.h (revision 11053)
+++ src/plugins/scriptedwizard/wiz.h (working copy)
@@ -78,6 +78,8 @@
bool IsCheckboxChecked(const wxString& name);
void FillComboboxWithCompilers(const wxString& name);
+ void FillContainerWithSelCompilers( const wxString& name, const wxString& validCompilerIDs );
+ void AppendContainerWithSelCompilers( const wxString& name, const wxString& validCompilerIDs );
wxString GetCompilerFromCombobox(const wxString& name);
void FillContainerWithCompilers(const wxString& name, const wxString& compilerID,
const wxString& validCompilerIDs);
@@ -150,6 +152,11 @@
const wxString& releaseOut,
const wxString& releaseObjOut);
+ // extender
+ int FillContainerWithChoices( const wxString& name, const wxString& choices );
+ int AppendContainerWithChoices( const wxString& name, const wxString& choices );
+ wxString GetWizardScriptFolder(void);
+
// pre-defined pages
void AddInfoPage(const wxString& pageId, const wxString& intro_msg);
void AddFilePathPage(bool showHeaderGuard);
@@ -190,6 +197,8 @@
wxString m_ReleaseName;
wxString m_ReleaseOutputDir;
wxString m_ReleaseObjOutputDir;
+
+ wxString m_WizardScriptFolder;
private:
Wiz(cb_unused const Wiz& rhs); // prevent copy construction
};
Index: src/plugins/scriptedwizard/wizpage.h
===================================================================
--- src/plugins/scriptedwizard/wizpage.h (revision 11053)
+++ src/plugins/scriptedwizard/wizpage.h (working copy)
@@ -94,6 +94,7 @@
wxString m_Filename;
wxString m_HeaderGuard;
bool m_AddToProject;
+ int m_TargetIndex;
};
class WizProjectPathPanel : public WizPageBase
--- End code ---
oBFusCATed:
Some comments:
1. I'll remove the description field in the xml. I don't think it is appropriate or useful to users.
2. I'll remove any mention of "// extender" or similar
3. Can we replace Sel with something more meaningful in FillContainerWithSelCompilers and AppendContainerWithSelCompilers?
4. Can we have some documentation for the new methods? What are they doing? What parameters do they expect?
5. I would like const and const& added to as many places in the patch as possible.
6. The bracket spacing is not consistent with the rest of the code - too much spaces on both sides.
After 4 is resolved I suppose I'll make more comments :)
LETARTARE:
@Pecan
Thanks for this patch.
I install 'cbScriptedWizardPlugin' in 'cb-11021' (Vista business).
I have found differences between 'cbArmNoneEabiWizard' and original plugin CB.
Your current proposal can it be installed without problems ?
Do you have a new version ?
Have a good day.
Pecan:
oBFusCATed,
Do you actually mean "I'll remove...." or do you mean you'd prefer me to remove.... ?
--- Quote from: oBFusCATed on May 08, 2017, 12:32:53 am ---Some comments:
1. I'll remove the description field in the xml. I don't think it is appropriate or useful to users.
2. I'll remove any mention of "// extender" or similar
3. Can we replace Sel with something more meaningful in FillContainerWithSelCompilers and AppendContainerWithSelCompilers?
4. Can we have some documentation for the new methods? What are they doing? What parameters do they expect?
5. I would like const and const& added to as many places in the patch as possible.
6. The bracket spacing is not consistent with the rest of the code - too much spaces on both sides.
After 4 is resolved I suppose I'll make more comments :)
--- End quote ---
Pecan:
If you have already installed cbScriptedWizardPlugin, you will not need this patch.
This patch does not make any changes to cbArmNoneEabiWizard.
--- Quote from: LETARTARE on May 27, 2017, 11:59:15 am ---@Pecan
Thanks for this patch.
I install 'cbScriptedWizardPlugin' in 'cb-11021' (Vista business).
I have found differences between 'cbArmNoneEabiWizard' and original plugin CB.
Your current proposal can it be installed without problems ?
Do you have a new version ?
Have a good day.
--- End quote ---
Navigation
[0] Message Index
[#] Next page
Go to full version