~ubuntu-branches/ubuntu/precise/guayadeque/precise

« back to all changes in this revision

Viewing changes to src/.svn/text-base/RaListBox.cpp.svn-base

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2011-05-14 15:08:03 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110514150803-8b5evqetnaj35j34
Tags: 0.3.1~dfsg0-1
* New upstream release.
* Strip wxsqlite3 stuff out of upstream's tarballs.
* Update get-orig-source target in debian/rules.
* Update gbp config file.
* Bump Standards.
* Build-depend on libwxsqlite3-2.8-dev
* Enable parallel builds.
* Link binaries against the system-wide copy of wxsqlite3.
* Point sources to the correct wxcurl's headers location.
* Update copyright file as per DEP-5
* Improve debian/watch to handle the ~dfsg\d* suffix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -------------------------------------------------------------------------------- //
2
 
//      Copyright (C) 2008-2010 J.Rios
3
 
//      anonbeat@gmail.com
4
 
//
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)
8
 
//    any later version.
9
 
//
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.
14
 
//
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
19
 
//
20
 
// -------------------------------------------------------------------------------- //
21
 
#include "RaListBox.h"
22
 
#include "Commands.h"
23
 
#include "Config.h"
24
 
#include "Images.h"
25
 
#include "OnlineLinks.h"
26
 
#include "RatingCtrl.h"
27
 
#include "MainApp.h"
28
 
#include "Utils.h"
29
 
#include "LibPanel.h"
30
 
 
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 )
34
 
{
35
 
    m_LibPanel = libpanel;
36
 
 
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 ) ) );
39
 
 
40
 
    ReloadItems();
41
 
};
42
 
 
43
 
// -------------------------------------------------------------------------------- //
44
 
guRaListBox::~guRaListBox()
45
 
{
46
 
    if( m_NormalStar )
47
 
        delete m_NormalStar;
48
 
    if( m_SelectStar )
49
 
        delete m_SelectStar;
50
 
}
51
 
 
52
 
// -------------------------------------------------------------------------------- //
53
 
void guRaListBox::GetItemsList( void )
54
 
{
55
 
    m_Db->GetRatings( m_Items );
56
 
}
57
 
 
58
 
// -------------------------------------------------------------------------------- //
59
 
int guRaListBox::GetSelectedSongs( guTrackArray * songs ) const
60
 
{
61
 
    wxArrayInt Items = GetSelectedItems();
62
 
    int Index;
63
 
    int Count = Items.Count();
64
 
    for( Index = 0; Index < Count; Index++ )
65
 
    {
66
 
        if( Items[ Index ] )
67
 
            Items[ Index ]--;
68
 
    }
69
 
    Count = m_Db->GetRatingsSongs( Items, songs );
70
 
    m_LibPanel->NormalizeTracks( songs );
71
 
    return Count;
72
 
}
73
 
 
74
 
// -------------------------------------------------------------------------------- //
75
 
void guRaListBox::DrawItem( wxDC &dc, const wxRect &rect, const int row, const int col ) const
76
 
{
77
 
    if( row == 0 )
78
 
    {
79
 
        guListBox::DrawItem( dc, rect, row, col );
80
 
    }
81
 
    else
82
 
    {
83
 
        int Rating = GetItemId( row ) - 1;
84
 
 
85
 
        dc.SetBackgroundMode( wxTRANSPARENT );
86
 
        int x;
87
 
        int w = ( ( GURATING_STYLE_MID * 2 ) + GURATING_IMAGE_SIZE );
88
 
 
89
 
        for( x = 0; x < 5; x++ )
90
 
        {
91
 
           dc.DrawBitmap( ( x >= Rating ) ? * m_NormalStar : * m_SelectStar,
92
 
                          rect.x + 3 + ( w * x ), rect.y + 3, true );
93
 
        }
94
 
    }
95
 
}
96
 
 
97
 
// -------------------------------------------------------------------------------- //
98
 
void guRaListBox::CreateContextMenu( wxMenu * Menu ) const
99
 
{
100
 
    wxMenuItem * MenuItem;
101
 
 
102
 
    int SelCount = GetSelectedCount();
103
 
    int ContextMenuFlags = m_LibPanel->GetContextMenuFlags();
104
 
 
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 );
108
 
 
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 );
112
 
 
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 );
116
 
 
117
 
    if( SelCount )
118
 
    {
119
 
        if( ContextMenuFlags & guLIBRARY_CONTEXTMENU_EDIT_TRACKS )
120
 
        {
121
 
            Menu->AppendSeparator();
122
 
 
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 );
126
 
        }
127
 
 
128
 
        Menu->AppendSeparator();
129
 
 
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 );
133
 
 
134
 
        if( ContextMenuFlags & guLIBRARY_CONTEXTMENU_COPY_TO )
135
 
        {
136
 
            m_LibPanel->CreateCopyToMenu( Menu, ID_RATING_COPYTO );
137
 
        }
138
 
    }
139
 
    m_LibPanel->CreateContextMenu( Menu );
140
 
}
141
 
 
142
 
// -------------------------------------------------------------------------------- //
143
 
wxString guRaListBox::GetSearchText( int item ) const
144
 
{
145
 
    return GetItemName( item );
146
 
}
147
 
 
148
 
// -------------------------------------------------------------------------------- //
149
 
int guRaListBox::GetDragFiles( wxFileDataObject * files )
150
 
{
151
 
    guTrackArray Songs;
152
 
    int index;
153
 
    int count = GetSelectedSongs( &Songs );
154
 
    m_LibPanel->NormalizeTracks( &Songs, true );
155
 
    for( index = 0; index < count; index++ )
156
 
    {
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 );
162
 
    }
163
 
    return count;
164
 
}
165
 
 
166
 
// -------------------------------------------------------------------------------- //