Subversion Repositories Kolibri OS

Rev

Rev 7771 | 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. #define NOLINE    0
  6. #define UNDERLINE 1
  7.  
  8. #define MAXLINKS 2000
  9.  
  10. bool open_new_window=false;
  11. bool open_new_tab=false;
  12.  
  13. struct array_link {
  14.         dword link;
  15.         unsigned int x,y,w,h;
  16.         unsigned int unic_id;
  17.         int underline, underline_h;
  18. };
  19.  
  20. struct LinksArray {
  21.         array_link links[MAXLINKS];
  22.         collection page_links;
  23.         unsigned int count;
  24.         unsigned int unic_count;
  25.         unsigned int active;
  26.         bool HoverAndProceed();
  27.         void AddLink();
  28.         void AddText();
  29.         dword GetURL();
  30.         void Clear();
  31.         void DrawUnderline();
  32. } PageLinks;
  33.  
  34. void LinksArray::AddLink(dword lpath)
  35. {
  36.         if (count>= MAXLINKS) return;
  37.         page_links.add(lpath);
  38.         unic_count++;
  39. }
  40.  
  41. void LinksArray::AddText(dword _x, _y, _w, _h, _link_underline, _underline_h)
  42. {
  43.         if (count>= MAXLINKS) return;
  44.         links[count].x = _x;
  45.         links[count].y = _y;
  46.         links[count].w = _w;
  47.         links[count].h = _h;
  48.         links[count].underline = _link_underline;
  49.         links[count].underline_h = _underline_h;
  50.         links[count].link = page_links.get(page_links.count-1);
  51.         links[count].unic_id = unic_count;
  52.         count++;
  53. }
  54.  
  55. dword LinksArray::GetURL(int id)
  56. {
  57.         return links[id].link;
  58. }
  59.  
  60. void LinksArray::Clear()
  61. {
  62.         page_links.drop();
  63.         page_links.realloc_size = 4096 * 32;
  64.         count = 0;
  65.         active = -1;
  66.         unic_count = 0;
  67.         CursorPointer.Restore();
  68.         open_new_window = false;
  69. }
  70.  
  71. void LinksArray::DrawUnderline(dword und_id, list_first, list_y, color)
  72. {
  73.         int i;
  74.         for (i=0; i<count; i++)
  75.         {
  76.                 if (links[i].unic_id==links[und_id].unic_id) && (links[i].y + links[i].h - list_first > list_y) {
  77.                         DrawBar(links[i].x, links[i].y + links[i].h - list_first, links[i].w, links[i].underline_h, color);
  78.                 }              
  79.         }
  80. }
  81.  
  82. PathShow_data status_text = {0, 17,250, 6, 250};
  83.  
  84. bool LinksArray::HoverAndProceed(dword mx, my, list_y, list_first)
  85. {
  86.         int i;
  87.         if (!count) return true;
  88.         for (i=0; i<count; i++)
  89.         {
  90.                 if (mx>links[i].x) && (my>links[i].y)
  91.                 && (mx<links[i].x+links[i].w) && (my<links[i].y+links[i].h)
  92.                 && (my>list_y+list_first)
  93.                 {
  94.                         if (mouse.lkm) && (mouse.down) {
  95.                                 DrawRectangle(links[active].x, -list_first + links[active].y,
  96.                                 links[active].w, links[active].h, 0);
  97.                                 return false;
  98.                         }
  99.                         if (mouse.mkm) && (mouse.up) {
  100.                                 if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
  101.                                         ProcessEvent(IN_NEW_TAB);
  102.                                 } else {
  103.                                         ProcessEvent(IN_NEW_WINDOW);
  104.                                 }
  105.                                 return false;
  106.                         }
  107.                         if (mouse.lkm) && (mouse.up) {
  108.                                 CursorPointer.Restore();
  109.                                 EventClickLink(PageLinks.GetURL(PageLinks.active));
  110.                                 return false;
  111.                         }
  112.                         if (mouse.pkm) && (mouse.up) {
  113.                                 EventShowLinkMenu();
  114.                                 return false;
  115.                         }
  116.                         if (active==i) return false;
  117.                         CursorPointer.Load(#CursorFile);
  118.                         CursorPointer.Set();
  119.  
  120.                         if (links[active].underline) {
  121.                                 DrawUnderline(active, list_first, list_y, link_color_default);                 
  122.                         }
  123.  
  124.                         if (links[i].underline) {
  125.                                 DrawUnderline(i, list_first, list_y, page_bg);
  126.                         }
  127.  
  128.                         active = i;
  129.                         DrawStatusBar(links[active].link);
  130.                         return true;
  131.                 }
  132.         }
  133.         if (active!=-1)
  134.         {
  135.                 CursorPointer.Restore();
  136.                 if (links[active].underline) {
  137.                         DrawUnderline(active, list_first, list_y, link_color_default);
  138.                 }
  139.                 DrawStatusBar(NULL);
  140.                 active = -1;
  141.         }
  142. }
  143.  
  144.