Subversion Repositories Kolibri OS

Rev

Rev 6738 | 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, underline_h;
  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 link_w, link_h, link_underline, _underline_h, new_text)
  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.         links[count-1].underline_h = _underline_h;
  46.  
  47.         page_links.add(new_text);
  48.         links[count-1].text = page_links.get(page_links.count-1);
  49. }
  50.  
  51. dword LinksArray::GetURL(int id)
  52. {
  53.         return links[id].link;
  54. }
  55.  
  56. void LinksArray::Clear()
  57. {
  58.         page_links.drop();
  59.         page_links.realloc_size = 4096 * 32;
  60.         count = 0;
  61.         active = -1;
  62.         CursorPointer.Restore();
  63. }
  64.  
  65. char temp[sizeof(URL)];
  66. PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, #temp, 0};
  67.  
  68. void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
  69. {
  70.         int i;
  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 + links[active].y,
  76.                                 links[active].w, links[active].h, 0);
  77.                         if (mouse.up) ClickLink();
  78.                         if (active==i) return;
  79.                         CursorPointer.Set();
  80.                         if (links[active].underline) DrawBar(links[active].x, -WB1.list.first + links[active].y
  81.                                 + links[active].h, links[active].w, links[i].underline_h, link_col_in);
  82.                         if (links[i].underline) DrawBar(links[i].x, -WB1.list.first + links[i].y
  83.                                 + links[i].h, links[i].w, links[i].underline_h, bg_col);
  84.                         active = i;
  85.                         status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
  86.                         status_text.start_y = Form.cheight - STATUSBAR_H + 3;
  87.                         status_text.area_size_x = Form.cwidth - status_text.start_x -3;
  88.                         DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
  89.                         status_text.text_pointer = links[active].link;
  90.                         PathShow_prepare stdcall(#status_text);
  91.                         PathShow_draw stdcall(#status_text);
  92.                         return;
  93.                 }
  94.         }
  95.         if (active!=-1)
  96.         {
  97.                 CursorPointer.Restore();
  98.                 if (links[active].underline) DrawBar(links[active].x, -WB1.list.first + links[active].y  + links[active].h,links[active].w, WB1.DrawBuf.zoom, link_col_in);
  99.                 DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
  100.                 active = -1;
  101.         }
  102. }
  103.