Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7285 → Rev 7286

/programs/cmm/aelia/aelia.c
1,4 → 1,4
#define MEMSIZE 4096*80
#define MEMSIZE 4096*100
 
#include "../lib/kfont.h"
#include "../lib/io.h"
88,9 → 88,9
{
InitDlls();
OpenDialog_init stdcall (#o_dialog);
LoadIniSettings();
kfont.init(DEFAULT_FONT);
Libimg_LoadImage(#skin, abspath("toolbar.png"));
LoadIniSettings();
list.no_selection = true;
SetEventMask(10000000000000000000000001100111b);
loop()
/programs/cmm/aelia/canvas.h
2,12 → 2,13
struct _canvas
{
void write_text();
void draw_bar();
void draw_hor_line();
};
 
void _canvas::write_text(int _x, _y; dword _text_col, _text_off)
{
char error_message[128];
 
if (_x > list.w) {
sprintf(#error_message, "ERROR: canvas.x overflow: H %d X %d", kfont.size.height, _x);
debugln(#error_message);
22,7 → 23,7
}
 
 
void _canvas::draw_bar(dword _x, _y, _w, _color)
void _canvas::draw_hor_line(dword _x, _y, _w, _color)
{
int i;
for (i = _y*list.w+_x*KFONT_BPP+kfont.raw ; i<_y*list.w+_x+_w*KFONT_BPP+kfont.raw ; i+=KFONT_BPP)
/programs/cmm/aelia/gui.h
1,7 → 1,7
void DrawToolbarButton(char image_id, int x)
void DrawToolbarButton(dword image_id, x)
{
DefineButton(x+1, 7, TOOLBAR_ICON_WIDTH-2, TOOLBAR_ICON_HEIGHT-2, 10+image_id + BT_HIDE, 0);
img_draw stdcall(skin.image, x, 6, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, 0, image_id*TOOLBAR_ICON_HEIGHT);
DrawLibImage(skin.image, x, 6, TOOLBAR_ICON_WIDTH, TOOLBAR_ICON_HEIGHT, 0, image_id*TOOLBAR_ICON_HEIGHT);
}
 
 
39,27 → 39,6
return history_page;
}
 
char char_width[255];
 
void get_label_symbols_size()
{
int i;
kfont.changeSIZE();
for (i=0; i<256; i++) char_width[i] = kfont.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++;
}
}
 
enum {
STEP_1_DOWNLOAD_PAGE = 0,
STEP_2_COUNT_PAGE_HEIGHT = 35,
/programs/cmm/aelia/prepare_page.h
1,44 → 1,3
void ParseTxt()
{
_canvas canvas;
byte ch, zeroch=0;
dword bufoff, buflen, line_start, srch_pos;
int stroka_y=5, line_length=0;
 
line_start=io.buffer_data;
buflen = strlen(io.buffer_data) + io.buffer_data;
for (bufoff=io.buffer_data; bufoff<buflen; bufoff++)
{
ch = ESBYTE[bufoff];
line_length += char_width[ch];
if (line_length>=list.w-30) || (ch==10) {
srch_pos = bufoff;
loop()
{
if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
if (srch_pos == line_start) break; //no white space found in whole line
srch_pos--;
}
if (kfont.size.height) {
ESBYTE[bufoff] >< zeroch; //set line end
canvas.write_text(8, stroka_y, 0x000000, line_start);
ESBYTE[bufoff] >< zeroch; //restore line
}
stroka_y += list.item_h;
line_start = bufoff;
line_length = 0;
}
}
if (!kfont.size.height) {
list.count = stroka_y/list.item_h+3;
if (list.count < list.visible) list.count = list.visible;
kfont.size.height = list.count+5*list.item_h;
kfont.raw_size = 0;
ParseTxt();
}
else canvas.write_text(8, stroka_y, 0x000000, line_start);
}
 
/*========================================================
= =
= STYLE =
48,11 → 7,12
#define HTML_PADDING_Y 5;
 
struct _style {
bool b, u, i, s;
bool bold, underlined, italic, strike;
bool h1, h2, h3, h4, h5, h6;
bool a;
bool pre;
bool ignore;
bool body;
dword color;
void clear();
};
59,12 → 19,13
 
void _style::clear()
{
b=u=i=s=0;
bold=underlined=italic=strike=0;
h1=h2=h3=h4=h5=h6=0;
a=0;
pre=0;
ignore=0;
color=0;
body=0;
}
 
/*========================================================
76,8 → 37,12
dword start;
dword end;
dword name;
dword param[10];
dword value[10];
 
bool opens;
 
dword param;
dword value;
 
void parse();
int nameis();
};
84,12 → 49,31
 
void _tag::parse()
{
dword START = start;
 
calc(1); //WTF
 
if (ESBYTE[START]=='/') {
START++;
opens = false;
} else opens = true;
 
name = START;
while ( (START < end) && (!__isWhite(ESBYTE[START])) ) {
START++;
}
if (START!=end) ESBYTE[START] = '\0';
START++;
 
strlwr(name);
 
start = START;
}
 
int _tag::nameis(dword _in_tag_name)
{
if (name) && (strcmp(_in_tag_name, start)==0) return true;
if (name) && (streq(_in_tag_name, name)) return true;
return false;
}
 
149,6 → 133,8
int size_pt_change;
dword start;
dword end;
 
dword width;
};
 
/*
209,9 → 195,9
_text text;
_canvas canvas;
void init();
void apply_text();
void set_style();
void parse();
void apply_text();
};
 
void _dom::init()
223,13 → 209,16
 
void _dom::set_style()
{
/*
if (tag.nameis("pre")) style.pre = true;
if (tag.nameis("/pre")) style.pre = false;
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 (tag.nameis("body")) style.body = tag.opens;
if (tag.nameis("b")) style.bold = tag.opens;
if (tag.nameis("i")) style.italic = tag.opens;
if (tag.nameis("s")) style.strike = tag.opens;
if (tag.nameis("pre")) style.pre = tag.opens;
if (tag.nameis("style")) style.ignore = tag.opens;
if (tag.nameis("a")) {
style.a = tag.opens;
if (tag.opens) style.color=0x0000FF; else style.color=0;
}
 
if (tag.nameis("br"))
|| (tag.nameis("p"))
239,12 → 228,25
return;
}
 
if (dom.tag.nameis("title")) {
if (tag.nameis("li")) && (tag.opens) {
draw.line_break();
return;
}
 
if (tag.nameis("td")) && (tag.opens) {
draw.line_break();
return;
}
 
/*
if (tag.nameis("title")) {
strcpy(#title, text.start);
strcat(#title, " - Aelia");
DrawTitle(#title);
}
 
 
 
if (tag.nameis("h1")) || (tag.nameis("/h1")) ||
(tag.nameis("h2")) || (tag.nameis("/h2")) ||
(tag.nameis("h3")) || (tag.nameis("/h3")) {
277,9 → 279,14
 
void _dom::apply_text()
{
if (kfont.size.height) canvas.write_text(draw.x, draw.y, style.color, text.start);
draw.line_break();
if (kfont.size.height) && (style.body) {
kfont.bold = style.bold;
canvas.write_text(draw.x, draw.y, style.color, text.start);
if (style.a) {
canvas.draw_hor_line(draw.x+1, draw.y + list.item_h-2, kfont.get_label_width(text.start), style.color);
}
}
}
 
void _dom::parse()
{
294,7 → 301,6
tag.start = i+1;
text.end = i-1;
ESBYTE[i] = '\0';
debug("TXT "); debugln(text.start);
apply_text();
}
if (ESBYTE[i]=='>') {
301,9 → 307,8
tag.end = i-1;
text.start = i+1;
ESBYTE[i] = '\0';
debug("TAG "); debugln(tag.start);
//tag.parse();
//set_style();
tag.parse();
set_style();
}
}
 
329,7 → 334,6
_dom dom;
list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, Form.cheight-TOOLBAR_H, kfont.size.pt+4);
strcpy(#title, history.current()+strrchr(history.current(),'/'));
get_label_symbols_size(); //get font chars width, need to increase performance
ChangeCharset(charsets[encoding], "CP866", io.buffer_data);
link.clear();
 
340,4 → 344,45
kfont.ApplySmooth();
 
DrawPage();
}
 
void ParseTxt()
{
_canvas canvas;
byte ch, zeroch=0;
dword bufoff, buflen, line_start, srch_pos;
int stroka_y=5, line_length=0;
 
line_start=io.buffer_data;
buflen = strlen(io.buffer_data) + io.buffer_data;
for (bufoff=io.buffer_data; bufoff<buflen; bufoff++)
{
ch = ESBYTE[bufoff];
line_length += kfont_char_width[ch];
if (line_length>=list.w-30) || (ch==10) {
srch_pos = bufoff;
loop()
{
if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
if (srch_pos == line_start) break; //no white space found in whole line
srch_pos--;
}
if (kfont.size.height) {
ESBYTE[bufoff] >< zeroch; //set line end
canvas.write_text(8, stroka_y, 0x000000, line_start);
ESBYTE[bufoff] >< zeroch; //restore line
}
stroka_y += list.item_h;
line_start = bufoff;
line_length = 0;
}
}
if (!kfont.size.height) {
list.count = stroka_y/list.item_h+3;
if (list.count < list.visible) list.count = list.visible;
kfont.size.height = list.count+5*list.item_h;
kfont.raw_size = 0;
ParseTxt();
}
else canvas.write_text(8, stroka_y, 0x000000, line_start);
}