00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00017 #include "sidplay_view.h"
00018 #include <sidplay.rsg>
00019
00020
00021 #include <eikclbd.h>
00022
00023
00024
00025
00026
00027
00028 void CSidPlayerStatusView::ConstructL(const TRect& aRect, CCoeControl* aParent)
00032 {
00033 CTOR(CSidPlayerStatusView);
00034 iParent = aParent;
00035
00036 CreateWindowL(aParent);
00037 #if defined(__ER6__)
00038 SetRect(aRect);
00039 #else
00040 SetRectL(aRect);
00041 #endif
00042
00043
00044
00045 }
00046
00047
00048 CSidPlayerStatusView::~CSidPlayerStatusView()
00052 {
00053 DTOR(CSidPlayerStatusView);
00054 }
00055
00056
00057 void CSidPlayerStatusView::Draw(const TRect& ) const
00061 {
00062 ELOG1(_L8("CSidPlayerStatusView::Draw\n"));
00063
00064 const TInt offset_x = 10;
00065 const TInt offset_x2 = 100;
00066 const TInt offset_y = 20;
00067 const TInt distance_y = 20;
00068 TInt pos_y = offset_y;
00069
00070 sidTune& tune = ((CSidPlayAppView*)iParent)->SidPlayer()->CurrentSidTune();
00071 struct sidTuneInfo mySidInfo;
00072 tune.getInfo(mySidInfo);
00073
00074 CWindowGc& gc = SystemGc();
00075
00076 gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00077 gc.SetBrushColor(KRgbWhite);
00078 gc.SetPenStyle(CGraphicsContext::ESolidPen);
00079 gc.SetPenColor(KRgbBlack);
00080 gc.SetBrushStyle(CGraphicsContext::ENullBrush);
00081
00082
00083 TBuf<128> buf;
00084 TBuf<128> rs;
00085
00086
00087 TRect drawRect = Rect();
00088
00089
00090 const CFont* fontUsed;
00091
00092
00093 CEikonEnv* eikonEnv = CEikonEnv::Static();
00094
00095
00096 gc.Clear();
00097
00098
00099
00100
00101 drawRect.Shrink(5, 5);
00102 gc.DrawRect(drawRect);
00103
00104
00105 fontUsed = eikonEnv->TitleFont();
00106 gc.UseFont(fontUsed);
00107
00108 if(mySidInfo.nameString)
00109 {
00110 gc.DrawText(_L("Name"), TPoint(offset_x, pos_y));
00111 buf.Copy(TPtrC8((TUint8*)mySidInfo.nameString));
00112 gc.DrawText(buf, TPoint(offset_x2, pos_y));
00113 pos_y += distance_y;
00114 }
00115
00116 if(mySidInfo.authorString)
00117 {
00118 gc.DrawText(_L("Author"), TPoint(offset_x, pos_y));
00119 buf.Copy(TPtrC8((TUint8*)mySidInfo.authorString));
00120 gc.DrawText(buf, TPoint(offset_x2, pos_y));
00121 pos_y += distance_y;
00122 }
00123
00124 if(mySidInfo.copyrightString)
00125 {
00126 gc.DrawText(_L("Copyright"), TPoint(offset_x, pos_y));
00127 buf.Copy(TPtrC8((TUint8*)mySidInfo.copyrightString));
00128 gc.DrawText(buf, TPoint(offset_x2, pos_y));
00129 pos_y += distance_y;
00130 }
00131
00132 gc.DrawText(_L("Subtune"), TPoint(offset_x, pos_y));
00133 rs.Format(_L("%d/%d"), mySidInfo.currentSong, mySidInfo.songs);
00134 gc.DrawText(rs, TPoint(offset_x2, pos_y));
00135 pos_y += distance_y;
00136
00137
00138 gc.DiscardFont();
00139 }
00140
00141
00142
00143
00144
00145
00146
00147 TInt SidPlayerTimeViewPeriodicUpdate(TAny* aPtr)
00151 {
00152 CSidPlayerTimeView* view = (CSidPlayerTimeView*)aPtr;
00153 if(((CSidPlayAppView*)(view->iParent))->SidPlayer()->iIdlePlay)
00154 view->DrawNow();
00155 return ETrue;
00156 }
00157
00158
00159 void CSidPlayerTimeView::ConstructL(const TRect& aRect, CCoeControl* aParent)
00163 {
00164 iParent = aParent;
00165
00166 CreateWindowL(aParent);
00167 #if defined(__ER6__)
00168 SetRect(aRect);
00169 #else
00170 SetRectL(aRect);
00171 #endif
00172
00173 iPeriodic = CPeriodic::NewL(CActive::EPriorityLow);
00174 TCallBack cb(SidPlayerTimeViewPeriodicUpdate, this);
00175 iPeriodic->Start(TTimeIntervalMicroSeconds32(0),
00176 TTimeIntervalMicroSeconds32(500000),
00177 cb);
00178 }
00179
00180
00181 CSidPlayerTimeView::~CSidPlayerTimeView()
00185 {
00186 if(iPeriodic)
00187 {
00188 delete iPeriodic;
00189 iPeriodic = NULL;
00190 }
00191 }
00192
00193
00194 void CSidPlayerTimeView::Draw(const TRect& ) const
00198 {
00199 const TInt offset_x = 10;
00200 const TInt offset_x2 = 60;
00201 const TInt offset_y = 20;
00202 const TInt distance_y = 20;
00203 TInt pos_y = offset_y;
00204
00205 emuEngine* ee = ((CSidPlayAppView*)iParent)->SidPlayer()->iEmuEngine;
00206
00207 CWindowGc& gc = SystemGc();
00208
00209 gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00210 gc.SetBrushColor(KRgbWhite);
00211 gc.SetPenStyle(CGraphicsContext::ESolidPen);
00212 gc.SetPenColor(KRgbRed);
00213 gc.SetBrushStyle(CGraphicsContext::ENullBrush);
00214
00215
00216 TBuf<128> buf;
00217 TBuf<128> rs;
00218
00219
00220 TRect drawRect = Rect();
00221
00222
00223 const CFont* fontUsed;
00224
00225
00226 CEikonEnv* eikonEnv = CEikonEnv::Static();
00227
00228
00229 gc.Clear();
00230
00231
00232
00233
00234 drawRect.Shrink(5, 5);
00235 gc.DrawRect(drawRect);
00236
00237
00238 fontUsed = eikonEnv->TitleFont();
00239 gc.UseFont(fontUsed);
00240
00241 gc.DrawText(_L("Time"), TPoint(offset_x, pos_y));
00242 rs.Format(_L("%d:%02d"), ee->getSecondsThisSong() / 60, ee->getSecondsThisSong() % 60);
00243 gc.DrawText(rs, TPoint(offset_x2, pos_y));
00244 pos_y += distance_y;
00245
00246 gc.DrawText(_L("Total"), TPoint(offset_x, pos_y));
00247 rs.Format(_L("%d:%02d"), ee->getSecondsTotal() / 60, ee->getSecondsTotal() % 60);
00248 gc.DrawText(rs, TPoint(offset_x2, pos_y));
00249 pos_y += distance_y;
00250
00251
00252 gc.DiscardFont();
00253 }
00254
00255
00256
00257
00258
00259
00260
00261 void CSidPlayAppView::ConstructL(const TRect& aRect, CSidPlayer* aThePlayer)
00265 {
00266 CTOR(CSidPlayAppView);
00267
00268 iThePlayer = aThePlayer;
00269 CreateWindowL();
00270
00271 #if defined(__CRYSTAL__)
00272 HBufC* appName = CEikonEnv::Static()->AllocReadResourceLC(R_SIDPLAY_APPNAME);
00273
00274
00275 iAppTitle = CCknAppTitle::NewL();
00276 iAppTitle->SetTextL(*appName,CCknAppTitle::EMainTitle);
00277 CleanupStack::PopAndDestroy();
00278 TSize titleSize(aRect.Width(),iAppTitle->MinimumSize().iHeight);
00279 TRect titleRect(TPoint(0,0),titleSize);
00280
00281 iAppTitle->SetRect(titleRect);
00282 iAppTitle->SetFocus(ETrue);
00283 #else
00284 TRect titleRect(TPoint(0,0), TPoint(0,0));
00285 #endif // __CRYSTAL__
00286
00287
00288
00289
00290 #if defined(__SERIES60__)
00291 const TRect status_view = TRect(1, 1, aRect.Width(), aRect.Height()-60);
00292 const TRect time_view = TRect(1, aRect.Height()-60+1, aRect.Width(), aRect.Height()-20);
00293 #else // CRYSTAL
00294 const TRect status_view = TRect(1, titleRect.Height(), 360, aRect.Height());
00295 const TRect time_view = TRect(360, titleRect.Height(), aRect.Width(), titleRect.Height()+60);
00296 const TRect volumeRect = TRect(400, titleRect.Height()+60 , aRect.Width()-1, aRect.Height()-1-20);
00297 #endif
00298
00299
00300
00301
00302
00303 iStatusView = new (ELeave) CSidPlayerStatusView;
00304 iStatusView->ConstructL(status_view, this);
00305
00306
00307
00308
00309 iTimeView = new (ELeave) CSidPlayerTimeView;
00310 iTimeView->ConstructL(time_view, this);
00311
00312
00313
00314
00315
00316 #if defined(__CRYSTAL__)
00317 CCknControlBar::SControlBarData v;
00318 v.iHeight = aRect.Width() - 1 - 441;
00319 v.iWidth = aRect.Height() - 1 - 81 - 20;
00320 v.iFinalValue = KVolumeSteps - 1;
00321
00322 iVolumeView = new (ELeave) CCknControlBar(v, EFalse);
00323
00324 CleanupStack::PushL(iVolumeView);
00325 iVolumeView->SetContainerWindowL(*this);
00326 CleanupStack::Pop(iVolumeView);
00327
00328 iVolumeView->ActivateL();
00329 iVolumeView->SetRect(volumeRect);
00330
00331 _LIT(KVolumeIcon, "\\system\\apps\\sidplay\\e32frodo.mbm");
00332 CGulIcon* icon = iEikonEnv->CreateIconL(KVolumeIcon, 0 );
00333 iVolumeView->SetIcon(icon,ETrue);
00334
00335 const TInt vol = iThePlayer->VolumeDelta(0);
00336 iVolumeView->SetAndDraw(vol);
00337 #endif // __CRYSTAL__
00338
00339 #if defined(__ER6__)
00340 SetRect(aRect);
00341 #else
00342 SetRectL(aRect);
00343 #endif
00344
00345
00346 ActivateL();
00347 }
00348
00349
00350 CSidPlayAppView::~CSidPlayAppView()
00354 {
00355 DTOR(CSidPlayAppView);
00356 delete iTimeView;
00357 delete iStatusView;
00358 #if defined(__CRYSTAL__)
00359 delete iAppTitle;
00360 delete iVolumeView;
00361 #endif
00362 }
00363
00364
00365 void CSidPlayAppView::Draw(const TRect& ) const
00369 {
00370 }
00371
00372
00373 TKeyResponse CSidPlayAppView::OfferKeyEventL(const TKeyEvent& ,TEventCode )
00374 {
00375
00376
00377 return EKeyWasNotConsumed;
00378 }
00379
00380
00381 TInt CSidPlayAppView::CountComponentControls() const
00385 {
00386 #if defined(__CRYSTAL__)
00387 return 4;
00388 #else
00389 return 2;
00390 #endif
00391 }
00392
00393
00394 CCoeControl* CSidPlayAppView::ComponentControl(TInt aIndex) const
00398 {
00399 switch (aIndex)
00400 {
00401 case 0: return iStatusView;
00402 case 1: return iTimeView;
00403 #if defined(__CRYSTAL__)
00404 case 2: return iAppTitle;
00405 case 3: return iVolumeView;
00406 #endif
00407 }
00408 return 0;
00409 }