/****************************************************************************
** Interface to the GUI.
**
**   Created : Sun Dec 14 12:09:08 2003
**        by : Varol Okan using kate editor
** Copyright : (c) Varol Okan
**   License : GPL v 2.0
**
** This class generates the command line for dvdauthor.
** Current Version of DVDAUTHOR used is 0.67
** You can find dvdauthor under http://dvdauthor.sourceforge.net/
**
****************************************************************************/

#ifndef MENUPREVIEW_H
#define MENUPREVIEW_H

#define DRAGGED_IMAGE_NAME "draggedImage.png"

#include <qvaluelist.h>

#include "selectionobject.h"
#include "buttonpreview.h"
#include "menuobject.h"

class QIconViewItem;
class ButtonObject;
class ImageObject;
class TextObject;
class MovieObject;
class DialogButton;
class SourceFileEntry;

class MenuPreview : public ButtonPreview
{
	Q_OBJECT
	// m_iCreatreObjectStyle
	enum { TypeNone=0, FrameType, TextType, ImageType, MovieType, CollectionType };
	// m_iPointerState
	enum { StateUnknown=0, StateNormal, StateMoveSelected, StateReadyToCreate, StateCreating, StateSelecting, StateSelected };
public:
	// type of what has dropped on this MenuPreview
	enum { DroppedDontKnow=0, DroppedMovie, DroppedImage, DroppedText, DroppedImageAndText, DroppedMovieAndText, DroppedChapter, DroppedPants };
	 
	 MenuPreview ( QWidget * parent, const char * name = 0, WFlags f = 0 );
	~MenuPreview ( );
	void clear   ( Rgba * );
	void initMe  ( Rgba * );
	MenuPreview &operator = ( MenuPreview & );

	void respondSourceFiles ( QValueList<SourceFileEntry *> );
	void respondSubMenus    ( QStringList );

	bool readProjectFile    ( QDomNode    & );
	bool writeProjectFile   ( QDomElement & );
	bool createContextMenu  ( QPoint);

	void setIsSubMenu       ( bool );
	void setIsMovieMenu     ( bool );
	MenuObject *readObject  ( QDomNode &objectNode );

	void setVisibleRegion   ( bool );
	void setImageButton     ( bool );
	void createAnimationData( QString &, long );

	void          connectStdSlots ( MenuObject *, bool );
	ButtonObject *defineAsButton  ( MenuObject *, bool b=true );

	MenuObject *createFrameObject      ( bool b=true );
	MenuObject *createTextObject       ( bool b=true );
	MenuObject *createImageObject      ( bool b=true );
	MenuObject *createMovieObject      ( bool b=true );
	MenuObject *createButtonObject     ( bool b=true );
	MenuObject *createObjectCollection ( bool b=true );

public slots:
	virtual void slotAddFrameObject        ( );
	virtual void slotAddTextObject         ( );
	virtual void slotAddImageObject        ( );
	virtual void slotAddMovieObject        ( );
	virtual void slotAddCollection         ( );
	virtual void slotAddFromLibrary        ( );
	virtual void slotUpdateStructure       ( );
	virtual void slotUpdatePixmap          ( );
	virtual void slotAddOverlay            ( MenuObject   * );
	virtual void slotAddShadow             ( MenuObject   * );
	virtual void slotDefineAsButton        ( MenuObject   * );
	virtual void slotDeleteObject          ( MenuObject   * );
	virtual void slotUndoObject            ( MenuObject   * );
	virtual void slotModifyObject          ( MenuObject   * );
	virtual void slotUnbutton              ( ButtonObject * );
	virtual void slotCreateButtonDialog    ( ButtonObject * );
	virtual void slotEmitDeleteMe          ( );
	virtual void slotDeleteMenu            ( );
	virtual void slotRenameMenu            ( );
	virtual void slotCloneMenu             ( );
	virtual void slotDestroyedButtonDialog ( );
	virtual void slotEditTimeline          ( );
	virtual void slotAlignSelection        ( );
	virtual void slotConvertToPAL          ( );
	virtual void slotConvertToNTSC         ( );
	virtual void slotCut                   ( );
	virtual void slotCopy                  ( );
	virtual void slotPaste                 ( );

signals:
	void signalUpdateStructure    ( );
	void signalRequestSourceFiles ( );
	void signalRequestSubMenus    ( );
	void signalDeleteMe           ( );
	void signalEditTimeline       ( );
	void signalRenameMe           ( );
	void signalCloneMe            ( );
	void signalLibrary            ( );
	void signalConvertMe          ( bool );
	void signalDroppedSomething   ( uint );
	void signalMaskColorChanged   ( Rgba, Rgba );
	void signalCreatedMovieObject ( MovieObject  *, bool );

protected:
	virtual void mousePressEvent	   ( QMouseEvent * );
	virtual void mouseReleaseEvent	   ( QMouseEvent * );
	virtual void mouseDoubleClickEvent ( QMouseEvent * );
	virtual void mouseMoveEvent 	   ( QMouseEvent * );

	// Drag'n drop stuff
	virtual void dropEvent      ( QDropEvent      * );
	virtual void dragEnterEvent ( QDragEnterEvent * );

	QString &newButtonName ( );

private:	// Private functions ...
	MenuObject *insertDraggedObject     ( QDropEvent *, QImage  & );
	MenuObject *insertDraggedImage      ( QDropEvent *, QImage  &, bool b=true );
	MenuObject *insertDraggedMovie      ( QDropEvent *, QImage  &, long i=0, bool b=true );
	MenuObject *insertDraggedThumbnail  ( QDropEvent *, QImage  & );
	MenuObject *insertDraggedChapter    ( QDropEvent *, QIconViewItem * );
	void        insertDraggedChapters   ( QDropEvent *, QValueList<QIconViewItem *> & );
	MenuObject *insertDraggedText       ( QDropEvent *, QString &, bool b=true );
	MenuObject *insertDraggedSourceInfo ( QDropEvent *, QImage  & );// ButtonObject
	MenuObject *insertDraggedSourceEntry( QDropEvent *, QImage  & );// FullScale Layouts and new menus and all the bells and whistles (In future release anyhow ...SORRY)
	QString     getMovieFileName        ( MovieObject*, QStringList & );
	void        checkSelection          ( );
	QString     uniqueObjectName        ( QString, QString );
	void        paste                   ( MenuObject * );
	bool        isAnimationData         ( QString & );

private:
	QPixmap m_doubleBuffer;
	int     m_iCreateObjectStyle;  // What object, text, image, frame, or movie ?
	int     m_iPointerState;
	bool    m_bImageButton;        // Should we create ImageButton objects or MovieButtons when dropping ?
	QRect   m_rectCurrentObject;
	bool    m_bIsSubMenu;
	bool    m_bIsMovieMenu;
	Rgba   *m_pPgcColors;
	DialogButton   *m_pDialogButton;
	SelectionObject m_selectionObject;
};

#endif // MENUPREVIEW_H
