/***************************************************************************
                          SIMPLY POWERFUL TOOLKIT (SPTK)
                          clayoutclient.h  -  description
                             -------------------
    begin                : Wed May 14 2003
    copyright            : (C) 2003 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 __CLAYOUTCLIENT_H__
#define __CLAYOUTCLIENT_H__

namespace sptk {

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

   /// Possible values for the widget layout aligns
	enum CLayoutAlign {
		SP_ALIGN_NONE,        /// Do not use allignment
		SP_ALIGN_LEFT,        /// Align to the left
		SP_ALIGN_RIGHT,       /// Align to the right
		SP_ALIGN_TOP,         /// Align to the top
		SP_ALIGN_BOTTOM,      /// Align to the bottom
		SP_ALIGN_CLIENT       /// Use the whole available space
	};

   /// @brief Base layout manager client.
   ///
   /// Allows CLayoutManager objects to move and resize
   /// the CLayoutClient objects in accordancy with they preferredSize() and
   /// layout alignment.
	class CLayoutClient {
	protected:
		/// The preferred layout size
		///
		/// It makes different sense depending on the widget layout align.
		/// For layout align SP_ALIGN_TOP or SP_ALIGN_BOTTOM it is a recomended height of the widget.
		/// For layout align SP_ALIGN_LEFT or SP_ALIGN_RIGHT it is a recomended width of the widget.
		/// For layout align SP_ALIGN_NONE or SP_ALIGN_CLIENT it is ignored.
		/// If the widget isn't in CLayoutManager group - it is ignored.
		/// If it doesn't contradict with preferred widget size it will define the final size of the widget.
		int          m_layoutSize;

		/// The layout align for the widget in CLayoutManager group 
		CLayoutAlign m_layoutAlign;
	public:
      /// Constructor
      /// @param layoutSize int, the size of the widget in layout. See m_layoutSize for more information.
      /// @param ca CLayoutAlign, widget align in layout 
		CLayoutClient(int layoutSize,CLayoutAlign ca) { m_layoutSize = layoutSize; m_layoutAlign = ca; }

      /// Destructor
		virtual ~CLayoutClient() {}

      /// Returns widget's layout align
      /// @see CLayoutAlign
		CLayoutAlign layoutAlign() const  { return m_layoutAlign; }

      /// Sets widget's layout align
      /// @see CLayoutAlign
		void layoutAlign(CLayoutAlign al) { m_layoutAlign = al; }

      /// Returns widget's layout size
		int  layoutSize() const { return m_layoutSize; }

      /// Sets widget's layout size
		void layoutSize(int ls) { m_layoutSize = ls;   }

      /// Computes widget's preferred size.
      /// Should be overriten in derived widget if it has any ideas about it's size limits.
      /// Widget may want to change none, one, or both preferred width and height suggested by the
      /// CLayoutManager.
      /// @param w int&, input/output widget preferred width
      /// @param h int&, input/output widget preferred height
		virtual void preferredSize(int& w,int& h) {};
	};
	/// @}
}

#endif
