4 * Central handling for icon data
6 * © 1994-1998 Straylight
9 /*----- Licensing note ----------------------------------------------------*
11 * This file is part of Straylight's Glass.
13 * Glass 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 * Glass 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 Glass. If not, write to the Free Software Foundation,
25 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 /*----- Header files ------------------------------------------------------*/
31 * ANSI standard headers
42 #include "steel/Steel.h"
54 /*----- External routines -------------------------------------------------*/
57 * BOOL iconData_processIcon
59 * glass_windPointer *w,
67 * Processes one icon in the given window. This routine will replace all
68 * the indirection pointers with pointers to blocks from the indirection
72 * glass_windPointer *w == the window data from which the icon is from
73 * int i == the icon to update (-1 for the title)
74 * BOOL updateSize == whether to update the window's size variable
75 * iconData_proc proc == function to return a pointer to an indirected
76 * string given what's in the data word. Pass 0 if its actually a
78 * void *handle == pointer to pass to 'proc'
81 * FALSE if it ran out of memory, or TRUE for success
84 BOOL iconData_processIcon
100 flags=w->def->desc.w.titleflags;
101 if (flags & wimp_INDIRECT)
104 indir=proc(w->def->desc.w.title.indirecttext.buffer,handle);
106 indir=w->def->desc.w.title.indirecttext.buffer;
107 utils_ctermToNterm(indir);
108 if (w->def->desc.w.title.indirecttext.bufflen<strlen(indir)+1)
109 w->def->desc.w.title.indirecttext.bufflen=strlen(indir)+1;
110 p=indir_alloc(w->def->desc.w.title.indirecttext.bufflen);
114 /* --- Watch out -- indir might have moved :-( --- */
117 indir=proc(w->def->desc.w.title.indirecttext.buffer,handle);
119 indir=w->def->desc.w.title.indirecttext.buffer;
120 utils_ctermToNterm(indir);
123 if (flags & wimp_ITEXT &&
124 w->def->desc.w.title.indirecttext.validstring!=(char *)-1)
127 valid=proc(w->def->desc.w.title.indirecttext.validstring,handle);
129 valid=w->def->desc.w.title.indirecttext.validstring;
130 utils_ctermToNterm(valid);
131 q=indir_alloc(strlen(valid)+1);
138 /* --- Aaarrghh -- valid might have moved. Find it again --- */
141 valid=proc(w->def->desc.w.title.indirecttext.validstring,handle);
143 valid=w->def->desc.w.title.indirecttext.validstring;
144 utils_ctermToNterm(valid);
147 w->def->desc.w.title.indirecttext.validstring=q;
149 w->size+=strlen(valid)+1;
151 else if ((flags & 3)==2)
152 w->def->desc.w.title.indirectsprite.spritearea=w->t->s;
154 w->size+=w->def->desc.w.title.indirecttext.bufflen;
155 w->def->desc.w.title.indirecttext.buffer=p;
160 flags=w->def->i[i].i.flags;
161 if (flags & wimp_INDIRECT)
164 indir=proc(w->def->i[i].i.data.indirecttext.buffer,handle);
166 indir=w->def->i[i].i.data.indirecttext.buffer;
167 utils_ctermToNterm(indir);
168 if (w->def->i[i].i.data.indirecttext.bufflen<strlen(indir)+1)
169 w->def->i[i].i.data.indirecttext.bufflen=strlen(indir)+1;
170 p=indir_alloc(w->def->i[i].i.data.indirecttext.bufflen);
174 /* --- indir may have moved in a nasty way --- */
177 indir=proc(w->def->i[i].i.data.indirecttext.buffer,handle);
179 indir=w->def->i[i].i.data.indirecttext.buffer;
180 utils_ctermToNterm(indir);
183 if (flags & wimp_ITEXT &&
184 w->def->i[i].i.data.indirecttext.validstring!=(char *)-1)
187 valid=proc(w->def->i[i].i.data.indirecttext.validstring,handle);
189 valid=w->def->i[i].i.data.indirecttext.validstring;
190 utils_ctermToNterm(valid);
191 q=indir_alloc(strlen(valid)+1);
198 /* --- There's a saboteur about moving valid around --- */
201 valid=proc(w->def->i[i].i.data.indirecttext.validstring,handle);
203 valid=w->def->i[i].i.data.indirecttext.validstring;
204 utils_ctermToNterm(valid);
207 w->def->i[i].i.data.indirecttext.validstring=q;
209 w->size+=strlen(valid)+1;
211 else if ((flags & 3)==2)
212 w->def->i[i].i.data.indirectsprite.spritearea=w->t->s;
214 w->size+=w->def->i[i].i.data.indirecttext.bufflen;
215 w->def->i[i].i.data.indirecttext.buffer=p;
222 * BOOL iconData_handleFont(glass_windPointer *w,wimp_iconflags *f)
225 * Processes a font handle, refinding etc. and adding to font reference
226 * array. It assumes the icon is from an external source, and doesn't
227 * attempt to free the font.
230 * glass_windPointer *w == the window containing the icon/title to fiddle
231 * wimp_iconflags *f == icon flags to fiddle with
234 * TRUE if all went well, or FALSE if the icon's font has been lost. In
235 * this case the icon has been deantialiased(!) leaving potentially very
239 BOOL iconData_handleFont(glass_windPointer *w,wimp_iconflags *f)
246 fhandle=(*f>>24) & 0xff;
249 if (os_swix(XFont_ReadDefn,&r))
255 if (os_swix(XFont_FindFont,&r))
260 *f=(*f & 0x00ffffff) | (fhandle<<24);