/***************************************************************************
                          SIMPLY POWERFUL TOOLKIT (SPTK)
                          CColumn.h  -  description
                             -------------------
    begin                : Thu Apr 27 2000
    copyright            : (C) 2000-2005 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 __CCOLUMNS_H__
#define __CCOLUMNS_H__

#include <string>
#include <sptk3/CStrings.h>
#include <sptk3/CVariant.h>
#include <sptk3/CRegistry.h>

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

/// Class CColumn represents a column descriptor for CListView
class SP_EXPORT CColumn {
protected:
   std::string  m_name;			///< Column name
   short        m_width;		///< Column width in pixels
   CVariantType m_type;			///< Column data type
   bool         m_visible;		///< Column visibility
   bool         m_autoWidth;	///< Column auto width flag
public:

   /// Constructor
   /// @param cname std::string, column name
   /// @param type CVariantType, column data type
   /// @param cwidth short, column width
   /// @param cvisible bool, column visibility
   CColumn(std::string cname,CVariantType type,short cwidth=100,bool cvisible=true);

   /// Copy constructor
   /// @param col const CColumn&, source column object
   CColumn(const CColumn& col);

   /// Column name
   std::string name()        const { return m_name; }

   /// Column width in pixels
   short   width()           const { return m_width; }

   /// Column width in pixels
   void    width(short w)          { m_width = w; }

   /// Column visibility
   bool    visible()         const { return m_visible; }

   /// Column visibility
   void    visible(bool v)         { m_visible = v; }

   /// Column auto width flag
   bool    autoWidth()       const { return m_autoWidth; }

   /// Column auto width flag
   void    autoWidth(bool v)       { m_autoWidth = v; }

   /// Column data type
   CVariantType type()       const { return m_type; }
};

/// Class CColumnList is a list of columns used in CListView
class SP_EXPORT CColumnList : public std::vector<CColumn> {
public:

   /// Default constructor
   CColumnList() {}

   /// Finds the column index by column name 
   /// @param columnName const char *, column name
   int  indexOf(const char *columnName) const;

   /// Loads information about columns (at least, columns width)
   /// from the registry.
   /// @param registry CRegistry&, loaded registry
   /// @param topic const char *, registry topic name
   void loadFromRegistry(CRegistry& registry,const char *topic);

   /// Save information about columns (at least, columns width)
   /// from the registry.
   /// @param registry CRegistry&, loaded registry
   /// @param topic const char *, registry topic name
   void saveToRegistry(CRegistry& registry,const char *topic);
};

/// @}

#endif
