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 LIST_VIEWS_H
00025 #define LIST_VIEWS_H
00026
00027 #include <ListItem.h>
00028 #include <ListView.h>
00029 #include <String.h>
00030
00031 enum
00032 {
00033 DISPLAY_PATH = 0,
00034 DISPLAY_NAME,
00035 };
00036
00037 class InterfaceWindow;
00038
00039
00040 class PlaylistItem : public BStringItem
00041 {
00042 public:
00043 PlaylistItem( const char* name );
00044 virtual ~PlaylistItem();
00045
00046 virtual void Draw( BView* owner, BRect frame,
00047 bool tintedLine,
00048 uint32 mode,
00049 bool active = false,
00050 bool playing = false );
00051
00052 private:
00053 BString fName;
00054
00055 };
00056
00057
00058 class DragSortableListView : public BListView
00059 {
00060 public:
00061 DragSortableListView( BRect frame,
00062 const char* name,
00063 list_view_type type
00064 = B_SINGLE_SELECTION_LIST,
00065 uint32 resizingMode
00066 = B_FOLLOW_LEFT
00067 | B_FOLLOW_TOP,
00068 uint32 flags
00069 = B_WILL_DRAW
00070 | B_NAVIGABLE
00071 | B_FRAME_EVENTS );
00072 virtual ~DragSortableListView();
00073
00074
00075 virtual void Draw( BRect updateRect );
00076 virtual bool InitiateDrag( BPoint point, int32 index,
00077 bool wasSelected );
00078 virtual void MessageReceived( BMessage* message );
00079 virtual void MouseMoved( BPoint where, uint32 transit,
00080 const BMessage* dragMessage );
00081 virtual void MouseUp( BPoint where );
00082 virtual void WindowActivated( bool active );
00083 virtual void DrawItem( BListItem *item, BRect itemFrame,
00084 bool complete = false);
00085
00086
00087 virtual void ModifiersChanged();
00088
00089 virtual void MoveItems( BList& items, int32 toIndex );
00090 virtual void CopyItems( BList& items, int32 toIndex );
00091 virtual void RemoveItemList( BList& indices );
00092 void RemoveSelected();
00093 int32 CountSelectedItems() const;
00094
00095 virtual BListItem* CloneItem( int32 atIndex ) const = 0;
00096 virtual void DrawListItem( BView* owner, int32 index,
00097 BRect itemFrame ) const = 0;
00098 virtual void MakeDragMessage( BMessage* message ) const = 0;
00099
00100 private:
00101 void _SetDropAnticipationRect( BRect r );
00102 void _SetDropIndex( int32 index );
00103 void _RemoveDropAnticipationRect();
00104
00105 BRect fDropRect;
00106 BMessage fDragMessageCopy;
00107
00108 protected:
00109 int32 fDropIndex;
00110 };
00111
00112
00113 class PlaylistView : public DragSortableListView
00114 {
00115 public:
00116 PlaylistView( intf_thread_t * p_intf,
00117 BRect frame,
00118 InterfaceWindow* mainWindow,
00119 BMessage* selectionChangeMessage = NULL );
00120 ~PlaylistView();
00121
00122
00123 virtual void AttachedToWindow();
00124 virtual void MessageReceived( BMessage* message );
00125 virtual void MouseDown( BPoint where );
00126 virtual void KeyDown( const char* bytes, int32 numBytes );
00127 virtual void Pulse();
00128 virtual void SelectionChanged();
00129
00130
00131 virtual void MoveItems( BList& items, int32 toIndex );
00132 virtual void CopyItems( BList& items, int32 toIndex );
00133 virtual void RemoveItemList( BList& indices );
00134
00135 virtual BListItem* CloneItem( int32 atIndex ) const;
00136 virtual void DrawListItem( BView* owner, int32 index,
00137 BRect itemFrame ) const;
00138 virtual void MakeDragMessage( BMessage* message ) const;
00139
00140
00141 void SetCurrent( int32 index );
00142 void SetPlaying( bool playing );
00143 void RebuildList();
00144
00145 void SortReverse();
00146 void SortByPath();
00147 void SortByName();
00148
00149 void SetDisplayMode( uint32 mode );
00150 uint32 DisplayMode() const
00151 { return fDisplayMode; }
00152
00153 private:
00154 BListItem* _PlayingItem() const;
00155 void _SetPlayingIndex( BListItem* item );
00156
00157 intf_thread_t * p_intf;
00158
00159 int32 fCurrentIndex;
00160 bool fPlaying;
00161 uint32 fDisplayMode;
00162 InterfaceWindow* fMainWindow;
00163 BMessage* fSelectionChangeMessage;
00164 PlaylistItem* fLastClickedItem;
00165 };
00166
00167 #endif // LIST_VIEWS_H