home *** CD-ROM | disk | FTP | other *** search
- /* wimpio.h
- *
- * External interface to wimpio.
-
- 1.0 -- April 1991 -- First working version
- 2.0 -- July 1991 -- Added extra handle to w_event
- -- Allow file drop on read window
- -- Use control block
- 2.1 -- Oct 1991 -- Change drop handler
- Icon bar support
- 2.2 -- Dec 1991 -- Fix menu problem
-
- Note that if the icon bar is set up, then the print and scan windows are
- normally kept closed.
- */
-
- /* Copyright (C) David Elworthy 1991. No warranty is given on this code. */
-
- #include <stdarg.h>
- #include "wimp.h"
- #include "event.h"
-
- /*----------------------------------- printf --------------------------------*/
-
- /* Create a printf window with the given title. You can only have one window.
- If a buffer pointer and size are given, text is displayed from that
- buffer. Otherwise, a buffer of the given size is created. If the size
- is left unspecified, a default size is used. Malloc is used for memory.
- Returns TRUE if OK - errors reported through the WIMP otherwise.
- title must be no longer than the title icon (indirect text) of the window.
- Creating the window increments the active count, and deleting it decrements the
- count (NOT show/hide).
- */
-
- extern int wprintf_create(char *title, char *buffer, int bufflen);
-
- /* Delete the window, and the buffer if we created it */
- extern void wprintf_delete(void);
-
- /* Show the printf window */
- extern void wprintf_show(void);
-
- /* Hide the printf window */
- extern void wprintf_hide(void);
-
- /* Print into window. Same specification as vprintf */
- /* This ignores the flag settings used in wimpc.h. */
- extern int wprintf(const char *format, va_list arg);
-
- /* Write from a buffer of given length (must be less than 4095 characters) */
- /* Length does not include null! */
- extern void w_write(char *buffer, int bufflen);
-
-
- /*------------------------------------ read --------------------------------*/
-
- /* Create the window through which read reads results. If the printf flag is set
- input is echoed by calling printf on it.
- Input is read through a writeable icon, terminated by pressing return or clicking
- OK.
- Returns TRUE if OK - errors reported through the WIMP otherwise.
- title must be no longer than the title icon (indirect text) of the window.
- Creating the window increments the active count, and deleting it decrements the
- count (NOT show/hide).
- You can't click OK until wread is called, but you can type in: this allows type ahead.
-
- */
- extern BOOL wread_create(char *title, BOOL printf_flag);
-
- /* Show the read window */
- extern void wread_show(void);
-
- /* Hide the read window */
- extern void wread_hide(void);
-
- /* Delete the read window */
- extern void wprintf_hide(void);
-
- /* Read text from the read window, as a single string, of given max. length. */
- /* bytes read if successful, -1 if not */
- extern int wread(char *buffer, int bufflen);
-
- /* Register a file drop handler for the read window.
- If you drop a file onto the read window, and you have given a non-null
- string to this routine, and the icons are not grayed, then it treats
- the string as a format string, and simulates the effect of typing that
- in to the window. For example, to get "(<filename>) run", you would give
- a string of "(%s) run". The format must be less than 80 characters -
- it is ignored if not. Passing NULL removes the drop handling.
- The second parameter allows a function to be called before this string is
- issued, for example to display menus. At the moment it passes no parameters on:
- future versions might pass the string in, or allow the process to be halted.
- At present, just the given handle is passed to it.
- */
- typedef void (*w_drop_handler)(void *handle);
- extern void w_register_drop(char *format, w_drop_handler handler, void *handle);
- #define WRead_MaxFormat (80)
-
-
- /* Pretend the given string had been typed in, and return pressed. */
- extern void wread_fake_input(char *text);
-
- /*------------------------------------ Others --------------------------------*/
-
- /* Vanilla event handler. Pass a redraw function or NULL.
- Often the only application specific operation of the event handler is the redraw,
- so we provide a function which will take an redraw function, and which
- handles open, redraw and close. It can also be called after other events
- have been dealt with.
- Now have two handles - one gets set to TRUE when the window is closed, if it
- is not NULL; the other is passed into the redraw function and the drop handler.
- (Unless handle is NULL)
- */
- typedef void (*w_redraw_fn)(wimp_redrawstr *r, void *handle);
- extern void w_event(wimp_eventstr *e, w_redraw_fn redraw, BOOL *closed, void *handle);
-
-
- /* Standard window creator - supply template name, title string.
- It returns the window handle, or -1, and does an activeinc
- You must register the event handler.
- Returns number if icons if nicons is not NULL.
- */
- extern wimp_w w_create(char *title, char *templatename, int *nicons);
-
- /* Close faker. If close is clicked in either window, and this function has
- been called with a non-NULL argument, it is faked as input.
- Otherwise, the close event is passed on to the wimp.
- Returns the previous argument (may be NULL).
- NB! The argument string is NOT copied, so it must not be a local array!
- */
- extern char *w_close_string(char *text);
-
- /* Icon bar support. Sets up an icon with the task's name on the icon bar.
- If the command string is specified, then when a file is dropped on the
- icon, the command is issued; if the string contains %s, the file name is
- substituted there. This string isn't copied, so don't make it local!
- The drop handler works as for w_register_drop.
- */
- extern void w_baricon(char *command, w_drop_handler handler, void *handle);
-
- /* Register the menu maker and processor. Menus are only processed when
- input is expected. The handle is passed to the functions
- */
- extern void w_register_menu(event_menu_maker maker, event_menu_proc proc, void *handle);
-
- /*----------------------------------- control block -------------------------*/
-
- /* The following control block allows you access to some of the wimpio internals.
- This is useful for customisation, but you should use it (a) with care and (b)
- only if you have to!
- If you want to change the event handler, use win_read_eventhandler with the
- window handle from the control block to find the standard one. Do your own
- event processing and then call the standard handler for any other events.
- */
-
- typedef struct
- {
- wimp_w printf_win_handle; /* Handle for the printf window */
- wimp_w read_win_handle; /* Handle for the read window */
- /* Other things may be added at a later date. */
- } wimpio_cb;
-
- /* The actual control block used */
- extern wimpio_cb wimpio_control;
-
- /* Values for use in the create flag of wimpc_init */
- #define WIMPIO_NOCREATE (0) /* Don't create windows */
- #define WIMPIO_CREATE (1) /* Just create the windows */
- #define WIMPIO_SHOW (2) /* Show as well as creating */
-
-