home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / clib / progs / haswinlib / c / icon < prev    next >
Encoding:
Text File  |  1991-02-04  |  3.6 KB  |  108 lines

  1. /* > $.CLIB.C.icon
  2.  *
  3.  *      HASWIN Graphics Library
  4.  *     =========================
  5.  *
  6.  *      Copyright (C) H.A.Shaw 1990.
  7.  *              Howard A. Shaw.
  8.  *              The Unit for Space Sciences,
  9.  *              Room 165,
  10.  *              Physics Building,
  11.  *              University of Kent at Canterbury.
  12.  *              Canterbury.
  13.  *              Kent.  CT2 7NJ
  14.  *      You may use and distribute this code freely, however please leave
  15.  *      it alone.  If you find bugs (and there will be many) please contact
  16.  *      me and the master source can be modified.  If you keep me informed
  17.  *      of who you give copies of this to then I can get release upgrades
  18.  *      to them.
  19.  *
  20.  *      These routines deal with making and deleting icons.
  21.  */
  22. #include "includes.h"
  23.  
  24. /*
  25.  *      create a new icon definition.
  26.  *      The string str is passed to haswin_buildiconflags to create the
  27.  *      icon's data flags etc.  See haswin_buildiconflags (above) for what
  28.  *      the string can contain.  In addition the following options, passed
  29.  *      back from haswin_buildiconflags are understood.
  30.  *      D    - the icon is draggable.
  31.  *      Q    - the icon can be used as a quit icon.
  32.  */
  33. icon *haswin_createicon(window *win, char *str, int fc, int bc, int esg, int minx, int miny, int maxx, int maxy) {
  34.  
  35.         icon    *ic;
  36.         int     i, blk[9], *permblk;
  37.         char    ptr[16];
  38.         _kernel_swi_regs  regs;
  39.  
  40.         if (!win)
  41.                 return((icon *)0);
  42.         ic = (icon *)haswin_malloc(sizeof(icon), "haswin_createicon", "icon block");
  43.         if ((int)win > 0)
  44.                 blk[0] = ic->whandle = win->handle;
  45.         else
  46.                 blk[0] = ic->whandle = (int)win;
  47.         blk[1] = minx;
  48.         blk[2] = miny;
  49.         blk[3] = maxx;
  50.         blk[4] = maxy;
  51.         if (haswin_buildiconflags(str, fc, bc, esg, &blk[5], ptr, 16) == HASWIN_FALSE) {
  52.                 haswin_free(ic);
  53.                 haswin_free(blk);
  54.                 return((icon *)0);
  55.         }
  56.         ic->name = haswin_malloc(asciilen((char *)blk[6])+1, "haswin_createicon", "icon name buffer");
  57.         strcpy(ic->name, (char *)blk[6]);
  58.         ic->window = 0;
  59.         ic->menu = 0;
  60.         ic->help = 0;
  61.         ic->helpmsg = 0;
  62.         ic->flags = 0;
  63.         ic->button = (blk[5] >> 12) & 0x0000000F;
  64.         for (i=0; ((i<16) && (ptr[i])); i++) {
  65.                 switch (ptr[i]) {
  66.                 case 'D':
  67.                         ic->flags |= ICON_DRAGSEL|ICON_DRAGADJ;
  68.                         break;
  69.                 case 'Q':
  70.                         ic->flags |= ICON_CANQUIT;
  71.                         break;
  72.                 default:
  73.                         haswin_interrorprintf("haswin_createicon: unknown option %c in %s", ptr[i], str);
  74.                         break;
  75.                 }
  76.         }
  77.         ic->mousebutton = 0;
  78.         ic->dragroutine = 0;
  79.         regs.r[1] = (int)blk;
  80.         if (!haswin_swi(HASWIN_Create_icon, ®s))
  81.                 return(0);
  82.         ic->ihandle = regs.r[0];
  83.         permblk = (int *)haswin_malloc(8*sizeof(int), "haswin_createicon", "SWI block");
  84.         permblk[0] = blk[1];
  85.         permblk[1] = blk[2];
  86.         permblk[2] = blk[3];
  87.         permblk[3] = blk[4];
  88.         permblk[4] = blk[5];
  89.         permblk[5] = blk[6];
  90.         permblk[6] = blk[7];
  91.         permblk[7] = blk[8];
  92.         ic->ic = permblk;
  93.         switch ((int)win) {
  94.         case ICONBAR_LEFT:
  95.         case ICONBAR_RIGHT:
  96.                 ic->next = haswin_baricons;
  97.                 haswin_baricons = ic;
  98.                 break;
  99.         default:
  100.                 ic->next = win->icons;
  101.                 win->icons = ic;
  102.                 win->numicons++;
  103.                 break;
  104.         }
  105.         return(ic);
  106. }
  107.  
  108.