/////////////////////////////////////////////////////////////////////////////
// Name:        No names yet.
// Purpose:     Contrib. demo
// Author:      Aleksandras Gluchovas
// Modified by:
// Created:     2000/02/08
// RCS-ID:      $Id: ui_lookeditor.h,v 1.5 2001/04/04 12:42:37 aleksandras Exp $
// Copyright:   (c) Aleksandras Gluchovas
// Licence:   	GPL (version 2.0 or later)
/////////////////////////////////////////////////////////////////////////////

#ifndef __UI_LOOKEDITOR_G__
#define __UI_LOOKEDITOR_G__

#include "wx/pmf/pm.h"

#include "XObject.h"
#include "wx/textctrl.h"

class XCollection;
class wxUILookRenderer;
class wxUILookInfo;
class wxTextEditorModel;
class wxTextEditorView;


class wxUILookDocument : public wxPMDocument
{
public:
	wxUILookDocument();
	~wxUILookDocument();

	// overriden methods of wxPMDocument
	virtual bool CanHaveFile();
	virtual bool SavePMDocument( wxOutputStream& s );
	virtual bool LoadPMDocument( wxInputStream& s );

	DECLARE_DYNAMIC_CLASS( wxUILookDocument )

	wxTextEditorModel* GetModel();
	void SetModel( wxTextEditorModel* pModel );

	// overriden methods of wxDocument

	virtual bool IsModified() const;
	virtual void Modify(bool modify);

protected:
	wxTextEditorModel* mpModel;
};

class wxUILookView : public wxPMView
{
public:
	wxUILookView();
	~wxUILookView();

	// overriden method wxView and wxPMView
	virtual bool OnCreate(wxDocument* doc, long flags);

	// overriden method of wxPMService
	virtual wxPMMergableMenuChain* GetMergableMenuChain();

	wxString GetScript();

	/*** event handlers ***/

	void OnUpdate( wxCommandEvent& event );
	void OnSaveAndUpdate( wxCommandEvent& event );
	void OnInsertImage( wxCommandEvent& event );
	void OnInsertNewItem( wxCommandEvent& event );
	void OnValidate( wxCommandEvent& event );
	void OnText( wxCommandEvent& event );
	
	// overriden method of wxDocument
//	virtual void OnUpdate(wxView* sender, wxObject* hint);

	enum EDITOR_COMMAND_IDS
	{
		ID_SCRIPT_TEXT = 100,
		ID_UPDATE,
		ID_SAVE_AND_UPDATE,
		ID_INSERT_IMAGE,
		ID_INSERT_NEW_ITEM,
		ID_VALIDATE,
	};

	DECLARE_DYNAMIC_CLASS( wxUILookView )
	DECLARE_EVENT_TABLE()

protected:
	bool DoValidate();
	bool DoUpdate();

protected:
	XCollection* mpScene;
	wxTextEditorModel* mpModel;
	wxTextEditorView*  mpScriptView;
	wxUILookRenderer* mpRenderer;
};


class wxUILookPreviewItem : public XObject
{
public:
	wxUILookPreviewItem();
	~wxUILookPreviewItem();
	// overriden methods of XObject

	virtual void Draw( wxDC& canvas );

	virtual XRect GetBounds();
	virtual void SetBounds( const XRect& bounds );
	virtual void SetBoundsNoRefresh( const XRect& bounds );

	void SetLookInfo( wxUILookInfo* pLookInfo, wxUILookRenderer* pRenderer );
	void RegenerateBitmap( wxDC& dc );

public:
	XRect				mBounds;
	wxUILookInfo*		mpLookInfo;
	wxUILookRenderer*	mpRenderer;
	wxBitmap			mCurBmp;
};

#endif // __UI_LOOKEDITOR_G__
