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
|
|
|
int count;
|
|
|
|
dword events[10];
|
2021-12-21 18:22:15 +01:00
|
|
|
dword names[10];
|
2020-05-10 14:49:02 +02:00
|
|
|
|
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++) {
|
2021-12-21 18:22:15 +01:00
|
|
|
xx += draw_button(xx + TAB_PADDING, i, names[i]) + TAB_PADDING;
|
2020-05-10 14:49:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
: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)
|
|
|
|
{
|
2021-12-21 18:22:15 +01:00
|
|
|
names[count] = text;
|
2020-05-10 14:49:02 +02:00
|
|
|
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);
|
2021-12-22 02:26:10 +01:00
|
|
|
WriteTextWithBg(xx, y+6, 0xD0, col_text, text, sc.work);
|
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
|
|
|
}
|