Subversion Repositories Kolibri OS

Rev

Rev 7749 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7749 Rev 7750
Line 27... Line 27...
27
	void SetStyle();
27
	void SetStyle();
28
	void DrawStyle();
28
	void DrawStyle();
29
	void DrawPage();
29
	void DrawPage();
30
	void DrawScroller();
30
	void DrawScroller();
31
	void LoadInternalPage();
31
	void NewLine();
32
	void NewLine();
-
 
33
	void Perenos();
32
	bool CheckForLineBreak();
34
	void BufEncode();
33
	void BufEncode();
35
} WB1;
34
} WB1;
36
 
35
 
Line 37... Line 36...
37
 
36
 
Line 95... Line 94...
95
		stolbec_len = strlen(#line) * zoom;
94
		stolbec_len = strlen(#line) * zoom;
96
		line_length = stolbec_len * list.font_w;
95
		line_length = stolbec_len * list.font_w;
97
 
96
 
Line 98... Line 97...
98
		if (debug_mode) {
97
		if (debug_mode) {
99
			DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xDDDddd);
98
			DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, 0xDDDddd);
100
		}
99
		}
Line 101... Line 100...
101
 
100
 
102
		if (style.bg_color!=page_bg) {
101
		if (style.bg_color!=page_bg) {
103
			DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, style.bg_color);
102
			DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, style.bg_color);
Line 104... Line 103...
104
		}
103
		}
105
 
104
 
106
		if (style.image) {
105
		if (style.image) {
Line 116... Line 115...
116
		if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
115
		if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
117
		if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
116
		if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
118
		if (link) {
117
		if (link) {
119
			if (line[0]==' ') && (line[1]==NULL) {} else {
118
			if (line[0]==' ') && (line[1]==NULL) {} else {
120
				DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, text_colors[text_color_index]);
119
				DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, link_color_inactive);
121
				PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom);				
120
				PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom);				
122
			}
121
			}
123
		}
122
		}
124
		stolbec += stolbec_len;
123
		stolbec += stolbec_len;
125
	}
124
		if (debug_mode) debug(#line);
-
 
125
		line = NULL;
-
 
126
	}
126
}
127
}
127
//============================================================================================
128
//============================================================================================
128
void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){
129
void TWebBrowser::SetPageDefaults()
129
	bufsize = in_filesize;
-
 
130
	bufpointer = bufpos;
-
 
131
	Prepare();
-
 
132
}
-
 
133
//============================================================================================
-
 
134
void TWebBrowser::SetPageDefaults()
-
 
