Subversion Repositories Kolibri OS

Rev

Rev 9581 | Rev 9597 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9581 Rev 9584
Line 1... Line 1...
1
/*
1
/*
2
 * System Monitor
2
 * System Monitor
3
 * version 1.4
3
 * version 1.41
4
 * Author: Leency
4
 * Author: Leency
5
*/
5
*/
Line 6... Line 6...
6
 
6
 
7
#define MEMSIZE 1024*60
7
#define MEMSIZE 1024*60
Line 8... Line 8...
8
#define NO_DLL_INIT
8
//#define NO_DLL_INIT
9
 
9
 
10
//===================================================//
10
//===================================================//
11
//                                                   //
11
//                                                   //
Line 16... Line 16...
16
#include "../lib/gui.h"
16
#include "../lib/gui.h"
17
#include "../lib/fs.h"
17
#include "../lib/fs.h"
18
#include "../lib/list_box.h"
18
#include "../lib/list_box.h"
Line 19... Line 19...
19
 
19
 
-
 
20
#include "../lib/obj/box_lib.h"
Line 20... Line 21...
20
#include "../lib/obj/box_lib.h"
21
#include "../lib/obj/libini.h"
21
 
22
 
Line 22... Line 23...
22
#include "../lib/patterns/select_list.h"
23
#include "../lib/patterns/select_list.h"
Line 73... Line 74...
73
//                       VARS                        //
74
//                       VARS                        //
74
//                                                   //
75
//                                                   //
75
//===================================================//
76
//===================================================//
Line 76... Line 77...
76
 
77
 
77
int current_process_id = 0;
78
int current_process_id = 0;
Line 78... Line 79...
78
int proc_list[256];
79
int proc_list[MAX_PROCESS_COUNT];
Line 79... Line 80...
79
 
80
 
80
checkbox show_system = { T_SHOW_SYSTEM, false };
81
checkbox show_system = { T_SHOW_SYSTEM, false };
Line 86... Line 87...
86
 
87
 
Line 87... Line 88...
87
proc_info Form;
88
proc_info Form;
Line 88... Line 89...
88
 
89
 
-
 
90
int right_w;
-
 
91
 
Line 89... Line 92...
89
int right_w;
92
bool show_sensors;
90
 
93
 
91
bool show_sensors = true;
94
_ini ini = { "/sys/settings/app.ini", "Sysmon" };
92
 
95
 
Line 98... Line 101...
98
 
101
 
