home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / g / gs / !GS / ps / Source / WimpPlus / h / wimpio < prev   
Encoding:
Text File  |  1991-12-05  |  6.9 KB  |  171 lines

  1. /* wimpio.h
  2.  *
  3.  * External interface to wimpio.
  4.  
  5.    1.0  --  April 1991  --  First working version
  6.    2.0  --  July  1991  --  Added extra handle to w_event
  7.                         --  Allow file drop on read window
  8.                         --  Use control block
  9.    2.1  --  Oct   1991  --  Change drop handler
  10.                             Icon bar support
  11.    2.2  --  Dec   1991  --  Fix menu problem
  12.  
  13.  Note that if the icon bar is set up, then the print and scan windows are
  14.  normally kept closed.
  15.  */
  16.  
  17. /* Copyright (C) David Elworthy 1991. No warranty is given on this code. */
  18.  
  19. #include <stdarg.h>
  20. #include "wimp.h"
  21. #include "event.h"
  22.  
  23. /*----------------------------------- printf --------------------------------*/
  24.  
  25. /* Create a printf window with the given title. You can only have one window.
  26.    If a buffer pointer and size are given, text is displayed from that
  27.    buffer. Otherwise, a buffer of the given size is created. If the size
  28.    is left unspecified, a default size is used. Malloc is used for memory.
  29.    Returns TRUE if OK - errors reported through the WIMP otherwise.
  30.    title must be no longer than the title icon (indirect text) of the window.
  31.    Creating the window increments the active count, and deleting it decrements the
  32.    count (NOT show/hide).
  33.  */
  34.  
  35. extern int wprintf_create(char *title, char *buffer, int bufflen);
  36.  
  37. /* Delete the window, and the buffer if we created it */
  38. extern void wprintf_delete(void);
  39.  
  40. /* Show the printf window */
  41. extern void wprintf_show(void);
  42.  
  43. /* Hide the printf window */
  44. extern void wprintf_hide(void);
  45.  
  46. /* Print into window. Same specification as vprintf */
  47. /* This ignores the flag settings used in wimpc.h. */
  48. extern int wprintf(const char *format, va_list arg);
  49.  
  50. /* Write from a buffer of given length (must be less than 4095 characters) */
  51. /* Length does not include null! */
  52. extern void w_write(char *buffer, int bufflen);
  53.  
  54.  
  55. /*------------------------------------ read --------------------------------*/
  56.  
  57. /* Create the window through which read reads results. If the printf flag is set
  58.    input is echoed by calling printf on it.
  59.    Input is read through a writeable icon, terminated by pressing return or clicking
  60.    OK.
  61.    Returns TRUE if OK - errors reported through the WIMP otherwise.
  62.    title must be no longer than the title icon (indirect text) of the window.
  63.    Creating the window increments the active count, and deleting it decrements the
  64.    count (NOT show/hide).
  65.    You can't click OK until wread is called, but you can type in: this allows type ahead.
  66.  
  67.  */
  68. extern BOOL wread_create(char *title, BOOL printf_flag);
  69.  
  70. /* Show the read window */
  71. extern void wread_show(void);
  72.  
  73. /* Hide the read window */
  74. extern void wread_hide(void);
  75.  
  76. /* Delete the read window */
  77. extern void wprintf_hide(void);
  78.  
  79. /* Read text from the read window, as a single string, of given max. length. */
  80. /* bytes read if successful, -1 if not */
  81. extern int wread(char *buffer, int bufflen);
  82.  
  83. /* Register a file drop handler for the read window.
  84.    If you drop a file onto the read window, and you have given a non-null
  85.    string to this routine, and the icons are not grayed, then it treats
  86.    the string as a format string, and simulates the effect of typing that
  87.    in to the window. For example, to get "(<filename>) run", you would give
  88.    a string of "(%s) run". The format must be less than 80 characters -
  89.    it is ignored if not. Passing NULL removes the drop handling.
  90.    The second parameter allows a function to be called before this string is
  91.    issued, for example to display menus. At the moment it passes no parameters on:
  92.    future versions might pass the string in, or allow the process to be halted.
  93.    At present, just the given handle is passed to it.
  94. */
  95. typedef void (*w_drop_handler)(void *handle);
  96. extern void w_register_drop(char *format, w_drop_handler handler, void *handle);
  97. #define WRead_MaxFormat (80)
  98.  
  99.  
  100. /* Pretend the given string had been typed in, and return pressed. */
  101. extern void wread_fake_input(char *text);
  102.  
  103. /*------------------------------------ Others --------------------------------*/
  104.  
  105. /* Vanilla event handler. Pass a redraw function or NULL.
  106.    Often the only application specific operation of the event handler is the redraw,
  107.    so we provide a function which will take an redraw function, and which
  108.    handles open, redraw and close. It can also be called after other events
  109.    have been dealt with.
  110.    Now have two handles - one gets set to TRUE when the window is closed, if it
  111.    is not NULL; the other is passed into the redraw function and the drop handler.
  112.    (Unless handle is NULL)
  113. */
  114. typedef void (*w_redraw_fn)(wimp_redrawstr *r, void *handle);
  115. extern void w_event(wimp_eventstr *e, w_redraw_fn redraw, BOOL *closed, void *handle);
  116.  
  117.  
  118. /* Standard window creator - supply template name, title string.
  119.    It returns the window handle, or -1, and does an activeinc
  120.    You must register the event handler.
  121.    Returns number if icons if nicons is not NULL.
  122. */
  123. extern wimp_w w_create(char *title, char *templatename, int *nicons);
  124.  
  125. /* Close faker. If close is clicked in either window, and this function has
  126.    been called with a non-NULL argument, it is faked as input.
  127.    Otherwise, the close event is passed on to the wimp.
  128.    Returns the previous argument (may be NULL).
  129.    NB! The argument string is NOT copied, so it must not be a local array!
  130. */
  131. extern char *w_close_string(char *text);
  132.  
  133. /* Icon bar support. Sets up an icon with the task's name on the icon bar.
  134.    If the command string is specified, then when a file is dropped on the
  135.    icon, the command is issued; if the string contains %s, the file name is
  136.    substituted there. This string isn't copied, so don't make it local!
  137.    The drop handler works as for w_register_drop.
  138. */
  139. extern void w_baricon(char *command, w_drop_handler handler, void *handle);
  140.  
  141. /* Register the menu maker and processor. Menus are only processed when
  142.    input is expected. The handle is passed to the functions
  143. */
  144. extern void w_register_menu(event_menu_maker maker, event_menu_proc proc, void *handle);
  145.  
  146. /*----------------------------------- control block -------------------------*/
  147.  
  148. /* The following control block allows you access to some of the wimpio internals.
  149.    This is useful for customisation, but you should use it (a) with care and (b)
  150.    only if you have to!
  151.    If you want to change the event handler, use win_read_eventhandler with the
  152.    window handle from the control block to find the standard one. Do your own
  153.    event processing and then call the standard handler for any other events.
  154. */
  155.  
  156. typedef struct
  157. {
  158.     wimp_w    printf_win_handle;   /* Handle for the printf window */
  159.     wimp_w    read_win_handle;     /* Handle for the read window */
  160. /* Other things may be added at a later date. */
  161. } wimpio_cb;
  162.  
  163. /* The actual control block used */
  164. extern wimpio_cb wimpio_control;
  165.  
  166. /* Values for use in the create flag of wimpc_init */
  167. #define WIMPIO_NOCREATE (0) /* Don't create windows */
  168. #define WIMPIO_CREATE   (1) /* Just create the windows */
  169. #define WIMPIO_SHOW     (2) /* Show as well as creating */
  170.  
  171.