/* Copyright 1996 Acorn Computers Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* Title: -> c.fileicon * Purpose: general display of a file icon in a dialog box. * Status: Arthur-specific, part of ArcEdit. * History: * 15-Mar-88: WRS: carved off from xfersend. * 16-Jul-91: IDJ: reverted to old DDE behaviour * 16-Jul-91: IDJ: added directory/app icon */ #define BOOL int #define TRUE 1 #define FALSE 0 #include <stdio.h> #include "h.os" #include "h.wimp" #include "h.wimpt" #include "h.sprite" #include "h.trace" #include "h.fileicon" #include "h.werr" void fileicon(wimp_w w, wimp_i ii, int filetype) { wimp_icreate i; wimp_i iii; /* Set up a sprite icon with the icon that represents the relevant file type. The user may now drag this icon away, if he so desires. */ i.w = w; wimpt_complain(wimp_get_icon_info(i.w, ii, &i.i)); wimpt_complain(wimp_delete_icon(w, ii)); /* the icon must initially be an indirect text icon. */ i.i.flags &= ~wimp_ITEXT; /* set not text */ i.i.flags |= wimp_ISPRITE + wimp_INDIRECT; /* set sprite */ if (filetype == 0x1000) sprintf(i.i.data.indirectsprite.name, "Directory"); else if (filetype == 0x2000) sprintf(i.i.data.indirectsprite.name, "Application"); else sprintf(i.i.data.indirectsprite.name, "file_%03x", filetype); /* now to check if the sprite exists. */ /* do a sprite_select on the Wimp sprite pool */ if (wimp_spriteop(24,i.i.data.indirectsprite.name) == 0) { /* the sprite exists: all is well */ } else { /* the sprite does not exist: print general don't-know icon. */ sprintf(i.i.data.indirectsprite.name, "file_xxx"); }; i.i.data.indirectsprite.spritearea = (void*) 1; tracef1("sprite name is %s.\n", (int) i.i.data.indirectsprite.name); wimp_create_icon(&i, &iii); /* will recreate with same number. */ #if TRACE if (iii != ii) { werr(FALSE, "INTERNAL: fi-1"); }; #endif tracef2("new icon no %i (should be %i).\n", iii, ii); } /* end */