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