3,28 → 3,58 |
#endif |
|
#define TAB_HEIGHT 28 |
#define NAME_SIZE 64 |
|
:struct _tabs |
{ |
int x,y,w; |
int base_id; |
|
int active_tab; |
int x,y,w,h; |
char names[640]; |
int count; |
dword events[10]; |
|
int click(); |
void draw(); |
void draw_active_tab(); |
void add(); |
|
dword draw_button(); |
int click(); |
void draw_wrapper(); |
}; |
|
:void _tabs::draw_wrapper() |
:void _tabs::draw() |
{ |
DrawRectangle(x,y+TAB_HEIGHT,w-1,h-TAB_HEIGHT, sc.work_graph); |
DrawBar(x+1,y+1+TAB_HEIGHT,w-3,1, sc.work_light); |
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); |
} |
|
:dword _tabs::draw_button(dword xx, but_id, text) |
for (i=0; i<count; i++) { |
xx += draw_button(xx + TAB_PADDING, i, i*NAME_SIZE + #names) + TAB_PADDING; |
} |
} |
|
:void _tabs::draw_active_tab() |
{ |
events[active_tab](); |
} |
|
:void _tabs::add(dword text, event) |
{ |
strcpy(count*NAME_SIZE + #names, text); |
events[count] = event; |
count++; |
} |
|
:dword _tabs::draw_button(dword xx, _id, text) |
{ |
dword col_bg, col_text; |
dword ww=strlen(text)*8, hh=TAB_HEIGHT; |
dword ww=strlen(text)*8; |
|
if (but_id==active_tab) |
if (_id==active_tab) |
{ |
col_bg=0xE44C9C; |
col_text=sc.work_text; |
34,16 → 64,18 |
col_bg=0xC3A1B7; |
col_text= MixColors(sc.work, sc.work_text, 120); |
} |
DefineHiddenButton(xx-2,y, ww-1+4,hh-1, but_id); |
DefineHiddenButton(xx-2,y, ww-1+4,TAB_HEIGHT-1, _id + base_id); |
WriteText(xx, y+6, 0x90, col_text, text); |
DrawBar(xx, y+hh-3, ww, 3, col_bg); |
//DrawStandartCaptButton(xx, y, but_id, text); //GetFreeButtonId() |
return xx; |
DrawBar(xx, y+TAB_HEIGHT-3, ww, 3, col_bg); |
return ww; |
} |
|
:int _tabs::click(int N) |
:int _tabs::click(int _id) |
{ |
if (N==active_tab) return false; |
active_tab = N; |
if (_id < base_id) || (_id > base_id + count) || (_id == active_tab) { |
return false; |
} |
active_tab = _id - base_id; |
events[active_tab](); |
return true; |
} |