home *** CD-ROM | disk | FTP | other *** search
-
- +------------------------------------------------------------+
- | This manual describes the function of the HASWIN |
- | library and explains how the library may be intergrated |
- | into a user application. It is hoped that the programmer |
- | will use the HASWIN interface as a whole since all the |
- | routines a programmer will ever require are built into the |
- | library, and not "mix-and-match" HASWIN routines with his |
- | own code and direct calls to WIMP and RISCOS SWIs. The |
- | manual expects the reader to have a good knowledge of the |
- | WIMP and RISCOS as it applies to graphics and the user |
- | environment. It is best to use the "RISC OS Programmers |
- | Reference Manual" (especially chapters on VDU Drivers, |
- | Sprites, Memory Management, and The Window Manager) in |
- | conjunction with this manual since the manual uses terms |
- | that are explained there. |
- +------------------------------------------------------------+
-
-
- The HASWIN window library.
- ===========================
- Copyright H.A. Shaw 1990.
- ===========================
-
- The HASWIN library provides a comprehsnsive set of routines
- designed to simplify the writing of complex WIMP based programs. The
- Archimedes WIMP, running under RISCOS requires some complex programming
- techniques in order to realise its full potential. The HASWIN routines
- simplify user programs by hiding all the complex data structures and
- programming required.
-
- HASWIN consists of one file at ANSI C source code level and an
- object code library file. The source file, an include file called haswin.h,
- provides all the routine and data structure definitions required, and
- includes any other files as needed. The Object code library file, haswin.o,
- contains the actual routines. Nearly all of these routines and data
- structures are given header definitions in the include file, but some data
- structures and routines in "haswin.o" are used internally by HASWIN and are
- therefore not defined. These routines will not be explained here. The
- Object code file was created using the following programs:
-
- Norcroft RISC OS ARM C vsn 3.00 [Jul 12 1989]
- (HASWIN has been sucessfully compiler using:
- "Norcroft ARM C (with debugger support) 2.01A Jul 14 1988")
- libfile: library file library tool
- objlib: object file library tool
-
- HASWIN provides and maintains the Archimedes screen by replacing the
- physical screen and WIMP system with its own routines. Programs should
- allow HASWIN to provide all access to the screen environment and should not
- call any of the Arthur, RISCOS or WIMP routines directly. The HASWIN
- routines generally follow the guidelines in the Application Notes for WIMP
- programmers on pages 1300-1330 of Volume III of the RISC OS Programmer's
- Reference Manual. Therefore a "standard" user interface is provided by all
- HASWIN programs that usually behaves exactly the way a user expects if he
- is used to using the Application programs provided by Acorn themselves. Any
- differences between the user interface provided by HASWIN applications and
- that of Acorn derived programs is usually due to HASWIN providing
- considerably more functions. HASWIN can therefore be considered as
- providing a superset of the user interface provided by the routines in the
- "RISC_OSLib" library supplied with Release III of the Acornsoft ANSI C
- compiler, and used by Acorn derived code written in C. The "RISC_OSLib"
- library does, however, cover the drawing of text within windows, copying
- the contents of windows, and dialogue boxes. HASWIN does not cover these
- issues since it is designed to provide the programmer only with windows,
- icons, menus, pointers and carets. What these things mean, or contain, is
- the concern of the programmer alone. HASWIN does, however, provide simple
- text and graphics overlays to a window with simple routines to allow user
- data to be put into a window and then automatically redrawn by HASWIN as the
- window scrolls and moves.
-
- To a programmer the screen appears to be made up of a number of
- data structures representing windows, icons, menus, carets and the mouse
- pointer. The user program tells the HASWIN library how these items are
- related and HASWIN deals with everything, only returning to the user
- program when its intervention is required. In order to do this HASWIN
- has to take some of the C identifier and pre-processor namespaces for its
- own use. Since the namespaces are very large this is not considered a
- problem. Of course it is the responsibility of the programmer to prevent
- namespace clashes with HASWIN. HASWIN uses the namespace as follows:
-
- 1) *ALL* identifiers starting with the string "haswin_" are
- reserved to the HASWIN library but may be used by the user
- programmer if they are defined in the library include file
- "haswin.h".
- 2) *ALL* identifiers starting with the string "graphics_" are
- reserved to the HASWIN library but may be used by the user
- programmer if they are defined in the library include file
- "haswin.h".
- 3) *ALL* #defined constants starting with the string "SPRITE_",
- and containing the string "AREA" anywhere within them are
- reserved to the HASWIN library but may be used (but not
- altered) by the user programmer if they are defined in the
- library include file "haswin.h".
- 4) *ALL* #defined constants starting with the strings "CARET_",
- "graphics_", "HASWIN_", "ICON_", "MESSAGE_", "POINTER_",
- "VDUVAR_", or "WINDOW_", are reserved to the HASWIN library
- but may be used by the user programmer (but not altered) if
- they are defined in the library include file "haswin.h".
- 5) The #defined constants in the list below are reserved by the
- HASWIN library, but may be used (but not altered) in user
- programs. They are defined in the library include file
- "haswin.h".
- ICONBAR_LEFT
- ICONBAR_RIGHT
- OS_Byte
- OS_Word
- OS_File
- OS_Args
- OS_GBPB
- OS_GetEnv
- OS_Heap
- OS_FSControl
- OS_Sprite_operation
- OS_ReadVduVariables
- OS_ReadMonotonicTime
- OS_Plot
- OS_Read_mem_map_info
- OS_Read_mem_map_entries
- OS_WriteI
- SWI_X
- TASK_MAXNAME
- 6) *ALL* identifiers starting with the string "_haswin_" are
- reserved to the HASWIN library and are for internal use only.
- The user program *MUST NOT* use them.
- 7) The "struct" identifiers in the list below are reserved by
- the HASWIN library, but may be used in user programs. They
- are defined in the library include file "haswin.h".
- buffer
- caret
- icon
- menu
- palette
- pointer
- text
- window
- 8) The "typedef" identifiers in the list below are reserved by
- the HASWIN library, but may be used in user programs. They
- are defined in the library include file "haswin.h".
- buffer
- caret
- icon
- menu
- palette
- pointer
- text
- window
- 9) The function identifiers in the list below are reserved by
- the HASWIN library, they may not be used in user programs.
- They are not defined in the library include file "haswin.h".
- asciilen()
- atoint()
- strqcpy()
- strnqcpy()
- filemousebutton()
-
- In fact HASWIN only uses the identifiers whose names appear in the
- list headed number 9 above and the library include file "haswin.h" as
- globals. The programmer may use any identifier not specifically defined in
- "haswin.h" or the list headed number 9 above but is warned that this can be
- dangerous and is certainly not going to allow the user program to be upward
- compatable to future releases of HASWIN.
-
- The HASWIN library is divided into groups of routines, each of which
- deals with one of the elements that form a Window Environment. Each of
- these groups has an information file associated with it. The groups (and
- information files) are as follows:
- carets, drawing, files, fonts, icons, the kernel, memory management,
- menus, palettes, pointers, polling, ram transfers, setting up,
- sprites, templates, text, windows.
-
-
- HASWIN programs benefit from some standardisation in the approch of
- the programmer to writing WIMP applications. In general terms a HASWIN
- program looks like the following...
-
-
- #include <haswin.h>
-
- /*
- * routines to deal with the various things that can happen in the WIMP
- * environment that HASWIN cannot deal with itself. A single routine can
- * deal with a particular event in as many windows, icons or menus as
- * required, but can only deal with one sort of event. User routines are
- * always passed enough information by HASWIN for them to work out which
- * window, icon or menu their event has occured in. The user can provide
- * routines to handle the following events:
- *
- * Routines to open windows.
- * Routines to draw windows,
- * Routines to drag windows,
- * Routines to handle mouse operations in windows,
- * Routines to drag icons,
- * Routines to handle mouse operations with icons,
- * Routines to create menu text strings.
- * Routines to take menu selections, as text strings, and process them
- * Routines to save user data into files.
- * Routines to load user data from files.
- * Routines to handle application launches using double-clicks on files of
- * specific filetypes.
- * Routines to save user data using direct RAM transfers.
- * Routines to load user data using direct RAM transfers.
- *
- * Finally the user can provide a single user poll routine that will be
- * called by HASWIN for all and any event, even if other routines exist to
- * handle it. The user poll routine must determine which events to ignore
- * itself.
- */
-
- main(int argc, char **argv) {
- /*
- * code to handle command line arguments
- */
-
- /*
- * code to initialise the required parts of HASWIN, the task itself,
- * file handling, direct RAM transfers, the user heap, error
- * handlers, etc.
- */
-
- /*
- * code to read in the program's resorces. Sprite files, template
- * files etc.
- */
-
- /*
- * code to create the data structures for the windows, icons, menus,
- * pointers and carets the program will use.
- */
-
- /*
- * code to link the user routines into their respective events in the
- * data structures HASWIN has created for the windows, icons, menus,
- * pointers and carets the program will use.
- */
-
- for (;;) {
- haswin_poll();
- /*
- * code to do any repeating processing required.
- */
- }
- }
-
- The program structure above is very general, and under most
- conditions not all parts will be required. Much time and trouble has gone
- into HASWINs fallback conditions, ie. what HASWIN does when something happens
- that HASWIN cannot handle and that the user has provided no routine for.
- It is hoped that HASWINs fallback conditions are sufficient for most
- programs, and a programmer should never have to write a "dummy" routine for
- HASWIN to call so that HASWIN does nothing, instead of its own default
- action. Therefore the programmer should need to write routines to handle
- only special cases. All the default actions should be performed by HASWIN
- itself.
-
-