/**************************************************************************
*   Copyright (C) 2005 by Jean-Michel Petit                               *
*   jm_petit@laposte.net                                                  *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
*   This program is distributed in the hope that it will be useful,       *
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
*   GNU General Public License for more details.                          *
*                                                                         *
*   You should have received a copy of the GNU General Public License     *
*   along with this program; if not, write to the                         *
*   Free Software Foundation, Inc.,                                       *
*   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
***************************************************************************/

#ifndef KVIEWMPEG2_H
#define KVIEWMPEG2_H

#include "k9dvdtitle.h"

#include <tqthread.h>
#include <viewmpeg2.h>
#include <tqwidget.h>
#include <tqstring.h>
#include <tqevent.h>
#include <tqmutex.h>
#include <tqgl.h>
#include "k9plaympeg2.h"
#include "k9glwidget.h"
#include "k9mplayer.h"

/**
  *@author 
  */

class k9Widget : public TQWidget {
TQ_OBJECT
  
protected:
   TQImage *m_image;
   void paintEvent ( TQPaintEvent * _event);
public:
   k9Widget (TQWidget *_parent);
   void setImage(TQImage *_image);
};


class kViewMPEG2 : public ViewMPEG2  {
TQ_OBJECT
  
public: 
	kViewMPEG2();
	~kViewMPEG2();
private:
  TQMutex mutex;
  k9DVDTitle *m_title;
  TQString dev;
  int selTitle;
  unsigned long  idxLect;
  bool pause;
  bool lockSlider;
  TQImage img;
  bool stopped;
  void sliderReleased();  
  /** No descriptions */
  void sliderPressed();
  void lock();
  void unlock();
  TQString file;
  TQString errMsg;
  bool error;
  TQString length;
  uint startSector;
  uint lastSector;
  k9PlayMPEG2 m_player;
  TQGridLayout *m_layout;
  bool m_prefUseGL;
  k9GLWidget *m_GLwidget;
  k9Widget *m_widget;
protected:
 void closeEvent( TQCloseEvent* );
 void resizeEvent ( TQResizeEvent * );
public slots: // Public slots
  /** No descriptions */
  void open (k9DVD *_dvd,k9DVDTitle * title,int chapter);
  void drawPixmap( TQImage *image);
  void drawppm(uchar *_buf,int _width,int _height,int _len);
  void setError(const TQString & err);
  void setPosition(uint32_t _position);
  void setMax(uint32_t _position);
  void setMin(uint32_t _position);
  void bPlayClick();
  void bStopClick();
  void readSettings();

};

#endif
