Rev 8500 | Rev 9294 | 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 | |||
8500 | leency | 3 | void TWebBrowser::RenderLine(dword _line) |
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 | { |
||
8500 | leency | 12 | strncpy(#header, _line, sizeof(TWebBrowser.header)-1); |
8462 | leency | 13 | strncat(#header, " - ", sizeof(TWebBrowser.header)-1); |
14 | strncat(#header, #version, sizeof(TWebBrowser.header)-1); |
||
15 | } |
||
8500 | leency | 16 | else if (t_html) && (!t_body) { |
17 | // |
||
8462 | leency | 18 | } |
8500 | leency | 19 | else if (ESBYTE[_line]) |
8462 | leency | 20 | { |
8500 | leency | 21 | pw = strlen(_line) * list.font_w; |
8462 | leency | 22 | zoom = list.font_w / BASIC_CHAR_W; |
23 | |||
9103 | leency | 24 | //there is some shit happens!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
8500 | leency | 25 | if (pw > draw_w) { |
9103 | leency | 26 | //draw_w = pw; |
8500 | leency | 27 | NewLine(); |
28 | } |
||
29 | |||
30 | if (debug_mode) { |
||
31 | canvas.DrawBar(draw_x, draw_y, pw, list.item_h, 0xCCCccc); |
||
32 | debugln(_line); |
||
33 | } |
||
34 | |||
8462 | leency | 35 | style.cur_line_h = math.max(style.cur_line_h, list.item_h); |
36 | |||
9103 | leency | 37 | if (!secondrun) goto _SKIP_DRAW; |
8462 | leency | 38 | if (bg_colors.get_last() - bg_colors.get(0)) { |
39 | canvas.DrawBar(draw_x, draw_y, pw, list.item_h, bg_colors.get_last()); |
||
40 | } |
||
41 | |||
42 | if (style.image) { |
||
43 | canvas.DrawBar(draw_x, draw_y, pw, list.item_h-1, 0xF9DBCB); |
||
44 | } |
||
45 | if (style.button) { |
||
46 | canvas.DrawBar(draw_x, draw_y, pw, list.item_h - calc(zoom*2), 0xCCCccc); |
||
47 | canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2), pw, zoom, 0x999999); |
||
48 | } |
||
49 | |||
50 | pc = text_colors.get_last(); |
||
51 | if (link) && (pc == text_colors.get(0)) pc = link_color_default; |
||
52 | |||
8500 | leency | 53 | canvas.WriteText(draw_x, draw_y, list.font_type, pc, _line, NULL); |
54 | if (style.b) canvas.WriteText(draw_x+1, draw_y, list.font_type, pc, _line, NULL); |
||
8462 | leency | 55 | if (style.s) canvas.DrawBar(draw_x, list.item_h / 2 - zoom + draw_y, pw, zoom, pc); |
56 | if (style.u) canvas.DrawBar(draw_x, list.item_h - zoom - zoom + draw_y, pw, zoom, pc); |
||
57 | if (link) { |
||
8500 | leency | 58 | if (ESBYTE[_line]==' ') && (ESBYTE[_line+1]==NULL) {} else { |
8462 | leency | 59 | canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2)-1, pw, zoom, link_color_default); |
60 | links.add_text(draw_x, draw_y + list.y, pw, list.item_h - calc(zoom*2)-1, zoom); |
||
61 | } |
||
62 | } |
||
9103 | leency | 63 | _SKIP_DRAW: |
8462 | leency | 64 | draw_x += pw; |
65 | } |
||
8500 | leency | 66 | ESBYTE[_line] = NULL; |
8462 | leency | 67 | } |
68 | |||
8491 | leency | 69 | void TWebBrowser::RenderTextbuf() |
70 | { |
||
8500 | leency | 71 | dword lbp = #linebuf; |
72 | int br; //break position |
||
73 | char nul = '\0'; |
||
74 | int len; |
||
8491 | leency | 75 | |
76 | //Do we need a line break? |
||
9103 | leency | 77 | |
78 | while (len = strlen(lbp)) && (len * list.font_w + draw_x - left_gap >= draw_w) { |
||
8491 | leency | 79 | //Yes, we do. Lets calculate where... |
9103 | leency | 80 | br = len; |
8491 | leency | 81 | |
9103 | leency | 82 | //debugln(" \\n"); |
83 | |||
8491 | leency | 84 | //Is a new line fits in the current line? |
9103 | leency | 85 | if (br * list.font_w + draw_x - left_gap >= draw_w) { |
86 | br = draw_w - draw_x + left_gap /list.font_w; |
||
8500 | leency | 87 | while(br) { |
88 | if (ESBYTE[lbp + br]==' ') { |
||
89 | br++; |
||
8499 | leency | 90 | break; |
91 | } |
||
8500 | leency | 92 | br--; |
8499 | leency | 93 | } |
8491 | leency | 94 | } |
95 | //Maybe a new line is too big for the whole new line? Then we have to split it |
||
8500 | leency | 96 | if (!br) && (len * list.font_w >= draw_w) { |
97 | br = draw_w - draw_x / list.font_w; |
||
8491 | leency | 98 | } |
99 | |||
8500 | leency | 100 | if (br) { |
101 | ESBYTE[lbp + br] >< nul; |
||
102 | RenderLine(lbp); |
||
103 | ESBYTE[lbp + br] >< nul; |
||
104 | lbp += br; |
||
105 | while (ESBYTE[lbp]==' ') && (ESBYTE[lbp]) lbp++; |
||
106 | if (ESBYTE[lbp]) NewLine(); |
||
8499 | leency | 107 | } else { |
108 | NewLine(); |
||
8500 | leency | 109 | RenderLine(lbp); |
8499 | leency | 110 | } |
8491 | leency | 111 | } |
8500 | leency | 112 | RenderLine(lbp); |
8491 | leency | 113 | } |
114 | |||
8500 | leency | 115 | void TWebBrowser::NewLine() |
116 | { |
||
117 | static bool empty_line = true; |
||
118 | |||
119 | if (draw_x==left_gap) && (draw_y==BODY_MARGIN) return; |
||
120 | if (t_html) && (!t_body) return; |
||
121 | |||
122 | if (draw_x == style.tag_list.level * 5 * list.font_w + left_gap) { |
||
123 | if (!empty_line) empty_line=true; else return; |
||
124 | } else { |
||
125 | empty_line = false; |
||
126 | } |
||
127 | |||
128 | draw_y += style.cur_line_h; |
||
129 | style.cur_line_h = list.item_h; |
||
130 | if (style.blq) draw_x = 6 * list.font_w; else draw_x = 0; //left_gap += style.tag_list.level * 5 * list.font_w ??? |
||
131 | draw_x += style.tag_list.level * 5 * list.font_w + left_gap; |
||
132 | } |
||
133 | |||
8462 | leency | 134 | bool TWebBrowser::RenderImage(dword cur_img) |
135 | { |
||
136 | int img_x, img_y, img_w, img_h; |
||
137 | dword imgbuf[44]; |
||
138 | |||
139 | if (!cur_img) return false; |
||
140 | |||
141 | img_h = ESDWORD[cur_img+8]; |
||
142 | img_w = ESDWORD[cur_img+4]; |
||
143 | |||
9103 | leency | 144 | if (img_w + draw_x - left_gap >= draw_w) NewLine(); |
8462 | leency | 145 | img_y = draw_y; |
146 | if (img_h < list.item_h) img_y += list.item_h - img_h / 2 - 1; else img_y -= 2; |
||
147 | style.cur_line_h = math.max(style.cur_line_h, img_h); |
||
148 | |||
149 | img_w = math.min(img_w, canvas.bufw - draw_x); |
||
150 | |||
151 | if (link) links.add_text(draw_x + list.x, img_y + list.y, img_w, img_h, 0); |
||
152 | |||
153 | if (img_y + img_h >= canvas.bufh) canvas.IncreaseBufSize(); |
||
154 | |||
9103 | leency | 155 | if (secondrun) |
156 | { |
||
157 | if (ESDWORD[cur_img+20] != IMAGE_BPP32) { |
||
158 | img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0); |
||
159 | $push eax |
||
160 | img_destroy stdcall(cur_img); |
||
161 | $pop eax |
||
162 | cur_img = EAX; |
||
163 | if (!EAX) return false; |
||
164 | } |
||
165 | imgbuf[04] = canvas.bufw; |
||
166 | imgbuf[08] = canvas.bufh; |
||
167 | imgbuf[20] = IMAGE_BPP32; |
||
168 | imgbuf[24] = buf_data+8; |
||
169 | img_blend stdcall(#imgbuf, cur_img, draw_x, img_y, 0, 0, img_w, img_h); |
||
8462 | leency | 170 | img_destroy stdcall(cur_img); |
171 | } |
||
172 | |||
173 | draw_x += img_w; |
||
9103 | leency | 174 | if (draw_x - left_gap >= draw_w) NewLine(); |
8462 | leency | 175 | return true; |
176 | }>>> |