Remove HTTPD object type
[vlc.git] / modules / gui / beos / MediaControlView.h
1 /*****************************************************************************
2  * MediaControlView.h: beos interface
3  *****************************************************************************
4  * Copyright (C) 1999, 2000, 2001 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Tony Castley <tony@castley.net>
8  *          Stephan Aßmus <stippi@yellowbites.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef BEOS_MEDIA_CONTROL_VIEW_H
26 #define BEOS_MEDIA_CONTROL_VIEW_H
27
28 #include <Box.h>
29 #include <Control.h>
30
31 class BBitmap;
32 class PlayPauseButton;
33 class PositionInfoView;
34 class SeekSlider;
35 class TransportButton;
36 class VolumeSlider;
37
38 class MediaControlView : public BBox
39 {
40  public:
41                                 MediaControlView( intf_thread_t * p_intf, BRect frame );
42     virtual                        ~MediaControlView();
43
44                                 // BBox
45     virtual    void                AttachedToWindow();
46     virtual    void                FrameResized(float width, float height);
47     virtual    void                GetPreferredSize(float* width, float* height);
48     virtual    void                MessageReceived(BMessage* message);
49     virtual    void                Pulse(); // detect stopped stream
50
51                                 // MediaControlView
52             void                SetProgress( float position );
53
54             void                SetStatus(int status, int rate);
55             void                SetEnabled(bool enable);
56             void                SetAudioEnabled(bool enable);
57             uint32                GetVolume() const;
58             void                SetSkippable(bool backward,
59                                              bool forward);
60             void                SetMuted(bool mute);
61  
62  private:
63             void                _LayoutControls(BRect frame) const;
64             BRect                _MinFrame() const;
65             void                _LayoutControl(BView* view,
66                                                BRect frame,
67                                                bool resizeWidth = false,
68                                                bool resizeHeight = false) const;
69
70             intf_thread_t *     p_intf;
71
72             VolumeSlider*        fVolumeSlider;
73             SeekSlider*            fSeekSlider;
74             TransportButton*    fSkipBack;
75             TransportButton*    fSkipForward;
76             TransportButton*    fRewind;
77             TransportButton*    fForward;
78             PlayPauseButton*    fPlayPause;
79             TransportButton*    fStop;
80             TransportButton*    fMute;
81             PositionInfoView*   fPositionInfo;
82
83             int                    fCurrentRate;
84             int                    fCurrentStatus;
85             float                fBottomControlHeight;
86             BRect                fOldBounds;
87             bool                fIsEnabled;
88             
89 };
90
91 class SeekSlider : public BControl
92 {
93  public:
94                                 SeekSlider(intf_thread_t * p_intf,
95                                            BRect frame,
96                                            const char* name,
97                                            MediaControlView* owner );
98
99     virtual                        ~SeekSlider();
100
101                                 // BControl
102     virtual    void                AttachedToWindow();
103     virtual void                Draw(BRect updateRect);
104     virtual    void                MouseDown(BPoint where);
105     virtual    void                MouseMoved(BPoint where, uint32 transit,
106                                            const BMessage* dragMessage);
107     virtual    void                MouseUp(BPoint where);
108     virtual    void                ResizeToPreferred();
109
110                                 // SeekSlider
111             void                SetPosition(float position);
112
113 private:
114             int32                _ValueFor(float x) const;
115             void                _StrokeFrame(BRect frame,
116                                              rgb_color left,
117                                              rgb_color top,
118                                              rgb_color right,
119                                              rgb_color bottom);
120
121             intf_thread_t     * p_intf;
122             MediaControlView*    fOwner;    
123             bool                fTracking;
124 };
125
126 class VolumeSlider : public BControl
127 {
128  public:
129                                 VolumeSlider(BRect frame,
130                                              const char* name,
131                                              int32 minValue,
132                                              int32 maxValue,
133                                              BMessage* message = NULL,
134                                              BHandler* target = NULL);
135
136     virtual                        ~VolumeSlider();
137
138                                 // BControl
139     virtual    void                AttachedToWindow();
140     virtual    void                SetValue(int32 value);
141     virtual void                SetEnabled(bool enable);
142     virtual void                Draw(BRect updateRect);
143     virtual void                MouseDown(BPoint where);
144     virtual    void                MouseMoved(BPoint where, uint32 transit,
145                                            const BMessage* dragMessage);
146     virtual    void                MouseUp(BPoint where);
147
148                                 // VolumeSlider
149             bool                IsValid() const;
150             void                SetMuted(bool mute);
151
152  private:
153             void                _MakeBitmaps();
154             void                _DimBitmap(BBitmap* bitmap);
155             int32                _ValueFor(float xPos) const;
156
157             BBitmap*            fLeftSideBits;
158             BBitmap*            fRightSideBits;
159             BBitmap*            fKnobBits;
160             bool                fTracking;
161             bool                fMuted;
162             int32                fMinValue;
163             int32                fMaxValue;
164 };
165
166 class PositionInfoView : public BView
167 {
168  public:
169                                 PositionInfoView( BRect frame,
170                                                   const char* name,
171                                                   intf_thread_t *p_intf );
172     virtual                        ~PositionInfoView();
173
174                                 // BView
175     virtual    void                Draw( BRect updateRect );
176     virtual    void                ResizeToPreferred();
177     virtual    void                GetPreferredSize( float* width,
178                                                   float* height );
179     virtual    void                Pulse();
180
181                                 // PositionInfoView
182     enum
183     {
184         MODE_SMALL,
185         MODE_BIG,
186     };
187
188             void                SetMode( uint32 mode );
189             void                GetBigPreferredSize( float* width,
190                                                      float* height );
191
192             void                SetFile( int32 index, int32 size );
193             void                SetTitle( int32 index, int32 size );
194             void                SetChapter( int32 index, int32 size );
195             void                SetTime( int32 seconds );
196             void                SetTime( const char* string );
197  private:
198             void                _InvalidateContents( uint32 which = 0 );
199             void                _MakeString( BString& into,
200                                              int32 index,
201                                              int32 maxIndex ) const;
202 //            void                _DrawAlignedString( const char* string,
203 //                                                    BRect frame,
204 //                                                    alignment mode = B_ALIGN_LEFT );
205
206             uint32                fMode;
207             int32                fCurrentFileIndex;
208             int32                fCurrentFileSize;
209             int32                fCurrentTitleIndex;
210             int32                fCurrentTitleSize;
211             int32                fCurrentChapterIndex;
212             int32                fCurrentChapterSize;
213
214             int32                fSeconds;
215             BString                fTimeString;
216             bigtime_t            fLastPulseUpdate;
217             float                fStackedWidthCache;
218             float                fStackedHeightCache;
219             
220             intf_thread_t *     p_intf;
221             
222 };
223
224 #endif    // BEOS_MEDIA_CONTROL_VIEW_H