Subversion Repositories Kolibri OS

Rev

Rev 7978 | Rev 8389 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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