Rev 8499 | Rev 9103 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8499 | Rev 8500 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | CANVAS canvas; |
1 | CANVAS canvas; |
Line 2... | Line 2... | ||
2 | 2 | ||
3 | void TWebBrowser::RenderLine() |
3 | void TWebBrowser::RenderLine(dword _line) |
4 | { |
4 | { |
5 | unsigned px; //paint x coordinate |
5 | unsigned px; //paint x coordinate |
6 | unsigned pw; //paint y coordinate |
6 | unsigned pw; //paint y coordinate |
7 | dword pc; //paint color |
7 | dword pc; //paint color |
Line 8... | Line 8... | ||
8 | int zoom; |
8 | int zoom; |
9 | 9 | ||
10 | if (style.title) |
10 | if (style.title) |
11 | { |
11 | { |
12 | strncpy(#header, #linebuf, sizeof(TWebBrowser.header)-1); |
12 | strncpy(#header, _line, sizeof(TWebBrowser.header)-1); |
13 | strncat(#header, " - ", sizeof(TWebBrowser.header)-1); |
- | |
14 | strncat(#header, #version, sizeof(TWebBrowser.header)-1); |
- | |
15 | linebuf = 0; |
13 | strncat(#header, " - ", sizeof(TWebBrowser.header)-1); |
16 | return; |
14 | strncat(#header, #version, sizeof(TWebBrowser.header)-1); |
17 | } |
- | |
18 | if (t_html) && (!t_body) { |
15 | } |
19 | linebuf = 0; |
16 | else if (t_html) && (!t_body) { |
20 | return; |
- | |
21 | } |
17 | // |
22 | 18 | } |
|
23 | if (linebuf) |
19 | else if (ESBYTE[_line]) |
24 | { |
20 | { |
Line -... | Line 21... | ||
- | 21 | pw = strlen(_line) * list.font_w; |
|
- | 22 | zoom = list.font_w / BASIC_CHAR_W; |
|
- | 23 | ||
- | 24 | if (pw > draw_w) { |
|
- | 25 | draw_w = pw; |
|
- | 26 | NewLine(); |
|
- | 27 | } |
|
- | 28 | ||
- | 29 | if (debug_mode) { |
|
- | 30 | canvas.DrawBar(draw_x, draw_y, pw, list.item_h, 0xCCCccc); |
|
25 | pw = strlen(#linebuf) * list.font_w; |
31 | debugln(_line); |
Line 26... | Line 32... | ||
26 | zoom = list.font_w / BASIC_CHAR_W; |
32 | } |
27 | 33 | ||
28 | style.cur_line_h = math.max(style.cur_line_h, list.item_h); |
34 | style.cur_line_h = math.max(style.cur_line_h, list.item_h); |
Line 40... | Line 46... | ||
40 | } |
46 | } |
Line 41... | Line 47... | ||
41 | 47 | ||
42 | pc = text_colors.get_last(); |
48 | pc = text_colors.get_last(); |
Line 43... | Line 49... | ||
43 | if (link) && (pc == text_colors.get(0)) pc = link_color_default; |
49 | if (link) && (pc == text_colors.get(0)) pc = link_color_default; |
44 | 50 | ||
45 | canvas.WriteText(draw_x, draw_y, list.font_type, pc, #linebuf, NULL); |
51 | canvas.WriteText(draw_x, draw_y, list.font_type, pc, _line, NULL); |
46 | if (style.b) canvas.WriteText(draw_x+1, draw_y, list.font_type, pc, #linebuf, NULL); |
52 | if (style.b) canvas.WriteText(draw_x+1, draw_y, list.font_type, pc, _line, NULL); |
47 | if (style.s) canvas.DrawBar(draw_x, list.item_h / 2 - zoom + draw_y, pw, zoom, pc); |
53 | if (style.s) canvas.DrawBar(draw_x, list.item_h / 2 - zoom + draw_y, pw, zoom, pc); |
48 | if (style.u) canvas.DrawBar(draw_x, list.item_h - zoom - zoom + draw_y, pw, zoom, pc); |
54 | if (style.u) canvas.DrawBar(draw_x, list.item_h - zoom - zoom + draw_y, pw, zoom, pc); |
49 | if (link) { |
55 | if (link) { |
50 | if (linebuf[0]==' ') && (linebuf[1]==NULL) {} else { |
56 | if (ESBYTE[_line]==' ') && (ESBYTE[_line+1]==NULL) {} else { |
51 | canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2)-1, pw, zoom, link_color_default); |
57 | canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2)-1, pw, zoom, link_color_default); |
52 | links.add_text(draw_x, draw_y + list.y, pw, list.item_h - calc(zoom*2)-1, zoom); |
58 | links.add_text(draw_x, draw_y + list.y, pw, list.item_h - calc(zoom*2)-1, zoom); |
53 | } |
59 | } |
54 | } |
- | |
55 | draw_x += pw; |
60 | } |
56 | if (debug_mode) debugln(#linebuf); |
61 | draw_x += pw; |
57 | } |
62 | } |
Line 58... | Line -... | ||
58 | linebuf = NULL; |
- | |
59 | } |
63 | ESBYTE[_line] = NULL; |
60 | 64 | } |
|
- | 65 | ||
61 | 66 | void TWebBrowser::RenderTextbuf() |
|
62 | void TWebBrowser::RenderTextbuf() |
67 | { |
63 | { |
68 | dword lbp = #linebuf; |
Line 64... | Line 69... | ||
64 | int break_pos; |
69 | int br; //break position |
65 | char next_line[sizeof(TWebBrowser.linebuf)]; |
70 | char nul = '\0'; |
66 | int zoom = list.font_w / BASIC_CHAR_W; |
71 | int len; |
67 | 72 | ||
Line 68... | Line 73... | ||
68 | //Do we need a line break? |
73 | //Do we need a line break? |
69 | while (strlen(#linebuf) * list.font_w + draw_x >= draw_w) { |
74 | while (len = strlen(lbp)) && (len * list.font_w + draw_x >= draw_w) { |
70 | //Yes, we do. Lets calculate where... |
75 | //Yes, we do. Lets calculate where... |
71 | break_pos = strrchr(#linebuf, ' '); |
76 | br = strrchr(lbp, ' '); |
72 | 77 | ||
73 | //Is a new line fits in the current line? |
78 | //Is a new line fits in the current line? |
74 | if (break_pos * list.font_w + draw_x > draw_w) { |
79 | if (br * list.font_w + draw_x >= draw_w) { |
75 | break_pos = draw_w - draw_x /list.font_w; |
80 | br = draw_w - draw_x /list.font_w; |
76 | while(break_pos) { |
81 | while(br) { |
77 | if (linebuf[break_pos]==' ') { |
82 | if (ESBYTE[lbp + br]==' ') { |
78 | break_pos++; |
83 | br++; |
79 | break; |
84 | break; |
80 | } |
85 | } |
81 | break_pos--; |
86 | br--; |
82 | } |
87 | } |
Line 83... | Line -... | ||
83 | } |
- | |
84 | //Maybe a new line is too big for the whole new line? Then we have to split it |
88 | } |
85 | if (!break_pos) && (style.tag_list.level*5 + strlen(#linebuf) * zoom >= list.column_max) { |
- | |
86 | break_pos = draw_w - draw_x / list.font_w; |
89 | //Maybe a new line is too big for the whole new line? Then we have to split it |
87 | } |
90 | if (!br) && (len * list.font_w >= draw_w) { |
- | 91 | br = draw_w - draw_x / list.font_w; |
|
- | 92 | } |
|
88 | 93 | ||
89 | 94 | if (br) { |
|
90 | if (break_pos) { |
95 | ESBYTE[lbp + br] >< nul; |
91 | strlcpy(#next_line, #linebuf + break_pos, sizeof(next_line)); |
96 | RenderLine(lbp); |
92 | linebuf[break_pos] = 0x00; |
97 | ESBYTE[lbp + br] >< nul; |
93 | RenderLine(); |
98 | lbp += br; |
94 | strlcpy(#linebuf, #next_line, sizeof(TWebBrowser.linebuf)); |
99 | while (ESBYTE[lbp]==' ') && (ESBYTE[lbp]) lbp++; |
95 | NewLine(); |
100 | if (ESBYTE[lbp]) NewLine(); |
- | 101 | } else { |
|
- | 102 | NewLine(); |
|
- | 103 | RenderLine(lbp); |
|
- | 104 | } |
|
- | 105 | } |
|
- | 106 | RenderLine(lbp); |
|
- | 107 | } |
|
- | 108 | ||
- | 109 | void TWebBrowser::NewLine() |
|
- | 110 | { |
|
- | 111 | static bool empty_line = true; |
|
- | 112 | ||
- | 113 | if (draw_x==left_gap) && (draw_y==BODY_MARGIN) return; |
|
- | 114 | if (t_html) && (!t_body) return; |
|
- | 115 | ||
- | 116 | if (draw_x == style.tag_list.level * 5 * list.font_w + left_gap) { |
|
- | 117 | if (!empty_line) empty_line=true; else return; |
|
- | 118 | } else { |
|
- | 119 | empty_line = false; |
|
96 | } else { |
120 | } |
Line 97... | Line 121... | ||
97 | NewLine(); |
121 | |
98 | RenderLine(); |
122 | draw_y += style.cur_line_h; |
99 | } |
123 | style.cur_line_h = list.item_h; |