Rev 4026 | Rev 4081 | 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 | |||
3107 | leency | 6 | //libraries |
3363 | leency | 7 | #define MEMSIZE 0x100000 |
3067 | leency | 8 | #include "..\lib\kolibri.h" |
9 | #include "..\lib\strings.h" |
||
10 | #include "..\lib\figures.h" |
||
11 | #include "..\lib\encoding.h" |
||
12 | #include "..\lib\file_system.h" |
||
13 | #include "..\lib\mem.h" |
||
14 | #include "..\lib\dll.h" |
||
3107 | leency | 15 | //*.obj libraries |
16 | #include "..\lib\lib.obj\box_lib.h" |
||
17 | #include "..\lib\lib.obj\libio_lib.h" |
||
18 | #include "..\lib\lib.obj\libimg_lib.h" |
||
4026 | leency | 19 | #include "..\lib\list_box.h" |
3107 | leency | 20 | //images |
3067 | leency | 21 | #include "img\toolbar_icons.c" |
22 | #include "img\URLgoto.txt"; |
||
23 | |||
4026 | leency | 24 | #ifndef AUTOBUILD |
25 | #include "lang.h--" |
||
26 | #endif |
||
3067 | leency | 27 | |
4026 | leency | 28 | #ifdef LANG_RUS |
4074 | leency | 29 | char version[]=" ’ҐЄбв®ўл© Ўа 㧥а 0.99.09"; |
4026 | leency | 30 | ?define IMAGES_CACHE_CLEARED "Љни Є авЁ®Є ®зЁйҐ" |
31 | #else |
||
4074 | leency | 32 | char version[]=" Text-based Browser 0.99.09"; |
4026 | leency | 33 | ?define IMAGES_CACHE_CLEARED "Images cache cleared" |
34 | #endif |
||
35 | |||
36 | |||
3067 | leency | 37 | #define URL param |
3449 | leency | 38 | char fontlol[64]; |
3067 | leency | 39 | |
40 | char editURL[sizeof(URL)], |
||
41 | page_links[12000], |
||
3464 | leency | 42 | header[2048]; |
3067 | leency | 43 | |
44 | struct lines{ |
||
45 | int visible, all, first, column_max; |
||
46 | }; |
||
47 | |||
48 | int mouse_dd; |
||
3466 | leency | 49 | edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(editURL),#editURL,#mouse_dd,2,19,19}; |
3464 | leency | 50 | scroll_bar scroll1 = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
3067 | leency | 51 | |
52 | |||
53 | proc_info Form; |
||
54 | #define WIN_W 640 |
||
55 | #define WIN_H 480 |
||
56 | |||
57 | |||
4074 | leency | 58 | char stak[4096]; |
3067 | leency | 59 | mouse m; |
60 | |||
4026 | leency | 61 | int action_buf; |
62 | |||
3067 | leency | 63 | #include "TWB.h" |
64 | #include "include\menu_rmb.h" |
||
65 | |||
66 | |||
67 | void main() |
||
68 | { |
||
3458 | leency | 69 | int btn, key; |
3067 | leency | 70 | int half_scroll_size; |
4026 | leency | 71 | int scroll_used=0, show_menu; |
3067 | leency | 72 | |
73 | mem_Init(); |
||
3107 | leency | 74 | if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();} |
75 | if (load_dll2(libio, #libio_init,1)!=0) debug("Error: library doesn't exists - libio"w); |
||
76 | if (load_dll2(libimg, #libimg_init,1)!=0) debug("Error: library doesn't exists - libimg"w); |
||
3067 | leency | 77 | |
3987 | leency | 78 | if (!URL) strcpy(#URL, "/sys/index.htm"); |
3067 | leency | 79 | strcpy(#editURL, #URL); |
80 | |||
81 | Form.width=WIN_W; |
||
82 | Form.height=WIN_H; |
||
83 | SetElementSizes(); |
||
84 | WB1.OpenPage(); |
||
85 | |||
86 | SetEventMask(0x27); |
||
87 | loop() |
||
88 | { |
||
89 | WaitEventTimeout(2); |
||
90 | switch(EAX & 0xFF) |
||
91 | { |
||
92 | CASE evMouse: |
||
93 | /*scrollbar_v_mouse (#scroll1); //конченый скролл притормажимает, идём "своим путём" |
||
94 | if (lines.first <> scroll1.position) |
||
95 | { |
||
96 | lines.first = scroll1.position; |
||
97 | WB1.ParseHTML(buf, filesize); |
||
98 | //break; |
||
99 | };*/ |
||
100 | |||
101 | btn=GetProcessSlot(Form.ID); |
||
4026 | leency | 102 | if (btn<>GetActiveProcess()) break; |
3067 | leency | 103 | |
3466 | leency | 104 | edit_box_mouse stdcall (#address_box); |
3067 | leency | 105 | |
106 | m.get(); |
||
107 | |||
4026 | leency | 108 | if (m.y>WB1.top) && (m.y |
3067 | leency | 109 | { |
4026 | leency | 110 | if (m.pkm) |
111 | { |
||
112 | show_menu = 1; |
||
113 | } |
||
114 | if (!m.pkm) && (show_menu) |
||
115 | { |
||
116 | show_menu = 0; |
||
117 | SwitchToAnotherThread(); |
||
4074 | leency | 118 | CreateThread(#menu_rmb,#stak+4092); |
4026 | leency | 119 | break; |
120 | } |
||
3067 | leency | 121 | } |
122 | |||
4026 | leency | 123 | if (m.vert==65535) |
3067 | leency | 124 | { |
3477 | leency | 125 | if (lines.first==0) break; |
126 | if (lines.first>3) lines.first-=2; ELSE lines.first=1; |
||
3067 | leency | 127 | WB1.Scan(ID1); |
128 | break; |
||
129 | } |
||
3477 | leency | 130 | if (m.vert==1) |
3067 | leency | 131 | { |
3477 | leency | 132 | if(lines.visible+lines.first+3>=lines.all) WB1.Scan(181); |
4026 | leency | 133 | else |
134 | { |
||
3067 | leency | 135 | lines.first+=2; |
136 | WB1.Scan(ID2); |
||
137 | } |
||
138 | break; |
||
139 | } |
||
140 | |||
141 | if (!m.lkm) scroll_used=0; |
||
3477 | leency | 142 | if (m.x>=scroll1.start_x) && (m.x<=scroll1.start_x+scroll1.size_x) |
4026 | leency | 143 | && (m.y>=scroll1.start_y+scroll1.btn_height) && (-scroll1.btn_height+scroll1.start_y+scroll1.size_y>m.y) |
144 | && (lines.all>lines.visible) && (m.lkm) |
||
145 | { |
||
146 | scroll_used=1; |
||
147 | } |
||
3067 | leency | 148 | |
149 | if (scroll_used) |
||
150 | { |
||
151 | half_scroll_size = WB1.height - 16 * lines.visible / lines.all - 3 /2; |
||
3477 | leency | 152 | if (half_scroll_size+WB1.top>m.y) || (m.y<0) || (m.y>4000) m.y=half_scroll_size+WB1.top; //если курсор над окном |
3067 | leency | 153 | btn=lines.first; //сохраняем старое количество |
154 | lines.first = m.y -half_scroll_size -WB1.top * lines.all / WB1.height; |
||
155 | if (lines.visible+lines.first>lines.all) lines.first=lines.all-lines.visible; |
||
156 | if (btn<>lines.first) WB1.ParseHTML(buf); //чтоб лишний раз не перерисовывать |
||
157 | } |
||
158 | |||
159 | break; |
||
160 | case evButton: |
||
161 | btn=GetButtonID(); |
||
3464 | leency | 162 | if (btn==1) |
3067 | leency | 163 | { |
164 | KillProcess(downloader_id); |
||
165 | ExitProcess(); |
||
166 | } |
||
167 | ELSE |
||
168 | { |
||
169 | WB1.Scan(btn); |
||
170 | } |
||
171 | break; |
||
172 | case evKey: |
||
173 | key = GetKey(); |
||
174 | |||
3466 | leency | 175 | if (address_box.flags & 0b10) SWITCH(key) //если активна строка адреса игнорируем некоторые кнопки |
3067 | leency | 176 | { CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; } |
177 | |||
178 | WB1.Scan(key); |
||
179 | |||
180 | _EDIT_MARK: |
||
3990 | leency | 181 | if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);} //адресная строка |
3067 | leency | 182 | break; |
183 | case evReDraw: |
||
4026 | leency | 184 | if (action_buf) { WB1.Scan(action_buf); action_buf=0;} |
3067 | leency | 185 | Draw_Window(); |
186 | break; |
||
187 | default: |
||
188 | if (downloader_id<>0) |
||
189 | { |
||
190 | if (GetProcessSlot(downloader_id)<>0) break; |
||
191 | downloader_id=0; |
||
192 | lines.first = lines.all = 0; |
||
193 | WB1.ReadHtml(_WIN); |
||
194 | Draw_Window(); |
||
195 | } |
||
196 | } |
||
197 | } |
||
198 | } |
||
199 | |||
200 | void SetElementSizes() |
||
201 | { |
||
3466 | leency | 202 | address_box.width = Form.width-266; |
3464 | leency | 203 | WB1.top = 44; |
3466 | leency | 204 | WB1.width = Form.width - 10 - scroll1.size_x; |
205 | WB1.height = Form.height - WB1.top - GetSkinHeight() - 4; |
||
3464 | leency | 206 | WB1.line_h = 10; |
3067 | leency | 207 | lines.column_max = WB1.width - 30 / 6; |
3464 | leency | 208 | lines.visible = WB1.height - 3 / WB1.line_h - 2; |
3468 | leency | 209 | DrawBufInit(); |
3067 | leency | 210 | } |
211 | |||
212 | |||
213 | void Draw_Window() |
||
214 | { |
||
215 | int j; |
||
3466 | leency | 216 | DefineAndDrawWindow(215,100,WIN_W,WIN_H,0x73,0xE4DFE1,0,0); |
3067 | leency | 217 | |
218 | GetProcessInfo(#Form, SelfInfo); |
||
3464 | leency | 219 | if (Form.status_window>2) |
3067 | leency | 220 | { |
221 | DrawTitle(#header); |
||
222 | return; |
||
223 | } |
||
224 | if (Form.height<120) MoveSize(OLD,OLD,OLD,120); |
||
225 | if (Form.width<280) MoveSize(OLD,OLD,280,OLD); |
||
226 | |||
227 | PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal); |
||
3363 | leency | 228 | if (GetProcessSlot(downloader_id)<>0) _PutImage(88,10, 24,24, #stop_btn); |
3067 | leency | 229 | |
3464 | leency | 230 | DrawBar(200,0,Form.cwidth-200,43,0xE4DFE1); |
231 | DrawBar(0,42,Form.cwidth,1,0xE2DBDC); |
||
232 | DrawBar(0,43,Form.cwidth,1,0xD2CED0); |
||
3067 | leency | 233 | for (j=0; j<5; j++) DefineButton(j*37+11, 7, 29, 29, 300+j+BT_HIDE, 0xE4DFE1); |
3464 | leency | 234 | _PutImage(Form.cwidth-48,14, 40,19, #URLgoto); |
235 | DefineButton(Form.cwidth-28,15, 18, 16, GOTOURL+BT_HIDE, 0xE4DFE1); |
||
236 | DefineButton(Form.cwidth-47,15, 17, 16, SEARCHWEB+BT_HIDE, 0xE4DFE1); |
||
237 | DrawRectangle(205,14,Form.cwidth-205-49,18,0x94AECE); //around adress bar |
||
238 | DrawRectangle(206,15,Form.cwidth-205-50,16,0xE4ECF3); |
||
3067 | leency | 239 | |
240 | SetElementSizes(); |
||
241 | WB1.ShowPage(); |
||
3464 | leency | 242 | |
3067 | leency | 243 | DefineButton(scroll1.start_x+1, scroll1.start_y+1, 16, 16, ID1+BT_HIDE, 0xE4DFE1); |
244 | DefineButton(scroll1.start_x+1, scroll1.start_y+scroll1.size_y-18, 16, 16, ID2+BT_HIDE, 0xE4DFE1); |
||
245 | } |
||
246 | |||
247 | |||
248 | stop:5;>>280)>120)>>>8;><8;>>>>>0)>=scroll1.start_x+scroll1.size_x)>>> |