Subversion Repositories Kolibri OS

Rev

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