Subversion Repositories Kolibri OS

Rev

Rev 7909 | Rev 9455 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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