99
void main()
102
void main()
100
{
103
{
101
	int btn;
104
	int btn;
-
 
105
	load_dll(boxlib, #box_lib_init,0);
-
 
106
	load_dll(libini, #lib_init,1);
102
	load_dll(boxlib, #box_lib_init,0);
107
	ReadIni();
103
	@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
108
	@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
104
	loop() switch(@WaitEventTimeout(50))
109
	loop() switch(@WaitEventTimeout(50))
105
	{
110
	{
106
	   	case evMouse:
111
		case evMouse:
-
 
112
			SelectList_ProcessMouse(); 
107
			SelectList_ProcessMouse();
113
			if (mouse.up) && (mouse.pkm) || (mouse.mkm) EventShowTinfo();
108
			break;
114
			break;
109
		case evKey:
115
		case evKey:
-
 
116
			GetKeys();
110
			GetKeys();
117
			switch(key_scancode) {
-
 
118
				case SCAN_CODE_ESC:
-
 
119
						EventExit();
111
			if (key_scancode == SCAN_CODE_ESC) ExitProcess();
120
				case SCAN_CODE_DEL:
-
 
121
						EventKillCurrentProcess();
-
 
122
						break;
-
 
123
				case SCAN_CODE_SPACE:
-
 
124
						show_sensors ^= 1;
-
 
125
						goto _DRAW_WINDOW;
-
 
126
				case SCAN_CODE_ENTER:
-
 
127
						EventShowTinfo();
-
 
128
						break;
-
 
129
				case SCAN_CODE_TAB:
-
 
130
						show_system.checked ^= 1;
-
 
131
						SelectList_LineChanged();
-
 
132
						break;
112
			if (key_scancode == SCAN_CODE_DEL) EventKillCurrentProcess();
133
				default:
-
 
134
						if (select_list.ProcessKey(key_scancode)) {
-
 
135
							SelectList_LineChanged();
-
 
136
						}
113
			if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged();
137
			}
114
			break;
138
			break;
115
		case evButton:
139
		case evButton:
116
			btn = @GetButtonID();
140
			btn = @GetButtonID();
Line 117... Line 141...
117
			if (1==btn) ExitProcess();
141
			if (1==btn) EventExit();
118
 
142
 
119
			if (show_system.click(btn)) {
143
			if (show_system.click(btn)) {
120
				SelectList_LineChanged();
144
				SelectList_LineChanged();
121
			}
145
			}
122
			if (BTN_PROC_KILL == btn) {
146
			if (BTN_PROC_KILL == btn) {
123
				EventKillCurrentProcess();
147
				EventKillCurrentProcess();
124
			}
148
			}
125
			if (BTN_PROC_INFO == btn) {
149
			if (BTN_PROC_INFO == btn) {
126
				RunProgram("/sys/tinfo", itoa(GetProcessSlot(current_process_id))); 
150
				EventShowTinfo();
127
			}
151
			}
128
			if (BTN_SHOWHIDE_SENSORS == btn) {
152
			if (BTN_SHOWHIDE_SENSORS == btn) {
129
				show_sensors ^= 1;
153
				show_sensors ^= 1;
130
				GOTO _DRAW_WINDOW;
154
				GOTO _DRAW_WINDOW;
131
			}
155
			}
132
			break;
156
			break;
133
		case evReDraw:
157
		case evReDraw:
134
			sc.get();
158
			sc.get();
135
			DefineAndDrawWindow(screen.width/2 - 350, 100, 700, 490, 0x33, sc.work, T_APP_TITLE,0);
159
			DefineAndDrawWindow(Form.left, Form.top, Form.width, Form.height, 0x33, sc.work, T_APP_TITLE,0);
136
			_DRAW_WINDOW:
160
			_DRAW_WINDOW:
137
			GetProcessInfo(#Form, SelfInfo);
161
			GetProcessInfo(#Form, SelfInfo);
138
			if (Form.status_window&ROLLED_UP) break;
162
			if (Form.status_window&ROLLED_UP) break;
Line 144... Line 168...
144
			}
168
			}
145
			right_w = Form.cwidth - RIGHT_X - GAP;
169
			right_w = Form.cwidth - RIGHT_X - GAP;
146
			right_w &= ~1; // make sure the number is even
170
			right_w &= ~1; // make sure the number is even
147
			WriteText(GAP+5, WIN_CONTENT_Y-20, 0x90, sc.work_text, T_PROC_HEADER);
171
			WriteText(GAP+5, WIN_CONTENT_Y-20, 0x90, sc.work_text, T_PROC_HEADER);
Line 148... Line 172...
148
 
172
 
149
			DefineButton(RIGHT_X-38,WIN_CONTENT_Y-25,18,18,BTN_SHOWHIDE_SENSORS,sc.work);
173
			DefineButton(RIGHT_X-38,WIN_CONTENT_Y-25,18,18,BTN_SHOWHIDE_SENSORS,sc.button);
150
			DrawRectangle3D(RIGHT_X-38,WIN_CONTENT_Y-25,19,18,sc.work_graph,sc.work_light);
174
			DrawRectangle3D(RIGHT_X-38,WIN_CONTENT_Y-25,19,18,sc.work_graph,sc.work_light);
151
			PutPixel(RIGHT_X-38+19,WIN_CONTENT_Y-25,sc.work_light);
175
			PutPixel(RIGHT_X-38+19,WIN_CONTENT_Y-25,sc.work_light);
152
			EDX = "<\0>";
176
			EDX = "<\0>";
153
			EDX += show_sensors * 2;
177
			EDX += show_sensors * 2;
154
			WriteText(RIGHT_X-38+5,WIN_CONTENT_Y-25+2,0x90,sc.work_text, EDX);
178
			WriteText(RIGHT_X-38+5,WIN_CONTENT_Y-25+2,0x90,sc.button_text, EDX);
155
			//EBX += 5 << 16;
179
			//EBX += 5 << 16;
Line 156... Line 180...
156
			//$int 64
180
			//$int 64
157
 
181
 
Line 367... Line 391...
367
	ram.draw_progress(GetFreeRAM()*ram.w/GetTotalRAM());
391
	ram.draw_progress(GetFreeRAM()*ram.w/GetTotalRAM());
368
	sprintf(#param, T_RAM_USAGE, GetFreeRAM()/1024, GetTotalRAM()/1024);
392
	sprintf(#param, T_RAM_USAGE, GetFreeRAM()/1024, GetTotalRAM()/1024);
369
	DrawIconWithText(RIGHT_X, ram.y - 25, 51, #param);
393
	DrawIconWithText(RIGHT_X, ram.y - 25, 51, #param);
370
}
394
}
Line -... Line 395...
-
 
395
 
-
 
396
void EventShowTinfo()
-
 
397
{
-
 
398
	RunProgram("/sys/tinfo", itoa(GetProcessSlot(current_process_id)));
Line -... Line 399...
-
 
399
}
-
 
400
 
-
 
401
void ReadIni()
-
 
402
{
-
 
403
	Form.left    = ini.GetInt("x", screen.width/2 - 350); 
-
 
404
	Form.top     = ini.GetInt("y", 100); 
-
 
405
	Form.width   = ini.GetInt("w", 700); 
-
 
406
	Form.height  = ini.GetInt("h", 490); 
-
 
407
	show_sensors = ini.GetInt("show_sensors", true); 
-
 
408
	show_system.checked = ini.GetInt("show_system", false); 
-
 
409
}
-
 
410
 
-
 
411
void EventExit()
-
 
412
{
-
 
413
	ini.SetInt("x", Form.left);
-
 
414
	ini.SetInt("y", Form.top);
-
 
415
	ini.SetInt("w", Form.width);
-
 
416
	ini.SetInt("h", Form.height);
-
 
417
	ini.SetInt("show_sensors", show_sensors);
-
 
418
	ini.SetInt("show_system", show_system.checked);