Subversion Repositories Kolibri OS

Rev

Rev 7037 | 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.         for (i=0; i<count; i++)
  68.         {
  69.                 if (mx>links[i].x) && (my>links[i].y) && (mx<links[i].x+links[i].w) && (my<links[i].y+links[i].h)
  70.                 {
  71.                         if (mouse.lkm) && (mouse.down) {
  72.                                 DrawRectangle(links[active].x, -WB1.list.first + links[active].y,
  73.                                 links[active].w, links[active].h, 0);
  74.                                 return false;
  75.                         }
  76.                         if (mouse.mkm) && (mouse.up) {
  77.                                 open_in_a_new_window = true;
  78.                                 ClickLink();
  79.                                 return false;
  80.                         }
  81.                         if (mouse.lkm) && (mouse.up) {
  82.                                 CursorPointer.Restore();
  83.                                 ClickLink();
  84.                                 return false;
  85.                         }
  86.                         if (mouse.pkm) && (mouse.up) {
  87.                                 EventShowLinkMenu(mouse.x, mouse.y);
  88.                                 return false;
  89.                         }
  90.                         if (active==i) return false;
  91.                         CursorPointer.Load(#CursorFile);
  92.                         CursorPointer.Set();
  93.                         if (links[active].underline) DrawBar(links[active].x, -WB1.list.first + links[active].y
  94.                                 + links[active].h, links[active].w, links[active].underline_h, link_color_inactive);
  95.                         if (links[i].underline) DrawBar(links[i].x, -WB1.list.first + links[i].y
  96.                                 + links[i].h, links[i].w, links[i].underline_h, bg_color);
  97.                         active = i;
  98.                         DrawStatusBar(links[active].link);
  99.                         return true;
  100.                 }
  101.         }
  102.         if (active!=-1)
  103.         {
  104.                 CursorPointer.Restore();
  105.                 if (links[active].underline) {
  106.                         DrawBar(links[active].x, -WB1.list.first + links[active].y + links[active].h,links[active].w,
  107.                                 links[active].underline_h, link_color_inactive);
  108.                 }
  109.                 DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
  110.                 active = -1;
  111.         }
  112. }
  113.  
  114.  
  115.