Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mediawidget.h

Go to the documentation of this file.
00001 /*
00002    Copyright (C) 2002 Simon Hausmann <simon@lst.de>
00003              (C) 2002 Max Reiss <harlekin@handhelds.org>
00004              (C) 2002 L. Potter <ljp@llornkcor.com>
00005              (C) 2002 Holger Freyther <zecke@handhelds.org>
00006 
00007    This program is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program; see the file COPYING.  If not, write to
00019    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020    Boston, MA 02111-1307, USA.
00021 */
00022 
00023 #ifndef MEDIAWIDGET_H
00024 #define MEDIAWIDGET_H
00025 
00026 #include <qbitmap.h>
00027 #include <qwidget.h>
00028 #include <qmap.h>
00029 
00030 #include "mediaplayerstate.h"
00031 #include "playlistwidget.h"
00032 
00033 class Skin;
00034 
00035 class MediaWidget : public QWidget
00036 {
00037     Q_OBJECT
00038 public:
00039     enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined };
00040     enum ButtonType { NormalButton, ToggleButton };
00041 
00042     struct Button
00043     {
00044         Button() : command( Undefined ), type( NormalButton ), isDown( false ) {}
00045 
00046         Command command;
00047 
00048         ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-(
00049         bool isDown : 1;
00050 
00051         QBitmap mask;
00052         QPixmap pixUp;
00053         QPixmap pixDown;
00054     };
00055     typedef QValueList<Button> ButtonVector;
00056 
00057     struct SkinButtonInfo
00058     {
00059         Command command;
00060         const char *fileName;
00061         ButtonType type;
00062     };
00063 
00064     struct GUIInfo
00065     {
00066         GUIInfo() : buttonInfo( 0 ), buttonCount( 0 ) {}
00067         GUIInfo( const QString &_fileNameInfix, const SkinButtonInfo *_buttonInfo, const uint _buttonCount )
00068             : fileNameInfix( _fileNameInfix ), buttonInfo( _buttonInfo ), buttonCount( _buttonCount )
00069         {}
00070 
00071         QString fileNameInfix;
00072         const SkinButtonInfo *buttonInfo;
00073         const uint buttonCount;
00074     };
00075     typedef QValueList<GUIInfo> GUIInfoList;
00076 
00077     MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
00078     virtual ~MediaWidget();
00079 
00080 public slots:
00081     virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
00082     virtual void setLength( long length ) = 0;
00083     virtual void setPlaying( bool playing ) = 0;
00084 
00085     virtual void loadSkin() = 0;
00086 
00087 signals:
00088     void moreReleased();
00089     void lessReleased();
00090     void forwardReleased();
00091     void backReleased();
00092     void forwardClicked();
00093     void backClicked();
00094     void moreClicked();
00095     void lessClicked();
00096 
00097 protected:
00098     void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
00099                        const Skin &skin );
00100     Button setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin );
00101 
00102     void loadDefaultSkin( const GUIInfo &guiInfo );
00103     void loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin );
00104 
00105     virtual void closeEvent( QCloseEvent * );
00106 
00107     virtual void paintEvent( QPaintEvent *pe );
00108 
00109     virtual void resizeEvent( QResizeEvent *e );
00110 
00111     Button *buttonAt( const QPoint &position );
00112 
00113     virtual void mousePressEvent( QMouseEvent *event );
00114     virtual void mouseReleaseEvent( QMouseEvent *event );
00115 
00116     virtual void makeVisible();
00117 
00118     void handleCommand( Command command, bool buttonDown );
00119 
00120     bool isOverButton( const QPoint &position, int buttonId ) const;
00121 
00122     void paintAllButtons( QPainter &p );
00123     void paintButton( const Button &button );
00124     void paintButton( QPainter &p, const Button &button );
00125 
00126     void setToggleButton( Button &button, bool down );
00127     void setToggleButton( Command command, bool down );
00128     void toggleButton( Button &button );
00129 
00130     MediaPlayerState &mediaPlayerState;
00131     PlayListWidget &playList;
00132 
00133     ButtonVector buttons;
00134 
00135     QImage buttonMask;
00136 
00137     QPoint upperLeftOfButtonMask;
00138 
00139     QPixmap backgroundPixmap;
00140     QImage buttonUpImage;
00141     QImage buttonDownImage;
00142 
00143     static QPixmap combineImageWithBackground( const QImage &background, const QPixmap &pixmap, const QPoint &offset );
00144     static QPixmap addMaskToPixmap( const QPixmap &pix, const QBitmap &mask );
00145 };
00146 
00147 #endif // MEDIAWIDGET_H
00148 /* vim: et sw=4 ts=4
00149  */

Generated on Sat Nov 5 16:17:31 2005 for OPIE by  doxygen 1.4.2