author | simon <simon> | 2002-12-09 22:42:29 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 22:42:29 (UTC) |
commit | 8641065755bbb1e2ff96e7fb964d4b0cd91c65b6 (patch) (unidiff) | |
tree | ecd14e4692538748ee59cba633c71024ebb7808d | |
parent | 421f5d6b87f509430836fb2c60b57f9266371121 (diff) | |
download | opie-8641065755bbb1e2ff96e7fb964d4b0cd91c65b6.zip opie-8641065755bbb1e2ff96e7fb964d4b0cd91c65b6.tar.gz opie-8641065755bbb1e2ff96e7fb964d4b0cd91c65b6.tar.bz2 |
- ok, next try for that allocator. stupid gcc2 :(
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index df03b22..a9dddf8 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -1,133 +1,144 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> |
3 | (C) 2002 Max Reiss <harlekin@handhelds.org> | 3 | (C) 2002 Max Reiss <harlekin@handhelds.org> |
4 | (C) 2002 L. Potter <ljp@llornkcor.com> | 4 | (C) 2002 L. Potter <ljp@llornkcor.com> |
5 | (C) 2002 Holger Freyther <zecke@handhelds.org> | 5 | (C) 2002 Holger Freyther <zecke@handhelds.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #ifndef MEDIAWIDGET_H | 23 | #ifndef MEDIAWIDGET_H |
24 | #define MEDIAWIDGET_H | 24 | #define MEDIAWIDGET_H |
25 | 25 | ||
26 | #include <qwidget.h> | 26 | #include <qwidget.h> |
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | 28 | ||
29 | #include "mediaplayerstate.h" | 29 | #include "mediaplayerstate.h" |
30 | #include "playlistwidget.h" | 30 | #include "playlistwidget.h" |
31 | 31 | ||
32 | #include <vector> | 32 | #include <vector> |
33 | #include <memory> | 33 | #include <memory> |
34 | 34 | ||
35 | namespace | ||
36 | { | ||
37 | struct simpleAndStupidAllocator | ||
38 | { | ||
39 | static void *allocate( size_t amount ) | ||
40 | { return ::operator new( amount ); } | ||
41 | static void deallocate( void *p, size_t ) | ||
42 | { ::operator delete( p ); } | ||
43 | }; | ||
44 | } | ||
45 | |||
35 | class MediaWidget : public QWidget | 46 | class MediaWidget : public QWidget |
36 | { | 47 | { |
37 | Q_OBJECT | 48 | Q_OBJECT |
38 | public: | 49 | public: |
39 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined }; | 50 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined }; |
40 | enum ButtonType { NormalButton, ToggleButton }; | 51 | enum ButtonType { NormalButton, ToggleButton }; |
41 | 52 | ||
42 | struct Button | 53 | struct Button |
43 | { | 54 | { |
44 | Button() : command( Undefined ), type( NormalButton ), isDown( false ) {} | 55 | Button() : command( Undefined ), type( NormalButton ), isDown( false ) {} |
45 | 56 | ||
46 | Command command; | 57 | Command command; |
47 | 58 | ||
48 | ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-( | 59 | ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-( |
49 | bool isDown : 1; | 60 | bool isDown : 1; |
50 | 61 | ||
51 | QBitmap mask; | 62 | QBitmap mask; |
52 | QPixmap pixUp; | 63 | QPixmap pixUp; |
53 | QPixmap pixDown; | 64 | QPixmap pixDown; |
54 | }; | 65 | }; |
55 | #if defined( _CC_GNU_ ) | 66 | #if defined( _CC_GNU_ ) |
56 | // use that allocator to avoid the default allocator that on gcc2 requires libstdc++ because | 67 | // use that allocator to avoid the default allocator that on gcc2 requires libstdc++ because |
57 | // in the BAD_ALLOC macro it uses std::cerr and friends :-( | 68 | // in the BAD_ALLOC macro it uses std::cerr and friends :-( |
58 | typedef std::vector<Button, std::__allocator<Button, std::__new_alloc> > ButtonVector; | 69 | typedef std::vector<Button, std::__allocator<Button, simpleAndStupidAllocator> > ButtonVector; |
59 | #else | 70 | #else |
60 | typedef std::vector<Button> ButtonVector; | 71 | typedef std::vector<Button> ButtonVector; |
61 | #endif | 72 | #endif |
62 | 73 | ||
63 | struct SkinButtonInfo | 74 | struct SkinButtonInfo |
64 | { | 75 | { |
65 | Command command; | 76 | Command command; |
66 | const char *fileName; | 77 | const char *fileName; |
67 | ButtonType type; | 78 | ButtonType type; |
68 | }; | 79 | }; |
69 | 80 | ||
70 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); | 81 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); |
71 | virtual ~MediaWidget(); | 82 | virtual ~MediaWidget(); |
72 | 83 | ||
73 | public slots: | 84 | public slots: |
74 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; | 85 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; |
75 | virtual void setLength( long length ) = 0; | 86 | virtual void setLength( long length ) = 0; |
76 | virtual void setPlaying( bool playing ) = 0; | 87 | virtual void setPlaying( bool playing ) = 0; |
77 | 88 | ||
78 | virtual void loadSkin() = 0; | 89 | virtual void loadSkin() = 0; |
79 | 90 | ||
80 | signals: | 91 | signals: |
81 | void moreReleased(); | 92 | void moreReleased(); |
82 | void lessReleased(); | 93 | void lessReleased(); |
83 | void forwardReleased(); | 94 | void forwardReleased(); |
84 | void backReleased(); | 95 | void backReleased(); |
85 | void forwardClicked(); | 96 | void forwardClicked(); |
86 | void backClicked(); | 97 | void backClicked(); |
87 | void moreClicked(); | 98 | void moreClicked(); |
88 | void lessClicked(); | 99 | void lessClicked(); |
89 | 100 | ||
90 | protected: | 101 | protected: |
91 | void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, | 102 | void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, |
92 | const QString &imagePrefix, const QSize &buttonAreaSize ); | 103 | const QString &imagePrefix, const QSize &buttonAreaSize ); |
93 | Button setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ); | 104 | Button setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ); |
94 | QBitmap setupButtonMask( const Command &command, const QString &fileName ); | 105 | QBitmap setupButtonMask( const Command &command, const QString &fileName ); |
95 | 106 | ||
96 | virtual void closeEvent( QCloseEvent * ); | 107 | virtual void closeEvent( QCloseEvent * ); |
97 | 108 | ||
98 | virtual void paintEvent( QPaintEvent *pe ); | 109 | virtual void paintEvent( QPaintEvent *pe ); |
99 | 110 | ||
100 | Button *buttonAt( const QPoint &position ); | 111 | Button *buttonAt( const QPoint &position ); |
101 | 112 | ||
102 | virtual void mousePressEvent( QMouseEvent *event ); | 113 | virtual void mousePressEvent( QMouseEvent *event ); |
103 | virtual void mouseReleaseEvent( QMouseEvent *event ); | 114 | virtual void mouseReleaseEvent( QMouseEvent *event ); |
104 | 115 | ||
105 | virtual void makeVisible(); | 116 | virtual void makeVisible(); |
106 | 117 | ||
107 | void handleCommand( Command command, bool buttonDown ); | 118 | void handleCommand( Command command, bool buttonDown ); |
108 | 119 | ||
109 | bool isOverButton( const QPoint &position, int buttonId ) const; | 120 | bool isOverButton( const QPoint &position, int buttonId ) const; |
110 | 121 | ||
111 | void paintAllButtons( QPainter &p ); | 122 | void paintAllButtons( QPainter &p ); |
112 | void paintButton( const Button &button ); | 123 | void paintButton( const Button &button ); |
113 | void paintButton( QPainter &p, const Button &button ); | 124 | void paintButton( QPainter &p, const Button &button ); |
114 | 125 | ||
115 | void setToggleButton( Button &button, bool down ); | 126 | void setToggleButton( Button &button, bool down ); |
116 | void setToggleButton( Command command, bool down ); | 127 | void setToggleButton( Command command, bool down ); |
117 | void toggleButton( Button &button ); | 128 | void toggleButton( Button &button ); |
118 | 129 | ||
119 | MediaPlayerState &mediaPlayerState; | 130 | MediaPlayerState &mediaPlayerState; |
120 | PlayListWidget &playList; | 131 | PlayListWidget &playList; |
121 | 132 | ||
122 | ButtonVector buttons; | 133 | ButtonVector buttons; |
123 | 134 | ||
124 | QImage buttonMask; | 135 | QImage buttonMask; |
125 | 136 | ||
126 | QPoint upperLeftOfButtonMask; | 137 | QPoint upperLeftOfButtonMask; |
127 | 138 | ||
128 | QPixmap backgroundPixmap; | 139 | QPixmap backgroundPixmap; |
129 | }; | 140 | }; |
130 | 141 | ||
131 | #endif // MEDIAWIDGET_H | 142 | #endif // MEDIAWIDGET_H |
132 | /* vim: et sw=4 ts=4 | 143 | /* vim: et sw=4 ts=4 |
133 | */ | 144 | */ |