Rev 5713 | Rev 5746 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5713 | Rev 5718 | ||
---|---|---|---|
Line 28... | Line 28... | ||
28 | #include "..\lib\patterns\libimg_load_skin.h" |
28 | #include "..\lib\patterns\libimg_load_skin.h" |
Line 29... | Line 29... | ||
29 | 29 | ||
Line 30... | Line 30... | ||
30 | char homepage[] = FROM "html\\homepage.htm"; |
30 | char homepage[] = FROM "html\\homepage.htm"; |
31 | 31 | ||
32 | #ifdef LANG_RUS |
32 | #ifdef LANG_RUS |
33 | char version[]=" ¥ªáâ®¢ë© ¡à 㧥à 1.2"; |
33 | char version[]=" ¥ªáâ®¢ë© ¡à 㧥à 1.21"; |
34 | ?define IMAGES_CACHE_CLEARED "íè ª à⨮ª ®ç¨é¥" |
34 | ?define IMAGES_CACHE_CLEARED "íè ª à⨮ª ®ç¨é¥" |
35 | ?define T_LAST_SLIDE "â® ¯®á«¥¤¨© á« ©¤" |
35 | ?define T_LAST_SLIDE "â® ¯®á«¥¤¨© á« ©¤" |
36 | char loading[] = " £à㧪 áâà ¨æë... |
36 | char loading[] = " £à㧪 áâà ¨æë... |
37 | char page_not_found[] = FROM "html\page_not_found_ru.htm"; |
37 | char page_not_found[] = FROM "html\page_not_found_ru.htm"; |
38 | char accept_language[]= "Accept-Language: ru\n"; |
38 | char accept_language[]= "Accept-Language: ru\n"; |
39 | #else |
39 | #else |
40 | char version[]=" Text-based Browser 1.2"; |
40 | char version[]=" Text-based Browser 1.21"; |
41 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
41 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
42 | ?define T_LAST_SLIDE "This slide is the last" |
42 | ?define T_LAST_SLIDE "This slide is the last" |
43 | char loading[] = "Loading... |
43 | char loading[] = "Loading... |
Line 68... | Line 68... | ||
68 | dword STATUSBAR_H = 15; |
68 | dword STATUSBAR_H = 15; |
69 | dword col_bg; |
69 | dword col_bg; |
70 | dword panel_color; |
70 | dword panel_color; |
71 | dword border_color; |
71 | dword border_color; |
Line 72... | Line 72... | ||
72 | 72 | ||
73 | progress_bar wv_progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F}; |
73 | progress_bar wv_progress_bar; |
Line -... | Line 74... | ||
- | 74 | byte souce_mode = false; |
|
- | 75 | ||
- | 76 | enum { |
|
- | 77 | BACK_BUTTON=1000, |
|
- | 78 | FORWARD_BUTTON, |
|
- | 79 | REFRESH_BUTTON, |
|
- | 80 | GOTOURL_BUTTON, |
|
- | 81 | SEARCHWEB_BUTTON, |
|
- | 82 | SANDWICH_BUTTON |
|
- | 83 | }; |
|
- | 84 | ||
- | 85 | enum { |
|
- | 86 | ZOOM2x=1100, |
|
- | 87 | VIEW_SOURCE, |
|
- | 88 | EDIT_SOURCE, |
|
- | 89 | VIEW_HISTORY, |
|
- | 90 | FREE_IMG_CACHE, |
|
- | 91 | DOWNLOAD_MANAGER |
|
74 | byte souce_mode = false; |
92 | }; |
75 | 93 | ||
76 | #include "..\TWB\TWB.c" |
94 | #include "..\TWB\TWB.c" |
77 | #include "menu_rmb.h" |
95 | #include "menu_rmb.h" |
78 | #include "history.h" |
96 | #include "history.h" |
Line 86... | Line 104... | ||
86 | 104 | ||
87 | #define URL_SERVICE_HISTORY "WebView://history" |
105 | #define URL_SERVICE_HISTORY "WebView://history" |
88 | #define URL_SERVICE_HOME "WebView://home" |
106 | #define URL_SERVICE_HOME "WebView://home" |
Line 89... | Line -... | ||
89 | #define URL_SERVICE_SOURCE "WebView://source:" |
- | |
Line 90... | Line 107... | ||
90 | 107 | #define URL_SERVICE_SOURCE "WebView://source:" |
|
Line 91... | Line 108... | ||
91 | enum { BUTTON_BACK=1000, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT }; |
108 | |
92 | 109 | ||
Line 107... | Line 124... | ||
107 | } |
124 | } |
Line 108... | Line 125... | ||
108 | 125 | ||
109 | void DrawProgress() |
126 | void DrawProgress() |
110 | { |
127 | { |
111 | unsigned long btn; |
- | |
112 | //progressbar_draw stdcall(#wv_progress_bar); |
- | |
113 | wv_progress_bar.width = wv_progress_bar.left = 0; |
128 | unsigned long btn; |
114 | if (http_transfer == 0) return; |
129 | if (http_transfer == 0) return; |
115 | if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30; |
130 | if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30; |
116 | DrawBar(address_box.left-1, address_box.top+14, btn, 2, wv_progress_bar.progress_color); |
131 | DrawBar(address_box.left-1, address_box.top+15, btn, 2, wv_progress_bar.progress_color); |
Line 117... | Line 132... | ||
117 | } |
132 | } |
118 | 133 | ||
Line 127... | Line 142... | ||
127 | load_dll(boxlib, #box_lib_init,0); |
142 | load_dll(boxlib, #box_lib_init,0); |
128 | load_dll(libio, #libio_init,1); |
143 | load_dll(libio, #libio_init,1); |
129 | load_dll(libimg, #libimg_init,1); |
144 | load_dll(libimg, #libimg_init,1); |
130 | load_dll(libHTTP, #http_lib_init,1); |
145 | load_dll(libHTTP, #http_lib_init,1); |
131 | load_dll(iconv_lib, #iconv_open,0); |
146 | load_dll(iconv_lib, #iconv_open,0); |
- | 147 | //load_dll(kmenu, #akmenu_init,0); |
|
132 | Libimg_LoadImage(#skin, abspath("wv_skin.png")); |
148 | Libimg_LoadImage(#skin, abspath("wv_skin.png")); |
133 | SetSkinColors(); |
149 | SetSkinColors(); |
Line 134... | Line 150... | ||
134 | 150 | ||
135 | WB1.DrawBuf.zoom = 1; |
151 | WB1.DrawBuf.zoom = 1; |
Line 157... | Line 173... | ||
157 | //Menu |
173 | //Menu |
158 | if (mouse.y>WB1.list.y) && (mouse.y |
174 | if (mouse.y>WB1.list.y) && (mouse.y |
159 | { |
175 | { |
160 | if (mouse.pkm) && (mouse.up) |
176 | if (mouse.pkm) && (mouse.up) |
161 | { |
177 | { |
162 | SwitchToAnotherThread(); |
- | |
163 | CreateThread(#menu_rmb,#stak+4092); |
178 | CreateThread(#menu_rmb,#stak+4092); |
164 | break; |
179 | break; |
165 | } |
180 | } |
166 | } |
181 | } |
167 | //Mouse scroll |
182 | //Mouse scroll |
Line 265... | Line 280... | ||
265 | http_free stdcall (http_transfer); |
280 | http_free stdcall (http_transfer); |
266 | http_transfer=0; |
281 | http_transfer=0; |
267 | PageLinks.GetAbsoluteURL(#URL); |
282 | PageLinks.GetAbsoluteURL(#URL); |
268 | BrowserHistory.current--; |
283 | BrowserHistory.current--; |
269 | strcpy(#editURL, #URL); |
284 | strcpy(#editURL, #URL); |
- | 285 | DrawEditBox(); |
|
270 | OpenPage(); |
286 | OpenPage(); |
271 | } |
287 | } |
272 | else |
288 | else |
273 | { |
289 | { |
274 | BrowserHistory.AddUrl(); |
290 | BrowserHistory.AddUrl(); |
Line 311... | Line 327... | ||
311 | img_draw stdcall(skin.image, TAB_W-13, 0, 30, skin.h, 101, 0); |
327 | img_draw stdcall(skin.image, TAB_W-13, 0, 30, skin.h, 101, 0); |
312 | } |
328 | } |
313 | else DrawBar(0,0, Form.cwidth,1, col_bg); |
329 | else DrawBar(0,0, Form.cwidth,1, col_bg); |
314 | // } |
330 | // } |
315 | DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-3, panel_color); |
331 | DrawBar(0,TAB_H+1, Form.cwidth,TOOLBAR_H-TAB_H-3, panel_color); |
316 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xe9e9e9); |
332 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
317 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
333 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
318 | SetElementSizes(); |
334 | SetElementSizes(); |
- | 335 | DrawRectangle(address_box.left-2, address_box.top-3, address_box.width+4, 20,border_color); |
|
- | 336 | DrawRectangle(address_box.left-1, address_box.top-2, address_box.width+2, 18,address_box.color); |
|
319 | DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color); |
337 | DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color); |
320 | DrawRectangle(address_box.left-2, address_box.top-2, address_box.width+4, 18,border_color); |
- | |
321 | // < / > |
338 | // < / > |
322 | DefineButton(address_box.left-49, address_box.top-1, 23, skin.h-2, BUTTON_BACK+BT_HIDE, 0); |
339 | DefineButton(address_box.left-49, address_box.top-2, 23, skin.h-2, BACK_BUTTON+BT_HIDE, 0); |
323 | DefineButton(address_box.left-25, address_box.top-1, 23, skin.h-2, FORWARD+BT_HIDE, 0); |
340 | DefineButton(address_box.left-25, address_box.top-2, 23, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0); |
324 | img_draw stdcall(skin.image, address_box.left-50, address_box.top-2, 48, skin.h, 3, 0); |
341 | img_draw stdcall(skin.image, address_box.left-50, address_box.top-3, 48, skin.h, 3, 0); |
325 | // refrash |
342 | // refresh_BUTTON |
326 | DefineButton(address_box.left+address_box.width+1, address_box.top-2, 16, skin.h-1, REFRESH+BT_HIDE+BT_NOFRAME, 0); |
343 | DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0); |
327 | if (http_transfer > 0) img_off = 131; else img_off = 52; |
344 | if (http_transfer > 0) img_off = 131; else img_off = 52; |
328 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, img_off, 0); |
345 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, img_off, 0); |
329 | // config |
346 | // config |
330 | DefineButton(Form.cwidth-23, address_box.top-2, 17, skin.h-1, 312+BT_HIDE, 0); |
347 | DefineButton(Form.cwidth-24, address_box.top-3, 19, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0); |
331 | img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-2, 16, skin.h, 85, 0); |
348 | img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-3, 16, skin.h, 85, 0); |
332 | //status bar |
349 | //status bar |
333 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
350 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
334 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
351 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
335 | wv_progress_bar.top = Form.cheight - STATUSBAR_H + 4; |
- | |
336 | ShowPage(); |
352 | ShowPage(); |
337 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
353 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
338 | DrawProgress(); |
354 | DrawProgress(); |
339 | } |
355 | } |
Line 340... | Line 356... | ||
340 | 356 | ||
341 | 357 | ||
342 | void Scan(dword id__) |
358 | void Scan(dword id__) |
343 | { |
359 | { |
344 | action_buf=0; |
360 | action_buf=0; |
345 | if (id__ >= 400) |
361 | if (id__ >= 400) && (id__ < 1000) |
346 | { |
362 | { |
347 | ProcessLinks(id__); |
363 | ProcessLinks(id__); |
348 | return; |
364 | return; |
349 | } |
365 | } |
350 | switch (id__) |
366 | switch (id__) |
351 | { |
367 | { |
352 | case SCAN_CODE_BS: |
368 | case SCAN_CODE_BS: |
353 | case BUTTON_BACK: |
369 | case BACK_BUTTON: |
354 | if (!BrowserHistory.GoBack()) return; |
370 | if (!BrowserHistory.GoBack()) return; |
Line 355... | Line 371... | ||
355 | OpenPage(); |
371 | OpenPage(); |
356 | return; |
372 | return; |
357 | 373 | ||
358 | case FORWARD: |
374 | case FORWARD_BUTTON: |
Line 359... | Line 375... | ||
359 | if (!BrowserHistory.GoForward()) return; |
375 | if (!BrowserHistory.GoForward()) return; |
Line 377... | Line 393... | ||
377 | if (WB1.list.visible + WB1.list.first >= WB1.list.count) return; |
393 | if (WB1.list.visible + WB1.list.first >= WB1.list.count) return; |
378 | WB1.list.first++; |
394 | WB1.list.first++; |
379 | WB1.Parse(); |
395 | WB1.Parse(); |
380 | return; |
396 | return; |
Line 381... | Line -... | ||
381 | - | ||
382 | case 44: //Z-key down |
- | |
383 | if (WB1.DrawBuf.zoom==2) |
- | |
384 | { |
- | |
385 | WB1.DrawBuf.zoom=1; |
- | |
386 | WB1.list.SetFont(8, 14, 10111000b); |
- | |
387 | } |
- | |
388 | else |
- | |
389 | { |
- | |
390 | WB1.DrawBuf.zoom=2; |
- | |
391 | WB1.list.SetFont(8, 14, 10111001b); |
- | |
392 | } |
- | |
393 | Draw_Window(); |
- | |
394 | return; |
- | |
395 | 397 | ||
396 | case GOTOURL: |
398 | case GOTOURL_BUTTON: |
397 | case SCAN_CODE_ENTER: //enter |
399 | case SCAN_CODE_ENTER: //enter |
398 | if (!editURL[0]) return; |
400 | if (!editURL[0]) return; |
399 | if (strncmp(#editURL,"http:",5)) && (editURL[0]!='/') && (strncmp(#editURL,"WebView:",9)) strncpy(#URL,"http://",7); |
401 | if (strncmp(#editURL,"http:",5)) && (editURL[0]!='/') && (strncmp(#editURL,"WebView:",9)) strncpy(#URL,"http://",7); |
400 | else |
402 | else |
401 | URL[0] = 0; |
403 | URL[0] = 0; |
402 | strcat(#URL, #editURL); |
404 | strcat(#URL, #editURL); |
403 | OpenPage(); |
405 | OpenPage(); |
Line -... | Line 406... | ||
- | 406 | return; |
|
- | 407 | ||
404 | return; |
408 | case 063: //F5 |
405 | 409 | IF(address_box.flags & 0b10) return; |
|
406 | case REFRESH: |
410 | case REFRESH_BUTTON: |
407 | if (http_transfer > 0) |
411 | if (http_transfer > 0) |
408 | { |
412 | { |
409 | StopLoading(); |
413 | StopLoading(); |
410 | Draw_Window(); |
414 | Draw_Window(); |
411 | } |
415 | } |
Line 412... | Line -... | ||
412 | else OpenPage(); |
- | |
413 | return; |
- | |
414 | - | ||
415 | /* |
- | |
416 | case 011: //Ctrk+K |
- | |
417 | BufEncode(CH_KOI8); |
- | |
418 | WB1.Parse(); |
416 | else OpenPage(); |
419 | return; |
- | |
420 | case 021: //Ctrl+U |
- | |
421 | BufEncode(CH_UTF8); |
- | |
422 | WB1.Parse(); |
- | |
423 | return; |
- | |
424 | case 004: //Ctrl+D |
- | |
425 | BufEncode(CH_CP866); |
- | |
426 | WB1.Parse(); |
417 | return; |
427 | return; |
- | |
428 | case 005: //Win encoding |
- | |
429 | BufEncode(CH_CP1251); |
418 | |
430 | WB1.Parse(); |
- | |
431 | return; |
- | |
432 | case 009: //free img cache |
- | |
433 | ImgCache.Free(); |
- | |
434 | notify(IMAGES_CACHE_CLEARED); |
- | |
435 | WB1.Parse(); |
419 | case SANDWICH_BUTTON: |
436 | return; |
- | |
437 | case 003: //history |
420 | mouse.y = TOOLBAR_H-6; |
- | 421 | mouse.x = Form.cwidth - 167; |
|
438 | strcpy(#URL, URL_SERVICE_HISTORY); |
422 | CreateThread(#menu_rmb,#stak+4092); |
439 | OpenPage(); |
423 | return; |
- | 424 | ||
440 | return; |
425 | case ZOOM2x: |
441 | case 006: //download manager |
426 | if (WB1.DrawBuf.zoom==2) |
442 | if (!downloader_opened) { |
427 | { |
- | 428 | WB1.DrawBuf.zoom=1; |
|
- | 429 | WB1.list.SetFont(8, 14, 10111000b); |
|
- | 430 | } |
|
- | 431 | else |
|
- | 432 | { |
|
- | 433 | WB1.DrawBuf.zoom=2; |
|
443 | strncpy(#DL_URL, "http://",7); |
434 | WB1.list.SetFont(8, 14, 10111001b); |
Line 444... | Line 435... | ||
444 | CreateThread(#Downloader,#downloader_stak+4092); |
435 | } |
445 | } |
436 | Draw_Window(); |
446 | return; |
437 | return; |
447 | 438 | ||
448 | case 052: //F3 |
439 | case VIEW_SOURCE: |
- | 440 | WB1.list.first = 0; |
|
449 | WB1.list.first = 0; |
441 | ShowSource(); |
450 | ShowSource(); |
442 | WB1.Parse(); |
451 | WB1.Parse(); |
443 | break; |
452 | break; |
444 | |
453 | case 053: //F4 |
445 | case EDIT_SOURCE: |
454 | if (!strncmp(#URL,"http:",5)) |
446 | if (!strncmp(#URL,"http:",5)) |
455 | { |
447 | { |
456 | WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
448 | WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
457 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
- | |
458 | } |
- | |
Line -... | Line 449... | ||
- | 449 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
|
- | 450 | } |
|
- | 451 | else RunProgram("/rd/1/tinypad", #URL); |
|
- | 452 | return; |
|
- | 453 | ||
- | 454 | case FREE_IMG_CACHE: |
|
- | 455 | ImgCache.Free(); |
|
- | 456 | notify(IMAGES_CACHE_CLEARED); |
|
- | 457 | WB1.Parse(); |
|
- | 458 | return; |
|
- | 459 | ||
- | 460 | case VIEW_HISTORY: |
|
- | 461 | strcpy(#URL, URL_SERVICE_HISTORY); |
|
- | 462 | OpenPage(); |
|
- | 463 | return; |
|
- | 464 | ||
- | 465 | case DOWNLOAD_MANAGER: |
|
- | 466 | if (!downloader_opened) { |
|
459 | else RunProgram("/rd/1/tinypad", #URL); |
467 | strncpy(#DL_URL, "http://",7); |
460 | return; |
468 | CreateThread(#Downloader,#downloader_stak+4092); |
461 | case 054: //F5 |
469 | } |
462 | IF(address_box.flags & 0b10) return; |
470 | return; |
463 | 471 | /* |
|
Line 464... | Line 472... | ||
464 | case 020: |
472 | case 020: |
465 | case NEWTAB: |
473 | case NEWTAB: |
466 | MoveSize(190,80,OLD,OLD); |
474 | MoveSize(190,80,OLD,OLD); |
467 | RunProgram(#program_path, #URL); |
475 | RunProgram(#program_path, #URL); |
468 | return; |
- | |
469 | - | ||
470 | case SEARCHWEB: |
- | |
471 | sprintf(#URL,"%s%s",#search_path,#editURL); |
- | |
472 | OpenPage(); |
- | |
473 | return; |
- | |
474 | - | ||
475 | case 312: |
476 | return; |
476 | SwitchToAnotherThread(); |
477 | |
477 | mouse.y = TOOLBAR_H-6; |
478 | case SEARCHWEB_BUTTON: |
Line 562... | Line 563... | ||
562 | http_transfer=0; |
563 | http_transfer=0; |
563 | bufsize = 0; |
564 | bufsize = 0; |
564 | bufpointer = free(bufpointer); |
565 | bufpointer = free(bufpointer); |
565 | } |
566 | } |
566 | wv_progress_bar.value = 0; |
567 | wv_progress_bar.value = 0; |
567 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 52, 0); |
568 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 52, 0); |
568 | } |
569 | } |
Line 569... | Line 570... | ||
569 | 570 | ||
570 | void SetPageDefaults() |
571 | void SetPageDefaults() |
571 | { |
572 | { |
Line 592... | Line 593... | ||
592 | else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory(); |
593 | else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory(); |
593 | return; |
594 | return; |
594 | } |
595 | } |
595 | if (!strncmp(#URL,"http:",5)) |
596 | if (!strncmp(#URL,"http:",5)) |
596 | { |
597 | { |
597 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 131, 0); |
598 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0); |
598 | http_get stdcall (#URL, 0, 0, #accept_language); |
599 | http_get stdcall (#URL, 0, 0, #accept_language); |
599 | http_transfer = EAX; |
600 | http_transfer = EAX; |
600 | if (!http_transfer) |
601 | if (!http_transfer) |
601 | { |
602 | { |
602 | StopLoading(); |
603 | StopLoading(); |