Subversion Repositories Kolibri OS

Rev

Rev 7906 | Rev 9453 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef TAB_PADDING
  2. #define TAB_PADDING 15
  3. #endif
  4.  
  5. #define TAB_HEIGHT 28
  6. #define NAME_SIZE 64
  7.  
  8. :struct _tabs
  9. {
  10.         int x,y,w;
  11.         int base_id;
  12.  
  13.         int active_tab;
  14.         char names[640];
  15.         int count;
  16.         dword events[10];
  17.  
  18.         int click();
  19.         void draw();
  20.         void draw_active_tab();
  21.         void add();
  22.  
  23.         dword draw_button();
  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<count; i++) {
  36.                 xx += draw_button(xx + TAB_PADDING, i, i*NAME_SIZE + #names) + TAB_PADDING;
  37.         }
  38. }
  39.  
  40. :void _tabs::draw_active_tab()
  41. {
  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++;
  50. }
  51.  
  52. :dword _tabs::draw_button(dword xx, _id, text)
  53. {
  54.         dword col_bg, col_text;
  55.         dword ww=strlen(text)*8;
  56.  
  57.         if (_id==active_tab)
  58.         {
  59.                 col_bg = 0xE44C9C;
  60.                 col_text = sc.work_text;
  61.         }
  62.         else
  63.         {
  64.                 col_bg = 0xC3A1B7;
  65.                 col_text = MixColors(sc.work, sc.work_text, 120);
  66.         }
  67.         DefineHiddenButton(xx-2,y, ww-1+4,TAB_HEIGHT-1, _id + base_id);
  68.         WriteText(xx, y+6, 0x90, col_text, text);
  69.         DrawBar(xx, y+TAB_HEIGHT-3, ww, 3, col_bg);
  70.         return ww;
  71. }
  72.  
  73. :int _tabs::click(int _id)
  74. {
  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;           
  81. }