New editors consist of an application directory installed within
Format of an Editor
An Editor is an application (a directory starting with an exclamation mark - '!') containing at least three files:
- !Run - (Obey)
- !RunImage - (BASIC)
- !Sprites - (Sprite)
This file is run when WimpWorks is started and should be used to inform WimpWorks how much memory this editor takes up. The amount will depend on the number of variables, size of code etc. An example file is:
| !Run file for !ButtonBar, a WWv2 Editor | © Jaffa Software 1997. All rights reserved. Set WimpWorks$ButtonBar$Dir <Obey$Dir> IconSprites <WimpWorks$ButtonBar$Dir>.!Sprites If "<WimpWorks$Dir>"<>"" Then Run <WimpWorks$Dir>.Resources.AddSlot -plus 4K
This is the main file which contains subroutines called by the main WimpWorks editor, the subroutines are described below (for an editor called !ButtonBar):
- FNbuttonbar = "..." - This FN is the leafname of the editor's directory (with the ! stripped) and should return the prefix for the following functions. In this example it returned "button"
- FNbutton_menu = "..." - Returns the string to use in the "Editors" menu.
- FNbutton_init = 0 - Called exactly once when WimpWorks is started should load any templates necessary etc.
- FNbutton_modified = (TRUE | FALSE) - Called to determine if the project has been modified. Should return TRUE if the editor has unsaved changes, or FALSE otherwise.
- FNbutton_exit = (TRUE | FALSE) - Called when the user wishes to quit WimpWorks. Should return TRUE if it is allowed or FALSE if not.
- FNbutton_clear = 0 - Called when the current project is being cleared, all project dependant data should be removed and any windows reset to their initial state.
- FNbutton_load(file$) = 0 - Called when a new project is being loaded. file$ contains the complete path of the new project.
- FNbuton_event(num%, eva$, evb$, evc$) = 0 - Called
when an event within WimpWorks has occured.
- num% is the event number
- eva$, evb$, evc$ are the strings passed to
PROCjaffa_event or FNjaffa_event. The decode strings for
the internal events can be found in
- FNbutton_save(file%) = 0 - Called when the project is being saved. file% contains the handle of the project's "WWv2Data" file being saved.
- FNbutton_basic_init(file%) = 0 - Called when the project is being saved and the BASIC file produced before it is linked with the main WimpWorks library. file% contains the file handle. Any code saved here (which should be detokenised BASIC) will be called exactly once when the application is started and should perform as little as possible, ie. call a procedure which is saved in the following function.
- FNbutton_basic_save(file%) = 0 - Called after the above function and should be where the majority of BASIC code is defined. The above function did not need any subroutine headers defined, however the output of this function goes straight into the raw file.
In all the above functions
curApp$ contains the full
filename of the current project, and
curEdit% contains the
current editor number, ie. yours. Your current editor number is also your
item number within
editMenu% (the "Editors" menu).
WWv2Version% contains the version of WimpWorks * 100 (eg.
220) in versions 2.20 and above.
There is also a stub routine which can be REDEFINEd to point to your own parser, note the original should still be called otherwise the internal commands will not be updated.
DEF FN__parser(line$, temp$) ' line$ - The actual line being parsed, this should not be processed, ' but any operations on temp$ should be mirrored on ' this exactly the same way. ' temp$ - Contains the line being parsed with all the text ' between any "s replaced with spaces. This string ' should be used to search for text in. =FNoldPrser(temp$,line$)
This file is technically optional, however should be included as then your editor will look attractive within a directory display.