Rev 6641 | Rev 6686 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6641 | Rev 6678 | ||
---|---|---|---|
1 | //HTML Viewer in C-- |
1 | //HTML Viewer in C-- |
2 | //Copyright 2007-2013 by Veliant & Leency |
2 | //Copyright 2007-2013 by Veliant & Leency |
3 | //Asper, lev, Lrz, Barsuk, Nable... |
3 | //Asper, lev, Lrz, Barsuk, Nable... |
4 | //home icon - rachel fu, GPL licence |
4 | //home icon - rachel fu, GPL licence |
5 | 5 | ||
6 | #ifndef AUTOBUILD |
6 | #ifndef AUTOBUILD |
7 | #include "lang.h--" |
7 | #include "lang.h--" |
8 | #endif |
8 | #endif |
9 | 9 | ||
10 | //libraries |
10 | //libraries |
11 | #define MEMSIZE 1060000 |
11 | #define MEMSIZE 1060000 |
12 | #include "..\lib\gui.h" |
12 | #include "..\lib\gui.h" |
13 | #include "..\lib\draw_buf.h" |
13 | #include "..\lib\draw_buf.h" |
14 | #include "..\lib\list_box.h" |
14 | #include "..\lib\list_box.h" |
15 | #include "..\lib\cursor.h" |
15 | #include "..\lib\cursor.h" |
16 | #include "..\lib\collection.h" |
16 | #include "..\lib\collection.h" |
17 | #include "..\lib\font.h" |
17 | #include "..\lib\font.h" |
18 | #include "..\lib\menu.h" |
18 | #include "..\lib\menu.h" |
19 | 19 | ||
20 | //*.obj libraries |
20 | //*.obj libraries |
21 | #include "..\lib\obj\box_lib.h" |
21 | #include "..\lib\obj\box_lib.h" |
22 | #include "..\lib\obj\libio_lib.h" |
22 | #include "..\lib\obj\libio_lib.h" |
23 | #include "..\lib\obj\libimg_lib.h" |
23 | #include "..\lib\obj\libimg_lib.h" |
24 | #include "..\lib\obj\http.h" |
24 | #include "..\lib\obj\http.h" |
25 | #include "..\lib\obj\iconv.h" |
25 | #include "..\lib\obj\iconv.h" |
26 | //useful patterns |
26 | //useful patterns |
27 | #include "..\lib\patterns\libimg_load_skin.h" |
27 | #include "..\lib\patterns\libimg_load_skin.h" |
28 | #include "..\lib\patterns\history.h" |
28 | #include "..\lib\patterns\history.h" |
29 | #include "..\lib\patterns\http_downloader.h" |
29 | #include "..\lib\patterns\http_downloader.h" |
30 | 30 | ||
31 | char homepage[] = FROM "html\\homepage.htm"; |
31 | char homepage[] = FROM "html\\homepage.htm"; |
32 | 32 | ||
33 | #ifdef LANG_RUS |
33 | #ifdef LANG_RUS |
34 | char version[]=" ¥ªáâ®¢ë© ¡à 㧥à 1.48"; |
34 | char version[]=" ¥ªáâ®¢ë© ¡à 㧥à 1.48"; |
35 | ?define IMAGES_CACHE_CLEARED "íè ª à⨮ª ®ç¨é¥" |
35 | ?define IMAGES_CACHE_CLEARED "íè ª à⨮ª ®ç¨é¥" |
36 | ?define T_LAST_SLIDE "â® ¯®á«¥¤¨© á« ©¤" |
36 | ?define T_LAST_SLIDE "â® ¯®á«¥¤¨© á« ©¤" |
37 | char loading[] = " £à㧪 áâà ¨æë... |
37 | char loading[] = " £à㧪 áâà ¨æë... |
38 | char page_not_found[] = FROM "html\page_not_found_ru.htm"; |
38 | char page_not_found[] = FROM "html\page_not_found_ru.htm"; |
39 | char accept_language[]= "Accept-Language: ru\n"; |
39 | char accept_language[]= "Accept-Language: ru\n"; |
40 | char rmb_menu[] = |
40 | char rmb_menu[] = |
41 | "®á¬®âà¥âì ¨á室¨ª |
41 | "®á¬®âà¥âì ¨á室¨ª |
42 | ¥¤ ªâ¨à®¢ âì ¨á室¨ª |
42 | ¥¤ ªâ¨à®¢ âì ¨á室¨ª |
43 | áâ®à¨ï |
43 | áâ®à¨ï |
44 | ç¨áâ¨âì ªíè ª à⨮ª |
44 | ç¨áâ¨âì ªíè ª à⨮ª |
45 | ¥¥¤¦¥à § £à㧮ª"; |
45 | ¥¥¤¦¥à § £à㧮ª"; |
46 | #else |
46 | #else |
47 | char version[]=" Text-based Browser 1.48"; |
47 | char version[]=" Text-based Browser 1.49"; |
48 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
48 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
49 | ?define T_LAST_SLIDE "This slide is the last" |
49 | ?define T_LAST_SLIDE "This slide is the last" |
50 | char loading[] = "Loading... |
50 | char loading[] = "Loading... |
51 | char page_not_found[] = FROM "html\page_not_found_en.htm"; |
51 | char page_not_found[] = FROM "html\page_not_found_en.htm"; |
52 | char accept_language[]= "Accept-Language: en\n"; |
52 | char accept_language[]= "Accept-Language: en\n"; |
53 | char rmb_menu[] = |
53 | char rmb_menu[] = |
54 | "View source |
54 | "View source |
55 | Edit source |
55 | Edit source |
56 | History |
56 | History |
57 | Free image cache |
57 | Free image cache |
58 | Download Manager"; |
58 | Download Manager"; |
59 | #endif |
59 | #endif |
60 | 60 | ||
61 | #define URL_SERVICE_HISTORY "WebView://history" |
61 | #define URL_SERVICE_HISTORY "WebView://history" |
62 | #define URL_SERVICE_HOME "WebView://home" |
62 | #define URL_SERVICE_HOME "WebView://home" |
63 | #define URL_SERVICE_SOURCE "WebView://source:" |
63 | #define URL_SERVICE_SOURCE "WebView://source:" |
64 | 64 | ||
65 | proc_info Form; |
65 | proc_info Form; |
66 | 66 | ||
67 | //char search_path[]="http://nigma.ru/index.php?s="; |
67 | //char search_path[]="http://nigma.ru/index.php?s="; |
68 | int redirected = 0; |
68 | int redirected = 0; |
69 | 69 | ||
70 | char stak[4096]; |
70 | char stak[4096]; |
71 | 71 | ||
72 | int action_buf; |
72 | int action_buf; |
73 | 73 | ||
74 | dword http_transfer = 0; |
74 | dword http_transfer = 0; |
75 | dword http_buffer; |
75 | dword http_buffer; |
76 | 76 | ||
77 | dword TOOLBAR_H = 33; |
77 | dword TOOLBAR_H = 33; |
78 | dword STATUSBAR_H = 15; |
78 | dword STATUSBAR_H = 15; |
79 | dword col_bg; |
79 | dword col_bg; |
80 | dword panel_color; |
80 | dword panel_color; |
81 | dword border_color; |
81 | dword border_color; |
82 | 82 | ||
83 | progress_bar wv_progress_bar; |
83 | progress_bar wv_progress_bar; |
84 | byte souce_mode = false; |
84 | byte souce_mode = false; |
85 | 85 | ||
86 | enum { |
86 | enum { |
87 | BACK_BUTTON=1000, |
87 | BACK_BUTTON=1000, |
88 | FORWARD_BUTTON, |
88 | FORWARD_BUTTON, |
89 | REFRESH_BUTTON, |
89 | REFRESH_BUTTON, |
90 | GOTOURL_BUTTON, |
90 | GOTOURL_BUTTON, |
91 | SANDWICH_BUTTON |
91 | SANDWICH_BUTTON |
92 | }; |
92 | }; |
93 | 93 | ||
94 | enum { |
94 | enum { |
95 | VIEW_SOURCE=1100, |
95 | VIEW_SOURCE=1100, |
96 | EDIT_SOURCE, |
96 | EDIT_SOURCE, |
97 | VIEW_HISTORY, |
97 | VIEW_HISTORY, |
98 | FREE_IMG_CACHE, |
98 | FREE_IMG_CACHE, |
99 | DOWNLOAD_MANAGER |
99 | DOWNLOAD_MANAGER |
100 | }; |
100 | }; |
101 | 101 | ||
102 | #include "..\TWB\TWB.c" |
102 | #include "..\TWB\TWB.c" |
103 | #include "history.h" |
103 | #include "history.h" |
104 | #include "show_src.h" |
104 | #include "show_src.h" |
105 | #include "download_manager.h" |
105 | #include "download_manager.h" |
106 | 106 | ||
107 | char editURL[sizeof(URL)]; |
107 | char editURL[sizeof(URL)]; |
108 | int mouse_twb; |
108 | int mouse_twb; |
109 | edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; |
109 | edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; |
110 | 110 | ||
111 | 111 | ||
112 | void main() |
112 | void main() |
113 | { |
113 | { |
114 | dword btn; |
114 | dword btn; |
115 | int half_scroll_size; |
115 | int half_scroll_size; |
116 | int scroll_used=0, show_menu; |
116 | int scroll_used=0, show_menu; |
117 | CursorPointer.Load(#CursorFile); |
117 | CursorPointer.Load(#CursorFile); |
118 | load_dll(boxlib, #box_lib_init,0); |
118 | load_dll(boxlib, #box_lib_init,0); |
119 | load_dll(libio, #libio_init,1); |
119 | load_dll(libio, #libio_init,1); |
120 | load_dll(libimg, #libimg_init,1); |
120 | load_dll(libimg, #libimg_init,1); |
121 | load_dll(libHTTP, #http_lib_init,1); |
121 | load_dll(libHTTP, #http_lib_init,1); |
122 | load_dll(iconv_lib, #iconv_open,0); |
122 | load_dll(iconv_lib, #iconv_open,0); |
123 | Libimg_LoadImage(#skin, abspath("wv_skin.png")); |
123 | Libimg_LoadImage(#skin, abspath("wv_skin.png")); |
124 | SetSkinColors(); |
124 | SetSkinColors(); |
125 | CreateDir("/tmp0/1/downloads"); |
125 | CreateDir("/tmp0/1/downloads"); |
126 | if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME); |
126 | if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME); |
127 | WB1.DrawBuf.zoom = 1; |
127 | WB1.DrawBuf.zoom = 1; |
128 | WB1.list.SetFont(8, 14, 10011000b); |
128 | WB1.list.SetFont(8, 14, 10011000b); |
129 | WB1.list.no_selection = true; |
129 | WB1.list.no_selection = true; |
130 | label.init(DEFAULT_FONT); |
130 | label.init(DEFAULT_FONT); |
131 | SetEventMask(0xa7); |
131 | SetEventMask(0xa7); |
132 | BEGIN_LOOP_APPLICATION: |
132 | BEGIN_LOOP_APPLICATION: |
133 | WaitEventTimeout(2); |
133 | WaitEventTimeout(2); |
134 | switch(EAX & 0xFF) |
134 | switch(EAX & 0xFF) |
135 | { |
135 | { |
136 | CASE evMouse: |
136 | CASE evMouse: |
137 | if (!CheckActiveProcess(Form.ID)) break; |
137 | if (!CheckActiveProcess(Form.ID)) break; |
138 | edit_box_mouse stdcall (#address_box); |
138 | edit_box_mouse stdcall (#address_box); |
139 | mouse.get(); |
139 | mouse.get(); |
140 | if (WB1.list.MouseOver(mouse.x, mouse.y)) |
140 | if (WB1.list.MouseOver(mouse.x, mouse.y)) |
141 | { |
141 | { |
142 | PageLinks.Hover(mouse.x, WB1.list.first*WB1.list.item_h + mouse.y, link_color_inactive, link_color_active, bg_color); |
142 | PageLinks.Hover(mouse.x, WB1.list.first*WB1.list.item_h + mouse.y, link_color_inactive, link_color_active, bg_color); |
143 | if (bufsize) && (mouse.pkm) && (mouse.up) { |
143 | if (bufsize) && (mouse.pkm) && (mouse.up) { |
144 | menu.show(Form.left+mouse.x-6,Form.top+mouse.y+skin_height+3, 180, #rmb_menu, VIEW_SOURCE); |
144 | menu.show(Form.left+mouse.x-6,Form.top+mouse.y+skin_height+3, 180, #rmb_menu, VIEW_SOURCE); |
145 | break; |
145 | break; |
146 | } |
146 | } |
147 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
147 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
148 | } |
148 | } |
149 | scrollbar_v_mouse (#scroll_wv); |
149 | scrollbar_v_mouse (#scroll_wv); |
150 | if (WB1.list.first != scroll_wv.position) |
150 | if (WB1.list.first != scroll_wv.position) |
151 | { |
151 | { |
152 | WB1.list.first = scroll_wv.position; |
152 | WB1.list.first = scroll_wv.position; |
153 | WB1.DrawPage(); |
153 | WB1.DrawPage(); |
154 | break; |
154 | break; |
155 | } |
155 | } |
156 | break; |
156 | break; |
157 | 157 | ||
158 | case evButton: |
158 | case evButton: |
159 | btn=GetButtonID(); |
159 | btn=GetButtonID(); |
160 | if (btn==1) ExitProcess(); |
160 | if (btn==1) ExitProcess(); |
161 | Scan(btn); |
161 | Scan(btn); |
162 | break; |
162 | break; |
163 | 163 | ||
164 | case evKey: |
164 | case evKey: |
165 | GetKeys(); |
165 | GetKeys(); |
166 | if (address_box.flags & 0b10) |
166 | if (address_box.flags & 0b10) |
167 | { |
167 | { |
168 | if (key_ascii == ASCII_KEY_ENTER) Scan(key_scancode); else { |
168 | if (key_ascii == ASCII_KEY_ENTER) Scan(key_scancode); else { |
169 | EAX = key_editbox; |
169 | EAX = key_editbox; |
170 | edit_box_key stdcall(#address_box); |
170 | edit_box_key stdcall(#address_box); |
171 | } |
171 | } |
172 | } |
172 | } |
173 | else |
173 | else |
174 | { |
174 | { |
175 | Scan(key_scancode); |
175 | Scan(key_scancode); |
176 | } |
176 | } |
177 | break; |
177 | break; |
178 | 178 | ||
179 | case evReDraw: |
179 | case evReDraw: |
180 | if (menu.list.cur_y) { |
180 | if (menu.list.cur_y) { |
181 | Scan(menu.list.cur_y); |
181 | Scan(menu.list.cur_y); |
182 | menu.list.cur_y = 0; |
182 | menu.list.cur_y = 0; |
183 | } |
183 | } |
184 | DefineAndDrawWindow(GetScreenWidth()-800/2,GetScreenHeight()-600/2,800,600,0x73,col_bg,0,0); |
184 | DefineAndDrawWindow(GetScreenWidth()-800/2,GetScreenHeight()-600/2,800,600,0x73,col_bg,0,0); |
185 | GetProcessInfo(#Form, SelfInfo); |
185 | GetProcessInfo(#Form, SelfInfo); |
186 | if (Form.status_window>2) { DrawTitle(#header); break; } |
186 | if (Form.status_window>2) { DrawTitle(#header); break; } |
187 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
187 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
188 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
188 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
189 | Draw_Window(); |
189 | Draw_Window(); |
190 | break; |
190 | break; |
191 | 191 | ||
192 | case evNetwork: |
192 | case evNetwork: |
193 | if (http_transfer > 0) { |
193 | if (http_transfer > 0) { |
194 | http_receive stdcall (http_transfer); |
194 | http_receive stdcall (http_transfer); |
195 | $push EAX |
195 | $push EAX |
196 | ESI = http_transfer; |
196 | ESI = http_transfer; |
197 | wv_progress_bar.max = ESI.http_msg.content_length; |
197 | wv_progress_bar.max = ESI.http_msg.content_length; |
198 | if (wv_progress_bar.value != ESI.http_msg.content_received) |
198 | if (wv_progress_bar.value != ESI.http_msg.content_received) |
199 | { |
199 | { |
200 | wv_progress_bar.value = ESI.http_msg.content_received; |
200 | wv_progress_bar.value = ESI.http_msg.content_received; |
201 | DrawProgress(); |
201 | DrawProgress(); |
202 | } |
202 | } |
203 | $pop EAX |
203 | $pop EAX |
204 | if (EAX == 0) { |
204 | if (EAX == 0) { |
205 | ESI = http_transfer; |
205 | ESI = http_transfer; |
206 | // Handle redirects |
206 | // Handle redirects |
207 | if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400) |
207 | if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400) |
208 | { |
208 | { |
209 | redirected++; |
209 | redirected++; |
210 | if (redirected<=5) |
210 | if (redirected<=5) |
211 | { |
211 | { |
212 | http_find_header_field stdcall (http_transfer, "location\0"); |
212 | http_find_header_field stdcall (http_transfer, "location\0"); |
213 | if (EAX!=0) { |
213 | if (EAX!=0) { |
214 | ESI = EAX; |
214 | ESI = EAX; |
215 | EDI = #URL; |
215 | EDI = #URL; |
216 | do { |
216 | do { |
217 | $lodsb; |
217 | $lodsb; |
218 | $stosb; |
218 | $stosb; |
219 | } while (AL != 0) && (AL != 13) && (AL != 10)); |
219 | } while (AL != 0) && (AL != 13) && (AL != 10)); |
220 | DSBYTE[EDI-1]='\0'; |
220 | DSBYTE[EDI-1]='\0'; |
221 | } |
221 | } |
222 | } |
222 | } |
223 | else |
223 | else |
224 | { |
224 | { |
225 | notify("Too many redirects"); |
225 | notify("Too many redirects"); |
226 | StopLoading(); |
226 | StopLoading(); |
227 | break; |
227 | break; |
228 | } |
228 | } |
229 | } |
229 | } |
230 | else |
230 | else |
231 | { |
231 | { |
232 | redirected = 0; |
232 | redirected = 0; |
233 | } |
233 | } |
234 | // Loading the page is complete, free resources |
234 | // Loading the page is complete, free resources |
235 | if (redirected>0) |
235 | if (redirected>0) |
236 | { |
236 | { |
237 | http_free stdcall (http_transfer); |
237 | http_free stdcall (http_transfer); |
238 | http_transfer=0; |
238 | http_transfer=0; |
239 | GetAbsoluteURL(#URL); |
239 | GetAbsoluteURL(#URL); |
240 | history.back(); |
240 | history.back(); |
241 | strcpy(#editURL, #URL); |
241 | strcpy(#editURL, #URL); |
242 | DrawEditBoxWebView(); |
242 | DrawEditBoxWebView(); |
243 | OpenPage(); |
243 | OpenPage(); |
244 | } |
244 | } |
245 | else |
245 | else |
246 | { |
246 | { |
247 | history.add(#URL); |
247 | history.add(#URL); |
248 | ESI = http_transfer; |
248 | ESI = http_transfer; |
249 | bufpointer = ESI.http_msg.content_ptr; |
249 | bufpointer = ESI.http_msg.content_ptr; |
250 | bufsize = ESI.http_msg.content_received; |
250 | bufsize = ESI.http_msg.content_received; |
251 | http_free stdcall (http_transfer); |
251 | http_free stdcall (http_transfer); |
252 | http_transfer=0; |
252 | http_transfer=0; |
253 | SetPageDefaults(); |
253 | SetPageDefaults(); |
254 | ShowPage(); |
254 | ShowPage(); |
255 | } |
255 | } |
256 | } |
256 | } |
257 | } |
257 | } |
258 | } |
258 | } |
259 | goto BEGIN_LOOP_APPLICATION; |
259 | goto BEGIN_LOOP_APPLICATION; |
260 | } |
260 | } |
261 | 261 | ||
262 | void SetElementSizes() |
262 | void SetElementSizes() |
263 | { |
263 | { |
264 | address_box.top = TOOLBAR_H/2-7; |
264 | address_box.top = TOOLBAR_H/2-7; |
265 | address_box.width = Form.cwidth - address_box.left - 25 - 22; |
265 | address_box.width = Form.cwidth - address_box.left - 25 - 22; |
266 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom, |
266 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom, |
267 | Form.cheight - TOOLBAR_H - STATUSBAR_H, WB1.list.font_h + WB1.DrawBuf.zoom + WB1.DrawBuf.zoom * WB1.DrawBuf.zoom); |
267 | Form.cheight - TOOLBAR_H - STATUSBAR_H, WB1.list.font_h + WB1.DrawBuf.zoom + WB1.DrawBuf.zoom * WB1.DrawBuf.zoom); |
268 | WB1.list.wheel_size = 7; |
268 | WB1.list.wheel_size = 7; |
269 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; |
269 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; |
270 | WB1.list.visible = WB1.list.h - 5 / WB1.list.item_h; |
270 | WB1.list.visible = WB1.list.h - 5 / WB1.list.item_h; |
271 | if (WB1.list.w!=WB1.DrawBuf.bufw) { |
271 | if (WB1.list.w!=WB1.DrawBuf.bufw) { |
272 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h * 30); |
272 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h * 30); |
273 | Scan(REFRESH_BUTTON); |
273 | Scan(REFRESH_BUTTON); |
274 | } |
274 | } |
275 | } |
275 | } |
276 | 276 | ||
277 | 277 | ||
278 | 278 | ||
279 | void Draw_Window() |
279 | void Draw_Window() |
280 | { |
280 | { |
281 | int list__w, list__h; |
281 | int list__w, list__h; |
282 | DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color); |
282 | DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, panel_color); |
283 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
283 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
284 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
284 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
285 | SetElementSizes(); |
285 | SetElementSizes(); |
286 | DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 20,border_color); |
286 | DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+5, 20,border_color); |
287 | DefineButton(address_box.left-50, address_box.top-2, 23, skin.h-2, BACK_BUTTON+BT_HIDE, 0); |
287 | DefineButton(address_box.left-50, address_box.top-2, 23, skin.h-2, BACK_BUTTON+BT_HIDE, 0); |
288 | DefineButton(address_box.left-26, address_box.top-2, 23, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0); |
288 | DefineButton(address_box.left-26, address_box.top-2, 23, skin.h-2, FORWARD_BUTTON+BT_HIDE, 0); |
289 | img_draw stdcall(skin.image, address_box.left-51, address_box.top-3, 48, skin.h, 3, 0); |
289 | img_draw stdcall(skin.image, address_box.left-51, address_box.top-3, 48, skin.h, 3, 0); |
290 | DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0); |
290 | DefineButton(address_box.left+address_box.width+1, address_box.top-3, 16, skin.h-1, REFRESH_BUTTON+BT_HIDE+BT_NOFRAME, 0); |
291 | DefineButton(Form.cwidth-24, address_box.top-3, 19, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0); |
291 | DefineButton(Form.cwidth-24, address_box.top-3, 19, skin.h-1, SANDWICH_BUTTON+BT_HIDE, 0); |
292 | img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-3, 16, skin.h, 85, 0); |
292 | img_draw stdcall(skin.image, Form.cwidth-22, address_box.top-3, 16, skin.h, 85, 0); |
293 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
293 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, col_bg); |
294 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
294 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, border_color); |
295 | if (!header) OpenPage(); else { WB1.DrawPage(); DrawEditBoxWebView(); } |
295 | if (!header) OpenPage(); else { WB1.DrawPage(); DrawEditBoxWebView(); } |
296 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
296 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
297 | DrawProgress(); |
297 | DrawProgress(); |
298 | 298 | ||
299 | /* |
299 | /* |
300 | list__w = 200; |
300 | list__w = 200; |
301 | list__h = 200; |
301 | list__h = 200; |
302 | label.raw_size = 0; |
302 | label.raw_size = 0; |
303 | label.write_buf(10,10, list__w, list__h, 0xFFFFFF, 0, 11, "Hello World!"); |
303 | label.write_buf(10,10, list__w, list__h, 0xFFFFFF, 0, 11, "Hello World!"); |
304 | label.write_buf(10,23, list__w, list__h, 0xFFFFFF, 0xFF00FF, 12, "How are you?"); |
304 | label.write_buf(10,23, list__w, list__h, 0xFFFFFF, 0xFF00FF, 12, "How are you?"); |
305 | label.write_buf(11,40, list__w, list__h, 0xFFFFFF, 0x2E74BB, 15, "Fine"); |
305 | label.write_buf(11,40, list__w, list__h, 0xFFFFFF, 0x2E74BB, 15, "Fine"); |
306 | label.apply_smooth(); |
306 | label.apply_smooth(); |
307 | label.show_buf(0,0); |
307 | label.show_buf(0,0); |
308 | */ |
308 | */ |
309 | } |
309 | } |
310 | 310 | ||
311 | 311 | ||
312 | void Scan(dword id__) |
312 | void Scan(dword id__) |
313 | { |
313 | { |
314 | action_buf=0; |
314 | action_buf=0; |
315 | if (WB1.list.ProcessKey(id__)) WB1.DrawPage(); |
315 | if (WB1.list.ProcessKey(id__)) WB1.DrawPage(); |
316 | else switch (id__) |
316 | else switch (id__) |
317 | { |
317 | { |
318 | case SCAN_CODE_BS: |
318 | case SCAN_CODE_BS: |
319 | case BACK_BUTTON: |
319 | case BACK_BUTTON: |
320 | if (history.back()) { |
320 | if (history.back()) { |
321 | strcpy(#URL, history.current()); |
321 | strcpy(#URL, history.current()); |
322 | OpenPage(); |
322 | OpenPage(); |
323 | } |
323 | } |
324 | return; |
324 | return; |
325 | case FORWARD_BUTTON: |
325 | case FORWARD_BUTTON: |
326 | if (history.forward()) { |
326 | if (history.forward()) { |
327 | strcpy(#URL, history.current()); |
327 | strcpy(#URL, history.current()); |
328 | OpenPage(); |
328 | OpenPage(); |
329 | } |
329 | } |
330 | return; |
330 | return; |
331 | case GOTOURL_BUTTON: |
331 | case GOTOURL_BUTTON: |
332 | case SCAN_CODE_ENTER: |
332 | case SCAN_CODE_ENTER: |
333 | if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') || (!strncmp(#editURL,"WebView:",9)) |
333 | if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') || (!strncmp(#editURL,"WebView:",9)) |
334 | { |
334 | { |
335 | strcpy(#URL, #editURL); |
335 | strcpy(#URL, #editURL); |
336 | } |
336 | } |
337 | else |
337 | else |
338 | { |
338 | { |
339 | strlcpy(#URL,"http://",7); |
339 | strlcpy(#URL,"http://",7); |
340 | strcat(#URL, #editURL); |
340 | strcat(#URL, #editURL); |
341 | } |
341 | } |
342 | OpenPage(); |
342 | OpenPage(); |
343 | return; |
343 | return; |
344 | case 063: //F5 |
344 | case 063: //F5 |
345 | IF(address_box.flags & 0b10) return; |
345 | IF(address_box.flags & 0b10) return; |
346 | case REFRESH_BUTTON: |
346 | case REFRESH_BUTTON: |
347 | if (http_transfer > 0) |
347 | if (http_transfer > 0) |
348 | { |
348 | { |
349 | StopLoading(); |
349 | StopLoading(); |
350 | Draw_Window(); |
350 | Draw_Window(); |
351 | } |
351 | } |
352 | else OpenPage(); |
352 | else OpenPage(); |
353 | return; |
353 | return; |
354 | case SANDWICH_BUTTON: |
354 | case SANDWICH_BUTTON: |
355 | mouse.y = TOOLBAR_H-6; |
355 | mouse.y = TOOLBAR_H-6; |
356 | mouse.x = Form.cwidth - 167; |
356 | mouse.x = Form.cwidth - 167; |
357 | menu.show(Form.left+mouse.x-6,Form.top+mouse.y+skin_height+3, 180, #rmb_menu, VIEW_SOURCE); |
357 | menu.show(Form.left+mouse.x-6,Form.top+mouse.y+skin_height+3, 180, #rmb_menu, VIEW_SOURCE); |
358 | return; |
358 | return; |
359 | case VIEW_SOURCE: |
359 | case VIEW_SOURCE: |
360 | WB1.list.first = 0; |
360 | WB1.list.first = 0; |
361 | ShowSource(); |
361 | ShowSource(); |
362 | WB1.LoadInternalPage(bufpointer, bufsize); |
362 | WB1.LoadInternalPage(bufpointer, bufsize); |
363 | break; |
363 | break; |
364 | case EDIT_SOURCE: |
364 | case EDIT_SOURCE: |
365 | if (!strncmp(#URL,"http:",5)) |
365 | if (!strncmp(#URL,"http:",5)) |
366 | { |
366 | { |
367 | WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
367 | WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
368 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
368 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
369 | } |
369 | } |
370 | else RunProgram("/rd/1/tinypad", #URL); |
370 | else RunProgram("/rd/1/tinypad", #URL); |
371 | return; |
371 | return; |
372 | case FREE_IMG_CACHE: |
372 | case FREE_IMG_CACHE: |
373 | ImgCache.Free(); |
373 | ImgCache.Free(); |
374 | notify(IMAGES_CACHE_CLEARED); |
374 | notify(IMAGES_CACHE_CLEARED); |
375 | WB1.DrawPage(); |
375 | WB1.DrawPage(); |
376 | return; |
376 | return; |
377 | case VIEW_HISTORY: |
377 | case VIEW_HISTORY: |
378 | strcpy(#URL, URL_SERVICE_HISTORY); |
378 | strcpy(#URL, URL_SERVICE_HISTORY); |
379 | OpenPage(); |
379 | OpenPage(); |
380 | return; |
380 | return; |
381 | case DOWNLOAD_MANAGER: |
381 | case DOWNLOAD_MANAGER: |
382 | if (!downloader_opened) { |
382 | if (!downloader_opened) { |
383 | downloader_edit = NULL; |
383 | downloader_edit = NULL; |
384 | CreateThread(#Downloader,#downloader_stak+4092); |
384 | CreateThread(#Downloader,#downloader_stak+4092); |
385 | } |
385 | } |
386 | return; |
386 | return; |
387 | } |
387 | } |
388 | } |
388 | } |
389 | 389 | ||
390 | 390 | ||
391 | void StopLoading() |
391 | void StopLoading() |
392 | { |
392 | { |
393 | if (http_transfer) |
393 | if (http_transfer) |
394 | { |
394 | { |
395 | EAX = http_transfer; |
395 | EAX = http_transfer; |
396 | EAX = EAX.http_msg.content_ptr; // get pointer to data |
396 | EAX = EAX.http_msg.content_ptr; // get pointer to data |
397 | $push EAX // save it on the stack |
397 | $push EAX // save it on the stack |
398 | http_free stdcall (http_transfer); // abort connection |
398 | http_free stdcall (http_transfer); // abort connection |
399 | $pop EAX |
399 | $pop EAX |
400 | free(EAX); // free data |
400 | free(EAX); // free data |
401 | http_transfer=0; |
401 | http_transfer=0; |
402 | bufsize = 0; |
402 | bufsize = 0; |
403 | bufpointer = free(bufpointer); |
403 | bufpointer = free(bufpointer); |
404 | } |
404 | } |
405 | wv_progress_bar.value = 0; |
405 | wv_progress_bar.value = 0; |
406 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 52, 0); |
406 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 52, 0); |
407 | } |
407 | } |
408 | 408 | ||
409 | void SetPageDefaults() |
409 | void SetPageDefaults() |
410 | { |
410 | { |
411 | strcpy(#header, #version); |
411 | strcpy(#header, #version); |
412 | WB1.list.count = WB1.list.first = 0; |
412 | WB1.list.count = WB1.list.first = 0; |
413 | stroka = 0; |
413 | stroka = 0; |
414 | cur_encoding = CH_NULL; |
414 | cur_encoding = CH_NULL; |
415 | if (o_bufpointer) o_bufpointer = free(o_bufpointer); |
415 | if (o_bufpointer) o_bufpointer = free(o_bufpointer); |
416 | anchor_line_num=WB1.list.first; |
416 | anchor_line_num=WB1.list.first; |
417 | anchor[0]='|'; |
417 | anchor[0]='|'; |
418 | } |
418 | } |
419 | 419 | ||
420 | void OpenPage() |
420 | void OpenPage() |
421 | { |
421 | { |
422 | StopLoading(); |
422 | StopLoading(); |
423 | souce_mode = false; |
423 | souce_mode = false; |
424 | strcpy(#editURL, #URL); |
424 | strcpy(#editURL, #URL); |
425 | history.add(#URL); |
425 | history.add(#URL); |
426 | if (!strncmp(#URL,"WebView:",8)) |
426 | if (!strncmp(#URL,"WebView:",8)) |
427 | { |
427 | { |
428 | SetPageDefaults(); |
428 | SetPageDefaults(); |
429 | if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.LoadInternalPage(#homepage, sizeof(homepage)); |
429 | if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.LoadInternalPage(#homepage, sizeof(homepage)); |
430 | else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory(); |
430 | else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory(); |
431 | DrawEditBoxWebView(); |
431 | DrawEditBoxWebView(); |
432 | return; |
432 | return; |
433 | } |
433 | } |
434 | if (!strncmp(#URL,"http:",5)) |
434 | if (!strncmp(#URL,"http:",5)) |
435 | { |
435 | { |
436 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0); |
436 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, 131, 0); |
437 | http_get stdcall (#URL, 0, 0, #accept_language); |
437 | http_get stdcall (#URL, 0, 0, #accept_language); |
438 | http_transfer = EAX; |
438 | http_transfer = EAX; |
439 | if (!http_transfer) |
439 | if (!http_transfer) |
440 | { |
440 | { |
441 | StopLoading(); |
441 | StopLoading(); |
442 | bufsize = 0; |
442 | bufsize = 0; |
443 | bufpointer = free(bufpointer); |
443 | bufpointer = free(bufpointer); |
444 | ShowPage(); |
444 | ShowPage(); |
445 | return; |
445 | return; |
446 | } |
446 | } |
447 | } |
447 | } |
448 | else |
448 | else |
449 | { |
449 | { |
450 | file_size stdcall (#URL); |
450 | file_size stdcall (#URL); |
451 | bufsize = EBX; |
451 | bufsize = EBX; |
452 | if (bufsize) |
452 | if (bufsize) |
453 | { |
453 | { |
454 | free(bufpointer); |
454 | free(bufpointer); |
455 | bufpointer = malloc(bufsize); |
455 | bufpointer = malloc(bufsize); |
456 | SetPageDefaults(); |
456 | SetPageDefaults(); |
457 | ReadFile(0, bufsize, bufpointer, #URL); |
457 | ReadFile(0, bufsize, bufpointer, #URL); |
458 | } |
458 | } |
459 | ShowPage(); |
459 | ShowPage(); |
460 | } |
460 | } |
461 | } |
461 | } |
462 | 462 | ||
463 | DrawEditBoxWebView() |
463 | DrawEditBoxWebView() |
464 | { |
464 | { |
465 | DrawWideRectangle(address_box.left-2, address_box.top-2, address_box.width+3, 19, 2, address_box.color); |
465 | DrawWideRectangle(address_box.left-2, address_box.top-2, address_box.width+3, 19, 2, address_box.color); |
466 | address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL); |
466 | address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL); |
467 | address_box.offset = 0; |
467 | address_box.offset = 0; |
468 | edit_box_draw stdcall(#address_box); |
468 | edit_box_draw stdcall(#address_box); |
469 | if (http_transfer > 0) EAX = 131; else EAX = 52; |
469 | if (http_transfer > 0) EAX = 131; else EAX = 52; |
470 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, EAX, 0); |
470 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-3, 17, skin.h, EAX, 0); |
471 | } |
471 | } |
472 | 472 | ||
473 | 473 | ||
474 | void ShowPage() |
474 | void ShowPage() |
475 | { |
475 | { |
476 | DrawEditBoxWebView(); |
476 | DrawEditBoxWebView(); |
477 | if (!bufsize) |
477 | if (!bufsize) |
478 | { |
478 | { |
479 | if (http_transfer) WB1.LoadInternalPage(#loading, sizeof(loading)); |
479 | if (http_transfer) WB1.LoadInternalPage(#loading, sizeof(loading)); |
480 | else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
480 | else WB1.LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
481 | } |
481 | } |
482 | else |
482 | else |
483 | { |
483 | { |
484 | WB1.Prepare(); |
484 | WB1.Prepare(); |
485 | } |
485 | } |
486 | //if (!header) strcpy(#header, #version); |
486 | //if (!header) strcpy(#header, #version); |
487 | if (!strcmp(#version, #header)) DrawTitle(#header); |
487 | if (!strcmp(#version, #header)) DrawTitle(#header); |
488 | } |
488 | } |
489 | 489 | ||
490 | byte UrlExtIs(dword ext) |
490 | byte UrlExtIs(dword ext) |
491 | { |
491 | { |
492 | if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true; |
492 | if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true; |
493 | return false; |
493 | return false; |
494 | } |
494 | } |
495 | 495 | ||
496 | int SetSkinColors() |
496 | int SetSkinColors() |
497 | { |
497 | { |
498 | dword image_data; |
498 | dword image_data; |
499 | image_data = DSDWORD[skin.image+24]; |
499 | image_data = DSDWORD[skin.image+24]; |
500 | col_bg = DSDWORD[image_data]; |
500 | col_bg = DSDWORD[image_data]; |
501 | panel_color = DSDWORD[skin.w*4*4 + image_data]; |
501 | panel_color = DSDWORD[skin.w*4*4 + image_data]; |
502 | border_color = DSDWORD[skin.w*4*7 + image_data]; |
502 | border_color = DSDWORD[skin.w*4*7 + image_data]; |
503 | wv_progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data]; |
503 | wv_progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data]; |
504 | $and col_bg, 0x00ffffff |
504 | $and col_bg, 0x00ffffff |
505 | $and panel_color, 0x00ffffff |
505 | $and panel_color, 0x00ffffff |
506 | $and border_color, 0x00ffffff |
506 | $and border_color, 0x00ffffff |
507 | $and wv_progress_bar.progress_color, 0x00ffffff |
507 | $and wv_progress_bar.progress_color, 0x00ffffff |
508 | } |
508 | } |
509 | 509 | ||
510 | void DrawProgress() |
510 | void DrawProgress() |
511 | { |
511 | { |
512 | unsigned long btn; |
512 | unsigned long btn; |
513 | if (http_transfer == 0) return; |
513 | if (http_transfer == 0) return; |
514 | if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30; |
514 | if (wv_progress_bar.max) btn = address_box.width*wv_progress_bar.value/wv_progress_bar.max; else btn = 30; |
515 | DrawBar(address_box.left-2, address_box.top+15, btn, 2, wv_progress_bar.progress_color); |
515 | DrawBar(address_box.left-2, address_box.top+15, btn, 2, wv_progress_bar.progress_color); |
516 | } |
516 | } |
517 | 517 | ||
518 | void ClickLink() |
518 | void ClickLink() |
519 | { |
519 | { |
520 | if (http_transfer > 0) |
520 | if (http_transfer > 0) |
521 | { |
521 | { |
522 | StopLoading(); |
522 | StopLoading(); |
523 | history.back(); |
523 | history.back(); |
524 | } |
524 | } |
525 | 525 | ||
526 | strcpy(#URL, PageLinks.GetURL(PageLinks.active)); |
526 | strcpy(#URL, PageLinks.GetURL(PageLinks.active)); |
527 | //#1 |
527 | //#1 |
528 | if (URL[0] == '#') |
528 | if (URL[0] == '#') |
529 | { |
529 | { |
530 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
530 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
531 | strcpy(#URL, history.current()); |
531 | strcpy(#URL, history.current()); |
532 | WB1.list.first=WB1.list.count-WB1.list.visible; |
532 | WB1.list.first=WB1.list.count-WB1.list.visible; |
533 | ShowPage(); |
533 | ShowPage(); |
534 | return; |
534 | return; |
535 | } |
535 | } |
536 | //liner.ru#1 |
536 | //liner.ru#1 |
537 | if (strrchr(#URL, '#')!=-1) |
537 | if (strrchr(#URL, '#')!=-1) |
538 | { |
538 | { |
539 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
539 | strcpy(#anchor, #URL+strrchr(#URL, '#')); |
540 | URL[strrchr(#URL, '#')-1] = 0x00; |
540 | URL[strrchr(#URL, '#')-1] = 0x00; |
541 | } |
541 | } |
542 | 542 | ||
543 | GetAbsoluteURL(#URL); |
543 | GetAbsoluteURL(#URL); |
544 | 544 | ||
545 | if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1) |
545 | if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1) |
546 | || (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1) |
546 | || (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1) |
547 | { |
547 | { |
548 | //notify(#URL); |
548 | //notify(#URL); |
549 | if (!strncmp(#URL,"http://", 7)) |
549 | if (!strncmp(#URL,"http://", 7)) |
550 | { |
550 | { |
551 | strcpy(#downloader_edit, #URL); |
551 | strcpy(#downloader_edit, #URL); |
552 | CreateThread(#Downloader,#downloader_stak+4092); |
552 | CreateThread(#Downloader,#downloader_stak+4092); |
553 | } |
553 | } |
554 | else RunProgram("@open", #URL); |
554 | else RunProgram("@open", #URL); |
555 | strcpy(#editURL, history.current()); |
555 | strcpy(#editURL, history.current()); |
556 | strcpy(#URL, history.current()); |
556 | strcpy(#URL, history.current()); |
557 | return; |
557 | return; |
558 | } |
558 | } |
559 | if (!strncmp(#URL,"mailto:", 7)) |
559 | if (!strncmp(#URL,"mailto:", 7)) |
560 | { |
560 | { |
561 | notify(#URL); |
561 | notify(#URL); |
562 | strcpy(#editURL, history.current()); |
562 | strcpy(#editURL, history.current()); |
563 | strcpy(#URL, history.current()); |
563 | strcpy(#URL, history.current()); |
564 | return; |
564 | return; |
565 | } |
565 | } |
566 | OpenPage(); |
566 | OpenPage(); |
567 | return; |
567 | return; |
568 | } |
568 | } |
569 | 569 | ||
570 | stop:=5) |
570 | stop:=5) |
571 | >>280)>120)> |
571 | >>280)>120)> |