Subversion Repositories Kolibri OS

Rev

Rev 5746 | 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. struct array_link {
  8.         dword link, text;
  9.         int x,y,w,h;
  10.         int underline;
  11. };
  12.  
  13. struct LinksArray {
  14.         array_link links[400];
  15.         char page_links[64000];
  16.         dword buflen;
  17.         int count, active;
  18.         void Hover();
  19.         void AddLink();
  20.         void AddText();
  21.         dword GetURL();
  22.         void Clear();
  23.         void GetAbsoluteURL();
  24.         int UrlAbsolute();
  25. } PageLinks;
  26.  
  27. void LinksArray::AddLink(dword lpath, int link_x, link_y)
  28. {
  29.         links[count].x = link_x;
  30.         links[count].y = link_y;
  31.  
  32.         links[count].link = buflen;
  33.         strcpy(buflen, lpath);
  34.         buflen += strlen(lpath)+1;
  35.         count++;
  36. }
  37.  
  38. void LinksArray::AddText(dword new_text, int link_w, link_h, link_underline)
  39. {
  40.         if (count<1) return;
  41.         links[count-1].w = link_w;
  42.         links[count-1].h = link_h;
  43.         links[count-1].underline = link_underline;
  44.  
  45.         links[count-1].text = buflen;
  46.         strcpy(buflen, new_text);
  47.         buflen += strlen(new_text)+1;
  48. }
  49.  
  50. dword LinksArray::GetURL(int id)
  51. {
  52.         return links[id].link;
  53. }
  54.  
  55. void LinksArray::Clear()
  56. {
  57.         int i;
  58.         for (i=0; i<=count; i++) DeleteButton(i+400);
  59.         buflen = #page_links;
  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.         signed int WBY =  -WB1.list.first*WB1.list.line_h + WB1.list.line_h - WB1.DrawBuf.zoom;
  72.         for (i=0; i<count; i++)
  73.         {
  74.                 if (mx>links[i].x) && (my>links[i].y) && (mx<links[i].x+links[i].w) && (my<links[i].y+links[i].h)
  75.                 {
  76.                         if (active==i) return;
  77.                         CursorPointer.Set();
  78.                         if (links[active].underline) DrawBar(links[active].x, WBY + links[active].y,links[active].w, WB1.DrawBuf.zoom, link_col_in);
  79.                         if (links[i].underline) DrawBar(links[i].x, WBY + links[i].y,links[i].w, WB1.DrawBuf.zoom, bg_col);
  80.                         active = i;
  81.                         status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
  82.                         status_text.start_y = Form.cheight - STATUSBAR_H + 3;
  83.                         status_text.area_size_x = Form.cwidth - status_text.start_x -3;
  84.                         DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
  85.                         status_text.text_pointer = links[active].link;
  86.                         PathShow_prepare stdcall(#status_text);
  87.                         PathShow_draw stdcall(#status_text);
  88.                         return;
  89.                 }
  90.         }
  91.         if (active!=-1)
  92.         {
  93.                 CursorPointer.Restore();
  94.                 if (links[active].underline) DrawBar(links[active].x, WBY + links[active].y,links[active].w, WB1.DrawBuf.zoom, link_col_in);
  95.                 DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
  96.                 active = -1;
  97.         }
  98. }
  99.  
  100. int LinksArray::UrlAbsolute(dword in_URL)
  101. {
  102.         if(!strncmp(in_URL,"http:",5)) return 1;
  103.         if(!strncmp(in_URL,"https:",6)) return 1;
  104.         if(!strncmp(in_URL,"mailto:",7)) return 1;
  105.         if(!strncmp(in_URL,"ftp:",4)) return 1;
  106.         if(!strncmp(in_URL,"WebView:",8)) return 1;
  107.         if(!strncmp(in_URL,"/sys/",5)) return 1;
  108.         if(!strncmp(in_URL,"/hd/",4)) return 1;
  109.         if(!strncmp(in_URL,"/fd/",4)) return 1;
  110.         if(!strncmp(in_URL,"/rd/",4)) return 1;
  111.         if(!strncmp(in_URL,"/tmp/",5)) return 1;
  112.         if(!strncmp(in_URL,"/cd/",4)) return 1;
  113.         if(!strncmp(in_URL,"/bd/",4)) return 1;
  114.         if(!strncmp(in_URL,"/usbhd/",7)) return 1;
  115.         if(!strncmp(in_URL,"/kolibrios/",11)) return 1;
  116.         return 0;
  117. }
  118.  
  119. void LinksArray::GetAbsoluteURL(dword in_URL)
  120. {
  121.         int i;
  122.         dword orig_URL = in_URL;
  123.         char newurl[sizeof(URL)];
  124.  
  125.         if (UrlAbsolute(in_URL)) return;
  126.        
  127.         IF (!strcmpn(in_URL,"./", 2)) in_URL+=2;
  128.         if (!http_transfer)
  129.         {
  130.                 strcpy(#newurl, BrowserHistory.CurrentUrl());
  131.         }
  132.         else
  133.         {
  134.                 strcpy(#newurl, #history_list[BrowserHistory.current-1].Item);
  135.         }
  136.  
  137.         if (ESBYTE[in_URL] == '/') //remove everything after site domain name
  138.         {
  139.                 i = strchr(#newurl+8, '/');
  140.                 if (i) ESBYTE[i]=0;
  141.                 in_URL+=1;
  142.         }
  143.                
  144.         _CUT_ST_LEVEL_MARK:
  145.                
  146.         if (newurl[strrchr(#newurl, '/')-2]<>'/')
  147.         {
  148.                 newurl[strrchr(#newurl, '/')] = 0x00;
  149.         }
  150.        
  151.         IF (!strncmp(in_URL,"../",3))
  152.         {
  153.                 in_URL+=3;
  154.                 newurl[strrchr(#newurl, '/')-1] = 0x00;
  155.                 goto _CUT_ST_LEVEL_MARK;
  156.         }
  157.        
  158.         if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/");
  159.        
  160.         strcat(#newurl, in_URL);
  161.         strcpy(orig_URL, #newurl);
  162. }
  163.  
  164.