Subversion Repositories Kolibri OS

Rev

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

  1. struct array_link {
  2.         dword link, text;
  3.         int x,y,w,h;
  4. };
  5.  
  6. struct LinksArray
  7. {
  8.         array_link links[100];
  9.         char page_links[12000];
  10.         dword buflen;
  11.         int count, active;
  12.  
  13.         void Hover();
  14.         void AddLink();
  15.         void AddText();
  16.         dword GetURL();
  17.         void Clear();
  18. };
  19.  
  20. void LinksArray::AddLink(dword new_link, int link_x, link_y)
  21. {
  22.         links[count].x = link_x;
  23.         links[count].y = link_y;
  24.  
  25.         links[count].link = buflen;
  26.         strcpy(buflen, new_link);
  27.         buflen += strlen(new_link)+1;
  28.         count++;
  29. }
  30.  
  31. void LinksArray::AddText(dword new_text, int link_w, link_h)
  32. {
  33.         if (count<1) return;
  34.         links[count-1].w = link_w;
  35.         links[count-1].h = link_h;
  36.  
  37.         links[count-1].text = buflen;
  38.         strcpy(buflen, new_text);
  39.         buflen += strlen(new_text)+1;
  40. }
  41.  
  42. dword LinksArray::GetURL(int id)
  43. {
  44.         return links[id].link;
  45. }
  46.  
  47. void LinksArray::Clear()
  48. {
  49.         buflen = #page_links;
  50.         count = 0;
  51.         active = -1;
  52. }
  53.  
  54. void LinksArray::Hover(dword mx, my, link_col_in, link_col_a)
  55. {
  56.         int i;
  57.         if (active>=0)
  58.         {
  59.                 WriteText(links[active].x,links[active].y, 0x80, link_col_in, links[active].text);
  60.                 DrawBar(links[active].x,links[active].y+8,links[active].w,1, link_col_in);
  61.                 active = -1;
  62.         }
  63.         for (i=0; i<count; i++)
  64.         {
  65.                 if (mx>links[i].x) && (my>links[i].y) && (mx<links[i].x+links[i].w) && (my<links[i].y+links[i].h)
  66.                 {
  67.                         WriteText(links[i].x,links[i].y, 0x80, link_col_a, links[i].text);
  68.                         DrawBar(links[i].x,links[i].y+8,links[i].w,1, link_col_a);
  69.                         active = i;
  70.                         return;
  71.                 }
  72.         }
  73. }
  74.  
  75.  
  76. LinksArray PageLinks;