Subversion Repositories Kolibri OS

Rev

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

  1. //HTML Viewer in C--
  2. //Copyright 2007-2012 by Veliant & Leency
  3. //Asper, lev, Lrz, Barsuk, Nable.
  4. //home icon - rachel fu, GPL licence
  5.  
  6. #include "..\lib\kolibri.h"
  7. #include "..\lib\encoding.h"
  8. #include "..\lib\file_system.h"
  9. #include "img\toolbar_icons.c"
  10. #include "img\URLgoto.txt";
  11. #include "..\lib\mem.h"
  12. #include "..\lib\libio_lib.h"
  13. #include "..\lib\libimg_lib.h"
  14. #include "..\lib\edit_box_lib.h"
  15. #include "..\lib\dll.h"
  16. #include "..\lib\scroll_bar\scroll_lib.h"
  17.  
  18. //ïåðåìåííûå
  19. char URL[4096],
  20.         editURL[4096],
  21.         page_links[12000],
  22.         header[512];
  23.  
  24. struct lines{
  25.         int visible, all, first, column_max;
  26. };
  27.  
  28. int     mouse_dd;
  29. edit_box edit1= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,248,#editURL,#mouse_dd,2,19,19};
  30. scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; //details in scroll_lib.h--
  31.  
  32. proc_info Form;
  33. dword stak[100]; //ìåíþ ÏÊÌ
  34. mouse m;
  35.  
  36. #include "TWB.h"
  37. #include "include\menu_rmb.h"
  38.  
  39.  
  40. void main()
  41. {
  42.         int btn;
  43.         byte key;
  44.         int half_scroll_size;
  45.        
  46.         mem_Init();
  47.         load_dll2(libio, #libio_init,1);
  48.         load_dll2(libimg, #libimg_init,1);
  49.         load_dll2(boxlib, #edit_box_draw,0);
  50.         load_dll2(#abox_lib, #boxlib_init,0);
  51.        
  52.         if (param) strcpy(#URL, #param);
  53.                 else strcpy(#URL, "/sys/index.htm");
  54.         strcpy(#editURL, #URL);
  55.        
  56.         WB1.OpenPage();
  57.  
  58.         SetEventMask(0x27);
  59.         loop()
  60.         {
  61.                 WaitEventTimeout(2);
  62.                 switch(EAX & 0xFF)
  63.                 {
  64.                         CASE evMouse:
  65.                                 /*scrollbar_v_mouse (#scroll1);      //êîí÷åíûé ñêðîëë ïðèòîðìàæèìàåò, èä¸ì "ñâîèì ïóò¸ì"
  66.                                 if (lines.first <> scroll1.position)
  67.                                 {
  68.                                         lines.first = scroll1.position;
  69.                                         WB1.ParseHTML(buf, filesize);
  70.                                         //break;
  71.                                 };*/
  72.                                
  73.                                 btn=GetSlot(Form.ID);
  74.                                 IF (btn<>ActiveProcess()) break; //åñëè îêíî íå àêòèâíî íà ñîáûòèÿ ìûøè íå ðåàãèðóåì
  75.  
  76.                                 edit_box_mouse stdcall (#edit1);
  77.  
  78.                                 m.get();
  79.                                
  80.                                 if (m.pkm) && (m.y>WB1.top) && (m.y<Form.height) && (filesize)
  81.                                 {
  82.                                         CreateThread(#menu_rmb,#stak);
  83.                                 }
  84.  
  85.                                 IF (m.vert==65535) //ïðîêðóòêà êîë¸ñèêîì
  86.                                 {
  87.                                         IF (lines.first==0) break;
  88.                                         IF (lines.first>3) lines.first-=2; ELSE lines.first=1;
  89.                                         WB1.Scan(ID1);
  90.                                         break;
  91.                                 }
  92.                                 IF (m.vert==1)
  93.                                 {
  94.                                         IF(lines.visible+lines.first+3>=lines.all) WB1.Scan(181);
  95.                                         ELSE    {
  96.                                                 lines.first+=2;
  97.                                                 WB1.Scan(ID2);
  98.                                         }
  99.                                         break;
  100.                                 }
  101.                                
  102.                                 IF (lines.all<lines.visible) break;
  103.                                 half_scroll_size = WB1.height - 16 * lines.visible / lines.all - 3 /2;
  104.                                 if (m.x>=WB1.width-14) && (m.x<=WB1.width+6)
  105.                                 && (m.y>WB1.top+16) && (m.y<WB1.top+WB1.height-16)
  106.                                 && (lines.all>lines.visible) while (m.lkm)
  107.                                 {
  108.                                         IF (half_scroll_size/2+WB1.top>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size/2+WB1.top; //åñëè êóðñîð íàä îêíîì
  109.                                         btn=lines.first; //ñîõðàíÿåì ñòàðîå êîëè÷åñòâî
  110.                                         lines.first = m.y -half_scroll_size -WB1.top * lines.all / WB1.height;
  111.                                         IF (lines.visible+lines.first>lines.all) lines.first=lines.all-lines.visible;
  112.                                         IF (btn<>lines.first) WB1.ParseHTML(buf, filesize); //÷òîá ëèøíèé ðàç íå ïåðåðèñîâûâàòü
  113.                                         m.get();
  114.                                 }
  115.  
  116.                                 break;
  117.                         case evButton:
  118.                                 btn=GetButtonID();
  119.                                 IF (btn==1)
  120.                                 {
  121.                                         KillProcess(downloader_id);
  122.                                         ExitProcess();
  123.                                 }
  124.                                 ELSE
  125.                                 {
  126.                                         WB1.Scan(btn);
  127.                                 }
  128.                                 break;
  129.                         case evKey:
  130.                                 key = GetKey();
  131.                                
  132.                                 if (edit1.flags == 66) || (edit1.flags == 98) SWITCH(key) //åñëè àêòèâíà ñòðîêà àäðåñà èãíîðèðóåì íåêîòîðûå êíîïêè
  133.                                         { CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; }
  134.  
  135.                                 WB1.Scan(key);
  136.                                
  137.                                 _EDIT_MARK:
  138.                                 IF (key<>0x0d) && (key<>183) && (key<>184) && (key<>173) {EAX=key<<8; edit_box_key stdcall(#edit1);} //àäðåñíàÿ ñòðîêà
  139.                                 break;
  140.                         case evReDraw:
  141.                                 Draw_Window();
  142.                                 break;
  143.                         default:
  144.                                 if (downloader_id<>0)
  145.                                 {
  146.                                         if (GetProcessSlot(downloader_id)<>0) break;
  147.                                         downloader_id=0;
  148.                                         lines.first = lines.all = 0;
  149.                                         WB1.ReadHtml(_WIN);
  150.                                         Draw_Window();
  151.                                 }
  152.                 }
  153.         }
  154. }
  155.  
  156.  
  157. void Draw_Window()
  158. {
  159.         int j;
  160.         DefineAndDrawWindow(215,100,640,480,0x73,0x00E4DFE1,0,0,0);
  161.  
  162.         GetProcessInfo(#Form, SelfInfo);
  163.         if (Form.status_window>2) //åñëè ñâåðíóòî â çàãîëîâîê, íè÷åãî íå ðèñóåì
  164.         {
  165.                 DrawTitle(#header);
  166.                 return;
  167.         }
  168.         if (Form.height<120) MoveSize(OLD,OLD,OLD,120);
  169.         if (Form.width<280) MoveSize(OLD,OLD,280,OLD);
  170.        
  171.         PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
  172.         if (GetProcessSlot(downloader_id)<>0) PutImage(#stop_btn,24,24,88,10);
  173.        
  174.         DrawBar(200,0,onLeft(200,9),43,0xE4DFE1); //çàêðàøèâàåì ôîí ïîä òóëáàðîì
  175.         DrawBar(0,42,onLeft(5,4),1,0xE2DBDC); //âûïóêëîñòü
  176.         DrawBar(0,43,onLeft(5,4),1,0xD2CED0); //âûïóêëîñòü
  177.         for (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0x00E4DFE1);
  178.         PutImage(#URLgoto,40,19,onLeft(57,0),14);
  179.         DefineButton(onLeft(37,0),15, 18, 16, GOTOURL+BT_HIDE, 0xE4DFE1);
  180.         DefineButton(onLeft(56,0),15, 17, 16, SEARCHWEB+BT_HIDE, 0xE4DFE1);
  181.         DrawRegion(205,14,onLeft(58,205),18,0x94AECE); //îáîäîê ïîëîñû àäðåñà
  182.         DrawRegion(206,15,onLeft(59,205),16,0xE4ECF3);
  183.  
  184.         edit1.width=Form.width-266;
  185.         WB1.top=44;
  186.         WB1.width=Form.width-13;
  187.         WB1.height=onTop(43,5);
  188.         lines.column_max = WB1.width - 30 / 6;
  189.         lines.visible = WB1.height - 3 / 10 - 2;
  190.  
  191.         WB1.ShowPage();
  192. }
  193.  
  194. int onLeft(dword right,left) {return Form.width-right-left;}
  195. int onTop(dword down,up) {return Form.height-GetSkinWidth()-down-up;}
  196.  
  197.  
  198. stop:
  199.