home *** CD-ROM | disk | FTP | other *** search
- <html>
- <h1>Example programs</h1>
-
- I have found through experience that by far the best way to
- learn how to use someone else's library is to look at the
- example programs supplied and copy them. I have supplied
- a set of 5 example programs which you should examine. They
- are not very functional (apart from the program you are using
- now: !HyperView), but show how to use some of the major features
- of the library.
- <p>
- Please feel free to use and copy the programs, and incorporate
- the structure of them into your own efforts. They are
- probably not bug free (none of my software is), but they
- seem to work OK.
-
- <p>
-
- <h2>!HyperView</h2>
-
- This is the application you are currently running. It is an HTML
- viewer application which is not particularly well written and
- is not very functional. When run, an icon appears on the
- icon bar. You can drag text files to this icon in order to
- display them in a window. If the file starts with the HTML
- tag <html> then it is displayed in a proportional outline
- font and formatted. Otherwise, it will be assumed to be
- preformatted text <pre> and will be displayed in the
- system font and not formatted.
- <p>
- The program has a few major problems, not least of which is that
- is seems to leak memory like the proverbial sieve. The main
- use of the program is to do what you are doing now - read
- the Vista user manual. I may improve it in future, but I hope
- it suits its purpose for the time being.
-
- <p>
- <h2>!Dbox</h2>
-
- This application shows how to use the DialogueBox class in Vista.
- If you look at the source file Vista:h.wins, you will see that
- the DialogueBox class is derived from both the Window and
- Thread classes. This is multiple inheritance and is very
- powerful. It means that the DialogueBox behaves like
- both a Window (ie it displays a window on the screen) and a
- Thread (ie it runs independently).
- <p>
- The fact that the DialogueBox is a thread allows the main program
- to sleep until it has terminated - a very powerful construct.
- <p>
- The example also shows how to use the various tools supplied with
- Vista in the file Vista:h.tools.
-
- <p>
- <h2>!MyApps</h2>
-
- This small application shows how to use the IconGrid class.
- This class is derived from the Window class and behaves like
- a Filer directory viewer. The application places an
- icon on the left side of the iconbar which, when clicked,
- displays a directory viewer. The idea is that you can
- drag directories, applications and files into this window
- and it will hold them in one accessible place until needed.
- <p>
- By double-clicking on one of the items in a window the
- application will do something with it. What it does depends
- on what it is. If you double-click an application, it will
- be run; a directory will be opened and a file will generate
- an error. The file should really broadcast a DataOpen message
- but that is left as an exercise (no I can't be bothered doing
- it at present).
- <p>
- This sounds useful, but I haven't supplied a Save option (another
- exercise?).
- <p>
-
- <p>
- <h2>!SaveEx</h2>
-
- This application simply shows how to use the SaveAs class. It displays
- a window with a FontObject object in it. By clicking menu on the
- window you are presented with a single option 'Save'. Drag the
- icon to a directory viewer to save a text file. Exciting eh?
-
- <p>
- <h2>!Threads</h2>
-
- This application is probably quite a useful utility in its own right.
- Clicking on the needle and thread icon gives you a window which
- displays lots of details about the mouse. Click a few more
- times and more windows appear displaying exactly the same thing.
- <p>
- This sounds easy, but if you look at the source code you will see that
- each window consists of a forever loop which reads the mouse
- position and performs some calculations. The program shows the
- power of the Multi-threading aspects of Vista. All of the
- forever loops run at the same time and are pre-empted
- by Vista when Wimp_Poll is needed.
- <p>
- This, in my opinion, makes the programs much easier to write
- as there is no need to have complex state machines prompted by
- event reception. Just write your program as you think about it
- and Vista will take care of the OS aspects.
- <p>
- <p>
- I hope that these programs are useful.
- <p>
- <p>
- <h3>Dave Allison</h3>.
-