home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / desklib / !DeskLib / h / Window < prev   
Encoding:
Text File  |  1994-05-29  |  9.3 KB  |  212 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Window.h
  12.     Author:  Copyright © 1992, 1993 Jason Williams
  13.     Version: 1.03 (29 June 1993)
  14.     Purpose: High-level window management functions
  15. */
  16.  
  17.  
  18. #ifndef __dl_window_h
  19. #define __dl_window_h
  20.  
  21. #ifndef __dl_wimp_h
  22. #include "Wimp.h"
  23. #endif
  24.  
  25.  
  26. typedef enum
  27. {
  28.   open_WHEREVER,             /* As defined in the window template file */
  29.   open_CENTERED,             /* center of screen */
  30.   open_CENTEREDUNDERPOINTER, /* Center window on pointer position */
  31.   open_OVERCARET,            /* Over the current caret position. NOTE: If no
  32.                                 caret, window is opened open_CENTERED */
  33.   open_UNDERPOINTER,         /* Under the current pointer position (so that
  34.                                 the pointer is then in TL corner of window */
  35.   open_NEARLAST              /* Slightly offset from the T.L. pos of the last
  36.                                 window to be opened with Window_Show  */
  37. } window_openpos;
  38.  
  39.  
  40.  
  41. /* Window_Create -----------------------------------------------------------
  42.  * This finds the named window template and creates a new copy of the window.
  43.  * It also records the memory allocated for the window so that it can be
  44.  * deallocated when the window is closed (using Window_Delete)
  45.  *
  46.  * "maxtitlesize" is the maximum length the window's title will be allowed
  47.  * grow to. (See Template.h: Template_Clone())
  48.  *
  49.  * Returns: The WIMP handle of the newly-created window, or 0 if the template
  50.  * for this window could not be found
  51.  */
  52. extern window_handle Window_Create(char *windowname, int maxtitlesize);
  53.  
  54.  
  55. /* Window_Show -------------------------------------------------------------
  56.  
  57.  * This opens the given window on-screen in the desired position.
  58.  * (It can be used with ANY window, even if not created with Window_Create)
  59.  */
  60. extern void Window_Show(window_handle window, window_openpos openpos);
  61.  
  62.  
  63. /* Window_CreateAndShow ----------------------------------------------------
  64.  * Simply calls Window_Create() and then Window_Show()
  65.  * (Just to make your programs slightly tidier)
  66.  */
  67. extern window_handle Window_CreateAndShow(char *windowname,
  68.                                           int  maxtitlesize,
  69.                                           window_openpos openpos);
  70.  
  71.  
  72. /* Window_Hide -------------------------------------------------------------
  73.  * Closes the specified window (removes it from screen)
  74.  * THE WINDOW IS NOT DELETED, just "hidden". It is preferable that you use
  75.  * Window_Create() and Window_Delete() every time you want a window to
  76.  * appear/disappear, to avoid problems.
  77.  *
  78.  * extern void Window_Hide(window_handle window);
  79.  */
  80. #define Window_Hide(handle) Wimp_CloseWindow(handle)
  81.  
  82.  
  83. /* Window_Delete -----------------------------------------------------------
  84.  * This Hides and deletes ANY window.
  85.  * It also removes any Event handlers attached to the window.
  86.  * If the window was created with Window_Create(), then it also deallocates
  87.  * any memory used by the window.
  88.  */
  89. extern void Window_Delete(window_handle window);
  90.  
  91.  
  92.  
  93. /* Window_GetInfo ----------------------------------------------------------
  94.  * This is simply a frontend to the Wimp_GetWindowInfo call. However, it
  95.  * returns the Window info block with the icon definitions STRIPPED.
  96.  * Thus, you can use a window_info structure in your local variables without
  97.  * having to allocate enough memory to cope with any icons that the window
  98.  * happens to have in it.
  99.  */
  100. extern void Window_GetInfo(window_handle window, window_info *result);
  101.  
  102.  
  103. /* Window_ParentName -------------------------------------------------------
  104.  * Given any window's handle, this function attempts to find the name
  105.  * (8 characters only, truncated if necessary) of the template from which
  106.  * the window was created (only works if created with Window_Create)
  107.  * - if the window handle is a negative number, "iconbar" is returned.
  108.  */
  109. extern void Window_ParentName(window_handle window, char *windowname);
  110.  
  111.  
  112. /* Window_AutoHelp ---------------------------------------------------------
  113.  * This adds an event handler for the given window and icon (event_ANY and
  114.  * window_ICONBAR may be used). Every HelpRequest message thereafter
  115.  * received for that window will be answered (if possible) with a message
  116.  * from your messages (see Msgs) file.
  117.  * The message tag used will be constructed from the window's template-name
  118.  * and the icon number, as in:
  119.  *    mainwind.-1   - Any part of the window not covered by an icon
  120.  *    mainwind.3    - Icon 3 of any window created from "mainwind" template
  121.  * 
  122.  * In the messages file, you can also use a catch-all message of:
  123.  *    mainwind.*
  124.  * which will catch ALL helprequests for the window, so ANY part of the
  125.  * window is guaranteed to give help (if no specific help for an icon is
  126.  * found, then the catch-all help will be used)
  127.  *
  128.  * NOTE that this function (Window.AutoHelp.c) may be recompiled to use
  129.  * EventMsg_Claim rather than Event_Claim if you so desire. However,
  130.  * note that currently EventMsg ignores the icon handle.
  131.  * EventMsg is more efficient than having multiple Event_Claims on 
  132.  * incoming message events (especially when you add individual handlers for
  133.  * single windows/icons), but ONLY if you are using several message event
  134.  * handlers. Thus, the default here is to use Event_Claim so as to not
  135.  * "pull in" the code for EventMsg unless you want to use it.
  136.  */
  137. extern BOOL Window_AutoHelp(window_handle window, icon_handle icon);
  138.  
  139.  
  140. /* Window_HelpHandler ------------------------------------------------------
  141.  * This is an event handler (added with Window_AutoHelp) which provides
  142.  * help on windows and their icons.
  143.  * If you wish to augment the help available for a window, you can call
  144.  * this handler yourself. Checking if it returns TRUE or FALSE gives an
  145.  * indicator of whether or not a help reply has been sent.
  146.  * Generally, you will check if the pointer is in an area of the window
  147.  * and supply help for that special area - if not, you drop back to a
  148.  * "fallback" position, and allow the "default" action, by callinf this
  149.  * handler.
  150.  * The other method is to add your own specialised help handler with
  151.  * Event_Claim, and then add this handler, so that your handler gets first
  152.  * choice when the event comes in.
  153.  */
  154. extern BOOL Window_HelpHandler(event_pollblock *event, void *reference);
  155.  
  156.  
  157. /* Window_ModeChange -------------------------------------------------------
  158.  * This function will go through all your templates and all windows that
  159.  * were created with Window_ calls, and re-find their outline fonts so
  160.  * that they are displayed correctly - this needs to be done after some
  161.  * mode changes. See Handler.h - Handler_ModeChangeWithFonts() to see
  162.  * how this should/can be used.
  163.  *
  164.  * NOTE: If you create ANY windows without using Window_Create calls, then
  165.  * this function will not fix their outline font use - but MUCH MORE
  166.  * IMPORTANTLY it will release the font, which may later be replaced
  167.  * by another font (or worse, cease to exists totally), so strange or
  168.  * unhealthy effects might ensue. i.e. ONLY use this if using Window_Create.
  169.  *
  170.  * Note also that this does NOT attempt to fix fonts in window titles
  171.  * because
  172.  *  a) The WIMP currently gets antialiased fonts *very* wrong with toolsprites
  173.  *     and/or titlebar selection, so they aren't recommended
  174.  *  b) Acorn DO have a new WIMP which uses an Outline font instead of system,
  175.  *     so the problem WILL go away with the next OS release.
  176.  *  c) This would involve re-creating the window, which would mean a possible
  177.  *     change in the window handle, which is something we can't do.
  178.  */
  179. extern void Window_ModeChange(void);
  180.  
  181.  
  182. /* Window_SetTitle ---------------------------------------------------------
  183.  * (equivalent of RISC OS Lib's win_settitle, only far better)
  184.  * This sets the text in the titlebar of the given window to the given string
  185.  *
  186.  * NOTE that if the title is not indirected, It will be unable to change
  187.  * the text, i.e. nothing will happen!
  188.  *
  189.  * It has several advantages over win_settitle, however:
  190.  *  + It uses legal OS calls to work out the rectange to redrawm so works
  191.  *    properly even with strange sized toolsprite sets
  192.  *  + It doesn't try to redraw anything if the window is CLOSED!
  193.  *  + It handles indirected and text-only title icons, rather than bombing
  194.  *    completely if the titlebar is not indirected.
  195.  *  + It actually terminates the string if it was too long to fit!!!
  196.  *
  197.  *  (And people wonder why I think ROLib is a load of excrement!)
  198.  *
  199.  *  Unfortunately it is not possible to only invalidate the VISIBLE area
  200.  *  of the window, so this may still create the occasional flicker of any
  201.  *  windows over the top of your titlebar... this can't be helped.
  202.  */
  203. extern void Window_SetTitle(window_handle window, char *title);
  204.  
  205.  
  206. /* Window_BringToFront -----------------------------------------------------
  207.  *  Pulls the given window to the front of the window stack
  208.  */
  209. extern void Window_BringToFront(window_handle window);
  210.  
  211. #endif
  212.