Rev 8492 | Rev 8500 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8462 | leency | 1 | CANVAS canvas; |
2 | |||
8491 | leency | 3 | void TWebBrowser::RenderLine() |
8462 | leency | 4 | { |
5 | unsigned px; //paint x coordinate |
||
6 | unsigned pw; //paint y coordinate |
||
7 | dword pc; //paint color |
||
8 | int zoom; |
||
9 | |||
10 | if (style.title) |
||
11 | { |
||
8492 | leency | 12 | strncpy(#header, #linebuf, sizeof(TWebBrowser.header)-1); |
8462 | leency | 13 | strncat(#header, " - ", sizeof(TWebBrowser.header)-1); |
14 | strncat(#header, #version, sizeof(TWebBrowser.header)-1); |
||
8492 | leency | 15 | linebuf = 0; |
8462 | leency | 16 | return; |
17 | } |
||
18 | if (t_html) && (!t_body) { |
||
8492 | leency | 19 | linebuf = 0; |
8462 | leency | 20 | return; |
21 | } |
||
22 | |||
8492 | leency | 23 | if (linebuf) |
8462 | leency | 24 | { |
8492 | leency | 25 | pw = strlen(#linebuf) * list.font_w; |
8462 | leency | 26 | zoom = list.font_w / BASIC_CHAR_W; |
27 | |||
28 | style.cur_line_h = math.max(style.cur_line_h, list.item_h); |
||
29 | |||
30 | if (bg_colors.get_last() - bg_colors.get(0)) { |
||
31 | canvas.DrawBar(draw_x, draw_y, pw, list.item_h, bg_colors.get_last()); |
||
32 | } |
||
33 | |||
34 | if (style.image) { |
||
35 | canvas.DrawBar(draw_x, draw_y, pw, list.item_h-1, 0xF9DBCB); |
||
36 | } |
||
37 | if (style.button) { |
||
38 | canvas.DrawBar(draw_x, draw_y, pw, list.item_h - calc(zoom*2), 0xCCCccc); |
||
39 | canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2), pw, zoom, 0x999999); |
||
40 | } |
||
41 | |||
42 | pc = text_colors.get_last(); |
||
43 | if (link) && (pc == text_colors.get(0)) pc = link_color_default; |
||
44 | |||
8492 | leency | 45 | canvas.WriteText(draw_x, draw_y, list.font_type, pc, #linebuf, NULL); |
46 | if (style.b) canvas.WriteText(draw_x+1, draw_y, list.font_type, pc, #linebuf, NULL); |
||
8462 | leency | 47 | 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); |
||
49 | if (link) { |
||
8492 | leency | 50 | if (linebuf[0]==' ') && (linebuf[1]==NULL) {} else { |
8462 | leency | 51 | 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); |
||
53 | } |
||
54 | } |
||
55 | draw_x += pw; |
||
8492 | leency | 56 | if (debug_mode) debugln(#linebuf); |
8462 | leency | 57 | } |
8499 | leency | 58 | linebuf = NULL; |
8462 | leency | 59 | } |
60 | |||
8499 | leency | 61 | |
8491 | leency | 62 | void TWebBrowser::RenderTextbuf() |
63 | { |
||
64 | int break_pos; |
||
8499 | leency | 65 | char next_line[sizeof(TWebBrowser.linebuf)]; |
8491 | leency | 66 | int zoom = list.font_w / BASIC_CHAR_W; |
67 | |||
68 | //Do we need a line break? |
||
8492 | leency | 69 | while (strlen(#linebuf) * list.font_w + draw_x >= draw_w) { |
8491 | leency | 70 | //Yes, we do. Lets calculate where... |
8492 | leency | 71 | break_pos = strrchr(#linebuf, ' '); |
8491 | leency | 72 | |
73 | //Is a new line fits in the current line? |
||
74 | if (break_pos * list.font_w + draw_x > draw_w) { |
||
75 | break_pos = draw_w - draw_x /list.font_w; |
||
8499 | leency | 76 | while(break_pos) { |
77 | if (linebuf[break_pos]==' ') { |
||
78 | break_pos++; |
||
79 | break; |
||
80 | } |
||
81 | break_pos--; |
||
82 | } |
||
8491 | leency | 83 | } |
84 | //Maybe a new line is too big for the whole new line? Then we have to split it |
||
8492 | leency | 85 | if (!break_pos) && (style.tag_list.level*5 + strlen(#linebuf) * zoom >= list.column_max) { |
8491 | leency | 86 | break_pos = draw_w - draw_x / list.font_w; |
87 | } |
||
88 | |||
89 | |||
8499 | leency | 90 | if (break_pos) { |
91 | strlcpy(#next_line, #linebuf + break_pos, sizeof(next_line)); |
||
92 | linebuf[break_pos] = 0x00; |
||
93 | RenderLine(); |
||
94 | strlcpy(#linebuf, #next_line, sizeof(TWebBrowser.linebuf)); |
||
95 | NewLine(); |
||
96 | } else { |
||
97 | NewLine(); |
||
98 | RenderLine(); |
||
99 | } |
||
8491 | leency | 100 | } |
101 | RenderLine(); |
||
102 | } |
||
103 | |||
8462 | leency | 104 | bool TWebBrowser::RenderImage(dword cur_img) |
105 | { |
||
106 | int img_x, img_y, img_w, img_h; |
||
107 | dword imgbuf[44]; |
||
108 | |||
109 | if (!cur_img) return false; |
||
110 | |||
111 | img_h = ESDWORD[cur_img+8]; |
||
112 | img_w = ESDWORD[cur_img+4]; |
||
113 | |||
114 | if (img_w + draw_x >= draw_w) NewLine(); |
||
115 | img_y = draw_y; |
||
116 | if (img_h < list.item_h) img_y += list.item_h - img_h / 2 - 1; else img_y -= 2; |
||
117 | style.cur_line_h = math.max(style.cur_line_h, img_h); |
||
118 | |||
119 | img_w = math.min(img_w, canvas.bufw - draw_x); |
||
120 | |||
121 | if (link) links.add_text(draw_x + list.x, img_y + list.y, img_w, img_h, 0); |
||
122 | |||
123 | if (img_y + img_h >= canvas.bufh) canvas.IncreaseBufSize(); |
||
124 | |||
125 | if (ESDWORD[cur_img+20] != IMAGE_BPP32) { |
||
126 | img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0); |
||
127 | $push eax |
||
128 | img_destroy stdcall(cur_img); |
||
129 | $pop eax |
||
130 | cur_img = EAX; |
||
131 | if (!EAX) return false; |
||
132 | } |
||
133 | imgbuf[04] = canvas.bufw; |
||
134 | imgbuf[08] = canvas.bufh; |
||
135 | imgbuf[20] = IMAGE_BPP32; |
||
136 | imgbuf[24] = buf_data+8; |
||
137 | img_blend stdcall(#imgbuf, cur_img, draw_x, img_y, 0, 0, img_w, img_h); |
||
138 | img_destroy stdcall(cur_img); |
||
139 | |||
140 | draw_x += img_w; |
||
141 | if (draw_x >= draw_w) NewLine(); |
||
142 | return true; |
||
143 | }> |