Subversion Repositories Kolibri OS

Rev

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