home *** CD-ROM | disk | FTP | other *** search
-
- The HASWIN window library.
- ===========================
- Copyright H.A. Shaw 1990.
- ===========================
-
- File handling under the HASWIN system.
- ---------------------------------------
-
- The WIMP, and user programs running under it, should provide a
- uniform interface that allows information flow between programs. This is
- done under HASWIN in the following way. A user program is informas HASWIN
- of routines to be called to load or save files. The HASWIN library handles
- the message passing between itself and the external filer task (that need
- not use the HASWIN library). The user routines are called by HASWIN when
- required and are passed all the information required to perform the load or
- save operation. HASWIN also monitors the launching of applications by the
- filer task and can trap particular filetypes, preventing the filer from
- launching the application and calling a user routine instead.
-
- The user routines are defined as follows:
-
- int usersave(char *name, buffer *buff)
- - This routine is called by HASWIN to save a file. "buff" is either
- 0 or points to a buffer containing:
- buff->i[ 0] - length of buffer (rounded to next word).
- buff->i[ 1] - <depends upon how the file save was initiated>
- buff->i[ 2] - <depends upon how the file save was initiated>
- buff->i[ 3] - <depends upon how the file save was initiated>
- buff->i[ 4] - <depends upon how the file save was initiated>
- buff->i[ 5] - <depends upon how the file save was initiated>
- buff->i[ 6] - <depends upon how the file save was initiated>
- buff->i[ 7] - <depends upon how the file save was initiated>
- buff->i[ 8] - <depends upon how the file save was initiated>
- buff->i[ 9] - estimated file size.
- buff->i[10] - file type.
- buff->c[44] - first character of 0 terminated file name.
- "name" points to the first character of the 0 terminated filename.
- This is usually equal to "buff->c[44]".
- If "buff" is non-zero then a file is to be saved and the buffer
- and "name" contain all the required information to save it. If
- "buff" is zero then the external task has sent an acknowledgement
- to confirm the correct transfer of a previous file to itself.
- - The routine should return HASWIN_TRUE if the file has been saved
- successfully and HASWIN_FALSE on some error.
-
- int userload(char *name, buffer *buff)
- - This routine is called by HASWIN to load a file. "buff" is either
- 0 or points to a buffer containing:
- buff->i[ 0] - length of buffer (rounded to next word).
- buff->i[ 1] - <depends upon how the file load was initiated>
- buff->i[ 2] - <depends upon how the file load was initiated>
- buff->i[ 3] - <depends upon how the file load was initiated>
- buff->i[ 4] - <depends upon how the file load was initiated>
- buff->i[ 5] - <depends upon how the file load was initiated>
- buff->i[ 6] - <depends upon how the file load was initiated>
- buff->i[ 7] - <depends upon how the file load was initiated>
- buff->i[ 8] - <depends upon how the file load was initiated>
- buff->i[ 9] - estimated file size.
- buff->i[10] - file type.
- buff->c[44] - first character of 0 terminated file name.
- "name" points to the first character of the 0 terminated filename.
- This is usually equal to "buff->c[44]".
- If "buff" is non-zero then a file is to be loadd and the buffer
- and "name" contain all the required information to load it. If
- "buff" is zero then the external task has sent an acknowledgement
- to confirm the correct transfer of a previous file to itself.
- - The routine should return HASWIN_TRUE if the file has been loadd
- successfully and HASWIN_FALSE on some error.
-
- int autoload(char *name, buffer *buff)
- - This routine is called by HASWIN when an application is to be
- launched by a double click onto a file of a filetype HASWIN has
- been told to watch out for. "buff" is either 0 or points to a
- buffer containing:
- buff->i[ 0] - length of buffer (rounded to next word).
- buff->i[ 1] - <depends upon how the launch was initiated>
- buff->i[ 2] - <depends upon how the launch was initiated>
- buff->i[ 3] - <depends upon how the launch was initiated>
- buff->i[ 4] - 5
- buff->i[ 5] - window handle of directory display containing
- file.
- buff->i[ 6] - unused.
- buff->i[ 7] - X-offset of file icon that was double clicked
- buff->i[ 8] - Y-offset of file icon that was double clicked
- buff->i[ 9] - 0
- buff->i[10] - file type.
- buff->c[44] - first character of 0 terminated file name.
- "name" points to the first character of the 0 terminated filename.
- This is usually equal to "buff->c[44]".
- - The routine should return HASWIN_TRUE if successful and
- HASWIN_FALSE on some error.
-
- Under normal conditions HASWIN is used in the following way to add
- automatic file loading and saving to it.
- 1) The routine "haswin_fileinitialise()" is called once in the
- main program to setup the file loading "file_load" and file
- saving "file_save" windows.
- 2) Once created the file loading and saving windows can be
- opened on the screen in the same wasy as any other windows.
- For example...
- haswin_reopenwindow(haswin_findwindowname("file_load"));
- ...will open the file loading window back whereever it had
- been opened last time.
- 3) Once opened the main file icon may be dragged, the filename
- changed and the file type changed.
- 4) A file save (call to the user save file routine) is triggered
- by the following...
- a) Clicking in the "OK" icon of the "file_save" window.
- b) Pressing <RETURN> while the filename icon of the
- "file_save" window has the input focus.
- c) Dragging the main file icon to a filer directory
- window, or another application that allows
- inter-process file transfer.
- A file load (call to the user load file routine) is triggered
- by the following...
- a) Clicking in the "OK" icon of the "file_load" window.
- b) Pressing <RETURN> while the filename icon of the
- "file_load" window has the input focus.
- c) An icon from a filer directory window being dragged
- to, and then "dropped" on an icon or window
- belonging to the program.
- Note that dragging the main file icon of the "file_load"
- window to a filer directory window, or another application
- that allows inter-process file transfer just sets the
- filename and does not start the file load operation.
-
- The file load and save operations are closely linked to the RAM
- transfer operations in the "ramtrans" part of the HASWIN library.
-
- HASWIN provides routines so that the user file load and save routines
- can be registered and manipulated. Once a user load or save routine has
- been registered with HASWIN then menus created from icons on the icon bar
- will have the file loading and saving items added automatically.
-
- void haswin_setsavefileroutine(int (*user)(char *, buffer *),
- char *name, char *type)
- - Register the routine "user" as a routine to be called to save a
- file. "name" is the default file leafname to be used in file save
- windows or menu items, and "type" is the default filetype. If
- "user" is 0 then deregister any existing file saving user routine.
-
- int haswin_pushsavefileroutine(int (*user)(char *, buffer *), char *name, char *type) {
- - Push the current save routine and default leaf name and filetype
- onto an internal stack and then register the routine "user" as a
- routine to be called to save a file. "name" is the default file
- leafname to be used in file save windows or menu items, and "type"
- is the default filetype. If "user" is 0 then register no user
- routine. Return HASWIN_TRUE if successful or HASWIN_FALSE on any
- error.
-
- int haswin_popsavefileroutine(void)
- - Pull a save file routine, default leaf name and filetype from the
- internal stack and re-regester them as the user save file routine,
- default leaf name and filetype. If the stack is empty register
- no routine and return HASWIN_FALSE, otherwise return HASWIN_TRUE.
-
- void haswin_setloadfileroutine(int (*user)(char *, buffer *),
- char *name, char *type)
- - Register the routine "user" as a routine to be called to load a
- file. "name" is the default file leafname to be used in file load
- windows or menu items, and "type" is the default filetype. If
- "user" is 0 then deregister any existing file loading user routine.
-
- int haswin_pushloadfileroutine(int (*user)(char *, buffer *), char *name, char *type) {
- - Push the current load routine and default leaf name and filetype
- onto an internal stack and then register the routine "user" as a
- routine to be called to load a file. "name" is the default file
- leafname to be used in file load windows or menu items, and "type"
- is the default filetype. If "user" is 0 then register no user
- routine. Return HASWIN_TRUE if successful or HASWIN_FALSE on any
- error.
-
- int haswin_poploadfileroutine(void)
- - Pull a load file routine, default leaf name and filetype from the
- internal stack and re-regester them as the user load file routine,
- default leaf name and filetype. If the stack is empty register
- no routine and return HASWIN_FALSE, otherwise return HASWIN_TRUE.
-
- void haswin_setautoloadroutine(int (*user)(char *, buffer *), char *type)
- - Register the routine "user" as a routine to be called if a file of
- type "type" is double-clicked and is therefore to be launched by
- the filer. If "user" is 0 then deregister any existing user
- routine.
-
- int haswin_pushautoloadroutine(int (*user)(char *, buffer *), char *type)
- - Push the current autoload routine and monitored filetype onto an
- internal stack and then register the routine "user" as a routine
- to be called if a file of type "type" is double-clicked and is
- therefore to be launched by the filer. If "user" is 0 then
- register no user routine. Return HASWIN_TRUE if successful or
- HASWIN_FALSE on any error.
-
- int haswin_popautoloadroutine(void)
- - Pull an autoload routine, and filetype to monitor from the
- internal stack and re-regester them as the user autoload routine,
- and monitored filetype. If the stack is empty register no routine
- and return HASWIN_FALSE, otherwise return HASWIN_TRUE.
-
- void haswin_loadfilemugwatch(int direction)
- - The load file window can have a small rotating wheel in its top
- left corner that is used as a "mugwatch" (something for mugs to
- watch!). The way the wheel moves depends upon the value of
- "direction".
- direction > 0 - move the wheel 45 degrees clockwise.
- direction < 0 - move the wheel 45 degrees anti-clockwise.
- direction == 0 - remove the wheel from the window.
-
- void haswin_savefilemugwatch(int direction)
- - The save file window can have a small rotating wheel in its top
- left corner that is used as a "mugwatch" (something for mugs to
- watch!). The way the wheel moves depends upon the value of
- "direction".
- direction > 0 - move the wheel 45 degrees clockwise.
- direction < 0 - move the wheel 45 degrees anti-clockwise.
- direction == 0 - remove the wheel from the window.
-
- int haswin_fileinitialise()
- - This must be called before using the load/save files system. See
- also the information on initialisation.
-
- void haswin_decodefiletype(int type, char *str)
- - Given a filetype number "type" fill the string "str" with the
- textual version of the filetype. The text is filled with spaces
- make it 8 characters long. If type is 0x1000 the text "Dir. "
- is used, and if type is 0x2000 the text "Appl. " is used.
- If the type is unknown the string is filled with 8 spaces.
-
- int haswin_encodefiletype(char *str)
- - Given a textual filetype "str" this routine returns the filetype
- number or 0 if the text is not known. The special string "Dir."
- returns the number 0x1000 and "Appl." returns 0x2000.
-
- int haswin_setfiletype(char *name, int type)
- - Call RISC OS to set the file "name" to the filetype "type"
- Return HASWIN_TRUE if successful or HASWIN_FALSE on some error.
-
-
-
- The HASWIN system allows certain file options to be set up to modify
- the way HASWIN operates on files. The file options are a set of
- flags that may be set, cleared or read by the user program. The
- following options are defined.
- HASWIN_OPTIONS_ADD - if set files are to be added when loaded or
- saved from the user program. The user load
- and save routines should check this option
- using "haswin_getfileoptions()" and take the
- correct action themselves. The user can alter
- this option by items in the menus automatically
- added by HASWIN.
-
- int haswin_clearfileoptions(int new)
- - Clear the file options given in "new". Returns the new state of
- the file options.
-
- int haswin_getfileoptions()
- - Return the current state of the file options.
-
- int haswin_setfileoptions(int new)
- - Set the file options given in "new". Returns the new state of
- the file options.
-
-