Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6052 → Rev 6053

/programs/cmm/aelia/aelia.c
59,6 → 59,7
 
#include "ini.h"
#include "gui.h"
#include "label.h"
#include "prepare_page.h"
 
void InitDlls()
96,12 → 97,13
HandleButtonEvent();
break;
case evReDraw:
draw_window();
if (menu.list.cur_y) {
encoding = menu.list.cur_y - 10;
debugln("evReDraw: charset changed");
EventOpenAddress(history.current());
menu.list.cur_y = 0;
}
draw_window();
}
}
}
/programs/cmm/aelia/buidin_pages/about.htm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programs/cmm/aelia/gui.h
42,9 → 42,9
 
enum {
STEP_1_DOWNLOAD_PAGE = 0,
STEP_2_COUNT_PAGE_HEIGHT = 30,
STEP_2_COUNT_PAGE_HEIGHT = 35,
STEP_3_DRAW_PAGE_INTO_BUFFER = 60,
STEP_4_SMOOTH_FONT = 94,
STEP_4_SMOOTH_FONT = 88,
STEP_5_STOP = 100,
};
 
54,7 → 54,6
if (percent<100) {
progress_width = address_box.width+5*percent/100;
DrawBar(address_box.left-3, address_box.top+16, progress_width, 2, 0x72B7EA);
//debugi(percent);
}
else {
progress_width = address_box.width+5;
61,15 → 60,3
DrawBar(address_box.left-3, address_box.top+16, progress_width, 2, 0xFFFfff);
}
}
 
int progress_percent;
void DrawProgressWhileDrawing(dword bufoff, buflen)
{
int progress_cur = bufoff - io.buffer_data;
int progress_max = buflen - io.buffer_data;
int new_progress_percent = STEP_4_SMOOTH_FONT-STEP_3_DRAW_PAGE_INTO_BUFFER*progress_cur/progress_max + STEP_3_DRAW_PAGE_INTO_BUFFER;
if (progress_percent != new_progress_percent) {
progress_percent = new_progress_percent;
DrawProgress(progress_percent);
}
}
/programs/cmm/aelia/label.h
0,0 → 1,43
char char_width[255];
 
void get_label_symbols_size()
{
int i;
label.changeSIZE();
for (i=0; i<256; i++) char_width[i] = label.symbol_size(i);
}
 
int get_label_len(dword _text)
{
int len=0;
byte ch;
loop () {
ch = ESBYTE[_text];
if (!ch) return len;
len += char_width[ch];
_text++;
}
}
 
