Subversion Repositories Kolibri OS

Rev

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

Rev 7784 Rev 7796
Line 5... Line 5...
5
#include "../lib/collection.h"
5
#include "../lib/collection.h"
6
#include "../lib/list_box.h"
6
#include "../lib/list_box.h"
7
#include "../lib/fs.h"
7
#include "../lib/fs.h"
Line 8... Line 8...
8
 
8
 
-
 
9
#define ITEM_H 19
Line 9... Line 10...
9
#define ITEM_H 19
10
#define SEP_H 4
10
 
11
 
11
llist menu1;
12
llist menu1;
Line 12... Line 13...
12
collection names;
13
collection names;
Line 13... Line 14...
13
collection hotkeys;
14
collection hotkeys;
14
 
15
 
-
 
16
int selected, win_x, win_y;
Line 15... Line 17...
15
int selected, win_x, win_y;
17
 
16
 
18
int max_name_len;
17
int max_name_len;
19
int max_hotkey_len;
18
int max_hotkey_len;
20
int menu_w, menu_h;
Line 68... Line 70...
68
	names.add(current_name);
70
	names.add(current_name);
Line 69... Line 71...
69
 
71
 
70
	if (next_name) GetMenuItems(next_name+2);
72
	if (next_name) GetMenuItems(next_name+2);
Line -... Line 73...
-
 
73
}
-
 
74
 
-
 
75
int GetSeparatorsCount()
-
 
76
{
-
 
77
	int i, count=0;
-
 
78
	for (i=0; i
-
 
79
		if (streq(names.get(i), "-")) count++;
-
 
80
	}
-
 
81
	return count;
-
 
82
}
-
 
83
 
-
 
84
int MoveMouseToHandleSeparators(int _mouse_y)
-
 
85
{
-
 
86
	int i, item_y=menu1.y;
-
 
87
	int item_i=0;
-
 
88
	for (i=0; i
-
 
89
	{
-
 
90
		if (streq(names.get(i), "-")) {
-
 
91
			item_y += SEP_H;
-
 
92
		} else {
-
 
93
			item_y += ITEM_H;
-
 
94
			item_i++;
-
 
95
		}
-
 
96
		if (_mouse_y >= item_y) && (_mouse_y < item_y + ITEM_H) {
-
 
97
			return item_i * ITEM_H + menu1.y;
-
 
98
		}
-
 
99
	}
71
}
100
}
72
 
101
 
