home *** CD-ROM | disk | FTP | other *** search
- /* > $.CLIB.C.iconset
- *
- * 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 change or get things to do with icons.
- */
- #include "includes.h"
-
- /************************************************************************
- * *
- * Routines to control the Icon part of the WIMP. *
- * *
- ************************************************************************/
-
- /*
- * change the data (title/spritename/contents) of an icon, and redraw.
- * For indirected sprites the pointer to the area pointer is the
- * validation string. If ic->name is 0, then set icon data up for
- * the first time.
- */
- int haswin_seticondata(icon *ic, char *data) {
-
- char *stmp;
- int spritearea;
- int nic[9], dic[2];
- window *wptr;
- _kernel_swi_regs regs;
-
- if (!ic)
- return(-1);
-
- if (!ic->name) {
- ic->name = haswin_malloc(asciilen(data)+1, "haswin_seticondata", "icon name");
- strcpy(ic->name, data);
- } else {
- if (!strcmp(haswin_geticontitle(ic), data))
- /* data has not changed, nothing to do! */
- return(ic->ihandle);
- }
- wptr = haswin_findwindowhandle(ic->whandle);
- /* create a new icon definition in nic */
- nic[0] = ic->whandle;
- nic[1] = ic->ic[0];
- nic[2] = ic->ic[1];
- nic[3] = ic->ic[2];
- nic[4] = ic->ic[3];
- nic[5] = ic->ic[4] | 0x00000100;
- nic[6] = ic->ic[5];
- nic[7] = ic->ic[6];
- /* if the icon is writable then don't shorten its length */
- if (((ic->ic[4]&0xE000) == 0xE000) && (ic->ic[7] > strlen(data))) {
- stmp = haswin_realloc((void *)(ic->ic[5]), ic->ic[7]+1, "haswin_seticondata", "icon data 1");
- nic[8] = ic->ic[7];
- } else {
- stmp = haswin_realloc((void *)(ic->ic[5]), strlen(data)+1, "haswin_seticondata", "icon data 2");
- nic[8] = strlen(data);
- }
- strcpy(stmp, data);
- nic[6] = (int)stmp;
- if ((nic[5] & 0x00000003) == 0x00000002) {
- /* icon is a sprite ! */
- /* find the sprite area control block for this sprite */
- /* if none found then put it in WIMP area */
- if ((spritearea=haswin_findsprite(stmp)) == HASWIN_UNKNOWN)
- spritearea = 1;
- nic[7] = (int)spritearea;
- } else
- nic[7] = ((int *)ic->ic)[6];
- /* delete the existing icon definition */
- dic[0] = ic->whandle;
- dic[1] = ic->ihandle;
- regs.r[1] = (int)dic;
- if (!haswin_swi(HASWIN_Delete_icon, ®s))
- return(ic->ihandle);
- /* recreate the icon */
- regs.r[1] = (int)nic;
- if (!haswin_swi(HASWIN_Create_icon, ®s))
- return(-1);
- ic->ihandle = regs.r[0];
- ic->ic[0] = nic[1];
- ic->ic[1] = nic[2];
- ic->ic[2] = nic[3];
- ic->ic[3] = nic[4];
- ic->ic[4] = nic[5];
- ic->ic[5] = nic[6];
- ic->ic[6] = nic[7];
- ic->ic[7] = nic[8];
- haswin_redrawwindow(wptr, nic[1], nic[3], nic[2], nic[4]);
- if (ic->ihandle > wptr->numicons)
- wptr->numicons = ic->ihandle;
- return(ic->ihandle);
- }
-
- /*
- * change the flags of an icon, and redraw.
- * Remember action is...
- * new-state = (old-state AND NOT mask) OR bits
- */
- void haswin_seticonstate(icon *ic, int mask, int bits) {
-
- int tmp[4];
- _kernel_swi_regs regs;
-
- if (!ic)
- return;
- tmp[0] = ic->whandle;
- tmp[1] = ic->ihandle;
- tmp[2] = bits;
- tmp[3] = mask;
- ((int *)ic->ic)[4] &= ~mask;
- ((int *)ic->ic)[4] |= bits;
- regs.r[1] = (int)tmp;
- haswin_swi(HASWIN_Set_icon_state, ®s);
- return;
- }
-
- int haswin_geticonxmin(icon *ic) {
-
- if ((!ic) || (!ic->ic))
- return(HASWIN_UNKNOWN);
- return(ic->ic[0]);
- }
-
- int haswin_geticonxmax(icon *ic) {
-
- if ((!ic) || (!ic->ic))
- return(HASWIN_UNKNOWN);
- return(ic->ic[2]);
- }
-
- int haswin_geticonymin(icon *ic) {
-
- if ((!ic) || (!ic->ic))
- return(HASWIN_UNKNOWN);
- return(ic->ic[1]);
- }
-
- int haswin_geticonymax(icon *ic) {
-
- if ((!ic) || (!ic->ic))
- return(HASWIN_UNKNOWN);
- return(ic->ic[3]);
- }
-
- int haswin_newiconflags(icon *ic, int new) {
-
- if (!ic)
- return(HASWIN_FALSE);
- ic->flags = new;
- return(HASWIN_TRUE);
- }
-
- int haswin_seticonflags(icon *ic, int new) {
-
- if (!ic)
- return(HASWIN_FALSE);
- return(haswin_newiconflags(ic, ic->flags | new));
- }
-
- int haswin_cleariconflags(icon *ic, int new) {
-
- if (!ic)
- return(HASWIN_FALSE);
- return(haswin_newiconflags(ic, ic->flags & ~new));
- }
-
- int haswin_geticonflags(icon *ic) {
-
- if (!ic)
- return(HASWIN_UNKNOWN);
- return(ic->flags);
- }
-
-