Rev 4191 | Rev 4413 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3067 | leency | 1 | //HTML Viewer in C-- |
3987 | leency | 2 | //Copyright 2007-2013 by Veliant & Leency |
3107 | leency | 3 | //Asper, lev, Lrz, Barsuk, Nable... |
3067 | leency | 4 | //home icon - rachel fu, GPL licence |
5 | |||
4085 | leency | 6 | #ifndef AUTOBUILD |
7 | #include "lang.h--" |
||
8 | #endif |
||
9 | |||
3107 | leency | 10 | //libraries |
3363 | leency | 11 | #define MEMSIZE 0x100000 |
3067 | leency | 12 | #include "..\lib\kolibri.h" |
13 | #include "..\lib\strings.h" |
||
14 | #include "..\lib\figures.h" |
||
15 | #include "..\lib\encoding.h" |
||
16 | #include "..\lib\file_system.h" |
||
17 | #include "..\lib\mem.h" |
||
18 | #include "..\lib\dll.h" |
||
3107 | leency | 19 | //*.obj libraries |
20 | #include "..\lib\lib.obj\box_lib.h" |
||
21 | #include "..\lib\lib.obj\libio_lib.h" |
||
22 | #include "..\lib\lib.obj\libimg_lib.h" |
||
4026 | leency | 23 | #include "..\lib\list_box.h" |
3107 | leency | 24 | //images |
3067 | leency | 25 | #include "img\toolbar_icons.c" |
26 | #include "img\URLgoto.txt"; |
||
27 | |||
4026 | leency | 28 | #ifdef LANG_RUS |
4411 | leency | 29 | char version[]=" ’ҐЄбв®ўл© Ўа 㧥а 0.99.11"; |
4026 | leency | 30 | ?define IMAGES_CACHE_CLEARED "Љни Є авЁ®Є ®зЁйҐ" |
31 | #else |
||
4411 | leency | 32 | char version[]=" Text-based Browser 0.99.11"; |
4026 | leency | 33 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
34 | #endif |
||
35 | |||
36 | |||
3067 | leency | 37 | #define URL param |
3449 | leency | 38 | char fontlol[64]; |
3067 | leency | 39 | |
40 | char editURL[sizeof(URL)], |
||
41 | page_links[12000], |
||
3464 | leency | 42 | header[2048]; |
3067 | leency | 43 | |
44 | struct lines{ |
||
45 | int visible, all, first, column_max; |
||
46 | }; |
||
47 | |||
48 | int mouse_dd; |
||
3466 | leency | 49 | edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(editURL),#editURL,#mouse_dd,2,19,19}; |
3464 | leency | 50 | 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}; |
3067 | leency | 51 | |
52 | |||
53 | proc_info Form; |
||
54 | #define WIN_W 640 |
||
55 | #define WIN_H 480 |
||
56 | |||
57 | |||
4074 | leency | 58 | char stak[4096]; |
3067 | leency | 59 | mouse m; |
60 | |||
4026 | leency | 61 | int action_buf; |
62 | |||
4411 | leency | 63 | #include "..\TWB\TWB.c" |
64 | #include "menu_rmb.h" |
||
3067 | leency | 65 | |
66 | |||
67 | void main() |
||
68 | { |
||
4081 | leency | 69 | int key, btn; |
3067 | leency | 70 | int half_scroll_size; |
4026 | leency | 71 | int scroll_used=0, show_menu; |
3067 | leency | 72 | |
73 | mem_Init(); |
||
3107 | leency | 74 | if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();} |
75 | if (load_dll2(libio, #libio_init,1)!=0) debug("Error: library doesn't exists - libio"w); |
||
76 | if (load_dll2(libimg, #libimg_init,1)!=0) debug("Error: library doesn't exists - libimg"w); |
||
3067 | leency | 77 | |
3987 | leency | 78 | if (!URL) strcpy(#URL, "/sys/index.htm"); |
3067 | leency | 79 | strcpy(#editURL, #URL); |
80 | |||
81 | Form.width=WIN_W; |
||
82 | Form.height=WIN_H; |
||
83 | SetElementSizes(); |
||
84 | WB1.OpenPage(); |
||
85 | |||
86 | SetEventMask(0x27); |
||
87 | loop() |
||
88 | { |
||
89 | WaitEventTimeout(2); |
||
90 | switch(EAX & 0xFF) |
||
91 | { |
||
92 | CASE evMouse: |
||
93 | /*scrollbar_v_mouse (#scroll1); //конченый скролл притормажимает, идём "своим путём" |
||
94 | if (lines.first <> scroll1.position) |
||
95 | { |
||
96 | lines.first = scroll1.position; |
||
97 | WB1.ParseHTML(buf, filesize); |
||
98 | //break; |
||
99 | };*/ |
||
100 | |||
4081 | leency | 101 | if (!CheckActiveProcess(Form.ID)) break; |
3067 | leency | 102 | |
3466 | leency | 103 | edit_box_mouse stdcall (#address_box); |
3067 | leency | 104 | |
105 | m.get(); |
||
106 | |||
4026 | leency | 107 | if (m.y>WB1.top) && (m.y |
3067 | leency | 108 | { |
4026 | leency | 109 | if (m.pkm) |
110 | { |
||
111 | show_menu = 1; |
||
112 | } |
||
113 | if (!m.pkm) && (show_menu) |
||
114 | { |
||
115 | show_menu = 0; |
||
116 | SwitchToAnotherThread(); |
||
4074 | leency | 117 | CreateThread(#menu_rmb,#stak+4092); |
4026 | leency | 118 | break; |
119 | } |
||
3067 | leency | 120 | } |
121 | |||
4026 | leency | 122 | if (m.vert==65535) |
3067 | leency | 123 | { |
3477 | leency | 124 | if (lines.first==0) break; |
125 | if (lines.first>3) lines.first-=2; ELSE lines.first=1; |
||
3067 | leency | 126 | WB1.Scan(ID1); |
127 | break; |
||
128 | } |
||
3477 | leency | 129 | if (m.vert==1) |
3067 | leency | 130 | { |
3477 | leency | 131 | if(lines.visible+lines.first+3>=lines.all) WB1.Scan(181); |
4026 | leency | 132 | else |
133 | { |
||
3067 | leency | 134 | lines.first+=2; |
135 | WB1.Scan(ID2); |
||
136 | } |
||
137 | break; |
||
138 | } |
||
139 | |||
140 | if (!m.lkm) scroll_used=0; |
||
3477 | leency | 141 | if (m.x>=scroll1.start_x) && (m.x<=scroll1.start_x+scroll1.size_x) |
4026 | leency | 142 | && (m.y>=scroll1.start_y+scroll1.btn_height) && (-scroll1.btn_height+scroll1.start_y+scroll1.size_y>m.y) |
143 | && (lines.all>lines.visible) && (m.lkm) |
||
144 | { |
||
145 | scroll_used=1; |
||
146 | } |
||
3067 | leency | 147 | |
148 | if (scroll_used) |
||
149 | { |
||
150 | half_scroll_size = WB1.height - 16 * lines.visible / lines.all - 3 /2; |
||
3477 | leency | 151 | if (half_scroll_size+WB1.top>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.top; //если курсор над окном |
3067 | leency | 152 | btn=lines.first; //сохраняем старое количество |
153 | lines.first = m.y -half_scroll_size -WB1.top * lines.all / WB1.height; |
||
154 | if (lines.visible+lines.first>lines.all) lines.first=lines.all-lines.visible; |
||
155 | if (btn<>lines.first) WB1.ParseHTML(buf); //чтоб лишний раз не перерисовывать |
||
156 | } |
||
157 | |||
158 | break; |
||
159 | case evButton: |
||
160 | btn=GetButtonID(); |
||
3464 | leency | 161 | if (btn==1) |
3067 | leency | 162 | { |
163 | KillProcess(downloader_id); |
||
164 | ExitProcess(); |
||
165 | } |
||
166 | ELSE |
||
167 | { |
||
168 | WB1.Scan(btn); |
||
169 | } |
||
170 | break; |
||
171 | case evKey: |
||
172 | key = GetKey(); |
||
173 | |||
3466 | leency | 174 | if (address_box.flags & 0b10) SWITCH(key) //если активна строка адреса игнорируем некоторые кнопки |
3067 | leency | 175 | { CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; } |
176 | |||
177 | WB1.Scan(key); |
||
178 | |||
179 | _EDIT_MARK: |
||
3990 | leency | 180 | if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);} //адресная строка |
3067 | leency | 181 | break; |
182 | case evReDraw: |
||
4026 | leency | 183 | if (action_buf) { WB1.Scan(action_buf); action_buf=0;} |
3067 | leency | 184 | Draw_Window(); |
185 | break; |
||
186 | default: |
||
187 | if (downloader_id<>0) |
||
188 | { |
||
189 | if (GetProcessSlot(downloader_id)<>0) break; |
||
190 | downloader_id=0; |
||
191 | lines.first = lines.all = 0; |
||
192 | WB1.ReadHtml(_WIN); |
||
193 | Draw_Window(); |
||
194 | } |
||
195 | } |
||
196 | } |
||
197 | } |
||
198 | |||
199 | void SetElementSizes() |
||
200 | { |
||
3466 | leency | 201 | address_box.width = Form.width-266; |
3464 | leency | 202 | WB1.top = 44; |
3466 | leency | 203 | WB1.width = Form.width - 10 - scroll1.size_x; |
204 | WB1.height = Form.height - WB1.top - GetSkinHeight() - 4; |
||
3464 | leency | 205 | WB1.line_h = 10; |
3067 | leency | 206 | lines.column_max = WB1.width - 30 / 6; |
3464 | leency | 207 | lines.visible = WB1.height - 3 / WB1.line_h - 2; |
3468 | leency | 208 | DrawBufInit(); |
3067 | leency | 209 | } |
210 | |||
211 | |||
212 | void Draw_Window() |
||
213 | { |
||
214 | int j; |
||
3466 | leency | 215 | DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,0xE4DFE1,0,0); |
3067 | leency | 216 | |
217 | GetProcessInfo(#Form, SelfInfo); |
||
3464 | leency | 218 | if (Form.status_window>2) |
3067 | leency | 219 | { |
220 | DrawTitle(#header); |
||
221 | return; |
||
222 | } |
||
223 | if (Form.height<120) MoveSize(OLD,OLD,OLD,120); |
||
224 | if (Form.width<280) MoveSize(OLD,OLD,280,OLD); |
||
225 | |||
226 | PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal); |
||
3363 | leency | 227 | if (GetProcessSlot(downloader_id)<>0) _PutImage(88,10, 24,24, #stop_btn); |
3067 | leency | 228 | |
3464 | leency | 229 | DrawBar(200,0,Form.cwidth-200,43,0xE4DFE1); |
230 | DrawBar(0,42,Form.cwidth,1,0xE2DBDC); |
||
231 | DrawBar(0,43,Form.cwidth,1,0xD2CED0); |
||
3067 | leency | 232 | for (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0xE4DFE1); |
3464 | leency | 233 | _PutImage(Form.cwidth-48,14, 40,19, #URLgoto); |
234 | DefineButton(Form.cwidth-28,15, 18, 16, GOTOURL+BT_HIDE, 0xE4DFE1); |
||
235 | DefineButton(Form.cwidth-47,15, 17, 16, SEARCHWEB+BT_HIDE, 0xE4DFE1); |
||
236 | DrawRectangle(205,14,Form.cwidth-205-49,18,0x94AECE); //around adress bar |
||
237 | DrawRectangle(206,15,Form.cwidth-205-50,16,0xE4ECF3); |
||
3067 | leency | 238 | |
239 | SetElementSizes(); |
||
240 | WB1.ShowPage(); |
||
3464 | leency | 241 | |
3067 | leency | 242 | DefineButton(scroll1.start_x+1, scroll1.start_y+1, 16, 16, ID1+BT_HIDE, 0xE4DFE1); |
243 | DefineButton(scroll1.start_x+1, scroll1.start_y+scroll1.size_y-18, 16, 16, ID2+BT_HIDE, 0xE4DFE1); |
||
244 | } |
||
245 | |||
246 | |||
247 | stop:5;>>280)>120)>>>8;><8;>>>>>0)>=scroll1.start_x+scroll1.size_x)>> |