73
void main()
102
void main()
Line 74... Line 103...
74
{
103
{
Line 75... Line 104...
75
	proc_info Form;
104
	proc_info Form;
76
 
105
 
Line -... Line 106...
-
 
106
	if (!param) die("'Menu component is for developers only' -I");
-
 
107
 
-
 
108
	GetMenuItems(#param);
-
 
109
	GetMenuWidths();
77
	if (!param) die("'Menu component is for developers only' -I");
110
 
78
 
111
	menu_w = max_name_len + max_hotkey_len + 23;
79
	GetMenuItems(#param);
112
	menu_h = GetSeparatorsCount() * SEP_H 
80
	GetMenuWidths();
113
		+ calc(names.count - GetSeparatorsCount() * ITEM_H);
Line 81... Line 114...
81
 
114
 
Line 82... Line 115...
82
	menu1.count = names.count;
115
	menu1.count = names.count;
Line 91... Line 124...
91
	{
124
	{
92
		case evMouse:			
125
		case evMouse:			
93
			GetProcessInfo(#Form, SelfInfo);
126
			GetProcessInfo(#Form, SelfInfo);
94
			if (!CheckActiveProcess(Form.ID)) exit();
127
			if (!CheckActiveProcess(Form.ID)) exit();
95
			mouse.get();
128
			mouse.get();
-
 
129
			if (menu1.MouseOver(mouse.x, mouse.y)) {
-
 
130
				mouse.y = MoveMouseToHandleSeparators(mouse.y);
96
			if (menu1.ProcessMouse(mouse.x, mouse.y)) draw_list();
131
				if (menu1.ProcessMouse(mouse.x, mouse.y)) draw_list();
97
			if (mouse.lkm)&&(mouse.up) click();
132
				if (mouse.lkm)&&(mouse.up) click();	
-
 
133
			} 
98
			break;
134
			break;
Line 99... Line 135...
99
 
135
 
100
		case evKey:
136
		case evKey:
101
			GetKeys();
137
			GetKeys();
Line 119... Line 155...
119
 
155
 
120
		case SCAN_CODE_ENTER:
156
		case SCAN_CODE_ENTER:
Line 121... Line 157...
121
			click();
157
			click();
122
 
158
 
-
 
159
		case SCAN_CODE_DOWN:
123
		case SCAN_CODE_DOWN:
160
			if (!menu1.KeyDown()) 
124
			if (!menu1.KeyDown()) menu1.KeyHome();
161
			|| (menu1.count - menu1.cur_y - GetSeparatorsCount() -1 < 0) menu1.KeyHome();
Line 125... Line 162...
125
			draw_list();
162
			draw_list();
126
			break;
163
			break;
Line 135... Line 172...
135
	}
172
	}
136
}
173
}
Line 137... Line 174...
137
 
174
 
138
void draw_list()
175
void draw_list()
139
{
176
{
140
	int i, item_y;
177
	int i, item_y=menu1.y, item_i=0;
141
	dword name_color;
178
	dword name_color;
Line 142... Line 179...
142
	dword hotkey_color;
179
	dword hotkey_color;
143
 
180
 
Line 157... Line 194...
157
		skin_dark = skin_is_dark();
194
		skin_dark = skin_is_dark();
158
	}
195
	}
Line 159... Line 196...
159
 
196
 
160
	for (i=0; i
197
	for (i=0; i
-
 
198
	{
-
 
199
		if (streq(names.get(i), "-")) {
-
 
200
			DrawBar(menu1.x, item_y+0, menu1.w, 1, inactive_background_color);
-
 
201
			DrawBar(menu1.x, item_y+1, menu1.w, 1, system.color.work_dark);
-
 
202
			DrawBar(menu1.x, item_y+2, menu1.w, 1, system.color.work_light);
161
	{
203
			DrawBar(menu1.x, item_y+3, menu1.w, 1, inactive_background_color);
-
 
204
			item_y += SEP_H;
162
		item_y = i*ITEM_H+menu1.y;
205
		} else {
163
		if (i==menu1.cur_y) {
206
			if (item_i==menu1.cur_y) {
164
			hotkey_color = name_color = system.color.work_button_text;
207
				hotkey_color = name_color = system.color.work_button_text;
165
			DrawBar(menu1.x, item_y+1,        menu1.w, ITEM_H-2, active_background_color);
208
				DrawBar(menu1.x, item_y+1,        menu1.w, ITEM_H-2, active_background_color);
166
			DrawBar(menu1.x, item_y,          menu1.w, 1, active_top_border_color);
209
				DrawBar(menu1.x, item_y,          menu1.w, 1, active_top_border_color);
167
			DrawBar(menu1.x, item_y+ITEM_H-1, menu1.w, 1, system.color.work_light);
210
				DrawBar(menu1.x, item_y+ITEM_H-1, menu1.w, 1, system.color.work_light);
Line 173... Line 216...
173
				inactive_text_shadow_color, names.get(i));
216
					inactive_text_shadow_color, names.get(i));
174
		}
217
			}
175
		WriteText(-strlen(hotkeys.get(i))*6 + 13 + max_name_len + max_hotkey_len, 
218
			WriteText(-strlen(hotkeys.get(i))*6 + 13 + max_name_len + max_hotkey_len, 
176
			item_y + menu1.text_y, 0x80, hotkey_color, hotkeys.get(i));
219
				item_y + menu1.text_y, 0x80, hotkey_color, hotkeys.get(i));
177
		WriteText(13, item_y + menu1.text_y, 0x80, name_color, names.get(i));
220
			WriteText(13, item_y + menu1.text_y, 0x80, name_color, names.get(i));
-
 
221
			item_y += ITEM_H;
-
 
222
			item_i++;		
-
 
223
		}
178
	}
224
	}
179
	if (selected) WriteText(5, selected-1*ITEM_H + menu1.y + menu1.text_y, 0x80, 0xEE0000, "\x10");
225
	if (selected) WriteText(5, selected-1*ITEM_H + menu1.y + menu1.text_y, 0x80, 0xEE0000, "\x10");
180
}
226
}
Line 181... Line 227...
181
 
227