Subversion Repositories Kolibri OS

Rev

Rev 4059 | Rev 4073 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. //list_box
  2.  
  3. struct llist
  4. {
  5.         int x, y, w, h, min_h, line_h;
  6.         int count, visible, first, current;
  7.         int current_temp;
  8.         void ClearList();
  9.         int KeyDown();
  10.         int KeyUp();
  11.         int KeyHome();
  12.         int KeyEnd();
  13.         void SetSizes(int xx, yy, ww, hh, min_hh, line_hh);
  14.         int MouseScroll(dword scroll_state);
  15. };
  16.  
  17.  
  18. void llist::ClearList()
  19. {
  20.         count = visible = first = current = 0;
  21. }
  22.  
  23.  
  24. void llist::SetSizes(int xx, yy, ww, hh, min_hh, line_hh)
  25. {
  26.         x = xx;
  27.         y = yy;
  28.         w = ww;
  29.         h = hh;
  30.         min_h = min_hh;
  31.         line_h = line_hh;
  32.         visible = h / line_h;
  33. }
  34.  
  35.  
  36. int llist::MouseScroll(dword scroll_state)
  37. {
  38.         if (scroll_state == 65535)
  39.         {
  40.                 if (first == 0) return 0;
  41.                 if (first > 3) first -= 2; else first=0;
  42.                 return 1;
  43.         }
  44.         if (scroll_state == 1)
  45.         {
  46.                 if (visible+first+3 >= count) first = count - visible; else first+=2;
  47.                 return 1;
  48.         }
  49.         return 0;
  50. }
  51.  
  52. int llist::KeyDown()
  53. {
  54.         if (current-first+1<visible)
  55.         {
  56.                 if (current+1>=count) return 0;
  57.                 current++;
  58.         }
  59.         else
  60.         {
  61.                 if (visible+first>=count) return 0;
  62.                 first++;
  63.                 current++;
  64.         }
  65.         return 1;
  66. }
  67.  
  68. int llist::KeyUp()
  69. {
  70.         if (current>first)
  71.         {
  72.                 current--;
  73.         }
  74.         else
  75.         {
  76.                 if (first==0) return 0;
  77.                 first--;
  78.                 current--;
  79.         }
  80.         return 1;
  81. }
  82.  
  83. int llist::KeyHome()
  84. {
  85.         if (current==0) && (first==0) return 0;
  86.         current=0;
  87.         first=0;
  88.         return 1;
  89. }
  90.  
  91. int llist::KeyEnd()
  92. {
  93.         if (current==count-1) && (first==count-visible) return 0;
  94.         current=count-1;
  95.         first=count-visible;
  96.         return 1;
  97. }