Subversion Repositories Kolibri OS

Rev

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