]> git.sesse.net Git - vlc/blob - modules/gui/beos/ListViews.h
Removes trailing spaces. Removes tabs.
[vlc] / modules / gui / beos / ListViews.h
1 /*****************************************************************************
2  * ListViews.h: BeOS interface list view class prototype
3  *****************************************************************************
4  * Copyright (C) 1999, 2000, 2001 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Stephan Aßmus <stippi@yellowbites.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef LIST_VIEWS_H
25 #define LIST_VIEWS_H
26
27 #include <ListItem.h>
28 #include <ListView.h>
29 #include <String.h>
30
31 enum
32 {
33     DISPLAY_PATH    = 0,
34     DISPLAY_NAME,
35 };
36
37 class InterfaceWindow;
38
39 // PlaylistItem
40 class PlaylistItem : public BStringItem
41 {
42  public:
43                             PlaylistItem( const char* name );
44         virtual                ~PlaylistItem();
45
46         virtual    void        Draw( BView* owner, BRect frame,
47                                   bool tintedLine,
48                                   uint32 mode,
49                                   bool active = false,
50                                   bool playing = false );
51
52  private:
53         BString                fName;    // additional to BStringItem::Text()
54
55 };
56
57 // DragSortableListView
58 class DragSortableListView : public BListView
59 {
60  public:
61                             DragSortableListView( BRect frame,
62                                                   const char* name,
63                                                   list_view_type type
64                                                         = B_SINGLE_SELECTION_LIST,
65                                                   uint32 resizingMode
66                                                         = B_FOLLOW_LEFT
67                                                           | B_FOLLOW_TOP,
68                                                   uint32 flags
69                                                         = B_WILL_DRAW
70                                                           | B_NAVIGABLE
71                                                           | B_FRAME_EVENTS );
72     virtual                    ~DragSortableListView();
73
74                             // BListView
75     virtual    void            Draw( BRect updateRect );
76     virtual    bool            InitiateDrag( BPoint point, int32 index,
77                                           bool wasSelected );
78     virtual void            MessageReceived( BMessage* message );
79     virtual void            MouseMoved( BPoint where, uint32 transit,
80                                         const BMessage* dragMessage );
81     virtual void            MouseUp( BPoint where );
82     virtual    void            WindowActivated( bool active );
83     virtual void            DrawItem( BListItem *item, BRect itemFrame,
84                                       bool complete = false);
85
86                             // DragSortableListView
87     virtual    void            ModifiersChanged();    // called by window
88
89     virtual    void            MoveItems( BList& items, int32 toIndex );
90     virtual    void            CopyItems( BList& items, int32 toIndex );
91     virtual    void            RemoveItemList( BList& indices );
92             void            RemoveSelected(); // uses RemoveItemList()
93             int32            CountSelectedItems() const;
94
95     virtual    BListItem*        CloneItem( int32 atIndex ) const = 0;
96     virtual    void            DrawListItem( BView* owner, int32 index,
97                                           BRect itemFrame ) const = 0;
98     virtual    void            MakeDragMessage( BMessage* message ) const = 0;
99
100  private:
101             void            _SetDropAnticipationRect( BRect r );
102             void            _SetDropIndex( int32 index );
103             void            _RemoveDropAnticipationRect();
104
105     BRect                    fDropRect;
106     BMessage                fDragMessageCopy;
107
108  protected:
109     int32                    fDropIndex;
110 };
111
112 // PlaylistView
113 class PlaylistView : public DragSortableListView
114 {
115  public:
116                             PlaylistView( intf_thread_t * p_intf,
117                                           BRect frame,
118                                           InterfaceWindow* mainWindow,
119                                           BMessage* selectionChangeMessage = NULL );
120                             ~PlaylistView();
121
122                             // BListView
123     virtual    void            AttachedToWindow();
124     virtual void            MessageReceived( BMessage* message );
125     virtual void            MouseDown( BPoint where );
126     virtual    void            KeyDown( const char* bytes, int32 numBytes );
127     virtual    void            Pulse();
128     virtual    void            SelectionChanged();
129
130                             // DragSortableListView
131     virtual    void            MoveItems( BList& items, int32 toIndex );
132     virtual    void            CopyItems( BList& items, int32 toIndex );
133     virtual    void            RemoveItemList( BList& indices );
134
135     virtual    BListItem*        CloneItem( int32 atIndex ) const;
136     virtual    void            DrawListItem( BView* owner, int32 index,
137                                           BRect itemFrame ) const;
138     virtual    void            MakeDragMessage( BMessage* message ) const;
139
140                             // PlaylistView
141             void            SetCurrent( int32 index );
142             void            SetPlaying( bool playing );
143             void            RebuildList();
144
145             void            SortReverse();
146             void            SortByPath();
147             void            SortByName();
148
149             void            SetDisplayMode( uint32 mode );
150             uint32            DisplayMode() const
151                                 { return fDisplayMode; }
152
153  private:
154             BListItem*        _PlayingItem() const;
155             void            _SetPlayingIndex( BListItem* item );
156
157     intf_thread_t * p_intf;
158
159     int32                    fCurrentIndex;
160     bool                    fPlaying;
161     uint32                    fDisplayMode;
162     InterfaceWindow*        fMainWindow;
163     BMessage*                fSelectionChangeMessage;
164     PlaylistItem*            fLastClickedItem;
165 };
166
167 #endif // LIST_VIEWS_H