home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / clib / progs / haswinlib / info / windows < prev   
Encoding:
Text File  |  1991-02-04  |  39.3 KB  |  762 lines

  1.  
  2.                       The HASWIN window library.
  3.                      ===========================
  4.                       Copyright H.A. Shaw 1990.
  5.                      ===========================
  6.  
  7. The HASWIN window.
  8. -------------------
  9.         The HASWIN window is a data structure created and maintained by
  10. the HASWIN routines.  A window has the following user selected features.
  11.     1)  - A set of flags for the various parts of the window, defined at
  12.           the creation of the window, some of which may be altered later.
  13.     2)  - Colours for title bar foreground and background, scroll bar outer
  14.           and inner, work area foreground and background, and for the input
  15.           focus.  These are also defined when the window is created, but may
  16.           be altered later.
  17.     3)  - Graphics that will be automatically redrawn by HASWIN.  HASWIN
  18.           allows text and lines, rectangles and circles to be drawn at any
  19.           position in any window in any of the WIMPs 16 standard colours.
  20.           Initialliy no graphics is added to the window, but routines exist
  21.           for adding, or removing the graphics at any time.  Graphics is
  22.           defined as a printf() like string.
  23.     4)  - Text that will be automatically redrawn by HASWIN.  HASWIN allows
  24.           text to be positioned in a 2-D grid in a foreground and background
  25.           colour.  The text area may be larger or smaller than the window
  26.           itself and text may be automatically inserted by HASWIN in responce
  27.           to mouse actions in the window and keypresses in the window.
  28.     5)  - A pointer made from a sprite that will be automatically selected
  29.           when the mouse is placed over the window.
  30.     6)  - A menu that is opened when the MENU mouse button is clicked in the
  31.           window.
  32.     7)  - A HASWIN window that contains help information that HASWIN will
  33.           automatically open on request from the user.
  34.     8)  - A text string to be sent to an application on request for Help
  35.           information about the window.
  36.     9)  - A HASWIN window called a "pane window" that is opened, closed or
  37.           moved whenever the main window is opened, closed or moved.  This
  38.           window may also have panes and therefore can form a linked list
  39.           of windows that open, close and move together.  If a pane window
  40.           is selected then the main window gets the input focus unless the
  41.           pane window has its WINDOW_FOCUS bit set.
  42.     10) - A HASWIN window called a "slide window" that behaves exactly as
  43.           if it was a pane window except that is also scrolls as the main
  44.           window scrolls.  Slide windows may themselves have slide windows.
  45.  
  46.         The user program provides a series of routines which HASWIN calls
  47. when something happens to a window that HASWIN cannot deal with directly.
  48. HASWIN makes intellegent guesses about which of the routines it is supplied
  49. with to use under any circumstance, and contains internal routines to use
  50. when the user program does not supply one.  The routine is automatically
  51. passed all relevant information by HASWIN when called.
  52.         openroutine() - called when the window is opened, or reopened at a
  53.                         new position.
  54.         drawroutine() - called when a section of the window must be
  55.                         redrawn.
  56.         dragroutine() - called when a drag is first started, and again when
  57.                         it is completed.
  58.         keyroutine()  - called when a key is pressed when the window has the
  59.                         input focus.
  60.         mousebutton() - called when the mouse buttons are pressed in the
  61.                         window and there is no other action.
  62.  
  63. A window is created by the following routines...
  64.  
  65. window *haswin_loadwindow(char *name, int flags);
  66.         - load a window from the currently opened Template file.
  67.           - "name" is the template file window identifier.
  68.           - "flgs" is the HASWIN flags for this window (in addition to
  69.             flags already in the template file).
  70.         - returns a pointer to the window structure, or 0 if the window
  71.           could not be created.
  72.  
  73. window *haswin_loadpanewindow(window *main, char *name, int flgs);
  74.         - load a pane window from the currently opened Template file.
  75.           - "main" is the master window for this pane.
  76.           - "name" is the template file window identifier.
  77.           - "flgs" is the HASWIN flags for this window (in addition to
  78.             flags already in the template file).
  79.         - returns a pointer to the window structure, or 0 if the window
  80.           could not be created.
  81.  
  82. window *haswin_loadslidewindow(window *main, char *name, int flgs);
  83.         - load a slide window from the currently opened Template file.
  84.           - "main" is the master window for this pane.
  85.           - "name" is the template file window identifier.
  86.           - "flgs" is the HASWIN flags for this window (in addition to
  87.             flags already in the template file).
  88.         - returns a pointer to the window structure, or 0 if the window
  89.           could not be created.
  90.  
  91. window *haswin_makewindow(char *title, int x, int y, int tf, int tb,
  92.                           int wf, int wb, int flgs);
  93.         - make a new window (restrictions are described below).
  94.           - "title" is the window title.
  95.           - "x" is the X size.
  96.           - "y" is the Y size.
  97.           - "tf" is the text foreground colour.
  98.           - "tb" is the text background colour.
  99.           - "wf" is the work foreground colour.
  100.           - "wb" is the work background colour.
  101.           - "flgs" is the HASWIN window flags.
  102.         - returns a pointer to the window structure, or 0 if the window
  103.           could not be created.
  104.  
  105. window *haswin_makepanewindow(window *main, char *title, int x, int y,
  106.                               int tf, int tb, int wf, int wb, int flgs);
  107.         - make a new pane window (restrictions are described below).
  108.           - "main"  is the master window for this pane.
  109.           - "title" is the window title.
  110.           - "x"     is the X size.
  111.           - "y"     is the Y size.
  112.           - "tf"    is the text foreground colour.
  113.           - "tb"    is the text background colour.
  114.           - "wf"    is the work foreground colour.
  115.           - "wb"    is the work background colour.
  116.           - "flgs"  is the HASWIN window flags.
  117.         - returns a pointer to the window structure, or 0 if the window
  118.           could not be created.
  119.  
  120. window *haswin_makeslidewindow(window *main, char *title, int x, int y,
  121.                                int tf, int tb, int wf, int wb, int flgs);
  122.         - make a new slide window (restrictions are described below).
  123.           - "main"  is the master window for this slide.
  124.           - "title" is the window title.
  125.           - "x"     is the X size.
  126.           - "y"     is the Y size.
  127.           - "tf"    is the text foreground colour.
  128.           - "tb"    is the text background colour.
  129.           - "wf"    is the work foreground colour.
  130.           - "wb"    is the work background colour.
  131.           - "flgs"  is the HASWIN window flags.
  132.         - returns a pointer to the window structure, or 0 if the window
  133.           could not be created.
  134.  
  135. window  *haswin_copywindow(window *win);
  136.         - copy the window structure "win" to a new window.  All data areas
  137.           within the window are copied into new dynamically allocated memory
  138.           and the pointers within the new window structure arranged to point
  139.           to the new data areas.  Therefore after a copy one window may be
  140.           modified (or even deleted) without regard to the other.  All pane
  141.           and slide windows belonging to "win" are also copied in their
  142.           entirety.  The new windows are not opened for display.
  143.         - Returns the new window structure, or HASWIN_FALSE on any error.
  144.  
  145.  
  146.         The windows that can be made with haswin_make(pane/slide)window()
  147. are slightly restricted in the following way.
  148.     a)  The input focus colour is always "white" (WIMP colour 0).
  149.     b)  The title is always text only in the system font.
  150. There are no restrictions on the windows that may be loaded from templates.
  151.  
  152.         If windows can be created then, of course, they may be deleted.  A
  153. HASWIN routine is provided to do this.
  154.  
  155. void    haswin_deletewindow(window *win);
  156.         - Remove the window "win" from the WIMP's tables.  This removes the
  157.           window from the display, frees all space used by the WIMP for the
  158.           window and its icons and then removes the window and its icons
  159.           from HASWIN's tables as well.  This is then repeated for all of
  160.           the window's panes and slides.
  161.  
  162. "flgs" is an integer made up from the following bits...
  163.     a) Bits that create the window's features...
  164.         WINDOW_MOVEABLE     window may move
  165.         WINDOW_TRESPASS     window may move off screen
  166.         WINDOW_GCOL         window colours are GCOL numbers
  167.         WINDOW_BACKDROP     window cannot have things under it
  168.         WINDOW_BACKICON     window has a back icon
  169.         WINDOW_CLOSEICON    window has a close icon
  170.         WINDOW_TITLE_BAR    window has a title bar
  171.         WINDOW_FULLICON     window has a toggle size icon
  172.         WINDOW_V_SCROLL     window has a vertical scroll bar
  173.         WINDOW_SIZEICON     window has a adjust size icon
  174.         WINDOW_H_SCROLL     window has a horizontal scroll bar
  175.         WINDOW_STDWINDOW    <combination of flags that produced a
  176.                             "standard window">
  177.     b) Bits that control the window's behaviour.  These are not stored in
  178.        template files, but must be added in the "flgs" parameter of the
  179.        "haswin_load(pane/slide)window()" routine...
  180.         WINDOW_TEMP         delete window on close
  181.         WINDOW_DRAGSEL      we may drag select in this window
  182.         WINDOW_DRAGADJ      we may drag adjust in this window
  183.         WINDOW_FILER        open a filer from the window's name on close
  184.                             with the ADJUST button
  185.         WINDOW_AUTOTEXT     create a text window overlay for the window on
  186.                             creation of the window.  The window is adjusted
  187.                             in size to the next whole number of characters in
  188.                             width and height.  The scroll amounts are made
  189.                             adjusted to fit with character sizes.  If this is
  190.                             set then the caret or characters are placed in
  191.                             the text automatically when mouse actions occur
  192.                             in the window.
  193.         WINDOW_SELECT       select window on mouse entry
  194.         WINDOW_HELPFUL      respond to !Help application
  195.     c) Bits that control the window's work area button type...
  196.         WINDOW_BUTTON_NEVER       Respond only to MENU button
  197.         WINDOW_BUTTON_ALWAYS      Respond whenever in window
  198.         WINDOW_BUTTON_REPEAT      Respond to SELECT/ADJUST with repeat
  199.         WINDOW_BUTTON_CLICK       Respond to SELECT/ADJUST once
  200.         WINDOW_BUTTON_RELEASE     Respond to SELECT/ADJUST when released
  201.         WINDOW_BUTTON_DCLICK      Respond to Double clicks on SELECT/ADJUST
  202.         WINDOW_BUTTON_CLICKDRAG   As WINDOW_BUTTON_CLICK   + DRAG
  203.         WINDOW_BUTTON_RELEASEDRAG As WINDOW_BUTTON_RELEASE + DRAG
  204.         WINDOW_BUTTON_DOUBLEDRAG  As WINDOW_BUTTON_DCLICK  + DRAG
  205.         WINDOW_BUTTON_MENU        Respond as a MENU button.
  206.         WINDOW_BUTTON_EVERYTHING  Respond to everything
  207.         WINDOW_BUTTON_RADIO       Respond as if a Radio button.
  208.         WINDOW_BUTTON_SILENT      This is a HASWIN type, respond to nothing
  209.         WINDOW_BUTTON_13          Unused
  210.         WINDOW_BUTTON_WRITECLICK  Writable + click
  211.         WINDOW_BUTTON_WRITABLE    Writable
  212.         WINDOW_BUTTON_DEFAULT     Default HASWIN button type.
  213.  
  214.         These window flags may be modified after window creation by use of
  215. the three routines described below...
  216.  
  217. int     haswin_clearwindowflags(window *win, int flgs);
  218.         - clear the window flags specified in "flgs" for the window "win".
  219.         - returns HASWIN_TRUE if successful, and HASWIN_FALSE on any error.
  220.  
  221. int     haswin_newwindowflags(window *win, int flgs);
  222.         - reset the window flags to the value "flgs" for the window "win".
  223.         - returns HASWIN_TRUE if successful, and HASWIN_FALSE on any error.
  224.  
  225. int     haswin_setwindowflags(window *win, int flgs);
  226.         - set the window flags specified in "flgs" for the window "win".
  227.         - returns HASWIN_TRUE if successful, and HASWIN_FALSE on any error.
  228.  
  229.  
  230.         After the creation of a window the various user defined fields may
  231. be accessed directly in order to set them up.  Normal assignment operations
  232. may be performed and these variables may be read from or written to at any
  233. time.  It is dangerous to use locally defined absolute storage for the
  234. fields "pointer", "caret", "menu", "help", or "helpmsg".  It is best to
  235. allocate dynamic storage for them using the functions provided.  The user
  236. fields are as follows:
  237.  
  238. short           pagex;
  239.         - amount to scroll in response to "page scroll X direction" request.
  240.           0 uses WIMP standard default, negative numbers scroll "the wrong
  241.           way".
  242.  
  243. short           pagey;
  244.         - amount to scroll in response to "page scroll Y direction" request.
  245.           0 uses WIMP standard default, negative numbers scroll "the wrong
  246.           way".
  247.  
  248. short           scrollx;
  249.         - amount to scroll in response to "line scroll X direction" request.
  250.           0 uses WIMP standard default, negative numbers scroll "the wrong
  251.           way".
  252.  
  253. short           scrolly;
  254.         - amount to scroll in response to "line scroll Y direction" request.
  255.           0 uses WIMP standard default, negative numbers scroll "the wrong
  256.           way".
  257.  
  258. struct pointer  *pointer;
  259.         - pointer structure to define a mouse pointer to select when the
  260.           mouse is over the window, or 0 for no pointer change.
  261.  
  262. struct caret    *caret;
  263.         - caret structure to use when the window is selected as the input
  264.           focus, or 0 for no caret on selection.
  265.  
  266. struct menu     *menu;
  267.         - menu structure to use when a menu must be opened in the window,
  268.           usually in response to a MENU mouse button click in the window
  269.           work area, or 0 for no menu.
  270.  
  271. struct window   *help;
  272.         - window structure to open when the user selects Window for the Help
  273.           sub-menu of a menu opened in the window, or 0 for no help window.
  274.  
  275. char            *helpmsg;
  276.         - text string to be sent in response to a HelpRequest message from
  277.           another task (usually !Help) when this window is quoted.
  278.  
  279. int     (*mousebutton)(struct window *win, buffer *buff);
  280.         - routine to call on mouse buton press in the window if there is
  281.           no other action to perform.  This is called when the following
  282.           mouse actions occur.
  283.               SELECT              - always.
  284.               MENU                - if there is no menu defined.
  285.               ADJUST              - always.
  286.               SELECT DRAG         - if there is no dragroutine defined.
  287.               ADJUST DRAG         - if there is no dragroutine defined.
  288.               SELECT DOUBLE CLICK - always.
  289.               ADJUST DOUBLE CLICK - always.
  290.         - "win" is the window structure, so that one "mousebutton()" routine
  291.           can service several windows.
  292.         - "buff" is the Mouse_Click buffer obtained from SWI(WIMP_Poll).
  293.         - returns HASWIN_TRUE if successful or HASWIN_FALSE to prevent
  294.           HASWIN from continuing default processing of the mouse click.
  295.         - 0 means that there is no routine.
  296.  
  297. int     (*drawroutine)(struct window *win, buffer *buff);
  298.         - This routine is called by HASWIN to redraw a part of the window.
  299.           The WIMP divides the area to be redrawn into a number (perhaps 1)
  300.           of non overlapping rectangles, and this routine will automatically
  301.           be called once for each of the rectangles to be redrawn.  HASWIN
  302.           takes care of all the code to do this, the routine just receives
  303.           the data blocks for redrawing each rectangular area.
  304.         - "win" is the window structure, so that one "drawroutine()" routine
  305.           can service several windows.
  306.         - "buff" is the buffer obtained from SWI(WIMP_RedrawWindow) or
  307.           SWI(WIMP_GetRectangle).
  308.         - returns HASWIN_TRUE if successful or HASWIN_FALSE to prevent
  309.           HASWIN from continuing default processing of the redraw window
  310.           sequence.
  311.         - 0 means that there is no routine.
  312.  
  313. int     (*openroutine)(struct window *win, buffer *buff);
  314.         - This routine is called to open the window, or to reopen the window
  315.           at a new place after a move, drag of the scroll bars or Adjust
  316.           Size icon of the window.
  317.         - "win" is the window structure, so that one "openroutine()" routine
  318.           can service several windows.
  319.         - "buff" is the Open_Window_Request buffer obtained from
  320.           SWI(WIMP_Poll).
  321.         - returns HASWIN_TRUE if successful or HASWIN_FALSE to prevent
  322.           HASWIN from continuing default processing of the window open.
  323.         - 0 means that there is no routine.
  324.  
  325. int     (*keyroutine)(struct window *win, buffer *buff);
  326.         - This routine is called when a key is pressed while the window is
  327.           selected as the input focus.  The key is passed to the routine
  328.           only if HASWIN cannot deal with it directly.  HASWIN automatically
  329.           deals with the following keys.
  330.           F1 - F9   - the 1st to 9th icon (in order of definition ie. icon
  331.                       handle) with a SELECT action is selected as if it had
  332.                       been "clicked" with the SELECT mouse button.
  333.           If the WINDOW_AUTOTEXT flag is set and the window has a text
  334.           overlay then the character is passed to haswin_textvdu() so that
  335.           it may be added to the window text overlay automatically.
  336.         - "win" is the window structure, so that one "keyroutine()" routine
  337.           can service several windows.
  338.         - "buff" is the Key_Pressed buffer obtained from SWI(WIMP_Poll).
  339.         - returns HASWIN_TRUE if successful or HASWIN_FALSE to prevent
  340.           HASWIN from continuing default processing of the keypress.
  341.         - 0 means that there is no routine.
  342.  
  343. int     (*dragroutine)(struct window *win, struct icon *ic,
  344.                        struct pointer *mouse, buffer *buff);
  345.         - This routine is called when a drag, either with the SELECT or
  346.           ADJUST mouse buttons is performed in the window.
  347.               At the beginning of the drag operation it is called with "win"
  348.           the window and "ic" the icon to be dragged, "mouse" is the current
  349.           mouse pointer and "buff" = 0.  If HASWIN_TRUE is returned the drag
  350.           operation is started and if HASWIN_FALSE is returned no further
  351.           action is performed.
  352.               At the end of the drag operation it is called again with "win"
  353.           set to the window and "ic" the icon dragged, "mouse" the pointer
  354.           as it was when the drag started, and "buff" the User_Drag_Box
  355.           buffer from SWI(WIMP_Poll).
  356.         - 0 means that there is no routine.
  357.  
  358.  
  359.         Various parts of the window's definition may be determined by the
  360. following routines...
  361.  
  362. int     haswin_getwindowbhandle(window *win);
  363.         - returns the handle of the window in front of "win" in the WIMP's
  364.           window stack, or -1 if "win" is the top window, -2 if "win" is
  365.           the bottom window or HASWIN_FALSE on an error.
  366.  
  367. int     haswin_getwindowcaret(window *win, int *x, int *y);
  368.         - fills the x,y coordinates of the window's caret into "x" and "y"
  369.         - returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
  370.  
  371. int     haswin_getwindowflags(window *win);
  372.         - returns the flags for the window "win".
  373.           or HASWIN_FALSE on an error.
  374.  
  375. char    *haswin_getwindowname(window *win);
  376.         - returns the name for the window "win".  This is the template
  377.           identifier if the window was created from a template file
  378.           with "haswin_load(pane/slide)window()" routines, or the
  379.           window title on creation of the window if created with the
  380.           "haswin_make(pane/slide)window()" routines or 0 on an error.
  381.  
  382. char    *haswin_getwindowtitle(window *win);
  383.         - returns the contents of the title for the window "win" or 0 on
  384.           an error.
  385.  
  386. int     haswin_getwindowxextent(window *win);
  387.         - returns the X-coordinate of the work area extent for the
  388.           window "win". or HASWIN_UNKNOWN on any error.
  389.  
  390. int     haswin_getwindowxorigin(window *win);
  391.         - returns the X-coordinate of the origin of the work area coordinate
  392.           system for the window "win". or HASWIN_UNKNOWN on any error.
  393.  
  394. int     haswin_getwindowxmax(window *win);
  395.         - returns the maximum X-coordinate of the work area for the
  396.           window "win". or HASWIN_UNKNOWN on any error.
  397.  
  398. int     haswin_getwindowxmin(window *win);
  399.         - returns the minimum X-coordinate of the work area for the
  400.           window "win". or HASWIN_UNKNOWN on any error.
  401.  
  402. int     haswin_getwindowxscroll(window *win);
  403.         - returns the scroll position in the X direction for the window
  404.          "win". or HASWIN_UNKNOWN on any error.
  405.  
  406. int     haswin_getwindowyextent(window *win);
  407.         - returns the Y-coordinate of the work area extent for the window
  408.           "win". or HASWIN_UNKNOWN on any error.
  409.  
  410. int     haswin_getwindowyorigin(window *win);
  411.         - returns the Y-coordinate of the origin of the work area coordinate
  412.           system for the window "win". or HASWIN_UNKNOWN on any error.
  413.  
  414. int     haswin_getwindowymax(window *win);
  415.         - returns the maximum Y-coordinate of the work area for the window
  416.           "win". or HASWIN_UNKNOWN on any error.
  417.  
  418. int     haswin_getwindowymin(window *win);
  419.         - returns the minimum Y-coordinate of the work area for the window
  420.           "win". or HASWIN_UNKNOWN on any error.
  421.  
  422. int     haswin_getwindowyscroll(window *win);
  423.         - returns the scroll position in the Y direction for the window
  424.           "win". or HASWIN_UNKNOWN on any error.
  425.  
  426.  
  427.     The following routines allow the various window characteristics to be
  428. altered.
  429.  
  430. int     haswin_resizewindow(window *win, int x, int y, int redraw);
  431.         - Alter the size of the window "win".  If the window is being
  432.           displayed and "x" or "y" are smaller than the current displayed
  433.           window then the displayed window is reduced in size and the
  434.           window redrawn.  If "redraw" is true then a complete redraw of the
  435.           window is forced if the window is being displayed.
  436.         - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
  437.  
  438. int     haswin_setwindoworigin(window *win, int x, int y);
  439.         - Move the origin of the window "win" to absolute position "x","y".
  440.           The values in "x" and "y" are in screen coordinates and 0,0 is the
  441.           top left of the window.  For example, for a window 100 by 150...
  442.                 haswin_setwindoworigin(win,   0, -150);
  443.                     - move 0,0 to bottom left corner.
  444.                 haswin_setwindoworigin(win, 100, -150);
  445.                     - move 0,0 to bottom right corner.
  446.                 haswin_setwindoworigin(win,   0,    0);
  447.                     - move 0,0 to top left corner.
  448.                 haswin_setwindoworigin(win, 100,    0);
  449.                     - move 0,0 to top right corner.
  450.           The values "x" and "y" are ALWAYS relative to the top left corner
  451.           being 0,0.  The window contents are NOT moved and redrawn, but any
  452.           later redrawing WILL use the new origin position.  Positions given
  453.           in the window's graphics string are relative to this window origin
  454.           so changing sthe origin and then redrawing part of a window can
  455.           cause part of the graphics drawn in a window to move.  To stop
  456.           this from happening it is best to move the window origin before
  457.           any graphics is drawn.  If the window origin is to be used to
  458.           scroll a window's contents then a full redraw should be done after
  459.           the call to this routine.  Note that the text overlay and existing
  460.           icons are NOT affected by this routine.  Icons created after the
  461.           change in the origin WILL be affected by the origin position.
  462.         - Returns HASWIN_TRUE if successful, or HASWIN_FALSE on any error.
  463.  
  464. int     haswin_addgraphics(window *win, char *string);
  465.         - Adds the graphics string to the current graphics to be drawn by
  466.           HASWIN automatically.  The string is a printf()like string using
  467.           the '$' symbol to enclose graphics drawing commands.  The
  468.           commands are as follows...
  469.               cx,y,r     draw circle at x,y radius r.
  470.               Cx,y,r     draw filled circle at x,y radius r.
  471.               dx,y       draw line to x,y.
  472.               Dx,y       draw line relative to x,y.
  473.               fn         select foreground colour n for later drawing.
  474.                                (background can't be changed)
  475.               mx,y       move to x,y.
  476.               Mx,y       move relative to x,y.
  477.               rx,y,w,h   draw rectangle x,y width w, height h.
  478.               Rx,y,w,h   draw filled rectangle x,y width w, height h.
  479.  
  480.           Numbers are in screen coordinates and x,y positions are relative
  481.           to the current window origin.  The WIMP's standard 16 colours
  482.           are available to draw with.  A single $$ pair can enclose many
  483.           control sequences and an empty $$ pair prints a single '$'.  Any
  484.           non control symbol (0-9cCdDfmMrR,$) separates commands within $$
  485.           pairs.  For example the sequence...
  486.  
  487.           "$m100,100 f15$This in blue$C250,100,30 m100,150 f11$This in red"
  488.  
  489.           ....displays "This in blue" in colour 15 starting at 100,100, and
  490.           draws a blue, filled circle radius 30 at 250,100, and displays
  491.           "This in red" in colour 11 starting at 100,150.
  492.  
  493. int     haswin_graphicsprintf(window *win, char *fmt, ...);
  494.         - This routine is a printf-like interface to haswin_addgraphics().
  495.         - "win" is the window to draw the graphics in.
  496.         - "fmt" is the format string.
  497.         The routine uses vsprintf() internally to process "fmt" and other
  498.         arguments.
  499.  
  500. int     haswin_textprintf(window *win, char *fmt, ...);
  501.         - This routine is a printf-like interface to haswin_textvdu().  See
  502.           the section of the manual concerning text for details.
  503.         - "win" is the window to draw the graphics in.
  504.         - "fmt" is the format string.
  505.         The routine uses vsprintf() internally to process "fmt" and other
  506.         arguments.
  507.  
  508.         HASWIN keeps a record of all the windows created and therefore four
  509. routines are provided to search the known windows for a particular one.
  510.  
  511. window  *haswin_findmasterhandle(int handle);
  512.         - Given a WIMP window handle "handle" find the master window for
  513.           the window.  The master is the one whos pane or slide window
  514.           this window is.  Windows that are not panes or slides of another
  515.           window are their own master.
  516.         - Returns a pointer to the master window structure for this pane or
  517.           slide, or a pointer to the window whos handle is "handle" if it
  518.           is not a pane or slide of any other window, or HASWIN_FALSE if
  519.           an error occurs.
  520.  
  521. window  *haswin_findmasterwindow(window *win);
  522.         - Given a window "win" find the master window for the window.  The
  523.           master is the one whos pane or slide window this window is.
  524.           Windows that are not panes or slides of another window are their
  525.           own master.
  526.         - Returns a pointer to the master window structure for this pane or
  527.           slide, or "win" if it is not a pane or slide of any other window,
  528.           or HASWIN_FALSE if an error occurs.
  529.  
  530. window  *haswin_findwindowhandle(int handle);
  531.         - Given a WIMP window handle "handle" find the window structure for
  532.           the window.
  533.         - Returns a pointer to the window structure, or HASWIN_FALSE if
  534.           an error occurs.
  535.  
  536. window  *haswin_findwindowname(char *name);
  537.         - Given the name of a window "name" find the window structure for
  538.           the window.
  539.         - Returns a pointer to the window structure, or HASWIN_FALSE if
  540.           an error occurs.
  541.  
  542.  
  543.         To simplify the writing of complex code to convert between screen
  544. coordinates the following routines are provided.  They convert x and y
  545. coordinates from window origin relative to and from real screen coordinates
  546. or text coordinates and compensate for scroll positions and window positions
  547. on the display.  The window does not have to be currently displayed, if it
  548. is not then the values as they would have been if the window was displayed
  549. at its last position are returned.
  550.  
  551. int     haswin_converttxtxtowin(window *win, int x);
  552.         - convert "x" from a text coordinate to relative to the window "win".
  553.           Return "x", or if "x" is outside the window the nearest, or
  554.           HASWIN_UNKNOWN on any error.
  555.  
  556. int     haswin_converttxtxytowin(window *win, int *x, int *y);
  557.         - convert "x" and "y" from text coordinates to relative to the window
  558.           "win" and replace in "x" and "y".  Return HASWIN_TRUE if successful
  559.           or HASWIN_FALSE on any error.
  560.  
  561. int     haswin_converttxtytowin(window *win, int y);
  562.         - convert "y" from a text coordinate to relative to the window "win".
  563.           Return "y", or if "y" is outside the window the nearest, or
  564.           HASWIN_UNKNOWN on any error.
  565.  
  566. int     haswin_convertwinxtotxt(window *win, int x);
  567.         - convert "x" from a position relative to the window "win" to a text
  568.           coordinate.  Return "x", or HASWIN_UNKNOWN on any error.
  569.  
  570. int     haswin_convertwinxytotxt(window *win, int *x, int *y);
  571.         - convert "x" and "y" from coordinates relative to the window "win"
  572.           to text coordinates and replace in "x" and "y". Return HASWIN_TRUE
  573.           if successful or HASWIN_FALSE on any error.
  574.  
  575. int     haswin_convertwinytotxt(window *win, int y);
  576.         - convert "y" from a position relative to the window "win" to a text
  577.           coordinate.  Return "y", or HASWIN_UNKNOWN on any error.
  578.  
  579. int     haswin_convertscrxtowin(window *win, int x);
  580.         - convert "x" from a real screen coordinate to relative to the
  581.           window "win".  Return "x", or if "x" is outside the window
  582.           the nearest, or HASWIN_UNKNOWN on any error.
  583.  
  584. int     haswin_convertscrxytowin(window *win, int *x, int *y);
  585.         - convert "x" and "y" from real screen coordinates to relative
  586.           to the window "win" and replace in "x" and "y".
  587.         - Return HASWIN_TRUE if successful or HASWIN_FALSE on any error.
  588.  
  589. int     haswin_convertscrytowin(window *win, int y);
  590.         - convert "y" from a real screen coordinate to relative to the
  591.           window "win".  Return "y", or if "y" is outside the window
  592.           the nearest, or HASWIN_UNKNOWN on any error.
  593.  
  594. int     haswin_convertwinxtoscr(window *win, int x);
  595.         - convert "x" from a position relative to the window "win" to a real
  596.           screen position.  Return "x", or HASWIN_UNKNOWN on any error.
  597.  
  598. int     haswin_convertwinxytoscr(window *win, int *x, int *y);
  599.         - convert "x" and "y" from coordinates relative to the window "win"
  600.           to real screen coordinates and replace in "x" and "y".
  601.         - Return HASWIN_TRUE if successful or HASWIN_FALSE on any error.
  602.  
  603. int     haswin_convertwinytoscr(window *win, int y);
  604.         - convert "y" from a position relative to the window "win" to a real
  605.           screen position.  Return "y", or HASWIN_UNKNOWN on any error.
  606.  
  607.  
  608.         One of the major functions of the HASWIN library is to allow easy
  609. access to the powerful window drawing functions of the WIMP environment.
  610. To this end HASWIN provides a number of routines to manipulate the basic
  611. display of windows on the screen.  These routines are as follows...
  612.  
  613. int     haswin_openwindow(window *win, , int xmin, int xmax,
  614.                                          int ymin, int ymax,
  615.                                          int scrx, int scry, int bhandle);
  616.         - Mark the window "win" for display on the screen at coordinates
  617.           "xmin","ymin", to "xmax","ymax".  The scroll offsets are set to
  618.           "scrx", "scry" and the window is placed in the WIMP's window
  619.           stack behind window handle "bhandle".  If "bhandle" is -1 the
  620.           window is opened at the top of the stack, and if -2 at the bottom
  621.           of the stack.
  622.         - Returns HASWIN_TRUE if successful and HASWIN_FALSE on any error.
  623.           It is not an error if the size and scroll bars of the window
  624.           lead to an impossible window size, or displayed working area.
  625.           HASWIN does the best it can under these conditions.
  626.         The window will not actually be shown on the display until HASWIN
  627.         starts polling the WIMP again with calls to the haswin_poll()
  628.         routine.
  629.  
  630. void    haswin_closewindow(window *win);
  631.         - Mark the window "win" as not to be displayed.  It will be removed
  632.           and any uncovered windows redrawn when HASWIN starts polling the
  633.           WIMP again with calls to the haswin_poll() routine.
  634.  
  635. int     haswin_forceredraw(window *win, int xmin, int xmax,
  636.                                         int ymin, int ymax);
  637.         - Mark the area from "xmin", "ymin" to "xmax", "ymax" in the window
  638.           "win" to be redrawn later.  If "win" is 0 then the coordinates are
  639.           real screen coordinates and all windows that cover the given area
  640.           will be redrawn (or partly redrawn).  The redraw will not actually
  641.           happen until HASWIN starts polling the WIMP again with calls to
  642.           the haswin_poll() routine.
  643.         - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
  644.           It is not an error for the area to be redrawn to not be currently
  645.           displayed.  In this circumstance no redrawing is done.
  646.  
  647. void    haswin_redrawwindow(window *win, int xmin, int xmax,
  648.                                          int ymin, int ymax);
  649.         - Redraw the area from "xmin", "ymin" to "xmax", "ymax" in the
  650.           window "win" now.  If "win" is 0 then the coordinates are
  651.           real screen coordinates and all windows that cover the given area
  652.           will be redrawn (or partly redrawn).  It is dangerous to call this
  653.           routine from within a window drawroutine() or openroutine().  At
  654.           present HASWIN does not trap such use of the routine, but the WIMP
  655.           can get very confused.
  656.         - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
  657.           It is not an error for the area to be redrawn to not be currently
  658.           displayed.  In this circumstance no redrawing is done.
  659.  
  660. int     haswin_reopenwindow(window *win);
  661.         - Cause the window "win" to be displayed on the screen in the same
  662.           place it was displayed last time.  This includes its position in
  663.           the WIMP's window stack.  If "win" has not been displayed before
  664.           it is opened with its bottom left corner in the bottom left of the
  665.           screen.  The window will not actually be opened until HASWIN
  666.           starts polling the WIMP again with calls to the haswin_poll()
  667.           routine.
  668.         - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
  669.  
  670.  
  671. While HASWIN is active and processing (see below) it automatically monitors
  672. changes in the screen and keeps the data structures associated with the
  673. windows updated.  However it is possible to force HASWIN is update its
  674. idea of a window's characteristics with the two routines below...
  675.  
  676. void    haswin_updatefullwindowinfo(window *win);
  677.         - forces HASWIN to determine ALL window characteristics by
  678.           interrogating the WIMP directly.  The following are updated
  679.           from the WIMP's tables...
  680.           a)  window screen X,Y positions, sizes and scroll offsets.
  681.           b)  handle of window in front of this one.
  682.           c)  window extent X,Y sizes.
  683.           d)  window colours.
  684.           e)  window flags.
  685.           f)  window title information.
  686.           g)  number of icons and icon definitions.
  687.  
  688. void    haswin_updatewindowinfo(window *win);
  689.         - forces HASWIN to determine some window characteristics by
  690.           interrogating the WIMP directly.  The following are updated
  691.           from the WIMP's tables...
  692.           a)  window screen X,Y positions, sizes and scroll offsets.
  693.           b)  handle of window in front of this one.
  694.           c)  window flags.
  695.  
  696. HASWIN contains code to redirect drawing operations into sprites.  A single
  697. routine provides a user interface to this code.  The routine is described
  698. below.
  699.  
  700. int     haswin_windowtosprite(window *win, char *sname);
  701.         - Create a new sprite called "sname" in the user area.  Then setup
  702.           HASWIN to redirect screen output to the sprite.  After that force
  703.           a complete screen redraw of the window "win" and then switch the
  704.           redirection off and resynchronise the underlying WIMP.  If both
  705.           "win" and "sname" are 0 then initialise the HASWIN code to perform
  706.           this redirection, but don't actually do anything.
  707.         - haswin_initialise() performs the call haswin_windowtosprite(0, 0)
  708.           to do the initialisation.
  709.         - Return HASWIN_TRUE if successful or HASWIN_FALSE on any error.
  710.  
  711.  
  712. It is possible to make HASWIN respond to windows it has not created itself
  713. or to prevent HASWIN from responding to its own windows.  If a window is
  714. not a true HASWIN one many of the features of HASWIN are, of course, not
  715. available, but many parts of HASWIN can still be used.  HASWIN maintains a
  716. list of windows called the active list that contains all the windows that
  717. HASWIN will respond to.  HASWIN windows are added to the list automatically
  718. when created, but may be removed and replaced at any time.  If a window is
  719. not in the active list HASWIN will not automatically respond to closes of
  720. the window, drags, mouse operations including entering or leaving the
  721. window, or menu operations in the window, or keys pressed while the window
  722. is selected as the input focus.  HASWIN must always respond to window open
  723. and redraw requests.  Operations not responded to are lost, not buffered for
  724. later response.  The icon bar is always in the active list.
  725. Three HASWIN routines are provided to access the active
  726. list.
  727.  
  728. int     haswin_addactivelist(int handle);
  729.         - adds a new window to the active windows list.
  730.           - "handle" is the WIMP window handle to be added.
  731.         - returns HASWIN_TRUE if the window was added successfully, or
  732.           HASWIN_FALSE otherwise.
  733.  
  734. int     haswin_inactivelist(int handle);
  735.         - find out if a window is in the active windows list.
  736.           - "handle" is the WIMP window handle to be looked up.
  737.         - returns HASWIN_TRUE if the window in in the active list, or
  738.           HASWIN_FALSE otherwise.
  739.  
  740. int     haswin_removeactivelist(int handle);
  741.         - remove a window from the active windows list.
  742.           - "handle" is the WIMP window handle to be removed.
  743.         - returns HASWIN_TRUE if the window was removed successfully, or
  744.           HASWIN_FALSE if the window was not in the list or otherwise.
  745.  
  746. Drawing HASWIN windows.
  747. ------------------------
  748.         HASWIN performs several operations automatically when a window is to
  749. be redrawn.  These actions are described in detail in the section of the
  750. manual concerned with the WIMP Poll routines.  These actions make the
  751. contents of a window appear consistantly.  A window is made up of several
  752. overlayed layers.  These layers are drawn in sequence so that consistancy is
  753. maintained.  Drawing occurs in the following order.
  754.  
  755.         1)      The border of the window is drawn.
  756.         2)      If a user draw routine is defined it is called to draw the
  757.                 user graphics.  If there is no user routinedefined , or if
  758.                 it returns HASWIN_TRUE then steps 3) and 4) are performed.
  759.         3)      Any text area overlay is drawn.
  760.         4)      Any graphics overlay is drawn.
  761.  
  762.