Subversion Repositories Kolibri OS

Rev

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

Rev 7906 Rev 7909
1
#ifndef TAB_PADDING
1
#ifndef TAB_PADDING
2
#define TAB_PADDING 15
2
#define TAB_PADDING 15
3
#endif
3
#endif
4
 
4
 
5
#define TAB_HEIGHT 28
5
#define TAB_HEIGHT 28
-
 
6
#define NAME_SIZE 64
6
 
7
 
7
:struct _tabs
8
:struct _tabs
8
{
9
{
-
 
10
	int x,y,w;
-
 
11
	int base_id;
-
 
12
 
9
	int active_tab;
13
	int active_tab;
-
 
14
	char names[640];
10
	int x,y,w,h;
15
	int count;
11
	dword draw_button();
16
	dword events[10];
-
 
17
 
12
	int click();
18
	int click();
-
 
19
	void draw();
13
	void draw_wrapper();
20
	void draw_active_tab();
-
 
21
	void add();
-
 
22
 
-
 
23
	dword draw_button();
14
};
24
};
-
 
25
 
-
 
26
:void _tabs::draw()
-
 
27
{
-
 
28
	int i, xx=x;
-
 
29
 
-
 
30
	if (w) {
-
 
31
		DrawBar(x+1,y+0+TAB_HEIGHT,w,1, sc.work_graph);
-
 
32
		DrawBar(x+1,y+1+TAB_HEIGHT,w,1, sc.work_light);		
-
 
33
	}
-
 
34
 
-
 
35
	for (i=0; i
-
 
36
		xx += draw_button(xx + TAB_PADDING, i, i*NAME_SIZE + #names) + TAB_PADDING;
-
 
37
	}
-
 
38
}
15
 
39
 
16
:void _tabs::draw_wrapper()
40
:void _tabs::draw_active_tab()
17
{
-
 
18
	DrawRectangle(x,y+TAB_HEIGHT,w-1,h-TAB_HEIGHT, sc.work_graph);
41
{
19
	DrawBar(x+1,y+1+TAB_HEIGHT,w-3,1, sc.work_light);
42
	events[active_tab]();
-
 
43
}
-
 
44
 
-
 
45
:void _tabs::add(dword text, event)
-
 
46
{
-
 
47
	strcpy(count*NAME_SIZE + #names, text);
-
 
48
	events[count] = event;
-
 
49
	count++;
20
}
50
}
21
 
51
 
22
:dword _tabs::draw_button(dword xx, but_id, text)
52
:dword _tabs::draw_button(dword xx, _id, text)
23
{
53
{
24
	dword col_bg, col_text;
54
	dword col_bg, col_text;
25
	dword ww=strlen(text)*8, hh=TAB_HEIGHT;
55
	dword ww=strlen(text)*8;
26
 
56
 
27
	if (but_id==active_tab)
57
	if (_id==active_tab)
28
	{
58
	{
29
		col_bg=0xE44C9C;
59
		col_bg = 0xE44C9C;
30
		col_text=sc.work_text;
60
		col_text = sc.work_text;
31
	}
61
	}
32
	else
62
	else
33
	{
63
	{
34
		col_bg=0xC3A1B7;
64
		col_bg = 0xC3A1B7;
35
		col_text= MixColors(sc.work, sc.work_text, 120);
65
		col_text = MixColors(sc.work, sc.work_text, 120);
36
	} 
66
	} 
37
	DefineHiddenButton(xx-2,y, ww-1+4,hh-1, but_id);
67
	DefineHiddenButton(xx-2,y, ww-1+4,TAB_HEIGHT-1, _id + base_id);
38
	WriteText(xx, y+6, 0x90, col_text, text);
68
	WriteText(xx, y+6, 0x90, col_text, text);
39
	DrawBar(xx, y+hh-3, ww, 3, col_bg);
69
	DrawBar(xx, y+TAB_HEIGHT-3, ww, 3, col_bg);
40
	//DrawStandartCaptButton(xx, y, but_id, text); //GetFreeButtonId()
-
 
41
	return xx;
70
	return ww;
42
}
71
}
43
 
72
 
44
:int _tabs::click(int N)
73
:int _tabs::click(int _id)
-
 
74
{
-
 
75
	if (_id < base_id) || (_id > base_id + count) || (_id == active_tab) {
-
 
76
		return false; 
45
{
77
	}
46
	if (N==active_tab) return false;
78
	active_tab = _id - base_id;
47
	active_tab = N;
79
	events[active_tab]();
48
	return true;
80
	return true;		
49
}
81
}