00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __MEDIA_BUTTON__
00025 #define __MEDIA_BUTTON__
00026
00027 #include <Control.h>
00028
00029 class BMessage;
00030 class BBitmap;
00031 class PeriodicMessageSender;
00032 class BitmapStash;
00033
00034
00035
00036
00037 class TransportButton : public BControl {
00038 public:
00039
00040 TransportButton(BRect frame, const char *name,
00041 const unsigned char *normalBits,
00042 const unsigned char *pressedBits,
00043 const unsigned char *disabledBits,
00044 BMessage *invokeMessage,
00045 BMessage *startPressingMessage = 0,
00046 BMessage *pressingMessage = 0,
00047 BMessage *donePressing = 0,
00048 bigtime_t period = 0,
00049 uint32 key = 0,
00050 uint32 modifiers = 0,
00051 uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP);
00052
00053 virtual ~TransportButton();
00054
00055 void SetStartPressingMessage(BMessage *);
00056 void SetPressingMessage(BMessage *);
00057 void SetDonePressingMessage(BMessage *);
00058 void SetPressingPeriod(bigtime_t);
00059
00060 virtual void SetEnabled(bool);
00061
00062 protected:
00063
00064 enum {
00065 kDisabledMask = 0x1,
00066 kPressedMask = 0x2
00067 };
00068
00069 virtual void AttachedToWindow();
00070 virtual void DetachedFromWindow();
00071 virtual void Draw(BRect);
00072 virtual void MouseDown(BPoint);
00073 virtual void MouseMoved(BPoint, uint32 code, const BMessage *);
00074 virtual void MouseUp(BPoint);
00075 virtual void WindowActivated(bool);
00076
00077 virtual BBitmap *MakeBitmap(uint32);
00078
00079
00080 virtual uint32 ModeMask() const;
00081
00082
00083 virtual const unsigned char *BitsForMask(uint32) const;
00084
00085
00086
00087 virtual void StartPressing();
00088 virtual void MouseCancelPressing();
00089 virtual void DonePressing();
00090
00091 private:
00092 void ShortcutKeyDown();
00093 void ShortcutKeyUp();
00094
00095 void MouseStartPressing();
00096 void MouseDonePressing();
00097
00098 BitmapStash *bitmaps;
00099
00100
00101
00102
00103 const unsigned char *normalBits;
00104 const unsigned char *pressedBits;
00105 const unsigned char *disabledBits;
00106
00107 BMessage *startPressingMessage;
00108 BMessage *pressingMessage;
00109 BMessage *donePressingMessage;
00110 bigtime_t pressingPeriod;
00111
00112 bool mouseDown;
00113 bool keyDown;
00114 PeriodicMessageSender *messageSender;
00115 BMessageFilter *keyPressFilter;
00116
00117 typedef BControl _inherited;
00118
00119 friend class SkipButtonKeypressFilter;
00120 friend class BitmapStash;
00121 };
00122
00123 class PlayPauseButton : public TransportButton {
00124
00125
00126 public:
00127 PlayPauseButton(BRect frame, const char *name,
00128 const unsigned char *normalBits,
00129 const unsigned char *pressedBits,
00130 const unsigned char *disabledBits,
00131 const unsigned char *normalPlayingBits,
00132 const unsigned char *pressedPlayingBits,
00133 const unsigned char *normalPausedBits,
00134 const unsigned char *pressedPausedBits,
00135 BMessage *invokeMessage,
00136 uint32 key = 0,
00137 uint32 modifiers = 0,
00138 uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP);
00139
00140
00141
00142
00143 void SetStopped();
00144 void SetPlaying();
00145 void SetPaused();
00146
00147 protected:
00148
00149 virtual uint32 ModeMask() const;
00150 virtual const unsigned char *BitsForMask(uint32) const;
00151
00152 virtual void StartPressing();
00153 virtual void MouseCancelPressing();
00154 virtual void DonePressing();
00155
00156 private:
00157 const unsigned char *normalPlayingBits;
00158 const unsigned char *pressedPlayingBits;
00159 const unsigned char *normalPausedBits;
00160 const unsigned char *pressedPausedBits;
00161
00162 enum PlayState {
00163 kStopped,
00164 kAboutToPlay,
00165 kPlaying,
00166 kAboutToPause,
00167 kPausedLedOn,
00168 kPausedLedOff
00169 };
00170
00171 enum {
00172 kPlayingMask = 0x4,
00173 kPausedMask = 0x8
00174 };
00175
00176 PlayState state;
00177 bigtime_t lastPauseBlinkTime;
00178 uint32 lastModeMask;
00179
00180 typedef TransportButton _inherited;
00181 };
00182
00183 #endif // __MEDIA_BUTTON__