Rev 6746 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6746 | Rev 6794 | ||
---|---|---|---|
1 | #define MEMSIZE 4096*20 |
1 | #define MEMSIZE 4096*20 |
2 | 2 | ||
3 | //===================================================// |
3 | //===================================================// |
4 | // // |
4 | // // |
5 | // LIB // |
5 | // LIB // |
6 | // // |
6 | // // |
7 | //===================================================// |
7 | //===================================================// |
8 | 8 | ||
9 | #include "../lib/gui.h" |
9 | #include "../lib/gui.h" |
10 | #include "../lib/list_box.h" |
10 | #include "../lib/list_box.h" |
11 | #include "../lib/obj/box_lib.h" |
11 | #include "../lib/obj/box_lib.h" |
12 | #include "../lib/io.h" |
12 | #include "../lib/io.h" |
13 | #include "../lib/patterns/select_list.h" |
13 | #include "../lib/patterns/select_list.h" |
14 | #include "../lib/patterns/restart_process.h" |
14 | #include "../lib/patterns/restart_process.h" |
15 | 15 | ||
16 | //===================================================// |
16 | //===================================================// |
17 | // // |
17 | // // |
18 | // DATA // |
18 | // DATA // |
19 | // // |
19 | // // |
20 | //===================================================// |
20 | //===================================================// |
21 | 21 | ||
22 | #define T_WINDOW_TITLE "Process Manager" |
22 | #define T_WINDOW_TITLE "Process Manager" |
23 | #define T_SHOW_SYSTEM_PROCESSES "Show system" |
23 | #define T_SHOW_SYSTEM_PROCESSES "Show system" |
24 | #define T_DETAILS "Details" |
24 | #define T_DETAILS "Details" |
25 | #define T_END_PROCESS "End process" |
25 | #define T_END_PROCESS "End process" |
26 | 26 | ||
27 | 27 | ||
28 | #define BOTPANEL_H 34 |
28 | #define BOTPANEL_H 34 |
29 | proc_info Form; |
29 | proc_info Form; |
30 | proc_info Process; |
30 | proc_info Process; |
31 | 31 | ||
32 | enum { |
32 | enum { |
33 | BTN_ID_SHOW_SYSTEM_PROCESSES=20, |
33 | BTN_ID_SHOW_SYSTEM_PROCESSES=20, |
34 | BTN_ID_KILL_PROCESS, |
34 | BTN_ID_KILL_PROCESS, |
35 | BTN_ID_SHOW_PROCESS_INFO |
35 | BTN_ID_SHOW_PROCESS_INFO |
36 | }; |
36 | }; |
37 | 37 | ||
38 | int current_process_id = 0; |
38 | int current_process_id = 0; |
39 | int show_system; |
39 | int show_system; |
40 | unsigned maxcpu; |
40 | unsigned maxcpu; |
41 | int proc_list[256]; |
41 | int proc_list[256]; |
42 | 42 | ||
43 | //===================================================// |
43 | //===================================================// |
44 | // // |
44 | // // |
45 | // CODE // |
45 | // CODE // |
46 | // // |
46 | // // |
47 | //===================================================// |
47 | //===================================================// |
48 | 48 | ||
49 | void GetCpuFrequency() { |
49 | void GetCpuFrequency() { |
50 | EAX = 18; |
50 | EAX = 18; |
51 | EBX = 5; |
51 | EBX = 5; |
52 | $int 0x40 |
52 | $int 0x40 |
53 | maxcpu = EAX; |
53 | maxcpu = EAX; |
54 | } |
54 | } |
55 | 55 | ||
56 | void main() |
56 | void main() |
57 | { |
57 | { |
58 | byte btn; |
58 | byte btn; |
59 | load_dll(boxlib, #box_lib_init,0); |
59 | load_dll(boxlib, #box_lib_init,0); |
60 | SetEventMask(10000000000000000000000001100111b); |
60 | SetEventMask(10000000000000000000000001100111b); |
61 | debugi(3); |
- | |
62 | GetCpuFrequency(); |
61 | GetCpuFrequency(); |
63 | debugi(4); |
- | |
64 | loop() |
62 | loop() |
65 | { |
63 | { |
66 | WaitEventTimeout(50); |
64 | WaitEventTimeout(50); |
67 | switch(EAX & 0xFF) |
65 | switch(EAX & 0xFF) |
68 | { |
66 | { |
69 | case evMouse: |
67 | case evMouse: |
70 | if (!CheckActiveProcess(Form.ID)) break; |
68 | if (!CheckActiveProcess(Form.ID)) break; |
71 | SelectList_ProcessMouse(); |
69 | SelectList_ProcessMouse(); |
72 | break; |
70 | break; |
73 | case evKey: |
71 | case evKey: |
74 | GetKeys(); |
72 | GetKeys(); |
75 | if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged(); |
73 | if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged(); |
76 | break; |
74 | break; |
77 | case evButton: |
75 | case evButton: |
78 | btn = GetButtonID(); |
76 | btn = GetButtonID(); |
79 | if (1 == btn) |
77 | if (1 == btn) |
80 | { |
78 | { |
81 | ExitProcess(); |
79 | ExitProcess(); |
82 | } |
80 | } |
83 | if (BTN_ID_SHOW_SYSTEM_PROCESSES == btn) |
81 | if (BTN_ID_SHOW_SYSTEM_PROCESSES == btn) |
84 | { |
82 | { |
85 | show_system ^= 1; |
83 | show_system ^= 1; |
86 | Draw_ShowSystemProcessesCheckbox(); |
84 | Draw_ShowSystemProcessesCheckbox(); |
87 | SelectList_LineChanged(); |
85 | SelectList_LineChanged(); |
88 | } |
86 | } |
89 | if (BTN_ID_KILL_PROCESS == btn) |
87 | if (BTN_ID_KILL_PROCESS == btn) |
90 | { |
88 | { |
91 | KillProcess(current_process_id); |
89 | KillProcess(current_process_id); |
92 | pause(10); |
90 | pause(10); |
93 | SelectList_LineChanged(); |
91 | SelectList_LineChanged(); |
94 | } |
92 | } |
95 | if (BTN_ID_SHOW_PROCESS_INFO == btn) |
93 | if (BTN_ID_SHOW_PROCESS_INFO == btn) |
96 | { |
94 | { |
97 | io.run("/sys/tinfo", itoa(GetProcessSlot(current_process_id))); |
95 | io.run("/sys/tinfo", itoa(GetProcessSlot(current_process_id))); |
98 | } |
96 | } |
99 | break; |
97 | break; |
100 | case evReDraw: |
98 | case evReDraw: |
101 | system.color.get(); |
99 | system.color.get(); |
102 | DefineAndDrawWindow(screen.width-400/2,screen.height-450/2,400,454,0x73,0,T_WINDOW_TITLE,0); |
100 | DefineAndDrawWindow(screen.width-400/2,screen.height-450/2,400,454,0x73,0,T_WINDOW_TITLE,0); |
103 | GetProcessInfo(#Form, SelfInfo); |
101 | GetProcessInfo(#Form, SelfInfo); |
104 | if (Form.status_window>2) break; |
102 | if (Form.status_window>2) break; |
105 | if (Form.width < 300) { MoveSize(OLD,OLD,300,OLD); break; } |
103 | if (Form.width < 300) { MoveSize(OLD,OLD,300,OLD); break; } |
106 | if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } |
104 | if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } |
107 | SelectList_Init(6, 6, Form.cwidth-12 - scroll1.size_x, Form.cheight-12-BOTPANEL_H, false); |
105 | SelectList_Init(6, 6, Form.cwidth-12 - scroll1.size_x, Form.cheight-12-BOTPANEL_H, false); |
108 | SelectList_DrawBorder(); |
106 | SelectList_DrawBorder(); |
109 | DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, 4, system.color.work); |
107 | DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, 4, system.color.work); |
110 | DrawBar(select_list.x-2, select_list.y+select_list.h+2, |
108 | DrawBar(select_list.x-2, select_list.y+select_list.h+2, |
111 | select_list.w+scroll1.size_x+4, BOTPANEL_H, system.color.work); |
109 | select_list.w+scroll1.size_x+4, BOTPANEL_H, system.color.work); |
112 | DrawCaptButton(Form.cwidth-116, |
110 | DrawCaptButton(Form.cwidth-116, |
113 | select_list.y+select_list.h+5, |
111 | select_list.y+select_list.h+5, |
114 | 110,25,BTN_ID_KILL_PROCESS,0xF38181, 0xFFFfff, T_END_PROCESS); |
112 | 110,25,BTN_ID_KILL_PROCESS,0xF38181, 0xFFFfff, T_END_PROCESS); |
115 | DrawCaptButton(Form.cwidth-236, |
113 | DrawCaptButton(Form.cwidth-236, |
116 | select_list.y+select_list.h+5, |
114 | select_list.y+select_list.h+5, |
117 | 110,25,BTN_ID_SHOW_PROCESS_INFO, |
115 | 110,25,BTN_ID_SHOW_PROCESS_INFO, |
118 | system.color.work_button, system.color.work_button_text, T_DETAILS); |
116 | system.color.work_button, system.color.work_button_text, T_DETAILS); |
119 | Draw_ShowSystemProcessesCheckbox(); |
117 | Draw_ShowSystemProcessesCheckbox(); |
120 | default: |
118 | default: |
121 | SelectList_LineChanged(); |
119 | SelectList_LineChanged(); |
122 | } |
120 | } |
123 | } |
121 | } |
124 | } |
122 | } |
125 | 123 | ||
126 | void SelectList_LineChanged() |
124 | void SelectList_LineChanged() |
127 | { |
125 | { |
128 | GetProcessList(); |
126 | GetProcessList(); |
129 | SelectList_Draw(); |
127 | SelectList_Draw(); |
130 | } |
128 | } |
131 | 129 | ||
132 | 130 | ||
133 | void GetProcessList() |
131 | void GetProcessList() |
134 | { |
132 | { |
135 | int i, j; |
133 | int i, j; |
136 | select_list.count=0; |
134 | select_list.count=0; |
137 | for (i=0; i |
135 | for (i=0; i |
138 | { |
136 | { |
139 | GetProcessInfo(#Process, i); |
137 | GetProcessInfo(#Process, i); |
140 | if (Process.name) |
138 | if (Process.name) |
141 | { |
139 | { |
142 | for (j=0; j<11; j++) if (Process.name[j]!=' ') { |
140 | for (j=0; j<11; j++) if (Process.name[j]!=' ') { |
143 | if (show_system==false) { |
141 | if (show_system==false) { |
144 | //do not show system process |
142 | //do not show system process |
145 | if (Process.name[0]=='@') break; |
143 | if (Process.name[0]=='@') break; |
146 | if (!strcmp(#Process.name, "IDLE")) break; |
144 | if (!strcmp(#Process.name, "IDLE")) break; |
147 | if (!strcmp(#Process.name, "OS")) break; |
145 | if (!strcmp(#Process.name, "OS")) break; |
148 | } |
146 | } |
149 | proc_list[select_list.count] = i; |
147 | proc_list[select_list.count] = i; |
150 | select_list.count++; |
148 | select_list.count++; |
151 | break; |
149 | break; |
152 | } |
150 | } |
153 | } |
151 | } |
154 | } |
152 | } |
155 | } |
153 | } |
156 | 154 | ||
157 | void SelectList_DrawLine(dword i) |
155 | void SelectList_DrawLine(dword i) |
158 | { |
156 | { |
159 | int posy; |
157 | int posy; |
160 | char cpu_use[16]; |
158 | char cpu_use[16]; |
161 | dword bg_color; |
159 | dword bg_color; |
162 | GetProcessInfo(#Process, proc_list[i+select_list.first]); |
160 | GetProcessInfo(#Process, proc_list[i+select_list.first]); |
163 | 161 | ||
164 | posy = i *select_list.item_h + select_list.y; |
162 | posy = i *select_list.item_h + select_list.y; |
165 | if (i % 2) bg_color = 0xFFFfff; else bg_color = 0xF0F0F0; |
163 | if (i % 2) bg_color = 0xFFFfff; else bg_color = 0xF0F0F0; |
166 | if (i+select_list.first == select_list.cur_y) { |
164 | if (i+select_list.first == select_list.cur_y) { |
167 | current_process_id = Process.ID; |
165 | current_process_id = Process.ID; |
168 | bg_color = 0x67CCEB; |
166 | bg_color = 0x67CCEB; |
169 | } |
167 | } |
170 | DrawBar(select_list.x, posy, select_list.w, select_list.item_h, bg_color); |
168 | DrawBar(select_list.x, posy, select_list.w, select_list.item_h, bg_color); |
171 | WriteText(select_list.x+005, posy+select_list.text_y, select_list.font_type, 0, #Process.name); |
169 | WriteText(select_list.x+005, posy+select_list.text_y, select_list.font_type, 0, #Process.name); |
172 | WriteText(select_list.w/10*5+select_list.x, posy+select_list.text_y, select_list.font_type, 0x444444, ConvertSizeToKb(Process.use_memory)); |
170 | WriteText(select_list.w/10*5+select_list.x, posy+select_list.text_y, select_list.font_type, 0x444444, ConvertSizeToKb(Process.use_memory)); |
173 | sprintf(#cpu_use, "%i %%", Process.use_cpu*100/maxcpu); |
171 | sprintf(#cpu_use, "%i %%", Process.use_cpu*100/maxcpu); |
174 | if (maxcpu) WriteText(select_list.w/10*8+select_list.x - calc(strlen(#cpu_use)-4*8), |
172 | if (maxcpu) WriteText(select_list.w/10*8+select_list.x - calc(strlen(#cpu_use)-4*8), |
175 | posy+select_list.text_y, select_list.font_type, 0x444444, #cpu_use); |
173 | posy+select_list.text_y, select_list.font_type, 0x444444, #cpu_use); |
176 | } |
174 | } |
177 | 175 | ||
178 | 176 | ||
179 | void Draw_ShowSystemProcessesCheckbox() { |
177 | void Draw_ShowSystemProcessesCheckbox() { |
180 | CheckBox(select_list.x + 3, select_list.y+select_list.h+10, 20, |
178 | CheckBox(select_list.x + 3, select_list.y+select_list.h+10, 20, |
181 | T_SHOW_SYSTEM_PROCESSES, show_system); |
179 | T_SHOW_SYSTEM_PROCESSES, show_system); |
182 | } |
180 | } |
183 | 181 | ||
184 | 182 | ||
185 | 183 | ||
186 | 184 | ||
187 | 185 | ||
188 | stop:11;>>> |
186 | stop:11;>>> |