Rev 6795 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6795 | Rev 6803 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | struct TWebBrowser { |
15 | struct TWebBrowser { |
16 | llist list; |
16 | llist list; |
17 | _style style; |
17 | _style style; |
18 | DrawBufer DrawBuf; |
18 | DrawBufer DrawBuf; |
- | 19 | int zoom; |
|
19 | void Prepare(); |
20 | void Prepare(); |
20 | void SetStyle(); |
21 | void SetStyle(); |
21 | void DrawStyle(); |
22 | void DrawStyle(); |
22 | void DrawPage(); |
23 | void DrawPage(); |
23 | void DrawScroller(); |
24 | void DrawScroller(); |
Line 60... | Line 61... | ||
60 | char tag[100]; |
61 | char tag[100]; |
61 | char oldtag[100]; |
62 | char oldtag[100]; |
62 | char attr[1200]; |
63 | char attr[1200]; |
63 | char val[4096]; |
64 | char val[4096]; |
64 | char anchor[256]=0; |
65 | |
65 | - | ||
Line 66... | Line 66... | ||
66 | #include "..\TWB\absolute_url.h" |
66 | #include "..\TWB\absolute_url.h" |
67 | #include "..\TWB\links.h" |
67 | #include "..\TWB\links.h" |
68 | #include "..\TWB\colors.h" |
68 | #include "..\TWB\colors.h" |
69 | #include "..\TWB\unicode_tags.h" |
69 | #include "..\TWB\unicode_tags.h" |
Line 73... | Line 73... | ||
73 | 73 | ||
74 | //============================================================================================ |
74 | //============================================================================================ |
75 | void TWebBrowser::DrawStyle() |
75 | void TWebBrowser::DrawStyle() |
76 | { |
76 | { |
Line 77... | Line 77... | ||
77 | int start_x, line_length, stolbec_len; |
77 | dword start_x, line_length, stolbec_len; |
78 | 78 | ||
79 | if (!header) |
79 | if (!header) |
80 | { |
80 | { |
81 | ChangeCharset("UTF-8", "CP866", #line); |
81 | ChangeCharset("UTF-8", "CP866", #line); |
82 | sprintf(#header, "%s - %s", #line, #version); |
82 | sprintf(#header, "%s - %s", #line, #version); |
83 | line = 0; |
83 | line = 0; |
84 | return; |
84 | return; |
Line 85... | Line 85... | ||
85 | } |
85 | } |
86 | if (t_html) && (!t_body) return; |
86 | if (t_html) && (!t_body) return; |
87 | 87 | ||
88 | if (line) && (!anchor) |
88 | if (line) |
89 | { |
89 | { |
Line 90... | Line 90... | ||
90 | start_x = stolbec * list.font_w + body_magrin + list.x; |
90 | start_x = stolbec * list.font_w + body_magrin + list.x; |
91 | stolbec_len = strlen(#line) * DrawBuf.zoom; |
91 | stolbec_len = strlen(#line) * zoom; |
92 | line_length = stolbec_len * list.font_w; |
92 | line_length = stolbec_len * list.font_w; |
93 | 93 | ||
94 | WriteBufText(start_x, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
94 | WriteBufText(start_x, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
95 | if (style.b) WriteBufText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
95 | if (style.b) WriteBufText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data); |
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]); |
96 | if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
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]); |
97 | if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
98 | if (link) { |
98 | if (link) { |
99 | DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(DrawBuf.zoom*2), line_length, DrawBuf.zoom, text_colors[text_color_index]); |
99 | DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, text_colors[text_color_index]); |
100 | PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(DrawBuf.zoom*2), UNDERLINE, DrawBuf.zoom); //TODO: set bigger underline_h for style.h |
100 | PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom); //TODO: set bigger underline_h for style.h |
101 | } |
101 | } |
Line 110... | Line 110... | ||
110 | } |
110 | } |
111 | //============================================================================================ |
111 | //============================================================================================ |
112 | void TWebBrowser::Prepare(){ |
112 | void TWebBrowser::Prepare(){ |
113 | word bukva[2]; |
113 | word bukva[2]; |
114 | int j; |
114 | dword j; |
115 | byte ignor_param; |
115 | byte ignor_param; |
116 | dword bufpos; |
116 | dword bufpos; |
117 | int line_len; |
117 | dword line_len; |
118 | style.b = style.u = style.s = style.h = style.blq = t_html = t_body = |
118 | style.b = style.u = style.s = style.h = style.blq = t_html = t_body = |
119 | style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0; |
119 | style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0; |
120 | style.align = ALIGN_LEFT; |
120 | style.align = ALIGN_LEFT; |
121 | link_color_inactive = 0x0000FF; |
121 | link_color_inactive = 0x0000FF; |
122 | link_color_active = 0xFF0000; |
122 | link_color_active = 0xFF0000; |
123 | bg_color = 0xFFFFFF; |
123 | bg_color = 0xFFFFFF; |
Line 126... | Line 126... | ||
126 | strcpy(#header, #version); |
126 | strcpy(#header, #version); |
127 | draw_y = body_magrin; |
127 | draw_y = body_magrin; |
128 | stolbec = 0; |
128 | stolbec = 0; |
129 | line = 0; |
129 | line = 0; |
130 | //for plaint text use CP866 for other UTF |
130 | zoom = 1; |
- | 131 | //for plaint text use CP866 for other UTF |
|
131 | if (strstri(bufpointer, "html")!=-1) |
132 | if (strstri(bufpointer, "html")!=-1) |
132 | { |
133 | { |
133 | debugln(" found"); |
134 | debugln(" found"); |
134 | style.pre = false; |
135 | style.pre = false; |
135 | cur_encoding = CH_NULL; |
136 | cur_encoding = CH_NULL; |
Line 224... | Line 225... | ||
224 | DrawStyle(); |
225 | DrawStyle(); |
225 | NewLine(); |
226 | NewLine(); |
226 | if (list.first == 0) list.count = draw_y; |
227 | if (list.first == 0) list.count = draw_y; |
227 | DrawPage(); |
228 | DrawPage(); |
228 | if (anchor) |
229 | } |
229 | { |
- | |
230 | anchor=NULL; |
- | |
231 | list.first = anchor_y; |
- | |
232 | Prepare(); |
- | |
233 | } |
- | |
234 | } |
- | |
235 | //============================================================================================ |
230 | //============================================================================================ |
236 | void TWebBrowser::Perenos() |
231 | void TWebBrowser::Perenos() |
237 | { |
232 | { |
238 | int perenos_num; |
233 | int perenos_num; |
239 | char new_line_text[4096]; |
234 | char new_line_text[4096]; |
240 | if (strlen(#line)*DrawBuf.zoom + stolbec < list.column_max) return; |
235 | if (strlen(#line)*zoom + stolbec < list.column_max) return; |
241 | perenos_num = strrchr(#line, ' '); |
236 | perenos_num = strrchr(#line, ' '); |
242 | if (!perenos_num) && (strlen(#line)*DrawBuf.zoom>list.column_max) perenos_num=list.column_max/DrawBuf.zoom; |
237 | if (!perenos_num) && (strlen(#line)*zoom>list.column_max) perenos_num=list.column_max/zoom; |
243 | strcpy(#new_line_text, #line + perenos_num); |
238 | strcpy(#new_line_text, #line + perenos_num); |
244 | line[perenos_num] = 0x00; |
239 | line[perenos_num] = 0x00; |
245 | DrawStyle(); |
240 | DrawStyle(); |
246 | strcpy(#line, #new_line_text); |
241 | strcpy(#line, #new_line_text); |
247 | NewLine(); |
242 | NewLine(); |
248 | } |
243 | } |
Line 275... | Line 270... | ||
275 | if (opened) strcat(#line, " \""); |
270 | if (opened) strcat(#line, " \""); |
276 | if (!opened) strcat(#line, "\" "); |
271 | if (!opened) strcat(#line, "\" "); |
277 | return; |
272 | return; |
278 | } |
273 | } |
279 | if (anchor) if (isattr("id=")) || (isattr("name=")) { //very bad: if the tag is not the last it wound work |
274 | //if (isattr("id=")) || (isattr("name=")) { //very bad: if the tag is not the last it wound work |
280 | if (!strcmp(#anchor, #val)) anchor_y=draw_y; |
275 | //add anchor |
281 | } |
276 | //} |
282 | if (istag("body")) { |
277 | if (istag("body")) { |
283 | t_body = opened; |
278 | t_body = opened; |
284 | do{ |
279 | do{ |
285 | if (isattr("link=")) link_color_inactive = GetColor(#val); |
280 | if (isattr("link=")) link_color_inactive = GetColor(#val); |
286 | if (isattr("alink=")) link_color_active = GetColor(#val); |
281 | if (isattr("alink=")) link_color_active = GetColor(#val); |
287 | if (isattr("text=")) text_colors[0]=GetColor(#val); |
282 | if (isattr("text=")) text_colors[0]=GetColor(#val); |
Line 351... | Line 346... | ||
351 | if (opened) |
346 | if (opened) |
352 | { |
347 | { |
353 | NewLine(); |
348 | NewLine(); |
354 | draw_y += 10; |
349 | draw_y += 10; |
355 | WB1.DrawBuf.zoom=2; |
350 | WB1.zoom=2; |
356 | WB1.list.font_type |= 10011001b; |
351 | WB1.list.font_type |= 10011001b; |
357 | if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; |
352 | if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; |
358 | if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; |
353 | if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; |
359 | list.item_h = basic_line_h * 2; |
354 | list.item_h = basic_line_h * 2; |
360 | } |
355 | } |
361 | else |
356 | else |
362 | { |
357 | { |
363 | NewLine(); |
358 | NewLine(); |
364 | WB1.DrawBuf.zoom=1; |
359 | WB1.zoom=1; |
365 | WB1.list.font_type = 10011000b; |
360 | WB1.list.font_type = 10011000b; |
366 | style.align = ALIGN_LEFT; |
361 | style.align = ALIGN_LEFT; |
367 | list.item_h = basic_line_h; |
362 | list.item_h = basic_line_h; |
368 | } |
363 | } |
369 | return; |
364 | return; |
370 | } |
365 | } |
Line 378... | Line 373... | ||
378 | style.li = opened; |
373 | style.li = opened; |
379 | if (opened) |
374 | if (opened) |
380 | { |
375 | { |
381 | NewLine(); |
376 | NewLine(); |
382 | DrawBuf.DrawBar(style.li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, |
377 | strcpy(#line, "\31 \0"); |
383 | list.item_h - calc(DrawBuf.zoom*2) /2 + draw_y, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x454545); |
378 | } |
384 | } |
- | |
385 | return; |
379 | return; |
386 | } |
380 | } |
387 | if (istag("ul")) || (istag("ol")) { |
381 | if (istag("ul")) || (istag("ol")) { |
388 | if (!opened) |
382 | if (!opened) |
389 | { |
383 | { |
Line 420... | Line 414... | ||
420 | return; |
414 | return; |
421 | } |
415 | } |
422 | } |
416 | } |
423 | 417 | ||
Line 424... | Line 418... | ||
424 | void TWebBrowser::BufEncode(int set_new_encoding) |
418 | void TWebBrowser::BufEncode(dword set_new_encoding) |
425 | { |
419 | { |
426 | int bufpointer_realsize; |
- | |
427 | if (o_bufpointer==0) |
420 | if (o_bufpointer==0) |
428 | { |
421 | { |
429 | o_bufpointer = malloc(bufsize); |
422 | o_bufpointer = malloc(bufsize); |
430 | strcpy(o_bufpointer, bufpointer); |
423 | strcpy(o_bufpointer, bufpointer); |
431 | } |
424 | } |
Line 454... | Line 447... | ||
454 | } |
447 | } |
455 | //============================================================================================ |
448 | //============================================================================================ |
456 | void TWebBrowser::NewLine() |
449 | void TWebBrowser::NewLine() |
457 | { |
450 | { |
458 | int onleft, ontop; |
451 | dword onleft, ontop; |
459 | 452 | ||
Line 460... | Line 453... | ||
460 | if (!stolbec) && (draw_y==body_magrin) return; |
453 | if (!stolbec) && (draw_y==body_magrin) return; |
Line 461... | Line 454... | ||
461 | 454 | ||
462 | onleft = list.x + body_magrin; |
455 | onleft = list.x + body_magrin; |
Line 466... | Line 459... | ||
466 | if (style.blq) stolbec = 6; else stolbec = 0; |
459 | if (style.blq) stolbec = 6; else stolbec = 0; |
467 | if (style.li) stolbec = style.li_tab * 5; |
460 | if (style.li) stolbec = style.li_tab * 5; |
468 | } |
461 | } |
469 | //============================================================================================ |
462 | //============================================================================================ |
470 | int istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; } |
463 | bool istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; } |
471 | int isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; } |
464 | bool isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; } |
472 | int isval(dword text) { if (!strcmp(#val,text)) return true; else return false; } |
465 | bool isval(dword text) { if (!strcmp(#val,text)) return true; else return false; } |
473 | //============================================================================================ |
466 | //============================================================================================ |
474 | void TWebBrowser::DrawPage() |
467 | void TWebBrowser::DrawPage() |
475 | { |
468 | { |
476 | PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0); |
469 | PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0); |
477 | DrawScroller(); |
470 | DrawScroller(); |
478 | }>>=15)>>>=>': |
471 | }>>=15)>>>=>': |