Maybe ScriptedWizard Plugin can add some functions such as ....I found some
useful funtions in scriptedwizard plugin after I readed the source code of emIDE (
http://www.emide.org/ ) last week.
In codeblocks\src\plugins\scriptedwizard\
wiz.cpp and wiz.hint Wiz::AddListboxChoices(const wxString& choices)
{
wxWizardPage* page = m_pWizard->GetCurrentPage();
if (page)
{
wxListBox* win = dynamic_cast<wxListBox*>(page->FindWindowByName(_("GenericChoiceList"), page));
if (win)
{
win->Clear();
win->InsertItems(GetArrayFromString(choices, _T(";")), 0);
return 0;
}
}
return -1;
}
It is similar tovoid Wiz::FillComboboxWithCompilers(const wxString& name)
{
wxWizardPage* page = m_pWizard->GetCurrentPage();
if (page)
{
wxComboBox* win = dynamic_cast<wxComboBox*>(page->FindWindowByName(name, page));
if (win && win->GetCount() == 0)
{
for (size_t i = 0; i < CompilerFactory::GetCompilersCount(); ++i)
{
Compiler* compiler = CompilerFactory::GetCompiler(i);
if (compiler)
win->Append(compiler->GetName());
}
Compiler* compiler = CompilerFactory::GetDefaultCompiler();
if (compiler)
win->SetSelection(win->FindString(compiler->GetName()));
}
}
}
void Wiz::AddGenericSingleChoiceListPage(const wxString& pageName, const wxString& descr, const wxString& choices, int defChoice)
{
// we don't track this; can add more than one
WizPageBase* page = new WizGenericSingleChoiceList(pageName, descr, GetArrayFromString(choices, _T(";")), defChoice, m_pWizard, m_Wizards[m_LaunchIndex].wizardPNG);
if (!page->SkipPage())
m_Pages.Add(page);
else
delete page;
}
I try to add some
new functions as follow
void Wiz::FillComboListboxWithSelCompilers( const wxString& name, const wxString& validCompilerIDs )
{
wxWizardPage* page = m_pWizard->GetCurrentPage();
if (page)
{
wxControlWithItems* win = dynamic_cast<wxControlWithItems*>( 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::AppendComboListboxWithSelCompilers( const wxString& name, const wxString& validCompilerIDs )
{
wxWizardPage* page = m_pWizard->GetCurrentPage();
if (page)
{
wxControlWithItems* win = dynamic_cast<wxControlWithItems*>( 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;
}
}
}
}
}
}
}
int Wiz::FillComboListboxWithChoices( const wxString& name, const wxString& choices )
{
wxWizardPage* page = m_pWizard->GetCurrentPage();
if (page)
{
wxControlWithItems* win = dynamic_cast<wxControlWithItems*>( 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::AppendComboListboxWithChoices( const wxString& name, const wxString& choices )
{
wxWizardPage* page = m_pWizard->GetCurrentPage();
if (page)
{
wxControlWithItems* win = dynamic_cast<wxControlWithItems*>( 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;
}
Then Add those to
Wiz::RegisterWizard() func(&Wiz::FillComboListboxWithSelCompilers, "FillComboListboxWithSelCompilers").
func(&Wiz::AppendComboListboxWithSelCompilers, "AppendComboListboxWithSelCompilers").
func(&Wiz::FillComboListboxWithChoices, "FillComboListboxWithChoices").
func(&Wiz::AppendComboListboxWithChoices, "AppendComboListboxWithChoices").
Now you can use that in your wizard.script.
Such as:
function BeginWizard()
{
.
.
// Generic device selection
Wizard.AddGenericSingleChoiceListPage(_T("DeviceSelection"), _T("Please select your device."), _T(""), deviceId);
.
.
}
function OnEnter_DeviceSelection(fwd)
{
Wizard.FillComboListboxWithChoices( _T(""), deviceNames );
}
You don't put all data or resource into xrc file. You can select another data source such as xml file.
You can change the data in running ScriptedWizard to new Project as you needing.
That let you have a bigger space to customize you Project wizard.