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