Subversion Repositories Kolibri OS

Rev

Rev 9516 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef TAB_P
  2. #define TAB_P 15  //Tab padding
  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.         int count;
  15.         dword events[10];
  16.         dword names[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.line);
  32.                 DrawBar(x+1,y+1+TAB_HEIGHT,w,1, sc.light);             
  33.         }
  34.  
  35.         for (i=0; i<count; i++) {
  36.                 xx += draw_button(xx + TAB_P, i, names[i]) + TAB_P;
  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.         names[count] = 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.         WriteTextWithBg(xx, y+6, 0xD0, col_text, text, sc.work);
  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. }