home *** CD-ROM | disk | FTP | other *** search
- /* > $.CLIB.C.icon
- *
- * HASWIN Graphics Library
- * =========================
- *
- * Copyright (C) H.A.Shaw 1990.
- * Howard A. Shaw.
- * The Unit for Space Sciences,
- * Room 165,
- * Physics Building,
- * University of Kent at Canterbury.
- * Canterbury.
- * Kent. CT2 7NJ
- * You may use and distribute this code freely, however please leave
- * it alone. If you find bugs (and there will be many) please contact
- * me and the master source can be modified. If you keep me informed
- * of who you give copies of this to then I can get release upgrades
- * to them.
- *
- * These routines deal with making and deleting icons.
- */
- #include "includes.h"
-
- /*
- * create a new icon definition.
- * The string str is passed to haswin_buildiconflags to create the
- * icon's data flags etc. See haswin_buildiconflags (above) for what
- * the string can contain. In addition the following options, passed
- * back from haswin_buildiconflags are understood.
- * D - the icon is draggable.
- * Q - the icon can be used as a quit icon.
- */
- icon *haswin_createicon(window *win, char *str, int fc, int bc, int esg, int minx, int miny, int maxx, int maxy) {
-
- icon *ic;
- int i, blk[9], *permblk;
- char ptr[16];
- _kernel_swi_regs regs;
-
- if (!win)
- return((icon *)0);
- ic = (icon *)haswin_malloc(sizeof(icon), "haswin_createicon", "icon block");
- if ((int)win > 0)
- blk[0] = ic->whandle = win->handle;
- else
- blk[0] = ic->whandle = (int)win;
- blk[1] = minx;
- blk[2] = miny;
- blk[3] = maxx;
- blk[4] = maxy;
- if (haswin_buildiconflags(str, fc, bc, esg, &blk[5], ptr, 16) == HASWIN_FALSE) {
- haswin_free(ic);
- haswin_free(blk);
- return((icon *)0);
- }
- ic->name = haswin_malloc(asciilen((char *)blk[6])+1, "haswin_createicon", "icon name buffer");
- strcpy(ic->name, (char *)blk[6]);
- ic->window = 0;
- ic->menu = 0;
- ic->help = 0;
- ic->helpmsg = 0;
- ic->flags = 0;
- ic->button = (blk[5] >> 12) & 0x0000000F;
- for (i=0; ((i<16) && (ptr[i])); i++) {
- switch (ptr[i]) {
- case 'D':
- ic->flags |= ICON_DRAGSEL|ICON_DRAGADJ;
- break;
- case 'Q':
- ic->flags |= ICON_CANQUIT;
- break;
- default:
- haswin_interrorprintf("haswin_createicon: unknown option %c in %s", ptr[i], str);
- break;
- }
- }
- ic->mousebutton = 0;
- ic->dragroutine = 0;
- regs.r[1] = (int)blk;
- if (!haswin_swi(HASWIN_Create_icon, ®s))
- return(0);
- ic->ihandle = regs.r[0];
- permblk = (int *)haswin_malloc(8*sizeof(int), "haswin_createicon", "SWI block");
- permblk[0] = blk[1];
- permblk[1] = blk[2];
- permblk[2] = blk[3];
- permblk[3] = blk[4];
- permblk[4] = blk[5];
- permblk[5] = blk[6];
- permblk[6] = blk[7];
- permblk[7] = blk[8];
- ic->ic = permblk;
- switch ((int)win) {
- case ICONBAR_LEFT:
- case ICONBAR_RIGHT:
- ic->next = haswin_baricons;
- haswin_baricons = ic;
- break;
- default:
- ic->next = win->icons;
- win->icons = ic;
- win->numicons++;
- break;
- }
- return(ic);
- }
-
-