Back to Contents        Previous        Next









15. Icon sprites & more on the iconbar icon **

‘Sprite-only’ icons
If you have an icon which has been defined as a ‘sprite-only’ icon (such as the file icon in a save window) then you can change it to another sprite by using PROCwimp_puticontext i.e. the same wimp-function that changes text in an indirected text icon. This will only work however, if the sprite-only icon is indirected and of sufficient indirected length, both of which are set up using a template editor.

For example, in the tutorial !RunImage from the previous Section, insert the following line just before ENDPROC in PROCuser_initialise:

PROCwimp_puticontext(save%,0,“file_ffd”)

(If you are using the “nicesave” template, the second parameter should be 3, not 0.)

Save the !RunImage, re-run !MyApp and bring up the ‘save box’ from item 5 of the main menu. The file icon in the save window will now be the standard one for Data.


[The tutorial !RunImage listing RI_08 is not updated to reflect the above trivial change - but keep the whole of the !MyApp application as it now stands somewhere safe, ready to be used again briefly in Section 2.22. A copy exists in the Tutor1 folder for your convenience.
When the tutorial is picked up again in the next section - Section 2.16 - a fresh !MyApp will be started.]



The iconbar icon
This also is a good place to revisit:

FNwimp_iconbar(spritename$,text$,maxlen%,position%)

which we introduced briefly very early on in this tutorial - in Section 2.1. You will recall that we have so far set text$ to a null string and maxlen% to 0 - and the resulting iconbar icon has always been a ‘sprite-only’ icon i.e. with no text beneath it.

By using other values for the second and third parameters, we can create an iconbar icon with text underneath the sprite and also arrange for this text to be indirected - with a maximum length determined by maxlen% - so that we can change it during the program run if we wish e.g. change the iconbar text (see a little later) to “Loaded” when file data has been dragged to it and loaded.

Firstly, it is vital to remember that the value you set in maxlen% will only come into effect if text$ is not set to a null string. (In fact, a null string triggers the action in the DrWimp library to create a ‘sprite-only’ result.)

If you want a ‘sprite-plus-text’ iconbar icon then a typical FNwimp_iconbar call might be:

iconbar%=FNwimp_iconbar(“!myapp”,“MyApp”,5,1)

and the result on the iconbar will be ...............
Picture Pics/pic007.png

Here, the second parameter contained text which is 5 characters long and we matched this in the value of the third parameter. (Dr Wimp automatically adds one for the terminator character.) The text is centred on the sprite.

If the value set in maxlen% is less than the length of text set in text$, then maxlen% will automatically be increased to the length of text$. Further, if the value set in maxlen% is greater than the length of text set in text$, then the iconbar text space created will be sufficient to display text of this greater length i.e. ready for you to change the text up to this greater length later in the program.

Finally, if you do not want the initial iconbar icon to show any text but you want to add some later, then simply use something like:

iconbar%=FNwimp_iconbar(“!myapp”,“ ”,5,1)

Note that the second parameter is not a null string but, rather, is a string with a space character in it. The result will be an iconbar icon with (centred) space beneath it for up to 5 characters (plus terminator) for you to use later in the program.

Once the iconbar icon has been suitably created, as above, its text and its sprite can be altered with PROCwimp_puticonbartext and PROCwimp_iconbarsprite respectively.

(!Animate in the Example applications folder shows how the iconbar sprite can be changed within a program run, by using PROCwimp_iconbarsprite.)


Finally, a couple of pieces of practical advice:

- try not to use an iconbar text length which extends much beyond the width of the sprite used, otherwise the result looks somewhat ungainly on the iconbar.
- If your text consists of all wide characters (e.g. “W”) then it is possible that the displayed result on the iconbar might be clipped slightly at each end. If this occurs just increase maxlen% until the display is right.


(Note on iconbar position: Dr Wimp currently only provides a simple choice for positioning the icon on the iconbar i.e. ‘right’ or ‘left’ and you will see that your icon is added as the ‘leftmost’ or ‘rightmost’, respectively, with this choice. The Wimp allows the iconbar icon to be placed more precisely than this. It is not difficult to achieve but the rules are too variable to arrange a useful generalised formula suitable for Dr Wimp. However, should any user be interested in more precise iconbar placement in a specific case, please contact the Dr Wimp author who will be very happy to assist further - see start of Manual for contact address.)







Top of page        Back to Contents        Previous        Next