home *** CD-ROM | disk | FTP | other *** search
-
- The HASWIN window library.
- ===========================
- Copyright H.A. Shaw 1990.
- ===========================
-
- The HASWIN window.
- -------------------
- The HASWIN window is a data structure created and maintained by
- the HASWIN routines. A window has the following user selected features.
- 1) - A set of flags for the various parts of the window, defined at
- the creation of the window, some of which may be altered later.
- 2) - Colours for title bar foreground and background, scroll bar outer
- and inner, work area foreground and background, and for the input
- focus. These are also defined when the window is created, but may
- be altered later.
- 3) - Graphics that will be automatically redrawn by HASWIN. HASWIN
- allows text and lines, rectangles and circles to be drawn at any
- position in any window in any of the WIMPs 16 standard colours.
- Initialliy no graphics is added to the window, but routines exist
- for adding, or removing the graphics at any time. Graphics is
- defined as a printf() like string.
- 4) - Text that will be automatically redrawn by HASWIN. HASWIN allows
- text to be positioned in a 2-D grid in a foreground and background
- colour. The text area may be larger or smaller than the window
- itself and text may be automatically inserted by HASWIN in responce
- to mouse actions in the window and keypresses in the window.
- 5) - A pointer made from a sprite that will be automatically selected
- when the mouse is placed over the window.
- 6) - A menu that is opened when the MENU mouse button is clicked in the
- window.
- 7) - A HASWIN window that contains help information that HASWIN will
- automatically open on request from the user.
- 8) - A text string to be sent to an application on request for Help
- information about the window.
- 9) - A HASWIN window called a "pane window" that is opened, closed or
- moved whenever the main window is opened, closed or moved. This
- window may also have panes and therefore can form a linked list
- of windows that open, close and move together. If a pane window
- is selected then the main window gets the input focus unless the
- pane window has its WINDOW_FOCUS bit set.
- 10) - A HASWIN window called a "slide window" that behaves exactly as
- if it was a pane window except that is also scrolls as the main
- window scrolls. Slide windows may themselves have slide windows.
-
- The user program provides a series of routines which HASWIN calls
- when something happens to a window that HASWIN cannot deal with directly.
- HASWIN makes intellegent guesses about which of the routines it is supplied
- with to use under any circumstance, and contains internal routines to use
- when the user program does not supply one. The routine is automatically
- passed all relevant information by HASWIN when called.
- openroutine() - called when the window is opened, or reopened at a
- new position.
- drawroutine() - called when a section of the window must be
- redrawn.
- dragroutine() - called when a drag is first started, and again when
- it is completed.
- keyroutine() - called when a key is pressed when the window has the
- input focus.
- mousebutton() - called when the mouse buttons are pressed in the
- window and there is no other action.
-
- A window is created by the following routines...
-
- window *haswin_loadwindow(char *name, int flags);
- - load a window from the currently opened Template file.
- - "name" is the template file window identifier.
- - "flgs" is the HASWIN flags for this window (in addition to
- flags already in the template file).
- - returns a pointer to the window structure, or 0 if the window
- could not be created.
-
- window *haswin_loadpanewindow(window *main, char *name, int flgs);
- - load a pane window from the currently opened Template file.
- - "main" is the master window for this pane.
- - "name" is the template file window identifier.
- - "flgs" is the HASWIN flags for this window (in addition to
- flags already in the template file).
- - returns a pointer to the window structure, or 0 if the window
- could not be created.
-
- window *haswin_loadslidewindow(window *main, char *name, int flgs);
- - load a slide window from the currently opened Template file.
- - "main" is the master window for this pane.
- - "name" is the template file window identifier.
- - "flgs" is the HASWIN flags for this window (in addition to
- flags already in the template file).
- - returns a pointer to the window structure, or 0 if the window
- could not be created.
-
- window *haswin_makewindow(char *title, int x, int y, int tf, int tb,
- int wf, int wb, int flgs);
- - make a new window (restrictions are described below).
- - "title" is the window title.
- - "x" is the X size.
- - "y" is the Y size.
- - "tf" is the text foreground colour.
- - "tb" is the text background colour.
- - "wf" is the work foreground colour.
- - "wb" is the work background colour.
- - "flgs" is the HASWIN window flags.
- - returns a pointer to the window structure, or 0 if the window
- could not be created.
-
- window *haswin_makepanewindow(window *main, char *title, int x, int y,
- int tf, int tb, int wf, int wb, int flgs);
- - make a new pane window (restrictions are described below).
- - "main" is the master window for this pane.
- - "title" is the window title.
- - "x" is the X size.
- - "y" is the Y size.
- - "tf" is the text foreground colour.
- - "tb" is the text background colour.
- - "wf" is the work foreground colour.
- - "wb" is the work background colour.
- - "flgs" is the HASWIN window flags.
- - returns a pointer to the window structure, or 0 if the window
- could not be created.
-
- window *haswin_makeslidewindow(window *main, char *title, int x, int y,
- int tf, int tb, int wf, int wb, int flgs);
- - make a new slide window (restrictions are described below).
- - "main" is the master window for this slide.
- - "title" is the window title.
- - "x" is the X size.
- - "y" is the Y size.
- - "tf" is the text foreground colour.
- - "tb" is the text background colour.
- - "wf" is the work foreground colour.
- - "wb" is the work background colour.
- - "flgs" is the HASWIN window flags.
- - returns a pointer to the window structure, or 0 if the window
- could not be created.
-
- window *haswin_copywindow(window *win);
- - copy the window structure "win" to a new window. All data areas
- within the window are copied into new dynamically allocated memory
- and the pointers within the new window structure arranged to point
- to the new data areas. Therefore after a copy one window may be
- modified (or even deleted) without regard to the other. All pane
- and slide windows belonging to "win" are also copied in their
- entirety. The new windows are not opened for display.
- - Returns the new window structure, or HASWIN_FALSE on any error.
-
-
- The windows that can be made with haswin_make(pane/slide)window()
- are slightly restricted in the following way.
- a) The input focus colour is always "white" (WIMP colour 0).
- b) The title is always text only in the system font.
- There are no restrictions on the windows that may be loaded from templates.
-
- If windows can be created then, of course, they may be deleted. A
- HASWIN routine is provided to do this.
-
- void haswin_deletewindow(window *win);
- - Remove the window "win" from the WIMP's tables. This removes the
- window from the display, frees all space used by the WIMP for the
- window and its icons and then removes the window and its icons
- from HASWIN's tables as well. This is then repeated for all of
- the window's panes and slides.
-
- "flgs" is an integer made up from the following bits...
- a) Bits that create the window's features...
- WINDOW_MOVEABLE window may move
- WINDOW_TRESPASS window may move off screen
- WINDOW_GCOL window colours are GCOL numbers
- WINDOW_BACKDROP window cannot have things under it
- WINDOW_BACKICON window has a back icon
- WINDOW_CLOSEICON window has a close icon
- WINDOW_TITLE_BAR window has a title bar
- WINDOW_FULLICON window has a toggle size icon
- WINDOW_V_SCROLL window has a vertical scroll bar
- WINDOW_SIZEICON window has a adjust size icon
- WINDOW_H_SCROLL window has a horizontal scroll bar
- WINDOW_STDWINDOW <combination of flags that produced a
- "standard window">
- b) Bits that control the window's behaviour. These are not stored in
- template files, but must be added in the "flgs" parameter of the
- "haswin_load(pane/slide)window()" routine...
- WINDOW_TEMP delete window on close
- WINDOW_DRAGSEL we may drag select in this window
- WINDOW_DRAGADJ we may drag adjust in this window
- WINDOW_FILER open a filer from the window's name on close
- with the ADJUST button
- WINDOW_AUTOTEXT create a text window overlay for the window on
- creation of the window. The window is adjusted
- in size to the next whole number of characters in
- width and height. The scroll amounts are made
- adjusted to fit with character sizes. If this is
- set then the caret or characters are placed in
- the text automatically when mouse actions occur
- in the window.
- WINDOW_SELECT select window on mouse entry
- WINDOW_HELPFUL respond to !Help application
- c) Bits that control the window's work area button type...
- WINDOW_BUTTON_NEVER Respond only to MENU button
- WINDOW_BUTTON_ALWAYS Respond whenever in window
- WINDOW_BUTTON_REPEAT Respond to SELECT/ADJUST with repeat
- WINDOW_BUTTON_CLICK Respond to SELECT/ADJUST once
- WINDOW_BUTTON_RELEASE Respond to SELECT/ADJUST when released
- WINDOW_BUTTON_DCLICK Respond to Double clicks on SELECT/ADJUST
- WINDOW_BUTTON_CLICKDRAG As WINDOW_BUTTON_CLICK + DRAG
- WINDOW_BUTTON_RELEASEDRAG As WINDOW_BUTTON_RELEASE + DRAG
- WINDOW_BUTTON_DOUBLEDRAG As WINDOW_BUTTON_DCLICK + DRAG
- WINDOW_BUTTON_MENU Respond as a MENU button.
- WINDOW_BUTTON_EVERYTHING Respond to everything
- WINDOW_BUTTON_RADIO Respond as if a Radio button.
- WINDOW_BUTTON_SILENT This is a HASWIN type, respond to nothing
- WINDOW_BUTTON_13 Unused
- WINDOW_BUTTON_WRITECLICK Writable + click
- WINDOW_BUTTON_WRITABLE Writable
- WINDOW_BUTTON_DEFAULT Default HASWIN button type.
-
- These window flags may be modified after window creation by use of
- the three routines described below...
-
- int haswin_clearwindowflags(window *win, int flgs);
- - clear the window flags specified in "flgs" for the window "win".
- - returns HASWIN_TRUE if successful, and HASWIN_FALSE on any error.
-
- int haswin_newwindowflags(window *win, int flgs);
- - reset the window flags to the value "flgs" for the window "win".
- - returns HASWIN_TRUE if successful, and HASWIN_FALSE on any error.
-
- int haswin_setwindowflags(window *win, int flgs);
- - set the window flags specified in "flgs" for the window "win".
- - returns HASWIN_TRUE if successful, and HASWIN_FALSE on any error.
-
-
- After the creation of a window the various user defined fields may
- be accessed directly in order to set them up. Normal assignment operations
- may be performed and these variables may be read from or written to at any
- time. It is dangerous to use locally defined absolute storage for the
- fields "pointer", "caret", "menu", "help", or "helpmsg". It is best to
- allocate dynamic storage for them using the functions provided. The user
- fields are as follows:
-
- short pagex;
- - amount to scroll in response to "page scroll X direction" request.
- 0 uses WIMP standard default, negative numbers scroll "the wrong
- way".
-
- short pagey;
- - amount to scroll in response to "page scroll Y direction" request.
- 0 uses WIMP standard default, negative numbers scroll "the wrong
- way".
-
- short scrollx;
- - amount to scroll in response to "line scroll X direction" request.
- 0 uses WIMP standard default, negative numbers scroll "the wrong
- way".
-
- short scrolly;
- - amount to scroll in response to "line scroll Y direction" request.
- 0 uses WIMP standard default, negative numbers scroll "the wrong
- way".
-
- struct pointer *pointer;
- - pointer structure to define a mouse pointer to select when the
- mouse is over the window, or 0 for no pointer change.
-
- struct caret *caret;
- - caret structure to use when the window is selected as the input
- focus, or 0 for no caret on selection.
-
- struct menu *menu;
- - menu structure to use when a menu must be opened in the window,
- usually in response to a MENU mouse button click in the window
- work area, or 0 for no menu.
-
- struct window *help;
- - window structure to open when the user selects Window for the Help
- sub-menu of a menu opened in the window, or 0 for no help window.
-
- char *helpmsg;
- - text string to be sent in response to a HelpRequest message from
- another task (usually !Help) when this window is quoted.
-
- int (*mousebutton)(struct window *win, buffer *buff);
- - routine to call on mouse buton press in the window if there is
- no other action to perform. This is called when the following
- mouse actions occur.
- SELECT - always.
- MENU - if there is no menu defined.
- ADJUST - always.
- SELECT DRAG - if there is no dragroutine defined.
- ADJUST DRAG - if there is no dragroutine defined.
- SELECT DOUBLE CLICK - always.
- ADJUST DOUBLE CLICK - always.
- - "win" is the window structure, so that one "mousebutton()" routine
- can service several windows.
- - "buff" is the Mouse_Click buffer obtained from SWI(WIMP_Poll).
- - returns HASWIN_TRUE if successful or HASWIN_FALSE to prevent
- HASWIN from continuing default processing of the mouse click.
- - 0 means that there is no routine.
-
- int (*drawroutine)(struct window *win, buffer *buff);
- - This routine is called by HASWIN to redraw a part of the window.
- The WIMP divides the area to be redrawn into a number (perhaps 1)
- of non overlapping rectangles, and this routine will automatically
- be called once for each of the rectangles to be redrawn. HASWIN
- takes care of all the code to do this, the routine just receives
- the data blocks for redrawing each rectangular area.
- - "win" is the window structure, so that one "drawroutine()" routine
- can service several windows.
- - "buff" is the buffer obtained from SWI(WIMP_RedrawWindow) or
- SWI(WIMP_GetRectangle).
- - returns HASWIN_TRUE if successful or HASWIN_FALSE to prevent
- HASWIN from continuing default processing of the redraw window
- sequence.
- - 0 means that there is no routine.
-
- int (*openroutine)(struct window *win, buffer *buff);
- - This routine is called to open the window, or to reopen the window
- at a new place after a move, drag of the scroll bars or Adjust
- Size icon of the window.
- - "win" is the window structure, so that one "openroutine()" routine
- can service several windows.
- - "buff" is the Open_Window_Request buffer obtained from
- SWI(WIMP_Poll).
- - returns HASWIN_TRUE if successful or HASWIN_FALSE to prevent
- HASWIN from continuing default processing of the window open.
- - 0 means that there is no routine.
-
- int (*keyroutine)(struct window *win, buffer *buff);
- - This routine is called when a key is pressed while the window is
- selected as the input focus. The key is passed to the routine
- only if HASWIN cannot deal with it directly. HASWIN automatically
- deals with the following keys.
- F1 - F9 - the 1st to 9th icon (in order of definition ie. icon
- handle) with a SELECT action is selected as if it had
- been "clicked" with the SELECT mouse button.
- If the WINDOW_AUTOTEXT flag is set and the window has a text
- overlay then the character is passed to haswin_textvdu() so that
- it may be added to the window text overlay automatically.
- - "win" is the window structure, so that one "keyroutine()" routine
- can service several windows.
- - "buff" is the Key_Pressed buffer obtained from SWI(WIMP_Poll).
- - returns HASWIN_TRUE if successful or HASWIN_FALSE to prevent
- HASWIN from continuing default processing of the keypress.
- - 0 means that there is no routine.
-
- int (*dragroutine)(struct window *win, struct icon *ic,
- struct pointer *mouse, buffer *buff);
- - This routine is called when a drag, either with the SELECT or
- ADJUST mouse buttons is performed in the window.
- At the beginning of the drag operation it is called with "win"
- the window and "ic" the icon to be dragged, "mouse" is the current
- mouse pointer and "buff" = 0. If HASWIN_TRUE is returned the drag
- operation is started and if HASWIN_FALSE is returned no further
- action is performed.
- At the end of the drag operation it is called again with "win"
- set to the window and "ic" the icon dragged, "mouse" the pointer
- as it was when the drag started, and "buff" the User_Drag_Box
- buffer from SWI(WIMP_Poll).
- - 0 means that there is no routine.
-
-
- Various parts of the window's definition may be determined by the
- following routines...
-
- int haswin_getwindowbhandle(window *win);
- - returns the handle of the window in front of "win" in the WIMP's
- window stack, or -1 if "win" is the top window, -2 if "win" is
- the bottom window or HASWIN_FALSE on an error.
-
- int haswin_getwindowcaret(window *win, int *x, int *y);
- - fills the x,y coordinates of the window's caret into "x" and "y"
- - returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_getwindowflags(window *win);
- - returns the flags for the window "win".
- or HASWIN_FALSE on an error.
-
- char *haswin_getwindowname(window *win);
- - returns the name for the window "win". This is the template
- identifier if the window was created from a template file
- with "haswin_load(pane/slide)window()" routines, or the
- window title on creation of the window if created with the
- "haswin_make(pane/slide)window()" routines or 0 on an error.
-
- char *haswin_getwindowtitle(window *win);
- - returns the contents of the title for the window "win" or 0 on
- an error.
-
- int haswin_getwindowxextent(window *win);
- - returns the X-coordinate of the work area extent for the
- window "win". or HASWIN_UNKNOWN on any error.
-
- int haswin_getwindowxorigin(window *win);
- - returns the X-coordinate of the origin of the work area coordinate
- system for the window "win". or HASWIN_UNKNOWN on any error.
-
- int haswin_getwindowxmax(window *win);
- - returns the maximum X-coordinate of the work area for the
- window "win". or HASWIN_UNKNOWN on any error.
-
- int haswin_getwindowxmin(window *win);
- - returns the minimum X-coordinate of the work area for the
- window "win". or HASWIN_UNKNOWN on any error.
-
- int haswin_getwindowxscroll(window *win);
- - returns the scroll position in the X direction for the window
- "win". or HASWIN_UNKNOWN on any error.
-
- int haswin_getwindowyextent(window *win);
- - returns the Y-coordinate of the work area extent for the window
- "win". or HASWIN_UNKNOWN on any error.
-
- int haswin_getwindowyorigin(window *win);
- - returns the Y-coordinate of the origin of the work area coordinate
- system for the window "win". or HASWIN_UNKNOWN on any error.
-
- int haswin_getwindowymax(window *win);
- - returns the maximum Y-coordinate of the work area for the window
- "win". or HASWIN_UNKNOWN on any error.
-
- int haswin_getwindowymin(window *win);
- - returns the minimum Y-coordinate of the work area for the window
- "win". or HASWIN_UNKNOWN on any error.
-
- int haswin_getwindowyscroll(window *win);
- - returns the scroll position in the Y direction for the window
- "win". or HASWIN_UNKNOWN on any error.
-
-
- The following routines allow the various window characteristics to be
- altered.
-
- int haswin_resizewindow(window *win, int x, int y, int redraw);
- - Alter the size of the window "win". If the window is being
- displayed and "x" or "y" are smaller than the current displayed
- window then the displayed window is reduced in size and the
- window redrawn. If "redraw" is true then a complete redraw of the
- window is forced if the window is being displayed.
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_setwindoworigin(window *win, int x, int y);
- - Move the origin of the window "win" to absolute position "x","y".
- The values in "x" and "y" are in screen coordinates and 0,0 is the
- top left of the window. For example, for a window 100 by 150...
- haswin_setwindoworigin(win, 0, -150);
- - move 0,0 to bottom left corner.
- haswin_setwindoworigin(win, 100, -150);
- - move 0,0 to bottom right corner.
- haswin_setwindoworigin(win, 0, 0);
- - move 0,0 to top left corner.
- haswin_setwindoworigin(win, 100, 0);
- - move 0,0 to top right corner.
- The values "x" and "y" are ALWAYS relative to the top left corner
- being 0,0. The window contents are NOT moved and redrawn, but any
- later redrawing WILL use the new origin position. Positions given
- in the window's graphics string are relative to this window origin
- so changing sthe origin and then redrawing part of a window can
- cause part of the graphics drawn in a window to move. To stop
- this from happening it is best to move the window origin before
- any graphics is drawn. If the window origin is to be used to
- scroll a window's contents then a full redraw should be done after
- the call to this routine. Note that the text overlay and existing
- icons are NOT affected by this routine. Icons created after the
- change in the origin WILL be affected by the origin position.
- - Returns HASWIN_TRUE if successful, or HASWIN_FALSE on any error.
-
- int haswin_addgraphics(window *win, char *string);
- - Adds the graphics string to the current graphics to be drawn by
- HASWIN automatically. The string is a printf()like string using
- the '$' symbol to enclose graphics drawing commands. The
- commands are as follows...
- cx,y,r draw circle at x,y radius r.
- Cx,y,r draw filled circle at x,y radius r.
- dx,y draw line to x,y.
- Dx,y draw line relative to x,y.
- fn select foreground colour n for later drawing.
- (background can't be changed)
- mx,y move to x,y.
- Mx,y move relative to x,y.
- rx,y,w,h draw rectangle x,y width w, height h.
- Rx,y,w,h draw filled rectangle x,y width w, height h.
-
- Numbers are in screen coordinates and x,y positions are relative
- to the current window origin. The WIMP's standard 16 colours
- are available to draw with. A single $$ pair can enclose many
- control sequences and an empty $$ pair prints a single '$'. Any
- non control symbol (0-9cCdDfmMrR,$) separates commands within $$
- pairs. For example the sequence...
-
- "$m100,100 f15$This in blue$C250,100,30 m100,150 f11$This in red"
-
- ....displays "This in blue" in colour 15 starting at 100,100, and
- draws a blue, filled circle radius 30 at 250,100, and displays
- "This in red" in colour 11 starting at 100,150.
-
- int haswin_graphicsprintf(window *win, char *fmt, ...);
- - This routine is a printf-like interface to haswin_addgraphics().
- - "win" is the window to draw the graphics in.
- - "fmt" is the format string.
- The routine uses vsprintf() internally to process "fmt" and other
- arguments.
-
- int haswin_textprintf(window *win, char *fmt, ...);
- - This routine is a printf-like interface to haswin_textvdu(). See
- the section of the manual concerning text for details.
- - "win" is the window to draw the graphics in.
- - "fmt" is the format string.
- The routine uses vsprintf() internally to process "fmt" and other
- arguments.
-
- HASWIN keeps a record of all the windows created and therefore four
- routines are provided to search the known windows for a particular one.
-
- window *haswin_findmasterhandle(int handle);
- - Given a WIMP window handle "handle" find the master window for
- the window. The master is the one whos pane or slide window
- this window is. Windows that are not panes or slides of another
- window are their own master.
- - Returns a pointer to the master window structure for this pane or
- slide, or a pointer to the window whos handle is "handle" if it
- is not a pane or slide of any other window, or HASWIN_FALSE if
- an error occurs.
-
- window *haswin_findmasterwindow(window *win);
- - Given a window "win" find the master window for the window. The
- master is the one whos pane or slide window this window is.
- Windows that are not panes or slides of another window are their
- own master.
- - Returns a pointer to the master window structure for this pane or
- slide, or "win" if it is not a pane or slide of any other window,
- or HASWIN_FALSE if an error occurs.
-
- window *haswin_findwindowhandle(int handle);
- - Given a WIMP window handle "handle" find the window structure for
- the window.
- - Returns a pointer to the window structure, or HASWIN_FALSE if
- an error occurs.
-
- window *haswin_findwindowname(char *name);
- - Given the name of a window "name" find the window structure for
- the window.
- - Returns a pointer to the window structure, or HASWIN_FALSE if
- an error occurs.
-
-
- To simplify the writing of complex code to convert between screen
- coordinates the following routines are provided. They convert x and y
- coordinates from window origin relative to and from real screen coordinates
- or text coordinates and compensate for scroll positions and window positions
- on the display. The window does not have to be currently displayed, if it
- is not then the values as they would have been if the window was displayed
- at its last position are returned.
-
- int haswin_converttxtxtowin(window *win, int x);
- - convert "x" from a text coordinate to relative to the window "win".
- Return "x", or if "x" is outside the window the nearest, or
- HASWIN_UNKNOWN on any error.
-
- int haswin_converttxtxytowin(window *win, int *x, int *y);
- - convert "x" and "y" from text coordinates to relative to the window
- "win" and replace in "x" and "y". Return HASWIN_TRUE if successful
- or HASWIN_FALSE on any error.
-
- int haswin_converttxtytowin(window *win, int y);
- - convert "y" from a text coordinate to relative to the window "win".
- Return "y", or if "y" is outside the window the nearest, or
- HASWIN_UNKNOWN on any error.
-
- int haswin_convertwinxtotxt(window *win, int x);
- - convert "x" from a position relative to the window "win" to a text
- coordinate. Return "x", or HASWIN_UNKNOWN on any error.
-
- int haswin_convertwinxytotxt(window *win, int *x, int *y);
- - convert "x" and "y" from coordinates relative to the window "win"
- to text coordinates and replace in "x" and "y". Return HASWIN_TRUE
- if successful or HASWIN_FALSE on any error.
-
- int haswin_convertwinytotxt(window *win, int y);
- - convert "y" from a position relative to the window "win" to a text
- coordinate. Return "y", or HASWIN_UNKNOWN on any error.
-
- int haswin_convertscrxtowin(window *win, int x);
- - convert "x" from a real screen coordinate to relative to the
- window "win". Return "x", or if "x" is outside the window
- the nearest, or HASWIN_UNKNOWN on any error.
-
- int haswin_convertscrxytowin(window *win, int *x, int *y);
- - convert "x" and "y" from real screen coordinates to relative
- to the window "win" and replace in "x" and "y".
- - Return HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_convertscrytowin(window *win, int y);
- - convert "y" from a real screen coordinate to relative to the
- window "win". Return "y", or if "y" is outside the window
- the nearest, or HASWIN_UNKNOWN on any error.
-
- int haswin_convertwinxtoscr(window *win, int x);
- - convert "x" from a position relative to the window "win" to a real
- screen position. Return "x", or HASWIN_UNKNOWN on any error.
-
- int haswin_convertwinxytoscr(window *win, int *x, int *y);
- - convert "x" and "y" from coordinates relative to the window "win"
- to real screen coordinates and replace in "x" and "y".
- - Return HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
- int haswin_convertwinytoscr(window *win, int y);
- - convert "y" from a position relative to the window "win" to a real
- screen position. Return "y", or HASWIN_UNKNOWN on any error.
-
-
- One of the major functions of the HASWIN library is to allow easy
- access to the powerful window drawing functions of the WIMP environment.
- To this end HASWIN provides a number of routines to manipulate the basic
- display of windows on the screen. These routines are as follows...
-
- int haswin_openwindow(window *win, , int xmin, int xmax,
- int ymin, int ymax,
- int scrx, int scry, int bhandle);
- - Mark the window "win" for display on the screen at coordinates
- "xmin","ymin", to "xmax","ymax". The scroll offsets are set to
- "scrx", "scry" and the window is placed in the WIMP's window
- stack behind window handle "bhandle". If "bhandle" is -1 the
- window is opened at the top of the stack, and if -2 at the bottom
- of the stack.
- - Returns HASWIN_TRUE if successful and HASWIN_FALSE on any error.
- It is not an error if the size and scroll bars of the window
- lead to an impossible window size, or displayed working area.
- HASWIN does the best it can under these conditions.
- The window will not actually be shown on the display until HASWIN
- starts polling the WIMP again with calls to the haswin_poll()
- routine.
-
- void haswin_closewindow(window *win);
- - Mark the window "win" as not to be displayed. It will be removed
- and any uncovered windows redrawn when HASWIN starts polling the
- WIMP again with calls to the haswin_poll() routine.
-
- int haswin_forceredraw(window *win, int xmin, int xmax,
- int ymin, int ymax);
- - Mark the area from "xmin", "ymin" to "xmax", "ymax" in the window
- "win" to be redrawn later. If "win" is 0 then the coordinates are
- real screen coordinates and all windows that cover the given area
- will be redrawn (or partly redrawn). The redraw will not actually
- happen until HASWIN starts polling the WIMP again with calls to
- the haswin_poll() routine.
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
- It is not an error for the area to be redrawn to not be currently
- displayed. In this circumstance no redrawing is done.
-
- void haswin_redrawwindow(window *win, int xmin, int xmax,
- int ymin, int ymax);
- - Redraw the area from "xmin", "ymin" to "xmax", "ymax" in the
- window "win" now. If "win" is 0 then the coordinates are
- real screen coordinates and all windows that cover the given area
- will be redrawn (or partly redrawn). It is dangerous to call this
- routine from within a window drawroutine() or openroutine(). At
- present HASWIN does not trap such use of the routine, but the WIMP
- can get very confused.
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
- It is not an error for the area to be redrawn to not be currently
- displayed. In this circumstance no redrawing is done.
-
- int haswin_reopenwindow(window *win);
- - Cause the window "win" to be displayed on the screen in the same
- place it was displayed last time. This includes its position in
- the WIMP's window stack. If "win" has not been displayed before
- it is opened with its bottom left corner in the bottom left of the
- screen. The window will not actually be opened until HASWIN
- starts polling the WIMP again with calls to the haswin_poll()
- routine.
- - Returns HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
-
- While HASWIN is active and processing (see below) it automatically monitors
- changes in the screen and keeps the data structures associated with the
- windows updated. However it is possible to force HASWIN is update its
- idea of a window's characteristics with the two routines below...
-
- void haswin_updatefullwindowinfo(window *win);
- - forces HASWIN to determine ALL window characteristics by
- interrogating the WIMP directly. The following are updated
- from the WIMP's tables...
- a) window screen X,Y positions, sizes and scroll offsets.
- b) handle of window in front of this one.
- c) window extent X,Y sizes.
- d) window colours.
- e) window flags.
- f) window title information.
- g) number of icons and icon definitions.
-
- void haswin_updatewindowinfo(window *win);
- - forces HASWIN to determine some window characteristics by
- interrogating the WIMP directly. The following are updated
- from the WIMP's tables...
- a) window screen X,Y positions, sizes and scroll offsets.
- b) handle of window in front of this one.
- c) window flags.
-
- HASWIN contains code to redirect drawing operations into sprites. A single
- routine provides a user interface to this code. The routine is described
- below.
-
- int haswin_windowtosprite(window *win, char *sname);
- - Create a new sprite called "sname" in the user area. Then setup
- HASWIN to redirect screen output to the sprite. After that force
- a complete screen redraw of the window "win" and then switch the
- redirection off and resynchronise the underlying WIMP. If both
- "win" and "sname" are 0 then initialise the HASWIN code to perform
- this redirection, but don't actually do anything.
- - haswin_initialise() performs the call haswin_windowtosprite(0, 0)
- to do the initialisation.
- - Return HASWIN_TRUE if successful or HASWIN_FALSE on any error.
-
-
- It is possible to make HASWIN respond to windows it has not created itself
- or to prevent HASWIN from responding to its own windows. If a window is
- not a true HASWIN one many of the features of HASWIN are, of course, not
- available, but many parts of HASWIN can still be used. HASWIN maintains a
- list of windows called the active list that contains all the windows that
- HASWIN will respond to. HASWIN windows are added to the list automatically
- when created, but may be removed and replaced at any time. If a window is
- not in the active list HASWIN will not automatically respond to closes of
- the window, drags, mouse operations including entering or leaving the
- window, or menu operations in the window, or keys pressed while the window
- is selected as the input focus. HASWIN must always respond to window open
- and redraw requests. Operations not responded to are lost, not buffered for
- later response. The icon bar is always in the active list.
- Three HASWIN routines are provided to access the active
- list.
-
- int haswin_addactivelist(int handle);
- - adds a new window to the active windows list.
- - "handle" is the WIMP window handle to be added.
- - returns HASWIN_TRUE if the window was added successfully, or
- HASWIN_FALSE otherwise.
-
- int haswin_inactivelist(int handle);
- - find out if a window is in the active windows list.
- - "handle" is the WIMP window handle to be looked up.
- - returns HASWIN_TRUE if the window in in the active list, or
- HASWIN_FALSE otherwise.
-
- int haswin_removeactivelist(int handle);
- - remove a window from the active windows list.
- - "handle" is the WIMP window handle to be removed.
- - returns HASWIN_TRUE if the window was removed successfully, or
- HASWIN_FALSE if the window was not in the list or otherwise.
-
- Drawing HASWIN windows.
- ------------------------
- HASWIN performs several operations automatically when a window is to
- be redrawn. These actions are described in detail in the section of the
- manual concerned with the WIMP Poll routines. These actions make the
- contents of a window appear consistantly. A window is made up of several
- overlayed layers. These layers are drawn in sequence so that consistancy is
- maintained. Drawing occurs in the following order.
-
- 1) The border of the window is drawn.
- 2) If a user draw routine is defined it is called to draw the
- user graphics. If there is no user routinedefined , or if
- it returns HASWIN_TRUE then steps 3) and 4) are performed.
- 3) Any text area overlay is drawn.
- 4) Any graphics overlay is drawn.
-
-