Hello,
II try to change the project creation wizard for "Avr Project" by adding a third page of choice additional libraries.
This setting uses a widget "wxCheckListBox" named "lib_addons" with fields: libA, libB, libC, libD.
I changed it to "wizard.xrc" and "wizard.script"
A-Modifications "wizard.xrc"
see *.zip
B-Modifications "wizard.script"
1 - global variables
/// ------------------------------
/// LETARTARE for wxCheckListBox
LibNumbers <- _T ("");
LibString <- _T ("");
/// <----------------------------
2 - in "BeginWizard function ()"
/// ---------------------------------------------------------------------
/// For testing LETARTARE "wiz::GetListboxStringSelections (wxString &)"
/// Page "libraryChoice" contents "wxCheckListBox"
Wizard.AddPage (_T ("libraryChoice")) /// inside "wizard.xrc"
/// <-------------------------------------------------------------------
3 - I created the following function to display the values retrieved
/// ----------------------------------------------- ---------------------
/// LETARTARE : lib_addons
/// functions available for "wxCheckListBox"
/// int GetListboxSelection(const wxString& name); // with ONLY ONE SELECTION !!!
/// wxString GetListboxSelections(const wxString& name);
/// wxString GetListboxStringSelections(const wxString& name);
/// void SetListboxSelection(const wxString& name, int sel);
function OnLeave_libraryChoice (fwd)
{
if (fwd)
{
LibNumbers = Wizard.GetListboxSelections (_T ("lib_addons"));
/// Console output for test scripting
::print (_T ("->") + LibNumbers + _T ("<-"));
if (LibNumbers.IsEmpty ()) {
::print (_T ("No selected library"));
}
else {
LibString = Wizard.GetListboxStringSelections (_T ("lib_addons"));
::print (_T ("lib_addons = ") + LibString);
}
}
return true;
}
/// <-------------------------------------------------------------------
Disregard of space errors in quotations !!
4 - Results:
creation is correct but:
- The variable LibNumbers is always equal to 0 !
- Variable LibString is always empty!
I can not find my mistake?
Cordially.
@jens
after some computer troubles...
I tested the functions :
wxString GetCheckListboxChecked (const wxString& name)
and
wxString GetCheckListboxStringChecked(const wxString& name)
Both give the desired result.
LibNumbers ->0;2;4;6;<-
Lib_addOns ->lib_A;lib_C;lib_E;lib_G;<-
But I will now check the four functions in more depth.
And continue editing the wizard.
A big thank you first (especially extremely quickly !)
@jens
All methods work correctly on my system.
Soon, I will provide a 'wizard.script' example.
To save with 'Config Manager', I would need:
void SetCheckListboxChecked(const wxString& name, wxString listname);
/// LETARTARE
void Wiz::SetCheckListboxChecked(const wxString& name, wxString listname )
{
wxWizardPage* page = m_pWizard->GetCurrentPage();
if (page)
{
wxCheckListBox* clb = dynamic_cast<wxCheckListBox*>(page->FindWindowByName(name, page));
if (clb && !listname.IsEmpty())
{
/// clear checked
unsigned int i;
for (i = 0; i < clb->GetCount() ; i++ )
clb->Check(i, false) ;
/// format listname "1;4;7;"
char sep = ';';
unsigned long pos;
/// checked
while (!listname.IsEmpty()) {
listname.BeforeFirst(sep).ToULong(&pos);
clb->Check(pos, true) ;
listname = listname.AfterFirst(sep) ;
}
}
}
}
is that correct ?