home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / desklib / Libraries / Icon / c / BarIconUse < prev    next >
Encoding:
Text File  |  1994-03-12  |  1.9 KB  |  65 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.BarIconUse.c
  12.     Author:  Copyright © 1994 Peter Gaunt
  13.     Version: 1.00 (12 Mar 1994)
  14.     Purpose: Place icon on the Icon Bar, using a caller-specified sprite
  15.                area.
  16. */
  17.  
  18. #include <string.h>
  19. #include <stdlib.h>
  20.  
  21. #include "DeskLib:Wimp.h"
  22. #include "DeskLib:WimpSWIs.h"
  23. #include "DeskLib:Error.h"
  24.  
  25. #define BARICON_XSIZE 68
  26. #define BARICON_YSIZE 68
  27.  
  28.  
  29. /*
  30.  * Plonk a sprite from a USER sprite area on the icon bar
  31.  * Returns icon handle.
  32.  */
  33.  
  34. extern icon_handle Icon_BarIconUser(char *spritename, window_handle pos,
  35.                                             unsigned int *area)
  36. {
  37.   icon_createblock icreate;
  38.   icon_handle      icon;
  39.   char             *iconname;
  40.  
  41.   icreate.window = pos;
  42.   icreate.icondata.flags.value = 0x1700310A;    /* Click-able sprite icon */
  43.  
  44.   iconname = malloc( wimp_MAXNAME + 1 );
  45.   if (iconname == NULL)
  46.     Error_Report(1,"Not enough memory");
  47.     
  48.   strcpy(iconname,spritename);
  49.  
  50.   icreate.icondata.data.indirectsprite.name = iconname;
  51.   icreate.icondata.data.indirectsprite.spritearea = area;
  52.   icreate.icondata.data.indirectsprite.nameisname = wimp_MAXNAME;
  53.  
  54.   icreate.icondata.workarearect.min.x =
  55.     icreate.icondata.workarearect.min.y = 0;
  56.  
  57.   icreate.icondata.workarearect.max.x =  BARICON_XSIZE;
  58.  
  59.   icreate.icondata.workarearect.max.y = BARICON_YSIZE;
  60.  
  61.   Wimp_CreateIcon(&icreate, &icon);
  62.   return(icon);
  63. }
  64.  
  65.