Rev 8439 | Rev 8451 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8439 | Rev 8444 | ||
---|---|---|---|
1 | void TWebBrowser::SetStyle() |
1 | void TWebBrowser::SetStyle() |
2 | { |
2 | { |
3 | if (tag.get_value_of("name=")) || (tag.get_value_of("id=")) { |
3 | if (tag.get_value_of("name")) || (tag.get_value_of("id")) { |
4 | anchors.add(tag.value, draw_y); |
4 | anchors.add(tag.value, draw_y); |
5 | if (anchors.current) && (streq(tag.value, #anchors.current+1)) { |
5 | if (anchors.current) && (streq(tag.value, #anchors.current+1)) { |
6 | list.first = draw_y; |
6 | list.first = draw_y; |
7 | anchors.current = NULL; |
7 | anchors.current = NULL; |
8 | } |
8 | } |
9 | } |
9 | } |
10 | if (tag.is("a")) { tag_a(); return; } |
10 | if (tag.is("a")) { tag_a(); return; } |
11 | if (tag.is("p")) { tag_p(); return; } |
11 | if (tag.is("p")) { tag_p(); return; } |
12 | if (tag.is("img")) { tag_img(); return; } |
12 | if (tag.is("img")) { tag_img(); return; } |
13 | if (tag.is("div")) { tag_div(); return; } |
13 | if (tag.is("div")) { tag_div(); return; } |
14 | if (tag.is("br")) { NewLine(); return; } |
14 | if (tag.is("br")) { NewLine(); return; } |
15 | if (tag.is("header")) { NewLine(); return; } |
15 | if (tag.is("header")) { NewLine(); return; } |
16 | if (tag.is("article")) { NewLine(); return; } |
16 | if (tag.is("article")) { NewLine(); return; } |
17 | if (tag.is("footer")) { NewLine(); return; } |
17 | if (tag.is("footer")) { NewLine(); return; } |
18 | if (tag.is("figure")) { NewLine(); return; } |
18 | if (tag.is("figure")) { NewLine(); return; } |
19 | if (tag.is("w:p")) { NewLine(); return; } |
19 | if (tag.is("w:p")) { NewLine(); return; } |
20 | if (tag.is("b")) { style.b = tag.opened; return; } |
20 | if (tag.is("b")) { style.b = tag.opened; return; } |
21 | if (tag.is("strong")) { style.b = tag.opened; return; } |
21 | if (tag.is("strong")) { style.b = tag.opened; return; } |
22 | if (tag.is("big")) { style.b = tag.opened; return; } |
22 | if (tag.is("big")) { style.b = tag.opened; return; } |
23 | if (tag.is("w:b")) { style.b = tag.opened; return; } |
23 | if (tag.is("w:b")) { style.b = tag.opened; return; } |
24 | if (tag.is("u")) { style.u = tag.opened; return; } |
24 | if (tag.is("u")) { style.u = tag.opened; return; } |
25 | if (tag.is("ins")) { style.u = tag.opened; return; } |
25 | if (tag.is("ins")) { style.u = tag.opened; return; } |
26 | if (tag.is("s")) { style.s = tag.opened; return; } |
26 | if (tag.is("s")) { style.s = tag.opened; return; } |
27 | if (tag.is("strike")) { style.s = tag.opened; return; } |
27 | if (tag.is("strike")) { style.s = tag.opened; return; } |
28 | if (tag.is("del")) { style.s = tag.opened; return; } |
28 | if (tag.is("del")) { style.s = tag.opened; return; } |
29 | if (tag.is("pre")) { style.pre = tag.opened; return; } |
29 | if (tag.is("pre")) { style.pre = tag.opened; return; } |
30 | if (tag.is("blockquote")) { style.blq = tag.opened; return; } |
30 | if (tag.is("blockquote")) { style.blq = tag.opened; return; } |
31 | if (tag.is("dl")) { if (tag.opened) NewLine(); return; } |
31 | if (tag.is("dl")) { if (tag.opened) NewLine(); return; } |
32 | if (tag.is("tr")) { if (tag.opened) NewLine(); return; } |
32 | if (tag.is("tr")) { if (tag.opened) NewLine(); return; } |
33 | if (tag.is("td")) { if (tag.opened) AddCharToTheLine(' '); return; } |
33 | if (tag.is("td")) { if (tag.opened) AddCharToTheLine(' '); return; } |
34 | if (tag.is("button")) { style.button = tag.opened; stolbec++; return; } |
34 | if (tag.is("button")) { style.button = tag.opened; stolbec++; return; } |
35 | if (tag.is("w:r")) { if (!tag.opened) style.b = false; return; } |
35 | if (tag.is("w:r")) { if (!tag.opened) style.b = false; return; } |
36 | if (tag.is("h1")) { tag_h1234_caption(); return; } |
36 | if (tag.is("h1")) { tag_h1234_caption(); return; } |
37 | if (tag.is("h2")) { tag_h1234_caption(); return; } |
37 | if (tag.is("h2")) { tag_h1234_caption(); return; } |
38 | if (tag.is("h3")) { tag_h1234_caption(); return; } |
38 | if (tag.is("h3")) { tag_h1234_caption(); return; } |
39 | if (tag.is("h4")) { tag_h1234_caption(); return; } |
39 | if (tag.is("h4")) { tag_h1234_caption(); return; } |
40 | if (tag.is("font")) { tag_font(); return; } |
40 | if (tag.is("font")) { tag_font(); return; } |
41 | if (tag.is("dt")) { tag_ol_ul_dt(); return; } |
41 | if (tag.is("dt")) { tag_ol_ul_dt(); return; } |
42 | if (tag.is("ul")) { tag_ol_ul_dt(); return; } |
42 | if (tag.is("ul")) { tag_ol_ul_dt(); return; } |
43 | if (tag.is("ol")) { tag_ol_ul_dt(); return; } |
43 | if (tag.is("ol")) { tag_ol_ul_dt(); return; } |
44 | if (tag.is("li")) { tag_li(); return; } |
44 | if (tag.is("li")) { tag_li(); return; } |
45 | if (tag.is("q")) { tag_q(); return; } |
45 | if (tag.is("q")) { tag_q(); return; } |
46 | if (tag.is("hr")) { tag_hr(); return; } |
46 | if (tag.is("hr")) { tag_hr(); return; } |
47 | if (tag.is("meta")) { tag_meta_xml(); return; } |
47 | if (tag.is("meta")) { tag_meta_xml(); return; } |
48 | if (tag.is("?xml")) { tag_meta_xml(); return; } |
48 | if (tag.is("?xml")) { tag_meta_xml(); return; } |
49 | if (tag.is("code")) { tag_code(); return; } |
49 | if (tag.is("code")) { tag_code(); return; } |
50 | if (tag.is("iframe")) { tag_iframe(); return; } |
50 | if (tag.is("iframe")) { tag_iframe(); return; } |
51 | if (tag.is("caption")) { tag_h1234_caption(); return; } |
51 | if (tag.is("caption")) { tag_h1234_caption(); return; } |
52 | if (tag.is("title")) { tag_title(); return; } |
52 | if (tag.is("title")) { tag_title(); return; } |
53 | if (tag.is("body")) { tag_body(); return; } |
53 | if (tag.is("body")) { tag_body(); return; } |
54 | if (tag.is("html")) { t_html = tag.opened; return; } |
54 | if (tag.is("html")) { t_html = tag.opened; return; } |
55 | if (tag.is("dd")) { |
55 | if (tag.is("dd")) { |
56 | //NewLine(); |
56 | //NewLine(); |
57 | //if (tag.opened) stolbec += 5; //stolbec overflow! |
57 | //if (tag.opened) stolbec += 5; //stolbec overflow! |
58 | return; |
58 | return; |
59 | } |
59 | } |
60 | } |
60 | } |
61 | 61 | ||
62 | void TWebBrowser::tag_p() |
62 | void TWebBrowser::tag_p() |
63 | { |
63 | { |
64 | IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) || (streq(#tag.prior,"p")) return; |
64 | IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) || (streq(#tag.prior,"p")) return; |
65 | NewLine(); |
65 | NewLine(); |
66 | } |
66 | } |
67 | 67 | ||
68 | void TWebBrowser::tag_title() |
68 | void TWebBrowser::tag_title() |
69 | { |
69 | { |
70 | style.title = tag.opened; |
70 | style.title = tag.opened; |
71 | if (!tag.opened) DrawTitle(#header); |
71 | if (!tag.opened) DrawTitle(#header); |
72 | } |
72 | } |
73 | 73 | ||
74 | void TWebBrowser::tag_font() |
74 | void TWebBrowser::tag_font() |
75 | { |
75 | { |
76 | style.font = tag.opened; |
76 | style.font = tag.opened; |
77 | style.bg_color = page_bg; |
77 | style.bg_color = page_bg; |
78 | if (tag.opened) |
78 | if (tag.opened) |
79 | { |
79 | { |
80 | if (tag.get_value_of("bg=")) style.bg_color = GetColor(tag.value); |
80 | if (tag.get_value_of("bg")) style.bg_color = GetColor(tag.value); |
81 | if (tag.get_value_of("color=")) { |
81 | if (tag.get_value_of("color")) { |
82 | text_colors.add(GetColor(tag.value)); |
82 | text_colors.add(GetColor(tag.value)); |
83 | } else { |
83 | } else { |
84 | text_colors.add(text_colors.get_last()); |
84 | text_colors.add(text_colors.get_last()); |
85 | } |
85 | } |
86 | } |
86 | } |
87 | else text_colors.pop(); |
87 | else text_colors.pop(); |
88 | } |
88 | } |
89 | 89 | ||
90 | void TWebBrowser::tag_div() |
90 | void TWebBrowser::tag_div() |
91 | { |
91 | { |
92 | if (streq(#tag.prior,"div")) && (tag.opened) return; |
92 | if (streq(#tag.prior,"div")) && (tag.opened) return; |
93 | if (!tag.opened) && (style.font) text_colors.pop(); |
93 | if (!tag.opened) && (style.font) text_colors.pop(); |
94 | NewLine(); |
94 | NewLine(); |
95 | } |
95 | } |
96 | 96 | ||
97 | void TWebBrowser::tag_iframe() |
97 | void TWebBrowser::tag_iframe() |
98 | { |
98 | { |
99 | if (tag.get_value_of("src=")) { |
99 | if (tag.get_value_of("src")) { |
100 | NewLine(); |
100 | NewLine(); |
101 | strcpy(#line, "IFRAME: "); |
101 | strcpy(#line, "IFRAME: "); |
102 | Paint(); |
102 | Paint(); |
103 | link=true; |
103 | link=true; |
104 | links.add_link(tag.value); |
104 | links.add_link(tag.value); |
105 | strncpy(#line, tag.value, sizeof(line)-1); |
105 | strncpy(#line, tag.value, sizeof(line)-1); |
106 | while (CheckForLineBreak()) {}; |
106 | while (CheckForLineBreak()) {}; |
107 | Paint(); |
107 | Paint(); |
108 | link=false; |
108 | link=false; |
109 | NewLine(); |
109 | NewLine(); |
110 | } |
110 | } |
111 | } |
111 | } |
112 | 112 | ||
113 | void TWebBrowser::tag_a() |
113 | void TWebBrowser::tag_a() |
114 | { |
114 | { |
115 | if (tag.opened) |
115 | if (tag.opened) |
116 | { |
116 | { |
117 | if (tag.get_value_of("href=")) && (!strstr(tag.value,"javascript:")) |
117 | if (tag.get_value_of("href")) && (!strstr(tag.value,"javascript:")) |
118 | { |
118 | { |
119 | link = true; |
119 | link = true; |
120 | links.add_link(tag.value); |
120 | links.add_link(tag.value); |
121 | } |
121 | } |
122 | } else { |
122 | } else { |
123 | link = false; |
123 | link = false; |
124 | style.bg_color = page_bg; |
124 | style.bg_color = page_bg; |
125 | } |
125 | } |
126 | } |
126 | } |
127 | 127 | ||
128 | void TWebBrowser::tag_meta_xml() |
128 | void TWebBrowser::tag_meta_xml() |
129 | { |
129 | { |
130 | if (custom_encoding == -1) if (tag.get_value_of("charset=")) |
130 | if (custom_encoding == -1) if (tag.get_value_of("charset")) |
131 | || (tag.get_value_of("content=")) || (tag.get_value_of("encoding=")) |
131 | || (tag.get_value_of("content")) || (tag.get_value_of("encoding")) |
132 | { |
132 | { |
133 | EDX = strrchr(tag.value, '=') + tag.value; //search in content= |
133 | EDX = strrchr(tag.value, '=') + tag.value; //search in content= |
134 | if (ESBYTE[EDX] == '"') EDX++; |
134 | if (ESBYTE[EDX] == '"') EDX++; |
135 | strlwr(EDX); |
135 | strlwr(EDX); |
136 | if (streqrp(EDX,"utf-8")) || (streqrp(EDX,"utf8")) ChangeEncoding(CH_UTF8); |
136 | if (streqrp(EDX,"utf-8")) || (streqrp(EDX,"utf8")) ChangeEncoding(CH_UTF8); |
137 | else if (streqrp(EDX,"windows-1251")) || (streqrp(EDX,"windows1251")) ChangeEncoding(CH_CP1251); |
137 | else if (streqrp(EDX,"windows-1251")) || (streqrp(EDX,"windows1251")) ChangeEncoding(CH_CP1251); |
138 | else if (streqrp(EDX,"dos")) || (streqrp(EDX,"cp-866")) ChangeEncoding(CH_CP866); |
138 | else if (streqrp(EDX,"dos")) || (streqrp(EDX,"cp-866")) ChangeEncoding(CH_CP866); |
139 | else if (streqrp(EDX,"iso-8859-5")) || (streqrp(EDX,"iso8859-5")) ChangeEncoding(CH_ISO8859_5); |
139 | else if (streqrp(EDX,"iso-8859-5")) || (streqrp(EDX,"iso8859-5")) ChangeEncoding(CH_ISO8859_5); |
140 | else if (streqrp(EDX,"koi8-r")) || (streqrp(EDX,"koi8-u")) ChangeEncoding(CH_KOI8); |
140 | else if (streqrp(EDX,"koi8-r")) || (streqrp(EDX,"koi8-u")) ChangeEncoding(CH_KOI8); |
141 | } |
141 | } |
142 | if (streq(tag.get_value_of("http-equiv="), "refresh")) && (tag.get_value_of("content=")) { |
142 | if (streq(tag.get_value_of("http-equiv"), "refresh")) && (tag.get_value_of("content")) { |
143 | if (tag.value = strstri(tag.value, "url=")) strcpy(#redirect, tag.value); |
143 | if (tag.value = strstri(tag.value, "url")) strcpy(#redirect, tag.value); |
144 | } |
144 | } |
145 | } |
145 | } |
146 | 146 | ||
147 | void TWebBrowser::tag_code() |
147 | void TWebBrowser::tag_code() |
148 | { |
148 | { |
149 | if (style.pre = tag.opened) { |
149 | if (style.pre = tag.opened) { |
150 | style.bg_color = 0xe4ffcb; |
150 | style.bg_color = 0xe4ffcb; |
151 | } else { |
151 | } else { |
152 | style.bg_color = page_bg; |
152 | style.bg_color = page_bg; |
153 | } |
153 | } |
154 | } |
154 | } |
155 | 155 | ||
156 | void TWebBrowser::tag_ol_ul_dt() |
156 | void TWebBrowser::tag_ol_ul_dt() |
157 | { |
157 | { |
158 | char type = ESBYTE[#tag.name]; |
158 | char type = ESBYTE[#tag.name]; |
159 | style.tag_list.upd_level(tag.opened, type); |
159 | style.tag_list.upd_level(tag.opened, type); |
160 | switch(type) |
160 | switch(type) |
161 | { |
161 | { |
162 | case 'd': |
162 | case 'd': |
163 | if (tag.opened) NewLine(); |
163 | if (tag.opened) NewLine(); |
164 | break; |
164 | break; |
165 | case 'u': |
165 | case 'u': |
166 | case 'o': |
166 | case 'o': |
167 | if (!tag.opened) && (!style.pre) NewLine(); |
167 | if (!tag.opened) && (!style.pre) NewLine(); |
168 | } |
168 | } |
169 | } |
169 | } |
170 | 170 | ||
171 | void TWebBrowser::tag_li() |
171 | void TWebBrowser::tag_li() |
172 | { |
172 | { |
173 | if (tag.opened) { |
173 | if (tag.opened) { |
174 | if (!style.tag_list.level) style.tag_list.upd_level(1, 'u'); |
174 | if (!style.tag_list.level) style.tag_list.upd_level(1, 'u'); |
175 | if (!style.pre) NewLine(); |
175 | if (!style.pre) NewLine(); |
176 | if (style.tag_list.order_type() == 'u') { |
176 | if (style.tag_list.order_type() == 'u') { |
177 | strcpy(#line, "\31 "); |
177 | strcpy(#line, "\31 "); |
178 | stolbec = style.tag_list.level * 5 - 2; |
178 | stolbec = style.tag_list.level * 5 - 2; |
179 | } |
179 | } |
180 | if (style.tag_list.order_type() == 'o') { |
180 | if (style.tag_list.order_type() == 'o') { |
181 | sprintf(#line, "%i. ", style.tag_list.inc_counter()); |
181 | sprintf(#line, "%i. ", style.tag_list.inc_counter()); |
182 | stolbec = style.tag_list.level * 5 - strlen(#line); |
182 | stolbec = style.tag_list.level * 5 - strlen(#line); |
183 | } |
183 | } |
184 | } |
184 | } |
185 | } |
185 | } |
186 | 186 | ||
187 | void TWebBrowser::tag_hr() |
187 | void TWebBrowser::tag_hr() |
188 | { |
188 | { |
189 | EAX = 0x999999; |
189 | EAX = 0x999999; |
190 | if (tag.get_value_of("color=")) GetColor(tag.value); |
190 | if (tag.get_value_of("color")) GetColor(tag.value); |
191 | $push eax; |
191 | $push eax; |
192 | NewLine(); |
192 | NewLine(); |
193 | $pop edi; |
193 | $pop edi; |
194 | draw_y += 10; |
194 | draw_y += 10; |
195 | canvas.DrawBar(5, draw_y - 1, list.w-10, 1, EDI); |
195 | canvas.DrawBar(5, draw_y - 1, list.w-10, 1, EDI); |
196 | NewLine(); |
196 | NewLine(); |
197 | draw_y += 10; |
197 | draw_y += 10; |
198 | return; |
198 | return; |
199 | } |
199 | } |
200 | 200 | ||
201 | void TWebBrowser::tag_body() |
201 | void TWebBrowser::tag_body() |
202 | { |
202 | { |
203 | t_body = tag.opened; |
203 | t_body = tag.opened; |
204 | if (tag.get_value_of("link=")) link_color_default = GetColor(tag.value); |
204 | if (tag.get_value_of("link")) link_color_default = GetColor(tag.value); |
205 | if (tag.get_value_of("alink=")) link_color_active = GetColor(tag.value); |
205 | if (tag.get_value_of("alink")) link_color_active = GetColor(tag.value); |
206 | if (tag.get_value_of("text=")) text_colors.set(0, GetColor(tag.value)); |
206 | if (tag.get_value_of("text")) text_colors.set(0, GetColor(tag.value)); |
207 | if (tag.get_value_of("bgcolor=")) { |
207 | if (tag.get_value_of("bgcolor")) { |
208 | style.bg_color = page_bg = GetColor(tag.value); |
208 | style.bg_color = page_bg = GetColor(tag.value); |
209 | canvas.Fill(0, page_bg); |
209 | canvas.Fill(0, page_bg); |
210 | } |
210 | } |
211 | // Autodetecting encoding if no encoding was set |
211 | // Autodetecting encoding if no encoding was set |
212 | if (tag.opened) && (custom_encoding==-1) && (cur_encoding == CH_CP866) { |
212 | if (tag.opened) && (custom_encoding==-1) && (cur_encoding == CH_CP866) { |
213 | if (strstr(bufpointer, "\208\190")) ChangeEncoding(CH_UTF8); |
213 | if (strstr(bufpointer, "\208\190")) ChangeEncoding(CH_UTF8); |
214 | else if (chrnum(bufpointer, '\246')>5) ChangeEncoding(CH_CP1251); |
214 | else if (chrnum(bufpointer, '\246')>5) ChangeEncoding(CH_CP1251); |
215 | } |
215 | } |
216 | } |
216 | } |
217 | 217 | ||
218 | void TWebBrowser::tag_q() |
218 | void TWebBrowser::tag_q() |
219 | { |
219 | { |
220 | if (tag.opened) { |
220 | if (tag.opened) { |
221 | AddCharToTheLine(' '); |
221 | AddCharToTheLine(' '); |
222 | AddCharToTheLine('\"'); |
222 | AddCharToTheLine('\"'); |
223 | } else { |
223 | } else { |
224 | AddCharToTheLine('\"'); |
224 | AddCharToTheLine('\"'); |
225 | AddCharToTheLine(' '); |
225 | AddCharToTheLine(' '); |
226 | } |
226 | } |
227 | } |
227 | } |
228 | 228 | ||
229 | void TWebBrowser::tag_h1234_caption() |
229 | void TWebBrowser::tag_h1234_caption() |
230 | { |
230 | { |
231 | if (ESBYTE[#tag.name+1]=='4') { |
231 | if (ESBYTE[#tag.name+1]=='4') { |
232 | NewLine(); |
232 | NewLine(); |
233 | NewLine(); |
233 | NewLine(); |
234 | style.h = tag.opened; |
234 | style.h = tag.opened; |
235 | style.b = tag.opened; |
235 | style.b = tag.opened; |
236 | } else { |
236 | } else { |
237 | style.h = tag.opened; |
237 | style.h = tag.opened; |
238 | if (tag.opened) { |
238 | if (tag.opened) { |
239 | if (!style.pre) NewLine(); |
239 | if (!style.pre) NewLine(); |
240 | draw_y += 10; |
240 | draw_y += 10; |
241 | zoom=2; |
241 | zoom=2; |
242 | list.font_type |= 10011001b; |
242 | list.font_type |= 10011001b; |
243 | list.item_h = BASIC_LINE_H * 2 - 2; |
243 | list.item_h = BASIC_LINE_H * 2 - 2; |
244 | if (tag.is("h1")) style.b = true; |
244 | if (tag.is("h1")) style.b = true; |
245 | } else { |
245 | } else { |
246 | if (tag.is("h1")) style.b = false; |
246 | if (tag.is("h1")) style.b = false; |
247 | NewLine(); |
247 | NewLine(); |
248 | zoom=1; |
248 | zoom=1; |
249 | list.font_type = 10011000b; |
249 | list.font_type = 10011000b; |
250 | list.item_h = BASIC_LINE_H; |
250 | list.item_h = BASIC_LINE_H; |
251 | } |
251 | } |
252 | } |
252 | } |
253 | } |
253 | } |
254 | 254 | ||
255 | 255 | ||
256 | void TWebBrowser::tag_img() |
256 | void TWebBrowser::tag_img() |
257 | { |
257 | { |
258 | char img_path[4096]=0; |
258 | char img_path[4096]=0; |
259 | dword imgbuf[44]; |
259 | dword imgbuf[44]; |
260 | dword cur_img; |
260 | dword cur_img; |
261 | int img_x, img_y, img_w, img_h; |
261 | int img_x, img_y, img_w, img_h; |
262 | 262 | ||
263 | if (!tag.get_value_of("src=")) goto NOIMG; |
263 | if (!tag.get_value_of("src")) goto NOIMG; |
264 | 264 | ||
265 | if (streqrp(tag.value, "data:")) { |
265 | if (streqrp(tag.value, "data:")) { |
266 | if (!strstr(tag.value, "base64,")) goto NOIMG; |
266 | if (!strstr(tag.value, "base64,")) goto NOIMG; |
267 | EDX = EAX+7; |
267 | EDX = EAX+7; |
268 | if (ESBYTE[EDX]==' ') EDX++; |
268 | if (ESBYTE[EDX]==' ') EDX++; |
269 | cur_img = malloc(strlen(EDX)); |
269 | cur_img = malloc(strlen(EDX)); |
270 | base64_decode stdcall (EDX, cur_img, strlen(EDX)); |
270 | base64_decode stdcall (EDX, cur_img, strlen(EDX)); |
271 | img_decode stdcall (cur_img, EAX, 0); |
271 | img_decode stdcall (cur_img, EAX, 0); |
272 | $push eax |
272 | $push eax |
273 | free(cur_img); |
273 | free(cur_img); |
274 | $pop eax |
274 | $pop eax |
275 | if (EAX) goto IMGOK; else goto NOIMG; |
275 | if (EAX) goto IMGOK; else goto NOIMG; |
276 | } |
276 | } |
277 | 277 | ||
278 | if (!strcmp(tag.value + strrchr(tag.value, '.'), "svg")) goto NOIMG; |
278 | if (!strcmp(tag.value + strrchr(tag.value, '.'), "svg")) goto NOIMG; |
279 | strlcpy(#img_path, tag.value, sizeof(img_path)-1); |
279 | strlcpy(#img_path, tag.value, sizeof(img_path)-1); |
280 | get_absolute_url(#img_path, history.current()); |
280 | get_absolute_url(#img_path, history.current()); |
281 | 281 | ||
282 | if (check_is_the_adress_local(#img_path)) { |
282 | if (check_is_the_adress_local(#img_path)) { |
283 | img_from_file stdcall(#img_path); |
283 | img_from_file stdcall(#img_path); |
284 | if (EAX) goto IMGOK; else goto NOIMG; |
284 | if (EAX) goto IMGOK; else goto NOIMG; |
285 | } |
285 | } |
286 | 286 | ||
287 | if (cache.has(#img_path)) { |
287 | if (cache.has(#img_path)) { |
288 | img_decode stdcall (cache.current_buf, cache.current_size, 0); |
288 | img_decode stdcall (cache.current_buf, cache.current_size, 0); |
289 | if (EAX) goto IMGOK; else goto NOIMG; |
289 | if (EAX) goto IMGOK; else goto NOIMG; |
290 | } else { |
290 | } else { |
291 | img_url.add(#img_path); |
291 | img_url.add(#img_path); |
292 | goto NOIMG; |
292 | goto NOIMG; |
293 | } |
293 | } |
294 | 294 | ||
295 | IMGOK: |
295 | IMGOK: |
296 | cur_img = EAX; |
296 | cur_img = EAX; |
297 | img_h = ESDWORD[cur_img+8]; |
297 | img_h = ESDWORD[cur_img+8]; |
298 | img_w = ESDWORD[cur_img+4]; |
298 | img_w = ESDWORD[cur_img+4]; |
299 | 299 | ||
300 | if (img_w / 6 + stolbec > list.column_max) { |
300 | if (img_w / 6 + stolbec > list.column_max) { |
301 | NewLine(); |
301 | NewLine(); |
302 | } |
302 | } |
303 | img_x = stolbec*list.font_w+3; |
303 | img_x = stolbec*list.font_w+3; |
304 | img_y = draw_y; |
304 | img_y = draw_y; |
305 | 305 | ||
306 | img_w = math.min(img_w, canvas.bufw - img_x); |
306 | img_w = math.min(img_w, canvas.bufw - img_x); |
307 | 307 | ||
308 | stolbec += img_w / 6; |
308 | stolbec += img_w / 6; |
309 | if (stolbec > list.column_max) NewLine(); |
309 | if (stolbec > list.column_max) NewLine(); |
310 | 310 | ||
311 | if (img_h > list.item_h + 5) { |
311 | if (img_h > list.item_h + 5) { |
312 | draw_y += img_h - list.item_h; |
312 | draw_y += img_h - list.item_h; |
313 | NewLine(); |
313 | NewLine(); |
314 | } |
314 | } |
315 | 315 | ||
316 | if (link) links.add_text(img_x + list.x, img_y + list.y, img_w, img_h, 0); |
316 | if (link) links.add_text(img_x + list.x, img_y + list.y, img_w, img_h, 0); |
317 | 317 | ||
318 | if (img_y + img_h >= canvas.bufh) canvas.IncreaseBufSize(); |
318 | if (img_y + img_h >= canvas.bufh) canvas.IncreaseBufSize(); |
319 | 319 | ||
320 | if (ESDWORD[cur_img+20] != IMAGE_BPP32) { |
320 | if (ESDWORD[cur_img+20] != IMAGE_BPP32) { |
321 | img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0); |
321 | img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0); |
322 | $push eax |
322 | $push eax |
323 | img_destroy stdcall(cur_img); |
323 | img_destroy stdcall(cur_img); |
324 | $pop eax |
324 | $pop eax |
325 | cur_img = EAX; |
325 | cur_img = EAX; |
326 | if (!EAX) goto NOIMG; |
326 | if (!EAX) goto NOIMG; |
327 | } |
327 | } |
328 | imgbuf[04] = canvas.bufw; |
328 | imgbuf[04] = canvas.bufw; |
329 | imgbuf[08] = canvas.bufh; |
329 | imgbuf[08] = canvas.bufh; |
330 | imgbuf[20] = IMAGE_BPP32; |
330 | imgbuf[20] = IMAGE_BPP32; |
331 | imgbuf[24] = buf_data+8; |
331 | imgbuf[24] = buf_data+8; |
332 | img_blend stdcall(#imgbuf, cur_img, img_x, img_y, 0, 0, img_w, img_h); |
332 | img_blend stdcall(#imgbuf, cur_img, img_x, img_y, 0, 0, img_w, img_h); |
333 | img_destroy stdcall(cur_img); |
333 | img_destroy stdcall(cur_img); |
334 | return; |
334 | return; |
335 | 335 | ||
336 | NOIMG: |
336 | NOIMG: |
337 | if (tag.get_value_of("title=")) || (tag.get_value_of("alt=")) { |
337 | if (tag.get_value_of("title")) || (tag.get_value_of("alt")) { |
338 | strncpy(#img_path, tag.value, sizeof(line)-3); |
338 | strncpy(#img_path, tag.value, sizeof(line)-3); |
339 | sprintf(#line, "[%s]", #img_path); |
339 | sprintf(#line, "[%s]", #img_path); |
340 | } else { |
340 | } else { |
341 | if (streqrp(#img_path, "data:")) img_path=0; |
341 | if (streqrp(#img_path, "data:")) img_path=0; |
342 | replace_char(#img_path, '?', NULL, strlen(#img_path)); |
342 | replace_char(#img_path, '?', NULL, strlen(#img_path)); |
343 | img_path[sizeof(line)-3] = '\0'; //prevent overflow in sprintf |
343 | img_path[sizeof(line)-3] = '\0'; //prevent overflow in sprintf |
344 | sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/')); |
344 | sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/')); |
345 | line[50]= NULL; |
345 | line[50]= NULL; |
346 | } |
346 | } |
347 | while (CheckForLineBreak()) {}; |
347 | while (CheckForLineBreak()) {}; |
348 | text_colors.add(0x9A6F29); |
348 | text_colors.add(0x9A6F29); |
349 | style.image = true; |
349 | style.image = true; |
350 | Paint(); |
350 | Paint(); |
351 | style.image = false; |
351 | style.image = false; |
352 | text_colors.pop(); |
352 | text_colors.pop(); |
353 | } |
353 | } |