home *** CD-ROM | disk | FTP | other *** search
- Guide for writing Special icons for Megaboard
- ---------------------------------------------
- ----------------
- - Introduction -
- ----------------
- This file explains how to create new special icons for Megaboard, it will
- only be of interest to programmers, other users should refer to the "Guide"
- file for information on general use.
- For a step-by-step tutorial on creating a special icon see the ProgTutrl
- file.
-
- ------------------
- - Relevant files -
- ------------------
- The files within Megaboard's application directory used by special icons are
- the script file named "Cstm_Scrpt" and the files contained in the "Special"
- subdirectory.
-
- ----------------------
- - Creating new icons -
- ----------------------
- Creating a new icon consists of two steps, writing the icon's definition in
- the script file and writing a set of ARM code entry points needed to maintain
- the icon.
-
- Icon definition commands
- ------------------------
- The script file consists of the following commands (Not case sensitive):
- * Start_Icon
- * Name:
- * Author:
- * Width:
- * Height:
- * Worksize:
- * Update:
- * Mouse_State:
- * KeyPress_State:
- * Message_State:
- Start_Parameters
- <Parameter name>:<default value>
- ...
- <Parameter name>:<default value>
- End_Parameters
- * End_Icon
- The Commands marked with an asterisk are mandatory and must be present in
- every icon definition.
-
- Writing an icon definition
- --------------------------
- An Icon definition always begins with the command Start_Icon, which may be
- preceded by any number of spaces, but otherwise must be the only item on the
- line.
- Start_Icon is followed on subsequent lines by a list of commands terminated
- by the End_Icon command.
-
- Syntax of script commands
- -------------------------
- All commands except Start_Icon, End_Icon, Start_Parameters and
- End_Parameters have the following syntax:
- |<Spaces>|<Command>:|<Spaces>|<Value>
- Where items contained in || are optional.
- Example use:
-
- Width: 100
- ^^^^^ ^
- ⇧ ⇧
- Leading Spaces
- Spaces separating
- are command
- ignored and
- value
- are
- also
- ignored
- The command above sets the special icon's width to 100 OS units.
- The following commands, however, have the same effect:
- Width:100
- Width: 100
- Width:100
-
-
- Command descriptions
- --------------------
- Now for a detailed description of script commands:
-
- Name:
- -----
- The Name command sets the name of the icon as contained in the 'Special icon'
- submenu and in the Function names (described later), it must therefore comply
- with Basic V variable name restrictions.
- Note: Although the command is not case sensitive in this case the value is.
- Example:
- Name: Pointer
-
- Author:
- -------
- You!
- This Command sets the name of the icon's author to be displayed in the Info
- Box for the icon.
- Example:
- Author: Fred Bloggs
-
- Version:
- --------
- Sets the version number of the icon as displayed in the 'Info' box including the
- date, if required.
- Example:
- Version: 1.00 (19 Aug 1994)
-
- Width:
- ------
- Sets the width of the icon in OS units. The value must be a decimal integer.
- Example:
- Width: 100
-
- Height:
- -------
- Sets the height of the icon in OS units. The value must be a decimal integer.
- Example:
- Height: 100
-
- Worksize:
- ---------
- Sets the amount of workspace the icon requires in bytes. The value must be a
- decimal integer.
- Example:
- Worksize: 100
-
- Update:
- -------
- Defines how often the icon requires updating, the value must be one of the
- following words:
-
- Continuous
- Second
- Minute
- Hour
- Day
- Never
-
- A value of Continuous means the icon needs updating as often as possible.
- Pointer is an example of such an icon.
- A value of Second, Minute, Hour or Day mean the icon needs updating every
- Second, Minute, Hour or Day (what else!).
- Never means the icon's contents do not change with time and therefore it does
- not require updating. It is, however, updated whenever it receives a message,
- keypress or mouseclick.
-
- Message_State:
- --------------
- Defines whether or not Wimp messages should be reported to the icon, the
- value must be either "On" or "Off".
-
- Mouse_State:
- --------------
- Defines whether or not mouse clicks should be reported to the icon, the
- value must be either "On" or "Off".
-
- Keypress_State:
- --------------
- Defines whether or not Keypresses should be reported to the icon, the
- value must be either "On" or "Off".
-
- Menu_State:
- --------------
- Defines whether or not the icon has a menu associated with it, the value must
- be either "On" or "Off".
-
- Start_Parameters
- ----------------
- Start_Parameters initiates the definition of parameters. It is followed by
- a list of parameter descriptions terminated by the Command "End_Parameters".
- Example:
- Start Parameters
-
- A parameter description has the following format:
- |<Spaces>|<Name>:|<Spaces>|<default>
-
- Where <name> is the name of the parameter (as displayed in the icons's
- submenu and <default> is its default value. As is initially displayed in
- the writeable parameter submenu item.
- Example:
- Pathname: adfs::4.$.Fred
-
- Megaboard currently has a limit of 16 parameters per icon this will
- (hopefully) be altered in a later version.
-
- End_Parameters
- --------------
- End_Parameters terminates a list of parameters.
-
- Example of a parameter list:
- Start_Parameters
- Pathname: adfs::4.$.Fred
- Size: 1024
- End_Parameters
-
- End_Icon
- --------
- End_icon terminates an icon definition
- Example:
- End_Icon
-
- -------------------------
- - ARM code entry points -
- -------------------------
- A Megaboard special icon requires a file containing several blocks of ARM
- code function correctly. The file must have the following format:
-
- Size of the first code block (including this word) (1 word)
- First code block (n words (must be a whol number of words))
-
- Size of the second code block (1 word)
- Second code block (n words (must be a whol number of words))
-
- ...
-
- Size of the last code block (1 word)
- Last code block (n words (must be a whol number of words))
-
- The following code blocks are required:
- initialise
- null
- redraw
- finish
- save
- load
- message
- mouse
- key
- menu
- menu_select
- menu_warning
- All of these blocks must be present in every entry points file regardless of
- whether a particular icon responds to all messages.
- Entry points are called using the BASIC CALL and USR commands i.e. R13 points
- to a stack and MOV PC,R14 Areturns.
- Entry point code must be position independent.
- The entry points file should be named "Code" and placed in the directory
- "!MegaBoard.Special.<icon name>". Where <icon name> is the name specified in
- the definition. Any other files the icon reqiures should also be stored in
- this directory.
-
- Technical details of the entry points
- -------------------------------------
-
- INITIALISE
- ----------
- On entry:
-
- R0 - The X screen coordinate of the centre of the icon.
- R1 - The Y screen coordinate of the centre of the icon.
- R2 - The width of the icon.
- R3 - The height of the icon.
- R4 - A pointer to the icon's workspace.
- R5 - A pointer to a list of parameters
- R5+0 - first parameter string
- R5+256 - second parameter string
- ...
- R5+n*256 - last parameter string
-
- On exit:
-
- A% - New X screen coordinate
- B% - New Y screen coordinate
- C% - New icon width
- D% - New icon height
-
- Purpose:
-
- Initialise is called when the icon is first placed on MegaBoard i.e. when the
- user clicks on it's menu item. It should do any setting up the icon requires
- in order for redraw to be called and store any parameters.
-
- Note: the BASIC variables A%-D% are altered from assembler with the
- following code (with A% as an example):
-
- ADR R11,variable ;R11 points to the variable name
- STMFD R13!,{R14} ;presverve R14 on the stack
- MOV R10,R14
- ADR R14,done ;point R14 to the address BASIC's variable
- locator should return to.
- ADD PC,R10,#&3C ;call BASIC's variable locator
-
- .done ;R0 now points to the variable's value
- LDR R1,newvalue
- STR R1,[R0]
-
- .variable EQUS A%+CHR$(10):ALIGN
- .newvalue EQUD new_value%
-
-
-
-
- NULL
- ----
- On entry:
-
- R0 - The X screen coordinate of the centre of the icon.
- R1 - The Y screen coordinate of the centre of the icon.
- R2 - The width of the icon.
- R3 - The height of the icon.
- R4 - A pointer to the icon's workspace.
-
- On exit:
-
- A% - New X screen coordinate
- B% - New Y screen coordinate
- C% - New icon width
- D% - New icon height
-
- Purpose:
-
- Null is called if the icon's script file entry has not set its update state
- to "Never". Megaboard attempts to call it at the interval specified by the
- update state, this is, however not guaranteed.
-
-
- REDRAW
- ------
- On entry:
-
- R0 - The X screen coordinate of the centre of the icon.
- R1 - The Y screen coordinate of the centre of the icon.
- R2 - The width of the icon.
- R3 - The height of the icon.
- R4 - A pointer to the icon's workspace.
-
- On exit:
-
- ---
-
- Purpose:
-
- Redraw is called whenever the icon on the screen requires updating, e.g. when
- all or part of it is uncovered by a moved window, and immediately after ALL
- other entry points except finish and those relating to menus. It should draw
- the icon at the screen coordinates in R0,R1.
-
- Note: Some restrictions apply within this entry point:
- - It is possible that screen output is redirected to a sprite when
- redraw is called. If this is the case then OS_ReadModeVariable will
- not return the correct values for the current mode, but for the
- sprite.
- - In order for the icon to be redrawn at the correct position redraw
- is sometimes called with the graphics origin not at (0,0) most
- RISC OS calls that output to the screen acknowledge this and modify
- their output acordingly, Font_Paint, however, does not. Icons that
- use outline fonts should read the graphics origin (it will still be
- read correctly if output is redirected) and add it to the coordinates
- passed to Font_Paint.
- - Redraw should NEVER alter the icon's appearance. It is very likely
- that redraw will be called several times for a single redraw
- operation, if a call altered the icon's appearance then the section
- plotted by the next call to redraw will not match the plotted by the
- first.
-
- FINISH
- ------
- On entry:
-
- R0 - The X screen coordinate of the centre of the icon.
- R1 - The Y screen coordinate of the centre of the icon.
- R2 - The width of the icon.
- R3 - The height of the icon.
- R4 - A pointer to the icon's workspace.
-
- On exit:
-
- ---
-
- Purpose:
-
- Finish is called when the icon is removed from MegaBoard. It should free up
- any resources claimed by other entry points, e.g. release RMA blocks and
- dynamic areas, close open files etc.
-
- SAVE
- ----
- On entry:
-
- R0 - The X screen coordinate of the centre of the icon.
- R1 - The Y screen coordinate of the centre of the icon.
- R2 - The width of the icon.
- R3 - The height of the icon.
- R4 - A pointer to the icon's workspace.
- R5 - Handle of the save file
-
- On exit:
-
- R0 - Number of saved parameters
-
- Purpose:
-
- Save is called when the user saves MegaBoard's current state to disc. If the
- icon has not altered it's state since initialisation this entry point should
- simply return with R0=0. Otherwise it should save a set of parameter strings
- it requires to reconstruct its current state in the save file. The format of
- these strings is:
-
- [<spaces>]<n>:[<spaces>]<string><newline>
-
- Where n is a number between 1 and the number returned in R5 (inclusive). The
- precise number of parameters returned in R5 must also be saved to the file
- and each must be uniquely numbered, however, they need not be stored in
- order.
- These parameters should not be confused with the icon's parameters specified
- in the icon's definition, although the strings may be the same.
- The number of saved parameters is not limited.
-
- LOAD
- ----
- On entry:
-
- R0 - The X screen coordinate of the centre of the icon.
- R1 - The Y screen coordinate of the centre of the icon.
- R2 - The width of the icon.
- R3 - The height of the icon.
- R4 - A pointer to the icon's workspace.
- R5 - Number of the saved parameter (-1 if there were none)
- R6 - Pointer to the string (without the header)
-
- On exit:
-
- A% - New X screen coordinate
- B% - New Y screen coordinate
- C% - New icon width
- D% - New icon height
-
- Purpose:
-
- Load is called once for each saved parameter when the user loads a new state
- from disc or once only if no parameters were saved. When a new state is
- loaded the special icons' initialise entry points are not called, therefore
- load must perform any initialisation necessary.
- The parameters passed to load are in the order of their numbers, as stored by
- save not in the order in which they were saved. Therefore the last call will
- contain the highest number in R5.
-
-
- MESSAGE
- -------
- On entry:
-
- R0 - The X screen coordinate of the centre of the icon.
- R1 - The Y screen coordinate of the centre of the icon.
- R2 - The width of the icon.
- R3 - The height of the icon.
- R4 - A pointer to the icon's workspace.
- R5 - A pointer to the message block
-
- On exit:
-
- A% - New X screen coordinate
- B% - New Y screen coordinate
- C% - New icon width
- D% - New icon height
-
- Purpose:
-
- Message is called if the icon's message state is set to "on" in it's
- definition and a file is dragged to the icon (i.e. Megaboard receices a
- DataLoad Message). R5 points to a standard message block as described in the
- PRM.
- Note: At the moment MegaBoard only passes DataLoad Messages on to special
- icons, this may however change in future versions, this entry point
- should therefore first check whether the message is really a DataLoad.
-
- MOUSE
- -----
- On entry:
-
- R0 - The X screen coordinate of the centre of the icon.
- R1 - The Y screen coordinate of the centre of the icon.
- R2 - The width of the icon.
- R3 - The height of the icon.
- R4 - A pointer to the icon's workspace.
- R5 - Button state
-
- On exit:
-
- A% - New X screen coordinate
- B% - New Y screen coordinate
- C% - New icon width
- D% - New icon height
-
- Purpose:
-
- Mouse is called if the icon's mouse state is set to "on" in it's definition
- and the user clicks either Select or Adjust on the icon.
-
-
- KEY
- ---
- On entry:
-
- R0 - The X screen coordinate of the centre of the icon.
- R1 - The Y screen coordinate of the centre of the icon.
- R2 - The width of the icon.
- R3 - The height of the icon.
- R5 - Wimp Key code
-
- On exit:
-
- A% - New X screen coordinate
- B% - New Y screen coordinate
- C% - New icon width
- D% - New icon height
-
- Purpose:
-
- Key is called if the icon's key state is set to "on" in it's definition and
- the user presses a key not processed by other tasks.
-
- MENU
- ----
- On entry:
-
- R0 - The X screen coordinate of the centre of the icon.
- R1 - The Y screen coordinate of the centre of the icon.
- R2 - The width of the icon.
- R3 - The height of the icon.
- R4 - A pointer to the icon's workspace.
- R5 - X coordinate at which the menu should be opened.
- R6 - Y coordinate at which the menu should be opened.
-
- On exit:
-
- ---
-
- Purpose:
-
- This entry point is called if the icon's menu state is set to "on" in it's
- definition and the user moves the pointer over the "Special menu" arrow in
- the "Special" submenu. It should set up a menu block and open the menu with
- Wimp_CreateSubMenu (NOT Wimp_CreateMenu) at the coordinates specified in R5
- and R6.
-
-
-
-
- MENU SELECT
- -----------
- On entry:
-
- R0 - The X screen coordinate of the centre of the icon.
- R1 - The Y screen coordinate of the centre of the icon.
- R2 - The width of the icon.
- R3 - The height of the icon.
- R4 - Pointer to the icon's workspace.
- R5 - Pointer to a block
- R5+0 - Item in the icon's base menu that was selected
- R5+4 - Item in the first submenu that was selected
- ...
- terminated by -1
-
- On exit:
-
- ---
-
- Purpose:
-
- Menu select is called if the icon's menu state is set to "on" in it's
- definition and the user chooses an item from one of its menu.
-
-
-
-
-
-
- MENU WARNING
- ------------
- On entry:
-
- R0 - The X screen coordinate of the centre of the icon.
- R1 - The Y screen coordinate of the centre of the icon.
- R2 - The width of the icon.
- R3 - The height of the icon.
- R4 - Pointer to the icon's workspace.
- R5 - X coordinate where the submenu should be opened
- R6 - Y coordinate where the submenu should be opened
- R7 - Pointer to a block
- R7+0 - Item in the icon's base menu that was selected
- R7+4 - Item in the first submenu that was selected
- ...
- terminated by -1
-
- On exit:
-
- ---
-
- Purpose:
-
- Menu warning is called if the icon's menu state is set to "on" in it's
- definition and MegaBoard receives a Menu_Warning message from the Wimp that
- is applicable to the icon's menu the user chooses an item from one of its
- menu.
-
-
-