00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00034 #include "dialogbox.h"
00035
00039 CDialogBox::CDialogBox(const TRect& aRect):
00040 iRect(aRect)
00041 {
00042 }
00043
00049 CDialogBox* CDialogBox::NewL(const TRect& aRect)
00050 {
00051 CDialogBox* self = new(ELeave) CDialogBox(aRect);
00052 CleanupStack::PushL(self);
00053 self->ConstructL();
00054 CleanupStack::Pop(self);
00055 return self;
00056 }
00057
00061 void CDialogBox::ConstructL()
00062 {
00063
00064 User::LeaveIfError(iWs.Connect());
00065
00066
00067 iScr = new(ELeave) CWsScreenDevice(iWs);
00068 User::LeaveIfError(iScr->Construct());
00069
00070
00071 iGc = new(ELeave) CWindowGc(iScr);
00072 User::LeaveIfError(iGc->Construct());
00073
00074
00075 iGrp = RWindowGroup(iWs);
00076 User::LeaveIfError(iGrp.Construct(0xdeadface, EFalse));
00077 iGrp.SetOrdinalPositionErr(0, 100);
00078
00079
00080 iWin = RWindow(iWs);
00081 User::LeaveIfError(iWin.Construct(iGrp, (TInt)this));
00082
00083
00084 iWin.SetTransparencyAlphaChannel();
00085
00086
00087 iWin.SetBackgroundColor(TRgb(0,0,0,0));
00088
00089
00090 iWin.SetExtent(iRect.iTl, iRect.Size());
00091
00092
00093 iWin.Activate();
00094
00095
00096 iWin.SetOrdinalPosition(-1);
00097
00098
00099 iWin.SetVisible(EFalse);
00100
00101
00102 iWs.Flush();
00103
00104
00105 iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
00106
00107
00108 iLoaders.AppendL(CLoader::NewL(KCallBitmaps1));
00109 iLoaders.AppendL(CLoader::NewL(KCallBitmaps2));
00110 iLoaders.AppendL(CLoader::NewL(KCallBitmaps3));
00111 iLoaders.AppendL(CLoader::NewL(KCallBitmaps4));
00112 iLoaders.AppendL(CLoader::NewL(KCallBitmaps5));
00113 iLoaders.AppendL(CLoader::NewL(KCallBitmaps6));
00114
00115 for (TInt ii=0; ii < 6; ii++)
00116 {
00117 iLoaders[ii]->Decode();
00118 iCallBuffer.AppendL(iLoaders[ii]->iBitmap);
00119 iCallBuffer.AppendL(iLoaders[ii]->iMask);
00120 }
00121
00122 iImageCounter = 0;
00123 iSemiTransFlag = EFalse;
00124
00125 }
00126
00130 CDialogBox::~CDialogBox()
00131 {
00132 Stop();
00133 delete iTimer;
00134
00135 iCallBuffer.ResetAndDestroy();
00136 iLoaders.ResetAndDestroy();
00137
00138 delete iGc;
00139 delete iScr;
00140
00141
00142 iWin.Close();
00143 iGrp.Close();
00144 iWs.Close();
00145 }
00146
00150 void CDialogBox::Start()
00151 {
00152
00153 iWin.SetVisible(ETrue);
00154 if (!iTimer->IsActive())
00155 {
00156
00157 iTimer->Start(0, 150*1000, TCallBack(CDialogBox::OnTick, this));
00158 }
00159 }
00160
00164 void CDialogBox::Stop()
00165 {
00166
00167 iWin.SetVisible(EFalse);
00168
00169
00170 iWs.Flush();
00171
00172
00173 iTimer->Cancel();
00174 }
00175
00179 TInt CDialogBox::OnTick(TAny* aArg)
00180 {
00181 CDialogBox* self = (CDialogBox*)aArg;
00182
00183
00184 self->iWin.Invalidate();
00185
00186
00187 self->iWin.BeginRedraw();
00188
00189
00190 self->iGc->Activate(self->iWin);
00191 self->Draw();
00192
00193
00194 self->iGc->Deactivate();
00195
00196
00197 self->iWin.EndRedraw();
00198
00199
00200 self->iWs.Flush();
00201
00202 return 0;
00203 }
00204
00208 TBool CDialogBox::Draw()
00209 {
00210 if(iImageCounter == 12)
00211 iImageCounter = 0;
00212 iCallFrame = iCallBuffer[iImageCounter++];
00213 iCallMaskFrame = iCallBuffer[iImageCounter++];
00214
00215
00216 iGc->BitBltMasked(TPoint(10,10), iCallFrame, iCallFrame->SizeInPixels(), iCallMaskFrame, EFalse);
00217
00218 return EFalse;
00219 }
00223 void CDialogBox::SetSemiTransparency()
00224 {
00225 iWin.SetBackgroundColor(TRgb(24,255,0,128));
00226 iSemiTransFlag = ETrue;
00227 }
00228
00232 void CDialogBox::RemoveSemiTransparency()
00233 {
00234 iWin.SetBackgroundColor(TRgb(0,0,0,0));
00235 iSemiTransFlag = EFalse;
00236 }
00237
00241 CLoader* CLoader::NewL(const TDesC& aFn)
00242 {
00243 CLoader* self = new(ELeave) CLoader;
00244 CleanupStack::PushL(self);
00245 self->ConstructL(aFn);
00246 CleanupStack::Pop();
00247 return self;
00248 }
00249
00253 void CLoader::ConstructL(const TDesC& aFn)
00254 {
00255 iBitmap = new(ELeave) CFbsBitmap;
00256 User::LeaveIfError(iBitmap->Load(aFn, 0));
00257
00258 iMask = new(ELeave) CFbsBitmap;
00259 User::LeaveIfError(iMask->Load(aFn, 1));
00260
00261 #ifdef PORTRAIT_MODE
00262 RotateL(*iBitmap);
00263 RotateL(*iMask);
00264 #endif
00265 }
00266
00267 CLoader::CLoader()
00268 {
00269 }
00270
00274 CLoader::~CLoader()
00275 {
00276
00277 }
00278
00279 void CLoader::Decode()
00280 {
00281 }
00282
00283 #ifdef PORTRAIT_MODE
00284
00288 void CLoader::RotateL(CFbsBitmap& aBitmap)
00289 {
00290 CFbsBitmap* tmp = new(ELeave) CFbsBitmap;
00291 CleanupStack::PushL(tmp);
00292
00293
00294 const TSize bSz = aBitmap.SizeInPixels();
00295
00296
00297 const TDisplayMode bMode = aBitmap.DisplayMode();
00298 const TSize tSz(bSz.iHeight, bSz.iWidth);
00299
00300
00301 User::LeaveIfError(tmp->Create(tSz, bMode));
00302
00303
00304 TUint8* pTmp = (TUint8*)tmp->DataAddress();
00305
00306 TInt y = tSz.iHeight - 1;
00307 TInt scanLineLength = tmp->ScanLineLength(tSz.iWidth,bMode);
00308 for (TInt x=0; x<bSz.iWidth; ++x)
00309 {
00310 TPtr8 buf(pTmp + (y * scanLineLength), scanLineLength);
00311
00312
00313 aBitmap.GetVerticalScanLine(buf, x, bMode);
00314
00315 --y;
00316 }
00317
00318
00319 User::LeaveIfError(aBitmap.SwapWidthAndHeight());
00320 Mem::Move(aBitmap.DataAddress(), tmp->DataAddress(), scanLineLength * tSz.iHeight);
00321
00322 CleanupStack::PopAndDestroy(tmp);
00323 }
00324
00325 #endif