4 * Handling of the Icon Palette
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
44 #include "steel/Steel.h"
46 #include "steel/interface.h"
47 #include "steel/sculptrix.h"
48 #include "steel/caretPtr.h"
49 #include "steel/flex.h"
65 /*----- Private data ------------------------------------------------------*/
67 static wimp_w window__palette; /* Window handle of floating icon palette */
69 /*----- Main code ---------------------------------------------------------*/
72 * void window__paletteHandler(wimp_eventstr *e,void *handle)
75 * Handles events for the icon palette window.
78 * wimp_eventstr *e == pointer to the current event
79 * void *handle == an unimportant pointer
82 static void window__paletteHandler(wimp_eventstr *e,void *handle)
95 wimpt_noerr(wimp_redraw_wind(&r,&more));
98 if (gPrefs_current()->sDispBorders)
100 sculptrix_setSpriteArea(gSprite_area());
101 sculptrix_redrawWindow(&r);
103 if (gPrefs_current()->iDispBorders)
104 interface_render3dWindow(&r);
105 if (gPrefs_current()->wDispBorders)
108 os_swix(XWimpExt_Redraw,®);
110 wimpt_noerr(wimp_get_rectangle(&r,&more));
114 wimpt_noerr(wimp_open_wind(&e->data.o));
117 wimpt_noerr(wimp_get_wind_state(window__palette,&s));
118 t=&template_find("default")->window;
122 win_register_event_handler(window__palette,0,0);
123 wimpt_noerr(wimp_delete_wind(window__palette));
128 caretPtr__pointer(FALSE); /* Don't change pointer in this window */
131 if ((e->data.but.m.bbits==0x40 || e->data.but.m.bbits==0x10) &&
132 e->data.but.m.i!=-1 &&
135 t=&template_find("default")->window;
136 ic=(wimp_icon *)(t+1);
137 window__grabIcon(&e->data.but.m,0);
138 window__qGrabbedIcon()->flags=ic[e->data.but.m.i].flags;
145 * void window__showPalette(void)
148 * Displays the palette window, as set up in the Defaults template file.
151 void window__showPalette(void)
159 static char title[25];
160 if (!window__palette)
162 t=&template_find("default")->window;
163 size=sizeof(wimp_wind)+t->nicons*sizeof(wimp_icon);
164 if (!flex_alloc((flex_ptr)&w,size))
167 msgs_lookup("wdNEMIP"));
171 ic=(wimp_icon *)(w+1);
172 for (i=0;i<w->nicons;i++)
173 ic[i].flags=(ic[i].flags&~0x0000f000)|0x00006000;
174 strcpy(title,msgs_lookup("wdIPT"));
175 w->spritearea=gSprite_area();
176 w->titleflags=wimp_INDIRECT | wimp_IHCENTRE | wimp_ITEXT;
177 w->title.indirecttext.buffer=title;
178 w->title.indirecttext.validstring=(char *)-1;
179 w->flags=wimp_WQUIT |
184 if (utils_complain(wimp_create_wind(w,&window__palette),
185 msgs_lookup("wdERIP")))
187 flex_free((flex_ptr)&w);
191 flex_free((flex_ptr)&w);
193 win_register_event_handler(window__palette,window__paletteHandler,0);
195 wimpt_noerr(wimp_get_wind_state(window__palette,&s));
197 wimpt_noerr(wimp_open_wind(&s.o));