Rev 7229 | Rev 7266 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7229 | Rev 7244 | ||
---|---|---|---|
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/io.h" |
11 | #include "../lib/io.h" |
12 | #include "../lib/collection.h" |
12 | #include "../lib/collection.h" |
13 | #include "../lib/patterns/restart_process.h" |
13 | #include "../lib/patterns/restart_process.h" |
14 | 14 | ||
15 | #include "../lib/mem.h" |
15 | #include "../lib/mem.h" |
16 | 16 | ||
17 | #include "../lib/obj/libio.h" |
17 | #include "../lib/obj/libio.h" |
18 | #include "../lib/obj/libimg.h" |
18 | #include "../lib/obj/libimg.h" |
19 | #include "../lib/obj/libini.h" |
19 | #include "../lib/obj/libini.h" |
20 | 20 | ||
21 | //===================================================// |
21 | //===================================================// |
22 | // // |
22 | // // |
23 | // DATA // |
23 | // DATA // |
24 | // // |
24 | // // |
25 | //===================================================// |
25 | //===================================================// |
26 | 26 | ||
27 | int current_process_id = 0; |
27 | int current_process_id = 0; |
28 | int proc_list[256]; |
28 | int proc_list[256]; |
29 | collection attached; |
29 | collection attached; |
30 | 30 | ||
31 | llist list; |
31 | llist list; |
32 | 32 | ||
33 | proc_info Form; |
33 | proc_info Form; |
34 | proc_info Process; |
34 | proc_info Process; |
35 | 35 | ||
36 | enum { |
36 | enum { |
37 | ATTACHEMENT_BOTTOM, |
37 | ATTACHEMENT_BOTTOM, |
38 | ATTACHEMENT_LEFT, |
38 | ATTACHEMENT_LEFT, |
39 | ATTACHEMENT_TOP, |
39 | ATTACHEMENT_TOP, |
40 | ATTACHEMENT_RIGHT |
40 | ATTACHEMENT_RIGHT |
41 | }; |
41 | }; |
42 | int attachement = ATTACHEMENT_BOTTOM; |
42 | int attachement = ATTACHEMENT_BOTTOM; |
43 | 43 | ||
44 | #define CELLW 40 |
44 | #define CELLW 40 |
45 | #define CELLH 40 |
45 | #define CELLH 40 |
46 | 46 | ||
47 | dword COLOR_BG = 0x3B3B3B; |
47 | dword COLOR_BG = 0x3B3B3B; |
48 | dword COLOR_MENU_BG = 0x323232; |
48 | dword COLOR_MENU_BG = 0x323232; |
49 | dword COLOR_OPENED = 0x999999; |
49 | dword COLOR_OPENED = 0x999999; |
50 | dword COLOR_ACTIVE = 0x0099FF; |
50 | dword COLOR_ACTIVE = 0x0099FF; |
51 | dword COLOR_TEXT = 0xFFFfff; |
51 | dword COLOR_TEXT = 0xFFFfff; |
52 | 52 | ||
53 | 53 | ||
54 | //===================================================// |
54 | //===================================================// |
55 | // // |
55 | // // |
56 | // CODE // |
56 | // CODE // |
57 | // // |
57 | // // |
58 | //===================================================// |
58 | //===================================================// |
59 | 59 | ||
60 | void main() |
60 | void main() |
61 | { |
61 | { |
62 | byte btn; |
62 | int btn; |
63 | load_dll(libio, #libio_init,1); |
63 | load_dll(libio, #libio_init,1); |
64 | load_dll(libimg, #libimg_init,1); |
64 | load_dll(libimg, #libimg_init,1); |
65 | load_dll(libini, #lib_init,1); |
65 | load_dll(libini, #lib_init,1); |
66 | 66 | ||
67 | Libimg_LoadImage(#skin, "/sys/icons32.png"); |
67 | Libimg_LoadImage(#skin, "/sys/icons32.png"); |
68 | Libimg_FillTransparent(skin.image, skin.w, skin.h, COLOR_BG); |
68 | Libimg_FillTransparent(skin.image, skin.w, skin.h, COLOR_BG); |
69 | 69 | ||
70 | ini_get_int stdcall ("/sys/appicons.ini", "taskbar", "attachement", ATTACHEMENT_BOTTOM); |
70 | ini_get_int stdcall ("/sys/appicons.ini", "taskbar", "attachement", ATTACHEMENT_BOTTOM); |
71 | attachement = EAX; |
71 | attachement = EAX; |
72 | 72 | ||
73 | SetAttachement(); |
73 | SetAttachement(); |
74 | GetAttachedItems(); |
74 | GetAttachedItems(); |
75 | 75 | ||
76 | GetProcessInfo(#Form, SelfInfo); |
76 | GetProcessInfo(#Form, SelfInfo); |
77 | SetWindowLayerBehaviour(-1, ZPOS_DESKTOP); |
77 | SetWindowLayerBehaviour(-1, ZPOS_DESKTOP); |
78 | SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
78 | SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
79 | loop() |
79 | loop() |
80 | { |
80 | { |
81 | WaitEventTimeout(50); |
81 | WaitEventTimeout(50); |
82 | switch(EAX & 0xFF) |
82 | switch(EAX & 0xFF) |
83 | { |
83 | { |
84 | case evMouse: |
84 | case evMouse: |
85 | if (!CheckActiveProcess(Form.ID)) break; |
85 | if (!CheckActiveProcess(Form.ID)) break; |
86 | mouse.get(); |
86 | mouse.get(); |
87 | if (mouse.down) {} |
87 | if (mouse.down) {} |
88 | //if (list.ProcessMouse()) DrawProcessList(); |
88 | //if (list.ProcessMouse()) DrawProcessList(); |
89 | break; |
89 | break; |
90 | case evKey: |
90 | case evKey: |
91 | GetKeys(); |
91 | GetKeys(); |
92 | if (key_scancode == SCAN_CODE_ESC) { |
92 | if (key_scancode == SCAN_CODE_ESC) { |
93 | RunProgram(#program_path, NULL); |
93 | RunProgram(#program_path, NULL); |
94 | ExitProcess(); |
94 | ExitProcess(); |
95 | } |
95 | } |
96 | break; |
96 | break; |
97 | case evButton: |
97 | case evButton: |
98 | btn = GetButtonID(); |
98 | btn = GetButtonID(); |
99 | btn -= 100; |
99 | btn -= 100; |
100 | if (btn < attached.count) RunProgram(attached.get(btn), NULL); |
100 | if (btn < attached.count) RunProgram(attached.get(btn), NULL); |
101 | else EventSetActiveProcess(btn); |
101 | else EventSetActiveProcess(btn); |
102 | break; |
102 | break; |
103 | case evReDraw: |
103 | case evReDraw: |
104 | DefineUnDragableWindow(NULL, NULL, NULL, NULL); |
104 | DefineUnDragableWindow(NULL, NULL, NULL, NULL); |
105 | list.SetSizes(0, 0, Form.width+1, Form.height+2, CELLH); |
105 | list.SetSizes(0, 0, Form.width+1, Form.height+2, CELLH); |
106 | default: |
106 | default: |
107 | DrawProcessList(); |
107 | DrawProcessList(); |
108 | } |
108 | } |
109 | } |
109 | } |
110 | } |
110 | } |
111 | 111 | ||
112 | 112 | ||
113 | void GetProcessList() |
113 | void GetProcessList() |
114 | { |
114 | { |
115 | int i, j; |
115 | int i, j; |
116 | list.count=0; |
116 | list.count=0; |
117 | 117 | ||
118 | for (i=0; i |
118 | for (i=0; i |
119 | { |
119 | { |
120 | proc_list[list.count] = 0; |
120 | proc_list[list.count] = 0; |
121 | list.count++; |
121 | list.count++; |
122 | } |
122 | } |
123 | 123 | ||
124 | for (i=0; i |
124 | for (i=0; i |
125 | { |
125 | { |
126 | GetProcessInfo(#Process, i); |
126 | GetProcessInfo(#Process, i); |
127 | if (Process.name) |
127 | if (Process.name) |
128 | { |
128 | { |
129 | for (j=0; j<11; j++) if (Process.name[j]!=' ') { |
129 | for (j=0; j<11; j++) if (Process.name[j]!=' ') { |
130 | //do not show system process |
130 | //do not show system process |
131 | if (Process.name[0]=='@') break; |
131 | if (Process.name[0]=='@') break; |
132 | if (!strcmp(#Process.name, "IDLE")) break; |
132 | if (!strcmp(#Process.name, "IDLE")) break; |
133 | if (!strcmp(#Process.name, "OS")) break; |
133 | if (!strcmp(#Process.name, "OS")) break; |
134 | if (!Process.width) && (!Process.height) break; |
134 | if (!Process.width) && (!Process.height) break; |
135 | proc_list[list.count] = i; |
135 | proc_list[list.count] = i; |
136 | list.count++; |
136 | list.count++; |
137 | break; |
137 | break; |
138 | } |
138 | } |
139 | } |
139 | } |
140 | } |
140 | } |
141 | } |
141 | } |
142 | 142 | ||
143 | void DrawProcessList() |
143 | void DrawProcessList() |
144 | { |
144 | { |
145 | #define ACTIVE_SIZE 3 |
145 | #define ACTIVE_SIZE 3 |
146 | #define CELL_MARGIN_X 10 |
146 | #define CELL_MARGIN_X 10 |
147 | #define CELL_MARGIN_Y 4 |
147 | #define CELL_MARGIN_Y 4 |
148 | #define CELL_PADDING 4 |
148 | #define CELL_PADDING 4 |
149 | int i; |
149 | int i; |
150 | int posy=list.y; |
150 | int posy=list.y; |
151 | int posx=list.x; |
151 | int posx=list.x; |
152 | int icon_n; |
152 | int icon_n; |
153 | dword status_color; |
153 | dword status_color; |
154 | 154 | ||
155 | GetProcessList(); |
155 | GetProcessList(); |
156 | 156 | ||
157 | for (i=0; i |
157 | for (i=0; i |
158 | { |
158 | { |
159 | if (proc_list[i+list.first]==0) { |
159 | if (proc_list[i+list.first]==0) { |
160 | status_color = COLOR_BG; |
160 | status_color = COLOR_BG; |
161 | ini_get_int stdcall ( |
161 | ini_get_int stdcall ( |
162 | "/sys/appicons.ini", |
162 | "/sys/appicons.ini", |
163 | "icons", |
163 | "icons", |
164 | attached.get(i+list.first)+strrchr(attached.get(i+list.first),'/'), |
164 | attached.get(i+list.first)+strrchr(attached.get(i+list.first),'/'), |
165 | 0 |
165 | 0 |
166 | ); |
166 | ); |
167 | icon_n = EAX; |
167 | icon_n = EAX; |
168 | } |
168 | } |
169 | else { |
169 | else { |
170 | GetProcessInfo(#Process, proc_list[i+list.first]); |
170 | GetProcessInfo(#Process, proc_list[i+list.first]); |
171 | strlwr(#Process.name); |
171 | strlwr(#Process.name); |
172 | ini_get_int stdcall ("/sys/appicons.ini", "icons", #Process.name, 0); |
172 | ini_get_int stdcall ("/sys/appicons.ini", "icons", #Process.name, 0); |
173 | icon_n = EAX; |
173 | icon_n = EAX; |
174 | if (CheckActiveProcess(Process.ID)) && (Process.status_window!=2) { |
174 | if (CheckActiveProcess(Process.ID)) && (Process.status_window!=2) { |
175 | current_process_id = Process.ID; |
175 | current_process_id = Process.ID; |
176 | status_color = COLOR_ACTIVE; |
176 | status_color = COLOR_ACTIVE; |
177 | } |
177 | } |
178 | else { |
178 | else { |
179 | status_color = COLOR_OPENED; |
179 | status_color = COLOR_OPENED; |
180 | } |
180 | } |
181 | } |
181 | } |
182 | DrawWideRectangle(posx, posy, 40, 40, CELL_PADDING, COLOR_BG); |
182 | DrawWideRectangle(posx, posy, 40, 40, CELL_PADDING, COLOR_BG); |
183 | DefineButton(posx, posy, CELLW-1, CELLH, 100+i+BT_HIDE+BT_NOFRAME, NULL); |
183 | DefineButton(posx, posy, CELLW-1, CELLH, 100+i+BT_HIDE+BT_NOFRAME, NULL); |
184 | img_draw stdcall(skin.image, posx+CELL_PADDING, posy+CELL_PADDING, 32, 32, 0, 32*icon_n); |
184 | img_draw stdcall(skin.image, posx+CELL_PADDING, posy+CELL_PADDING, 32, 32, 0, 32*icon_n); |
185 | 185 | ||
186 | if (ATTACHEMENT_BOTTOM==attachement) DrawBar(posx, posy+CELLH-ACTIVE_SIZE, CELLW, ACTIVE_SIZE, status_color); |
186 | if (ATTACHEMENT_BOTTOM==attachement) DrawBar(posx, posy+CELLH-ACTIVE_SIZE, CELLW, ACTIVE_SIZE, status_color); |
187 | if (ATTACHEMENT_LEFT ==attachement) DrawBar(posx, posy, ACTIVE_SIZE, CELLH, status_color); |
187 | if (ATTACHEMENT_LEFT ==attachement) DrawBar(posx, posy, ACTIVE_SIZE, CELLH, status_color); |
188 | if (ATTACHEMENT_TOP ==attachement) DrawBar(posx, posy, CELLW, ACTIVE_SIZE, status_color); |
188 | if (ATTACHEMENT_TOP ==attachement) DrawBar(posx, posy, CELLW, ACTIVE_SIZE, status_color); |
189 | if (ATTACHEMENT_RIGHT ==attachement) DrawBar(posx+CELLW-ACTIVE_SIZE, posy, ACTIVE_SIZE, CELLH, status_color); |
189 | if (ATTACHEMENT_RIGHT ==attachement) DrawBar(posx+CELLW-ACTIVE_SIZE, posy, ACTIVE_SIZE, CELLH, status_color); |
190 | 190 | ||
191 | if (ATTACHEMENT_TOP==attachement) || (ATTACHEMENT_BOTTOM==attachement) { |
191 | if (ATTACHEMENT_TOP==attachement) || (ATTACHEMENT_BOTTOM==attachement) { |
192 | posx += CELLW; |
192 | posx += CELLW; |
193 | DrawBar(posx, posy, CELL_MARGIN_X, list.h, COLOR_BG); |
193 | DrawBar(posx, posy, CELL_MARGIN_X, list.h, COLOR_BG); |
194 | posx += CELL_MARGIN_X; |
194 | posx += CELL_MARGIN_X; |
195 | } |
195 | } |
196 | if (ATTACHEMENT_LEFT==attachement) || (ATTACHEMENT_RIGHT==attachement) { |
196 | if (ATTACHEMENT_LEFT==attachement) || (ATTACHEMENT_RIGHT==attachement) { |
197 | posy += CELLH; |
197 | posy += CELLH; |
198 | DrawBar(posx, posy, list.w, CELL_MARGIN_Y, COLOR_BG); |
198 | DrawBar(posx, posy, list.w, CELL_MARGIN_Y, COLOR_BG); |
199 | posy += CELL_MARGIN_Y; |
199 | posy += CELL_MARGIN_Y; |
200 | } |
200 | } |
201 | } |
201 | } |
202 | DrawBar(posx, posy, list.w, list.h, COLOR_BG); |
202 | DrawBar(posx, posy, list.w, list.h, COLOR_BG); |
203 | } |
203 | } |
204 | 204 | ||
205 | void SetAttachement() |
205 | void SetAttachement() |
206 | { |
206 | { |
207 | if (attachement==ATTACHEMENT_LEFT) { |
207 | if (attachement==ATTACHEMENT_LEFT) { |
208 | DefineUnDragableWindow(0, 0, CELLW-1, screen.height); |
208 | DefineUnDragableWindow(0, 0, CELLW-1, screen.height); |
209 | SetClientScreenArea(CELLW, screen.width-CELLW, 0, screen.height); |
209 | SetClientScreenArea(CELLW, screen.width-CELLW, 0, screen.height); |
210 | } |
210 | } |
211 | if (attachement==ATTACHEMENT_RIGHT) { |
211 | if (attachement==ATTACHEMENT_RIGHT) { |
212 | DefineUnDragableWindow(screen.width - CELLW, 0, CELLW, screen.height); |
212 | DefineUnDragableWindow(screen.width - CELLW, 0, CELLW, screen.height); |
213 | SetClientScreenArea(0, screen.width-CELLW, 0, screen.height); |
213 | SetClientScreenArea(0, screen.width-CELLW, 0, screen.height); |
214 | } |
214 | } |
215 | if (attachement==ATTACHEMENT_TOP) { |
215 | if (attachement==ATTACHEMENT_TOP) { |
216 | DefineUnDragableWindow(0, 0, screen.width, CELLH-1); |
216 | DefineUnDragableWindow(0, 0, screen.width, CELLH-1); |
217 | SetClientScreenArea(0, 0, CELLH, screen.height); |
217 | SetClientScreenArea(0, 0, CELLH, screen.height); |
218 | } |
218 | } |
219 | if (attachement==ATTACHEMENT_BOTTOM) { |
219 | if (attachement==ATTACHEMENT_BOTTOM) { |
220 | DefineUnDragableWindow(0, screen.height, screen.width, CELLH); |
220 | DefineUnDragableWindow(0, screen.height, screen.width, CELLH); |
221 | SetClientScreenArea(0, 0, 0, screen.height - CELLH); |
221 | SetClientScreenArea(0, 0, 0, screen.height - CELLH); |
222 | } |
222 | } |
223 | } |
223 | } |
224 | 224 | ||
225 | byte draw_icons_from_section(dword key_value, key_name, sec_name, f_name) |
225 | byte draw_icons_from_section(dword key_value, key_name, sec_name, f_name) |
226 | { |
226 | { |
227 | attached.add(key_name); |
227 | attached.add(key_name); |
228 | return true; |
228 | return true; |
229 | } |
229 | } |
230 | 230 | ||
231 | void GetAttachedItems() |
231 | void GetAttachedItems() |
232 | { |
232 | { |
233 | attached.drop(); |
233 | attached.drop(); |
234 | ini_enum_keys stdcall ("/sys/appicons.ini", "attached", #draw_icons_from_section); |
234 | ini_enum_keys stdcall ("/sys/appicons.ini", "attached", #draw_icons_from_section); |
235 | } |
235 | } |
236 | //===================================================// |
236 | //===================================================// |
237 | // // |
237 | // // |
238 | // EVENTS // |
238 | // EVENTS // |
239 | // // |
239 | // // |
240 | //===================================================// |
240 | //===================================================// |
241 | 241 | ||
242 | //If we clicked on current active process then minimize it |
242 | //If we clicked on current active process then minimize it |
243 | //else set active |
243 | //else set active |
244 | void EventSetActiveProcess(dword i) |
244 | void EventSetActiveProcess(dword i) |
245 | { |
245 | { |
246 | GetProcessInfo(#Process, proc_list[i+list.first]); |
246 | GetProcessInfo(#Process, proc_list[i+list.first]); |
247 | Process.num_slot = GetProcessSlot(Process.ID); |
247 | Process.num_slot = GetProcessSlot(Process.ID); |
248 | if (Process.ID) ActivateWindow(Process.num_slot); |
248 | if (Process.ID) ActivateWindow(Process.num_slot); |
249 | if (current_process_id == Process.ID) && (Process.status_window!=2) { |
249 | if (current_process_id == Process.ID) && (Process.status_window!=2) { |
250 | MinimizeWindow(); |
250 | MinimizeWindow(); |
251 | //TODO: make another window active |
251 | //TODO: make another window active |
252 | } |
252 | } |
253 | DrawProcessList(); |
253 | DrawProcessList(); |
254 | } |
254 | } |
255 | 255 | ||
256 | 256 | ||
257 | stop:11;>> |
257 | stop:11;>> |