|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "tavsrcUI.h" |
|
17 |
|
18 // |
|
19 // class CStreamerUI |
|
20 // |
|
21 CStreamerUI* CStreamerUI::NewL(TBool aDisplayPlaylist, TBool aDisplayChunkyIcon) |
|
22 { |
|
23 CStreamerUI* ui = new (ELeave) CStreamerUI (); |
|
24 CleanupStack::PushL(ui); |
|
25 ui->ConstructL(aDisplayPlaylist, aDisplayChunkyIcon); |
|
26 CleanupStack::Pop(ui); |
|
27 return ui; |
|
28 } |
|
29 |
|
30 CStreamerUI::CStreamerUI() |
|
31 { |
|
32 } |
|
33 |
|
34 void CStreamerUI::ConstructL(TBool aDisplayPlaylist, TBool aDisplayChunkyIcon) |
|
35 { |
|
36 if (aDisplayChunkyIcon) |
|
37 { |
|
38 iIconConsole = Console::NewL(_L("Icon"), TSize(-1,-1)); |
|
39 } |
|
40 |
|
41 if (aDisplayPlaylist) |
|
42 { |
|
43 iPlayListConsole = Console::NewL(_L("Play List"), TSize(-1,-1)); |
|
44 } |
|
45 } |
|
46 |
|
47 CStreamerUI::~CStreamerUI() |
|
48 { |
|
49 delete iIconConsole; |
|
50 iIconConsole = NULL; |
|
51 delete iPlayListConsole; |
|
52 iPlayListConsole = NULL; |
|
53 } |
|
54 |
|
55 void CStreamerUI::Play() |
|
56 { |
|
57 if (iIconConsole) |
|
58 { |
|
59 TBuf<KIconSize> line; |
|
60 |
|
61 iIconConsole->ClearScreen(); |
|
62 |
|
63 for (TInt len=1; len<=KIconSize/2; len++) |
|
64 { |
|
65 line.AppendFill('*',len*2); |
|
66 iIconConsole->SetPos(KIconIndent,len); |
|
67 iIconConsole->Printf(line); |
|
68 iIconConsole->SetPos(KIconIndent,KIconSize-len); |
|
69 iIconConsole->Printf(line); |
|
70 line.Zero(); |
|
71 } |
|
72 } |
|
73 DrawPointer(); |
|
74 } |
|
75 |
|
76 void CStreamerUI::Pause() |
|
77 { |
|
78 if (iIconConsole) |
|
79 { |
|
80 TBuf<KIconSize> line; |
|
81 |
|
82 iIconConsole->ClearScreen(); |
|
83 line.AppendFill('*',KIconSize/3); |
|
84 line.AppendFill(' ',KIconSize/3); |
|
85 line.AppendFill('*',KIconSize/3); |
|
86 |
|
87 for (TInt len=1; len<=KIconSize; len++) |
|
88 { |
|
89 iIconConsole->SetPos(KIconIndent,len); |
|
90 iIconConsole->Printf(line); |
|
91 } |
|
92 } |
|
93 } |
|
94 |
|
95 void CStreamerUI::Stop() |
|
96 { |
|
97 if (iIconConsole) |
|
98 { |
|
99 TBuf<KIconSize> line; |
|
100 |
|
101 iIconConsole->ClearScreen(); |
|
102 line.AppendFill('*',KIconSize); |
|
103 |
|
104 for (TInt len=1; len<=KIconSize; len++) |
|
105 { |
|
106 iIconConsole->SetPos(KIconIndent,len); |
|
107 iIconConsole->Printf(line); |
|
108 } |
|
109 } |
|
110 } |
|
111 |
|
112 void CStreamerUI::AddTitle(const TDesC& aTitle) |
|
113 { |
|
114 if (iPlayListConsole) |
|
115 { |
|
116 iPlayListConsole->SetPos(KPlayListX+2); |
|
117 iPlayListConsole->Printf(_L("%S\n"), &aTitle); |
|
118 } |
|
119 } |
|
120 |
|
121 void CStreamerUI::Next() |
|
122 { |
|
123 ClearPointer(); |
|
124 ++iPlayListY; |
|
125 DrawPointer(); |
|
126 } |
|
127 |
|
128 void CStreamerUI::Prev() |
|
129 { |
|
130 ClearPointer(); |
|
131 --iPlayListY; |
|
132 DrawPointer(); |
|
133 } |
|
134 |
|
135 void CStreamerUI::First() |
|
136 { |
|
137 ClearPointer(); |
|
138 iPlayListY = 0; |
|
139 DrawPointer(); |
|
140 } |
|
141 |
|
142 void CStreamerUI::ClearPointer() |
|
143 { |
|
144 if (iPlayListConsole) |
|
145 { |
|
146 iPlayListConsole->SetPos(KPlayListX, iPlayListY); |
|
147 iPlayListConsole->Printf(_L(" ")); |
|
148 } |
|
149 } |
|
150 |
|
151 void CStreamerUI::DrawPointer() |
|
152 { |
|
153 if (iPlayListConsole) |
|
154 { |
|
155 iPlayListConsole->SetPos(KPlayListX, iPlayListY); |
|
156 iPlayListConsole->Printf(_L(">")); |
|
157 } |
|
158 } |
|
159 |
|
160 static const TInt KProgressBarSize = 70; |
|
161 |
|
162 // |
|
163 // class CProgressBar |
|
164 // |
|
165 CProgressBar::CProgressBar(TInt aMaximum) : iMax(aMaximum) |
|
166 { |
|
167 } |
|
168 |
|
169 CProgressBar::~CProgressBar() |
|
170 { |
|
171 delete iConsole; |
|
172 } |
|
173 |
|
174 CProgressBar* CProgressBar::NewL(TInt aMaximum) |
|
175 { |
|
176 CProgressBar* p = new (ELeave) CProgressBar(aMaximum); |
|
177 CleanupStack::PushL(p); |
|
178 p->ConstructL(); |
|
179 CleanupStack::Pop(p); |
|
180 return p; |
|
181 } |
|
182 |
|
183 void CProgressBar::Increment(TInt aStep) |
|
184 { |
|
185 iValue+=aStep; |
|
186 if (iValue < 0) |
|
187 { |
|
188 iValue = 0; |
|
189 } |
|
190 #ifdef __WINS__ |
|
191 Redraw(); |
|
192 #endif |
|
193 } |
|
194 |
|
195 void CProgressBar::ConstructL() |
|
196 { |
|
197 #ifdef __WINS__ |
|
198 iConsole = Console::NewL(_L("Progress"), TSize(KProgressBarSize+5,1)); |
|
199 Redraw(); |
|
200 #endif |
|
201 } |
|
202 |
|
203 void CProgressBar::Redraw() |
|
204 { |
|
205 iConsole->SetPos(0); |
|
206 |
|
207 TBuf<KProgressBarSize> bar; |
|
208 TInt numDone = ((iValue*KProgressBarSize) /iMax); |
|
209 TInt numToDo = 0; |
|
210 |
|
211 if (numDone<bar.MaxLength()) |
|
212 { |
|
213 bar.AppendFill('|',numDone); |
|
214 numToDo = KProgressBarSize - numDone; |
|
215 } |
|
216 bar.AppendFill('-',numToDo); |
|
217 |
|
218 iConsole->Printf(bar); |
|
219 } |