/***************************************************************************
                          SIMPLY POWERFUL TOOLKIT (SPTK)
                          CTabs.h  -  description
                             -------------------
    begin                : Tue Feb 26 2002
    copyright            : (C) 2002-2006 by Alexey S.Parshin
    email                : alexeyp@gmail.com
 ***************************************************************************/

/***************************************************************************
   This library is free software; you can redistribute it and/or modify it 
   under the terms of the GNU Library General Public License as published by
   the Free Software Foundation; either version 2 of the License, or (at 
   your option) any later version.

   This library is distributed in the hope that it will be useful, but 
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
   General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; if not, write to the Free Software Foundation, 
   Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

   Please report all bugs and problems to "alexeyp@gmail.com"
 ***************************************************************************/

#ifndef __CTABS_H__
#define __CTABS_H__

#include <sptk3/sptk.h>
#include <sptk3/CGroup.h>

namespace sptk {

   /// @addtogroup gui GUI Classes
   /// @{

	class CTabGroup;

   /// @brief Tabs widget
   ///
   /// It can show the tabs in several rows if they are too wide to fit.
	class SP_EXPORT CTabs : public CGroup {
		CTabGroup*  m_tabs;            ///< Tabs as a separate group
		int         m_autoColorIndex;  ///< The internal index inside tabs auto-color table

      /// auto-color table
		static const Fl_Color AutoColorTable[16];

		void        removeEmptyLastPage();                             ///< Removes an empty last page prior to adding a new page
	protected:
		virtual void prepareNewPage(Fl_Group *page,bool autoColor);    ///< Sets default parameters for a new page
	public:
      /// @brief Constructor in SPTK style 
      /// @param label const char*, label
      /// @param layoutSize int, widget align in layout
      /// @param layoutAlign CLayoutAlign, widget align in layout
		CTabs(const char* label=0L,int layoutSize=10,CLayoutAlign layoutAlign=SP_ALIGN_TOP);

#ifdef __COMPATIBILITY_MODE__    
      /// @brief Constructor in FLTK style 
      /// @param x int, x-position
      /// @param y int, y-position
      /// @param w int, width
      /// @param h int, height
      /// @param label, const char* label
		CTabs(int x,int y,int w,int h,const char* label = 0);
#endif    

	   /// @brief Destructor
		~CTabs();

      /// @brief Creates a new CGroup page
      /// @param label const char*, tab and page label
      /// @param autoColor bool, auto-color assignment on/off
		virtual Fl_Group* newPage(const char* label,bool autoColor=false);

      /// @brief Creates a new CScroll page
      /// @param label const char*, tab and page label
      /// @param autoColor bool, auto-color assignment on/off
		virtual Fl_Group* newScroll(const char* label,bool autoColor=false);

      /// @brief Custom draw method
		virtual void draw();

	   /// @brief Show/hide tabs flag
	   /// 
	   /// @param show bool, if true the tabs would be visible
		void showTabs(bool show);        

      /// @brief Returns currently selected page 
		Fl_Group *page();

      /// Selects page 
		int page(Fl_Widget *page);

      /// @brief Returns tabs count
		unsigned pageCount() const;

      /// @brief Returns selected page number
		int pageNumber() const;

      /// @brief Sets selected page by number
		void pageNumber(unsigned pageNumber);

	   /// @brief Removes a page completely
		void remove(Fl_Group *page);
	};	
   /// @}
}
#endif