void WriteTextIntoBuf(int _x, _y; dword _text_col, _text_off)
{
char error_message[128];
if (_x > list.w) {
sprintf(#error_message, "\nWriteTextIntoBuf _x overflow: H %d X %d \n", label.size.height, _x);
notify(#error_message);
}
if (_y+label.size.pt > label.size.height) {
sprintf(#error_message, "\nWriteTextIntoBuf _y overflow: H %d Y %d \n", label.size.height, _y);
notify(#error_message);
return;
}
label.write_buf(_x, _y, list.w, label.size.height, 0xFFFFFF, _text_col, label.size.pt, _text_off);
if (_y/list.item_h-list.first==list.visible) DrawPage();
}
 
 
void label_draw_bar(dword _x, _y, _w, _color)
{
int i;
for (i = _y*list.w+_x*3+label.raw ; i<_y*list.w+_x+_w*3+label.raw ; i+=3) ESDWORD[i] = _color;
}
/programs/cmm/aelia/prepare_page.h
1,30 → 1,24
char char_width[255];
 
void PreparePage()
{
int i;
list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, Form.cheight-TOOLBAR_H, label.size.pt+1);
list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, Form.cheight-TOOLBAR_H, label.size.pt+2);
strcpy(#title, history.current()+strrchr(history.current(),'/'));
//get font chars width, need to increase performance
//if (strstri(io.buffer_data, "<html>")==-1) {
get_label_symbols_size();
ChangeCharset(charsets[encoding], "CP866", io.buffer_data);
if (strstri(io.buffer_data, "<html")==-1) {
debugln("no <html> found");
label.changeSIZE();
for (i=0; i<256; i++) char_width[i] = label.symbol_size(i);
ChangeCharset(charsets[encoding], "CP866", io.buffer_data);
DrawProgress(STEP_2_COUNT_PAGE_HEIGHT); ParceTxt(false); //get page height to calculate buffer size
DrawProgress(STEP_3_DRAW_PAGE_INTO_BUFFER); ParceTxt(true); //draw text in buffer
DrawProgress(STEP_4_SMOOTH_FONT); label.apply_smooth();
DrawProgress(STEP_5_STOP); DrawPage();
/*}
else {
} else {
debugln("<html> tag found");
label.changeSIZE();
for (i=0; i<256; i++) char_width[i] = label.symbol_size(i);
ChangeCharset(charsets[encoding], "CP866", io.buffer_data);
DrawProgress(STEP_2_COUNT_PAGE_HEIGHT); ParceHtml(false); //get page height to calculate buffer size
DrawProgress(STEP_3_DRAW_PAGE_INTO_BUFFER); ParceHtml(true); //draw text in buffer
}
strcat(#title, " - Aelia");
DrawTitle(#title);
DrawProgress(STEP_4_SMOOTH_FONT); label.apply_smooth();
DrawProgress(STEP_5_STOP); DrawPage();
}*/
}
 
void ParceTxt(byte draw)
49,10 → 43,8
}
if (draw==true) {
ESBYTE[bufoff] >< zeroch; //set line end
label.write_buf(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, line_start);
WriteTextIntoBuf(8, stroka_y, 0x000000, line_start);
ESBYTE[bufoff] >< zeroch; //restore line
DrawProgressWhileDrawing(bufoff, buflen);
if (stroka_y/list.item_h-list.first==list.visible) DrawPage();
}
stroka_y += list.item_h;
line_start = bufoff;
65,7 → 57,7
label.size.height = list.count+1*list.item_h;
label.raw_size = 0;
}
if (draw==true) label.write_buf(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, line_start);
if (draw==true) WriteTextIntoBuf(8, stroka_y, 0x000000, line_start);
}
 
 
75,18 → 67,7
= =
========================================================*/
 
/*
HTML parcer tags:
<title>
<meta encoding>
<a hrf="">
<img src="" alt="">
<h1> ... <h6>
<b>
<u>
<s>
<pre>
*/
/* <title> <meta encoding> <a hrf=""> <img src="" alt=""> <h1>..<h6> <b> <u> <s> <pre> */
 
struct _DOM {
dword start;
99,10 → 80,15
bool h1, h2, h3, h4, h5, h6;
bool a;
bool pre;
bool title;
bool br;
bool ignore;
dword color;
} style;
 
struct _text {
dword start;
int x, y;
};
 
struct _tag {
dword start;
dword name;
109,49 → 95,33
dword param[10];
dword value[10];
void parce();
void get_param_value();
int nameis();
};
 
void _tag::parce()
{
bool closed_status = false;
if (start) debugln(start);
/*
if (strncmp(start, "/", 1)==0) {
start++;
closed_status = true;
dword o = name = start;
while (ESBYTE[o]!=' ') && (ESBYTE[o]) o++; //searching for a space after tag name
ESBYTE[o] = '\0';
strlwr(name);
}
if (!strcmp(start, "title")) style.title = closed_status;
if (!strcmp(start, "br")) style.br = closed_status;
*/
}
 
struct _text {
dword start;
int x, y;
void draw();
};
 
void _text::draw()
int _tag::nameis(dword _in_tag_name)
{
if (start) debugln(start);
/*
if (style.title) {
strlcpy(#title, start, sizeof(title));
DrawTitle(#title);
return;
if (strcmp(_in_tag_name, name)==0) return true;
return false;
}
if (style.br) {
y += list.item_h;
style.br = false;
}
*/
}
 
#define HTML_PADDING_X 8;
#define HTML_PADDING_Y 5;
 
 
void ParceHtml(byte draw)
{
byte ch;
int stroka_x = HTML_PADDING_X;
int stroka_y = HTML_PADDING_Y;
dword line_break;
byte ch, zeroch;
_DOM DOM;
_text text;
_tag tag;
158,7 → 128,7
dword DOM_pos;
 
/* Create DOM */
debugln("starting DOM parce");
debugln("creating DOM");
DOM.len = strlen(io.buffer_data);
DOM.start = malloc(DOM.len);
DOM.end = DOM.start + DOM.len;
165,21 → 135,66
strlcpy(DOM.start, io.buffer_data, DOM.len);
 
/* Parce DOM */
debugln("starting DOM parce...");
text.start = DOM_pos;
for (DOM_pos=DOM.start; DOM_pos<DOM.end; DOM_pos++)
{
if (ESBYTE[DOM_pos]==0x0D) || (ESBYTE[DOM_pos]==0x0A) ESBYTE[DOM_pos]=' ';
ch = ESBYTE[DOM_pos];
//debugch(ch);
if (ch=='<') {
ESBYTE[DOM_pos] = NULL;
ESBYTE[DOM_pos] = '\0';
tag.start = DOM_pos + 1;
text.draw();
if (style.ignore) continue;
if (tag.nameis("title")) {
strcpy(#title, text.start);
continue;
}
while (get_label_len(text.start) + stroka_x + 30 > list.w)
{
//debugln("long line cut");
zeroch = 0;
for (line_break=tag.start-1; line_break>text.start; line_break--;)
{
ESBYTE[line_break] >< zeroch; //set line end
if (get_label_len(text.start) + stroka_x + 30 <= list.w) break;
ESBYTE[line_break] >< zeroch; //restore line
}
if (draw==true) {
if (style.a) label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
}
ESBYTE[line_break] >< zeroch; //restore line
text.start = line_break;
stroka_x = HTML_PADDING_X;
stroka_y += list.item_h;
}
if (draw==true) {
if (style.a) label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
}
stroka_x += get_label_len(text.start);
}
if (ch=='>') {
ESBYTE[DOM_pos] = NULL;
ESBYTE[DOM_pos] = '\0';
text.start = DOM_pos + 1;
tag.parce();
if (tag.nameis("br")) || (tag.nameis("p")) || (tag.nameis("div")) || (tag.nameis("h1")) || (tag.nameis("h2")) {
stroka_y+= list.item_h;
stroka_x = HTML_PADDING_X;
continue;
}
if (tag.nameis("script")) || (tag.nameis("style")) style.ignore = true;
if (tag.nameis("/script")) || (tag.nameis("/style")) style.ignore = false;
if (tag.nameis("a")) { style.a = true; style.color=0x0000FF; }
if (tag.nameis("/a")) { style.a = false; style.color=0x000000; }
}
}
if (draw==false) {
list.count = stroka_y/list.item_h+2;
if (list.count < list.visible) list.count = list.visible;
label.size.height = list.count+1*list.item_h;
label.raw_size = 0;
}
free(DOM.start);
ExitProcess();
}
/programs/cmm/lib/font.h
210,11 → 210,10
=====================================================================================*/
 
 
inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
inline fastcall dword b24(EAX) { return DSDWORD[EAX] & 0x00FFFFFF; }
:void LABEL::apply_smooth()
{
dword i,line_w,to;
rgb.DwordToRgb(ShadowPixel(background,2)); //get shadowed pixel
dword i,line_w,to,dark_background;
line_w = size.width * 3;
to = size.height - 1 * line_w + raw - 3;
for(i=raw; i < to; i+=3)
223,31 → 222,19
// pixels position, where b - black, w - write
// bw
// wb
if(b24(i)==0x000000) && (b24(i+3)!=0x000000) && (b24(i+line_w)!=0x000000) && (b24(i+3+line_w)==0x000000)
if(b24(i)!=background) && (b24(i+3)==background) && (b24(i+line_w)==background) && (b24(i+3+line_w)!=background)
{
ESBYTE[i+3] = rgb.b;
ESBYTE[i+4] = rgb.g;
ESBYTE[i+5] = rgb.r;
ESBYTE[i+line_w ] = rgb.b;
ESBYTE[i+line_w+1] = rgb.g;
ESBYTE[i+line_w+2] = rgb.r;
// // I don't know why but underneath code works slower then beneath
// DSDWORD[i] = DSDWORD[i] & 0xFF000000 | dark_background;
// DSDWORD[i+line_w] = DSDWORD[i+3+line_w] & 0xFF000000 | dark_background;
dark_background = MixColors(background,b24(i),200);
DSDWORD[i+3] = DSDWORD[i+3] & 0xFF000000 | dark_background;
DSDWORD[i+line_w] = DSDWORD[i+line_w] & 0xFF000000 | dark_background;
}
// wb
// bw
else if(b24(i)!=0x000000) && (b24(i+3)==0x000000) && (b24(i+line_w)==0x000000) && (b24(i+3+line_w)!=0x000000)
else if(b24(i)==background) && (b24(i+3)!=background) && (b24(i+line_w)!=background) && (b24(i+3+line_w)==background)
{
ESBYTE[i ] = rgb.b;
ESBYTE[i+1] = rgb.g;
ESBYTE[i+2] = rgb.r;
ESBYTE[i+line_w+3] = rgb.b;
ESBYTE[i+line_w+4] = rgb.g;
ESBYTE[i+line_w+5] = rgb.r;
// // I don't know why but underneath code works slower then beneath
// DSDWORD[i] = DSDWORD[i] & 0xFF000000 | dark_background;
// DSDWORD[i+3+line_w] = DSDWORD[i+3+line_w] & 0xFF000000 | dark_background;
dark_background = MixColors(background,b24(i+3),200);
DSDWORD[i] = DSDWORD[i] & 0xFF000000 | dark_background;
DSDWORD[i+3+line_w] = DSDWORD[i+3+line_w] & 0xFF000000 | dark_background;
}
}
}