135
{
130
{
136
	style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
131
	style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
137
	style.li = link = text_color_index = text_colors[0] = style.li_tab = false;
132
	style.li = link = text_color_index = text_colors[0] = style.li_tab = false;
138
	style.align = ALIGN_LEFT;
133
	style.align = ALIGN_LEFT;
139
	link_color_inactive = 0x0000FF;
134
	link_color_inactive = 0x0000FF;
Line 169... Line 164...
169
		case 0x0a:
164
		case 0x0a:
170
			if (style.pre)
165
			if (style.pre)
171
			{
166
			{
172
				DrawStyle();
167
				DrawStyle();
173
				line = NULL;
168
				NewLine();
174
				NewLine();
-
 
175
				break;
169
				break;
176
			}
170
			}
177
			goto DEFAULT_MARK;
171
			goto DEFAULT_MARK;
178
		case '\9':
172
		case '\9':
179
			if (style.pre) //otherwise go to 0x0d	
173
			if (style.pre) //otherwise go to 0x0d	
Line 191... Line 185...
191
				chrcat(#tag, bukva);
185
				chrcat(#tag, bukva);
192
			}
186
			}
193
			if (bukva = GetUnicodeSymbol(#tag)) {
187
			if (bukva = GetUnicodeSymbol(#tag)) {
194
				bufpos += j;
188
				bufpos += j;
195
			} else {
189
				CheckForLineBreak();
-
 
190
			} else {
196
				bukva = '&';
191
				bukva = '&';
197
			}
192
				goto DEFAULT_MARK;
198
			goto DEFAULT_MARK;
-
 
199
			break;
193
			}
-
 
194
			break;
200
		case '<':
195
		case '<':
201
			bufpos++;
196
			bufpos++;
202
			if (!strncmp(bufpos,"!--",3))
197
			if (!strncmp(bufpos,"!--",3))
203
			{
198
			{
204
				bufpos+=3;
199
				bufpos+=3;
Line 221... Line 216...
221
				else
216
				else
222
				{
217
				{
223
					ignor_param = true;
218
					ignor_param = true;
224
					if (strlen(#tagparam)+1
219
					if (strlen(#tagparam)+1
225
				}
220
					//	chrncat(#tagparam, bukva, sizeof(tagparam)-1);
-
 
221
				}
226
				bufpos++;
222
				bufpos++;
227
			}
223
			}
228
			strlwr(#tag);
224
			strlwr(#tag);
229
 
225
 
Line 248... Line 244...
248
			}
244
			}
249
			else opened = 1;
245
			else opened = 1;
250
 
246
 
Line 251... Line 247...
251
			if (tag) && (!istag("span")) && (!istag("i")) && (!istag("svg")) {
247
			if (tag) && (!istag("span")) && (!istag("i")) && (!istag("svg")) {
252
				Perenos();
248
				CheckForLineBreak();
253
				DrawStyle();
249
				DrawStyle();
254
				line = NULL;
-
 
255
				if (tag) SetStyle();
250
				if (tag) SetStyle();
256
			}
251
			}
257
			strlcpy(#oldtag, #tag, sizeof(oldtag));
252
			strlcpy(#oldtag, #tag, sizeof(oldtag)-1);
258
			tag = attr = tagparam = ignor_param = NULL;
253
			tag = attr = tagparam = ignor_param = NULL;
259
			break;
254
			break;
260
		default:
255
		default:
261
			DEFAULT_MARK:
256
			DEFAULT_MARK:
262
			if (bukva<=15) bukva=' ';
257
			if (bukva<=15) bukva=' ';
Line 266... Line 261...
266
				if (line[line_len-1]==' ') break; //no double spaces
261
				if (line[line_len-1]==' ') break; //no double spaces
267
				if (!stolbec) && (!line) break; //no paces at the beginning of the line
262
				if (!stolbec) && (!line) break; //no paces at the beginning of the line
268
			}
263
			}
269
			if (line_len < sizeof(line)) chrcat(#line, bukva);
264
			if (line_len < sizeof(line)) chrcat(#line, bukva);
270
			Perenos();
265
			CheckForLineBreak();
271
		}
266
		}
272
	}
267
	}
273
	DrawStyle();
268
	DrawStyle();
274
	NewLine();
269
	NewLine();
275
	if (list.first == 0) list.count = draw_y;
270
	if (list.first == 0) list.count = draw_y;
276
	DrawPage();
271
	DrawPage();
277
}
272
}
278
//============================================================================================
273
//============================================================================================
279
void TWebBrowser::Perenos()
274
bool TWebBrowser::CheckForLineBreak()
280
{
275
{
281
	int perenos_num;
276
	int line_break_pos;
282
	char new_line_text[4096];
277
	char new_line_text[4096];
283
	if (strlen(#line)*zoom + stolbec < list.column_max) return;
278
	if (strlen(#line)*zoom + stolbec < list.column_max) return false;
284
	perenos_num = strrchr(#line, ' ');
279
	line_break_pos = strrchr(#line, ' ');
285
	if (!perenos_num) && (strlen(#line)*zoom>list.column_max) {
280
	if (line_break_pos*zoom + stolbec > list.column_max) {
-
 
281
		line_break_pos = list.column_max/zoom - stolbec;
-
 
282
		while(line_break_pos) && (line[line_break_pos]!=' ') line_break_pos--;
-
 
283
	}
-
 
284
	if (!line_break_pos) && (strlen(#line)*zoom>list.column_max) {
286
		perenos_num=list.column_max/zoom; 
285
		line_break_pos=list.column_max/zoom; 
287
		if (!stolbec)&&(style.pre) draw_y-=list.item_h; //hack to fix https://prnt.sc/rk3kyt
286
		if (!stolbec)&&(style.pre) draw_y-=list.item_h; //hack to fix https://prnt.sc/rk3kyt
288
	}
287
	}
289
	strcpy(#new_line_text, #line + perenos_num);
288
	strcpy(#new_line_text, #line + line_break_pos);
290
	line[perenos_num] = 0x00;
289
	line[line_break_pos] = 0x00;
291
	DrawStyle();
290
	DrawStyle();
292
	strcpy(#line, #new_line_text);
291
	strcpy(#line, #new_line_text);
293
	NewLine();
292
	NewLine();
294
}
293
	//if (strlen(#line)*zoom + stolbec > list.column_max)CheckForLineBreak();
-
 
294
	return true;
-
 
295
}
295
//============================================================================================
296
//============================================================================================
296
void TWebBrowser::SetStyle() {
297
void TWebBrowser::SetStyle() {
297
	char img_path[4096]=0;
298
	char img_path[4096]=0;
298
	int left1 = body_magrin + list.x;
299
	int left1 = body_magrin + list.x;
299
	int meta_encoding;
300
	int meta_encoding;
Line 307... Line 308...
307
	}
308
	}
308
	
309
	
Line 309... Line 310...
309
	IF(istag("q"))
310
	IF(istag("q"))
310
	{
311
	{
-
 
312
		if (opened)	{
-
 
313
			meta_encoding = strlen(#line);
-
 
314
			if (line[meta_encoding-1] != ' ') chrcat(#line, ' ');
311
		if (opened)	strcat(#line, " \"");
315
			chrcat(#line, '\"');
-
 
316
		}
312
		if (!opened) strcat(#line, "\" ");
317
		if (!opened) strcat(#line, "\" ");
313
		return;
318
		return;
314
	}
319
	}
315
	if (isattr("id=")) || (isattr("name=")) { // TO FIX: works only if the param is the last
320
	if (isattr("id=")) || (isattr("name=")) { // TO FIX: works only if the param is the last
316
		anchors.add(#val, draw_y);
321
		anchors.add(#val, draw_y);
Line 402... Line 407...
402
	if (istag("blockquote")) { style.blq = opened; return; }
407
	if (istag("blockquote")) { style.blq = opened; return; }
403
	if (istag("pre")) || (istag("code")) { style.pre = opened; return; }
408
	if (istag("pre")) || (istag("code")) { style.pre = opened; return; }
404
	if (istag("img")) {
409
	if (istag("img")) {
405
		do{
410
		do{
406
			if (isattr("src=")) strncpy(#img_path, #val, sizeof(img_path)-1);
411
			if (isattr("src=")) strlcpy(#img_path, #val, sizeof(img_path)-1);
407
			if (isattr("title=")) && (strlen(#val)
412
			if (isattr("title=")) && (strlen(#val)
408
			if (isattr("alt=")) && (strlen(#val)
413
			if (isattr("alt=")) && (strlen(#val)
409
		} while(GetNextParam());
414
		} while(GetNextParam());
410
		if (!img_path) return;
415
		if (!img_path) { line=0; return; }
411
		style.image = true;
416
		style.image = true;
412
		text_color_index++;
417
		text_color_index++;
413
		text_colors[text_color_index] = 0x9A6F29;
418
		text_colors[text_color_index] = 0x9A6F29;
414
		if (!line) {
419
		if (!line) {
415
			if (!strncmp(#img_path, "data:", 5)) img_path=0;
420
			if (!strncmp(#img_path, "data:", 5)) img_path=0;
416
			replace_char(#img_path, '?', NULL, strlen(#img_path));
421
			replace_char(#img_path, '?', NULL, strlen(#img_path));
417
			sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/'));
422
			sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/'));
418
			line[50]= NULL;
423
			line[50]= NULL;
419
		}
424
		}
420
		if (strlen(#line) + stolbec > list.column_max) Perenos();
425
		while (CheckForLineBreak()) {};
421
		DrawStyle();
426
		DrawStyle();
422
		line=0;
427
		text_color_index--;
423
		text_color_index--;
-
 
424
		style.image = false;
428
		style.image = false;
425
		//ImgCache.Images( left1, draw_y, WB1.list.w); 
429
		//ImgCache.Images( left1, draw_y, WB1.list.w); 
426
		return; 
430
		return; 
427
	}
431
	}
428
	if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("caption")) {
432
	if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("caption")) {
Line 557... Line 561...
557
	if (t_html) && (!t_body) return;
561
	if (t_html) && (!t_body) return;
558
	draw_y += list.item_h;
562
	draw_y += list.item_h;
559
	if (style.blq) stolbec = 6; else stolbec = 0;
563
	if (style.blq) stolbec = 6; else stolbec = 0;
560
	if (style.li) stolbec = style.li_tab * 5;
564
	if (style.li) stolbec = style.li_tab * 5;
561
}
565
	if (debug_mode) debugln(NULL);
-
 
566
}
562
//============================================================================================
567
//============================================================================================
563
bool istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; }
568
bool istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; }
564
bool isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; }
569
bool isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; }
565
bool isval(dword text) { if (!strcmp(#val,text)) return true; else return false; }
570
bool isval(dword text) { if (!strcmp(#val,text)) return true; else return false; }
566
//============================================================================================
571
//============================================================================================