home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / m / multimod / !MultiMod / c / boxes next >
Encoding:
Text File  |  1992-11-16  |  4.1 KB  |  135 lines

  1. /* boxes.c handles all the box resizing commitments for the (any?) program */
  2.  
  3. #include "all.h"
  4.  
  5. /* It provides the following services:
  6.  *
  7.  :  Display a given icon number (0..Entries-1) using a given mode
  8.  :  Return icon whose box covers a given WA coordinate
  9.  *
  10.  */
  11.  
  12. /* Handles a "Full Info" display */
  13.  
  14. void display_module(int handle,int module, wimp_redrawstr *r)
  15. {
  16.         char buffer[308];
  17.         wimp_icon i;
  18.         SMI       m = &data[handle]->m[module];
  19.  
  20.         sprintf(buffer,"%-12.12s -- %-11.11s -- %.256s",m->leaf,m->display,m->filename);
  21.         finfo_icon(module,&i.box);
  22.         i.flags  = FLAGS;
  23.         i.data.indirecttext.buffer      = buffer;
  24.         i.data.indirecttext.validstring = Module_SmallFileIcon;
  25.         i.data.indirecttext.bufflen     = 308;
  26.         wimp_ploticon(&i);
  27. }
  28.  
  29. /* This procedure handles a "Small Icons" display */
  30.  
  31. void display_msmall(int handle, int module, wimp_redrawstr *r)
  32. {
  33.         wimp_icon i;
  34.  
  35.         small_icon(module,&i.box);
  36.         i.flags  = SMALL_TESTING FLAGS;
  37.         i.data.indirecttext.buffer      = data[handle]->m[module].leaf;
  38.         i.data.indirecttext.validstring = Module_SmallFileIcon;
  39.         i.data.indirecttext.bufflen     = 16;
  40.         wimp_ploticon(&i);
  41. }
  42.  
  43. /* This procedure handles a "Large Icons" display */
  44.  
  45. void display_mlarge(int handle, int module, wimp_redrawstr *r)
  46. {
  47.         wimp_icon i;
  48.  
  49.         large_icon(module,&i.box);
  50.         i.flags  = LARGE_TESTING LARGE_FLAGS;
  51.         i.data.indirecttext.buffer      = data[handle]->m[module].leaf;
  52.         i.data.indirecttext.validstring = Module_LargeFileIcon;
  53.         i.data.indirecttext.bufflen     = 16;
  54.         wimp_ploticon(&i);
  55. }
  56.  
  57. /* These procedures set the given wimp_box to enclose the given index
  58.  * of a module (whether it exists or not - no check is made here)
  59.  */
  60.  
  61. void large_icon(int index, wimp_box *box)
  62. {
  63.         box->x0 = LARGE_ICONSWIDTH * (index % LARGE_ICONSPERROW);
  64.         box->x1 = box->x0 + LARGE_ICONSWIDTH;
  65.         box->y1 = -44-(LARGE_ICONSHEIGHT*(index / LARGE_ICONSPERROW)) - 8;
  66.         box->y0 = box->y1 - LARGE_ICONSHEIGHT - 4 + 32;
  67. }
  68.  
  69. void small_icon(int index, wimp_box *box)
  70. {
  71.         box->x0 = SMALL_ICONSWIDTH * (index % SMALL_ICONSPERROW);
  72.         box->x1 = box->x0 + SMALL_ICONSWIDTH;
  73.         box->y1 = -44-(SMALL_ICONSHEIGHT*(index / SMALL_ICONSPERROW));
  74.         box->y0 = box->y1 - SMALL_ICONSHEIGHT - 4;
  75. }
  76.  
  77. void finfo_icon(int index, wimp_box *box)
  78. {
  79.         box->x0 = 4 + 0;
  80.         box->x1 = 4 + FULLINFO_WIDTH;
  81.         box->y1 = -44-(LineGap*index);
  82.         box->y0 = box->y1 - LineGap - 4;
  83. }
  84.  
  85. int matchbox(int handle)
  86. {
  87.         SFI d = data[handle];
  88.         int boxing = -1;  /* Handle of module pointer is over */
  89.  
  90.         union {
  91.                 coords_pointstr point;
  92.                 coords_pointstr wao  ;
  93.               } xy;
  94.         coords_cvtstr   cvtstr;
  95.         wimp_wstate     state;
  96.         wimp_mousestr   mouse;
  97.  
  98.         wimp_get_point_info(&mouse);      /* Read pointer position */
  99.         wimp_get_wind_state(d->w,&state); /* Read the window state */
  100.  
  101.         cvtstr.box = state.o.box;         /* Transfer the coordinates to cvtstr */
  102.         cvtstr.scx = state.o.x;           /* x scroll position                  */
  103.         cvtstr.scy = state.o.y;           /* y scroll position                  */
  104.         xy.point.x = mouse.x;             /* x-mouse location                   */
  105.         xy.point.y = mouse.y;             /* y-mouse location                   */
  106.  
  107.         coords_point_toworkarea(&xy.point,&cvtstr); /* Transform co-ordinates   */
  108.  
  109.         xy.wao.y = - xy.wao.y - 48;
  110.         boxing =  (xy.wao.y < 0) ? -1 : multi[d->disp].withinbox(&xy.wao,d);
  111.  
  112.         return boxing >= d->entries ? -1 : boxing;
  113. }
  114.  
  115. int small_box(coords_pointstr *c,SFI d)
  116. {
  117.         int row = (c->y / SMALL_ICONSHEIGHT) * SMALL_ICONSPERROW;
  118.         int col = (c->x / SMALL_ICONSWIDTH ) ;
  119.  
  120.         return col + row;
  121. }
  122.  
  123. int large_box(coords_pointstr *c,SFI d)
  124. {
  125.         int row = (c->y / LARGE_ICONSHEIGHT) * LARGE_ICONSPERROW;
  126.         int col = (c->x / LARGE_ICONSWIDTH );
  127.  
  128.         return col + row;
  129. }
  130.  
  131. int finfo_box(coords_pointstr *c, SFI d)
  132. {
  133.         return ((c->y-4) / LineGap);
  134. }
  135.