Subversion Repositories Kolibri OS

Rev

Rev 4497 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. CustomCursor CursorPointer;
  2. dword CursorFile = FROM "../TWB/pointer.cur";
  3.  
  4. #define NOLINE    0
  5. #define UNDERLINE 1
  6.  
  7.  
  8. struct array_link {
  9.         dword link, text;
  10.         int x,y,w,h;
  11.         int underline;
  12. };
  13.  
  14. struct LinksArray
  15. {
  16.         array_link links[200];
  17.         char page_links[64000];
  18.         dword buflen;
  19.         int count, active;
  20.  
  21.         void Hover();
  22.         void AddLink();
  23.         void AddText();
  24.         dword GetURL();
  25.         void Clear();
  26. };
  27.  
  28. void LinksArray::AddLink(dword new_link, int link_x, link_y)
  29. {
  30.         links[count].x = link_x;
  31.         links[count].y = link_y;
  32.  
  33.         links[count].link = buflen;
  34.         strcpy(buflen, new_link);
  35.         buflen += strlen(new_link)+1;
  36.         count++;
  37. }
  38.  
  39. void LinksArray::AddText(dword new_text, int link_w, link_h, link_underline)
  40. {
  41.         if (count<1) return;
  42.         links[count-1].w = link_w;
  43.         links[count-1].h = link_h;
  44.         links[count-1].underline = link_underline;
  45.  
  46.         links[count-1].text = buflen;
  47.         strcpy(buflen, new_text);
  48.         buflen += strlen(new_text)+1;
  49. }
  50.  
  51. dword LinksArray::GetURL(int id)
  52. {
  53.         return links[id].link;
  54. }
  55.  
  56. void LinksArray::Clear()
  57. {
  58.         int i;
  59.         for (i=0; i<=count; i++) DeleteButton(i+400);
  60.         buflen = #page_links;
  61.         count = 0;
  62.         active = -1;
  63.         CursorPointer.Restore();
  64. }
  65.  
  66.  
  67. void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
  68. {
  69.         int i;
  70.         for (i=0; i<count; i++)
  71.         {
  72.                 if (mx>links[i].x) && (my>links[i].y) && (mx<links[i].x+links[i].w) && (my<links[i].y+links[i].h)
  73.                 {
  74.                         if (active==i) return;
  75.                         CursorPointer.Set();
  76.                         if (links[active].underline) DrawBar(links[active].x,links[active].y+8,links[active].w,1, link_col_in);
  77.                         if (links[i].underline) DrawBar(links[i].x,links[i].y+8,links[i].w,1, bg_col);
  78.                         active = i;
  79.                         return;
  80.                 }
  81.         }
  82.         if (active!=-1)
  83.         {
  84.                 CursorPointer.Restore();
  85.                 if (links[active].underline) DrawBar(links[active].x,links[active].y+8,links[active].w,1, link_col_in);
  86.                 active = -1;
  87.         }
  88. }
  89.  
  90.  
  91. LinksArray PageLinks;
  92.