Rev 4550 | Rev 4562 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4491 | leency | 1 | #include "..\TWB\links.h" |
4411 | leency | 2 | |
3 | |||
4540 | leency | 4 | dword bufpointer; |
5 | dword bufsize; |
||
4411 | leency | 6 | |
4416 | leency | 7 | #define URL param |
8 | |||
9 | scroll_bar scroll_wv = { 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}; |
||
10 | |||
4417 | leency | 11 | char header[2048]; |
4416 | leency | 12 | |
4411 | leency | 13 | char download_path[]="/rd/1/.download"; |
14 | |||
15 | struct TWebBrowser { |
||
4540 | leency | 16 | llist list; |
4475 | leency | 17 | DrawBufer DrawBuf; |
4411 | leency | 18 | void GetNewUrl(); |
4475 | leency | 19 | void ReadHtml(); |
4550 | leency | 20 | void Parse(); |
4475 | leency | 21 | void WhatTextStyle(); |
4411 | leency | 22 | void DrawPage(); |
23 | void DrawScroller(); |
||
4475 | leency | 24 | void TextGoDown(); |
4486 | leency | 25 | }; |
26 | |||
4411 | leency | 27 | TWebBrowser WB1; |
28 | |||
4491 | leency | 29 | byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, |
4417 | leency | 30 | link, ignor_text, cur_encoding, text_align; |
31 | byte condition_text_active, condition_text_val, condition_href, condition_max; |
||
4411 | leency | 32 | |
4488 | leency | 33 | enum { _WIN, _DOS, _KOI, _UTF }; |
4475 | leency | 34 | |
4411 | leency | 35 | enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; |
36 | |||
4417 | leency | 37 | dword text_colors[300]; |
38 | dword text_color_index; |
||
4491 | leency | 39 | dword link_color_inactive; |
40 | dword link_color_active; |
||
4417 | leency | 41 | dword bg_color; |
4411 | leency | 42 | |
4417 | leency | 43 | int stroka; |
44 | int stolbec; |
||
45 | int tab_len; |
||
46 | int anchor_line_num; |
||
4411 | leency | 47 | |
4417 | leency | 48 | char line[500]; |
49 | char tag[100]; |
||
50 | char tagparam[10000]; |
||
51 | char parametr[1200]; |
||
52 | char options[4096]; |
||
53 | char anchor[256]; |
||
4411 | leency | 54 | |
4416 | leency | 55 | #include "..\TWB\history.h" |
4411 | leency | 56 | #include "..\TWB\colors.h" |
57 | #include "..\TWB\unicode_tags.h" |
||
58 | #include "..\TWB\img_cache.h" |
||
59 | #include "..\TWB\parce_tag.h" |
||
60 | |||
4475 | leency | 61 | |
62 | |||
4411 | leency | 63 | //======================================================================= |
64 | |||
65 | |||
66 | void TWebBrowser::DrawPage() |
||
67 | { |
||
68 | int start_x, start_y, line_length, magrin_left=5; |
||
69 | |||
70 | if (!header) |
||
71 | { |
||
72 | strcpy(#header, #line); |
||
73 | strcat(#header, " -"); |
||
74 | strcat(#header, #version); |
||
75 | line = 0; |
||
76 | return; |
||
77 | } |
||
78 | |||
4415 | leency | 79 | if (stroka >= 0) && (stroka - 2 < list.visible) && (line) && (!anchor) |
4411 | leency | 80 | { |
4414 | leency | 81 | start_x = stolbec * 6 + list.x + magrin_left; |
82 | start_y = stroka * 10 + list.y + magrin_left; |
||
4411 | leency | 83 | line_length = strlen(#line) * 6; |
84 | |||
4475 | leency | 85 | WriteBufText(start_x, 0, 0x88, text_colors[text_color_index], #line, buf_data); |
86 | IF (b_text) WriteBufText(start_x+1, 0, 0x88, text_colors[text_color_index], #line, buf_data); |
||
87 | IF (i_text) { stolbec++; DrawBuf.Skew(start_x, 0, line_length, list.line_h); } |
||
88 | IF (s_text) DrawBuf.DrawBar(start_x, 4, line_length, 1, text_colors[text_color_index]); |
||
89 | IF (u_text) DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]); |
||
4411 | leency | 90 | IF (link) { |
4493 | leency | 91 | UnsafeDefineButton(start_x-2, start_y, line_length + 3, 9, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9); |
4475 | leency | 92 | DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]); |
4550 | leency | 93 | PageLinks.AddText(#line, line_length, list.line_h, UNDERLINE); |
4411 | leency | 94 | } |
95 | stolbec += strlen(#line); |
||
96 | } |
||
97 | } |
||
98 | //======================================================================= |
||
99 | |||
100 | |||
101 | |||
102 | char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", 0}; |
||
103 | void TWebBrowser::GetNewUrl(){ |
||
104 | int i, len; |
||
4534 | leency | 105 | char newurl[4096]; |
4411 | leency | 106 | |
107 | for (i=0; ABSOLUTE_LINKS[i]; i++) |
||
108 | { |
||
109 | len=strlen(ABSOLUTE_LINKS[i]); |
||
110 | if (!strcmpn(#URL, ABSOLUTE_LINKS[i], len)) return; |
||
111 | } |
||
112 | |||
4534 | leency | 113 | IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2); |
114 | strcpy(#newurl, BrowserHistory.CurrentUrl()); |
||
4411 | leency | 115 | |
116 | if (URL[0] == '/') |
||
117 | { |
||
4534 | leency | 118 | i = strchr(#newurl+8, '/'); |
119 | newurl[i+7]=0; |
||
4411 | leency | 120 | strcpy(#URL, #URL+1); |
121 | } |
||
122 | |||
123 | _CUT_ST_LEVEL_MARK: |
||
124 | |||
4534 | leency | 125 | if (newurl[strrchr(#newurl, '/')-2]<>'/') |
4411 | leency | 126 | { |
4534 | leency | 127 | newurl[strrchr(#newurl, '/')] = 0x00; |
4411 | leency | 128 | } |
129 | |||
4534 | leency | 130 | IF (!strncmp(#URL,"../",3)) |
4411 | leency | 131 | { |
132 | strcpy(#URL,#URL+3); |
||
4534 | leency | 133 | newurl[strrchr(#newurl, '/')-1] = 0x00; |
4411 | leency | 134 | goto _CUT_ST_LEVEL_MARK; |
135 | } |
||
136 | |||
4534 | leency | 137 | if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/"); |
4411 | leency | 138 | |
4534 | leency | 139 | strcat(#newurl, #URL); |
140 | strcpy(#URL, #newurl); |
||
4411 | leency | 141 | } |
142 | |||
143 | |||
144 | void TWebBrowser::ReadHtml(byte encoding) |
||
145 | { |
||
4554 | leency | 146 | if (native_http) |
147 | { |
||
148 | if (strncmp(#URL,"http:",5)) { |
||
149 | file_size stdcall (#URL); |
||
150 | bufsize = EBX; |
||
151 | } |
||
152 | |||
153 | if (!bufsize) return; |
||
154 | |||
155 | if (strncmp(#URL,"http:",5)) { |
||
156 | mem_Free(bufpointer); |
||
157 | bufpointer = mem_Alloc(bufsize); |
||
158 | } |
||
159 | |||
160 | if (strncmp(#URL,"http:",5)) ReadFile(0, bufsize, bufpointer, #URL); |
||
161 | |||
162 | cur_encoding = encoding; |
||
163 | if (encoding==_WIN) wintodos(bufpointer); |
||
164 | if (encoding==_UTF) utf8rutodos(bufpointer); |
||
165 | if (encoding==_KOI) koitodos(bufpointer); |
||
166 | } |
||
4411 | leency | 167 | else |
4554 | leency | 168 | { |
169 | if (!strncmp(#URL,"http:",5)) |
||
170 | file_size stdcall (#download_path); |
||
171 | else |
||
172 | file_size stdcall (#URL); |
||
173 | |||
174 | bufsize = EBX; |
||
175 | if (!bufsize) return; |
||
176 | |||
177 | mem_Free(bufpointer); |
||
178 | bufpointer = mem_Alloc(bufsize); |
||
179 | if (!strncmp(#URL,"http:",5)) |
||
180 | ReadFile(0, bufsize, bufpointer, #download_path); |
||
181 | else |
||
182 | ReadFile(0, bufsize, bufpointer, #URL); |
||
183 | |||
184 | cur_encoding = encoding; |
||
185 | if (encoding==_WIN) wintodos(bufpointer); |
||
186 | if (encoding==_UTF) utf8rutodos(bufpointer); |
||
187 | if (encoding==_KOI) koitodos(bufpointer); |
||
188 | } |
||
4411 | leency | 189 | } |
190 | |||
4554 | leency | 191 | /* |
192 | void TWebBrowser::ReadHtml(byte encoding) |
||
193 | { |
||
4411 | leency | 194 | |
4554 | leency | 195 | |
196 | } |
||
197 | */ |
||
198 | |||
199 | |||
4550 | leency | 200 | void TWebBrowser::Parse(dword bufpos, in_filesize){ |
4411 | leency | 201 | word bukva[2]; |
202 | int j, perenos_num; |
||
203 | byte ignor_param; |
||
204 | char temp[768]; |
||
4550 | leency | 205 | bufsize = in_filesize; |
206 | bufpointer = bufpos; |
||
4411 | leency | 207 | |
208 | b_text = i_text = u_text = s_text = blq_text = |
||
4417 | leency | 209 | li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = |
210 | condition_text_val = condition_text_active = 0; //обнуляем теги |
||
4475 | leency | 211 | condition_max = 255; |
4411 | leency | 212 | text_align = ALIGN_LEFT; |
4491 | leency | 213 | link_color_inactive = 0x0000FF; |
214 | link_color_active = 0xFF0000; |
||
4411 | leency | 215 | bg_color = 0xFFFFFF; |
4475 | leency | 216 | DrawBuf.Fill(bg_color); |
4504 | leency | 217 | PageLinks.Clear(); |
4411 | leency | 218 | strcpy(#header, #version); |
4415 | leency | 219 | stroka = -list.first; |
4411 | leency | 220 | stolbec = 0; |
221 | line = 0; |
||
222 | |||
223 | if (pre_text<>2) |
||
224 | { |
||
225 | pre_text=0; |
||
226 | if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1; |
||
227 | if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1; |
||
228 | } |
||
229 | |||
4550 | leency | 230 | for ( ; bufpointer+bufsize > bufpos; bufpos++;) |
4411 | leency | 231 | { |
4508 | leency | 232 | bukva = ESBYTE[bufpos]; |
4417 | leency | 233 | if (ignor_text) && (bukva!='<') continue; |
234 | if (condition_text_active) && (condition_text_val != condition_href) && (bukva!='<') continue; |
||
4411 | leency | 235 | switch (bukva) |
236 | { |
||
237 | case 0x0a: |
||
238 | if (pre_text) |
||
239 | { |
||
240 | bukva = temp = NULL; |
||
241 | goto NEXT_MARK; |
||
242 | } |
||
243 | case '\9': |
||
244 | if (pre_text) //иначе идём на 0x0d |
||
245 | { |
||
246 | tab_len=strlen(#line)/8; |
||
247 | tab_len=tab_len*8; |
||
248 | tab_len=8+tab_len-strlen(#line); |
||
249 | for (j=0; j |
||
250 | break; |
||
251 | } |
||
252 | goto DEFAULT_MARK; |
||
253 | case '=': //quoted printable |
||
254 | if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK; |
||
255 | |||
4508 | leency | 256 | temp[0] = ESBYTE[bufpos+1]; |
257 | temp[1] = ESBYTE[bufpos+2]; |
||
4411 | leency | 258 | temp[2] = '\0'; |
259 | if (bukva = Hex2Symb(#temp)) |
||
260 | { |
||
4508 | leency | 261 | bufpos+=2; |
4411 | leency | 262 | goto DEFAULT_MARK; |
263 | } |
||
264 | break; |
||
265 | |||
266 | case '&': // and so on |
||
4508 | leency | 267 | bufpos++; |
4411 | leency | 268 | tag=0; |
4508 | leency | 269 | for (j=0; (ESBYTE[bufpos]<>';') && (j<7); j++, bufpos++;) |
4411 | leency | 270 | { |
4508 | leency | 271 | bukva = ESBYTE[bufpos]; |
4411 | leency | 272 | chrcat(#tag, bukva); |
273 | } |
||
4417 | leency | 274 | if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK; |
4411 | leency | 275 | break; |
276 | case '<': |
||
4508 | leency | 277 | bufpos++; //промотаем символ < |
4411 | leency | 278 | tag = parametr = tagparam = ignor_param = NULL; |
4508 | leency | 279 | if (ESBYTE[bufpos] == '!') //фильтрация внутри , дерзко |
4411 | leency | 280 | { |
4508 | leency | 281 | bufpos++; |
282 | if (ESBYTE[bufpos] == '-') |
||
4411 | leency | 283 | { |
284 | HH_: |
||
285 | do |
||
286 | { |
||
4508 | leency | 287 | bufpos++; |
4550 | leency | 288 | if (bufpointer + bufsize <= bufpos) break 2; |
4411 | leency | 289 | } |
4508 | leency | 290 | while (ESBYTE[bufpos] <>'-'); |
4411 | leency | 291 | |
4508 | leency | 292 | bufpos++; |
293 | if (ESBYTE[bufpos] <>'-') goto HH_; |
||
4411 | leency | 294 | } |
295 | } |
||
4550 | leency | 296 | while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //получаем тег и его параметры |
4411 | leency | 297 | { |
4508 | leency | 298 | bukva = ESBYTE[bufpos]; |
4411 | leency | 299 | if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; |
300 | if (!ignor_param) && (bukva <>' ') |
||
301 | { |
||
302 | if (strlen(#tag) |
||
303 | } |
||
304 | else |
||
305 | { |
||
306 | ignor_param = true; |
||
307 | if (!ignor_text) && (strlen(#tagparam)+1 |
||
308 | } |
||
4508 | leency | 309 | bufpos++; |
4411 | leency | 310 | } |
311 | strlwr(#tag); |
||
312 | strlwr(#tagparam); |
||
313 | |||
4417 | leency | 314 | if (condition_text_active) && (condition_text_val != condition_href) |
315 | { |
||
316 | if (strcmp(#tag, "/condition")!=0) break; |
||
317 | } |
||
4411 | leency | 318 | if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/ |
319 | if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam(); |
||
320 | |||
4415 | leency | 321 | if (stolbec + strlen(#line) > list.column_max) //============the same as NEXT_MARK |
4411 | leency | 322 | { |
323 | perenos_num = strrchr(#line, ' '); |
||
4415 | leency | 324 | if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max; |
4411 | leency | 325 | strcpy(#temp, #line + perenos_num); //перенос по словам |
326 | line[perenos_num] = 0x00; |
||
4415 | leency | 327 | if (stroka-1 > list.visible) && (list.first <>0) break 1; //уходим... |
4411 | leency | 328 | DrawPage(); |
329 | strcpy(#line, #temp); |
||
4414 | leency | 330 | TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //закрашиваем следущую строку |
4411 | leency | 331 | } |
332 | DrawPage(); |
||
333 | |||
4550 | leency | 334 | line=NULL; |
4414 | leency | 335 | if (tag) WhatTextStyle(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //обработка тегов |
4411 | leency | 336 | |
337 | tag = parametr = tagparam = ignor_param = NULL; |
||
338 | break; |
||
339 | default: |
||
340 | DEFAULT_MARK: |
||
341 | if (bukva<=15) bukva=' '; |
||
342 | if (!pre_text) && (bukva == ' ') |
||
343 | { |
||
344 | if (line[strlen(#line)-1]==' ') break; //убрать 2 пробела подряд |
||
345 | if (!stolbec) && (!line) break; //строка не может начинаться с пробела |
||
346 | } |
||
347 | if (strlen(#line) |
||
348 | |||
4415 | leency | 349 | if (stolbec + strlen(#line) > list.column_max) |
4411 | leency | 350 | { |
351 | NEXT_MARK: |
||
352 | perenos_num = strrchr(#line, ' '); |
||
4415 | leency | 353 | if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max; |
4411 | leency | 354 | strcpy(#temp, #line + perenos_num); //перенос по словам |
355 | line[perenos_num] = 0x00; |
||
4415 | leency | 356 | if (stroka-1 > list.visible) && (list.first <>0) break 1; //уходим... |
4411 | leency | 357 | DrawPage(); |
358 | strcpy(#line, #temp); |
||
4414 | leency | 359 | TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //закрашиваем следущую строку |
4411 | leency | 360 | } |
361 | } |
||
362 | } |
||
363 | |||
364 | DrawPage(); //рисует последнюю строку, потом это надо убрать, оптимизировав код |
||
4414 | leency | 365 | TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //закрашиваем следущую строку |
4411 | leency | 366 | |
4415 | leency | 367 | if (list.visible * 10 + 25 <= list.h) |
368 | DrawBar(list.x, list.visible * 10 + list.y + 25, list.w, -list.visible * 10 + list.h - 25, bg_color); |
||
4414 | leency | 369 | if (stroka * 10 + 5 <= list.h) |
370 | DrawBar(list.x, stroka * 10 + list.y + 5, list.w, -stroka * 10 + list.h - 5, bg_color); //закрашиваем всё до конца |
||
4415 | leency | 371 | if (list.first == 0) list.count = stroka; |
4411 | leency | 372 | if (anchor) //если посреди текста появится новый якорь - будет бесконечный цикл |
373 | { |
||
374 | anchor=NULL; |
||
4415 | leency | 375 | list.first=anchor_line_num; |
4550 | leency | 376 | Parse(bufpointer, bufsize); |
4411 | leency | 377 | } |
378 | DrawScroller(); |
||
379 | } |
||
380 | |||
381 | |||
382 | |||
383 | char oldtag[100]; |
||
384 | void TWebBrowser::WhatTextStyle(int left1, top1, width1) { |
||
385 | dword hr_color; |
||
4491 | leency | 386 | byte opened; |
4411 | leency | 387 | |
388 | //проверяем тег открывается или закрывается |
||
389 | if (tag[0] == '/') |
||
390 | { |
||
4491 | leency | 391 | opened = 0; |
4411 | leency | 392 | strcpy(#tag, #tag+1); |
393 | } |
||
4491 | leency | 394 | else opened = 1; |
4411 | leency | 395 | |
4488 | leency | 396 | if (isTag("html")) |
4411 | leency | 397 | { |
4491 | leency | 398 | IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (opened==0) ignor_text = 1; ELSE ignor_text = 0; |
4411 | leency | 399 | return; |
400 | } |
||
401 | |||
4491 | leency | 402 | if (isTag("script")) || (isTag("style")) || (isTag("binary")) ignor_text = opened; |
4411 | leency | 403 | |
4488 | leency | 404 | if(isTag("title")) |
4411 | leency | 405 | { |
4491 | leency | 406 | if (opened) header=NULL; |
4411 | leency | 407 | else if (!stroka) DrawTitle(#header); //тег закрылся - вывели строку |
408 | return; |
||
409 | } |
||
410 | |||
411 | if (ignor_text) return; |
||
412 | |||
4491 | leency | 413 | IF(isTag("q")) |
414 | { |
||
415 | if (opened) |
||
416 | { |
||
417 | TextGoDown(left1, top1, width1); |
||
418 | strcat(#line, ' \"'); |
||
419 | } |
||
420 | if (!opened) |
||
421 | { |
||
422 | chrcat(#line, '\"'); |
||
423 | TextGoDown(left1, top1, width1); |
||
424 | } |
||
425 | } |
||
4411 | leency | 426 | |
427 | if (anchor) && (!strcmp(#parametr, "id=")) //очень плохо!!! потому что если не последний тег, работать не будет |
||
428 | { |
||
4415 | leency | 429 | if (!strcmp(#anchor, #options)) anchor_line_num=list.first+stroka; |
4411 | leency | 430 | } |
431 | |||
4488 | leency | 432 | if (isTag("body")) |
4411 | leency | 433 | { |
434 | do{ |
||
4491 | leency | 435 | if (!strcmp(#parametr, "condition_max=")) condition_max = atoi(#options); |
436 | if (!strcmp(#parametr, "link=")) link_color_inactive = GetColor(#options); |
||
437 | if (!strcmp(#parametr, "alink=")) link_color_active = GetColor(#options); |
||
4411 | leency | 438 | if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options); |
439 | if (!strcmp(#parametr, "bgcolor=")) |
||
440 | { |
||
441 | bg_color=GetColor(#options); |
||
4475 | leency | 442 | DrawBuf.Fill(bg_color); |
4411 | leency | 443 | } |
444 | } while(GetNextParam()); |
||
445 | return; |
||
446 | } |
||
447 | |||
4488 | leency | 448 | if (isTag("a")) |
4411 | leency | 449 | { |
4491 | leency | 450 | if (opened) |
4411 | leency | 451 | { |
452 | if (link) IF(text_color_index > 0) text_color_index--; //если предыдущий тег а не был закрыт |
||
453 | |||
454 | do{ |
||
455 | if (!strcmp(#parametr, "href=")) |
||
456 | { |
||
4415 | leency | 457 | if (stroka - 1 > list.visible) || (stroka < -2) return; |
4411 | leency | 458 | |
459 | text_color_index++; |
||
460 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
461 | |||
462 | link = 1; |
||
4491 | leency | 463 | text_colors[text_color_index] = link_color_inactive; |
464 | PageLinks.AddLink(#options, stolbec*6+left1, top1); |
||
4411 | leency | 465 | } |
466 | if (anchor) && (!strcmp(#parametr, "name=")) |
||
467 | { |
||
468 | if (!strcmp(#anchor, #options)) |
||
469 | { |
||
4415 | leency | 470 | anchor_line_num=list.first+stroka; |
4411 | leency | 471 | } |
472 | } |
||
473 | } while(GetNextParam()); |
||
474 | } |
||
475 | else { |
||
476 | link = 0; |
||
477 | IF(text_color_index > 0) text_color_index--; |
||
478 | } |
||
479 | return; |
||
480 | } |
||
481 | |||
4488 | leency | 482 | if (isTag("font")) |
4411 | leency | 483 | { |
4491 | leency | 484 | if (opened) |
4411 | leency | 485 | { |
486 | text_color_index++; |
||
487 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
488 | |||
489 | do{ |
||
490 | if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#') |
||
491 | { |
||
492 | text_colors[text_color_index] = GetColor(#options); |
||
493 | } |
||
494 | } while(GetNextParam()); |
||
495 | } |
||
496 | else |
||
497 | if (text_color_index > 0) text_color_index--; |
||
498 | return; |
||
499 | } |
||
4488 | leency | 500 | if(isTag("tr")) || (isTag("br")) { |
4411 | leency | 501 | TextGoDown(left1, top1, width1); |
502 | return; |
||
503 | } |
||
4533 | leency | 504 | if (isTag("div")) || (isTag("header")) || (isTag("footer")) { |
4411 | leency | 505 | IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1); |
506 | return; |
||
507 | } |
||
4488 | leency | 508 | if (isTag("p")) { |
4411 | leency | 509 | IF(oldtag[0] == 'h') return; |
510 | TextGoDown(left1, top1, width1); |
||
4491 | leency | 511 | IF(opened) TextGoDown(left1, top1 + 10, width1); |
4411 | leency | 512 | return; |
513 | } |
||
4475 | leency | 514 | /* |
4488 | leency | 515 | if (isTag("center")) |
4411 | leency | 516 | { |
4491 | leency | 517 | if (opened) text_align = ALIGN_CENTER; |
518 | if (!opened) |
||
4411 | leency | 519 | { |
520 | TextGoDown(left1, top1, width1); |
||
521 | text_align = ALIGN_LEFT; |
||
522 | } |
||
523 | return; |
||
524 | } |
||
4488 | leency | 525 | if (isTag("right")) |
4411 | leency | 526 | { |
4491 | leency | 527 | if (opened) text_align = ALIGN_RIGHT; |
528 | if (!opened) |
||
4411 | leency | 529 | { |
530 | TextGoDown(left1, top1, width1); |
||
531 | text_align = ALIGN_LEFT; |
||
532 | } |
||
533 | return; |
||
534 | } |
||
4475 | leency | 535 | */ |
4488 | leency | 536 | if (isTag("h1")) || (isTag("h2")) || (isTag("h3")) || (isTag("h4")) { |
4411 | leency | 537 | TextGoDown(left1, top1, width1); |
4491 | leency | 538 | if (opened) && (stroka>1) TextGoDown(left1, top1 + 10, width1); |
4411 | leency | 539 | strcpy(#oldtag, #tag); |
4491 | leency | 540 | if (opened) |
4411 | leency | 541 | { |
542 | if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"center")) text_align = ALIGN_CENTER; |
||
543 | if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"right")) text_align = ALIGN_RIGHT; |
||
544 | b_text = 1; |
||
545 | } |
||
4491 | leency | 546 | if (!opened) |
4411 | leency | 547 | { |
548 | text_align = ALIGN_LEFT; |
||
549 | b_text = 0; |
||
550 | } |
||
551 | return; |
||
552 | } |
||
553 | else |
||
554 | oldtag=NULL; |
||
555 | |||
4488 | leency | 556 | if (isTag("b")) || (isTag("strong")) || (isTag("big")) { |
4491 | leency | 557 | b_text = opened; |
4411 | leency | 558 | return; |
559 | } |
||
4488 | leency | 560 | if(isTag("i")) || (isTag("em")) || (isTag("subtitle")) { |
4491 | leency | 561 | i_text = opened; |
4411 | leency | 562 | return; |
563 | } |
||
4488 | leency | 564 | if (isTag("dt")) |
4411 | leency | 565 | { |
4491 | leency | 566 | li_text = opened; |
567 | IF(opened == 0) return; |
||
4411 | leency | 568 | TextGoDown(left1, top1, width1); |
569 | return; |
||
570 | } |
||
4488 | leency | 571 | if (isTag("condition")) |
4417 | leency | 572 | { |
4491 | leency | 573 | condition_text_active = opened; |
574 | if (opened) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options); |
||
4417 | leency | 575 | return; |
576 | } |
||
4488 | leency | 577 | if (isTag("li")) || (isTag("dt")) //надо сделать вложенные списки |
4411 | leency | 578 | { |
4491 | leency | 579 | li_text = opened; |
580 | if (opened) |
||
4411 | leency | 581 | { |
582 | TextGoDown(left1, top1, width1); |
||
4475 | leency | 583 | if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555); |
4411 | leency | 584 | } |
585 | return; |
||
586 | } |
||
4491 | leency | 587 | if (isTag("u")) || (isTag("ins")) u_text = opened; |
588 | if (isTag("s")) || (isTag("strike")) || (isTag("del")) s_text = opened; |
||
589 | if (isTag("ul")) || (isTag("ol")) IF(!opened) |
||
4411 | leency | 590 | { |
4491 | leency | 591 | li_text = opened; |
4411 | leency | 592 | li_tab--; |
593 | TextGoDown(left1, top1, width1); |
||
594 | } ELSE li_tab++; |
||
4488 | leency | 595 | if (isTag("dd")) stolbec += 5; |
4491 | leency | 596 | if (isTag("blockquote")) blq_text = opened; |
4497 | leency | 597 | if (isTag("pre")) || (isTag("code")) pre_text = opened; |
4488 | leency | 598 | if (isTag("hr")) |
4411 | leency | 599 | { |
600 | if (anchor) || (stroka < -1) |
||
601 | { |
||
602 | stroka+=2; |
||
603 | return; |
||
604 | } |
||
605 | if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999; |
||
606 | TextGoDown(left1, top1, width1); |
||
4486 | leency | 607 | DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color); |
608 | TextGoDown(left1, top1+list.line_h, width1); |
||
4411 | leency | 609 | } |
4488 | leency | 610 | if (isTag("img")) |
4411 | leency | 611 | { |
4491 | leency | 612 | ImgCache.Images( left1, top1, width1); |
4411 | leency | 613 | return; |
614 | } |
||
4488 | leency | 615 | if (isTag("meta")) || (isTag("?xml")) |
4411 | leency | 616 | { |
617 | do{ |
||
618 | if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding=")) |
||
619 | { |
||
620 | strcpy(#options, #options[strrchr(#options, '=')]); //поиск в content= |
||
4475 | leency | 621 | if (!strcmp(#options, "utf-8")) || (!strcmp(#options,"utf8")) ReadHtml(_UTF); |
4411 | leency | 622 | if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) ReadHtml(_KOI); |
623 | if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) ReadHtml(_DOS); |
||
624 | } |
||
625 | } while(GetNextParam()); |
||
626 | return; |
||
627 | } |
||
628 | } |
||
629 | |||
4491 | leency | 630 | /* |
631 | char *encodings = { |
||
632 | "utf-8", _UTF, |
||
633 | "utf8", _UTF, |
||
634 | "koi8-r", _KOI, |
||
635 | "koi8-u", _KOI, |
||
636 | "dos", _DOS, |
||
637 | "cp-866", _DOS |
||
638 | }; |
||
639 | */ |
||
4411 | leency | 640 | |
641 | void TWebBrowser::DrawScroller() //не оптимальная отрисовка, но зато в одном месте |
||
642 | { |
||
4416 | leency | 643 | scroll_wv.max_area = list.count; |
644 | scroll_wv.cur_area = list.visible; |
||
645 | scroll_wv.position = list.first; |
||
4411 | leency | 646 | |
4416 | leency | 647 | scroll_wv.all_redraw=1; |
4486 | leency | 648 | scroll_wv.start_x = list.x + list.w; |
4508 | leency | 649 | scroll_wv.start_y = list.y; |
4486 | leency | 650 | scroll_wv.size_y=list.h; |
4411 | leency | 651 | |
4416 | leency | 652 | scrollbar_v_draw(#scroll_wv); |
4411 | leency | 653 | } |
654 | |||
4475 | leency | 655 | |
656 | void TWebBrowser::TextGoDown(int left1, top1, width1) |
||
657 | { |
||
4486 | leency | 658 | if (!stroka) DrawBar(list.x, list.y, list.w, 5, bg_color); //закрашиваем фон над первой строкой |
659 | if (top1>=list.y) && ( top1 < list.h+list.y-10) && (!anchor) |
||
4475 | leency | 660 | { |
4486 | leency | 661 | if (text_align == ALIGN_CENTER) DrawBuf.AlignCenter(left1,top1,list.w,list.line_h,stolbec * 6); |
662 | if (text_align == ALIGN_RIGHT) DrawBuf.AlignRight(left1,top1,list.w,list.line_h,stolbec * 6); |
||
663 | PutPaletteImage(buf_data+8, list.w, list.line_h, left1-5, top1, 32,0); |
||
4475 | leency | 664 | DrawBuf.Fill(bg_color); |
665 | } |
||
666 | stroka++; |
||
4544 | leency | 667 | if (blq_text) stolbec = 6; else stolbec = 0; |
4475 | leency | 668 | if (li_text) stolbec = li_tab * 5; |
4488 | leency | 669 | } |
670 | |||
671 | |||
672 | |||
673 | int isTag(dword text) |
||
674 | { |
||
675 | if (!strcmp(#tag,text)) return 1; else return 0; |
||
676 | }>>>>>=>=>>=15)>>>>>>>=>!--> |