Rev 7758 | Rev 7762 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7758 | Rev 7759 | ||
---|---|---|---|
1 | //HTML Viewer in C-- |
- | |
2 | //Copyright 2007-2020 by Veliant & Leency |
1 | //Copyright 2007-2020 by Veliant & Leency |
3 | //Asper, lev, Lrz, Barsuk, Nable, hidnplayr... |
2 | //Asper, lev, Lrz, Barsuk, Nable, hidnplayr... |
4 | 3 | ||
5 | #ifndef AUTOBUILD |
4 | #ifndef AUTOBUILD |
6 | #include "lang.h--" |
5 | #include "lang.h--" |
7 | #endif |
6 | #endif |
8 | 7 | ||
9 | //libraries |
8 | //libraries |
10 | #define MEMSIZE 1024 * 850 |
9 | #define MEMSIZE 1024 * 850 |
11 | #include "..\lib\gui.h" |
10 | #include "..\lib\gui.h" |
12 | #include "..\lib\draw_buf.h" |
11 | #include "..\lib\draw_buf.h" |
13 | #include "..\lib\list_box.h" |
12 | #include "..\lib\list_box.h" |
14 | #include "..\lib\cursor.h" |
13 | #include "..\lib\cursor.h" |
15 | #include "..\lib\collection.h" |
14 | #include "..\lib\collection.h" |
16 | #include "..\lib\random.h" |
15 | #include "..\lib\random.h" |
17 | #include "..\lib\clipboard.h" |
16 | #include "..\lib\clipboard.h" |
18 | 17 | ||
19 | // *.obj libraries |
18 | // *.obj libraries |
20 | #include "..\lib\obj\box_lib.h" |
19 | #include "..\lib\obj\box_lib.h" |
21 | #include "..\lib\obj\libio.h" |
20 | #include "..\lib\obj\libio.h" |
22 | #include "..\lib\obj\libimg.h" |
21 | #include "..\lib\obj\libimg.h" |
23 | #include "..\lib\obj\http.h" |
22 | #include "..\lib\obj\http.h" |
24 | #include "..\lib\obj\iconv.h" |
23 | #include "..\lib\obj\iconv.h" |
25 | #include "..\lib\obj\proc_lib.h" |
24 | #include "..\lib\obj\proc_lib.h" |
26 | 25 | ||
27 | //useful patterns |
26 | //useful patterns |
28 | #include "..\lib\patterns\history.h" |
27 | #include "..\lib\patterns\history.h" |
29 | #include "..\lib\patterns\http_downloader.h" |
28 | #include "..\lib\patterns\http_downloader.h" |
30 | #include "..\lib\patterns\simple_open_dialog.h" |
29 | #include "..\lib\patterns\simple_open_dialog.h" |
- | 30 | #include "..\lib\patterns\toolbar_button.h" |
|
31 | 31 | ||
32 | #include "show_src.h" |
32 | #include "show_src.h" |
33 | #include "download_manager.h" |
33 | #include "download_manager.h" |
34 | _history history; |
34 | _history history; |
35 | #include "history.h" |
35 | #include "history.h" |
36 | bool debug_mode = false; |
36 | bool debug_mode = false; |
37 | #include "..\TWB\TWB.c" |
37 | #include "..\TWB\TWB.c" //HTML Parser, a core component |
- | 38 | ||
- | 39 | TWebBrowser WB1; |
|
38 | 40 | ||
39 | char version[]="WebView 2.0 Gold"; |
41 | char version[]="WebView 2.1"; |
40 | 42 | ||
41 | #ifdef LANG_RUS |
43 | #ifdef LANG_RUS |
42 | char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; |
44 | char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; |
43 | char homepage[] = FROM "html\\homepage_ru.htm""\0"; |
45 | char homepage[] = FROM "html\\homepage_ru.htm""\0"; |
44 | char help[] = FROM "html\\help_ru.htm""\0"; |
46 | char help[] = FROM "html\\help_ru.htm""\0"; |
45 | char accept_language[]= "Accept-Language: ru\n"; |
47 | char accept_language[]= "Accept-Language: ru\n"; |
46 | char rmb_menu[] = |
48 | char rmb_menu[] = |
47 | "®á¬®âà¥âì ¨á室¨ª |
49 | "®á¬®âà¥âì ¨á室¨ª |
48 | ¥¤ ªâ¨à®¢ âì ¨á室¨ª"; |
50 | ¥¤ ªâ¨à®¢ âì ¨á室¨ª"; |
49 | char main_menu[] = |
51 | char main_menu[] = |
50 | "âªàëâì ä ©« |
52 | "âªàëâì ä ©« |
51 | ®¢®¥ ®ª® |
53 | ®¢®¥ ®ª® |
52 | áâ®à¨ï |
54 | áâ®à¨ï |
53 | ¥¥¤¦¥à § £à㧮ª"; |
55 | ¥¥¤¦¥à § £à㧮ª"; |
54 | char link_menu[] = |
56 | char link_menu[] = |
55 | "®¯¨à®¢ âì áá뫪ã |
57 | "®¯¨à®¢ âì áá뫪ã |
56 | ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨"; |
58 | ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨"; |
57 | char loading_text[] = " £à㧪 ..."; |
59 | char loading_text[] = " £à㧪 ..."; |
58 | #else |
60 | #else |
59 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
61 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
60 | char homepage[] = FROM "html\\homepage_en.htm""\0"; |
62 | char homepage[] = FROM "html\\homepage_en.htm""\0"; |
61 | char help[] = FROM "html\\help_en.htm""\0"; |
63 | char help[] = FROM "html\\help_en.htm""\0"; |
62 | char accept_language[]= "Accept-Language: en\n"; |
64 | char accept_language[]= "Accept-Language: en\n"; |
63 | char rmb_menu[] = |
65 | char rmb_menu[] = |
64 | "View source |
66 | "View source |
65 | Edit source"; |
67 | Edit source"; |
66 | char main_menu[] = |
68 | char main_menu[] = |
67 | "Open local file |
69 | "Open local file |
68 | New window |
70 | New window |
69 | History |
71 | History |
70 | Download Manager"; |
72 | Download Manager"; |
71 | char link_menu[] = |
73 | char link_menu[] = |
72 | "Copy link |
74 | "Copy link |
73 | Download link contents"; |
75 | Download link contents"; |
74 | char loading_text[] = "Loading..."; |
76 | char loading_text[] = "Loading..."; |
75 | #endif |
77 | #endif |
76 | 78 | ||
77 | #define URL_SIZE 4000 |
79 | #define URL_SIZE 4000 |
78 | 80 | ||
79 | #define URL_SERVICE_HISTORY "WebView:history" |
81 | #define URL_SERVICE_HISTORY "WebView:history" |
80 | #define URL_SERVICE_HOMEPAGE "WebView:home" |
82 | #define URL_SERVICE_HOMEPAGE "WebView:home" |
81 | #define URL_SERVICE_HELP "WebView:help" |
83 | #define URL_SERVICE_HELP "WebView:help" |
82 | 84 | ||
83 | #define PADDING 9 |
85 | #define PADDING 9 |
84 | #define SKIN_Y 24 |
86 | #define SKIN_Y 24 |
85 | #define TSZE 25 |
87 | #define TSZE 25 |
86 | dword TOOLBAR_H = PADDING+TSZE+PADDING+2; |
88 | dword TOOLBAR_H = PADDING+TSZE+PADDING+2; |
87 | dword STATUSBAR_H = 15; |
89 | dword STATUSBAR_H = 15; |
88 | 90 | ||
89 | int action_buf; |
91 | int action_buf; |
90 | 92 | ||
91 | _http http = {0, 0, 0, 0, 0, 0, 0}; |
93 | _http http = 0; |
92 | 94 | ||
93 | bool source_mode = false; |
95 | bool source_mode = false; |
94 | 96 | ||
95 | progress_bar wv_progress_bar; |
97 | progress_bar wv_progress_bar; |
96 | char stak[4096]; |
98 | char stak[4096]; |
97 | proc_info Form; |
99 | proc_info Form; |
98 | 100 | ||
99 | enum { |
101 | enum { |
- | 102 | ENCODINGS=900, |
|
100 | BACK_BUTTON=1000, |
103 | BACK_BUTTON=1000, |
101 | FORWARD_BUTTON, |
104 | FORWARD_BUTTON, |
102 | REFRESH_BUTTON, |
105 | REFRESH_BUTTON, |
103 | GOTOURL_BUTTON, |
106 | GOTOURL_BUTTON, |
- | 107 | CHANGE_ENCODING, |
|
104 | SANDWICH_BUTTON, |
108 | SANDWICH_BUTTON, |
105 | VIEW_SOURCE, |
109 | VIEW_SOURCE, |
106 | EDIT_SOURCE, |
110 | EDIT_SOURCE, |
107 | OPEN_FILE, |
111 | OPEN_FILE, |
108 | NEW_WINDOW, |
112 | NEW_WINDOW, |
109 | VIEW_HISTORY, |
113 | VIEW_HISTORY, |
110 | DOWNLOAD_MANAGER, |
114 | DOWNLOAD_MANAGER, |
111 | COPY_LINK_URL, |
115 | COPY_LINK_URL, |
112 | DOWNLOAD_LINK_CONTENTS, |
116 | DOWNLOAD_LINK_CONTENTS, |
113 | }; |
117 | }; |
114 | 118 | ||
115 | char default_dir[] = "/rd/1"; |
119 | char default_dir[] = "/rd/1"; |
116 | od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" }; |
120 | od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" }; |
117 | 121 | ||
118 | char editURL[URL_SIZE+1]; |
122 | char editURL[URL_SIZE+1]; |
119 | edit_box address_box = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff, |
123 | edit_box address_box = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff, |
120 | 0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19}; |
124 | 0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19}; |
121 | 125 | ||
122 | 126 | ||
123 | void LoadLibraries() |
127 | void LoadLibraries() |
124 | { |
128 | { |
125 | load_dll(boxlib, #box_lib_init,0); |
129 | load_dll(boxlib, #box_lib_init,0); |
126 | load_dll(libio, #libio_init,1); |
130 | load_dll(libio, #libio_init,1); |
127 | load_dll(libimg, #libimg_init,1); |
131 | load_dll(libimg, #libimg_init,1); |
128 | load_dll(libHTTP, #http_lib_init,1); |
132 | load_dll(libHTTP, #http_lib_init,1); |
129 | load_dll(iconv_lib, #iconv_open,0); |
133 | load_dll(iconv_lib, #iconv_open,0); |
130 | load_dll(Proc_lib, #OpenDialog_init,0); |
134 | load_dll(Proc_lib, #OpenDialog_init,0); |
131 | OpenDialog_init stdcall (#o_dialog); |
135 | OpenDialog_init stdcall (#o_dialog); |
132 | } |
136 | } |
133 | 137 | ||
134 | void HandleParam() |
138 | void HandleParam() |
135 | { |
139 | { |
136 | if (param) { |
140 | if (param) { |
137 | if (!strncmp(#param, "-d ", 3)) { |
141 | if (!strncmp(#param, "-d ", 3)) { |
138 | strcpy(#downloader_edit, #param+3); |
142 | strcpy(#downloader_edit, #param+3); |
139 | CreateThread(#Downloader,#downloader_stak+4092); |
143 | CreateThread(#Downloader,#downloader_stak+4092); |
140 | ExitProcess(); |
144 | ExitProcess(); |
141 | } else if (!strncmp(#param, "-s ", 3)) { |
145 | } else if (!strncmp(#param, "-s ", 3)) { |
142 | source_mode = true; |
146 | source_mode = true; |
143 | history.add(#param + 3); |
147 | history.add(#param + 3); |
144 | } else { |
148 | } else { |
145 | history.add(#param); |
149 | history.add(#param); |
146 | } |
150 | } |
147 | } else { |
151 | } else { |
148 | history.add(URL_SERVICE_HOMEPAGE); |
152 | history.add(URL_SERVICE_HOMEPAGE); |
149 | } |
153 | } |
150 | } |
154 | } |
151 | 155 | ||
152 | void main() |
156 | void main() |
153 | { |
157 | { |
154 | int i, btn, redirect_count=0; |
158 | int i, btn, redirect_count=0; |
155 | LoadLibraries(); |
159 | LoadLibraries(); |
156 | CreateDir("/tmp0/1/downloads"); |
160 | CreateDir("/tmp0/1/downloads"); |
157 | Libimg_LoadImage(#skin, "/sys/toolbar.png"); |
161 | Libimg_LoadImage(#skin, "/sys/toolbar.png"); |
158 | HandleParam(); |
162 | HandleParam(); |
159 | skin.h = 26; |
163 | skin.h = 26; |
160 | WB1.list.SetFont(8, 14, 10011000b); |
164 | WB1.list.SetFont(8, 14, 10011000b); |
161 | WB1.list.no_selection = true; |
165 | WB1.list.no_selection = true; |
- | 166 | WB1.custom_encoding = -1; |
|
162 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); |
167 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); |
163 | loop() switch(WaitEvent()) |
168 | loop() switch(WaitEvent()) |
164 | { |
169 | { |
165 | case evMouse: |
170 | case evMouse: |
166 | edit_box_mouse stdcall (#address_box); |
171 | edit_box_mouse stdcall (#address_box); |
167 | mouse.get(); |
172 | mouse.get(); |
168 | if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y, WB1.list.y, WB1.list.first)) |
173 | if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y, WB1.list.y, WB1.list.first)) |
169 | && (mouse.pkm) && (mouse.up) { |
174 | && (mouse.pkm) && (mouse.up) { |
170 | if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y); |
175 | if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y); |
171 | break; |
176 | break; |
172 | } |
177 | } |
173 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
178 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
174 | scrollbar_v_mouse (#scroll_wv); |
179 | scrollbar_v_mouse (#scroll_wv); |
175 | if (WB1.list.first != scroll_wv.position) |
180 | if (WB1.list.first != scroll_wv.position) |
176 | { |
181 | { |
177 | WB1.list.first = scroll_wv.position; |
182 | WB1.list.first = scroll_wv.position; |
178 | WB1.DrawPage(); |
183 | WB1.DrawPage(); |
179 | break; |
184 | break; |
180 | } |
185 | } |
181 | if (mouse.up) && (! address_box.flags & ed_focus) && (address_box.flags & ed_shift_bac) |
186 | if (mouse.up) && (! address_box.flags & ed_focus) && (address_box.flags & ed_shift_bac) |
182 | { |
187 | { |
183 | DrawOmnibox(); //reset text selection |
188 | DrawOmnibox(); //reset text selection |
184 | } |
189 | } |
185 | break; |
190 | break; |
186 | 191 | ||
187 | case evButton: |
192 | case evButton: |
188 | btn = GetButtonID(); |
193 | btn = GetButtonID(); |
189 | if (1==btn) ExitProcess(); else ProcessEvent(btn); |
194 | if (1==btn) ExitProcess(); else ProcessEvent(btn); |
190 | break; |
195 | break; |
191 | 196 | ||
192 | case evKey: |
197 | case evKey: |
193 | GetKeys(); |
198 | GetKeys(); |
194 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
199 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
195 | if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;} |
200 | if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;} |
196 | if (key_scancode == SCAN_CODE_KEY_H) {ProcessEvent(VIEW_HISTORY);break;} |
201 | if (key_scancode == SCAN_CODE_KEY_H) {ProcessEvent(VIEW_HISTORY);break;} |
197 | if (key_scancode == SCAN_CODE_KEY_U) {EventViewSource();break;} |
202 | if (key_scancode == SCAN_CODE_KEY_U) {EventViewSource();break;} |
198 | if (key_scancode == SCAN_CODE_KEY_T) |
203 | if (key_scancode == SCAN_CODE_KEY_T) |
199 | || (key_scancode == SCAN_CODE_KEY_N) {RunProgram(#program_path, NULL);break;} |
204 | || (key_scancode == SCAN_CODE_KEY_N) {RunProgram(#program_path, NULL);break;} |
200 | if (key_scancode == SCAN_CODE_KEY_J) {ProcessEvent(DOWNLOAD_MANAGER);break;} |
205 | if (key_scancode == SCAN_CODE_KEY_J) {ProcessEvent(DOWNLOAD_MANAGER);break;} |
201 | if (key_scancode == SCAN_CODE_KEY_R) {ProcessEvent(REFRESH_BUTTON);break;} |
206 | if (key_scancode == SCAN_CODE_KEY_R) {ProcessEvent(REFRESH_BUTTON);break;} |
202 | if (key_scancode == SCAN_CODE_ENTER) {EventSeachWeb();break;} |
207 | if (key_scancode == SCAN_CODE_ENTER) {EventSeachWeb();break;} |
203 | if (key_scancode == SCAN_CODE_LEFT) {ProcessEvent(BACK_BUTTON);break;} |
208 | if (key_scancode == SCAN_CODE_LEFT) {ProcessEvent(BACK_BUTTON);break;} |
204 | if (key_scancode == SCAN_CODE_RIGHT) {ProcessEvent(FORWARD_BUTTON);break;} |
209 | if (key_scancode == SCAN_CODE_RIGHT) {ProcessEvent(FORWARD_BUTTON);break;} |
205 | if (key_scancode == SCAN_CODE_KEY_W) {ExitProcess();break;} |
210 | if (key_scancode == SCAN_CODE_KEY_W) {ExitProcess();break;} |
206 | } |
211 | } |
207 | 212 | ||
208 | if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON); |
213 | if (key_scancode == SCAN_CODE_F5) ProcessEvent(REFRESH_BUTTON); |
209 | 214 | ||
210 | if (address_box.flags & ed_focus) |
215 | if (address_box.flags & ed_focus) |
211 | { |
216 | { |
212 | if (key_scancode == SCAN_CODE_ENTER) { |
217 | if (key_scancode == SCAN_CODE_ENTER) { |
213 | ProcessEvent(key_scancode); |
218 | ProcessEvent(key_scancode); |
214 | } |
219 | } |
215 | else { |
220 | else { |
216 | EAX = key_editbox; |
221 | EAX = key_editbox; |
217 | edit_box_key stdcall(#address_box); |
222 | edit_box_key stdcall(#address_box); |
218 | } |
223 | } |
219 | } |
224 | } |
220 | else |
225 | else |
221 | { |
226 | { |
222 | #define KEY_SCROLL_N 11 |
227 | #define KEY_SCROLL_N 11 |
223 | if (SCAN_CODE_UP == key_scancode) for (i=0;i |
228 | if (SCAN_CODE_UP == key_scancode) for (i=0;i |
224 | if (SCAN_CODE_DOWN == key_scancode) for (i=0;i |
229 | if (SCAN_CODE_DOWN == key_scancode) for (i=0;i |
225 | if (key_scancode == SCAN_CODE_F6) {address_box.flags=ed_focus; DrawOmnibox();} |
230 | if (key_scancode == SCAN_CODE_F6) {address_box.flags=ed_focus; DrawOmnibox();} |
226 | if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage(); |
231 | if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage(); |
227 | else ProcessEvent(key_scancode); |
232 | else ProcessEvent(key_scancode); |
228 | } |
233 | } |
229 | break; |
234 | break; |
230 | 235 | ||
231 | case evReDraw: |
236 | case evReDraw: |
232 | if (menu.cur_y) { |
237 | if (menu.cur_y) { |
233 | ProcessEvent(menu.cur_y); |
238 | ProcessEvent(menu.cur_y); |
234 | menu.cur_y = 0; |
239 | menu.cur_y = 0; |
235 | } |
240 | } |
236 | DefineAndDrawWindow(GetScreenWidth()-800/2-random(80), |
241 | DefineAndDrawWindow(GetScreenWidth()-800/2-random(80), |
237 | GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0); |
242 | GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0); |
238 | GetProcessInfo(#Form, SelfInfo); |
243 | GetProcessInfo(#Form, SelfInfo); |
239 | system.color.get(); |
244 | system.color.get(); |
240 | if (Form.status_window>2) { DrawTitle(#header); break; } |
245 | if (Form.status_window>2) break; |
241 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
246 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
242 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
247 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
243 | draw_window(); |
248 | draw_window(); |
244 | break; |
249 | break; |
245 | 250 | ||
246 | case evNetwork: |
251 | case evNetwork: |
247 | if (http.transfer <= 0) break; |
252 | if (http.transfer <= 0) break; |
248 | http.receive(); |
253 | http.receive(); |
249 | EventUpdateProgressBar(); |
254 | EventUpdateProgressBar(); |
250 | if (http.receive_result != 0) break; |
255 | if (http.receive_result != 0) break; |
251 | if (http.status_code >= 300) && (http.status_code < 400) |
256 | if (http.status_code >= 300) && (http.status_code < 400) |
252 | { |
257 | { |
253 | // Handle redirects |
258 | // Handle redirects |
254 | if (redirect_count<=5) { |
259 | if (redirect_count<=5) { |
255 | redirect_count++; |
260 | redirect_count++; |
256 | http.handle_redirect(); |
261 | http.handle_redirect(); |
257 | http.free(); |
262 | http.free(); |
258 | GetAbsoluteURL(#http.redirect_url, history.current()); |
263 | GetAbsoluteURL(#http.redirect_url, history.current()); |
259 | history.back(); |
264 | history.back(); |
260 | OpenPage(#http.redirect_url); |
265 | OpenPage(#http.redirect_url); |
261 | } else { |
266 | } else { |
262 | notify("'Too many redirects.' -E"); |
267 | notify("'Too many redirects.' -E"); |
263 | StopLoading(); |
268 | StopLoading(); |
264 | } |
269 | } |
265 | } else { |
270 | } else { |
266 | // Loading the page is complete, free resources |
271 | // Loading the page is complete, free resources |
267 | redirect_count = 0; |
272 | redirect_count = 0; |
268 | http.free(); |
273 | http.free(); |
269 | LoadInternalPage(http.content_pointer, http.content_received); |
274 | LoadInternalPage(http.content_pointer, http.content_received); |
270 | } |
275 | } |
271 | } |
276 | } |
272 | } |
277 | } |
273 | 278 | ||
274 | void SetElementSizes() |
279 | void SetElementSizes() |
275 | { |
280 | { |
276 | basic_line_h = calc(WB1.list.font_h * 130) / 100; |
- | |
277 | address_box.width = Form.cwidth - address_box.left - 52 - 16; |
281 | address_box.width = Form.cwidth - address_box.left - 52 - 16; |
278 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, |
282 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, |
279 | Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h); |
283 | Form.cheight - TOOLBAR_H - STATUSBAR_H, BASIC_LINE_H); |
280 | WB1.list.wheel_size = 7 * basic_line_h; |
284 | WB1.list.wheel_size = 7 * BASIC_LINE_H; |
281 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1; |
285 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1; |
282 | WB1.list.visible = WB1.list.h; |
286 | WB1.list.visible = WB1.list.h; |
283 | } |
287 | } |
284 | 288 | ||
285 | - | ||
286 | 289 | ||
287 | void draw_window() |
290 | void draw_window() |
288 | { |
291 | { |
289 | int i; |
292 | int i; |
290 | SetElementSizes(); |
293 | SetElementSizes(); |
291 | 294 | ||
292 | DrawBar(0,0, Form.cwidth,PADDING, system.color.work); |
295 | DrawBar(0,0, Form.cwidth,PADDING, system.color.work); |
293 | DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, system.color.work); |
296 | DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, system.color.work); |
294 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, system.color.work_dark); |
297 | DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, system.color.work_dark); |
295 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, system.color.work_graph); |
298 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, system.color.work_graph); |
296 | DrawBar(0, PADDING, address_box.left-2, TSZE+1, system.color.work); |
299 | DrawBar(0, PADDING, address_box.left-2, TSZE+1, system.color.work); |
297 | DrawBar(address_box.left+address_box.width+18, PADDING, Form.cwidth-address_box.left-address_box.width-18, TSZE+1, system.color.work); |
300 | DrawBar(address_box.left+address_box.width+18, PADDING, Form.cwidth-address_box.left-address_box.width-18, TSZE+1, system.color.work); |
298 | 301 | ||
299 | DrawTopPanelButton(BACK_BUTTON, PADDING-1, 30); |
302 | DrawTopPanelButton(BACK_BUTTON, PADDING-1, PADDING, 30); |
300 | DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, 31); |
303 | DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, PADDING, 31); |
301 | DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-3, -1); |
304 | DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-3, PADDING, -1); |
302 | for (i=0; i<=2; i++) DrawBar(Form.cwidth-PADDING-TSZE+3, i*5+PADDING+7, 15, 3, system.color.work_graph); |
- | |
303 | 305 | for (i=0; i<=2; i++) DrawBar(Form.cwidth-PADDING-TSZE+3, i*5+PADDING+7, 15, 3, system.color.work_graph); |
|
304 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, system.color.work); |
306 | |
305 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, system.color.work_graph); |
307 | DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, system.color.work_graph); |
306 | 308 | ||
307 | DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x, |
309 | DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x, |
308 | WB1.list.h-1, scroll_wv.bckg_col); |
310 | WB1.list.h-1, scroll_wv.bckg_col); |
309 | 311 | ||
310 | if (WB1.list.w!=WB1.DrawBuf.bufw) { |
312 | if (WB1.list.w!=WB1.DrawBuf.bufw) { |
311 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20); |
313 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20); |
312 | if (!strncmp(history.current(),"http",4)) { |
314 | if (!strncmp(history.current(),"http",4)) { |
313 | //nihuya ne izyachnoe reshenie, no pust' poka butet tak |
315 | //nihuya ne izyashnoe reshenie, no pust' poka butet tak |
314 | i=source_mode; |
316 | i=source_mode; |
315 | debugval("source_mode", source_mode); |
- | |
316 | LoadInternalPage(#loading_text, sizeof(loading_text)); |
317 | LoadInternalPage(#loading_text, sizeof(loading_text)); |
317 | source_mode=i; |
318 | source_mode=i; |
318 | debugval("source_mode", source_mode); |
- | |
319 | } |
319 | } |
320 | OpenPage(history.current()); |
320 | OpenPage(history.current()); |
321 | } else { |
321 | } else { |
322 | WB1.DrawPage(); |
322 | WB1.DrawPage(); |
323 | DrawOmnibox(); |
323 | DrawOmnibox(); |
324 | } |
324 | } |
325 | DrawProgress(); |
325 | DrawProgress(); |
- | 326 | DrawStatusBar(NULL); |
|
- | 327 | } |
|
- | 328 | ||
- | 329 | void EventChangeEncodingAndLoadPage(int _new_encoding) |
|
- | 330 | { |
|
- | 331 | dword newbuf, newsize; |
|
- | 332 | WB1.custom_encoding = _new_encoding; |
|
- | 333 | newsize = strlen(WB1.o_bufpointer); |
|
- | 334 | newbuf = malloc(newsize); |
|
- | 335 | memmov(newbuf, WB1.o_bufpointer, newsize); |
|
- | 336 | LoadInternalPage(newbuf, newsize); |
|
- | 337 | free(newbuf); |
|
326 | } |
338 | } |
327 | 339 | ||
328 | 340 | ||
329 | void ProcessEvent(dword id__) |
341 | void ProcessEvent(dword id__) |
330 | { |
342 | { |
331 | switch (id__) |
343 | switch (id__) |
332 | { |
344 | { |
- | 345 | case ENCODINGS...ENCODINGS+6: |
|
- | 346 | EventChangeEncodingAndLoadPage(id__-ENCODINGS); |
|
- | 347 | return; |
|
333 | case NEW_WINDOW: |
348 | case NEW_WINDOW: |
334 | RunProgram(#program_path, NULL); |
349 | RunProgram(#program_path, NULL); |
335 | return; |
350 | return; |
336 | case SCAN_CODE_BS: |
351 | case SCAN_CODE_BS: |
337 | case BACK_BUTTON: |
352 | case BACK_BUTTON: |
338 | if (history.back()) { |
353 | if (history.back()) { |
339 | OpenPage(history.current()); |
354 | OpenPage(history.current()); |
340 | } |
355 | } |
341 | return; |
356 | return; |
342 | case FORWARD_BUTTON: |
357 | case FORWARD_BUTTON: |
343 | if (history.forward()) { |
358 | if (history.forward()) { |
344 | OpenPage(history.current()); |
359 | OpenPage(history.current()); |
345 | } |
360 | } |
346 | return; |
361 | return; |
347 | case GOTOURL_BUTTON: |
362 | case GOTOURL_BUTTON: |
348 | case SCAN_CODE_ENTER: |
363 | case SCAN_CODE_ENTER: |
349 | EventSubmitOmnibox(); |
364 | EventSubmitOmnibox(); |
350 | return; |
365 | return; |
351 | case REFRESH_BUTTON: |
366 | case REFRESH_BUTTON: |
352 | if (http.transfer > 0) { |
367 | if (http.transfer > 0) { |
353 | StopLoading(); |
368 | StopLoading(); |
354 | draw_window(); |
369 | draw_window(); |
355 | } else { |
370 | } else { |
356 | OpenPage(history.current()); |
371 | OpenPage(history.current()); |
357 | } |
372 | } |
358 | return; |
373 | return; |
- | 374 | case CHANGE_ENCODING: |
|
- | 375 | EventShowEncodingsList(Form.cwidth - 150, status_text.start_y-117); |
|
- | 376 | return; |
|
359 | case SANDWICH_BUTTON: |
377 | case SANDWICH_BUTTON: |
360 | EventShowMainMenu(Form.cwidth - 215, TOOLBAR_H-6); |
378 | EventShowMainMenu(Form.cwidth - 215, TOOLBAR_H-6); |
361 | return; |
379 | return; |
362 | case VIEW_SOURCE: |
380 | case VIEW_SOURCE: |
363 | EventViewSource(); |
381 | EventViewSource(); |
364 | break; |
382 | break; |
365 | case EDIT_SOURCE: |
383 | case EDIT_SOURCE: |
366 | if (check_is_the_adress_local(history.current())) { |
384 | if (check_is_the_adress_local(history.current())) { |
367 | RunProgram("/rd/1/tinypad", history.current()); |
385 | RunProgram("/rd/1/tinypad", history.current()); |
368 | } else { |
386 | } else { |
369 | CreateFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm"); |
387 | CreateFile(WB1.bufsize, WB1.bufpointer, "/tmp0/1/WebView_tmp.htm"); |
370 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
388 | if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm"); |
371 | } |
389 | } |
372 | return; |
390 | return; |
373 | case VIEW_HISTORY: |
391 | case VIEW_HISTORY: |
374 | OpenPage(URL_SERVICE_HISTORY); |
392 | OpenPage(URL_SERVICE_HISTORY); |
375 | return; |
393 | return; |
376 | case DOWNLOAD_MANAGER: |
394 | case DOWNLOAD_MANAGER: |
377 | if (!downloader_opened) { |
395 | if (!downloader_opened) { |
378 | downloader_edit = NULL; |
396 | downloader_edit = NULL; |
379 | CreateThread(#Downloader,#downloader_stak+4092); |
397 | CreateThread(#Downloader,#downloader_stak+4092); |
380 | } |
398 | } |
381 | return; |
399 | return; |
382 | case COPY_LINK_URL: |
400 | case COPY_LINK_URL: |
383 | Clipboard__CopyText(PageLinks.GetURL(PageLinks.active)); |
401 | Clipboard__CopyText(PageLinks.GetURL(PageLinks.active)); |
384 | notify("'URL copied to clipboard'O"); |
402 | notify("'URL copied to clipboard'O"); |
385 | return; |
403 | return; |
386 | case DOWNLOAD_LINK_CONTENTS: |
404 | case DOWNLOAD_LINK_CONTENTS: |
387 | if (!downloader_opened) { |
405 | if (!downloader_opened) { |
388 | strcpy(#downloader_edit, PageLinks.GetURL(PageLinks.active)); |
406 | strcpy(#downloader_edit, PageLinks.GetURL(PageLinks.active)); |
389 | CreateThread(#Downloader,#downloader_stak+4092); |
407 | CreateThread(#Downloader,#downloader_stak+4092); |
390 | } |
408 | } |
391 | return; |
409 | return; |
392 | case OPEN_FILE: |
410 | case OPEN_FILE: |
393 | EventOpenDialog(); |
411 | EventOpenDialog(); |
394 | return; |
412 | return; |
395 | case SCAN_CODE_F12: |
413 | case SCAN_CODE_F12: |
396 | debug_mode ^= 1; |
414 | debug_mode ^= 1; |
397 | if (debug_mode) notify("'Debug mode ON'-I"); |
415 | if (debug_mode) notify("'Debug mode ON'-I"); |
398 | else notify("'Debug mode OFF'-I"); |
416 | else notify("'Debug mode OFF'-I"); |
399 | return; |
417 | return; |
400 | } |
418 | } |
401 | } |
419 | } |
402 | 420 | ||
403 | void StopLoading() |
421 | void StopLoading() |
404 | { |
422 | { |
405 | if (http.transfer) |
423 | if (http.transfer) |
406 | { |
424 | { |
407 | EAX = http.transfer; |
425 | EAX = http.transfer; |
408 | EAX = EAX.http_msg.content_ptr; // get pointer to data |
426 | EAX = EAX.http_msg.content_ptr; // get pointer to data |
409 | $push EAX // save it on the stack |
427 | $push EAX // save it on the stack |
410 | http_free stdcall (http.transfer); // abort connection |
428 | http_free stdcall (http.transfer); // abort connection |
411 | $pop EAX |
429 | $pop EAX |
412 | free(EAX); // free data |
430 | free(EAX); // free data |
413 | http.transfer=0; |
431 | http.transfer=0; |
414 | pause(10); |
432 | pause(10); |
415 | } |
433 | } |
416 | wv_progress_bar.value = 0; |
434 | wv_progress_bar.value = 0; |
417 | DrawOmnibox(); |
435 | DrawOmnibox(); |
418 | } |
436 | } |
419 | 437 | ||
420 | //rewrite into |
438 | //rewrite into |
421 | //bool strrpl(dword dst, from, into, dst_len); |
439 | //bool strrpl(dword dst, from, into, dst_len); |
422 | bool ReplaceSpaceInUrl(dword url, size) { |
440 | bool ReplaceSpaceInUrl(dword url, size) { |
423 | unsigned int i, j; |
441 | unsigned int i, j; |
424 | bool was_changed=false; |
442 | bool was_changed=false; |
425 | for (i=url+size-3; i>url; i--) |
443 | for (i=url+size-3; i>url; i--) |
426 | { |
444 | { |
427 | if (ESBYTE[i]!=' ') continue; |
445 | if (ESBYTE[i]!=' ') continue; |
428 | for (j=url+size-3; j>=i; j--) { |
446 | for (j=url+size-3; j>=i; j--) { |
429 | ESBYTE[j+3]=ESBYTE[j+2]; |
447 | ESBYTE[j+3]=ESBYTE[j+2]; |
430 | ESBYTE[j+2]=ESBYTE[j+1]; |
448 | ESBYTE[j+2]=ESBYTE[j+1]; |
431 | ESBYTE[j+1]=ESBYTE[j]; |
449 | ESBYTE[j+1]=ESBYTE[j]; |
432 | } |
450 | } |
433 | ESBYTE[i] = '%'; |
451 | ESBYTE[i] = '%'; |
434 | ESBYTE[i+1] = '2'; |
452 | ESBYTE[i+1] = '2'; |
435 | ESBYTE[i+2] = '0'; |
453 | ESBYTE[i+2] = '0'; |
436 | was_changed = true; |
454 | was_changed = true; |
437 | } |
455 | } |
438 | return was_changed; |
456 | return was_changed; |
439 | } |
457 | } |
440 | 458 | ||
441 | bool GetLocalFileData(dword _path) |
459 | bool GetLocalFileData(dword _path) |
442 | { |
460 | { |
443 | dword data, size; |
461 | dword data, size; |
444 | file_size stdcall (_path); |
462 | file_size stdcall (_path); |
445 | if (!EBX) { |
463 | if (!EBX) { |
446 | return false; |
464 | return false; |
447 | } else { |
465 | } else { |
448 | size = EBX; |
466 | size = EBX; |
449 | data = malloc(size); |
467 | data = malloc(size); |
450 | ReadFile(0, size, data, _path); |
468 | ReadFile(0, size, data, _path); |
451 | LoadInternalPage(data, size); |
469 | LoadInternalPage(data, size); |
452 | free(data); |
470 | free(data); |
453 | return true; |
471 | return true; |
454 | } |
472 | } |
455 | } |
473 | } |
456 | 474 | ||
457 | void OpenPage(dword _open_URL) |
475 | void OpenPage(dword _open_URL) |
458 | { |
476 | { |
459 | char new_url[URL_SIZE+1]; |
477 | char new_url[URL_SIZE+1]; |
460 | 478 | ||
461 | StopLoading(); |
479 | StopLoading(); |
462 | 480 | ||
463 | strcpy(#editURL, _open_URL); |
481 | strcpy(#editURL, _open_URL); |
464 | address_box.flags=0; |
482 | address_box.flags=0; |
465 | DrawOmnibox(); |
483 | DrawOmnibox(); |
466 | 484 | ||
467 | strncpy(#new_url, _open_URL, URL_SIZE); |
485 | strncpy(#new_url, _open_URL, URL_SIZE); |
468 | 486 | ||
469 | //Exclude # from the URL to the load page |
487 | //Exclude # from the URL to the load page |
470 | //We will bring it back when we get the buffer |
488 | //We will bring it back when we get the buffer |
471 | if (strrchr(#new_url, '#')) anchors.take_anchor_from(#new_url); |
489 | if (strrchr(#new_url, '#')) anchors.take_anchor_from(#new_url); |
472 | 490 | ||
473 | history.add(#new_url); |
491 | history.add(#new_url); |
474 | 492 | ||
475 | if (!strncmp(#new_url,"WebView:",8)) { |
493 | if (!strncmp(#new_url,"WebView:",8)) { |
476 | //INTERNAL PAGE |
494 | //INTERNAL PAGE |
477 | if (!strcmp(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage)); |
495 | if (!strcmp(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#homepage, sizeof(homepage)); |
478 | else if (!strcmp(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help)); |
496 | else if (!strcmp(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#help, sizeof(help)); |
479 | else if (!strcmp(#new_url, URL_SERVICE_HISTORY)) ShowHistory(); |
497 | else if (!strcmp(#new_url, URL_SERVICE_HISTORY)) ShowHistory(); |
480 | else LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
498 | else LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
481 | } else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) { |
499 | } else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) { |
482 | //WEB PAGE |
500 | //WEB PAGE |
483 | if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) { |
501 | if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) { |
484 | strcpy(#editURL, #new_url); |
502 | strcpy(#editURL, #new_url); |
485 | } |
503 | } |
486 | 504 | ||
487 | if (!strncmp(#new_url,"http:",5)) { |
505 | if (!strncmp(#new_url,"http:",5)) { |
488 | http.get(#new_url); |
506 | http.get(#new_url); |
489 | } else if (!strncmp(#new_url,"https://",8)) { |
507 | } else if (!strncmp(#new_url,"https://",8)) { |
490 | strcpy(#new_url, "http://gate.aspero.pro/?site="); |
508 | strcpy(#new_url, "http://gate.aspero.pro/?site="); |
491 | strncat(#new_url, _open_URL, URL_SIZE); |
509 | strncat(#new_url, _open_URL, URL_SIZE); |
492 | http.get(#new_url); |
510 | http.get(#new_url); |
493 | } |
511 | } |
494 | 512 | ||
495 | DrawOmnibox(); |
513 | DrawOmnibox(); |
496 | 514 | ||
497 | if (!http.transfer) { |
515 | if (!http.transfer) { |
498 | StopLoading(); |
516 | StopLoading(); |
499 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
517 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
500 | } |
518 | } |
501 | } else { |
519 | } else { |
502 | //LOCAL PAGE |
520 | //LOCAL PAGE |
503 | if (!GetLocalFileData(#new_url)) { |
521 | if (!GetLocalFileData(#new_url)) { |
504 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
522 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
505 | } |
523 | } |
506 | } |
524 | } |
507 | } |
525 | } |
508 | 526 | ||
509 | void EventClickLink(dword _click_URL) |
527 | void EventClickLink(dword _click_URL) |
510 | { |
528 | { |
511 | char new_url[URL_SIZE+1]; |
529 | char new_url[URL_SIZE+1]; |
512 | 530 | ||
513 | if (open_new_window) { |
531 | if (open_new_window) { |
514 | strcpy(#new_url, _click_URL); |
532 | strcpy(#new_url, _click_URL); |
515 | GetAbsoluteURL(#new_url, history.current()); |
533 | GetAbsoluteURL(#new_url, history.current()); |
516 | RunProgram(#program_path, #new_url); |
534 | RunProgram(#program_path, #new_url); |
517 | return; |
535 | return; |
518 | } |
536 | } |
519 | 537 | ||
520 | if (ESBYTE[_click_URL]=='#') { |
538 | if (ESBYTE[_click_URL]=='#') { |
521 | if (anchors.get_pos_by_name(_click_URL+1)!=-1) { |
539 | if (anchors.get_pos_by_name(_click_URL+1)!=-1) { |
522 | WB1.list.first = anchors.get_pos_by_name(_click_URL+1); |
540 | WB1.list.first = anchors.get_pos_by_name(_click_URL+1); |
523 | WB1.list.CheckDoesValuesOkey(); |
541 | WB1.list.CheckDoesValuesOkey(); |
524 | } |
542 | } |
525 | strcpy(#editURL, history.current()); |
543 | strcpy(#editURL, history.current()); |
526 | strcat(#editURL, _click_URL); |
544 | strcat(#editURL, _click_URL); |
527 | DrawOmnibox(); |
545 | DrawOmnibox(); |
528 | WB1.DrawPage(); |
546 | WB1.DrawPage(); |
529 | return; |
547 | return; |
530 | } |
548 | } |
531 | 549 | ||
532 | if (!strncmp(_click_URL,"mailto:", 7)) || (!strncmp(_click_URL,"tel:", 4)) { |
550 | if (!strncmp(_click_URL,"mailto:", 7)) || (!strncmp(_click_URL,"tel:", 4)) { |
533 | notify(_click_URL); |
551 | notify(_click_URL); |
534 | return; |
552 | return; |
535 | } |
553 | } |
536 | 554 | ||
537 | if (http.transfer > 0) { |
555 | if (http.transfer > 0) { |
538 | StopLoading(); |
556 | StopLoading(); |
539 | history.back(); |
557 | history.back(); |
540 | } |
558 | } |
541 | 559 | ||
542 | strcpy(#new_url, _click_URL); |
560 | strcpy(#new_url, _click_URL); |
543 | GetAbsoluteURL(#new_url, history.current()); |
561 | GetAbsoluteURL(#new_url, history.current()); |
544 | 562 | ||
545 | if (strrchr(#new_url, '#')!=0) { |
563 | if (strrchr(#new_url, '#')!=0) { |
546 | anchors.take_anchor_from(#new_url); |
564 | anchors.take_anchor_from(#new_url); |
547 | OpenPage(#new_url); |
565 | OpenPage(#new_url); |
548 | return; |
566 | return; |
549 | } |
567 | } |
550 | 568 | ||
551 | if (!strncmp(#new_url,"WebView:",8)) { |
569 | if (!strncmp(#new_url,"WebView:",8)) { |
552 | OpenPage(#new_url); |
570 | OpenPage(#new_url); |
553 | return; |
571 | return; |
554 | } |
572 | } |
555 | 573 | ||
556 | if (strncmp(#new_url,"http://",7)!=0) && (strncmp(#new_url,"https://",8)!=0) |
574 | if (strncmp(#new_url,"http://",7)!=0) && (strncmp(#new_url,"https://",8)!=0) |
557 | { |
575 | { |
558 | if (UrlExtIs(#new_url,".htm")!=true) && (UrlExtIs(#new_url,".html")!=true) |
576 | if (UrlExtIs(#new_url,".htm")!=true) && (UrlExtIs(#new_url,".html")!=true) |
559 | { |
577 | { |
560 | if (strchr(#new_url, '|')) { |
578 | if (strchr(#new_url, '|')) { |
561 | ESBYTE[strchr(#new_url, '|')] = NULL; |
579 | ESBYTE[strchr(#new_url, '|')] = NULL; |
562 | RunProgram(#new_url, strlen(#new_url)+1+#new_url); |
580 | RunProgram(#new_url, strlen(#new_url)+1+#new_url); |
563 | } else { |
581 | } else { |
564 | RunProgram("/sys/@open", #new_url); |
582 | RunProgram("/sys/@open", #new_url); |
565 | } |
583 | } |
566 | return; |
584 | return; |
567 | } |
585 | } |
568 | } else { |
586 | } else { |
569 | if (UrlExtIs(#new_url,".png")==true) || (UrlExtIs(#new_url,".jpg")==true) |
587 | if (UrlExtIs(#new_url,".png")==true) || (UrlExtIs(#new_url,".jpg")==true) |
570 | || (UrlExtIs(#new_url,".zip")==true) || (UrlExtIs(#new_url,".kex")==true) || (UrlExtIs(#new_url,".pdf")==true) |
588 | || (UrlExtIs(#new_url,".zip")==true) || (UrlExtIs(#new_url,".kex")==true) || (UrlExtIs(#new_url,".pdf")==true) |
571 | || (UrlExtIs(#new_url,".7z")==true) { |
589 | || (UrlExtIs(#new_url,".7z")==true) { |
572 | if (!downloader_opened) { |
590 | if (!downloader_opened) { |
573 | strcpy(#downloader_edit, #new_url); |
591 | strcpy(#downloader_edit, #new_url); |
574 | CreateThread(#Downloader,#downloader_stak+4092); |
592 | CreateThread(#Downloader,#downloader_stak+4092); |
575 | } |
593 | } |
576 | else notify("'WebView\nPlease, start a new download only when previous ended.'Et"); |
594 | else notify("'WebView\nPlease, start a new download only when previous ended.'Et"); |
577 | return; |
595 | return; |
578 | } |
596 | } |
579 | } |
597 | } |
580 | OpenPage(#new_url); |
598 | OpenPage(#new_url); |
581 | } |
599 | } |
582 | 600 | ||
583 | void EventSubmitOmnibox() |
601 | void EventSubmitOmnibox() |
584 | { |
602 | { |
585 | char new_url[URL_SIZE+1]; |
603 | char new_url[URL_SIZE+1]; |
586 | if (!editURL[0]) return; |
604 | if (!editURL[0]) return; |
587 | if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') |
605 | if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/') |
588 | || (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) { |
606 | || (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) { |
589 | OpenPage(#editURL); |
607 | OpenPage(#editURL); |
590 | } else { |
608 | } else { |
591 | strcpy(#new_url, "http://"); |
609 | strcpy(#new_url, "http://"); |
592 | strncat(#new_url, #editURL, sizeof(new_url)-1); |
610 | strncat(#new_url, #editURL, sizeof(new_url)-1); |
593 | OpenPage(#new_url); |
611 | OpenPage(#new_url); |
594 | } |
612 | } |
595 | } |
613 | } |
596 | 614 | ||
597 | void LoadInternalPage(dword _bufdata, _in_bufsize){ |
615 | void LoadInternalPage(dword _bufdata, _in_bufsize){ |
598 | if (!_bufdata) || (!_in_bufsize) { |
616 | if (!_bufdata) || (!_in_bufsize) { |
599 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
617 | LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
600 | } else { |
618 | } else { |
601 | bufsize = _in_bufsize; |
- | |
602 | if (bufpointer!=_bufdata) free(bufpointer); |
- | |
603 | bufpointer = malloc(bufsize); |
- | |
604 | memmov(bufpointer, _bufdata, bufsize); |
- | |
605 | WB1.list.first = 0; //scroll page to the top |
619 | WB1.list.first = 0; //scroll page to the top |
606 | DrawOmnibox(); |
620 | DrawOmnibox(); |
607 | if(!strrchr(#editURL, '#')) { |
621 | if(!strrchr(#editURL, '#')) { |
608 | strcat(#editURL, #anchors.current); |
622 | strcat(#editURL, #anchors.current); |
609 | DrawOmnibox(); |
623 | DrawOmnibox(); |
610 | } |
624 | } |
611 | WB1.ParseHtml(); |
625 | WB1.ParseHtml(_bufdata, _in_bufsize); |
- | 626 | DrawStatusBar(NULL); |
|
612 | if (source_mode) { |
627 | if (source_mode) { |
613 | source_mode = false; |
628 | source_mode = false; |
614 | ShowSource(bufpointer, bufsize); |
629 | ShowSource(WB1.bufpointer, _in_bufsize); |
615 | } else { |
630 | } else { |
616 | WB1.DrawPage(); |
631 | WB1.DrawPage(); |
617 | } |
632 | } |
618 | } |
633 | } |
619 | } |
634 | } |
620 | 635 | ||
621 | byte UrlExtIs(dword base, ext) |
636 | byte UrlExtIs(dword base, ext) |
622 | { |
637 | { |
623 | if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true; |
638 | if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true; |
624 | return false; |
639 | return false; |
625 | } |
640 | } |
626 | 641 | ||
627 | void DrawProgress() |
642 | void DrawProgress() |
628 | { |
643 | { |
629 | dword persent; |
644 | dword persent; |
630 | if (http.transfer == 0) return; |
645 | if (http.transfer == 0) return; |
631 | if (wv_progress_bar.max) { |
646 | if (wv_progress_bar.max) { |
632 | persent = wv_progress_bar.value*100/wv_progress_bar.max; |
647 | persent = wv_progress_bar.value*100/wv_progress_bar.max; |
633 | } else { |
648 | } else { |
634 | persent = 10; |
649 | persent = 10; |
635 | } |
650 | } |
636 | DrawBar(address_box.left-1, address_box.top+20, persent*address_box.width+16/100, 2, 0x72B7EB); |
651 | DrawBar(address_box.left-1, address_box.top+20, persent*address_box.width+16/100, 2, 0x72B7EB); |
637 | } |
652 | } |
638 | 653 | ||
639 | void EventShowPageMenu(dword _left, _top) |
654 | void EventShowPageMenu(dword _left, _top) |
640 | { |
655 | { |
- | 656 | menu.selected = 0; |
|
641 | menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE); |
657 | menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE); |
642 | } |
658 | } |
- | 659 | ||
- | 660 | void EventShowEncodingsList(dword _left, _top) |
|
- | 661 | { |
|
- | 662 | menu.selected = WB1.cur_encoding + 1; |
|
- | 663 | menu.show(Form.left+_left-6+77,Form.top+_top+skin_height-3, 100, |
|
- | 664 | "UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", ENCODINGS); |
|
- | 665 | } |
|
643 | 666 | ||
644 | void EventShowMainMenu(dword _left, _top) |
667 | void EventShowMainMenu(dword _left, _top) |
- | 668 | { |
|
645 | { |
669 | menu.selected = 0; |
646 | menu.show(Form.left+_left-6+77,Form.top+_top+skin_height-3, 140, #main_menu, OPEN_FILE); |
670 | menu.show(Form.left+_left-6+77,Form.top+_top+skin_height-3, 140, #main_menu, OPEN_FILE); |
647 | } |
671 | } |
648 | 672 | ||
649 | void EventShowLinkMenu(dword _left, _top) |
673 | void EventShowLinkMenu(dword _left, _top) |
650 | { |
674 | { |
- | 675 | menu.selected = 0; |
|
651 | menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK_URL); |
676 | menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #link_menu, COPY_LINK_URL); |
652 | } |
677 | } |
653 | 678 | ||
654 | void EventUpdateProgressBar() |
679 | void EventUpdateProgressBar() |
655 | { |
680 | { |
656 | wv_progress_bar.max = http.content_length; |
681 | wv_progress_bar.max = http.content_length; |
657 | if (wv_progress_bar.value != http.content_received) |
682 | if (wv_progress_bar.value != http.content_received) |
658 | { |
683 | { |
659 | wv_progress_bar.value = http.content_received; |
684 | wv_progress_bar.value = http.content_received; |
660 | DrawProgress(); |
685 | DrawProgress(); |
661 | } |
686 | } |
662 | } |
687 | } |
663 | 688 | ||
664 | void EventSeachWeb() |
689 | void EventSeachWeb() |
665 | { |
690 | { |
666 | char new_url[URL_SIZE+1]; |
691 | char new_url[URL_SIZE+1]; |
667 | replace_char(#editURL, ' ', '_', URL_SIZE); |
692 | replace_char(#editURL, ' ', '_', URL_SIZE); |
668 | strcpy(#new_url, "https://www.google.com/search?q="); |
693 | strcpy(#new_url, "https://www.google.com/search?q="); |
669 | strncat(#new_url, #editURL, URL_SIZE); |
694 | strncat(#new_url, #editURL, URL_SIZE); |
670 | OpenPage(#new_url); |
695 | OpenPage(#new_url); |
671 | } |
696 | } |
672 | 697 | ||
673 | void EventOpenDialog() |
698 | void EventOpenDialog() |
674 | { |
699 | { |
675 | OpenDialog_start stdcall (#o_dialog); |
700 | OpenDialog_start stdcall (#o_dialog); |
676 | if (o_dialog.status) { |
701 | if (o_dialog.status) { |
677 | OpenPage(#openfile_path); |
702 | OpenPage(#openfile_path); |
678 | } |
703 | } |
679 | } |
704 | } |
680 | 705 | ||
681 | void EventViewSource() |
706 | void EventViewSource() |
682 | { |
707 | { |
683 | char source_view_param[URL_SIZE+1]; |
708 | char source_view_param[URL_SIZE+1]; |
684 | strcpy(#source_view_param, "-s "); |
709 | strcpy(#source_view_param, "-s "); |
685 | strncat(#source_view_param, history.current(), URL_SIZE); |
710 | strncat(#source_view_param, history.current(), URL_SIZE); |
686 | RunProgram(#program_path, #source_view_param); |
711 | RunProgram(#program_path, #source_view_param); |
687 | } |
712 | } |
688 | 713 | ||
689 | void DrawStatusBar(dword _status_text) |
714 | void DrawStatusBar(dword _status_text) |
690 | { |
715 | { |
- | 716 | status_text.font_color = system.color.work_text; |
|
691 | status_text.start_x = 10; |
717 | status_text.start_x = 10; |
692 | status_text.start_y = Form.cheight - STATUSBAR_H + 3; |
718 | status_text.start_y = Form.cheight - STATUSBAR_H + 4; |
693 | status_text.area_size_x = Form.cwidth - status_text.start_x -3; |
719 | status_text.area_size_x = Form.cwidth - status_text.start_x -3 - 70; |
694 | DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, system.color.work); |
720 | //DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, system.color.work); |
- | 721 | DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, system.color.work); |
|
- | 722 | if (_status_text) { |
|
695 | status_text.text_pointer = _status_text; |
723 | status_text.text_pointer = _status_text; |
696 | PathShow_prepare stdcall(#status_text); |
724 | PathShow_prepare stdcall(#status_text); |
697 | PathShow_draw stdcall(#status_text); |
725 | PathShow_draw stdcall(#status_text); |
698 | } |
726 | } |
699 | - | ||
700 | - | ||
701 | void DrawOvalBorder(dword x,y,w,h, light,dark,right,dots) |
- | |
702 | { |
- | |
703 | DrawBar(x+1, y, w, 1, light); |
- | |
704 | DrawBar(x+1, y+h+1, w, 1, dark); |
- | |
705 | DrawBar(x, y+1, 1, h-1, light); |
- | |
706 | DrawBar(x+w+1, y+2, 1, h-2, right); |
- | |
707 | - | ||
708 | PutPixel(x, y, dots); |
- | |
709 | PutPixel(x+w+1, y+h+1, dots); |
- | |
710 | PutPixel(x, y+h+1, dots); |
- | |
711 | PutPixel(x+w+1, y, dots); |
- | |
712 | - | ||
713 | PutPixel(x, y+h, dark); |
- | |
714 | PutPixel(x+w+1, y+1, light); |
- | |
715 | PutPixel(x+w+1, y+h, dark); |
- | |
716 | } |
- | |
717 | - | ||
718 | libimg_image top_icons; |
- | |
719 | libimg_image left_icons; |
- | |
720 | - | ||
721 | void DrawTopPanelButton(dword _button_id, _x, signed int _icon_n) |
727 | DefineHiddenButton(status_text.start_x+status_text.area_size_x+10, status_text.start_y-3, |
722 | { |
- | |
723 | static dword semi_white=0, bg_col, bg_col_light, bg_col_dark, bg_dark; |
- | |
724 | if (!semi_white) { |
- | |
725 | bg_col = system.color.work; |
728 | 60, 12, CHANGE_ENCODING); |
726 | if (GrayScaleImage(#bg_col,1,1)<65) bg_dark=true; else bg_dark=false; |
- | |
727 | Libimg_LoadImage(#top_icons, "/sys/icons16.png"); |
- | |
728 | Libimg_LoadImage(#left_icons, "/sys/icons16.png"); |
- | |
729 | - | ||
730 | semi_white = MixColors(system.color.work, 0xFFFfff, bg_dark*90 + 96); |
729 | WriteTextCenter(status_text.start_x+status_text.area_size_x+10, |
731 | bg_col_dark = MixColors(system.color.work, system.color.work_graph, 90); |
730 | status_text.start_y, 60, system.color.work_text, WB1.cur_encoding*10+#charsets); |
732 | bg_col_light = MixColors(semi_white, 0xFFFfff, bg_dark*90 + 10); |
- | |
733 | - | ||
734 | Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffFFFfff, semi_white); |
- | |
735 | Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffCACBD6, MixColors(semi_white, 0, 220)); |
- | |
736 | - | ||
737 | Libimg_ReplaceColor(left_icons.image, left_icons.w, left_icons.h, 0xffFFFfff, system.color.work); |
- | |
738 | Libimg_ReplaceColor(left_icons.image, left_icons.w, left_icons.h, 0xffCACBD6, MixColors(system.color.work, 0, 200)); |
- | |
739 | } |
- | |
740 | - | ||
741 | DrawWideRectangle(_x+1, PADDING+1, TSZE, TSZE, 5, semi_white); |
- | |
742 | DrawOvalBorder(_x, PADDING, TSZE, TSZE, bg_col_light, bg_col_dark, semi_white, system.color.work); |
- | |
743 | - | ||
744 | DefineHiddenButton(_x, PADDING, TSZE+1, TSZE+1, _button_id); |
- | |
745 | if (_icon_n==-1) { |
- | |
746 | DrawBar(_x+6, PADDING+5, 16, 16, semi_white); |
- | |
747 | } else { |
- | |
748 | img_draw stdcall(top_icons.image, _x+6, PADDING+5, 16, 16, 0, _icon_n*16); |
- | |
749 | } |
- | |
750 | } |
731 | } |
751 | 732 | ||
752 | void DrawOmnibox() |
733 | void DrawOmnibox() |
753 | { |
734 | { |
754 | int skin_x_offset; |
735 | int skin_x_offset; |
755 | 736 | ||
- | 737 | DrawOvalBorder(address_box.left-2, address_box.top-3, address_box.width+18, 24, system.color.work_graph, |
|
756 | DrawOvalBorder(address_box.left-2, address_box.top-3, address_box.width+18, 24, system.color.work_graph, system.color.work_graph, system.color.work_graph, system.color.work_dark); |
738 | system.color.work_graph, system.color.work_graph, system.color.work_dark); |
757 | DrawBar(address_box.left-1, address_box.top-2, address_box.width+18, 1, 0xD8DCD8); |
739 | DrawBar(address_box.left-1, address_box.top-2, address_box.width+18, 1, 0xD8DCD8); |
758 | DrawBar(address_box.left-1, address_box.top-1, address_box.width+18, 1, address_box.color); |
740 | DrawBar(address_box.left-1, address_box.top-1, address_box.width+18, 1, address_box.color); |
759 | DrawBar(address_box.left-1, address_box.top, 1, 22, address_box.color); |
741 | DrawBar(address_box.left-1, address_box.top, 1, 22, address_box.color); |
760 | 742 | ||
761 | if (address_box.flags & ed_focus) address_box.flags = ed_focus; else address_box.flags = 0; |
743 | if (address_box.flags & ed_focus) address_box.flags = ed_focus; else address_box.flags = 0; |
762 | EditBox_UpdateText(#address_box, address_box.flags); |
744 | EditBox_UpdateText(#address_box, address_box.flags); |
763 | edit_box_draw stdcall(#address_box); |
745 | edit_box_draw stdcall(#address_box); |
764 | if (http.transfer > 0) skin_x_offset = 85; else skin_x_offset = 68; |
746 | if (http.transfer > 0) skin_x_offset = 85; else skin_x_offset = 68; |
765 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, |
747 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, |
766 | address_box.top-1, 16, skin.h-3, skin_x_offset, SKIN_Y+2); |
748 | address_box.top-1, 16, skin.h-3, skin_x_offset, SKIN_Y+2); |
767 | DefineHiddenButton(address_box.left+address_box.width-1, address_box.top-2, 17, skin.h-3, REFRESH_BUTTON); |
749 | DefineHiddenButton(address_box.left+address_box.width-1, address_box.top-2, 17, skin.h-3, REFRESH_BUTTON); |
768 | 750 | ||
769 | DrawProgress(); |
751 | DrawProgress(); |
770 | } |
752 | } |
771 | 753 | ||
772 | 754 | ||
773 | stop:65)>=2;>=5)>>=>280)>120)> |
755 | stop:=2;>=5)>>=>280)>120)> |