Subversion Repositories Kolibri OS

Rev

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

Rev 7447 Rev 7450
Line 1... Line 1...
1
#ifndef INCLUDE_MENU_H
1
#ifndef INCLUDE_MENU_H
2
#define INCLUDE_MENU_H
2
#define INCLUDE_MENU_H
Line -... Line 3...
-
 
3
 
3
 
4
#ifndef INCLUDE_LIST_BOX
-
 
5
#include "../lib/list_box.h"
Line 4... Line 6...
4
#include "../lib/list_box.h"
6
#endif
Line 5... Line 7...
5
 
7
 
6
:dword menu_process_id;
8
:dword menu_process_id;
7
 
9
 
8
:struct _menu
-
 
9
{
10
:struct _menu : llist
10
	dword appear_x, appear_y, text, identifier, selected;	
11
{
11
	llist list;
12
	dword appear_x, appear_y, text, identifier, selected;	
Line 12... Line 13...
12
	void show();
13
	void show();
13
	char stak[4096];
14
	char stak[4096];
14
} menu;
15
} menu;
15
 
16
 
16
void _menu::show(dword _appear_x, _appear_y, _menu_width, _text, _identifier)
17
:void _menu::show(dword _appear_x, _appear_y, _menu_width, _menu_text, _identifier)
17
{
18
{
18
	#define ITEM_H 21
19
	#define ITEM_H 21
Line 19... Line 20...
19
	appear_x = _appear_x;
20
	appear_x = _appear_x;
20
	appear_y = _appear_y;
21
	appear_y = _appear_y;
21
	text = _text;
22
	text = _menu_text;
22
	identifier = _identifier;
23
	identifier = _identifier;
Line 23... Line 24...
23
 
24
 
24
	list.cur_y = -1;
25
	cur_y = -1;
Line 25... Line 26...
25
	list.ClearList();
26
	ClearList();
Line 37... Line 38...
37
	{
38
	{
38
		case evMouse:
39
		case evMouse:
39
			GetProcessInfo(#MenuForm, SelfInfo);
40
			GetProcessInfo(#MenuForm, SelfInfo);
40
			if (!CheckActiveProcess(MenuForm.ID)) _menu_no_item_click();
41
			if (!CheckActiveProcess(MenuForm.ID)) _menu_no_item_click();
41
			mouse.get();
42
			mouse.get();
42
			if (menu.list.ProcessMouse(mouse.x, mouse.y)) _menu_draw_list();
43
			if (menu.ProcessMouse(mouse.x, mouse.y)) _menu_draw_list();
43
			if (mouse.lkm)&&(mouse.up) _menu_item_click();
44
			if (mouse.lkm)&&(mouse.up) _menu_item_click();
44
			break;		
45
			break;		
45
		case evKey:
46
		case evKey:
46
			GetKeys();
47
			GetKeys();
47
			if (key_scancode==SCAN_CODE_ESC) _menu_no_item_click();
48
			if (key_scancode==SCAN_CODE_ESC) _menu_no_item_click();
48
			if (key_scancode==SCAN_CODE_ENTER) _menu_item_click();
49
			if (key_scancode==SCAN_CODE_ENTER) _menu_item_click();
49
			if (menu.list.ProcessKey(key_scancode)) _menu_draw_list();
50
			if (menu.ProcessKey(key_scancode)) _menu_draw_list();
50
			break;
51
			break;
51
		case evReDraw:
52
		case evReDraw:
52
			DefineAndDrawWindow(menu.appear_x,menu.appear_y,menu.list.w+2,menu.list.h+4,0x01, 0, 0, 0x01fffFFF);
53
			DefineAndDrawWindow(menu.appear_x,menu.appear_y,menu.w+2,menu.h+4,0x01, 0, 0, 0x01fffFFF);
53
			DrawPopup(0,0,menu.list.w,menu.list.h+3,0, 0xE4DFE1,0x9098B0);
54
			DrawPopup(0,0,menu.w,menu.h+3,0, 0xE4DFE1,0x9098B0);
54
			_menu_draw_list();				
55
			_menu_draw_list();				
55
	}
56
	}
56
}
57
}
Line 57... Line 58...
57
 
58
 
58
:void _menu_draw_list()
59
:void _menu_draw_list()
59
{
60
{
60
	int N, bgcol;
61
	int N, bgcol;
61
	for (N=0; N
62
	for (N=0; N
62
	{
63
	{
63
		if (N==menu.list.cur_y) bgcol=0xFFFfff; else bgcol=0xE4DFE1;
64
		if (N==menu.cur_y) bgcol=0xFFFfff; else bgcol=0xE4DFE1;
64
		DrawBar(menu.list.x, N*menu.list.item_h+menu.list.y, menu.list.w-3, menu.list.item_h, bgcol);
65
		DrawBar(menu.x, N*menu.item_h+menu.y, menu.w-3, menu.item_h, bgcol);
65
	}
66
	}
66
	WriteTextLines(13, menu.list.item_h-8/2+menu.list.y, 0x80, 0, menu.text, menu.list.item_h);
67
	WriteTextLines(13, menu.item_h-8/2+menu.y, 0x80, 0, menu.text, menu.item_h);
67
	if (menu.selected) WriteText(5, menu.selected-1*menu.list.item_h+8, 0x80, 0xEE0000, "\x10");
68
	if (menu.selected) WriteText(5, menu.selected-1*menu.item_h+8, 0x80, 0xEE0000, "\x10");
Line 68... Line 69...
68
}
69
}
69
 
70
 
70
:void _menu_item_click()
71
:void _menu_item_click()
71
{
72
{
72
	menu.list.cur_y = menu.identifier + menu.list.cur_y;
73
	menu.cur_y = menu.identifier + menu.cur_y;
Line 73... Line 74...
73
	KillProcess(menu_process_id);
74
	KillProcess(menu_process_id);
74
}
75
}
75
 
76
 
76
:void _menu_no_item_click()
77
:void _menu_no_item_click()
77
{
78
{
Line 78... Line 79...
78
	menu.list.cur_y = 0;
79
	menu.cur_y = 0;
79
	KillProcess(menu_process_id);
80
	KillProcess(menu_process_id);