Rev 5710 | Rev 5712 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5710 | Rev 5711 | ||
---|---|---|---|
Line 86... | Line 86... | ||
86 | 86 | ||
87 | #define URL_SERVICE_HISTORY "WebView://history" |
87 | #define URL_SERVICE_HISTORY "WebView://history" |
88 | #define URL_SERVICE_HOME "WebView://home" |
88 | #define URL_SERVICE_HOME "WebView://home" |
Line 89... | Line 89... | ||
89 | #define URL_SERVICE_SOURCE "WebView://source:" |
89 | #define URL_SERVICE_SOURCE "WebView://source:" |
Line 90... | Line 90... | ||
90 | 90 | ||
Line 91... | Line 91... | ||
91 | enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN }; |
91 | enum { BUTTON_BACK=1000, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT }; |
92 | 92 | ||
Line 117... | Line 117... | ||
117 | } |
117 | } |
Line 118... | Line 118... | ||
118 | 118 | ||
119 | 119 | ||
120 | void main() |
120 | void main() |
121 | { |
121 | { |
122 | unsigned long key, btn; |
122 | dword btn; |
Line 123... | Line 123... | ||
123 | int half_scroll_size; |
123 | int half_scroll_size; |
124 | int scroll_used=0, show_menu; |
124 | int scroll_used=0, show_menu; |
Line 131... | Line 131... | ||
131 | load_dll(iconv_lib, #iconv_open,0); |
131 | load_dll(iconv_lib, #iconv_open,0); |
132 | Libimg_LoadImage(#skin, abspath("wv_skin.png")); |
132 | Libimg_LoadImage(#skin, abspath("wv_skin.png")); |
133 | SetSkinColors(); |
133 | SetSkinColors(); |
Line 134... | Line 134... | ||
134 | 134 | ||
- | 135 | WB1.DrawBuf.zoom = 1; |
|
135 | WB1.DrawBuf.zoom = 1; |
136 | WB1.list.SetFont(6, 9, 10001000b); |
136 | Form.width=WIN_W; |
137 | Form.width=WIN_W; |
137 | Form.height=WIN_H; |
138 | Form.height=WIN_H; |
138 | SetElementSizes(); |
139 | SetElementSizes(); |
139 | if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME); |
140 | if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME); |
Line 186... | Line 187... | ||
186 | WB1.list.first = mouse.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h; |
187 | WB1.list.first = mouse.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h; |
187 | if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible; |
188 | if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible; |
188 | if (btn!=WB1.list.first) WB1.Parse(); |
189 | if (btn!=WB1.list.first) WB1.Parse(); |
189 | } |
190 | } |
190 | break; |
191 | break; |
- | 192 | ||
191 | case evButton: |
193 | case evButton: |
192 | btn=GetButtonID(); |
194 | btn=GetButtonID(); |
193 | if (btn==1) ExitProcess(); |
195 | if (btn==1) ExitProcess(); |
194 | Scan(btn); |
196 | Scan(btn); |
195 | break; |
197 | break; |
- | 198 | ||
196 | case evKey: |
199 | case evKey: |
197 | key = GetKey(); |
200 | GetKeys(); |
198 | if (address_box.flags & 0b10) |
201 | if (address_box.flags & 0b10) |
199 | { |
202 | { |
200 | if (key==ASCII_KEY_ENTER) Scan(key); else |
203 | if (key_ascii == ASCII_KEY_ENTER) Scan(key_scancode); else |
201 | if (key!=0x0d) && (key!=183) && (key!=184) {EAX=key<<8; edit_box_key stdcall(#address_box);} |
204 | if (key_ascii != 0x0d) && (key_ascii != 183) && (key_ascii != 184) {EAX = key_ascii << 8; edit_box_key stdcall(#address_box);} |
- | 205 | } |
|
- | 206 | else |
|
- | 207 | { |
|
- | 208 | Scan(key_scancode); |
|
202 | } |
209 | } |
203 | else Scan(key); |
- | |
204 | break; |
210 | break; |
Line 205... | Line 211... | ||
205 | 211 | ||
206 | case evReDraw: |
212 | case evReDraw: |
207 | if (action_buf) Scan(action_buf); |
213 | if (action_buf) Scan(action_buf); |
Line 283... | Line 289... | ||
283 | void SetElementSizes() |
289 | void SetElementSizes() |
284 | { |
290 | { |
285 | address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H; |
291 | address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H; |
286 | address_box.width = Form.cwidth - address_box.left - 25 - 22; |
292 | address_box.width = Form.cwidth - address_box.left - 25 - 22; |
287 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom, |
293 | WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom, |
288 | Form.cheight - TOOLBAR_H - STATUSBAR_H, 11*WB1.DrawBuf.zoom); |
294 | Form.cheight - TOOLBAR_H - STATUSBAR_H, WB1.list.font_h + WB1.DrawBuf.zoom + WB1.DrawBuf.zoom * WB1.DrawBuf.zoom); |
289 | WB1.list.SetFont(6, 9, 0x88); |
- | |
290 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; |
295 | WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; |
291 | WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h; |
296 | WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h; |
292 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h); |
297 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h); |
293 | } |
298 | } |
Line 312... | Line 317... | ||
312 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
317 | DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, border_color); |
313 | SetElementSizes(); |
318 | SetElementSizes(); |
314 | DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color); |
319 | DrawRectangle(address_box.left-1, address_box.top-1, address_box.width+2, 16,address_box.color); |
315 | DrawRectangle(address_box.left-2, address_box.top-2, address_box.width+4, 18,border_color); |
320 | DrawRectangle(address_box.left-2, address_box.top-2, address_box.width+4, 18,border_color); |
316 | // < / > |
321 | // < / > |
317 | DefineButton(address_box.left-49, address_box.top-1, 23, skin.h-2, 300+BT_HIDE, 0); |
322 | DefineButton(address_box.left-49, address_box.top-1, 23, skin.h-2, BUTTON_BACK+BT_HIDE, 0); |
318 | DefineButton(address_box.left-25, address_box.top-1, 23, skin.h-2, 301+BT_HIDE, 0); |
323 | DefineButton(address_box.left-25, address_box.top-1, 23, skin.h-2, FORWARD+BT_HIDE, 0); |
319 | img_draw stdcall(skin.image, address_box.left-50, address_box.top-2, 48, skin.h, 3, 0); |
324 | img_draw stdcall(skin.image, address_box.left-50, address_box.top-2, 48, skin.h, 3, 0); |
320 | // refrash |
325 | // refrash |
321 | DefineButton(address_box.left+address_box.width+1, address_box.top-2, 16, skin.h-1, REFRESH+BT_HIDE+BT_NOFRAME, 0); |
326 | DefineButton(address_box.left+address_box.width+1, address_box.top-2, 16, skin.h-1, REFRESH+BT_HIDE+BT_NOFRAME, 0); |
322 | if (http_transfer > 0) img_off = 131; else img_off = 52; |
327 | if (http_transfer > 0) img_off = 131; else img_off = 52; |
323 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, img_off, 0); |
328 | img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, img_off, 0); |
Line 332... | Line 337... | ||
332 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
337 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
333 | DrawProgress(); |
338 | DrawProgress(); |
334 | } |
339 | } |
Line 335... | Line 340... | ||
335 | 340 | ||
336 | 341 | ||
337 | void Scan(int id) |
342 | void Scan(dword id__) |
338 | { |
343 | { |
339 | action_buf=0; |
344 | action_buf=0; |
340 | if (id >= 400) |
345 | if (id__ >= 400) |
341 | { |
346 | { |
342 | ProcessLinks(id); |
347 | ProcessLinks(id__); |
343 | return; |
348 | return; |
344 | } |
349 | } |
- | 350 | switch (id__) |
|
- | 351 | { |
|
- | 352 | case SCAN_CODE_BS: |
|
- | 353 | case BUTTON_BACK: |
|
- | 354 | if (!BrowserHistory.GoBack()) return; |
|
- | 355 | OpenPage(); |
|
- | 356 | return; |
|
- | 357 | ||
- | 358 | case FORWARD: |
|
- | 359 | if (!BrowserHistory.GoForward()) return; |
|
- | 360 | OpenPage(); |
|
- | 361 | return; |
|
- | 362 | ||
- | 363 | case SCAN_CODE_HOME: |
|
- | 364 | case SCAN_CODE_END: |
|
- | 365 | case SCAN_CODE_PGUP: |
|
- | 366 | case SCAN_CODE_PGDN: |
|
- | 367 | if (WB1.list.ProcessKey(key_scancode)) WB1.Parse(); |
|
- | 368 | return; |
|
- | 369 | ||
- | 370 | case SCAN_CODE_UP: |
|
- | 371 | if (WB1.list.first <= 0) return; |
|
- | 372 | WB1.list.first--; |
|
- | 373 | WB1.Parse(); |
|
- | 374 | return; |
|
- | 375 | ||
- | 376 | case SCAN_CODE_DOWN: |
|
- | 377 | if (WB1.list.visible + WB1.list.first >= WB1.list.count) return; |
|
- | 378 | WB1.list.first++; |
|
- | 379 | WB1.Parse(); |
|
- | 380 | return; |
|
- | 381 | ||
- | 382 | case 44: //Z-key down |
|
- | 383 | if (WB1.DrawBuf.zoom==2) |
|
- | 384 | { |
|
- | 385 | WB1.DrawBuf.zoom=1; |
|
- | 386 | WB1.list.SetFont(6, 9, 10001000b); |
|
- | 387 | } |
|
- | 388 | else |
|
- | 389 | { |
|
- | 390 | WB1.DrawBuf.zoom=2; |
|
- | 391 | WB1.list.SetFont(6, 9, 10001001b); |
|
- | 392 | } |
|
- | 393 | Draw_Window(); |
|
- | 394 | return; |
|
- | 395 | ||
- | 396 | case GOTOURL: |
|
- | 397 | case SCAN_CODE_ENTER: //enter |
|
- | 398 | if (!editURL[0]) return; |
|
- | 399 | if (strncmp(#editURL,"http:",5)) && (editURL[0]!='/') && (strncmp(#editURL,"WebView:",9)) strncpy(#URL,"http://",7); |
|
- | 400 | else |
|
- | 401 | URL[0] = 0; |
|
- | 402 | strcat(#URL, #editURL); |
|
- | 403 | OpenPage(); |
|
- | 404 | return; |
|
345 | switch (id) |
405 | |
346 | { |
406 | /* |
347 | case 011: //Ctrk+K |
407 | case 011: //Ctrk+K |
348 | BufEncode(CH_KOI8); |
408 | BufEncode(CH_KOI8); |
349 | WB1.Parse(); |
409 | WB1.Parse(); |
Line 373... | Line 433... | ||
373 | if (!downloader_opened) { |
433 | if (!downloader_opened) { |
374 | strncpy(#DL_URL, "http://",7); |
434 | strncpy(#DL_URL, "http://",7); |
375 | CreateThread(#Downloader,#downloader_stak+4092); |
435 | CreateThread(#Downloader,#downloader_stak+4092); |
376 | } |
436 | } |
377 | return; |
437 | return; |
378 | case ASCII_KEY_BS: |
- | |
379 | case BACK: |
- | |
380 | if (!BrowserHistory.GoBack()) return; |
- | |
381 | OpenPage(); |
- | |
382 | return; |
- | |
383 | case FORWARD: |
- | |
384 | if (!BrowserHistory.GoForward()) return; |
- | |
385 | OpenPage(); |
- | |
386 | return; |
438 | |
387 | case 052: //F3 |
439 | case 052: //F3 |
388 | WB1.list.first = 0; |
440 | WB1.list.first = 0; |
389 | ShowSource(); |
441 | ShowSource(); |
390 | WB1.Parse(); |
442 | WB1.Parse(); |
391 | break; |
443 | break; |
Line 405... | Line 457... | ||
405 | StopLoading(); |
457 | StopLoading(); |
406 | Draw_Window(); |
458 | Draw_Window(); |
407 | } |
459 | } |
408 | else OpenPage(); |
460 | else OpenPage(); |
409 | return; |
461 | return; |
410 | case 014: |
- | |
411 | case 020: |
462 | case 020: |
412 | case NEWTAB: |
463 | case NEWTAB: |
413 | MoveSize(190,80,OLD,OLD); |
464 | MoveSize(190,80,OLD,OLD); |
414 | RunProgram(#program_path, #URL); |
465 | RunProgram(#program_path, #URL); |
415 | return; |
466 | return; |
416 | case GOTOURL: |
- | |
417 | case 0x0D: //enter |
- | |
418 | if (!editURL[0]) return; |
- | |
419 | if (strncmp(#editURL,"http:",5)) && (editURL[0]!='/') && (strncmp(#editURL,"WebView:",9)) strncpy(#URL,"http://",7); |
- | |
420 | else |
467 | |
421 | URL[0] = 0; |
- | |
422 | strcat(#URL, #editURL); |
- | |
423 | OpenPage(); |
- | |
424 | return; |
- | |
425 | case SEARCHWEB: |
468 | case SEARCHWEB: |
426 | sprintf(#URL,"%s%s",#search_path,#editURL); |
469 | sprintf(#URL,"%s%s",#search_path,#editURL); |
427 | OpenPage(); |
470 | OpenPage(); |
428 | return; |
471 | return; |
Line 429... | Line -... | ||
429 | - | ||
430 | case 183: //PgDown |
- | |
431 | if (WB1.list.count < WB1.list.visible) return; |
- | |
432 | IF(WB1.list.first == WB1.list.count - WB1.list.visible) return; |
- | |
433 | WB1.list.first += WB1.list.visible + 2; |
- | |
434 | IF(WB1.list.visible + WB1.list.first > WB1.list.count) WB1.list.first = WB1.list.count - WB1.list.visible; |
- | |
435 | WB1.Parse(); |
- | |
436 | return; |
- | |
437 | - | ||
438 | case 184: //PgUp |
- | |
439 | if (WB1.list.count < WB1.list.visible) return; |
- | |
440 | IF(WB1.list.first == 0) return; |
- | |
441 | WB1.list.first -= WB1.list.visible - 2; |
- | |
442 | IF(WB1.list.first < 0) WB1.list.first = 0; |
- | |
443 | WB1.Parse(); |
- | |
444 | return; |
- | |
445 | - | ||
446 | case 178: |
- | |
447 | case BTN_UP: |
- | |
448 | if (WB1.list.first <= 0) return; |
- | |
449 | WB1.list.first--; |
- | |
450 | WB1.Parse(); |
- | |
451 | return; |
- | |
452 | - | ||
453 | case 177: |
- | |
454 | case BTN_DOWN: |
- | |
455 | if (WB1.list.visible + WB1.list.first >= WB1.list.count) return; |
- | |
456 | WB1.list.first++; |
- | |
457 | WB1.Parse(); |
- | |
458 | return; |
- | |
459 | - | ||
460 | case 180: //home |
- | |
461 | if (WB1.list.KeyHome()) WB1.Parse(); |
- | |
462 | return; |
- | |
463 | - | ||
464 | case 181: //end |
- | |
465 | if (WB1.list.count < WB1.list.visible) return; |
- | |
466 | if (WB1.list.KeyEnd()) WB1.Parse(); |
- | |
467 | return; |
472 | |
468 | case 312: |
473 | case 312: |
469 | SwitchToAnotherThread(); |
474 | SwitchToAnotherThread(); |
470 | mouse.y = TOOLBAR_H-6; |
475 | mouse.y = TOOLBAR_H-6; |
471 | mouse.x = Form.cwidth - 167; |
476 | mouse.x = Form.cwidth - 167; |
472 | CreateThread(#menu_rmb,#stak+4092); |
477 | CreateThread(#menu_rmb,#stak+4092); |
473 | return; |
478 | return; |
474 | case 122: |
- | |
475 | if (WB1.DrawBuf.zoom==1) WB1.DrawBuf.zoom=2; else WB1.DrawBuf.zoom=1; |
- | |
476 | Draw_Window(); |
479 | */ |
477 | } |
480 | } |