1
// -------------------------------------------------------------------------------- //
2
// Copyright (C) 2008-2010 J.Rios
5
// This Program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2, or (at your option)
10
// This Program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; see the file LICENSE. If not, write to
17
// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
// http://www.gnu.org/copyleft/gpl.html
20
// -------------------------------------------------------------------------------- //
21
#include "RaListBox.h"
25
#include "OnlineLinks.h"
26
#include "RatingCtrl.h"
31
// -------------------------------------------------------------------------------- //
32
guRaListBox::guRaListBox( wxWindow * parent, guLibPanel * libpanel, guDbLibrary * db, const wxString &label ) :
33
guListBox( parent, db, label, wxLB_MULTIPLE | guLISTVIEW_ALLOWDRAG | guLISTVIEW_HIDE_HEADER )
35
m_LibPanel = libpanel;
37
m_NormalStar = new wxBitmap( guImage( ( guIMAGE_INDEX ) ( guIMAGE_INDEX_star_normal_tiny + GURATING_STYLE_MID ) ) );
38
m_SelectStar = new wxBitmap( guImage( ( guIMAGE_INDEX ) ( guIMAGE_INDEX_star_highlight_tiny + GURATING_STYLE_MID ) ) );
43
// -------------------------------------------------------------------------------- //
44
guRaListBox::~guRaListBox()
52
// -------------------------------------------------------------------------------- //
53
void guRaListBox::GetItemsList( void )
55
m_Db->GetRatings( m_Items );
58
// -------------------------------------------------------------------------------- //
59
int guRaListBox::GetSelectedSongs( guTrackArray * songs ) const
61
wxArrayInt Items = GetSelectedItems();
63
int Count = Items.Count();
64
for( Index = 0; Index < Count; Index++ )
69
Count = m_Db->GetRatingsSongs( Items, songs );
70
m_LibPanel->NormalizeTracks( songs );
74
// -------------------------------------------------------------------------------- //
75
void guRaListBox::DrawItem( wxDC &dc, const wxRect &rect, const int row, const int col ) const
79
guListBox::DrawItem( dc, rect, row, col );
83
int Rating = GetItemId( row ) - 1;
85
dc.SetBackgroundMode( wxTRANSPARENT );
87
int w = ( ( GURATING_STYLE_MID * 2 ) + GURATING_IMAGE_SIZE );
89
for( x = 0; x < 5; x++ )
91
dc.DrawBitmap( ( x >= Rating ) ? * m_NormalStar : * m_SelectStar,
92
rect.x + 3 + ( w * x ), rect.y + 3, true );
97
// -------------------------------------------------------------------------------- //
98
void guRaListBox::CreateContextMenu( wxMenu * Menu ) const
100
wxMenuItem * MenuItem;
102
int SelCount = GetSelectedCount();
103
int ContextMenuFlags = m_LibPanel->GetContextMenuFlags();
105
MenuItem = new wxMenuItem( Menu, ID_RATING_PLAY, _( "Play" ), _( "Play the selected tracks" ) );
106
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_player_tiny_light_play ) );
107
Menu->Append( MenuItem );
109
MenuItem = new wxMenuItem( Menu, ID_RATING_ENQUEUE, _( "Enqueue" ), _( "Add current selected tracks to playlist" ) );
110
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
111
Menu->Append( MenuItem );
113
MenuItem = new wxMenuItem( Menu, ID_RATING_ENQUEUE_ASNEXT, _( "Enqueue Next" ), _( "Add current selected tracks to playlist as Next Tracks" ) );
114
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_add ) );
115
Menu->Append( MenuItem );
119
if( ContextMenuFlags & guLIBRARY_CONTEXTMENU_EDIT_TRACKS )
121
Menu->AppendSeparator();
123
MenuItem = new wxMenuItem( Menu, ID_RATING_EDITTRACKS, _( "Edit Songs" ), _( "Edit the selected tracks" ) );
124
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_tiny_edit ) );
125
Menu->Append( MenuItem );
128
Menu->AppendSeparator();
130
MenuItem = new wxMenuItem( Menu, ID_RATING_SAVETOPLAYLIST, _( "Save to PlayList" ), _( "Save the selected tracks to PlayList" ) );
131
MenuItem->SetBitmap( guImage( guIMAGE_INDEX_doc_save ) );
132
Menu->Append( MenuItem );
134
if( ContextMenuFlags & guLIBRARY_CONTEXTMENU_COPY_TO )
136
m_LibPanel->CreateCopyToMenu( Menu, ID_RATING_COPYTO );
139
m_LibPanel->CreateContextMenu( Menu );
142
// -------------------------------------------------------------------------------- //
143
wxString guRaListBox::GetSearchText( int item ) const
145
return GetItemName( item );
148
// -------------------------------------------------------------------------------- //
149
int guRaListBox::GetDragFiles( wxFileDataObject * files )
153
int count = GetSelectedSongs( &Songs );
154
m_LibPanel->NormalizeTracks( &Songs, true );
155
for( index = 0; index < count; index++ )
157
wxString FileName = guFileDnDEncode( Songs[ index ].m_FileName );
158
//FileName.Replace( wxT( "#" ), wxT( "%23" ) );
159
//FileName.Replace( wxT( "%" ), wxT( "%25" ) );
160
//guLogMessage( wxT( "Adding song '%s'" ), Songs[ index ].m_FileName.c_str() );
161
files->AddFile( FileName );
166
// -------------------------------------------------------------------------------- //