Difference between revisions of "Talk:Wizard scripts"
From Code::Blocks
Line 1: | Line 1: | ||
=> '''add into 'How do I create a new wizard?'''' | => '''add into 'How do I create a new wizard?'''' | ||
+ | The first thing to know is that each wizard script contains | ||
− | + | - global variables : | |
+ | :example | ||
− | + | <code>ObjectName <- _T("name")</code> | |
+ | <code>ObjectIndex <- 0</code> | ||
− | |||
+ | - and basic primitive functions : | ||
− | |||
− | *''' | + | *'''Common and mandatory for all types of project :''' |
− | + | which contains different entry pages, see [[Wizard Scripting Commands#Adding wizard pages|Adding wizard pages ]] | |
− | |||
+ | <code>void BeginWizard ()</code> | ||
− | |||
− | *''' | + | * '''For a project :''' |
− | |||
+ | **to get the template files in a project | ||
− | + | <code>wxString GetFilesDir ()</code> | |
− | * | + | **to get generated files in a project |
− | |||
+ | <code>wxString GetGeneratedFile(index)</code>''' | ||
− | + | **to create project | |
+ | <code>bool SetupProject (project)</code> | ||
− | |||
− | |||
+ | *'''For a single target (within a project)''' | ||
− | + | <code>bool SetupTarget (target, IsDebug)</code> | |
− | |||
− | |||
+ | *'''For file creation''' | ||
− | + | <code>wxString CreateFiles ()</code> | |
− | |||
− | |||
+ | *'''For an item to be defined by the user''' | ||
+ | <code>bool SetupCustom ()</code> | ||
− | These functions will be performed by the manager wizard. | + | |
+ | :These functions will be performed by the manager wizard. | ||
+ | |||
+ | |||
+ | Then you should do is read about [[Wizard Scripting Commands|Wizard Scripting Commands ]] and use it as a reference on what commands are accepted and what their syntax is. | ||
+ | |||
+ | |||
+ | Here is a simple example taken from the distribution wizard.script 12.11 | ||
+ | |||
+ | //////////////////////////////////////////////////////////////////////////////// | ||
+ | // | ||
+ | // Code::Blocks new file wizard script | ||
+ | // | ||
+ | // Project: Empty file | ||
+ | // Author: Yiannis Mandravellos | ||
+ | // | ||
+ | //////////////////////////////////////////////////////////////////////////////// | ||
+ | function BeginWizard() | ||
+ | { | ||
+ | local info_msg = _T("Welcome to the new empty file wizard!\n" + | ||
+ | "This wizard will guide you to create a new empty file.\n\n" + | ||
+ | "When you 're ready to proceed, please click \"Next\"..."); | ||
+ | // add builtin pages | ||
+ | Wizard.AddInfoPage(_T("EmptyFileIntro"), info_msg); // intro | ||
+ | Wizard.AddFilePathPage(false); // select filename (no header guard for source files) | ||
+ | } | ||
+ | function CreateFiles() | ||
+ | { | ||
+ | local fname = Wizard.GetFileName(); | ||
+ | local ed = GetEditorManager(); | ||
+ | if (IsNull(ed)) | ||
+ | { | ||
+ | ShowError(_T("The wizard could not locate the editor manager.")); | ||
+ | } | ||
+ | local ed_new = ed.New(fname); | ||
+ | if (IsNull(ed_new)) | ||
+ | { | ||
+ | ShowError(_T("The wizard could not create a new file.\n" + | ||
+ | "Maybe the target folder is write-protected?")); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | // succeeded -> add file to project if needed | ||
+ | if (Wizard.GetFileAddToProject()) | ||
+ | { | ||
+ | AddFileToTargets(Wizard, fname); | ||
+ | } | ||
+ | } | ||
+ | return fname; | ||
+ | } |
Latest revision as of 22:32, 11 February 2013
=> add into 'How do I create a new wizard?'
The first thing to know is that each wizard script contains
- global variables :
- example
ObjectName <- _T("name")
ObjectIndex <- 0
- and basic primitive functions :
- Common and mandatory for all types of project :
which contains different entry pages, see Adding wizard pages
void BeginWizard ()
- For a project :
- to get the template files in a project
wxString GetFilesDir ()
- to get generated files in a project
wxString GetGeneratedFile(index)
- to create project
bool SetupProject (project)
- For a single target (within a project)
bool SetupTarget (target, IsDebug)
- For file creation
wxString CreateFiles ()
- For an item to be defined by the user
bool SetupCustom ()
- These functions will be performed by the manager wizard.
Then you should do is read about Wizard Scripting Commands and use it as a reference on what commands are accepted and what their syntax is.
Here is a simple example taken from the distribution wizard.script 12.11
//////////////////////////////////////////////////////////////////////////////// // // Code::Blocks new file wizard script // // Project: Empty file // Author: Yiannis Mandravellos // //////////////////////////////////////////////////////////////////////////////// function BeginWizard() { local info_msg = _T("Welcome to the new empty file wizard!\n" + "This wizard will guide you to create a new empty file.\n\n" + "When you 're ready to proceed, please click \"Next\"..."); // add builtin pages Wizard.AddInfoPage(_T("EmptyFileIntro"), info_msg); // intro Wizard.AddFilePathPage(false); // select filename (no header guard for source files) } function CreateFiles() { local fname = Wizard.GetFileName(); local ed = GetEditorManager(); if (IsNull(ed)) { ShowError(_T("The wizard could not locate the editor manager.")); } local ed_new = ed.New(fname); if (IsNull(ed_new)) { ShowError(_T("The wizard could not create a new file.\n" + "Maybe the target folder is write-protected?")); } else { // succeeded -> add file to project if needed if (Wizard.GetFileAddToProject()) { AddFileToTargets(Wizard, fname); } } return fname; }