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

midi

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  * ListViews.h: BeOS interface list view class prototype
  3.  *****************************************************************************
  4.  * Copyright (C) 1999, 2000, 2001 the VideoLAN team
  5.  * $Id: 30728db826489f6064d2d724062ac709ba0cb0f3 $
  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. #ifndef LIST_VIEWS_H
  24. #define LIST_VIEWS_H
  25. #include <ListItem.h>
  26. #include <ListView.h>
  27. #include <String.h>
  28. enum
  29. {
  30.     DISPLAY_PATH    = 0,
  31.     DISPLAY_NAME,
  32. };
  33. class InterfaceWindow;
  34. // PlaylistItem
  35. class PlaylistItem : public BStringItem
  36. {
  37.  public:
  38.                             PlaylistItem( const char* name );
  39.         virtual                ~PlaylistItem();
  40.         virtual    void        Draw( BView* owner, BRect frame,
  41.                                   bool tintedLine,
  42.                                   uint32 mode,
  43.                                   bool active = false,
  44.                                   bool playing = false );
  45.  private:
  46.         BString                fName;    // additional to BStringItem::Text()
  47. };
  48. // DragSortableListView
  49. class DragSortableListView : public BListView
  50. {
  51.  public:
  52.                             DragSortableListView( BRect frame,
  53.                                                   const char* name,
  54.                                                   list_view_type type
  55.                                                         = B_SINGLE_SELECTION_LIST,
  56.                                                   uint32 resizingMode
  57.                                                         = B_FOLLOW_LEFT
  58.                                                           | B_FOLLOW_TOP,
  59.                                                   uint32 flags
  60.                                                         = B_WILL_DRAW
  61.                                                           | B_NAVIGABLE
  62.                                                           | B_FRAME_EVENTS );
  63.     virtual                    ~DragSortableListView();
  64.                             // BListView
  65.     virtual    void            Draw( BRect updateRect );
  66.     virtual    bool            InitiateDrag( BPoint point, int32 index,
  67.                                           bool wasSelected );
  68.     virtual void            MessageReceived( BMessage* message );
  69.     virtual void            MouseMoved( BPoint where, uint32 transit,
  70.                                         const BMessage* dragMessage );
  71.     virtual void            MouseUp( BPoint where );
  72.     virtual    void            WindowActivated( bool active );
  73.     virtual void            DrawItem( BListItem *item, BRect itemFrame,
  74.                                       bool complete = false);
  75.                             // DragSortableListView
  76.     virtual    void            ModifiersChanged();    // called by window
  77.     virtual    void            MoveItems( BList& items, int32 toIndex );
  78.     virtual    void            CopyItems( BList& items, int32 toIndex );
  79.     virtual    void            RemoveItemList( BList& indices );
  80.             void            RemoveSelected(); // uses RemoveItemList()
  81.             int32            CountSelectedItems() const;
  82.     virtual    BListItem*        CloneItem( int32 atIndex ) const = 0;
  83.     virtual    void            DrawListItem( BView* owner, int32 index,
  84.                                           BRect itemFrame ) const = 0;
  85.     virtual    void            MakeDragMessage( BMessage* message ) const = 0;
  86.  private:
  87.             void            _SetDropAnticipationRect( BRect r );
  88.             void            _SetDropIndex( int32 index );
  89.             void            _RemoveDropAnticipationRect();
  90.     BRect                    fDropRect;
  91.     BMessage                fDragMessageCopy;
  92.  protected:
  93.     int32                    fDropIndex;
  94. };
  95. // PlaylistView
  96. class PlaylistView : public DragSortableListView
  97. {
  98.  public:
  99.                             PlaylistView( intf_thread_t * p_intf,
  100.                                           BRect frame,
  101.                                           InterfaceWindow* mainWindow,
  102.                                           BMessage* selectionChangeMessage = NULL );
  103.                             ~PlaylistView();
  104.                             // BListView
  105.     virtual    void            AttachedToWindow();
  106.     virtual void            MessageReceived( BMessage* message );
  107.     virtual void            MouseDown( BPoint where );
  108.     virtual    void            KeyDown( const char* bytes, int32 numBytes );
  109.     virtual    void            Pulse();
  110.     virtual    void            SelectionChanged();
  111.                             // DragSortableListView
  112.     virtual    void            MoveItems( BList& items, int32 toIndex );
  113.     virtual    void            CopyItems( BList& items, int32 toIndex );
  114.     virtual    void            RemoveItemList( BList& indices );
  115.     virtual    BListItem*        CloneItem( int32 atIndex ) const;
  116.     virtual    void            DrawListItem( BView* owner, int32 index,
  117.                                           BRect itemFrame ) const;
  118.     virtual    void            MakeDragMessage( BMessage* message ) const;
  119.                             // PlaylistView
  120.             void            SetCurrent( int32 index );
  121.             void            SetPlaying( bool playing );
  122.             void            RebuildList();
  123.             void            SortReverse();
  124.             void            SortByPath();
  125.             void            SortByName();
  126.             void            SetDisplayMode( uint32 mode );
  127.             uint32            DisplayMode() const
  128.                                 { return fDisplayMode; }
  129.  private:
  130.             BListItem*        _PlayingItem() const;
  131.             void            _SetPlayingIndex( BListItem* item );
  132.     intf_thread_t * p_intf;
  133.     int32                    fCurrentIndex;
  134.     bool                    fPlaying;
  135.     uint32                    fDisplayMode;
  136.     InterfaceWindow*        fMainWindow;
  137.     BMessage*                fSelectionChangeMessage;
  138.     PlaylistItem*            fLastClickedItem;
  139. };
  140. #endif // LIST_VIEWS_H