forked from KolibriOS/kolibrios
sysmon: add process tab
git-svn-id: svn://kolibrios.org@7614 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
c89576f170
commit
6af7c83564
@ -142,7 +142,7 @@ lif=14
|
||||
3ds=15
|
||||
asc=15
|
||||
vox=15
|
||||
tls=15
|
||||
stl=15
|
||||
kex=16
|
||||
skn=17
|
||||
obj=18
|
||||
@ -225,4 +225,4 @@ djvu=85
|
||||
csv=28
|
||||
rft=85
|
||||
lif=13
|
||||
tls=78
|
||||
stl=78
|
@ -153,7 +153,9 @@ void EventManualSearch()
|
||||
|
||||
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)
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "..\lib\patterns\select_list.h"
|
||||
#include "..\lib\patterns\simple_open_dialog.h"
|
||||
|
||||
#include "ui_elements_preview.h"
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// DATA //
|
||||
@ -69,17 +71,9 @@ int cur;
|
||||
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 main()
|
||||
|
||||
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,19 +195,15 @@ void draw_window()
|
||||
void DrawWindowContent()
|
||||
{
|
||||
int id;
|
||||
incn y;
|
||||
int list_w;
|
||||
|
||||
system.color.get();
|
||||
|
||||
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,46 +226,24 @@ void DrawWindowContent()
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
: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()
|
||||
{
|
||||
@ -356,7 +325,7 @@ void EventTabClick(int N)
|
||||
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()
|
||||
|
34
programs/cmm/appearance/ui_elements_preview.h
Normal file
34
programs/cmm/appearance/ui_elements_preview.h
Normal file
@ -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);
|
||||
}
|
@ -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
|
@ -12,7 +12,7 @@ enum {
|
||||
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 };
|
||||
|
@ -4,9 +4,8 @@
|
||||
|
||||
:struct _tabs
|
||||
{
|
||||
int x,y,w,h;
|
||||
int active_tab;
|
||||
int c;
|
||||
int x,y,w,h;
|
||||
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)
|
||||
|
@ -217,7 +217,7 @@ void MailBoxLoop() {
|
||||
if (!mailstart) break;
|
||||
CreateFile(strlen(mailstart), mailstart, "mail.txt");
|
||||
pause(10);
|
||||
RunProgram("tinypad", "mail.txt");
|
||||
RunProgram("/sys/tinypad", "mail.txt");
|
||||
}
|
||||
if (id==STOP_LOADING)
|
||||
{
|
||||
|
@ -1,6 +0,0 @@
|
||||
if tup.getconfig("NO_CMM") ~= "" then return end
|
||||
if tup.getconfig("LANG") == "ru"
|
||||
then C_LANG = "LANG_RUS"
|
||||
else C_LANG = "LANG_ENG" -- this includes default case without config
|
||||
end
|
||||
tup.rule("process.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "process.com")
|
@ -1,9 +0,0 @@
|
||||
@del lang.h--
|
||||
@echo #define LANG_RUS 1 >lang.h--
|
||||
|
||||
C-- process.c
|
||||
@del process
|
||||
@rename process.com process
|
||||
@pause
|
||||
@del lang.h--
|
||||
@del warning.txt
|
185
programs/cmm/sysmon/general.h
Normal file
185
programs/cmm/sysmon/general.h
Normal file
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +1,3 @@
|
||||
#define MEMSIZE 4096*20
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// LIB //
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
#include "../lib/gui.h"
|
||||
#include "../lib/list_box.h"
|
||||
#include "../lib/obj/box_lib.h"
|
||||
#include "../lib/io.h"
|
||||
#include "../lib/patterns/select_list.h"
|
||||
#include "../lib/patterns/restart_process.h"
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// DATA //
|
||||
@ -24,13 +9,10 @@
|
||||
#define T_DETAILS "Details"
|
||||
#define T_END_PROCESS "End process"
|
||||
|
||||
|
||||
#define BOTPANEL_H 34
|
||||
proc_info Form;
|
||||
proc_info Process;
|
||||
#define BOTPANEL_H 36
|
||||
|
||||
enum {
|
||||
BTN_ID_SHOW_SYSTEM_PROCESSES=20,
|
||||
BTN_ID_SHOW_SYSTEM_PROCESSES=200,
|
||||
BTN_ID_KILL_PROCESS,
|
||||
BTN_ID_SHOW_PROCESS_INFO
|
||||
};
|
||||
@ -47,19 +29,18 @@ checkbox show_system = { T_SHOW_SYSTEM_PROCESSES, false };
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
void main()
|
||||
void Processes__Main()
|
||||
{
|
||||
int btn;
|
||||
load_dll(boxlib, #box_lib_init,0);
|
||||
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:
|
||||
if (!CheckActiveProcess(Form.ID)) break;
|
||||
SelectList_ProcessMouse();
|
||||
break;
|
||||
case evKey:
|
||||
@ -68,10 +49,8 @@ void main()
|
||||
break;
|
||||
case evButton:
|
||||
btn = GetButtonID();
|
||||
if (1 == btn)
|
||||
{
|
||||
ExitProcess();
|
||||
}
|
||||
Sysmon__ButtonEvent(btn);
|
||||
|
||||
if (show_system.click(btn))
|
||||
{
|
||||
SelectList_LineChanged();
|
||||
@ -88,21 +67,21 @@ void main()
|
||||
}
|
||||
break;
|
||||
case evReDraw:
|
||||
system.color.get();
|
||||
DefineAndDrawWindow(screen.width-400/2,screen.height-450/2,400,454,0x73,0,T_WINDOW_TITLE,0);
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
if (Form.status_window>2) break;
|
||||
if (Form.width < 300) { MoveSize(OLD,OLD,300,OLD); break; }
|
||||
if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; }
|
||||
SelectList_Init(6, 6, Form.cwidth-12 - scroll1.size_x, Form.cheight-12-BOTPANEL_H, false);
|
||||
_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);
|
||||
|
||||
//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-116,
|
||||
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-236,
|
||||
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);
|
||||
@ -113,16 +92,11 @@ void main()
|
||||
}
|
||||
}
|
||||
|
||||
void SelectList_LineChanged()
|
||||
{
|
||||
GetProcessList();
|
||||
SelectList_Draw();
|
||||
}
|
||||
|
||||
|
||||
void GetProcessList()
|
||||
void Processes__GetProcessList()
|
||||
{
|
||||
int i, j;
|
||||
proc_info Process;
|
||||
|
||||
select_list.count=0;
|
||||
for (i=0; i<MAX_PROCESS_COUNT; i++)
|
||||
{
|
||||
@ -149,6 +123,8 @@ 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;
|
||||
@ -165,9 +141,8 @@ void SelectList_DrawLine(dword i)
|
||||
posy+select_list.text_y, select_list.font_type, 0x444444, #cpu_use);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
stop:
|
||||
void SelectList_LineChanged()
|
||||
{
|
||||
Processes__GetProcessList();
|
||||
SelectList_Draw();
|
||||
}
|
@ -4,15 +4,26 @@
|
||||
* 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"
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
@ -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);
|
||||
|
||||
GetTmpDiskSizes();
|
||||
|
||||
loop()
|
||||
{
|
||||
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);
|
||||
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"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
load_dll(boxlib, #box_lib_init,0);
|
||||
General__Main();
|
||||
}
|
||||
|
||||
void DrawBlockHeader(dword _x, _y, _icon, _title, _subtitle)
|
||||
int Sysmon__DefineAndDrawWindow()
|
||||
{
|
||||
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;
|
||||
}
|
||||
system.color.get();
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// 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:
|
Loading…
Reference in New Issue
Block a user