Subversion Repositories Kolibri OS

Rev

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

  1. CustomCursor CursorPointer;
  2. dword CursorFile = FROM "TWB/pointer.cur";
  3. #include "..\lib\collection.h"
  4.  
  5. struct PAGE_LINKS {
  6.         collection link;
  7.         collection page_links;
  8.        
  9.         collection_int x;
  10.         collection_int y;
  11.         collection_int w;
  12.         collection_int h;
  13.         collection_int id;
  14.         collection_int underline_h;
  15.  
  16.         signed int active;
  17.         dword active_url;
  18.         bool hover();
  19.         void add_link();
  20.         void add_text();
  21.         void clear();
  22.         void draw_underline();
  23. } links;
  24.  
  25. void PAGE_LINKS::add_link(dword lpath)
  26. {
  27.         page_links.add(lpath);
  28. }
  29.  
  30. void PAGE_LINKS::add_text(dword _x, _y, _w, _h, _underline_h)
  31. {
  32.         x.add(_x);
  33.         y.add(_y);
  34.         w.add(_w);
  35.         h.add(_h);
  36.         underline_h.add(_underline_h);
  37.         link.add(page_links.get_last());
  38.         id.add(page_links.count);
  39. }
  40.  
  41. void PAGE_LINKS::clear()
  42. {
  43.         x.drop();
  44.         y.drop();
  45.         w.drop();
  46.         h.drop();
  47.         underline_h.drop();
  48.         link.drop();
  49.         id.drop();
  50.  
  51.         page_links.drop();
  52.         page_links.realloc_size = 4096 * 32;
  53.         active = -1;
  54.         active_url = 0;
  55.         CursorPointer.Restore();
  56. }
  57.  
  58. void PAGE_LINKS::draw_underline(signed _id, dword list_first, list_y, color)
  59. {
  60.         int i;
  61.         if (_id == -1) return;
  62.         for (i=0; i<id.count; i++)
  63.         {
  64.                 if (id.get(i) - id.get(_id) == 0)
  65.                 && (y.get(i) + h.get(i) - list_first > list_y) {
  66.                         DrawBar(x.get(i), y.get(i) + h.get(i) - list_first,
  67.                                 w.get(i), underline_h.get(i), color);
  68.                 }              
  69.         }
  70. }
  71.  
  72. bool PAGE_LINKS::hover(dword list_y, list_first)
  73. {
  74.         int i;
  75.         int mx = mouse.x;
  76.         int my = mouse.y + list_first;
  77.         if (!id.count) return false;
  78.  
  79.         //Here we check is any link hovered
  80.         for (i=0; i<id.count; i++)
  81.         {
  82.                 if (mx>x.get(i)) && (my>y.get(i))
  83.                 && (mx<x.get(i)+w.get(i)) && (my<y.get(i)+h.get(i))
  84.                 && (my>list_y+list_first)
  85.                 {
  86.                         if (active!=i) {
  87.                                 CursorPointer.Load(#CursorFile);
  88.                                 CursorPointer.Set();
  89.  
  90.                                 draw_underline(active, list_first, list_y, link_color_default);                
  91.                                 draw_underline(i, list_first, list_y, DEFAULT_BG_COL);
  92.  
  93.                                 active_url = link.get(i);
  94.                                 active = i;
  95.                                 DrawStatusBar(active_url);
  96.                         }
  97.                         if (mouse.lkm) && (mouse.down) {
  98.                                 DrawRectangle(x.get(active), -list_first + y.get(active),
  99.                                         w.get(active), h.get(active), 0);
  100.                         }
  101.                         return true;
  102.                 }
  103.         }
  104.         if (active_url) {
  105.                 CursorPointer.Restore();
  106.                 draw_underline(active, list_first, list_y, link_color_default);
  107.                 active_url = 0;
  108.                 active = -1;
  109.                 DrawStatusBar(NULL);
  110.         }
  111.         return false;
  112. }
  113.  
  114.