MediaControlView.h
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:9k
源码类别:

midi

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  * MediaControlView.h: beos interface
  3.  *****************************************************************************
  4.  * Copyright (C) 1999, 2000, 2001 the VideoLAN team
  5.  * $Id: 27c416178534cca1c92fa19cd2e22f1b14163ca2 $
  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. #ifndef BEOS_MEDIA_CONTROL_VIEW_H
  25. #define BEOS_MEDIA_CONTROL_VIEW_H
  26. #include <Box.h>
  27. #include <Control.h>
  28. class BBitmap;
  29. class PlayPauseButton;
  30. class PositionInfoView;
  31. class SeekSlider;
  32. class TransportButton;
  33. class VolumeSlider;
  34. class MediaControlView : public BBox
  35. {
  36.  public:
  37.                                 MediaControlView( intf_thread_t * p_intf, BRect frame );
  38.     virtual                        ~MediaControlView();
  39.                                 // BBox
  40.     virtual    void                AttachedToWindow();
  41.     virtual    void                FrameResized(float width, float height);
  42.     virtual    void                GetPreferredSize(float* width, float* height);
  43.     virtual    void                MessageReceived(BMessage* message);
  44.     virtual    void                Pulse(); // detect stopped stream
  45.                                 // MediaControlView
  46.             void                SetProgress( float position );
  47.             void                SetStatus(int status, int rate);
  48.             void                SetEnabled(bool enable);
  49.             void                SetAudioEnabled(bool enable);
  50.             uint32                GetVolume() const;
  51.             void                SetSkippable(bool backward,
  52.                                              bool forward);
  53.             void                SetMuted(bool mute);
  54.  
  55.  private:
  56.             void                _LayoutControls(BRect frame) const;
  57.             BRect                _MinFrame() const;
  58.             void                _LayoutControl(BView* view,
  59.                                                BRect frame,
  60.                                                bool resizeWidth = false,
  61.                                                bool resizeHeight = false) const;
  62.             intf_thread_t *     p_intf;
  63.             VolumeSlider*        fVolumeSlider;
  64.             SeekSlider*            fSeekSlider;
  65.             TransportButton*    fSkipBack;
  66.             TransportButton*    fSkipForward;
  67.             TransportButton*    fRewind;
  68.             TransportButton*    fForward;
  69.             PlayPauseButton*    fPlayPause;
  70.             TransportButton*    fStop;
  71.             TransportButton*    fMute;
  72.             PositionInfoView*   fPositionInfo;
  73.             int                    fCurrentRate;
  74.             int                    fCurrentStatus;
  75.             float                fBottomControlHeight;
  76.             BRect                fOldBounds;
  77.             bool                fIsEnabled;
  78.             
  79. };
  80. class SeekSlider : public BControl
  81. {
  82.  public:
  83.                                 SeekSlider(intf_thread_t * p_intf,
  84.                                            BRect frame,
  85.                                            const char* name,
  86.                                            MediaControlView* owner );
  87.     virtual                        ~SeekSlider();
  88.                                 // BControl
  89.     virtual    void                AttachedToWindow();
  90.     virtual void                Draw(BRect updateRect);
  91.     virtual    void                MouseDown(BPoint where);
  92.     virtual    void                MouseMoved(BPoint where, uint32 transit,
  93.                                            const BMessage* dragMessage);
  94.     virtual    void                MouseUp(BPoint where);
  95.     virtual    void                ResizeToPreferred();
  96.                                 // SeekSlider
  97.             void                SetPosition(float position);
  98. private:
  99.             int32                _ValueFor(float x) const;
  100.             void                _StrokeFrame(BRect frame,
  101.                                              rgb_color left,
  102.                                              rgb_color top,
  103.                                              rgb_color right,
  104.                                              rgb_color bottom);
  105.             intf_thread_t     * p_intf;
  106.             MediaControlView*    fOwner;    
  107.             bool                fTracking;
  108. };
  109. class VolumeSlider : public BControl
  110. {
  111.  public:
  112.                                 VolumeSlider(BRect frame,
  113.                                              const char* name,
  114.                                              int32 minValue,
  115.                                              int32 maxValue,
  116.                                              BMessage* message = NULL,
  117.                                              BHandler* target = NULL);
  118.     virtual                        ~VolumeSlider();
  119.                                 // BControl
  120.     virtual    void                AttachedToWindow();
  121.     virtual    void                SetValue(int32 value);
  122.     virtual void                SetEnabled(bool enable);
  123.     virtual void                Draw(BRect updateRect);
  124.     virtual void                MouseDown(BPoint where);
  125.     virtual    void                MouseMoved(BPoint where, uint32 transit,
  126.                                            const BMessage* dragMessage);
  127.     virtual    void                MouseUp(BPoint where);
  128.                                 // VolumeSlider
  129.             bool                IsValid() const;
  130.             void                SetMuted(bool mute);
  131.  private:
  132.             void                _MakeBitmaps();
  133.             void                _DimBitmap(BBitmap* bitmap);
  134.             int32                _ValueFor(float xPos) const;
  135.             BBitmap*            fLeftSideBits;
  136.             BBitmap*            fRightSideBits;
  137.             BBitmap*            fKnobBits;
  138.             bool                fTracking;
  139.             bool                fMuted;
  140.             int32                fMinValue;
  141.             int32                fMaxValue;
  142. };
  143. class PositionInfoView : public BView
  144. {
  145.  public:
  146.                                 PositionInfoView( BRect frame,
  147.                                                   const char* name,
  148.                                                   intf_thread_t *p_intf );
  149.     virtual                        ~PositionInfoView();
  150.                                 // BView
  151.     virtual    void                Draw( BRect updateRect );
  152.     virtual    void                ResizeToPreferred();
  153.     virtual    void                GetPreferredSize( float* width,
  154.                                                   float* height );
  155.     virtual    void                Pulse();
  156.                                 // PositionInfoView
  157.     enum
  158.     {
  159.         MODE_SMALL,
  160.         MODE_BIG,
  161.     };
  162.             void                SetMode( uint32 mode );
  163.             void                GetBigPreferredSize( float* width,
  164.                                                      float* height );
  165.             void                SetFile( int32 index, int32 size );
  166.             void                SetTitle( int32 index, int32 size );
  167.             void                SetChapter( int32 index, int32 size );
  168.             void                SetTime( int32 seconds );
  169.             void                SetTime( const char* string );
  170.  private:
  171.             void                _InvalidateContents( uint32 which = 0 );
  172.             void                _MakeString( BString& into,
  173.                                              int32 index,
  174.                                              int32 maxIndex ) const;
  175. //            void                _DrawAlignedString( const char* string,
  176. //                                                    BRect frame,
  177. //                                                    alignment mode = B_ALIGN_LEFT );
  178.             uint32                fMode;
  179.             int32                fCurrentFileIndex;
  180.             int32                fCurrentFileSize;
  181.             int32                fCurrentTitleIndex;
  182.             int32                fCurrentTitleSize;
  183.             int32                fCurrentChapterIndex;
  184.             int32                fCurrentChapterSize;
  185.             int32                fSeconds;
  186.             BString                fTimeString;
  187.             bigtime_t            fLastPulseUpdate;
  188.             float                fStackedWidthCache;
  189.             float                fStackedHeightCache;
  190.             
  191.             intf_thread_t *     p_intf;
  192.             
  193. };
  194. #endif    // BEOS_MEDIA_CONTROL_VIEW_H