kfont.h: split symbol() and symbol_size() functions

git-svn-id: svn://kolibrios.org@6806 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2016-12-21 19:50:13 +00:00
parent aa8338809f
commit c299820b03
12 changed files with 113 additions and 138 deletions

View File

@ -88,7 +88,7 @@ void main()
InitDlls(); InitDlls();
OpenDialog_init stdcall (#o_dialog); OpenDialog_init stdcall (#o_dialog);
CursorPointer.Load(#CursorFile); CursorPointer.Load(#CursorFile);
label.init(DEFAULT_FONT); kfont.init(DEFAULT_FONT);
Libimg_LoadImage(#skin, abspath("toolbar.png")); Libimg_LoadImage(#skin, abspath("toolbar.png"));
LoadIniSettings(); LoadIniSettings();
list.no_selection = true; list.no_selection = true;
@ -328,18 +328,18 @@ char favicon_address[UML];
void EventMagnifyPlus() void EventMagnifyPlus()
{ {
label.size.pt++; kfont.size.pt++;
if(!label.changeSIZE()) if(!kfont.changeSIZE())
label.size.pt--; kfont.size.pt--;
else else
PreparePage(); PreparePage();
} }
void EventMagnifyMinus() void EventMagnifyMinus()
{ {
label.size.pt--; kfont.size.pt--;
if(!label.changeSIZE()) if(!kfont.changeSIZE())
label.size.pt++; kfont.size.pt++;
else else
PreparePage(); PreparePage();
} }
@ -435,7 +435,7 @@ void draw_window()
} }
else else
{ {
if (!label.raw) { //this code need to be run if (!kfont.raw) { //this code need to be run
if (param) EventOpenAddress(#param); //only once at browser sturtup if (param) EventOpenAddress(#param); //only once at browser sturtup
else EventOpenAddress("aelia:home"); else EventOpenAddress("aelia:home");
} }
@ -448,7 +448,7 @@ void draw_window()
void DrawPage() void DrawPage()
{ {
list.CheckDoesValuesOkey(); list.CheckDoesValuesOkey();
if (list.count) _PutImage(list.x,list.y,list.w,list.h,list.first*list.item_h*list.w*3 + label.raw); if (list.count) _PutImage(list.x,list.y,list.w,list.h,list.first*list.item_h*list.w*3 + kfont.raw);
DrawScroller(); DrawScroller();
} }

View File

@ -4,7 +4,7 @@ int encoding;
void LoadIniSettings() void LoadIniSettings()
{ {
label.size.pt = 14; kfont.size.pt = 14;
encoding = CH_CP866; encoding = CH_CP866;
Form.left = 150; Form.left = 150;
Form.top = 50; Form.top = 50;
@ -12,7 +12,7 @@ void LoadIniSettings()
Form.height = 560; Form.height = 560;
/* /*
strcpy(#ini_path, "/sys/settings/treader.ini"); strcpy(#ini_path, "/sys/settings/treader.ini");
ini_get_int stdcall (#ini_path, #config_section, "FontSize", 14); label.size.pt = EAX; ini_get_int stdcall (#ini_path, #config_section, "FontSize", 14); kfont.size.pt = EAX;
ini_get_int stdcall (#ini_path, #config_section, "Encoding", CH_CP866); encoding = EAX; ini_get_int stdcall (#ini_path, #config_section, "Encoding", CH_CP866); encoding = EAX;
ini_get_int stdcall (#ini_path, #config_section, "WinX", 150); Form.left = EAX; ini_get_int stdcall (#ini_path, #config_section, "WinX", 150); Form.left = EAX;
ini_get_int stdcall (#ini_path, #config_section, "WinY", 50); Form.top = EAX; ini_get_int stdcall (#ini_path, #config_section, "WinY", 50); Form.top = EAX;
@ -24,7 +24,7 @@ void LoadIniSettings()
void SaveIniSettings() void SaveIniSettings()
{ {
/* /*
ini_set_int stdcall (#ini_path, #config_section, "FontSize", label.size.pt); ini_set_int stdcall (#ini_path, #config_section, "FontSize", kfont.size.pt);
ini_set_int stdcall (#ini_path, #config_section, "Encoding", encoding); ini_set_int stdcall (#ini_path, #config_section, "Encoding", encoding);
ini_set_int stdcall (#ini_path, #config_section, "WinX", Form.left); ini_set_int stdcall (#ini_path, #config_section, "WinX", Form.left);
ini_set_int stdcall (#ini_path, #config_section, "WinY", Form.top); ini_set_int stdcall (#ini_path, #config_section, "WinY", Form.top);

View File

@ -3,8 +3,8 @@ char char_width[255];
void get_label_symbols_size() void get_label_symbols_size()
{ {
int i; int i;
label.changeSIZE(); kfont.changeSIZE();
for (i=0; i<256; i++) char_width[i] = label.symbol_size(i); for (i=0; i<256; i++) char_width[i] = kfont.symbol_size(i);
} }
int get_label_len(dword _text) int get_label_len(dword _text)
@ -23,15 +23,15 @@ void WriteTextIntoBuf(int _x, _y; dword _text_col, _text_off)
{ {
char error_message[128]; char error_message[128];
if (_x > list.w) { if (_x > list.w) {
sprintf(#error_message, "'WriteTextIntoBuf _x overflow: H %d X %d' -A", label.size.height, _x); sprintf(#error_message, "'WriteTextIntoBuf _x overflow: H %d X %d' -A", kfont.size.height, _x);
notify(#error_message); notify(#error_message);
} }
if (_y+label.size.pt > label.size.height) { if (_y+kfont.size.pt > kfont.size.height) {
sprintf(#error_message, "'WriteTextIntoBuf _y overflow: H %d Y %d' -A", label.size.height, _y); sprintf(#error_message, "'WriteTextIntoBuf _y overflow: H %d Y %d' -A", kfont.size.height, _y);
notify(#error_message); notify(#error_message);
return; return;
} }
label.WriteIntoBuffer(_x, _y, list.w, label.size.height, 0xFFFFFF, _text_col, label.size.pt, _text_off); kfont.WriteIntoBuffer(_x, _y, list.w, kfont.size.height, 0xFFFFFF, _text_col, kfont.size.pt, _text_off);
if (_y/list.item_h-list.first==list.visible) DrawPage(); if (_y/list.item_h-list.first==list.visible) DrawPage();
} }
@ -39,5 +39,5 @@ void WriteTextIntoBuf(int _x, _y; dword _text_col, _text_off)
void label_draw_bar(dword _x, _y, _w, _color) void label_draw_bar(dword _x, _y, _w, _color)
{ {
int i; 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; for (i = _y*list.w+_x*3+kfont.raw ; i<_y*list.w+_x+_w*3+kfont.raw ; i+=3) ESDWORD[i] = _color;
} }

View File

@ -1,7 +1,7 @@
void PreparePage() void PreparePage()
{ {
list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, Form.cheight-TOOLBAR_H, label.size.pt+2); list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, Form.cheight-TOOLBAR_H, kfont.size.pt+2);
strcpy(#title, history.current()+strrchr(history.current(),'/')); strcpy(#title, history.current()+strrchr(history.current(),'/'));
//get font chars width, need to increase performance //get font chars width, need to increase performance
get_label_symbols_size(); get_label_symbols_size();
@ -20,7 +20,7 @@ void PreparePage()
} }
strcat(#title, " - Aelia"); strcat(#title, " - Aelia");
DrawTitle(#title); DrawTitle(#title);
DrawProgress(STEP_4_SMOOTH_FONT); label.ApplySmooth(); DrawProgress(STEP_4_SMOOTH_FONT); kfont.ApplySmooth();
DrawProgress(STEP_5_STOP); DrawPage(); DrawProgress(STEP_5_STOP); DrawPage();
} }
@ -57,8 +57,8 @@ int stroka_y=5, line_length=0;
if (draw==false) { if (draw==false) {
list.count = stroka_y/list.item_h+3; list.count = stroka_y/list.item_h+3;
if (list.count < list.visible) list.count = list.visible; if (list.count < list.visible) list.count = list.visible;
label.size.height = list.count+5*list.item_h; kfont.size.height = list.count+5*list.item_h;
label.raw_size = 0; kfont.raw_size = 0;
} }
if (draw==true) WriteTextIntoBuf(8, stroka_y, 0x000000, line_start); if (draw==true) WriteTextIntoBuf(8, stroka_y, 0x000000, line_start);
} }
@ -124,7 +124,7 @@ _tag tag;
if (draw==true) { if (draw==true) {
if (style.a) { if (style.a) {
link.add(stroka_x,stroka_y + size_pt_change,get_label_len(text.start),list.item_h,text.start," "); link.add(stroka_x,stroka_y + size_pt_change,get_label_len(text.start),list.item_h,text.start," ");
label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color); label_draw_bar(stroka_x, stroka_y+kfont.size.pt+1, get_label_len(text.start), style.color);
} }
WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start); WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
} }
@ -137,7 +137,7 @@ _tag tag;
if (draw==true) { if (draw==true) {
if (style.a) { if (style.a) {
link.add(stroka_x,stroka_y + size_pt_change,get_label_len(text.start),list.item_h,text.start," "); link.add(stroka_x,stroka_y + size_pt_change,get_label_len(text.start),list.item_h,text.start," ");
label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color); label_draw_bar(stroka_x, stroka_y+kfont.size.pt+1, get_label_len(text.start), style.color);
} }
WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start); WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
} }
@ -172,7 +172,7 @@ _tag tag;
} else if (tag.nameis("/h3")) { } else if (tag.nameis("/h3")) {
size_pt_change = -4; size_pt_change = -4;
} }
label.size.pt += size_pt_change; kfont.size.pt += size_pt_change;
get_label_symbols_size(); get_label_symbols_size();
if (size_pt_change > 0) { if (size_pt_change > 0) {
stroka_y+= list.item_h;//что если будет очень длинная строка в теге? stroka_y+= list.item_h;//что если будет очень длинная строка в теге?
@ -192,8 +192,8 @@ _tag tag;
if (draw==false) { if (draw==false) {
list.count = stroka_y/list.item_h+3; list.count = stroka_y/list.item_h+3;
if (list.count < list.visible) list.count = list.visible; if (list.count < list.visible) list.count = list.visible;
label.size.height = list.count+5*list.item_h; kfont.size.height = list.count+5*list.item_h;
label.raw_size = 0; kfont.raw_size = 0;
} }
free(DOM_start); free(DOM_start);
} }

View File

@ -708,7 +708,7 @@ void Line_ReDraw(dword bgcol, filenum){
if (text_col==0xA6A6B7) text_col=0xFFFFFF; if (text_col==0xA6A6B7) text_col=0xFFFFFF;
} }
if (file.selected) text_col=0xFF0000; if (file.selected) text_col=0xFF0000;
if (label.size.pt==9) || (!label.font) if (kfont.size.pt==9) || (!kfont.font)
{ {
if (Form.width>=480) if (Form.width>=480)
{ {
@ -724,14 +724,14 @@ void Line_ReDraw(dword bgcol, filenum){
else else
{ {
strcpy(#label_file_name, file_name_off); strcpy(#label_file_name, file_name_off);
if (label.getsize(label.size.pt, #label_file_name) + 141 + 26 > files.w) if (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w)
{ {
while (label.getsize(label.size.pt, #label_file_name) + 141 + 26 > files.w) { while (kfont.getsize(kfont.size.pt, #label_file_name) + 141 + 26 > files.w) {
ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL; ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL;
} }
strcpy(#label_file_name+strlen(#label_file_name)-2, "..."); strcpy(#label_file_name+strlen(#label_file_name)-2, "...");
} }
label.WriteIntoWindow(files.x + 23, files.item_h - label.height / 2 + y, bgcol, text_col, label.size.pt, #label_file_name); kfont.WriteIntoWindow(files.x + 23, files.item_h - kfont.height / 2 + y, bgcol, text_col, kfont.size.pt, #label_file_name);
} }
DrawBar(files.x+files.w-141,y,1,files.item_h,system.color.work); //gray line 1 DrawBar(files.x+files.w-141,y,1,files.item_h,system.color.work); //gray line 1
DrawBar(files.x+files.w-68,y,1,files.item_h,system.color.work); //gray line 2 DrawBar(files.x+files.w-68,y,1,files.item_h,system.color.work); //gray line 2

View File

@ -78,8 +78,8 @@ void settings_dialog()
else if (id==25) { files.item_h++; files_active.item_h = files_inactive.item_h = files.item_h; } else if (id==25) { files.item_h++; files_active.item_h = files_inactive.item_h = files.item_h; }
else if (id==26) && (files.item_h>15) files_inactive.item_h = files.item_h = files.item_h-1; else if (id==26) && (files.item_h>15) files_inactive.item_h = files.item_h = files.item_h-1;
else if (id==27) show_status_bar ^= 1; else if (id==27) show_status_bar ^= 1;
else if (id==30) { label.size.pt++; IF(!label.changeSIZE()) label.size.pt--; BigFontsChange(); } else if (id==30) { kfont.size.pt++; IF(!kfont.changeSIZE()) kfont.size.pt--; BigFontsChange(); }
else if (id==31) { label.size.pt--; IF(!label.changeSIZE()) label.size.pt++; BigFontsChange(); } else if (id==31) { kfont.size.pt--; IF(!kfont.changeSIZE()) kfont.size.pt++; BigFontsChange(); }
EventRedrawWindow(Form.left,Form.top); EventRedrawWindow(Form.left,Form.top);
break; break;
@ -116,7 +116,7 @@ void DrawSettingsCheckBoxes()
CheckBox(x, y.inc(25), 22, NOTIFY_COPY_END, info_after_copy); CheckBox(x, y.inc(25), 22, NOTIFY_COPY_END, info_after_copy);
CheckBox(x, y.inc(25), 32, SHOW_BREADCRUMBS, show_breadcrumb); CheckBox(x, y.inc(25), 32, SHOW_BREADCRUMBS, show_breadcrumb);
CheckBox(x, y.inc(25), 24, USE_TWO_PANELS, two_panels); CheckBox(x, y.inc(25), 24, USE_TWO_PANELS, two_panels);
MoreLessBox(x, y.inc(31), 30, 31, label.size.pt, FONT_SIZE_LABEL); MoreLessBox(x, y.inc(31), 30, 31, kfont.size.pt, FONT_SIZE_LABEL);
MoreLessBox(x, y.inc(31), 25, 26, files.item_h, LIST_LINE_HEIGHT); MoreLessBox(x, y.inc(31), 25, 26, files.item_h, LIST_LINE_HEIGHT);
WriteText(6, y.inc(28), 0xD0, system.color.work_text, START_PATH); WriteText(6, y.inc(28), 0xD0, system.color.work_text, START_PATH);
path_start_ed.top = y.inc(23); path_start_ed.top = y.inc(23);
@ -137,7 +137,7 @@ void LoadIniSettings()
ini_get_int stdcall (eolite_ini_path, #config_section, "ShowStatusBar", 1); show_status_bar = EAX; ini_get_int stdcall (eolite_ini_path, #config_section, "ShowStatusBar", 1); show_status_bar = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "RealFileNamesCase", 1); real_files_names_case = EAX; ini_get_int stdcall (eolite_ini_path, #config_section, "RealFileNamesCase", 1); real_files_names_case = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "InfoAfterCopy", 0); info_after_copy = EAX; ini_get_int stdcall (eolite_ini_path, #config_section, "InfoAfterCopy", 0); info_after_copy = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "FontSize", 12); label.size.pt = EAX; ini_get_int stdcall (eolite_ini_path, #config_section, "FontSize", 12); kfont.size.pt = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "TwoPanels", 0); two_panels = EAX; ini_get_int stdcall (eolite_ini_path, #config_section, "TwoPanels", 0); two_panels = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "LineHeight", 19); files.item_h = EAX; ini_get_int stdcall (eolite_ini_path, #config_section, "LineHeight", 19); files.item_h = EAX;
ini_get_int stdcall (eolite_ini_path, #config_section, "WinX", 200); WinX = EAX; ini_get_int stdcall (eolite_ini_path, #config_section, "WinX", 200); WinX = EAX;
@ -150,9 +150,9 @@ void LoadIniSettings()
path_start_ed.pos = strlen(#path_start); path_start_ed.pos = strlen(#path_start);
ini_get_str stdcall ("/sys/SETTINGS/SYSTEM.INI", "system", "font file",#temp,4096,DEFAULT_FONT); ini_get_str stdcall ("/sys/SETTINGS/SYSTEM.INI", "system", "font file",#temp,4096,DEFAULT_FONT);
label.init(#temp); kfont.init(#temp);
ini_get_str stdcall ("/sys/SETTINGS/SYSTEM.INI", "system", "font smoothing",#temp,4096,"on"); ini_get_str stdcall ("/sys/SETTINGS/SYSTEM.INI", "system", "font smoothing",#temp,4096,"on");
if(!strcmp(#temp,"off")) label.smooth = false; else label.smooth = true; if(!strcmp(#temp,"off")) kfont.smooth = false; else kfont.smooth = true;
} }
@ -162,7 +162,7 @@ void SaveIniSettings()
ini_set_int stdcall (eolite_ini_path, #config_section, "ShowStatusBar", show_status_bar); ini_set_int stdcall (eolite_ini_path, #config_section, "ShowStatusBar", show_status_bar);
ini_set_int stdcall (eolite_ini_path, #config_section, "RealFileNamesCase", real_files_names_case); ini_set_int stdcall (eolite_ini_path, #config_section, "RealFileNamesCase", real_files_names_case);
ini_set_int stdcall (eolite_ini_path, #config_section, "InfoAfterCopy", info_after_copy); ini_set_int stdcall (eolite_ini_path, #config_section, "InfoAfterCopy", info_after_copy);
ini_set_int stdcall (eolite_ini_path, #config_section, "FontSize", label.size.pt); ini_set_int stdcall (eolite_ini_path, #config_section, "FontSize", kfont.size.pt);
ini_set_int stdcall (eolite_ini_path, #config_section, "TwoPanels", two_panels); ini_set_int stdcall (eolite_ini_path, #config_section, "TwoPanels", two_panels);
ini_set_int stdcall (eolite_ini_path, #config_section, "LineHeight", files.item_h); ini_set_int stdcall (eolite_ini_path, #config_section, "LineHeight", files.item_h);
ini_set_int stdcall (eolite_ini_path, #config_section, "WinX", Form.left); ini_set_int stdcall (eolite_ini_path, #config_section, "WinX", Form.left);
@ -202,7 +202,7 @@ void SetAppColors()
void BigFontsChange() void BigFontsChange()
{ {
files.item_h = label.size.pt + 4; files.item_h = kfont.size.pt + 4;
if (files.item_h<18) files.item_h = 18; if (files.item_h<18) files.item_h = 18;
files_active.item_h = files_inactive.item_h = files.item_h; files_active.item_h = files_inactive.item_h = files.item_h;
} }

View File

@ -17,7 +17,7 @@ void main()
int btn; int btn;
char title[4196]; char title[4196];
if (!param) strcpy(#param, DEFAULT_FONT); if (!param) strcpy(#param, DEFAULT_FONT);
label.init(#param); kfont.init(#param);
tabs.active_tab=PHRASE_TAB; tabs.active_tab=PHRASE_TAB;
strcpy(#title, "Font preview: "); strcpy(#title, "Font preview: ");
strcat(#title, #param); strcat(#title, #param);
@ -26,8 +26,8 @@ void main()
case evButton: case evButton:
btn = GetButtonID(); btn = GetButtonID();
if (btn==1) ExitProcess(); if (btn==1) ExitProcess();
if (btn==STRONG_BTN) label.bold ^=1; if (btn==STRONG_BTN) kfont.bold ^=1;
if (btn==SMOOTH_BTN) label.smooth ^=1; if (btn==SMOOTH_BTN) kfont.smooth ^=1;
if (btn==PHRASE_TAB) || (btn==CHARS_TAB) tabs.click(btn); if (btn==PHRASE_TAB) || (btn==CHARS_TAB) tabs.click(btn);
goto _DRAW_WINDOW_CONTENT; goto _DRAW_WINDOW_CONTENT;
case evReDraw: case evReDraw:
@ -37,12 +37,12 @@ void main()
if (Form.status_window>2) break; if (Form.status_window>2) break;
_DRAW_WINDOW_CONTENT: _DRAW_WINDOW_CONTENT:
DrawBar(0, 0, Form.cwidth, PANELH-1, system.color.work); DrawBar(0, 0, Form.cwidth, PANELH-1, system.color.work);
CheckBox(10, 8, STRONG_BTN, "Bold", label.bold); CheckBox(10, 8, STRONG_BTN, "Bold", kfont.bold);
CheckBox(83,8, SMOOTH_BTN, "Smooth", label.smooth); CheckBox(83,8, SMOOTH_BTN, "Smooth", kfont.smooth);
tabs.draw(Form.cwidth-150, PANELH, PHRASE_TAB, "Phrase"); tabs.draw(Form.cwidth-150, PANELH, PHRASE_TAB, "Phrase");
tabs.draw(Form.cwidth-70, PANELH, CHARS_TAB, "Chars"); tabs.draw(Form.cwidth-70, PANELH, CHARS_TAB, "Chars");
DrawBar(0, PANELH-1,Form.cwidth,1,system.color.work_graph); DrawBar(0, PANELH-1,Form.cwidth,1,system.color.work_graph);
if (!label.font) if (!kfont.font)
{ {
DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff); DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff);
WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded."); WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
@ -57,14 +57,14 @@ void DrawPreviewPhrase()
{ {
dword i, y; dword i, y;
char line[256]; char line[256];
label.raw_size = free(label.raw); kfont.raw_size = free(kfont.raw);
for (i=10, y=5; i<22; i++, y+=label.height;) //not flexible, need to calculate font count and max line length for (i=10, y=5; i<22; i++, y+=kfont.height;) //not flexible, need to calculate font count and max line length
{ {
sprintf(#line,"<EFBFBD> §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i); sprintf(#line,"<EFBFBD> §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
label.WriteIntoBuffer(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line); kfont.WriteIntoBuffer(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line);
} }
if (label.smooth) label.ApplySmooth(); if (kfont.smooth) kfont.ApplySmooth();
label.ShowBuffer(0, PANELH); kfont.ShowBuffer(0, PANELH);
} }
void DrawPreviewChars() void DrawPreviewChars()
@ -72,17 +72,17 @@ void DrawPreviewChars()
dword i, x=20, y=0; dword i, x=20, y=0;
char line[2]; char line[2];
line[1]=NULL; line[1]=NULL;
label.raw_size = free(label.raw); kfont.raw_size = free(kfont.raw);
for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length
{ {
line[0]=i; line[0]=i;
label.WriteIntoBuffer(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line); kfont.WriteIntoBuffer(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line);
x+= label.height+2; x+= kfont.height+2;
if (x>=Form.cwidth-30) { if (x>=Form.cwidth-30) {
x=20; x=20;
y+=label.height+2; y+=kfont.height+2;
} }
} }
if (label.smooth) label.ApplySmooth(); if (kfont.smooth) kfont.ApplySmooth();
label.ShowBuffer(0, PANELH); kfont.ShowBuffer(0, PANELH);
} }

View File

@ -31,7 +31,7 @@
dword raw; dword raw;
dword raw_size; dword raw_size;
byte init(); bool init();
bool changeSIZE(); bool changeSIZE();
byte symbol(); byte symbol();
byte symbol_size(); byte symbol_size();
@ -42,7 +42,7 @@
int WriteIntoWindowCenter(); int WriteIntoWindowCenter();
void WriteIntoBuffer(); void WriteIntoBuffer();
void ShowBuffer(); void ShowBuffer();
} label; } kfont;
:bool LABEL::changeSIZE() :bool LABEL::changeSIZE()
{ {
@ -59,6 +59,7 @@
block = math.ceil(height*width/32); block = math.ceil(height*width/32);
return true; return true;
} }
:dword LABEL::getsize(byte fontSizePoints, dword text1) :dword LABEL::getsize(byte fontSizePoints, dword text1)
{ {
size.height = size.width = 0; size.height = size.width = 0;
@ -67,7 +68,7 @@
if(size.pt)if(!changeSIZE())return 0; if(size.pt)if(!changeSIZE())return 0;
WHILE(DSBYTE[text1]) WHILE(DSBYTE[text1])
{ {
symbol_size(DSBYTE[text1]); size.width += symbol_size(DSBYTE[text1]);
text1++; text1++;
} }
$neg size.offset_y $neg size.offset_y
@ -76,84 +77,59 @@
size.width += size.offset_x+1; size.width += size.offset_x+1;
return size.width; return size.width;
} }
:byte LABEL::symbol_size(byte s) :byte LABEL::symbol_size(byte s)
{ {
//return symbol_size(s); int chaw_width;
dword xi,yi; chaw_width = symbol(0,0, s, 0);
dword tmp,_; if(bold) chaw_width += math.ceil(size.pt/17);
dword iii = 0; return chaw_width;
byte rw=0;
byte X;
if(bold) size.width+=math.ceil(size.pt/17);
if(s==32)
{
size.width += width/4;
return;
}
if(s==9)
{
size.width += width;
return;
}
s = Cp866ToAnsi(s);
tmp = block*s << 2 + font;
for(yi=0; yi<height; yi++)
{
for(xi=0; xi<width; xi++)
{
if(iii%32) _ >>= 1;
else
{
tmp += 4;
_ = DSDWORD[tmp];
}
if(_&1)
{
if(xi>rw)rw=xi;
if(size.height<yi)size.height = yi;
if(size.offset_y<0)size.offset_y = yi;
else if(yi<size.offset_y)size.offset_y = yi;
if(!X) X = xi;
else if(X>xi)X = xi;
}
iii++;
}
}
size.width += rw;
if(size.offset_x<0)size.offset_x = X;
} }
:byte LABEL::symbol(signed x,y; byte s; dword image_raw) :byte LABEL::symbol(signed x,y; byte s; dword image_raw)
{ {
dword xi,yi; dword xi,yi;
dword iii = 0; dword iii = 0;
dword offs; dword offs;
byte rw=0; dword tmp, _;
byte X;
byte chaw_width=0;
if(s==32)return width/4; if(s==32)return width/4;
if(s==9)return width; if(s==9)return width;
s = Cp866ToAnsi(s); s = Cp866ToAnsi(s);
EBX = block*s << 2 + font; tmp = block*s << 2 + font;
for(yi=0; yi<height; yi++) for(yi=0; yi<height; yi++)
{ {
EDI = size.offset_y + yi + y * size.width * 3 + image_raw; EDI = size.offset_y + yi + y * size.width * 3 + image_raw;
for(xi=0; xi<width; xi++) for(xi=0; xi<width; xi++)
{ {
if(iii%32) $shr ecx,1 if(iii%32) _ >>= 1;
else else
{ {
EBX += 4; tmp += 4;
ECX = DSDWORD[EBX]; _ = DSDWORD[tmp];
} }
if(ECX&true) if(_&1) //check does the pixel set
{ {
if(xi>rw)rw=xi; if(xi>chaw_width)chaw_width=xi;
if (image_raw)
{
offs = x + xi *3 + EDI; offs = x + xi *3 + EDI;
DSDWORD[offs] = DSDWORD[offs] & 0xFF000000 | color; DSDWORD[offs] = DSDWORD[offs] & 0xFF000000 | color;
if(bold) DSDWORD[offs+3] = DSDWORD[offs+3] & 0xFF000000 | color; if(bold) DSDWORD[offs+3] = DSDWORD[offs+3] & 0xFF000000 | color;
}
else
{
if(size.height<yi)size.height = yi;
if(size.offset_y<0)size.offset_y = yi; else if(yi<size.offset_y)size.offset_y = yi;
if(!X) X = xi; else if(X>xi)X = xi;
if(size.offset_x<0)size.offset_x = X;
}
} }
iii++; iii++;
} }
} }
return rw; return chaw_width;
} }
inline fastcall Cp866ToAnsi(AL) { inline fastcall Cp866ToAnsi(AL) {
@ -168,7 +144,7 @@ inline fastcall Cp866ToAnsi(AL) {
return AL; return AL;
} }
:byte LABEL::init(dword font_path) :bool LABEL::init(dword font_path)
{ {
IO label_io; IO label_io;
if(font)free(font); if(font)free(font);
@ -206,7 +182,7 @@ inline fastcall dword b24(EAX) { return DSDWORD[EAX] & 0x00FFFFFF; }
// wb // wb
if(b24(i)!=background) && (b24(i+3)==background) && (b24(i+line_w)==background) && (b24(i+3+line_w)!=background) if(b24(i)!=background) && (b24(i+3)==background) && (b24(i+line_w)==background) && (b24(i+3+line_w)!=background)
{ {
dark_background = MixColors(background,b24(i),210); dark_background = MixColors(background,b24(i),200);
DSDWORD[i+3] = DSDWORD[i+3] & 0xFF000000 | dark_background; DSDWORD[i+3] = DSDWORD[i+3] & 0xFF000000 | dark_background;
DSDWORD[i+line_w] = DSDWORD[i+line_w] & 0xFF000000 | dark_background; DSDWORD[i+line_w] = DSDWORD[i+line_w] & 0xFF000000 | dark_background;
} }
@ -214,7 +190,7 @@ inline fastcall dword b24(EAX) { return DSDWORD[EAX] & 0x00FFFFFF; }
// bw // bw
else if(b24(i)==background) && (b24(i+3)!=background) && (b24(i+line_w)!=background) && (b24(i+3+line_w)==background) else if(b24(i)==background) && (b24(i+3)!=background) && (b24(i+line_w)!=background) && (b24(i+3+line_w)==background)
{ {
dark_background = MixColors(background,b24(i+3),210); dark_background = MixColors(background,b24(i+3),200);
DSDWORD[i] = DSDWORD[i] & 0xFF000000 | dark_background; DSDWORD[i] = DSDWORD[i] & 0xFF000000 | dark_background;
DSDWORD[i+3+line_w] = DSDWORD[i+3+line_w] & 0xFF000000 | dark_background; DSDWORD[i+3+line_w] = DSDWORD[i+3+line_w] & 0xFF000000 | dark_background;
} }
@ -280,5 +256,4 @@ inline fastcall dword b24(EAX) { return DSDWORD[EAX] & 0x00FFFFFF; }
} }
#endif #endif

View File

@ -51,7 +51,7 @@ void load_config()
void main() void main()
{ {
dword id; dword id;
label.init(DEFAULT_FONT); kfont.init(DEFAULT_FONT);
load_dll(libio, #libio_init,1); load_dll(libio, #libio_init,1);
load_dll(libimg, #libimg_init,1); load_dll(libimg, #libimg_init,1);
load_dll(libini, #lib_init,1); load_dll(libini, #lib_init,1);
@ -135,8 +135,8 @@ byte draw_icons_from_section(dword key_value, key_name, sec_name, f_name)
img_draw stdcall(skin.image, col*list.item_w+tmp-10, row*list.item_h+5 + list_pos, 32, 32, 0, icon_id*32); img_draw stdcall(skin.image, col*list.item_w+tmp-10, row*list.item_h+5 + list_pos, 32, 32, 0, icon_id*32);
if (icon_char_pos) ESBYTE[icon_char_pos] = '\0'; //delete icon from string if (icon_char_pos) ESBYTE[icon_char_pos] = '\0'; //delete icon from string
app_path_collection.add(key_value); app_path_collection.add(key_value);
//label.WriteIntoWindowCenter(col*list.item_w+7,row*list.item_h+47 + list_pos, list.item_w,0, LIST_BACKGROUND_COLOR, 0xDCDCDC, 12, key_name); //kfont.WriteIntoWindowCenter(col*list.item_w+7,row*list.item_h+47 + list_pos, list.item_w,0, LIST_BACKGROUND_COLOR, 0xDCDCDC, 12, key_name);
label.WriteIntoWindowCenter(col*list.item_w+6,row*list.item_h+46 + list_pos, list.item_w,0, LIST_BACKGROUND_COLOR, 0x000000, 12, key_name); kfont.WriteIntoWindowCenter(col*list.item_w+6,row*list.item_h+46 + list_pos, list.item_w,0, LIST_BACKGROUND_COLOR, 0x000000, 12, key_name);
if (list.cur_y == list.count) DrawWideRectangle(col*list.item_w+6, row*list.item_h + list_pos,list.item_w,list.item_h-5, 2, 0x0080FF); if (list.cur_y == list.count) DrawWideRectangle(col*list.item_w+6, row*list.item_h + list_pos,list.item_w,list.item_h-5, 2, 0x0080FF);
list.count++; list.count++;
col++; col++;
@ -161,7 +161,7 @@ byte process_sections(dword sec_name, f_name)
col = 0; col = 0;
old_row = row; old_row = row;
DrawBar(0, row * list.item_h + list_pos, Form.cwidth , 29, LIST_BACKGROUND_COLOR); DrawBar(0, row * list.item_h + list_pos, Form.cwidth , 29, LIST_BACKGROUND_COLOR);
text_len = label.WriteIntoWindow(10, row * list.item_h + 10 + list_pos, LIST_BACKGROUND_COLOR, 0, 15, sec_name); text_len = kfont.WriteIntoWindow(10, row * list.item_h + 10 + list_pos, LIST_BACKGROUND_COLOR, 0, 15, sec_name);
DrawBar(text_len+20, row * list.item_h + list_pos + 20, Form.cwidth-text_len-20, 1, 0xDCDCDC); DrawBar(text_len+20, row * list.item_h + list_pos + 20, Form.cwidth-text_len-20, 1, 0xDCDCDC);
DrawBar(text_len+20, row * list.item_h + list_pos + 21, Form.cwidth-text_len-20, 1, 0xFCFCFC); DrawBar(text_len+20, row * list.item_h + list_pos + 21, Form.cwidth-text_len-20, 1, 0xFCFCFC);
list_pos += 29; list_pos += 29;
@ -174,7 +174,7 @@ void draw_top_bar()
DrawBar(0,0,Form.cwidth, list.y-2, system.color.work); DrawBar(0,0,Form.cwidth, list.y-2, system.color.work);
DrawBar(0,list.y-2, Form.cwidth, 1, MixColors(system.color.work, system.color.work_graph, 180)); DrawBar(0,list.y-2, Form.cwidth, 1, MixColors(system.color.work, system.color.work_graph, 180));
DrawBar(0,list.y-1, Form.cwidth, 1, system.color.work_graph); DrawBar(0,list.y-1, Form.cwidth, 1, system.color.work_graph);
label.WriteIntoWindowCenter(0,5, Form.cwidth, list.y, system.color.work, system.color.work_text, 16, #window_title); kfont.WriteIntoWindowCenter(0,5, Form.cwidth, list.y, system.color.work, system.color.work_text, 16, #window_title);
} }
void EventRunApp(dword appid) void EventRunApp(dword appid)

View File

@ -5,7 +5,7 @@ int encoding;
void LoadIniSettings() void LoadIniSettings()
{ {
strcpy(#ini_path, "/sys/settings/txtread.ini"); strcpy(#ini_path, "/sys/settings/txtread.ini");
ini_get_int stdcall (#ini_path, #config_section, "FontSize", 14); label.size.pt = EAX; ini_get_int stdcall (#ini_path, #config_section, "FontSize", 14); kfont.size.pt = EAX;
ini_get_int stdcall (#ini_path, #config_section, "Encoding", CH_CP866); encoding = EAX; ini_get_int stdcall (#ini_path, #config_section, "Encoding", CH_CP866); encoding = EAX;
ini_get_int stdcall (#ini_path, #config_section, "WinX", 150); Form.left = EAX; ini_get_int stdcall (#ini_path, #config_section, "WinX", 150); Form.left = EAX;
ini_get_int stdcall (#ini_path, #config_section, "WinY", 50); Form.top = EAX; ini_get_int stdcall (#ini_path, #config_section, "WinY", 50); Form.top = EAX;
@ -15,7 +15,7 @@ void LoadIniSettings()
void SaveIniSettings() void SaveIniSettings()
{ {
ini_set_int stdcall (#ini_path, #config_section, "FontSize", label.size.pt); ini_set_int stdcall (#ini_path, #config_section, "FontSize", kfont.size.pt);
ini_set_int stdcall (#ini_path, #config_section, "Encoding", encoding); ini_set_int stdcall (#ini_path, #config_section, "Encoding", encoding);
ini_set_int stdcall (#ini_path, #config_section, "WinX", Form.left); ini_set_int stdcall (#ini_path, #config_section, "WinX", Form.left);
ini_set_int stdcall (#ini_path, #config_section, "WinY", Form.top); ini_set_int stdcall (#ini_path, #config_section, "WinY", Form.top);

View File

@ -37,7 +37,7 @@ dword line_start=io.buffer_data;
if (mode==DRAW_BUF) { if (mode==DRAW_BUF) {
EBX = bufoff-line_start; EBX = bufoff-line_start;
strlcpy(#line, line_start, EBX); strlcpy(#line, line_start, EBX);
label.WriteIntoBuffer(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, #line); kfont.WriteIntoBuffer(8,stroka_y,list.w,kfont.size.height, 0xFFFFFF, 0, kfont.size.pt, #line);
stroka_y += list.item_h; stroka_y += list.item_h;
line_start = bufoff; line_start = bufoff;
line_length = 30; line_length = 30;
@ -45,15 +45,15 @@ dword line_start=io.buffer_data;
} }
} }
if (mode==COUNT_BUF_HEIGHT) list.count+=2; if (mode==COUNT_BUF_HEIGHT) list.count+=2;
if (mode==DRAW_BUF) label.WriteIntoBuffer(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, line_start); if (mode==DRAW_BUF) kfont.WriteIntoBuffer(8,stroka_y,list.w,kfont.size.height, 0xFFFFFF, 0, kfont.size.pt, line_start);
} }
void PreparePage() void PreparePage()
{ {
//get font chars width, need to increase performance //get font chars width, need to increase performance
int i; int i;
label.changeSIZE(); kfont.changeSIZE();
for (i=0; i<256; i++) char_width[i] = label.symbol_size(i); for (i=0; i<256; i++) char_width[i] = kfont.symbol_size(i);
//get font buffer height //get font buffer height
list.w = Form.cwidth-scroll.size_x-1; list.w = Form.cwidth-scroll.size_x-1;
@ -61,13 +61,13 @@ void PreparePage()
Parcer(COUNT_BUF_HEIGHT); Parcer(COUNT_BUF_HEIGHT);
//draw text in buffer //draw text in buffer
list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, label.size.pt+3); list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, kfont.size.pt+4);
if (list.count < list.visible) list.count = list.visible; if (list.count < list.visible) list.count = list.visible;
label.size.height = list.count+1*list.item_h; kfont.size.height = list.count+1*list.item_h;
label.raw_size = 0; kfont.raw_size = 0;
Parcer(DRAW_BUF); Parcer(DRAW_BUF);
//draw result //draw result
label.ApplySmooth(); kfont.ApplySmooth();
DrawPage(); DrawPage();
} }

View File

@ -72,7 +72,7 @@ void main()
{ {
InitDlls(); InitDlls();
OpenDialog_init stdcall (#o_dialog); OpenDialog_init stdcall (#o_dialog);
label.init(DEFAULT_FONT); kfont.init(DEFAULT_FONT);
Libimg_LoadImage(#skin, abspath("toolbar.png")); Libimg_LoadImage(#skin, abspath("toolbar.png"));
LoadIniSettings(); LoadIniSettings();
OpenFile(#param); OpenFile(#param);
@ -202,18 +202,18 @@ void EventOpenFile()
void EventMagnifyPlus() void EventMagnifyPlus()
{ {
label.size.pt++; kfont.size.pt++;
if(!label.changeSIZE()) if(!kfont.changeSIZE())
label.size.pt--; kfont.size.pt--;
else else
PreparePage(); PreparePage();
} }
void EventMagnifyMinus() void EventMagnifyMinus()
{ {
label.size.pt--; kfont.size.pt--;
if(!label.changeSIZE()) if(!kfont.changeSIZE())
label.size.pt++; kfont.size.pt++;
else else
PreparePage(); PreparePage();
} }
@ -291,6 +291,6 @@ void draw_window()
void DrawPage() void DrawPage()
{ {
_PutImage(list.x,list.y,list.w,list.h,list.first*list.item_h*list.w*3 + label.raw); _PutImage(list.x,list.y,list.w,list.h,list.first*list.item_h*list.w*3 + kfont.raw);
DrawScroller(); DrawScroller();
} }