/* * wPalette.c * * Handling of the Icon Palette * * © 1994-1998 Straylight */ /*----- Licensing note ----------------------------------------------------* * * This file is part of Straylight's Glass. * * Glass is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Glass is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Glass. If not, write to the Free Software Foundation, * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /*----- Header files ------------------------------------------------------*/ /* * ANSI standard headers */ #include #include #include /* * Steel headers */ #define _STDAPP #define _LOWLVL #include "steel/Steel.h" #include "steel/interface.h" #include "steel/sculptrix.h" #include "steel/caretPtr.h" #include "steel/flex.h" /* * Glass headers */ #include "gStruct.h" #include "gMenus.h" #include "gIcons.h" #include "glass.h" #include "gPrefs.h" #include "gSprite.h" #include "window.h" #include "_window.h" /*----- Private data ------------------------------------------------------*/ static wimp_w window__palette; /* Window handle of floating icon palette */ /*----- Main code ---------------------------------------------------------*/ /* * void window__paletteHandler(wimp_eventstr *e,void *handle) * * Use * Handles events for the icon palette window. * * Parameters * wimp_eventstr *e == pointer to the current event * void *handle == an unimportant pointer */ static void window__paletteHandler(wimp_eventstr *e,void *handle) { BOOL more=TRUE; wimp_redrawstr r; wimp_wstate s; wimp_wind *t; os_regset reg; wimp_icon *ic; unused(handle); switch (e->e) { case wimp_EREDRAW: r.w=e->data.o.w; wimpt_noerr(wimp_redraw_wind(&r,&more)); while (more) { if (gPrefs_current()->sDispBorders) { sculptrix_setSpriteArea(gSprite_area()); sculptrix_redrawWindow(&r); } if (gPrefs_current()->iDispBorders) interface_render3dWindow(&r); if (gPrefs_current()->wDispBorders) { reg.r[1]=(int)&r; os_swix(XWimpExt_Redraw,®); } wimpt_noerr(wimp_get_rectangle(&r,&more)); } break; case wimp_EOPEN: wimpt_noerr(wimp_open_wind(&e->data.o)); break; case wimp_ECLOSE: wimpt_noerr(wimp_get_wind_state(window__palette,&s)); t=&template_find("default")->window; t->box=s.o.box; t->scx=s.o.x; t->scy=s.o.y; win_register_event_handler(window__palette,0,0); wimpt_noerr(wimp_delete_wind(window__palette)); win_activedec(); window__palette=0; break; case wimp_EPTRENTER: caretPtr__pointer(FALSE); /* Don't change pointer in this window */ break; case wimp_EBUT: if ((e->data.but.m.bbits==0x40 || e->data.but.m.bbits==0x10) && e->data.but.m.i!=-1 && !window_grabbing()) { t=&template_find("default")->window; ic=(wimp_icon *)(t+1); window__grabIcon(&e->data.but.m,0); window__qGrabbedIcon()->flags=ic[e->data.but.m.i].flags; } break; } } /* * void window__showPalette(void) * * Use * Displays the palette window, as set up in the Defaults template file. */ void window__showPalette(void) { wimp_wind *w; wimp_wind *t; wimp_icon *ic; wimp_wstate s; int i; int size; static char title[25]; if (!window__palette) { t=&template_find("default")->window; size=sizeof(wimp_wind)+t->nicons*sizeof(wimp_icon); if (!flex_alloc((flex_ptr)&w,size)) { werr(FALSE, msgs_lookup("wdNEMIP")); return; } memcpy(w,t,size); ic=(wimp_icon *)(w+1); for (i=0;inicons;i++) ic[i].flags=(ic[i].flags&~0x0000f000)|0x00006000; strcpy(title,msgs_lookup("wdIPT")); w->spritearea=gSprite_area(); w->titleflags=wimp_INDIRECT | wimp_IHCENTRE | wimp_ITEXT; w->title.indirecttext.buffer=title; w->title.indirecttext.validstring=(char *)-1; w->flags=wimp_WQUIT | wimp_WBACK | wimp_WTITLE | wimp_WNEW | wimp_WMOVEABLE; if (utils_complain(wimp_create_wind(w,&window__palette), msgs_lookup("wdERIP"))) { flex_free((flex_ptr)&w); window__palette=0; return; } flex_free((flex_ptr)&w); win_activeinc(); win_register_event_handler(window__palette,window__paletteHandler,0); } wimpt_noerr(wimp_get_wind_state(window__palette,&s)); s.o.behind=-1; wimpt_noerr(wimp_open_wind(&s.o)); }