2020-05-10 03:44:40 +02:00
|
|
|
#ifndef TAB_PADDING
|
2018-04-11 19:46:08 +02:00
|
|
|
#define TAB_PADDING 15
|
2020-05-10 03:44:40 +02:00
|
|
|
#endif
|
|
|
|
|
2018-04-11 19:46:08 +02:00
|
|
|
#define TAB_HEIGHT 28
|
2020-05-10 14:49:02 +02:00
|
|
|
#define NAME_SIZE 64
|
2018-04-11 19:46:08 +02:00
|
|
|
|
|
|
|
:struct _tabs
|
|
|
|
{
|
2020-05-10 14:49:02 +02:00
|
|
|
int x,y,w;
|
|
|
|
int base_id;
|
|
|
|
|
2018-04-11 19:46:08 +02:00
|
|
|
int active_tab;
|
2020-05-10 14:49:02 +02:00
|
|
|
char names[640];
|
|
|
|
int count;
|
|
|
|
dword events[10];
|
|
|
|
|
2018-04-11 19:46:08 +02:00
|
|
|
int click();
|
2020-05-10 14:49:02 +02:00
|
|
|
void draw();
|
|
|
|
void draw_active_tab();
|
|
|
|
void add();
|
|
|
|
|
|
|
|
dword draw_button();
|
2018-04-11 19:46:08 +02:00
|
|
|
};
|
|
|
|
|
2020-05-10 14:49:02 +02:00
|
|
|
:void _tabs::draw()
|
|
|
|
{
|
|
|
|
int i, xx=x;
|
|
|
|
|
|
|
|
if (w) {
|
|
|
|
DrawBar(x+1,y+0+TAB_HEIGHT,w,1, sc.work_graph);
|
|
|
|
DrawBar(x+1,y+1+TAB_HEIGHT,w,1, sc.work_light);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<count; i++) {
|
|
|
|
xx += draw_button(xx + TAB_PADDING, i, i*NAME_SIZE + #names) + TAB_PADDING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
:void _tabs::draw_active_tab()
|
2018-04-11 19:46:08 +02:00
|
|
|
{
|
2020-05-10 14:49:02 +02:00
|
|
|
events[active_tab]();
|
2018-04-11 19:46:08 +02:00
|
|
|
}
|
|
|
|
|
2020-05-10 14:49:02 +02:00
|
|
|
:void _tabs::add(dword text, event)
|
|
|
|
{
|
|
|
|
strcpy(count*NAME_SIZE + #names, text);
|
|
|
|
events[count] = event;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
:dword _tabs::draw_button(dword xx, _id, text)
|
2018-04-11 19:46:08 +02:00
|
|
|
{
|
|
|
|
dword col_bg, col_text;
|
2020-05-10 14:49:02 +02:00
|
|
|
dword ww=strlen(text)*8;
|
2018-04-11 19:46:08 +02:00
|
|
|
|
2020-05-10 14:49:02 +02:00
|
|
|
if (_id==active_tab)
|
2018-04-11 19:46:08 +02:00
|
|
|
{
|
2020-05-10 14:49:02 +02:00
|
|
|
col_bg = 0xE44C9C;
|
|
|
|
col_text = sc.work_text;
|
2018-04-11 19:46:08 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-10 14:49:02 +02:00
|
|
|
col_bg = 0xC3A1B7;
|
|
|
|
col_text = MixColors(sc.work, sc.work_text, 120);
|
2018-04-11 19:46:08 +02:00
|
|
|
}
|
2020-05-10 14:49:02 +02:00
|
|
|
DefineHiddenButton(xx-2,y, ww-1+4,TAB_HEIGHT-1, _id + base_id);
|
2018-04-11 20:32:00 +02:00
|
|
|
WriteText(xx, y+6, 0x90, col_text, text);
|
2020-05-10 14:49:02 +02:00
|
|
|
DrawBar(xx, y+TAB_HEIGHT-3, ww, 3, col_bg);
|
|
|
|
return ww;
|
2018-04-11 19:46:08 +02:00
|
|
|
}
|
|
|
|
|
2020-05-10 14:49:02 +02:00
|
|
|
:int _tabs::click(int _id)
|
2018-04-11 19:46:08 +02:00
|
|
|
{
|
2020-05-10 14:49:02 +02:00
|
|
|
if (_id < base_id) || (_id > base_id + count) || (_id == active_tab) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
active_tab = _id - base_id;
|
|
|
|
events[active_tab]();
|
|
|
|
return true;
|
2018-04-11 19:46:08 +02:00
|
|
|
}
|