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