/***************************************************************************
                          SIMPLY POWERFUL TOOLKIT (SPTK)
                          CExcelColumn.h  -  description
                             -------------------
    begin                : 19 March 2004
    copyright            : (C) 2004 by Alexey 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 __CEXCELCOLUMN_H__
#define __CEXCELCOLUMN_H__

#include <sptk3/excel/CExcelRecord.h>
#include <sptk3/excel/CExcelRecordsBuffer.h>
#include <vector>

namespace sptk {

   /// @addtogroup excel Excel Classes
   /// @{

   /// @brief Excel COLINFO record (a column information record)
   ///
   /// The current approach is to have one record per column
	class CExcelColumn : public CExcelRecord {
		friend class CExcelColumns;
	protected:
	public:
      /// Default constructor
		CExcelColumn(unsigned columnIndex=0); 

      /// Returns column index
		unsigned index() const;

      /// Returns column width in characters of the default font
		unsigned width() const;

      /// Sets the column width 
      /// @param w unsigned, the column width in characters of the default font 
		void width(unsigned w);
	};

   /// A set of CExcelColumn in memory
	class CExcelColumns : public std::vector<CExcelColumn *> {
	public:
      /// Default constructor
		CExcelColumns() {}

      /// Destructor
		~CExcelColumns() { clear(); }

      /// Cleaner
		void clear();

      /// Resizes the column set
      /// @param newSize unsigned, new number of columns
		void resize(unsigned newSize);

      /// Saves columns information into Excel records
      /// @param records CExcelRecordsBuffer&, Excel records
		void saveRecords(CExcelRecordsBuffer& records);
	};
   /// @}
}
#endif
