Subversion Repositories Kolibri OS

Rev

Rev 6731 | 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, text;
  12.         int x,y,w,h;
  13.         int underline;
  14. };
  15.  
  16. struct LinksArray {
  17.         array_link links[MAXLINKS];
  18.         collection page_links;
  19.         dword buflen;
  20.         int count, active;
  21.         void Hover();
  22.         void AddLink();
  23.         void AddText();
  24.         dword GetURL();
  25.         void Clear();
  26. } PageLinks;
  27.  
  28. void LinksArray::AddLink(dword lpath, int link_x, link_y)
  29. {
  30.         if (count>= MAXLINKS) return;
  31.         links[count].x = link_x;
  32.         links[count].y = link_y;
  33.  
  34.         page_links.add(lpath);
  35.         links[count].link = page_links.get(page_links.count-1);
  36.         count++;
  37. }
  38.  
  39. void LinksArray::AddText(dword new_text, int link_w, link_h, link_underline)
  40. {
  41.         if (count>= MAXLINKS) || (!count) return;
  42.         links[count-1].w = link_w;
  43.         links[count-1].h = link_h;
  44.         links[count-1].underline = link_underline;
  45.  
  46.         page_links.add(new_text);
  47.         links[count-1].text = page_links.get(page_links.count-1);
  48. }
  49.  
  50. dword LinksArray::GetURL(int id)
  51. {
  52.         return links[id].link;
  53. }
  54.  
  55. void LinksArray::Clear()
  56. {
  57.         page_links.drop();
  58.         page_links.realloc_size = 4096 * 32;
  59.         count = 0;
  60.         active = -1;
  61.         CursorPointer.Restore();
  62. }
  63.  
  64. char temp[sizeof(URL)];
  65. PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, #temp, 0};
  66.  
  67. void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
  68. {
  69.         int i;
  70.         signed int WBY =  -WB1.list.first*WB1.list.item_h - WB1.DrawBuf.zoom;
  71.         for (i=0; i<count; i++)
  72.         {
  73.                 if (mx>links[i].x) && (my>links[i].y) && (mx<links[i].x+links[i].w) && (my<links[i].y+links[i].h)
  74.                 {
  75.                         if (mouse.down) DrawRectangle(links[active].x, -WB1.list.first*WB1.list.item_h + links[active].y, links[active].w, links[active].h, 0);
  76.                         if (mouse.up) ClickLink();
  77.                         if (active==i) return;
  78.                         CursorPointer.Set();
  79.                         if (links[active].underline) DrawBar(links[active].x, WBY + links[active].y + links[active].h,links[active].w, WB1.DrawBuf.zoom, link_col_in);
  80.                         if (links[i].underline) DrawBar(links[i].x, WBY + links[i].y + links[i].h,links[i].w, WB1.DrawBuf.zoom, bg_col);
  81.                         active = i;
  82.                         status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
  83.                         status_text.start_y = Form.cheight - STATUSBAR_H + 3;
  84.                         status_text.area_size_x = Form.cwidth - status_text.start_x -3;
  85.                         DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
  86.                         status_text.text_pointer = links[active].link;
  87.                         PathShow_prepare stdcall(#status_text);
  88.                         PathShow_draw stdcall(#status_text);
  89.                         return;
  90.                 }
  91.         }
  92.         if (active!=-1)
  93.         {
  94.                 CursorPointer.Restore();
  95.                 if (links[active].underline) DrawBar(links[active].x, WBY + links[active].y  + links[active].h,links[active].w, WB1.DrawBuf.zoom, link_col_in);
  96.                 DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
  97.                 active = -1;
  98.         }
  99. }
  100.