home *** CD-ROM | disk | FTP | other *** search
- /* boxes.c handles all the box resizing commitments for the (any?) program */
-
- #include "all.h"
-
- /* It provides the following services:
- *
- : Display a given icon number (0..Entries-1) using a given mode
- : Return icon whose box covers a given WA coordinate
- *
- */
-
- /* Handles a "Full Info" display */
-
- void display_module(int handle,int module, wimp_redrawstr *r)
- {
- char buffer[308];
- wimp_icon i;
- SMI m = &data[handle]->m[module];
-
- sprintf(buffer,"%-12.12s -- %-11.11s -- %.256s",m->leaf,m->display,m->filename);
- finfo_icon(module,&i.box);
- i.flags = FLAGS;
- i.data.indirecttext.buffer = buffer;
- i.data.indirecttext.validstring = Module_SmallFileIcon;
- i.data.indirecttext.bufflen = 308;
- wimp_ploticon(&i);
- }
-
- /* This procedure handles a "Small Icons" display */
-
- void display_msmall(int handle, int module, wimp_redrawstr *r)
- {
- wimp_icon i;
-
- small_icon(module,&i.box);
- i.flags = SMALL_TESTING FLAGS;
- i.data.indirecttext.buffer = data[handle]->m[module].leaf;
- i.data.indirecttext.validstring = Module_SmallFileIcon;
- i.data.indirecttext.bufflen = 16;
- wimp_ploticon(&i);
- }
-
- /* This procedure handles a "Large Icons" display */
-
- void display_mlarge(int handle, int module, wimp_redrawstr *r)
- {
- wimp_icon i;
-
- large_icon(module,&i.box);
- i.flags = LARGE_TESTING LARGE_FLAGS;
- i.data.indirecttext.buffer = data[handle]->m[module].leaf;
- i.data.indirecttext.validstring = Module_LargeFileIcon;
- i.data.indirecttext.bufflen = 16;
- wimp_ploticon(&i);
- }
-
- /* These procedures set the given wimp_box to enclose the given index
- * of a module (whether it exists or not - no check is made here)
- */
-
- void large_icon(int index, wimp_box *box)
- {
- box->x0 = LARGE_ICONSWIDTH * (index % LARGE_ICONSPERROW);
- box->x1 = box->x0 + LARGE_ICONSWIDTH;
- box->y1 = -44-(LARGE_ICONSHEIGHT*(index / LARGE_ICONSPERROW)) - 8;
- box->y0 = box->y1 - LARGE_ICONSHEIGHT - 4 + 32;
- }
-
- void small_icon(int index, wimp_box *box)
- {
- box->x0 = SMALL_ICONSWIDTH * (index % SMALL_ICONSPERROW);
- box->x1 = box->x0 + SMALL_ICONSWIDTH;
- box->y1 = -44-(SMALL_ICONSHEIGHT*(index / SMALL_ICONSPERROW));
- box->y0 = box->y1 - SMALL_ICONSHEIGHT - 4;
- }
-
- void finfo_icon(int index, wimp_box *box)
- {
- box->x0 = 4 + 0;
- box->x1 = 4 + FULLINFO_WIDTH;
- box->y1 = -44-(LineGap*index);
- box->y0 = box->y1 - LineGap - 4;
- }
-
- int matchbox(int handle)
- {
- SFI d = data[handle];
- int boxing = -1; /* Handle of module pointer is over */
-
- union {
- coords_pointstr point;
- coords_pointstr wao ;
- } xy;
- coords_cvtstr cvtstr;
- wimp_wstate state;
- wimp_mousestr mouse;
-
- wimp_get_point_info(&mouse); /* Read pointer position */
- wimp_get_wind_state(d->w,&state); /* Read the window state */
-
- cvtstr.box = state.o.box; /* Transfer the coordinates to cvtstr */
- cvtstr.scx = state.o.x; /* x scroll position */
- cvtstr.scy = state.o.y; /* y scroll position */
- xy.point.x = mouse.x; /* x-mouse location */
- xy.point.y = mouse.y; /* y-mouse location */
-
- coords_point_toworkarea(&xy.point,&cvtstr); /* Transform co-ordinates */
-
- xy.wao.y = - xy.wao.y - 48;
- boxing = (xy.wao.y < 0) ? -1 : multi[d->disp].withinbox(&xy.wao,d);
-
- return boxing >= d->entries ? -1 : boxing;
- }
-
- int small_box(coords_pointstr *c,SFI d)
- {
- int row = (c->y / SMALL_ICONSHEIGHT) * SMALL_ICONSPERROW;
- int col = (c->x / SMALL_ICONSWIDTH ) ;
-
- return col + row;
- }
-
- int large_box(coords_pointstr *c,SFI d)
- {
- int row = (c->y / LARGE_ICONSHEIGHT) * LARGE_ICONSPERROW;
- int col = (c->x / LARGE_ICONSWIDTH );
-
- return col + row;
- }
-
- int finfo_box(coords_pointstr *c, SFI d)
- {
- return ((c->y-4) / LineGap);
- }
-