Subversion Repositories Kolibri OS

Rev

Rev 7285 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. dword CursorFile = FROM "pointer.cur";
  2.  
  3. struct _link
  4. {
  5.         CustomCursor CursorPointer;
  6.         int count;
  7.         int x[4096], y[4096], w[4096], h[4096];
  8.         collection text;
  9.         collection url;
  10.         void clear();
  11.         void add();
  12.         int hover();
  13.         int active;
  14.         void draw_underline();
  15. } link;
  16.  
  17. void _link::clear()
  18. {
  19.         text.drop();
  20.         url.drop();
  21.         count = 0;
  22. }
  23.  
  24. void _link::add(int _xx, _yy, _ww, _hh, dword _textt, _urll )
  25. {
  26.         if (count==4095) return;
  27.         x[count] = _xx;
  28.         y[count] = _yy;
  29.         w[count] = _ww;
  30.         h[count] = _hh;
  31.         text.add(_textt);
  32.         url.add(_urll);
  33.         count++;
  34. }
  35.  
  36. void _link::draw_underline(dword i, color)
  37. {
  38.         DrawBar(x[i]+list.x, -list.first*list.item_h+y[i]+list.y+h[i]-1, w[i], 1, color);
  39. }
  40.  
  41. int _link::hover()
  42. {
  43.         int i;
  44.         int new_active = -1;
  45.         int link_start_y = list.first*list.item_h;
  46.         mouse.x = mouse.x - list.x;
  47.         mouse.y = mouse.y - list.y;
  48.         for (i=0; i<count; i++) {
  49.                 if(y[i] > link_start_y) && (y[i] < link_start_y+list.h) {
  50.                         // debugln( sprintf(#param, "mx:%i my:%i x[i]:%i y[i]:%i", mx, my, x[i], y[i]) );
  51.                         if (mouse.x > x[i])
  52.                         && (mouse.x < x[i]+w[i])
  53.                         && (mouse.y > y[i]-link_start_y)
  54.                         && (mouse.y < h[i]-link_start_y+link.y[i]) {
  55.                                 new_active = i;
  56.                                 break;
  57.                         }
  58.                 }
  59.         }
  60.  
  61.         if (new_active != active)
  62.         {
  63.                 if (-1 == new_active) {
  64.                         draw_underline(active, 0x0000FF);
  65.                         CursorPointer.Restore();               
  66.                 }
  67.                 else {
  68.                         draw_underline(active, 0x0000FF);
  69.                         draw_underline(new_active, 0xFFFfff);
  70.                         CursorPointer.Load(#CursorFile);
  71.                         CursorPointer.Set();
  72.                 }
  73.                 active = new_active;
  74.                 return true;
  75.         }
  76.  
  77.         return false;
  78. }