Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7613 → Rev 7614

/data/common/File Managers/icons.ini
142,7 → 142,7
3ds=15
asc=15
vox=15
tls=15
stl=15
kex=16
skn=17
obj=18
225,4 → 225,4
csv=28
rft=85
lif=13
tls=78
stl=78
/programs/cmm/process/Tupfile.lua
File deleted
/programs/cmm/process/compile.bat
File deleted
\ No newline at end of file
/programs/cmm/process/process.c
File deleted
\ No newline at end of file
/programs/cmm/app_plus/app_plus.c
153,8 → 153,10
 
void EventOpenApp()
{
RunProgram("syspanel", APP_PLUS_INI_PATH);
if (RunProgram("/sys/syspanel", APP_PLUS_INI_PATH) < 0) {
notify("'App+ can not be started because\n/sys/syspanel does not exists' -E");
}
}
 
void EventButton(dword id)
{
/programs/cmm/appearance/appearance.c
19,6 → 19,8
#include "..\lib\patterns\select_list.h"
#include "..\lib\patterns\simple_open_dialog.h"
 
#include "ui_elements_preview.h"
 
//===================================================//
// //
// DATA //
69,18 → 71,10
proc_info Form;
block skp;
 
_tabs tabs = { LP, LP, NULL, NULL, SKINS };
_tabs tabs = { SKINS, LP, LP, NULL, NULL };
 
checkbox update_docky = { T_UPDATE_DOCK, false };
checkbox checkbox1 = { "Checkbox", true };
more_less_box spinbox1 = { 23, 0, 999, "SpinBox" };
edit_box edit_cmm = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
0x10000000,sizeof(param)-2,#param,0, 0b};
 
char st_str[16];
edit_box edit_st = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
0x10000000,sizeof(st_str)-2,#st_str,0, 0b};
 
char default_dir[] = "/rd/1";
od_filter filter2 = { 8, "TXT\0\0" };
 
191,7 → 185,8
 
void draw_window()
{
DefineAndDrawWindow(screen.width-600/2,80,630,504+skin_height,0x74,NULL,WINDOW_HEADER,0);
system.color.get();
DefineAndDrawWindow(screen.width-600/2,80,630,504+skin_height,0x34,system.color.work,WINDOW_HEADER,0);
GetProcessInfo(#Form, SelfInfo);
IF (Form.status_window>=2) return;
DrawWindowContent();
200,7 → 195,6
void DrawWindowContent()
{
int id;
incn y;
int list_w;
 
system.color.get();
207,12 → 201,9
 
if (tabs.active_tab == SKINS) list_w=250; else list_w=350;
 
DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, LP, system.color.work);
 
tabs.w = Form.cwidth-LP-LP;
tabs.h = Form.cheight-LP-LP;
tabs.draw_wrapper();
tabs.draw_button(tabs.x+TAB_PADDING, SKINS, T_SKINS);
tabs.draw_button(strlen(T_SKINS)*8+tabs.x+TAB_PADDING+TAB_PADDING, WALLPAPERS, T_WALLPAPERS);
 
235,27 → 226,18
 
SelectList_Draw();
SelectList_DrawBorder();
//DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, LP, system.color.work);
 
if (tabs.active_tab == SKINS)
{
DrawBar(skp.x-20, select_list.y, skp.w+40, select_list.h, system.color.work);
DrawRectangle(skp.x-20, select_list.y, skp.w+40, select_list.h, system.color.work_graph);
update_docky.draw(skp.x, select_list.y+15);
y.n = skp.y;
DrawFrame(skp.x, skp.y, skp.w, skp.h, " Components Preview ");
spinbox1.draw(skp.x+20, y.inc(30));
WriteText(skp.x+20, y.inc(30), 0x90, system.color.work_text, "C-- Edit");
DrawEditBoxPos(skp.x+20, y.inc(20), #edit_cmm);
WriteText(skp.x+20, y.inc(35), 0x90, system.color.work_text, "Strandard Edit");
DrawStEditBoxPos(skp.x+20, y.inc(20), #edit_st);
DrawStandartCaptButton(skp.x+20, skp.y+skp.h-40, GetFreeButtonId(), "Button1");
DrawStandartCaptButton(skp.x+120, skp.y+skp.h-40, GetFreeButtonId(), "Button2");
DrawUiElementsPreview(skp.x+20, skp.y, skp.h);
}
if (tabs.active_tab == WALLPAPERS)
{
skp.x -= TAB_PADDING + 3;
DrawStandartCaptButton(skp.x, select_list.y, BTN_SELECT_WALLP_FOLDER, T_SELECT_FOLDER);
DrawBar(skp.x, select_list.y+50, 180, 80, system.color.work);
DrawFrame(skp.x, select_list.y+50, 180, 80, T_PICTURE_MODE);
optionbox_stretch.draw(skp.x+14, select_list.y+70);
optionbox_tiled.draw(skp.x+14, select_list.y+97);
262,20 → 244,7
}
}
 
:void DrawStEditBoxPos(dword x,y, edit_box_pointer)
{
dword c_inactive = MixColors(system.color.work_graph, system.color.work, 128);
dword c_active = MixColors(system.color.work_graph, 0, 128);
ESI = edit_box_pointer;
ESI.edit_box.left = x;
ESI.edit_box.top = y;
ESI.edit_box.blur_border_color = c_inactive;
ESI.edit_box.focus_border_color = c_active;
edit_box_draw stdcall (edit_box_pointer);
}
 
 
 
void Open_Dir()
{
int j;
356,7 → 325,7
select_list.cur_y = active_wallpaper;
}
if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; select_list.CheckDoesValuesOkey();
if (select_list.w) DrawWindowContent();
if (select_list.w) draw_window();
}
 
void EventDeleteFile()
/programs/cmm/appearance/ui_elements_preview.h
0,0 → 1,34
 
checkbox checkbox1 = { "Checkbox", true };
more_less_box spinbox1 = { 23, 0, 999, "SpinBox" };
edit_box edit_cmm = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
0x10000000,sizeof(param)-2,#param,0, 0b};
char st_str[16];
edit_box edit_st = {180,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
0x10000000,sizeof(st_str)-2,#st_str,0, 0b};
 
 
void DrawUiElementsPreview(dword x,y,h)
{
incn y2;
y2.n = y;
spinbox1.draw(x, y2.inc(30));
WriteText(x, y2.inc(30), 0x90, system.color.work_text, "C-- Edit");
DrawEditBoxPos(x, y2.inc(20), #edit_cmm);
WriteText(x, y2.inc(35), 0x90, system.color.work_text, "Strandard Edit");
DrawStEditBoxPos(x, y2.inc(20), #edit_st);
DrawStandartCaptButton(x, y+h-40, GetFreeButtonId(), "Button1");
DrawStandartCaptButton(x+100, y+h-40, GetFreeButtonId(), "Button2");
}
 
:void DrawStEditBoxPos(dword x,y, edit_box_pointer)
{
dword c_inactive = MixColors(system.color.work_graph, system.color.work, 128);
dword c_active = MixColors(system.color.work_graph, 0, 128);
ESI = edit_box_pointer;
ESI.edit_box.left = x;
ESI.edit_box.top = y;
ESI.edit_box.blur_border_color = c_inactive;
ESI.edit_box.focus_border_color = c_active;
edit_box_draw stdcall (edit_box_pointer);
}
/programs/cmm/kf_font_viewer/compile_en.bat
1,5 → 1,5
@del "kf_view"
@C-- "font_viewer.c"
@del "font_viewer"
@rename "font_viewer.com" "font_viewer"
@rename "font_viewer.com" "kf_view"
@del warning.txt
@pause
/programs/cmm/kf_font_viewer/font_viewer.c
12,7 → 12,7
PHRASE_TAB=20, CHARS_TAB
};
 
_tabs tabs = { 0,0, WIN_W, WIN_H, PHRASE_TAB};
_tabs tabs = { PHRASE_TAB };
 
block preview = { 0, PANELH, WIN_W, WIN_H - PANELH };
checkbox bold = { "Bold", false };
/programs/cmm/lib/gui/tabs.h
4,9 → 4,8
 
:struct _tabs
{
int active_tab;
int x,y,w,h;
int active_tab;
int c;
void draw_button();
int click();
void draw_wrapper();
14,20 → 13,8
 
:void _tabs::draw_wrapper()
{
dword color_light = MixColors(system.color.work, 0xFFFfff, 40);
dword color_content = MixColors(system.color.work, 0xFFFfff, 120);
dword color_light_border = MixColors(system.color.work, system.color.work_graph, 120);
 
DrawRectangle(x-1, y-1, w+1, h+1, system.color.work_graph);
DrawBar(x, y, w, h, color_content); //0xF3F3F3
DrawRectangle3D(x, y, w-1, h-1, color_light, color_content); //0xF3F3F3
 
DrawBar(x+1, y+h+1, w-2, 2, system.color.work_dark); //"shadow"
 
DrawBar(x, y+TAB_HEIGHT-1, w, 1, color_light_border);
DrawBar(x, y+TAB_HEIGHT, w, 1, color_light);
 
c = y + TAB_HEIGHT;
DrawRectangle(x,y+TAB_HEIGHT,w-1,h-TAB_HEIGHT, system.color.work_graph);
DrawRectangle(x+1,y+1+TAB_HEIGHT,w-3,h-2-TAB_HEIGHT, system.color.work_light);
}
 
:void _tabs::draw_button(dword xx, but_id, text)
38,16 → 25,17
if (but_id==active_tab)
{
col_bg=0xE44C9C;
col_text=0x000000;
col_text=system.color.work_text;
}
else
{
col_bg=0xC3A1B7;
col_text=0x333333;
col_text= MixColors(system.color.work, system.color.work_text, 120);
}
DefineHiddenButton(xx,y, ww-1,hh-1, but_id);
DefineHiddenButton(xx-2,y, ww-1+4,hh-1, but_id);
WriteText(xx, y+6, 0x90, col_text, text);
DrawBar(xx, y+hh-3, ww, 3, col_bg);
//DrawStandartCaptButton(xx, y, but_id, text); //GetFreeButtonId()
}
 
:int _tabs::click(int N)
/programs/cmm/liza/mail_box.c
217,7 → 217,7
if (!mailstart) break;
CreateFile(strlen(mailstart), mailstart, "mail.txt");
pause(10);
RunProgram("tinypad", "mail.txt");
RunProgram("/sys/tinypad", "mail.txt");
}
if (id==STOP_LOADING)
{
/programs/cmm/sysmon/general.h
0,0 → 1,185
//===================================================//
// //
// DATA //
// //
//===================================================//
 
dword cpu_stack[1980*3];
 
sensor cpu;
sensor ram;
sensor rd;
sensor tmp[10];
 
dword tmp_size[10];
 
//===================================================//
// //
// CODE //
// //
//===================================================//
 
void General__Main()
{
dword cpu_frequency;
incn y;
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON);
 
cpu_frequency = GetCpuFrequency()/1000;
GetTmpDiskSizes();
 
goto _GENERAL_REDRAW;
loop()
{
WaitEventTimeout(25);
switch(EAX & 0xFF)
{
case evButton:
Sysmon__ButtonEvent(GetButtonID());
break;
case evKey:
GetKeys();
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
break;
case evReDraw:
_GENERAL_REDRAW:
if (!Sysmon__DefineAndDrawWindow()) break;
 
y.n = WIN_CONTENT_Y;
if (cpu_frequency < 1000) sprintf(#param, "CPU frequency: %i Hz", cpu_frequency);
else sprintf(#param, "CPU frequency: %i MHz", cpu_frequency/1000);
DrawBlockHeader(WIN_PAD, y.inc(0), 37, "CPU load", #param);
cpu.set_size(WIN_PAD, y.inc(45), WIN_CONTENT_W, 100);
 
sprintf(#param, "Total RAM: %i MiB", GetTotalRAM()/1024);
DrawBlockHeader(WIN_PAD, y.inc(cpu.h + 25), 36, "RAM usage", #param);
ram.set_size(WIN_PAD, y.inc(45), WIN_CONTENT_W, 23);
 
DrawBlockHeader(WIN_PAD, y.inc(ram.h + 25), 3, "System RAM Disk usage", "Fixed size: 1.44 MiB");
rd.set_size(WIN_PAD, y.inc(45), WIN_CONTENT_W, 23);
 
sprintf(#param, "TMP Disk 0 size: %i MiB", tmp_size[0]);
DrawBlockHeader(WIN_PAD, y.inc(rd.h + 25), 50, "Virtual drive usage", #param);
tmp[0].set_size(WIN_PAD, y.inc(45), WIN_CONTENT_W, 23);
 
default:
MonitorCpu();
 
//MonitorRam();
ram.draw_progress(
GetFreeRAM()*ram.w/GetTotalRAM(),
GetTotalRAM()-GetFreeRAM()/1024,
GetFreeRAM()/1024,
"M"
);
DrawBar(ram.x+ram.w-96, ram.y-25, 96, 20, system.color.work);
sprintf(#param, "%i KiB", GetTotalRAM()-GetFreeRAM());
WriteText(ram.x+ram.w-calc(strlen(#param)*8), ram.y-25, 0x90, system.color.work_text, #param);
 
//MonitorRd();
dir_size.get("/rd/1");
dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
dir_size.bytes /= 1024; //convert to KiB
dir_size.bytes = 1440 - dir_size.bytes;
rd.draw_progress(
dir_size.bytes*rd.w/1440,
1440 - dir_size.bytes,
dir_size.bytes,
"K"
);
 
//MonitorTmp();
if (tmp_size[0]) {
dir_size.get("/tmp0/1");
dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
dir_size.bytes /= 1024*1024; //convert to MiB
dir_size.bytes= tmp_size[0] - dir_size.bytes;
tmp[0].draw_progress(
dir_size.bytes*tmp[0].w/tmp_size[0],
tmp_size[0] - dir_size.bytes,
dir_size.bytes,
"M"
);
}
}
}
}
 
void DrawBlockHeader(dword _x, _y, _icon, _title, _subtitle)
{
#define ICONGAP 45
WriteTextB(_x+ICONGAP, _y, 0x90, system.color.work_text, _title);
DrawIcon32(_x, _y, system.color.work, _icon);
WriteText(_x+ICONGAP, _y+20, 0x90, system.color.work_text, _subtitle);
}
 
dword GetCpuLoad(dword max_h)
{
dword idle;
dword CPU_SEC = GetCpuFrequency() >> 20 + 1;
dword IDLE_SEC = GetCpuIdleCount() >> 20 * max_h;
 
EAX = IDLE_SEC;
EBX = CPU_SEC;
$cdq
$div ebx
idle = EAX;
 
return max_h - idle;
}
 
dword GetDiskSize(dword disk_n)
{
BDVK bdvk;
char tmp_path[8];
strcpy(#tmp_path, "/tmp0/1");
tmp_path[4] = disk_n + '0';
GetFileInfo(#tmp_path, #bdvk);
return bdvk.sizelo;
}
void GetTmpDiskSizes()
{
char i;
for (i=0; i<=9; i++)
{
tmp_size[i] = GetDiskSize(i) / 1024 / 1024;
}
}
 
//===================================================//
// //
// MONITORS //
// //
//===================================================//
 
int pos=0;
void MonitorCpu()
{
int i;
if (!cpu.w) return;
 
cpu_stack[pos] = GetCpuLoad(cpu.h);
if (cpu_stack[pos]<=2) || (cpu_stack[pos]>cpu.h) cpu_stack[pos]=2;
DrawBar(cpu.x+cpu.w-30, cpu.y-25, 30, 20, system.color.work);
sprintf(#param, "%i%%", cpu_stack[pos]);
WriteText(cpu.x+cpu.w-calc(strlen(#param)*8), cpu.y-25, 0x90, system.color.work_text, #param);
 
for (i=0; i<WIN_CONTENT_W; i+=2) {
DrawBar(i+cpu.x, cpu.y, 1, cpu.h-cpu_stack[i], PROGRESS_BG);
DrawBar(i+cpu.x, cpu.h-cpu_stack[i]+cpu.y, 1, cpu_stack[i], LOAD_CPU);
 
DrawBar(i+1+cpu.x, cpu.y, 1, cpu.h, PROGRESS_BG);
}
 
pos++;
if (pos>=WIN_CONTENT_W) {
pos = WIN_CONTENT_W-1;
for (i=0; i<pos; i++) {
cpu_stack[i] = cpu_stack[i+1];
}
}
}
/programs/cmm/sysmon/process.h
0,0 → 1,148
//===================================================//
// //
// DATA //
// //
//===================================================//
 
#define T_WINDOW_TITLE "Process Manager"
#define T_SHOW_SYSTEM_PROCESSES "Show system"
#define T_DETAILS "Details"
#define T_END_PROCESS "End process"
 
#define BOTPANEL_H 36
 
enum {
BTN_ID_SHOW_SYSTEM_PROCESSES=200,
BTN_ID_KILL_PROCESS,
BTN_ID_SHOW_PROCESS_INFO
};
 
int current_process_id = 0;
unsigned maxcpu;
int proc_list[256];
 
checkbox show_system = { T_SHOW_SYSTEM_PROCESSES, false };
 
//===================================================//
// //
// CODE //
// //
//===================================================//
 
void Processes__Main()
{
int btn;
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
maxcpu = GetCpuFrequency();
goto _PROCESS_REDRAW;
loop()
{
WaitEventTimeout(50);
switch(EAX & 0xFF)
{
case evMouse:
SelectList_ProcessMouse();
break;
case evKey:
GetKeys();
if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged();
break;
case evButton:
btn = GetButtonID();
Sysmon__ButtonEvent(btn);
 
if (show_system.click(btn))
{
SelectList_LineChanged();
}
if (BTN_ID_KILL_PROCESS == btn)
{
KillProcess(current_process_id);
pause(10);
SelectList_LineChanged();
}
if (BTN_ID_SHOW_PROCESS_INFO == btn)
{
io.run("/sys/tinfo", itoa(GetProcessSlot(current_process_id)));
}
break;
case evReDraw:
_PROCESS_REDRAW:
if (!Sysmon__DefineAndDrawWindow()) break;
 
SelectList_Init(WIN_PAD, WIN_CONTENT_Y,
WIN_CONTENT_W-scroll1.size_x,
WIN_CONTENT_H-BOTPANEL_H-TAB_HEIGHT, false);
SelectList_DrawBorder();
 
//DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, 4, system.color.work);
DrawBar(select_list.x-2, select_list.y+select_list.h+2,
select_list.w+scroll1.size_x+4, BOTPANEL_H, system.color.work);
DrawCaptButton(Form.cwidth-110-WIN_PAD,
select_list.y+select_list.h+5,
110,25,BTN_ID_KILL_PROCESS,0xF38181, 0xFFFfff, T_END_PROCESS);
DrawCaptButton(Form.cwidth-230-WIN_PAD,
select_list.y+select_list.h+5,
110,25,BTN_ID_SHOW_PROCESS_INFO,
system.color.work_button, system.color.work_button_text, T_DETAILS);
show_system.draw(select_list.x + 3, select_list.y+select_list.h+10);
default:
SelectList_LineChanged();
}
}
}
 
void Processes__GetProcessList()
{
int i, j;
proc_info Process;
 
select_list.count=0;
for (i=0; i<MAX_PROCESS_COUNT; i++)
{
GetProcessInfo(#Process, i);
if (Process.name)
{
for (j=0; j<11; j++) if (Process.name[j]!=' ') {
if (show_system.checked==false) {
//do not show system process
if (Process.name[0]=='@') break;
if (!strcmp(#Process.name, "IDLE")) break;
if (!strcmp(#Process.name, "OS")) break;
}
proc_list[select_list.count] = i;
select_list.count++;
break;
}
}
}
}
 
void SelectList_DrawLine(dword i)
{
int posy;
char cpu_use[16];
dword bg_color;
proc_info Process;
 
GetProcessInfo(#Process, proc_list[i+select_list.first]);
posy = i *select_list.item_h + select_list.y;
if (i % 2) bg_color = 0xFFFfff; else bg_color = 0xF0F0F0;
if (i+select_list.first == select_list.cur_y) {
current_process_id = Process.ID;
bg_color = 0x67CCEB;
}
DrawBar(select_list.x, posy, select_list.w, select_list.item_h, bg_color);
WriteText(select_list.x+005, posy+select_list.text_y, select_list.font_type, 0, #Process.name);
WriteText(select_list.w/10*5+select_list.x, posy+select_list.text_y, select_list.font_type, 0x444444, ConvertSizeToKb(Process.use_memory));
sprintf(#cpu_use, "%i %%", Process.use_cpu*100/maxcpu);
if (maxcpu) WriteText(select_list.w/10*8+select_list.x - calc(strlen(#cpu_use)-4*8),
posy+select_list.text_y, select_list.font_type, 0x444444, #cpu_use);
}
 
void SelectList_LineChanged()
{
Processes__GetProcessList();
SelectList_Draw();
}
/programs/cmm/sysmon/sysmon.c
4,16 → 4,27
* Author: Leency
*/
 
#define MEMSIZE 4096*10
#define MEMSIZE 4096*30
 
//===================================================//
// //
// LIB //
// //
//===================================================//
 
#include "../lib/io.h"
#include "../lib/gui.h"
#include "../lib/fs.h"
#include "../lib/list_box.h"
 
#include "../lib/obj/libio.h"
#include "../lib/obj/libimg.h"
#include "../lib/obj/libini.h"
#include "../lib/obj/box_lib.h"
 
#include "../lib/patterns/select_list.h"
#include "../lib/patterns/restart_process.h"
 
//===================================================//
// //
// DATA //
20,188 → 31,67
// //
//===================================================//
 
#define CPU_STACK 440
dword cpu_stack[CPU_STACK];
#define WIN_PAD 20 //Window padding
#define WIN_CONTENT_X WIN_PAD
#define WIN_CONTENT_Y TAB_HEIGHT+WIN_PAD
#define WIN_CONTENT_W 400
#define WIN_CONTENT_H 465
proc_info Form;
 
sensor cpu;
sensor ram;
sensor rd;
sensor tmp[10];
#include "general.h"
#include "process.h"
 
dword tmp_size[10];
#define T_GENERAL "General"
#define T_PROCESSES "Processes"
 
//===================================================//
// //
// CODE //
// //
//===================================================//
enum {
TAB_GENERAL=20,
TAB_PROCESSES
};
_tabs tabs = { TAB_GENERAL, 4, 0, WIN_CONTENT_W+WIN_PAD+WIN_PAD-4-4, TAB_HEIGHT };
 
void main()
{
proc_info Form;
dword cpu_frequency = GetCpuFrequency()/1000;
int id;
 
incn y;
 
load_dll(libio, #libio_init,1);
load_dll(libimg, #libimg_init,1);
load_dll(libini, #lib_init,1);
load_dll(boxlib, #box_lib_init,0);
General__Main();
}
 
GetTmpDiskSizes();
loop()
int Sysmon__DefineAndDrawWindow()
{
WaitEventTimeout(25);
switch(EAX & 0xFF)
{
case evButton:
if (GetButtonID()) ExitProcess();
break;
case evKey:
GetKeys();
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
break;
case evReDraw:
#define LEFT 25
#define ICONGAP 45
system.color.get();
DefineAndDrawWindow(150, 100, CPU_STACK+LEFT+LEFT+4+9, 480 + skin_height + 4, 0x34, system.color.work, "System Monitor",0);
DefineAndDrawWindow(screen.width - WIN_CONTENT_H - 200, 100, WIN_CONTENT_W + WIN_PAD + WIN_PAD +9,
WIN_CONTENT_H + TAB_HEIGHT + skin_height + 4, 0x34, system.color.work, "System Monitor",0);
GetProcessInfo(#Form, SelfInfo);
 
y.n = 0;
if (cpu_frequency < 1000) sprintf(#param, "CPU frequency: %i Hz", cpu_frequency);
else sprintf(#param, "CPU frequency: %i MHz", cpu_frequency/1000);
DrawBlockHeader(LEFT, y.inc(20), 37, "CPU load", #param);
cpu.set_size(LEFT, y.inc(45), CPU_STACK, 100);
 
sprintf(#param, "Total RAM: %i MiB", GetTotalRAM()/1024);
DrawBlockHeader(LEFT, y.inc(cpu.h + 25), 36, "RAM usage", #param);
ram.set_size(LEFT, y.inc(45), CPU_STACK, 23);
 
DrawBlockHeader(LEFT, y.inc(ram.h + 25), 3, "System RAM Disk usage", "Fixed size: 1.44 MiB");
rd.set_size(LEFT, y.inc(45), CPU_STACK, 23);
 
sprintf(#param, "TMP Disk 0 size: %i MiB", tmp_size[0]);
DrawBlockHeader(LEFT, y.inc(rd.h + 25), 50, "Virtual drive usage", #param);
tmp[0].set_size(LEFT, y.inc(45), CPU_STACK, 23);
 
default:
MonitorCpu();
 
//MonitorRam();
ram.draw_progress(
GetFreeRAM()*ram.w/GetTotalRAM(),
GetTotalRAM()-GetFreeRAM()/1024,
GetFreeRAM()/1024,
"M"
);
DrawBar(ram.x+ram.w-96, ram.y-25, 96, 20, system.color.work);
sprintf(#param, "%i KiB", GetTotalRAM()-GetFreeRAM());
WriteText(ram.x+ram.w-calc(strlen(#param)*8), ram.y-25, 0x90, system.color.work_text, #param);
 
//MonitorRd();
dir_size.get("/rd/1");
dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
dir_size.bytes /= 1024; //convert to KiB
dir_size.bytes = 1440 - dir_size.bytes;
rd.draw_progress(
dir_size.bytes*rd.w/1440,
1440 - dir_size.bytes,
dir_size.bytes,
"K"
);
 
//MonitorTmp();
if (tmp_size[0]) {
dir_size.get("/tmp0/1");
dir_size.bytes += dir_size.files/2 + 32 * 512; //file attr size + FAT table size
dir_size.bytes /= 1024*1024; //convert to MiB
dir_size.bytes= tmp_size[0] - dir_size.bytes;
tmp[0].draw_progress(
dir_size.bytes*tmp[0].w/tmp_size[0],
tmp_size[0] - dir_size.bytes,
dir_size.bytes,
"M"
);
if (Form.status_window>2) return false;
//if (Form.width < 300) { MoveSize(OLD,OLD,300,OLD); break; }
//if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; }
tabs.draw_wrapper();
tabs.draw_button(tabs.x+TAB_PADDING, TAB_GENERAL, T_GENERAL);
tabs.draw_button(strlen(T_GENERAL)*8+tabs.x+TAB_PADDING+TAB_PADDING, TAB_PROCESSES, T_PROCESSES);
return true;
}
}
}
}
 
void DrawBlockHeader(dword _x, _y, _icon, _title, _subtitle)
{
WriteTextB(_x+ICONGAP, _y, 0x90, system.color.work_text, _title);
DrawIcon32(_x, _y, system.color.work, _icon);
WriteText(_x+ICONGAP, _y+20, 0x90, system.color.work_text, _subtitle);
}
 
dword GetCpuLoad(dword max_h)
{
dword idle;
dword CPU_SEC = GetCpuFrequency() >> 20 + 1;
dword IDLE_SEC = GetCpuIdleCount() >> 20 * max_h;
 
EAX = IDLE_SEC;
EBX = CPU_SEC;
$cdq
$div ebx
idle = EAX;
 
return max_h - idle;
}
 
dword GetDiskSize(dword disk_n)
{
BDVK bdvk;
char tmp_path[8];
strcpy(#tmp_path, "/tmp0/1");
tmp_path[4] = disk_n + '0';
GetFileInfo(#tmp_path, #bdvk);
return bdvk.sizelo;
}
void GetTmpDiskSizes()
{
char i;
for (i=0; i<=9; i++)
{
tmp_size[i] = GetDiskSize(i) / 1024 / 1024;
}
}
 
//===================================================//
// //
// MONITORS //
// EVENTS //
// //
//===================================================//
 
int pos=0;
void MonitorCpu()
void Sysmon__ButtonEvent(dword id)
{
int i;
if (!cpu.w) return;
 
cpu_stack[pos] = GetCpuLoad(cpu.h);
if (cpu_stack[pos]<=2) || (cpu_stack[pos]>cpu.h) cpu_stack[pos]=2;
DrawBar(cpu.x+cpu.w-30, cpu.y-25, 30, 20, system.color.work);
sprintf(#param, "%i%%", cpu_stack[pos]);
WriteText(cpu.x+cpu.w-calc(strlen(#param)*8), cpu.y-25, 0x90, system.color.work_text, #param);
 
for (i=0; i<CPU_STACK; i+=2) {
DrawBar(i+cpu.x, cpu.y, 1, cpu.h-cpu_stack[i], PROGRESS_BG);
DrawBar(i+cpu.x, cpu.h-cpu_stack[i]+cpu.y, 1, cpu_stack[i], LOAD_CPU);
 
DrawBar(i+1+cpu.x, cpu.y, 1, cpu.h, PROGRESS_BG);
if (1==id) ExitProcess();
if (TAB_GENERAL==id) {
tabs.active_tab = TAB_GENERAL;
General__Main();
}
 
pos++;
if (pos>=CPU_STACK) {
pos = CPU_STACK-1;
for (i=0; i<pos; i++) {
cpu_stack[i] = cpu_stack[i+1];
if (TAB_PROCESSES==id) {
tabs.active_tab = TAB_PROCESSES;
Processes__Main();
}
}
}
 
 
stop: