/////////////////////////////////////////////////////////////////////////////
// Name:        No names yet.
// Purpose:     Contrib. demo
// Author:      Aleksandras Gluchovas
// Modified by:
// Created:     2001/03/23
// RCS-ID:      $Id: helpfinder_svc.h,v 1.1 2001/04/03 20:10:27 aleksandras Exp $
// Copyright:   (c) Aleksandras Gluchovas (alex@soften.ktu.lt)
// Licence:   	GPL (version 2.0 or later)
/////////////////////////////////////////////////////////////////////////////

#ifndef __HELPFINDER_SVC_G__
#define __HELPFINDER_SVC_G__

#include "wx/pmf/pm.h"
#include "wx/list.h"
#include "wx/dynarray.h"

#include "indexing_svc.h"

class wxPMHelpFinderService : public wxPMSimpleService,
							  public I_IndexHandler
{
public:
	wxPMHelpFinderService();
	~wxPMHelpFinderService();

	enum MY_MENU_COMMANDS { 

		ID_CONFIGURE = 100,
		ID_OPTIONS,
		ID_FIND_HELP,
		ID_TOGGLE_FINDER_PANE
	};

	enum ITEM_TYPES
	{
		WX_HELP_ENTRY_ITEM = 201
	};

	// overriden methods of wxPMService

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

	virtual wxPMMergableMenuChain* GetMergableMenuChain();

	// event handlers

	void OnConfigure( wxCommandEvent& event );
	void OnOptions( wxCommandEvent& event );
	void OnFindHelp( wxCommandEvent& event );
	void OnToggleFinderPane( wxCommandEvent& event );

	// implementation of I_IndexHandler interface

	virtual const char* GetIndexHandlerName();

	virtual bool OnClearIndexItems( int indexId );
	virtual bool OnBeginBuild( int indexId );
	virtual bool OnIndexFile( const wxPMFileInfo& file, int fileId, int indexId );
	virtual bool OnEndBuild( int indexId );

	// other methods

	wxPMIndexingService* GetIndexingService();

	DECLARE_EVENT_TABLE()
	DECLARE_DYNAMIC_CLASS( wxPMHelpFinderService )
protected:

	wxPMIndexingService* mpIndexSvc;
	wxPMSimplePane* mpPane;
	char* mpTmpBuf;
	int mTmpBufLen;
};

class HelpFinderPanel : public wxPanel
{
public:
	HelpFinderPanel();

	void SetFinder( wxPMHelpFinderService* finderSvc );

	void OnInitDialog( wxInitDialogEvent& event );
	void OnSetFocus( wxFocusEvent& event );
	void OnEnter( wxCommandEvent& event );
	void OnSearch( wxCommandEvent& event );
	void OnTop( wxCommandEvent& event );
	void OnBack( wxCommandEvent& event );
	void OnForward( wxCommandEvent& event );

	bool LoadItemContent();
	void SetPageContent( const wxString& html );

	void FocusName();

	DECLARE_EVENT_TABLE()
	DECLARE_DYNAMIC_CLASS( HelpFinderPanel )

protected:
	wxPMHelpFinderService* mpFinder;
};

#endif // __HELPFINDER_SVC_G__