Rev 5509 | Rev 5530 | 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" |
||
5499 | leency | 14 | #include "..\lib\gui.h" |
3067 | leency | 15 | #include "..\lib\encoding.h" |
16 | #include "..\lib\file_system.h" |
||
17 | #include "..\lib\mem.h" |
||
18 | #include "..\lib\dll.h" |
||
4508 | leency | 19 | #include "..\lib\draw_buf.h" |
20 | #include "..\lib\list_box.h" |
||
21 | #include "..\lib\cursor.h" |
||
22 | |||
3107 | leency | 23 | //*.obj libraries |
5499 | leency | 24 | #include "..\lib\obj\box_lib.h" |
25 | #include "..\lib\obj\libio_lib.h" |
||
26 | #include "..\lib\obj\libimg_lib.h" |
||
27 | #include "..\lib\obj\http.h" |
||
3067 | leency | 28 | |
5408 | leency | 29 | //useful patterns |
30 | #include "..\lib\patterns\libimg_load_skin.h" |
||
31 | |||
5493 | leency | 32 | char homepage[] = FROM "html\\homepage.htm"; |
4677 | leency | 33 | |
4026 | leency | 34 | #ifdef LANG_RUS |
5519 | leency | 35 | char version[]=" Текстовый браузер 1.1"; |
4416 | leency | 36 | ?define IMAGES_CACHE_CLEARED "Кэш картинок очищен" |
4417 | leency | 37 | ?define T_LAST_SLIDE "Это последний слайд" |
4550 | leency | 38 | char loading[] = "Загрузка страницы... |
4677 | leency | 39 | char page_not_found[] = FROM "html\page_not_found_ru.htm"; |
4649 | leency | 40 | char accept_language[]= "Accept-Language: ru\n"; |
4026 | leency | 41 | #else |
5519 | leency | 42 | char version[]=" Text-based Browser 1.1"; |
4026 | leency | 43 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
4417 | leency | 44 | ?define T_LAST_SLIDE "This slide is the last" |
4550 | leency | 45 | char loading[] = "Loading... |
4677 | leency | 46 | char page_not_found[] = FROM "html\page_not_found_en.htm"; |
4649 | leency | 47 | char accept_language[]= "Accept-Language: en\n"; |
4026 | leency | 48 | #endif |
49 | |||
3067 | leency | 50 | proc_info Form; |
5519 | leency | 51 | #define WIN_W 799 |
52 | #define WIN_H 559 |
||
3067 | leency | 53 | |
4416 | leency | 54 | char search_path[]="http://nigma.ru/index.php?s="; |
4558 | hidnplayr | 55 | char str_location[]="location\0"; |
56 | int redirected = 0; |
||
3067 | leency | 57 | |
4074 | leency | 58 | char stak[4096]; |
3067 | leency | 59 | mouse m; |
4026 | leency | 60 | int action_buf; |
61 | |||
4565 | leency | 62 | dword http_transfer = 0; |
4537 | leency | 63 | dword http_buffer; |
4534 | leency | 64 | |
4692 | leency | 65 | dword TAB_H = false; //19; |
4677 | leency | 66 | dword TAB_W = 150; |
4692 | leency | 67 | dword TOOLBAR_H = 31; //50; |
5519 | leency | 68 | dword STATUSBAR_H = 15; |
4718 | leency | 69 | dword col_bg; |
70 | dword panel_color; |
||
71 | dword border_color; |
||
4677 | leency | 72 | |
5519 | leency | 73 | progress_bar wv_progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F}; |
4718 | leency | 74 | byte souce_mode = false; |
4677 | leency | 75 | |
4411 | leency | 76 | #include "..\TWB\TWB.c" |
77 | #include "menu_rmb.h" |
||
4636 | leency | 78 | #include "history.h" |
4718 | leency | 79 | #include "show_src.h" |
5493 | leency | 80 | #include "downloader.h" |
3067 | leency | 81 | |
4534 | leency | 82 | char editURL[sizeof(URL)]; |
83 | int mouse_twb; |
||
4677 | leency | 84 | edit_box address_box = {250,55,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; |
4534 | leency | 85 | |
4677 | leency | 86 | #define URL_SERVICE_HISTORY "WebView://history" |
87 | #define URL_SERVICE_HOME "WebView://home" |
||
4718 | leency | 88 | #define URL_SERVICE_SOURCE "WebView://source:" |
4534 | leency | 89 | |
4488 | leency | 90 | enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN }; |
3067 | leency | 91 | |
5408 | leency | 92 | libimg_image skin; |
4488 | leency | 93 | |
5408 | leency | 94 | int SetSkinColors() |
4677 | leency | 95 | { |
4718 | leency | 96 | dword image_data; |
97 | image_data = DSDWORD[skin.image+24]; |
||
4846 | leency | 98 | col_bg = DSDWORD[image_data]; |
4718 | leency | 99 | panel_color = DSDWORD[skin.w*4*4 + image_data]; |
100 | border_color = DSDWORD[skin.w*4*7 + image_data]; |
||
5519 | leency | 101 | wv_progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data]; |
4718 | leency | 102 | $and col_bg, 0x00ffffff |
103 | $and panel_color, 0x00ffffff |
||
104 | $and border_color, 0x00ffffff |
||
5519 | leency | 105 | $and wv_progress_bar.progress_color, 0x00ffffff |
4677 | leency | 106 | } |
107 | |||
4686 | leency | 108 | void DrawProgress() |
109 | { |
||
110 | unsigned long btn; |
||
5519 | leency | 111 | //progressbar_draw stdcall(#wv_progress_bar); |
112 | wv_progress_bar.width = wv_progress_bar.left = 0; |
||
4686 | leency | 113 | if (http_transfer == 0) return; |
5519 | leency | 114 | if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30; |
115 | DrawBar(address_box.left-1, address_box.top+14, btn, 2, wv_progress_bar.progress_color); |
||
4686 | leency | 116 | } |
117 | |||
4718 | leency | 118 | |
3067 | leency | 119 | void main() |
120 | { |
||
4686 | leency | 121 | unsigned long key, btn; |
3067 | leency | 122 | int half_scroll_size; |
4026 | leency | 123 | int scroll_used=0, show_menu; |
3067 | leency | 124 | |
125 | mem_Init(); |
||
4536 | leency | 126 | CursorPointer.Load(#CursorFile); |
5403 | leency | 127 | if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("Error: library doesn't exists - box_lib"); |
4536 | leency | 128 | if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio"); |
129 | if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg"); |
||
4540 | leency | 130 | if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http"); |
5408 | leency | 131 | Libimg_LoadImage(#skin, abspath("wv_skin.png")); |
132 | SetSkinColors(); |
||
3067 | leency | 133 | |
5519 | leency | 134 | WB1.DrawBuf.zoomf = 1; |
3067 | leency | 135 | Form.width=WIN_W; |
136 | Form.height=WIN_H; |
||
137 | SetElementSizes(); |
||
5493 | leency | 138 | if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME); |
4416 | leency | 139 | OpenPage(); |
3067 | leency | 140 | |
5493 | leency | 141 | CreateDir("/tmp0/1/downloads"); |
142 | |||
4536 | leency | 143 | SetEventMask(0xa7); |
3067 | leency | 144 | loop() |
145 | { |
||
146 | WaitEventTimeout(2); |
||
147 | switch(EAX & 0xFF) |
||
148 | { |
||
149 | CASE evMouse: |
||
4081 | leency | 150 | if (!CheckActiveProcess(Form.ID)) break; |
4636 | leency | 151 | //Edit URL |
3466 | leency | 152 | edit_box_mouse stdcall (#address_box); |
3067 | leency | 153 | m.get(); |
4636 | leency | 154 | //Links hover |
4550 | leency | 155 | if (m.y>WB1.list.y) PageLinks.Hover(m.x, m.y, link_color_inactive, link_color_active, bg_color); |
4636 | leency | 156 | //Menu |
4540 | leency | 157 | if (m.y>WB1.list.y) && (m.y |
3067 | leency | 158 | { |
4026 | leency | 159 | if (m.pkm) |
160 | { |
||
161 | show_menu = 1; |
||
162 | } |
||
163 | if (!m.pkm) && (show_menu) |
||
164 | { |
||
165 | show_menu = 0; |
||
166 | SwitchToAnotherThread(); |
||
4074 | leency | 167 | CreateThread(#menu_rmb,#stak+4092); |
4026 | leency | 168 | break; |
169 | } |
||
3067 | leency | 170 | } |
4636 | leency | 171 | //Mouse scroll |
4415 | leency | 172 | if (m.vert) |
3067 | leency | 173 | { |
4636 | leency | 174 | if (WB1.list.MouseScroll(m.vert)) WB1.Parse(); |