home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / desklib / Libraries / Icon / c / FileIcon < prev    next >
Encoding:
Text File  |  1994-03-06  |  2.0 KB  |  61 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:    Icon.FileIcon.c
  12.     Author:  Copyright © 1994 Tim Browse
  13.     Version: 1.00 (04 Mar 1994)
  14.     Purpose: Changes an icon in a window to display the correct filetype
  15.                sprite for the given filetype number.
  16. */
  17.  
  18.  
  19. #include <stdio.h>
  20.  
  21. #include "Wimp.h"
  22. #include "WimpSWIS.h"
  23.  
  24. void Icon_FileIcon(window_handle window, icon_handle icon, int filetype)
  25. {
  26.   /* Icon should be an indirected text-only icon with enough room in text
  27.      buffer to hold the sprite name.  
  28.      This converts to an indirected sprite-only icon, and fills in the sprite
  29.      name and area.
  30.   */
  31.   icon_createblock iconcreate;
  32.   icon_handle handle;
  33.  
  34.   /* Get the data for this icon */
  35.   Wimp_GetIconState(window, icon, &iconcreate.icondata);
  36.  
  37.   /* Delete this icon - we have to change the data fields */
  38.   Wimp_DeleteIcon(window, icon);
  39.  
  40.   /* Put sprite name in name field */
  41.   sprintf((char *) iconcreate.icondata.data.indirectsprite.name, 
  42.           "file_%3.3x", filetype);
  43.  
  44.   /* Fill in sprite area */
  45.   iconcreate.icondata.data.indirectsprite.spritearea = (unsigned int *) 1;
  46.  
  47.   /* Fill in sprite name length */
  48.   iconcreate.icondata.data.indirectsprite.nameisname = 8; /* file_xxx */
  49.  
  50.   /* Change to sprite-only */
  51.   iconcreate.icondata.flags.data.text   = FALSE;
  52.   iconcreate.icondata.flags.data.sprite = TRUE;
  53.  
  54.   /* Re-create the icon */
  55.   iconcreate.window = window;
  56.   Wimp_CreateIcon(&iconcreate, &handle);
  57.     
  58.   /* Force the icon to be redrawn */
  59.   Wimp_SetIconState(window, handle, 0, 0);
  60. }
  61.