/////////////////////////////////////////////////////////////////////////////
// Name:        No names yet.
// Purpose:     Contrib. demo
// Author:      Aleksandras Gluchovas
// Modified by:
// Created:     2000/02/08
// RCS-ID:      $id$
// Copyright:   (c) Aleksandras Gluchovas (alex@soften.ktu.lt)
// Licence:   	GPL (version 2.0 or later)
/////////////////////////////////////////////////////////////////////////////
 
#ifndef __FLTOOLBARMGR_G__
#define __FLTOOLBARMGR_G__

#include "inf_toolbarmgr.h"

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

class FLToolBarInfo;
class FLToolBarToolInfo;
class FLToolBarClientInfo;

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

WX_DEFINE_ARRAY( FLToolBarToolInfo*, FLToolBarToolInfoListT );
WX_DEFINE_ARRAY( FLToolBarInfo*, FLToolBarInfoListT );
WX_DEFINE_ARRAY( FLToolBarClientInfo*, FLToolBarClientInfoListT );

// info structures

class FLToolBarToolInfo : public wxObject
{
public:
	wxBitmap  mBmp;
	int		  mCmdId;
	bool	  mTogglable;
	wxString  mToolTip;
};

class FLToolBarInfo : public wxObject
{
public:
	FLToolBarInfo();
	~FLToolBarInfo();

public:
	int mAling;
	int mOfs;
	int mRow;
	wxString mTitle;

	FLToolBarToolInfoListT mTools;

	// initialized later
	wxWindow* mpBarWnd;
};

class FLToolBarClientInfo : public wxObject
{
public:
	FLToolBarClientInfo();
	~FLToolBarClientInfo();

public:
	wxClassInfo* mpClass;
	wxObject* mpInstance;

	FLToolBarInfoListT mBars;
};

// the manager

class wxFLToolBarManager : public wxEvtHandler, 
								 public wxPMService, 
								 public wxPMBootstrapServiceListener,

								 // implements "standard" interface
								 public wxPMInf_ToolBarManager
{
public:
	wxFLToolBarManager();
	~wxFLToolBarManager();

	// overriden methods of wxPMService

	virtual bool Start();
	virtual bool Stop();

	virtual wxPMMergableMenuChain* GetMergableMenuChain();

	virtual wxObject* GetWxObject();

	// implemented interface of wxPMInf_ToolBarManager

	virtual bool RegisterClient( wxClassInfo* pClass, wxObject* pInstance = NULL );
	virtual bool UnregisterClient( wxClassInfo* pClass, wxObject* pInstance = NULL );

	virtual bool IsRegisteredClient( wxClassInfo* pClass, wxObject* pInstance = NULL );

	virtual wxToolBarClientHandle FindClient( wxClassInfo* pClass, wxObject* pInstance = NULL );
	virtual wxToolBarClientHandle FindClient( wxObject* pInstance );

	virtual void BeginToolBar( wxToolBarClientHandle hClient, const wxString& title = "", 
							   int align = wxALIGN_TOP, int ofs = 0, int row = 0 );

	virtual void AddTool( wxToolBarClientHandle hClient, int cmdId, const wxBitmap& bmp, 
						  const wxString& toolTip = "", bool togglable = FALSE );

	virtual void EndToolBar( wxToolBarClientHandle hClient );

	virtual void UpdateUI( wxToolBarClientHandle hClient );

	// overriden notifications of wxPMBootstrapServiceListener

	virtual void OnServiceStarted( wxPMService& service );
	virtual void OnServiceStopped( wxPMService& service );

	// event handlers

	DECLARE_EVENT_TABLE()

	// all service classes are dynamic
	DECLARE_DYNAMIC_CLASS( wxFLToolBarManager )

protected:
	virtual void CreateToolbarsForClient( FLToolBarClientInfo* pClient );
	virtual void ActiveteToolbarsForClient( FLToolBarClientInfo* pClient, bool activate );
	virtual bool BarsCreated( FLToolBarClientInfo* pForClient );

protected:
	FLToolBarClientInfoListT mClients;
	wxFrameLayout* mpFl;
};

#endif // __FLTOOLBARMGR_G__