/////////////////////////////////////////////////////////////////////////////
// Name:        No names yet.
// Purpose:     Contrib. demo
// Author:      Aleksandras Gluchovas
// Modified by:
// Created:     2000/02/08
// RCS-ID:      $Id: pm_flalg.h,v 1.1 2001/04/03 20:10:26 aleksandras Exp $
// Copyright:   (c) Aleksandras Gluchovas
// Licence:   	GPL (version 2.0 or later)
/////////////////////////////////////////////////////////////////////////////

#ifndef __PM_FLALG_G__
#define __PM_FLALG_G__

#include "wx/pmf/pm.h"
#include "wx/pmf/inf/layoutalg.h"

class wxFrameLayout; // in "wx/fl/controlbar.h"

class wxPMFrameLayoutPreferenceTemplate;
class wxPMFrameLayoutPreference;

WX_DEFINE_ARRAY( wxPMFrameLayoutPreferenceTemplate*, PMFrameLayoutPreferenceTemplateListT );

class wxPMFrameLayoutPreferenceTemplate : public wxObject
{
public:
	wxPMFrameLayoutPreferenceTemplate( wxClassInfo* pPaneClass,
									   wxPMFrameLayoutPreference* pPreference );
	~wxPMFrameLayoutPreferenceTemplate();

public:
	wxClassInfo* m_pPaneClass;
	wxPMFrameLayoutPreference* m_pPrefrence;
};


class wxPMFrameLayoutPreference : public wxPMLayoutPreference
{
public:
	wxPMFrameLayoutPreference();
	wxPMFrameLayoutPreference( int alignment, // FL_ALIGN_TOP, FL_ALIGN_BOTTOM, 
											  // FL_ALIGN_LEFT, FL_ALIGN_RIGHT
							   int xPos, int row, 
							   int width, int height, bool isFixed = FALSE );

	// overridden method of wxPMLayoutPreference
	virtual void Serialize( wxConfigBase& cfg, const wxString& key, bool isLoading );


	DECLARE_DYNAMIC_CLASS( wxPMFrameLayoutPreference )

protected:
	int m_Alignment;
	int m_XPos;
	int m_Row;
	int m_Width;
	int m_Height;
	bool m_IsFixed;

	friend class wxPMFLAlgorithm;
};

class wxPMFLAlgorithm : public wxEvtHandler,
						public wxPMService,
						public I_PMPaneLayoutAlgorithm, 
						public wxPMBootstrapServiceListener
							 
{
public:
	wxPMFLAlgorithm();
	~wxPMFLAlgorithm();

	// overridden methods of wxPMService
	virtual bool Start();
	virtual bool Stop();
	virtual wxObject* GetWxObject();
	virtual void* GetInterface( const char* infName, const char* version = NULL );

	// overridden notifications of wxPMBootstrapServiceListener
	virtual void OnPaneShown( wxPMPane& pane );
	virtual void OnPaneHidden( wxPMPane& pane );
	virtual void OnServiceStarted( wxPMService& service );
	virtual void OnServiceStopped( wxPMService& service );

	// overridden method of I_PMPaneLayoutAlgorithm
	virtual wxPMLayoutPreference* CreateDefaultLayoutPrefs();

	// overridden method of wxPMService
	virtual void Serialize( wxConfigBase& cfg, const wxString& key, bool isLoading );

	virtual void AddPreferenceTemplate( wxPMFrameLayoutPreferenceTemplate* pTempl );
	virtual void AddPreferenceTemplate( wxClassInfo* pClass, wxPMFrameLayoutPreference* pPref );

	// other methods

	virtual wxFrameLayout* GetFrameLayout();

	/*** event-handlers ***/

	DECLARE_DYNAMIC_CLASS( wxPMFLAlgorithm )

protected:
	void DoRelayout();

protected:
	PMPaneListT m_TopLevelPanes;
	PMPaneListT m_ActivePanes;
	PMFrameLayoutPreferenceTemplateListT m_PrefTemplates;

	bool m_RelayoutPending;
	int  m_NextWndId;

	wxFrameLayout* m_pLayout;
};


#endif // __PM_FLALG_G__