Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

ListViews.h

00001 /*****************************************************************************
00002  * ListViews.h: BeOS interface list view class prototype
00003  *****************************************************************************
00004  * Copyright (C) 1999, 2000, 2001 the VideoLAN team
00005  * $Id: ListViews.h 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Stephan Aßmus <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
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 // PlaylistItem
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;  // additional to BStringItem::Text()
00054 
00055 };
00056 
00057 // DragSortableListView
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                                                         // BListView
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                                                         // DragSortableListView
00087         virtual void                    ModifiersChanged();     // called by window
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(); // uses RemoveItemList()
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 // PlaylistView
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                                                         // BListView
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                                                         // DragSortableListView
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                                                         // PlaylistView
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

Generated on Tue Dec 20 10:14:37 2005 for vlc-0.8.4a by  doxygen 1.4.2