home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / Window / c / Settitle < prev    next >
Encoding:
Text File  |  1993-06-29  |  2.3 KB  |  63 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.c.SetTitle
  12.     Author:  Copyright © 1993 Jason Williams
  13.     Version: 1.00 (28 Jun 1993)
  14.     Purpose: Set the text in a window's titlebar, and force a redraw of
  15.              the *correct* region of the screen to update it.
  16.              (i.e. it even works with Edouard Poor's MegaWindow toolsprites!)
  17. */
  18.  
  19. #include "DeskLib:Wimp.h"
  20. #include "DeskLib:WimpSWIs.h"
  21. #include "DeskLib:Window.h"
  22.  
  23. #include <string.h>
  24.  
  25.  
  26. extern void Window_SetTitle(window_handle window, char *title)
  27. {
  28.   window_info        info;
  29.   window_redrawblock redraw;
  30.   window_outline     outline;
  31.   char               *buffer;
  32.   int                bufflen;
  33.  
  34.   /* Get the wimp information for this window */
  35.   Window_GetInfo(window, &info);
  36.  
  37.   if (!info.block.titleflags.data.indirected)
  38.     return;                /* We can't set the title if it isn't indirected! */
  39.  
  40.   buffer  = info.block.title.indirecttext.buffer;
  41.   bufflen = info.block.title.indirecttext.bufflen - 1;
  42.  
  43.   /* Copy the given string into the window's title bar string */
  44.   strncpy(buffer, title, bufflen);
  45.   buffer[bufflen] = 0;              /* And ensure it is correctly terminated */
  46.  
  47.   if (info.block.flags.data.open)   /* *IF* window open, redraw the titlebar */
  48.   {
  49.     /* Get the position of the window on screen */
  50.     outline.window = window;
  51.     Wimp_GetWindowOutline(&outline);
  52.  
  53.     /*  Force a redraw of the title bar - it is the rectangle that lies
  54.      *  between the window outline as returned by Wimp_GetWindowOutline and
  55.      *  the window screenrect as returned by Wimp_GetWindowInfo
  56.      */
  57.     redraw.window     = -1;                        /* invalidate screen area */
  58.     redraw.rect       = outline.screenrect;
  59.     redraw.rect.min.y = info.block.screenrect.max.y;
  60.     Wimp_ForceRedraw(&redraw);
  61.   }
  62. }
  63.