File indexing completed on 2024-04-21 15:38:30
0001 /** 0002 This file belong to the KMPlayer project, a movie player plugin for Konqueror 0003 Copyright (C) 2007 Koos Vriezen <koos.vriezen@gmail.com> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Lesser General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Lesser General Public License for more details. 0014 0015 You should have received a copy of the GNU Lesser General Public 0016 License along with this library; if not, write to the Free Software 0017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0018 **/ 0019 0020 #ifndef KMPLAYER_VIEW_AREA_H 0021 #define KMPLAYER_VIEW_AREA_H 0022 0023 #include <qwidget.h> 0024 #include <QAbstractNativeEventFilter> 0025 typedef QWidget QX11EmbedContainer; 0026 #include <QList> 0027 0028 #include "mediaobject.h" 0029 #include "surface.h" 0030 0031 class QPaintEngine; 0032 class KActionCollection; 0033 0034 namespace KMPlayer { 0035 0036 class View; 0037 class IViewer; 0038 class ViewerAreaPrivate; 0039 class VideoOutput; 0040 0041 /* 0042 * The area in which the video widget and controlpanel are laid out 0043 */ 0044 class KMPLAYER_EXPORT ViewArea : public QWidget, public QAbstractNativeEventFilter { 0045 friend class VideoOutput; 0046 Q_OBJECT 0047 public: 0048 ViewArea(QWidget* parent, View *view, bool paint_bg) KDE_NO_CDTOR_EXPORT; 0049 ~ViewArea() KDE_NO_CDTOR_EXPORT; 0050 KDE_NO_EXPORT bool isFullScreen () const { return m_fullscreen; } 0051 KDE_NO_EXPORT bool isMinimalMode () const { return m_minimal; } 0052 KDE_NO_EXPORT KActionCollection * actionCollection () const { return m_collection; } 0053 KDE_NO_EXPORT QRect topWindowRect () const { return m_topwindow_rect; } 0054 Surface *getSurface(Mrl* mrl) KDE_NO_EXPORT; 0055 void mouseMoved() KDE_NO_EXPORT; 0056 void scheduleRepaint(const IRect& rect) KDE_NO_EXPORT; 0057 ConnectionList* updaters() KDE_NO_EXPORT; 0058 void resizeEvent(QResizeEvent*) KDE_NO_EXPORT; 0059 void enableUpdaters(bool enable, unsigned int off_time) KDE_NO_EXPORT; 0060 void minimalMode (); 0061 IViewer *createVideoWidget (); 0062 void destroyVideoWidget (IViewer *widget); 0063 void setVideoWidgetVisible (bool show); 0064 signals: 0065 void fullScreenChanged (); 0066 public slots: 0067 void fullScreen() KDE_NO_EXPORT; 0068 void accelActivated() KDE_NO_EXPORT; 0069 void scale(int) KDE_NO_EXPORT; 0070 protected: 0071 void showEvent(QShowEvent*) KDE_NO_EXPORT; 0072 void keyPressEvent(QKeyEvent*) KDE_NO_EXPORT; 0073 void mouseMoveEvent(QMouseEvent*) KDE_NO_EXPORT; 0074 void mousePressEvent(QMouseEvent*) KDE_NO_EXPORT; 0075 void mouseDoubleClickEvent(QMouseEvent*) KDE_NO_EXPORT; 0076 void dragEnterEvent(QDragEnterEvent*) KDE_NO_EXPORT; 0077 void dropEvent(QDropEvent*) KDE_NO_EXPORT; 0078 void contextMenuEvent(QContextMenuEvent* e) KDE_NO_EXPORT; 0079 void paintEvent(QPaintEvent*) KDE_NO_EXPORT; 0080 void timerEvent(QTimerEvent* e) KDE_NO_EXPORT; 0081 void closeEvent(QCloseEvent* e) KDE_NO_EXPORT; 0082 bool nativeEventFilter(const QByteArray& eventType, void * message, long *result); 0083 QPaintEngine *paintEngine () const; 0084 private: 0085 void syncVisual() KDE_NO_EXPORT; 0086 void updateSurfaceBounds() KDE_NO_EXPORT; 0087 void stopTimers() KDE_NO_EXPORT; 0088 0089 ConnectionList m_updaters; 0090 ViewerAreaPrivate *d; 0091 View * m_view; 0092 KActionCollection * m_collection; 0093 SurfacePtr surface; 0094 IRect m_repaint_rect; 0095 IRect m_update_rect; 0096 QRect m_topwindow_rect; 0097 typedef QList <IViewer *> VideoWidgetList; 0098 VideoWidgetList video_widgets; 0099 int m_mouse_invisible_timer; 0100 int m_repaint_timer; 0101 int m_restore_fullscreen_timer; 0102 bool m_fullscreen; 0103 bool m_minimal; 0104 bool m_updaters_enabled; 0105 bool m_paint_background; 0106 }; 0107 0108 /* 0109 * The video widget 0110 */ 0111 class KMPLAYER_NO_EXPORT VideoOutput : public QX11EmbedContainer, public IViewer { 0112 Q_OBJECT 0113 public: 0114 VideoOutput(QWidget* parent, View* view) KDE_NO_CDTOR_EXPORT; 0115 ~VideoOutput() KDE_NO_CDTOR_EXPORT; 0116 0117 int heightForWidth(int w) const KDE_NO_EXPORT; 0118 0119 virtual WindowId windowHandle (); 0120 virtual WindowId clientHandle (); 0121 virtual WindowId ownHandle(); 0122 using QWidget::setGeometry; 0123 virtual void setGeometry (const IRect &rect); 0124 virtual void setAspect (float a); 0125 virtual float aspect () { return m_aspect; } 0126 virtual void useIndirectWidget (bool); 0127 virtual void setMonitoring(Monitor m) KDE_NO_EXPORT; 0128 virtual void map() KDE_NO_EXPORT; 0129 virtual void unmap() KDE_NO_EXPORT; 0130 0131 KDE_NO_EXPORT long inputMask () const { return m_input_mask; } 0132 void setBackgroundColor(const QColor& c) KDE_NO_EXPORT; 0133 void resetBackgroundColor() KDE_NO_EXPORT; 0134 void setCurrentBackgroundColor(const QColor& c) KDE_NO_EXPORT; 0135 KDE_NO_EXPORT View * view () const { return m_view; } 0136 0137 WindowId clientWinId() { return m_client_window; } 0138 void discardClient() {} 0139 void embedded(WindowId handle) KDE_NO_EXPORT; 0140 public slots: 0141 void fullScreenChanged() KDE_NO_EXPORT; 0142 protected: 0143 void resizeEvent(QResizeEvent*) KDE_NO_EXPORT; 0144 void timerEvent(QTimerEvent*) KDE_NO_EXPORT; 0145 void dragEnterEvent(QDragEnterEvent*) KDE_NO_EXPORT; 0146 void dropEvent(QDropEvent*) KDE_NO_EXPORT; 0147 void contextMenuEvent(QContextMenuEvent* e) KDE_NO_EXPORT; 0148 //virtual void windowChanged( WId w ); 0149 private: 0150 WId m_plain_window; 0151 WId m_client_window; 0152 int resized_timer; 0153 unsigned int m_bgcolor; 0154 float m_aspect; 0155 View * m_view; 0156 long m_input_mask; 0157 }; 0158 0159 } // namespace KMPlayer 0160 0161 #endif