Rev 5978 | Rev 5982 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3067 | leency | 1 | //HTML Viewer in C-- |
3987 | leency | 2 | //Copyright 2007-2013 by Veliant & Leency |
3107 | leency | 3 | //Asper, lev, Lrz, Barsuk, Nable... |
3067 | leency | 4 | //home icon - rachel fu, GPL licence |
5 | |||
4085 | leency | 6 | #ifndef AUTOBUILD |
7 | #include "lang.h--" |
||
8 | #endif |
||
9 | |||
3107 | leency | 10 | //libraries |
5981 | leency | 11 | #define MEMSIZE 1060000 |
5499 | leency | 12 | #include "..\lib\gui.h" |
4508 | leency | 13 | #include "..\lib\draw_buf.h" |
14 | #include "..\lib\list_box.h" |
||
15 | #include "..\lib\cursor.h" |
||
5978 | leency | 16 | #include "..\lib\collection.h" |
5981 | leency | 17 | #include "..\lib\font.h" |
18 | |||
3107 | leency | 19 | //*.obj libraries |
5499 | leency | 20 | #include "..\lib\obj\box_lib.h" |
21 | #include "..\lib\obj\libio_lib.h" |
||
22 | #include "..\lib\obj\libimg_lib.h" |
||
23 | #include "..\lib\obj\http.h" |
||
5690 | leency | 24 | #include "..\lib\obj\iconv.h" |
5408 | leency | 25 | //useful patterns |
26 | #include "..\lib\patterns\libimg_load_skin.h" |
||
5978 | leency | 27 | #include "..\lib\patterns\history.h" |
5408 | leency | 28 | |
5493 | leency | 29 | char homepage[] = FROM "html\\homepage.htm"; |
4677 | leency | 30 | |
4026 | leency | 31 | #ifdef LANG_RUS |
5811 | leency | 32 | char version[]=" Текстовый браузер 1.40"; |
4416 | leency | 33 | ?define IMAGES_CACHE_CLEARED "Кэш картинок очищен" |
4417 | leency | 34 | ?define T_LAST_SLIDE "Это последний слайд" |
4550 | leency | 35 | char loading[] = "Загрузка страницы... |
4677 | leency | 36 | char page_not_found[] = FROM "html\page_not_found_ru.htm"; |
4649 | leency | 37 | char accept_language[]= "Accept-Language: ru\n"; |
4026 | leency | 38 | #else |
5811 | leency | 39 | char version[]=" Text-based Browser 1.40"; |
4026 | leency | 40 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
4417 | leency | 41 | ?define T_LAST_SLIDE "This slide is the last" |
4550 | leency | 42 | char loading[] = "Loading... |
4677 | leency | 43 | char page_not_found[] = FROM "html\page_not_found_en.htm"; |
4649 | leency | 44 | char accept_language[]= "Accept-Language: en\n"; |
4026 | leency | 45 | #endif |
46 | |||
5773 | leency | 47 | #define URL_SERVICE_HISTORY "WebView://history" |
48 | #define URL_SERVICE_HOME "WebView://home" |
||
49 | #define URL_SERVICE_SOURCE "WebView://source:" |
||
5631 | pavelyakov | 50 | |
3067 | leency | 51 | proc_info Form; |
52 | |||
5772 | leency | 53 | //char search_path[]="http://nigma.ru/index.php?s="; |
4558 | hidnplayr | 54 | int redirected = 0; |
3067 | leency | 55 | |
4074 | leency | 56 | char stak[4096]; |
5640 | pavelyakov | 57 | |
4026 | leency | 58 | int action_buf; |
59 | |||
4565 | leency | 60 | dword http_transfer = 0; |
4537 | leency | 61 | dword http_buffer; |
4534 | leency | 62 | |
5772 | leency | 63 | dword TOOLBAR_H = 33; |
5519 | leency | 64 | dword STATUSBAR_H = 15; |
4718 | leency | 65 | dword col_bg; |
66 | dword panel_color; |
||
67 | dword border_color; |
||
4677 | leency | 68 | |
5718 | leency | 69 | progress_bar wv_progress_bar; |
4718 | leency | 70 | byte souce_mode = false; |
4677 | leency | 71 | |
5718 | leency | 72 | enum { |
73 | BACK_BUTTON=1000, |
||
74 | FORWARD_BUTTON, |
||
75 | REFRESH_BUTTON, |
||
76 | GOTOURL_BUTTON, |
||
77 | SANDWICH_BUTTON |
||
78 | }; |
||
79 | |||
80 | enum { |
||
5768 | leency | 81 | VIEW_SOURCE=1100, |
5718 | leency | 82 | EDIT_SOURCE, |
83 | VIEW_HISTORY, |
||
84 | FREE_IMG_CACHE, |
||
85 | DOWNLOAD_MANAGER |
||
86 | }; |
||
87 | |||
4411 | leency | 88 | #include "..\TWB\TWB.c" |
5768 | leency | 89 | #include "menu.h" |
4636 | leency | 90 | #include "history.h" |
4718 | leency | 91 | #include "show_src.h" |
5685 | leency | 92 | #include "network_get.h" |
5493 | leency | 93 | #include "downloader.h" |
3067 | leency | 94 | |
4534 | leency | 95 | char editURL[sizeof(URL)]; |
96 | int mouse_twb; |
||
5772 | leency | 97 | edit_box address_box = {250,56,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19}; |
4534 | leency | 98 | |
99 | |||
3067 | leency | 100 | void main() |
101 | { |
||
5711 | leency | 102 | dword btn; |
3067 | leency | 103 | int half_scroll_size; |
4026 | leency | 104 | int scroll_used=0, show_menu; |
4536 | leency | 105 | CursorPointer.Load(#CursorFile); |
5626 | leency | 106 | load_dll(boxlib, #box_lib_init,0); |
107 | load_dll(libio, #libio_init,1); |
||
108 | load_dll(libimg, #libimg_init,1); |
||
109 | load_dll(libHTTP, #http_lib_init,1); |
||
5690 | leency | 110 | load_dll(iconv_lib, #iconv_open,0); |
5718 | leency | 111 | //load_dll(kmenu, #akmenu_init,0); |
5408 | leency | 112 | Libimg_LoadImage(#skin, abspath("wv_skin.png")); |
113 | SetSkinColors(); |
||
5772 | leency | 114 | CreateDir("/tmp0/1/downloads"); |
115 | if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME); |
||
5678 | leency | 116 | WB1.DrawBuf.zoom = 1; |
5712 | leency | 117 | WB1.list.SetFont(8, 14, 10111000b); |
5779 | leency | 118 | WB1.list.no_selection = true; |
5981 | leency | 119 | //font init |
120 | font.no_bg_copy = true; |
||
121 | font.bg_color = 0xFFFFFF; |
||
122 | font.load(DEFAULT_FONT); |
||
123 | if (!font.data) { |
||
124 | notify("'Error: Font is not loaded.' -E"); |
||
125 | ExitProcess(); |
||
126 | } |
||
127 | // |
||
4536 | leency | 128 | SetEventMask(0xa7); |
5631 | pavelyakov | 129 | BEGIN_LOOP_APPLICATION: |
3067 | leency | 130 | WaitEventTimeout(2); |
131 | switch(EAX & 0xFF) |
||
132 | { |
||
133 | CASE evMouse: |
||
4081 | leency | 134 | if (!CheckActiveProcess(Form.ID)) break; |
3466 | leency | 135 | edit_box_mouse stdcall (#address_box); |
5640 | pavelyakov | 136 | mouse.get(); |
5772 | leency | 137 | if (WB1.list.MouseOver(mouse.x, mouse.y)) |
3067 | leency | 138 | { |
5825 | leency | 139 | PageLinks.Hover(mouse.x, WB1.list.first*WB1.list.item_h + mouse.y, link_color_inactive, link_color_active, bg_color); |
5772 | leency | 140 | if (bufsize) && (mouse.pkm) && (mouse.up) { CreateThread(#menu_rmb,#stak+4092); break; } |
141 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
||
3067 | leency | 142 | } |
5782 | leency | 143 | scrollbar_v_mouse (#scroll_wv); |
144 | if (WB1.list.first != scroll_wv.position) |
||
3067 | leency | 145 | { |
5782 | leency | 146 | WB1.list.first = scroll_wv.position; |
147 | WB1.DrawPage(); |
||
148 | break; |
||
3067 | leency | 149 | } |
150 | break; |
||
5711 | leency | 151 | |
3067 | leency | 152 | case evButton: |
153 | btn=GetButtonID(); |
||
4636 | leency | 154 | if (btn==1) ExitProcess(); |
155 | Scan(btn); |
||
3067 | leency | 156 | break; |
5711 | leency | 157 | |
3067 | leency | 158 | case evKey: |
5711 | leency | 159 | GetKeys(); |
5531 | leency | 160 | if (address_box.flags & 0b10) |
5530 | leency | 161 | { |
5711 | leency | 162 | if (key_ascii == ASCII_KEY_ENTER) Scan(key_scancode); else |
163 | if (key_ascii != 0x0d) && (key_ascii != 183) && (key_ascii != 184) {EAX = key_ascii << 8; edit_box_key stdcall(#address_box);} |
||
5530 | leency | 164 | } |
5711 | leency | 165 | else |
166 | { |
||
167 | Scan(key_scancode); |
||
168 | } |
||
5530 | leency | 169 | break; |
3067 | leency | 170 | |
171 | case evReDraw: |
||
4636 | leency | 172 | if (action_buf) Scan(action_buf); |
5773 | leency | 173 | DefineAndDrawWindow(GetScreenWidth()-800/2,GetScreenHeight()-600/2,800,600,0x73,col_bg,0,0); |
4725 | leency | 174 | GetProcessInfo(#Form, SelfInfo); |
4727 | leency | 175 | if (Form.status_window>2) { DrawTitle(#header); break; } |
5811 | leency | 176 | if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
177 | if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
||
3067 | leency | 178 | Draw_Window(); |
179 | break; |
||