home *** CD-ROM | disk | FTP | other *** search
- /* > $.CLIB.C.iconfind
- *
- * 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 find icons given variouse things to serach for.
- */
- #include "includes.h"
-
- /*
- * given a icon structure, return the contents (title) of the icon.
- */
- char *haswin_geticontitle(icon *iptr) {
-
- char *ptr;
-
- if ((iptr) && (iptr->ic)) {
- if (iptr->ic[4] & 0x00000100) {
- ptr = (char *)(iptr->ic[5]);
- ptr[iptr->ic[7]] = '\0';
- } else {
- ptr = &((char *)iptr->ic)[20];
- asciilen(ptr);
- }
- return(ptr);
- } else
- return("don't know");
- }
-
- /*
- * given a icon structure, return the name of the icon. This does
- * not change even in writeable icons.
- */
- char *haswin_geticonname(icon *ic) {
-
- if ((ic) && (ic->name))
- return(ic->name);
- else
- return("don't know");
- }
-
- /*
- * given a window and an icon name find the icon structure.
- * Note that window handles -1 and -2 are both on the icon bar.
- */
- icon *haswin_findiconname(window *win, char *name) {
-
- register icon *iptr;
- register int length;
-
- if ((!win) || (!name))
- return((icon *)0);
- switch ((int)win) {
- case ICONBAR_LEFT:
- case ICONBAR_RIGHT:
- iptr = haswin_baricons;
- break;
- default:
- iptr = win->icons;
- break;
- }
- length = asciilen(name);
- while (iptr) {
- if (!strncmp(name, iptr->name, length))
- return(iptr);
- iptr=iptr->next;
- }
- return((icon *)0);
- }
- /*
- * given a window and an icon title find the icon structure.
- * Note that window handles -1 and -2 are both on the icon bar.
- */
-
- icon *haswin_findicontitle(window *win, char *name) {
-
- register icon *iptr;
- register int length;
-
- if ((!win) || (!name))
- return((icon *)0);
- switch ((int)win) {
- case ICONBAR_LEFT:
- case ICONBAR_RIGHT:
- iptr = haswin_baricons;
- break;
- default:
- iptr = win->icons;
- break;
- }
- length = asciilen(name);
- while (iptr) {
- if (!strncmp(name, haswin_geticontitle(iptr), length))
- return(iptr);
- iptr=iptr->next;
- }
- return((icon *)0);
- }
-
- /*
- * given a window, and icon handle find the icon structure associated
- * with an icon.
- * Note that window handles -1 and -2 are both on the icon bar.
- */
- icon *haswin_findiconhandle(window *win, int inum) {
-
- register icon *iptr;
-
- if ((!win) || (inum < 0))
- return((icon *)0);
- switch ((int)win) {
- case ICONBAR_LEFT:
- case ICONBAR_RIGHT:
- iptr = haswin_baricons;
- break;
- default:
- iptr = win->icons;
- break;
- }
- while (iptr) {
- if (iptr->ihandle == inum)
- return(iptr);
- iptr=iptr->next;
- }
- return((icon *)0);
- }
-
-
-