Rev 6783 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6783 | Rev 6794 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | 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}; |
- | |
2 | 1 | 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}; |
|
Line 3... | Line 2... | ||
3 | enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; |
2 | |
Line 4... | Line 3... | ||
4 | 3 | enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; |
|
5 | struct _style { |
4 | |
6 | byte |
5 | struct _style { |
7 | b, i, u, s, h, |
6 | byte |
8 | pre, |
7 | b, u, s, h, |
9 | blq, |
8 | pre, |
10 | li, |
9 | blq, |
11 | li_tab, |
10 | li, |
Line 45... | Line 44... | ||
45 | dword link_color_active; |
44 | dword link_color_inactive; |
46 | dword bg_color; |
45 | dword link_color_active; |
47 | 46 | dword bg_color; |
|
48 | int stroka; |
47 | |
Line 49... | Line 48... | ||
49 | int stolbec; |
48 | int draw_y; |
50 | int tab_len; |
49 | int stolbec; |
51 | int anchor_line_num; |
50 | int tab_len; |
52 | 51 | int anchor_y; |
|
- | 52 | ||
- | 53 | int body_magrin=5; |
|
- | 54 | int basic_line_h=22; |
|
Line 53... | Line 55... | ||
53 | char URL[10000]; |
55 | |
54 | char header[2048]; |
56 | char URL[10000]; |
55 | char line[500]; |
57 | char header[2048]; |
56 | char tagparam[10000]; |
58 | char line[500]; |
Line 71... | Line 73... | ||
71 | //============================================================================================ |
73 | |
72 | void TWebBrowser::DrawStyle() |
74 | //============================================================================================ |
73 | { |
75 | void TWebBrowser::DrawStyle() |
74 | int start_x, start_y, line_length, stolbec_len, body_magrin=5; |
76 | { |
Line 75... | Line 77... | ||
75 | 77 | int start_x, line_length, stolbec_len; |
|
76 | if (!header) |
78 | |
77 | { |
79 | if (!header) |
78 | ChangeCharset("UTF-8", "CP866", #line); |
- | |
79 | strcpy(#header, #line); |
- | |
80 | strcat(#header, " - "); |
80 | { |
81 | strcat(#header, #version); |
81 | ChangeCharset("UTF-8", "CP866", #line); |
82 | line = 0; |
82 | sprintf(#header, "%s - %s", #line, #version); |
83 | return; |
83 | line = 0; |
84 | } |
84 | return; |
Line 85... | Line 85... | ||
85 | if (t_html) && (!t_body) return; |
85 | } |
86 | 86 | if (t_html) && (!t_body) return; |
|
87 | if (line) && (!anchor) |
87 | |
88 | { |
- | |
89 | start_x = stolbec * list.font_w + body_magrin * DrawBuf.zoom + list.x; |
88 | if (line) && (!anchor) |
90 | start_y = stroka * list.item_h + body_magrin; |
89 | { |
Line 91... | Line -... | ||
91 | stolbec_len = strlen(#line) * DrawBuf.zoom; |
- | |
92 | line_length = stolbec_len * list.font_w; |
90 | start_x = stolbec * list.font_w + body_magrin + list.x; |
93 | 91 | stolbec_len = strlen(#line) * DrawBuf.zoom; |
|
94 | if (style.h) stroka++; |
- | |
95 | WriteBufText(start_x, start_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
92 | line_length = stolbec_len * list.font_w; |
96 | if (style.b) WriteBufText(start_x+1, start_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
93 | |
97 | if (style.i) { stolbec++; DrawBuf.Skew(start_x, start_y, line_length, list.item_h); } // bug with zoom>1 |
94 | WriteBufText(start_x, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
98 | if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
95 | if (style.b) WriteBufText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
99 | if (style.u) DrawBuf.DrawBar(start_x, list.item_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
96 | if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - DrawBuf.zoom + draw_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
100 | if (link) { |
97 | if (style.u) DrawBuf.DrawBar(start_x, list.item_h - DrawBuf.zoom - DrawBuf.zoom + draw_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
101 | DrawBuf.DrawBar(start_x, list.item_h*style.h + list.item_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
98 | if (link) { |
102 | PageLinks.AddText(#line, line_length, list.item_h*style.h + list.item_h, UNDERLINE); |
99 | DrawBuf.DrawBar(start_x, draw_y + list.item_h - 2, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
103 | } |
100 | PageLinks.AddText(line_length, list.item_h - 2, UNDERLINE, 1, #line); //TODO: set bigger underline_h for style.h |
104 | stolbec += stolbec_len; |
101 | } |
Line 117... | Line 114... | ||
117 | byte ignor_param; |
114 | int j; |
118 | dword bufpos; |
115 | byte ignor_param; |
119 | int line_len; |
116 | dword bufpos; |
120 | style.b = style.i = style.u = style.s = style.h = style.blq = t_html = t_body = |
117 | int line_len; |
121 | style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0; |
118 | style.b = style.u = style.s = style.h = style.blq = t_html = t_body = |
122 | style.align = ALIGN_LEFT; |
119 | style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0; |
123 | link_color_inactive = 0x0000FF; |
120 | style.align = ALIGN_LEFT; |
124 | link_color_active = 0xFF0000; |
121 | link_color_inactive = 0x0000FF; |
125 | bg_color = 0xFFFFFF; |
122 | link_color_active = 0xFF0000; |
126 | DrawBuf.Fill(bg_color); |
123 | bg_color = 0xFFFFFF; |
127 | PageLinks.Clear(); |
124 | DrawBuf.Fill(bg_color); |
128 | strcpy(#header, #version); |
125 | PageLinks.Clear(); |
129 | stroka = -list.first; |
126 | strcpy(#header, #version); |
130 | stolbec = 0; |
127 | draw_y = body_magrin; |
131 | line = 0; |
128 | stolbec = 0; |
132 | //for plaint text use CP866 for other UTF |
129 | line = 0; |
133 | if (strstri(bufpointer, "html")!=-1) |
130 | //for plaint text use CP866 for other UTF |
134 | { |
131 | if (strstri(bufpointer, "html")!=-1) |
135 | debugln(" found"); |
132 | { |
136 | style.pre = false; |
133 | debugln(" found"); |
Line 225... | Line 222... | ||
225 | } |
222 | } |
226 | DrawStyle(); |
223 | } |
227 | NewLine(); |
224 | DrawStyle(); |
228 | if (list.first == 0) list.count = stroka; |
225 | NewLine(); |
229 | DrawPage(); |
226 | if (list.first == 0) list.count = draw_y; |
230 | if (anchor) |
227 | DrawPage(); |
231 | { |
228 | if (anchor) |
232 | anchor=NULL; |
229 | { |
233 | list.first=anchor_line_num; |
230 | anchor=NULL; |
234 | Prepare(); |
231 | list.first = anchor_y; |
235 | } |
232 | Prepare(); |
236 | } |
233 | } |
237 | //============================================================================================ |
234 | } |
238 | void TWebBrowser::Perenos() |
235 | //============================================================================================ |
239 | { |
236 | void TWebBrowser::Perenos() |
240 | int perenos_num; |
237 | { |
Line 250... | Line 247... | ||
250 | } |
247 | NewLine(); |
251 | //============================================================================================ |
248 | } |
252 | void TWebBrowser::SetStyle() { |
249 | //============================================================================================ |
253 | int left1 = 5 + list.x; |
250 | void TWebBrowser::SetStyle() { |
254 | int top1 = stroka * list.item_h + list.y + 5; |
251 | int left1 = body_magrin + list.x; |
255 | byte opened; |
252 | byte opened; |
256 | byte meta_encoding; |
- | |
257 | if (tag[0] == '/') |
253 | byte meta_encoding; |
258 | { |
254 | if (tag[0] == '/') |
259 | opened = 0; |
255 | { |
260 | strcpy(#tag, #tag+1); |
256 | opened = 0; |
261 | } |
257 | strcpy(#tag, #tag+1); |
Line 268... | Line 264... | ||
268 | if (istag("form")) if (!opened) ignor_text = false; |
264 | if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) { ignor_text = opened; return; } |
269 | if(istag("title")) { |
265 | if (istag("form")) if (!opened) ignor_text = false; |
270 | if (opened) header=NULL; |
266 | if(istag("title")) { |
271 | else if (!stroka) DrawTitle(#header); |
267 | if (opened) header=NULL; |
272 | return; |
268 | else DrawTitle(#header); |
273 | } |
269 | return; |
274 | if (ignor_text) return; |
270 | } |
275 | 271 | if (ignor_text) return; |
|
276 | IF(istag("q")) |
272 | |
Line 277... | Line 273... | ||
277 | { |
273 | IF(istag("q")) |
Line 280... | Line 276... | ||
280 | return; |
276 | if (!opened) strcat(#line, "\" "); |
281 | } |
277 | return; |
282 | if (anchor) if (isattr("id=")) || (isattr("name=")) { //very bad: if the tag is not the last it wound work |
278 | } |
283 | if (!strcmp(#anchor, #val)) anchor_line_num=list.first+stroka; |
279 | if (anchor) if (isattr("id=")) || (isattr("name=")) { //very bad: if the tag is not the last it wound work |
284 | } |
280 | if (!strcmp(#anchor, #val)) anchor_y=draw_y; |
285 | if (istag("body")) { |
281 | } |
286 | t_body = opened; |
282 | if (istag("body")) { |
287 | do{ |
283 | t_body = opened; |
288 | if (isattr("link=")) link_color_inactive = GetColor(#val); |
284 | do{ |
289 | if (isattr("alink=")) link_color_active = GetColor(#val); |
285 | if (isattr("link=")) link_color_inactive = GetColor(#val); |
290 | if (isattr("text=")) text_colors[0]=GetColor(#val); |
286 | if (isattr("alink=")) link_color_active = GetColor(#val); |
Line 308... | Line 304... | ||
308 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
304 | text_color_index++; |
309 | link = 1; |
305 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
310 | text_colors[text_color_index] = link_color_inactive; |
306 | link = 1; |
311 | PageLinks.AddLink(#val, DrawBuf.zoom * stolbec * list.font_w + left1, top1-DrawBuf.zoom); |
307 | text_colors[text_color_index] = link_color_inactive; |
312 | } |
308 | PageLinks.AddLink(#val, DrawBuf.zoom * stolbec * list.font_w + left1, draw_y + list.y); |
313 | } while(GetNextParam()); |
309 | } |
314 | } |
310 | } while(GetNextParam()); |
315 | else { |
311 | } |
316 | link = 0; |
312 | else { |
317 | IF(text_color_index > 0) text_color_index--; |
313 | link = 0; |
318 | } |
314 | IF(text_color_index > 0) text_color_index--; |
Line 343... | Line 339... | ||
343 | if (istag("br")) { NewLine(); return; } |
339 | } |
344 | if (istag("tr")) { if (opened) NewLine(); return; } |
340 | if (istag("br")) { NewLine(); return; } |
345 | if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; } |
341 | if (istag("tr")) { if (opened) NewLine(); return; } |
346 | if (istag("i")) || (istag("em")) || (istag("subtitle")) { style.i=opened; return; } |
342 | if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; } |
347 | if (istag("u")) || (istag("ins")) { style.u=opened; return;} |
343 | if (istag("u")) || (istag("ins")) { style.u=opened; return;} |
348 | if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; } |
- | |
349 | if (istag("dd")) { stolbec += 5; return; } |
344 | if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; } |
350 | if (istag("blockquote")) { style.blq = opened; return; } |
345 | if (istag("dd")) { stolbec += 5; return; } |
351 | if (istag("pre")) || (istag("code")) { style.pre = opened; return; } |
346 | if (istag("blockquote")) { style.blq = opened; return; } |
352 | if (istag("img")) { ImgCache.Images( left1, top1, WB1.list.w); return; } |
347 | if (istag("pre")) || (istag("code")) { style.pre = opened; return; } |
353 | if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) || (istag("caption")) { |
348 | if (istag("img")) { ImgCache.Images( left1, draw_y, WB1.list.w); return; } |
354 | style.h = opened; |
349 | if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) || (istag("caption")) { |
355 | NewLine(); |
350 | style.h = opened; |
356 | if (opened) |
351 | if (opened) |
357 | { |
- | |
358 | WB1.DrawBuf.zoom=2; |
352 | { |
359 | WB1.list.font_type |= 10011001b; |
353 | NewLine(); |
- | 354 | draw_y += 10; |
|
- | 355 | WB1.DrawBuf.zoom=2; |
|
360 | if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; |
356 | WB1.list.font_type |= 10011001b; |
361 | if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; |
357 | if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; |
362 | if (stroka>1) NewLine(); |
358 | if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; |
363 | } |
359 | list.item_h = basic_line_h * 2; |
364 | else |
360 | } |
365 | { |
361 | else |
366 | WB1.DrawBuf.zoom=1; |
362 | { |
367 | WB1.list.font_type = 10011000b; |
363 | NewLine(); |
- | 364 | WB1.DrawBuf.zoom=1; |
|
368 | style.align = ALIGN_LEFT; |
365 | WB1.list.font_type = 10011000b; |
369 | } |
366 | style.align = ALIGN_LEFT; |
370 | return; |
367 | list.item_h = basic_line_h; |
- | 368 | } |
|
371 | } |
369 | return; |
372 | if (istag("dt")) { |
370 | } |
373 | style.li = opened; |
371 | if (istag("dt")) { |
374 | if (opened) NewLine(); |
372 | style.li = opened; |
375 | return; |
373 | if (opened) NewLine(); |
Line 380... | Line 378... | ||
380 | if (opened) |
378 | style.li = opened; |
381 | { |
379 | if (opened) |
382 | NewLine(); |
380 | { |
383 | DrawBuf.DrawBar(style.li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, stroka +1 * list.item_h - 3 |
381 | NewLine(); |
384 | - DrawBuf.zoom - DrawBuf.zoom, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x454545); |
382 | DrawBuf.DrawBar(style.li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, |
385 | } |
383 | list.item_h - calc(DrawBuf.zoom*2) /2 + draw_y, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x454545); |
386 | return; |
384 | } |
387 | } |
385 | return; |
388 | if (istag("ul")) || (istag("ol")) { |
386 | } |
389 | if (!opened) |
387 | if (istag("ul")) || (istag("ol")) { |
390 | { |
388 | if (!opened) |
391 | style.li = opened; |
389 | { |
Line 399... | Line 397... | ||
399 | $push edi; |
397 | if (isattr("color=")) EDI = GetColor(#val); else EDI = 0x999999; |
400 | NewLine(); |
398 | $push edi; |
401 | $pop edi; |
399 | NewLine(); |
402 | DrawBuf.DrawBar(5, list.item_h*stroka+4, list.w-10, 1, EDI); |
400 | $pop edi; |
403 | NewLine(); |
401 | DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI); |
404 | return; |
402 | NewLine(); |
405 | } |
403 | return; |
406 | if (istag("meta")) || (istag("?xml")) { |
404 | } |
407 | meta_encoding = CH_NULL; |
405 | if (istag("meta")) || (istag("?xml")) { |
408 | do{ |
406 | meta_encoding = CH_NULL; |
409 | if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding=")) |
407 | do{ |
Line 446... | Line 444... | ||
446 | scroll_wv.max_area = list.count; |
444 | { |
447 | scroll_wv.cur_area = list.visible; |
445 | scroll_wv.max_area = list.count; |
448 | scroll_wv.position = list.first; |
446 | scroll_wv.cur_area = list.visible; |
449 | 447 | scroll_wv.position = list.first; |
|
450 | scroll_wv.all_redraw = 0; |
448 | scroll_wv.all_redraw = 0; |
451 | scroll_wv.start_x = list.x + list.w; |
- | |
452 | scroll_wv.start_y = list.y; |
449 | scroll_wv.start_x = list.x + list.w; |
453 | 450 | scroll_wv.start_y = list.y; |
|
454 | scroll_wv.size_y = list.h; |
451 | scroll_wv.size_y = list.h; |
455 | scroll_wv.start_x = list.w * DrawBuf.zoom + list.x; |
- | |
456 | 452 | scroll_wv.start_x = list.w + list.x; |
|
457 | scrollbar_v_draw(#scroll_wv); |
453 | scrollbar_v_draw(#scroll_wv); |
458 | } |
- | |
459 | //============================================================================================ |
454 | } |
460 | void TWebBrowser::NewLine() |
455 | //============================================================================================ |
461 | { |
456 | void TWebBrowser::NewLine() |
462 | int onleft, ontop; |
457 | { |
463 | 458 | int onleft, ontop; |
|
464 | onleft = list.x + 5; |
459 | |
Line -... | Line 460... | ||
- | 460 | if (!stolbec) && (draw_y==body_magrin) return; |
|
- | 461 | ||
465 | ontop = stroka * list.item_h + list.y + 5; |
462 | onleft = list.x + body_magrin; |
466 | if (t_html) && (!t_body) return; |
463 | ontop = draw_y + list.y; |
467 | if (stroka * list.item_h + 5 >= 0) && ( stroka + 1 * list.item_h + 5 < list.h) && (!anchor) |
464 | if (t_html) && (!t_body) return; |
468 | { |
- | |
469 | if (style.align == ALIGN_CENTER) && (DrawBuf.zoom==1) DrawBuf.AlignCenter(onleft,ontop,list.w,list.item_h,stolbec * list.font_w); |
- | |
470 | if (style.align == ALIGN_RIGHT) && (DrawBuf.zoom==1) DrawBuf.AlignRight(onleft,ontop,list.w,list.item_h,stolbec * list.font_w); |
- | |
471 | } |
- | |
472 | stroka++; |
- | |
473 | if (style.blq) stolbec = 6; else stolbec = 0; |
465 | draw_y += list.item_h; |
474 | if (style.li) stolbec = style.li_tab * 5; |
466 | if (style.blq) stolbec = 6; else stolbec = 0; |
475 | } |
467 | if (style.li) stolbec = style.li_tab * 5; |
476 | //============================================================================================ |
468 | } |
477 | int istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; } |
469 | //============================================================================================ |
478 | int isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; } |
470 | int istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; } |
479 | int isval(dword text) { if (!strcmp(#val,text)) return true; else return false; } |
471 | int isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; } |
480 | //============================================================================================ |
472 | int isval(dword text) { if (!strcmp(#val,text)) return true; else return false; } |
481 | void TWebBrowser::DrawPage() |
473 | //============================================================================================ |
482 | { |
474 | void TWebBrowser::DrawPage() |
483 | PutPaletteImage(list.first * list.item_h * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0); |
475 | { |
484 | DrawScroller(); |
476 | PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0); |
485 | }>>>=15)>>>=>': |
477 | DrawScroller(); |
486 | >7);>>')>> |
478 | }>>=15)>>>=>': |
487 | 479 | >7);>>')>> |