home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / term43-source.lha / Extras / Source / gtlayout-Source.lha / LTP_SelectKeys.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-21  |  2.2 KB  |  125 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1994 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. #ifdef DO_PICKSHORTCUTS
  10. VOID __regargs
  11. LTP_SelectKeys(LayoutHandle *handle,ObjectNode *group)
  12. {
  13.     UBYTE         bunch;
  14.     ObjectNode    *node;
  15.     ULONG         page;
  16.  
  17.     SCANPAGE(group,node,page)
  18.     {
  19.         bunch = 0;
  20.  
  21.         switch(node -> Type)
  22.         {
  23.             case GROUP_KIND:
  24.  
  25.                 LTP_SelectKeys(handle,node);
  26.                 break;
  27.  
  28.             case TEXT_KIND:
  29.  
  30.                 if(!node -> Special . Text . UsePicker)
  31.                     break;
  32.  
  33.             case FRACTION_KIND:
  34.             case PASSWORD_KIND:
  35.             case STRING_KIND:
  36.  
  37.                 if(node -> Special . String . UsePicker)
  38.                     bunch = 255;
  39.  
  40.             case BUTTON_KIND:
  41.             case CHECKBOX_KIND:
  42.             case INTEGER_KIND:
  43.  
  44.                 bunch++;
  45.  
  46.             case LISTVIEW_KIND:
  47.             case MX_KIND:
  48.             case CYCLE_KIND:
  49.             case PALETTE_KIND:
  50.             case SCROLLER_KIND:
  51.             case SLIDER_KIND:
  52. #ifdef DO_LEVEL_KIND
  53.             case LEVEL_KIND:
  54. #endif    /* DO_LEVEL_KIND */
  55. #ifdef DO_TAPEDECK_KIND
  56.             case TAPEDECK_KIND:
  57. #endif    /* DO_TAPEDECK_KIND */
  58.  
  59.                 bunch++;
  60.  
  61.                 if(node -> Label && !node -> Key && !node -> NoKey)
  62.                 {
  63.                     WORD    i,len,code,glyph;
  64.                     STRPTR    label;
  65.  
  66.                     label    = node -> Label;
  67.                     len    = strlen(label);
  68.  
  69.                     for(i = 0 ; i < len ; i++)
  70.                     {
  71.                         glyph    = ToLower(label[i]);
  72.                         code    = -1;
  73.  
  74.                         if(bunch == 1)    // Support increment & decrement
  75.                         {
  76.                             if(LTP_Keys[0][glyph] && LTP_Keys[1][glyph])
  77.                                 code = LTP_Keys[0][glyph];
  78.                         }
  79.                         else
  80.                         {
  81.                             if(bunch == 2)
  82.                             {
  83.                                 if(LTP_Keys[0][glyph])
  84.                                     code = LTP_Keys[0][glyph];
  85.                                 else
  86.                                 {
  87.                                     if(LTP_Keys[1][glyph] && LTP_Keys[0][glyph])
  88.                                     {
  89.                                         if(ToLower(LTP_Keys[1][glyph]) == glyph)
  90.                                             code = LTP_Keys[0][glyph];
  91.                                     }
  92.                                 }
  93.                             }
  94.                         }
  95.  
  96.                         if(code != -1 && !handle -> Keys[code])
  97.                         {
  98.                             STRPTR newLabel;
  99.  
  100.                             if(newLabel = LTP_Alloc(handle,len + 2))
  101.                             {
  102.                                 node -> Label    = newLabel;
  103.                                 node -> Key    = code;
  104.  
  105.                                 if(i)
  106.                                     CopyMem(label,newLabel,i);
  107.  
  108.                                 newLabel[i] = '_';
  109.  
  110.                                 CopyMem(label + i,&newLabel[i + 1],len - i);
  111.  
  112.                                 handle -> Keys[code] = handle -> Keys[LTP_Keys[1][code]] = TRUE;
  113.  
  114.                                 break;
  115.                             }
  116.                         }
  117.                     }
  118.                 }
  119.  
  120.                 break;
  121.         }
  122.     }
  123. }
  124. #endif
  125.