/////////////////////////////////////////////////////////////////////////////
// Name:        No names yet.
// Purpose:     Contrib. demo
// Author:      Aleksandras Gluchovas
// Modified by:
// Created:     2001/02/10
// RCS-ID:      
// Copyright:   (c) Aleksandras Gluchovas
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#ifndef __MATRIXG_G__
#define __MATRIXG_G__

#include "wx/sizer.h"
#include "wx/dynarray.h"

class WXDLLEXPORT MatrixItem : public wxObject
{
public:
	wxRect	  mBounds;
	wxSize	  mMinSize;
	wxRect	  mFinalBounds;
	wxWindow* mpWnd;
};

WX_DEFINE_ARRAY( MatrixItem*, MatrixItemListT );

class WXDLLEXPORT wxMatrixLayoutGuard : public wxEvtHandler
{
public:
	wxMatrixLayoutGuard( wxWindow* window, bool fitBestSize = FALSE );
	~wxMatrixLayoutGuard();

	void FitBestSize();

	// event handlers

	void OnSize( wxSizeEvent& event );


	DECLARE_CLASS( wxMatrixLayoutGuard )
	DECLARE_EVENT_TABLE()

protected:
    virtual void RecalcSizes() ;
    virtual wxSize CalcMin();

	virtual void CollectItems();
	virtual void DoSizeMatrix( bool vertical, int& minSize );
	virtual void DoRecalcSizes( wxSize& minSize );
	virtual void ApplySizes();

protected:
	wxWindow*		mpWnd;
	MatrixItemListT mItems;
	wxSize			mExtraSize;
	wxSize		    mPrefSize;
};


#endif // __MATRIX_G__