cmm programs: a lot of small optimizations

git-svn-id: svn://kolibrios.org@3412 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2013-03-25 22:50:35 +00:00
parent 46c609efe5
commit abd4ed875a
9 changed files with 58 additions and 81 deletions

View File

@ -200,6 +200,7 @@ void Translate()
void OpenDictionary(dword fileid)
{
KillProcess(speaker_id);
if (!dir_buf) ShowDictList();
if (!dir_buf) strcpy(#cur_dict, "none");
else strcpy(#cur_dict, fileid*304+dir_buf+72);

View File

@ -13,6 +13,7 @@
#include "..\lib\lib.obj\box_lib.h"
#include "..\lib\file_system.h"
#include "..\lib\figures.h"
#include "..\lib\encoding.h"
//images
#include "imgs\toolbar.txt"
#include "imgs\left_p.txt"
@ -25,7 +26,8 @@ int BUTTON_HEIGHT=18;
#define ONLY_OPEN 2
//ïåðåìåííûå
#define title "Eolite File Manager v1.64"
#define TITLE "Eolite File Manager v1.64"
#define ABOUT_TITLE "Eolite v1.64"
dword col_work = 0xE4DFE1;
dword col_border = 0x819FC5;
dword col_padding = 0xC8C9C9;
@ -421,7 +423,7 @@ void main()
}
break;
case evReDraw:
DefineAndDrawWindow(40,20,550,500,0x73,col_work,title);
DefineAndDrawWindow(40,20,550,500,0x73,col_work,TITLE);
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) break;
min_win_h = disc_num*16+195;
@ -557,7 +559,7 @@ void Line_ReDraw(dword color, filenum){
{
strcpy(#temp, off);
Put_icon(#temp+_strrchr(#temp,'.'), BUTTON_HEIGHT/2-7+y, color);
WriteText(7-strlen(ConvertSize(ESDWORD[off-8]))*6+onLeft(75,0),BUTTON_HEIGHT-6/2+y,0x80,0,ConvertSize(ESDWORD[off-8])); //size
WriteText(7-strlen(ConvertMemSize(ESDWORD[off-8]))*6+onLeft(75,0),BUTTON_HEIGHT-6/2+y,0x80,0,ConvertMemSize(ESDWORD[off-8])); //size
}
else
if (!strcmp("..",off))

View File

@ -25,7 +25,7 @@ void about_dialog()
DefineAndDrawWindow(600,150,181,232+GetSkinHeight(),0x34,col_work,"About Eolite");
DrawBar(0,0,172,50,0x8494C4);
PutPaletteImage(#logo,85,85,43,7,8,#logo_pal);
WriteTextB(46,100,0x90,0xBF40BF,"Eolite v1.64");
WriteTextB(46,100,0x90,0xBF40BF,ABOUT_TITLE);
WriteText(55,120,0x80,0,"Developers:");
WriteText(39,130,0x80,0,"Leency & Veliant");
WriteText(45,140,0x80,0,"KolibriOS Team");

View File

@ -13,20 +13,6 @@ void ShowMessage(dword message)
}
dword ConvertSize(dword bytes)
{
unsigned char size_prefix[8], size_nm[4];
if (bytes>=1073741824) strcpy(#size_nm, " Gb");
else if (bytes>=1048576) strcpy(#size_nm, " Mb");
else if (bytes>=1024) strcpy(#size_nm, " Kb");
else strcpy(#size_nm, " b ");
while (bytes>1023) bytes/=1024;
strcpy(#size_prefix, itoa(bytes));
strcat(#size_prefix, #size_nm);
return #size_prefix;
}
dword col_palette[14] = {0xD2D3D3,0xD4D4D4,0xD6D5D6,0xD8D7D8,0xDAD8D9,0xDCDADB,
0xDFDCDD,0xE1DDDE,0xE2DEE0,0xE4DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1,0xE3DFE1};

View File

@ -40,9 +40,9 @@ int DefineWindow(dword wtitle, wbutton)
if (Form.status_window>2) return 0; //rolled_up
DrawBar(0, 0, Form.cwidth, BLACK_H, 0);
DrawBar(0, BLACK_H, Form.cwidth, Form.cheight-BLACK_H, 0xFFFfff);
_PutImage(BLACK_H-LOGOW/2, BLACK_H-LOGOH/2, LOGOW,LOGOH, #logo);
WriteTextB(BLACK_H-LOGOW + LOGOW, BLACK_H-6/2, 0x90, 0xFFFfff, wtitle);
DrawBar(0, BLACK_H, Form.cwidth, Form.cheight-BLACK_H, 0xFFFfff);
DrawCaptButton(Form.cwidth-107, Form.cheight-40, 90, 24, 10, sc.work_button, sc.work_button_text,wbutton);
return 1;
}

View File

@ -155,7 +155,7 @@ inline fastcall void utf8rutodos( ESI)
//------------------------------------------------------------------------------
dword Hex2Symb(char* htmlcolor)
:dword Hex2Symb(char* htmlcolor)
{
dword j=0, symbol=0;
char ch=0x00;
@ -171,3 +171,16 @@ dword Hex2Symb(char* htmlcolor)
wintodos(#symbol);
AL=symbol;
}
:dword ConvertMemSize(unsigned int bytes)
{
unsigned char size_prefix[8], size_nm[4];
if (bytes>=1073741824) strcpy(#size_nm, " Gb");
else if (bytes>=1048576) strcpy(#size_nm, " Mb");
else if (bytes>=1024) strcpy(#size_nm, " Kb");
else strcpy(#size_nm, " b ");
while (bytes>1023) bytes/=1024;
strcpy(#size_prefix, itoa(bytes));
strcat(#size_prefix, #size_nm);
return #size_prefix;
}

View File

@ -203,9 +203,11 @@ f70 getinfo_file_70;
if (! ReadFile(0, CopyFile_atr.sizelo, cBufer, copy_from))
{
rezult = WriteFile(CopyFile_atr.sizelo, cBufer, copy_in);
debugi(rezult);
}
}
free(cBufer);
debugi(rezult);
return rezult;
}

View File

@ -127,9 +127,9 @@ void OpenMailDat()
ReadFile(0, 512, #read_data, "/sys/network/mail.dat");
if (!read_data)
{
//strcpy(#email_text, "eiroglif@yandex.ru"); //temporarily, for testing
strcpy(#email_text, "example@mail.com");
//strcpy(#pass_text, "rostov");
strcpy(#email_text, "eiroglif@yandex.ru"); //temporarily, for testing
//strcpy(#email_text, "example@mail.com");
strcpy(#pass_text, "rostov");
}
else
{

View File

@ -3,12 +3,24 @@
#define LIST_INFO_H 59
int status_bar_h = 15;
llist mail_list;
llist letter_view;
scroll_bar scroll1 = { 17,200,210, LIST_INFO_H-3,18,0,115,15,0,0xCCCccc,0xD2CED0,0x555555,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
scroll_bar scroll2 = { 17,200,210, LIST_INFO_H,18,0,115,15,0,0xCCCccc,0xD2CED0,0x555555,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
struct letter_attr
{
char adress[64];
char header[256];
byte m_type;
int size;
void CreateMailsArray();
void SetMailsSizes();
int GetLetterSize(int N);
};
letter_attr atr;
dword mails_db;
llist mail_list;
llist letter_view;
char from[256];
char to[256];
@ -252,8 +264,8 @@ void MailBoxLoop()
debug("Got mail list");
DrawMailBox();
CreateMailsArray();
SetMailsSizes();
atr.CreateMailsArray();
atr.SetMailsSizes();
}
}
}
@ -268,7 +280,7 @@ void MailBoxLoop()
if (EAX == 0xffffffff) { notify("Error while trying to get letter from server"); aim=NULL; break;}
mailbuffer = free(mailbuffer);
letter_size = GetLetterSize(mail_list.current+1) + 1024;
letter_size = atr.GetLetterSize(mail_list.current+1) + 1024;
mailbuffer = malloc(letter_size);
mailpointer = mailbuffer;
aim = GET_ANSWER_RETR;
@ -330,11 +342,11 @@ void DrawToolbar()
mail_list.SetSizes(0, toolbar_w, Form.cwidth - scroll1.size_x - 1, mail_list.h, 60,18);
DrawBar(0,0, Form.cwidth,toolbar_w-3, sc.work);
DrawCaptButton(10 , BUT_Y, BUT_W, BUT_H, GET_MAIL, sc.work_button, sc.work_button_text,"Get mail");
DrawCaptButton(BUT_W+BUT_SPACE + 10, BUT_Y, BUT_W, BUT_H, SEND_MAIL, sc.work_button, sc.work_button_text,"Send Email");
DrawCaptButton(BUT_W+BUT_SPACE*2 + 10, BUT_Y, BUT_W, BUT_H, DELETE_LETTER, sc.work_button, sc.work_button_text,"Delete");
DrawCaptButton(BUT_W+BUT_SPACE*3 + 10, BUT_Y, BUT_W, BUT_H, SAVE_LETTER, sc.work_button, sc.work_button_text,"Save");
DrawCaptButton(Form.cwidth-BUT_W - 10, BUT_Y, BUT_W, BUT_H, EXIT_MAIL, sc.work_button, sc.work_button_text,"< Exit");
DrawCaptButton(10 , BUT_Y, BUT_W, BUT_H, GET_MAIL, sc.work_button, sc.work_button_text,"Get mail");
DrawCaptButton(BUT_W+BUT_SPACE + 10, BUT_Y, BUT_W, BUT_H, SEND_MAIL, sc.work_button, sc.work_button_text,"Send Email");
DrawCaptButton(BUT_W+BUT_SPACE*2 + 10, BUT_Y, BUT_W, BUT_H, DELETE_LETTER, sc.work_button, sc.work_button_text,"Delete");
DrawCaptButton(BUT_W+BUT_SPACE*3 + 10, BUT_Y, BUT_W, BUT_H, SAVE_LETTER, sc.work_button, sc.work_button_text,"Save");
DrawCaptButton(Form.cwidth-BUT_W - 10, BUT_Y, BUT_W, BUT_H, EXIT_MAIL, sc.work_button, sc.work_button_text,"< Exit");
DrawBar(0, mail_list.y-3, mail_list.w,1, sc.work_graph);
DrawBar(0, mail_list.y-2, mail_list.w,1, 0xdfdfdf);
@ -365,8 +377,7 @@ void DrawMailList()
DefineButton(0, on_y, mail_list.w-1, mail_list.line_h, 30+i+BT_HIDE+BT_NOFRAME);
DrawBar(0, on_y + mail_list.line_h-1, mail_list.w, 1, 0xCCCccc);
WriteText(10, on_y+5, 0x80, 0, itoa(i+mail_list.first+1));
//WriteText(mail_list.w - 40, on_y+5, 0x80, 0, itoa(GetLetterSize(i+mail_list.first+1)));
WriteText(mail_list.w - 40, on_y+5, 0x80, 0, ConvertSize(GetLetterSize(i+mail_list.first+1)));
WriteText(mail_list.w - 40, on_y+5, 0x80, 0, ConvertMemSize(atr.GetLetterSize(i+mail_list.first+1)));
}
DrawBar(0, i*mail_list.line_h + mail_list.y, mail_list.w, -i*mail_list.line_h+mail_list.h, 0xFFFfff);
DrawScroller1();
@ -382,20 +393,6 @@ void PutMailDirectionImage(int x,y, to_str, from_str)
}
dword ConvertSize(unsigned int bytes)
{
unsigned char size_prefix[8], size_nm[4];
if (bytes>=1073741824) strcpy(#size_nm, " Gb");
else if (bytes>=1048576) strcpy(#size_nm, " Mb");
else if (bytes>=1024) strcpy(#size_nm, " Kb");
else strcpy(#size_nm, " b ");
while (bytes>1023) bytes/=1024;
strcpy(#size_prefix, itoa(bytes));
strcat(#size_prefix, #size_nm);
return #size_prefix;
}
void DrawLetterInfo()
{
int lt_y = mail_list.y+mail_list.h;
@ -520,15 +517,6 @@ int GetMailCount(){
void listputc(char agot_char){
*listpointer=agot_char;
listpointer++;
@ -547,39 +535,24 @@ int GetLetterSize_(int number){
}
struct line_element
{
byte m_type;
char adress[64];
char header[256];
int size;
};
dword mails_db;
void CreateMailsArray()
void letter_attr::CreateMailsArray()
{
mails_db = free(mails_db);
mails_db = malloc( mail_list.count * sizeof(line_element) );
mails_db = malloc( mail_list.count * sizeof(atr) );
}
dword GetCurrentElement(int el_N)
void letter_attr::SetMailsSizes()
{
return sizeof(line_element)*el_N + #mails_db;
}
void SetMailsSizes()
{
int i, temp;
int i, off;
for (i=0; i < mail_list.count; i++)
{
temp = GetLetterSize_(i);
EBX = GetCurrentElement(i); //в регистр EBX суём адрес блока памяти со смещением к элементу N с котрым мы хотим работать
EBX.line_element.size = temp;//работаем с m_type N-ного элемента структуры отраженной на блок памяти
ESDWORD[sizeof(atr)*i+#mails_db+#atr.size-#atr] = GetLetterSize_(i);
}
}
int GetLetterSize(int el_N)
int letter_attr::GetLetterSize(int N)
{
EBX = GetCurrentElement(el_N);
return EBX.line_element.size;
return ESDWORD[sizeof(atr)*N+#mails_db+#atr.size-#atr];
}