4 * creates a file icon in a window, plonk over another one.
6 * © 1993-1998 Straylight
9 /*----- Licensing note ----------------------------------------------------*
11 * This file is part of Straylight's Steel library.
13 * Steel is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
18 * Steel is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with Steel. If not, write to the Free Software Foundation,
25 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
37 static BOOL fileicon__spriteExist(char *name)
40 if (wimp_spriteop(40,name))
47 char *fileicon_spriteName(int filetype,char *name)
49 char *spritename=buffer_find();
52 for (p=name;*p!=0;p++)
60 strcpy(spritename,"file_xxx");
63 if (fileicon__spriteExist(leaf))
64 strcpy(spritename,leaf);
66 strcpy(spritename,"application");
69 strcpy(spritename,"directory");
72 sprintf(spritename,"file_%.3x",filetype);
73 if (!fileicon__spriteExist(spritename))
74 strcpy(spritename,"file_xxx");
80 void fileicon(wimp_w w,wimp_i i,int filetype,char *name)
84 wimpt_noerr(wimp_get_icon_info(w,i,&(icn.i)));
85 wimpt_noerr(wimp_delete_icon(w,i));
86 if ((icn.i.flags & wimp_INDIRECT)==0)
87 werr(TRUE,msgs_lookup("ficnNII:(fileicon, caller fault): "
88 "Icon must be indirected."));
96 wimp_IBTYPE * wimp_BDEBOUNCEDRAG |
100 strcpy(icn.i.data.indirectsprite.name,fileicon_spriteName(filetype,name));
101 icn.i.data.indirectsprite.spritearea=(void *)1;
102 icn.i.data.indirectsprite.nameisname=TRUE;
104 wimpt_noerr(wimp_create_icon(&icn,&ih));
105 wimpt_noerr(wimp_set_icon_state(w,ih,0,0));
107 werr(TRUE,msgs_lookup("ficnIHD:(fileicon): Icon handle has changed."));