00001
00002
00003
00004
00010 #include "dialogbox.h"
00011
00015 CDialogBox::CDialogBox(const TRect& aRect):
00016 iRect(aRect)
00017 {
00018 }
00019
00025 CDialogBox* CDialogBox::NewL(const TRect& aRect)
00026 {
00027 CDialogBox* self = new(ELeave) CDialogBox(aRect);
00028 CleanupStack::PushL(self);
00029 self->ConstructL();
00030 CleanupStack::Pop(self);
00031 return self;
00032 }
00033
00037 void CDialogBox::ConstructL()
00038 {
00039
00040 User::LeaveIfError(iWs.Connect());
00041
00042
00043 iScr = new(ELeave) CWsScreenDevice(iWs);
00044 User::LeaveIfError(iScr->Construct());
00045
00046
00047 iGc = new(ELeave) CWindowGc(iScr);
00048 User::LeaveIfError(iGc->Construct());
00049
00050
00051 iGrp = RWindowGroup(iWs);
00052 User::LeaveIfError(iGrp.Construct(0xdeadface, EFalse));
00053 iGrp.SetOrdinalPositionErr(0, 100);
00054
00055
00056 iWin = RWindow(iWs);
00057 User::LeaveIfError(iWin.Construct(iGrp, (TInt)this));
00058
00059
00060 iWin.SetTransparencyAlphaChannel();
00061
00062
00063 iWin.SetBackgroundColor(TRgb(0,0,0,0));
00064
00065
00066 iWin.SetExtent(iRect.iTl, iRect.Size());
00067
00068
00069 iWin.Activate();
00070
00071
00072 iWin.SetOrdinalPosition(-1);
00073
00074
00075 iWin.SetVisible(EFalse);
00076
00077
00078 iWs.Flush();
00079
00080
00081 iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
00082
00083
00084 iLoaders.AppendL(CLoader::NewL(KCallBitmaps1));
00085 iLoaders.AppendL(CLoader::NewL(KCallBitmaps2));
00086 iLoaders.AppendL(CLoader::NewL(KCallBitmaps3));
00087 iLoaders.AppendL(CLoader::NewL(KCallBitmaps4));
00088 iLoaders.AppendL(CLoader::NewL(KCallBitmaps5));
00089 iLoaders.AppendL(CLoader::NewL(KCallBitmaps6));
00090
00091 for (TInt ii=0; ii < 6; ii++)
00092 {
00093 iLoaders[ii]->Decode();
00094 iCallBuffer.AppendL(iLoaders[ii]->iBitmap);
00095 iCallBuffer.AppendL(iLoaders[ii]->iMask);
00096 }
00097
00098 iImageCounter = 0;
00099 iSemiTransFlag = EFalse;
00100
00101 }
00102
00106 CDialogBox::~CDialogBox()
00107 {
00108 Stop();
00109 delete iTimer;
00110
00111 iCallBuffer.ResetAndDestroy();
00112 iLoaders.ResetAndDestroy();
00113
00114 delete iGc;
00115 delete iScr;
00116
00117
00118 iWin.Close();
00119 iGrp.Close();
00120 iWs.Close();
00121 }
00122
00126 void CDialogBox::Start()
00127 {
00128
00129 iWin.SetVisible(ETrue);
00130 if (!iTimer->IsActive())
00131 {
00132
00133 iTimer->Start(0, 150*1000, TCallBack(CDialogBox::OnTick, this));
00134 }
00135 }
00136
00140 void CDialogBox::Stop()
00141 {
00142
00143 iWin.SetVisible(EFalse);
00144
00145
00146 iWs.Flush();
00147
00148
00149 iTimer->Cancel();
00150 }
00151
00155 TInt CDialogBox::OnTick(TAny* aArg)
00156 {
00157 CDialogBox* self = (CDialogBox*)aArg;
00158
00159
00160 self->iWin.Invalidate();
00161
00162
00163 self->iWin.BeginRedraw();
00164
00165
00166 self->iGc->Activate(self->iWin);
00167 self->Draw();
00168
00169
00170 self->iGc->Deactivate();
00171
00172
00173 self->iWin.EndRedraw();
00174
00175
00176 self->iWs.Flush();
00177
00178 return 0;
00179 }
00180
00184 TBool CDialogBox::Draw()
00185 {
00186 if(iImageCounter == 12)
00187 iImageCounter = 0;
00188 iCallFrame = iCallBuffer[iImageCounter++];
00189 iCallMaskFrame = iCallBuffer[iImageCounter++];
00190
00191
00192 iGc->BitBltMasked(TPoint(10,10), iCallFrame, iCallFrame->SizeInPixels(), iCallMaskFrame, EFalse);
00193
00194 return EFalse;
00195 }
00199 void CDialogBox::SetSemiTransparency()
00200 {
00201 iWin.SetBackgroundColor(TRgb(24,255,0,128));
00202 iSemiTransFlag = ETrue;
00203 }
00204
00208 void CDialogBox::RemoveSemiTransparency()
00209 {
00210 iWin.SetBackgroundColor(TRgb(0,0,0,0));
00211 iSemiTransFlag = EFalse;
00212 }
00213
00217 CLoader* CLoader::NewL(const TDesC& aFn)
00218 {
00219 CLoader* self = new(ELeave) CLoader;
00220 CleanupStack::PushL(self);
00221 self->ConstructL(aFn);
00222 CleanupStack::Pop();
00223 return self;
00224 }
00225
00229 void CLoader::ConstructL(const TDesC& aFn)
00230 {
00231 iBitmap = new(ELeave) CFbsBitmap;
00232 User::LeaveIfError(iBitmap->Load(aFn, 0));
00233
00234 iMask = new(ELeave) CFbsBitmap;
00235 User::LeaveIfError(iMask->Load(aFn, 1));
00236
00237 #ifdef PORTRAIT_MODE
00238 RotateL(*iBitmap);
00239 RotateL(*iMask);
00240 #endif
00241 }
00242
00243 CLoader::CLoader()
00244 {
00245 }
00246
00250 CLoader::~CLoader()
00251 {
00252
00253 }
00254
00255 void CLoader::Decode()
00256 {
00257 }
00258
00259 #ifdef PORTRAIT_MODE
00260
00264 void CLoader::RotateL(CFbsBitmap& aBitmap)
00265 {
00266 CFbsBitmap* tmp = new(ELeave) CFbsBitmap;
00267 CleanupStack::PushL(tmp);
00268
00269
00270 const TSize bSz = aBitmap.SizeInPixels();
00271
00272
00273 const TDisplayMode bMode = aBitmap.DisplayMode();
00274 const TSize tSz(bSz.iHeight, bSz.iWidth);
00275
00276
00277 User::LeaveIfError(tmp->Create(tSz, bMode));
00278
00279
00280 TUint8* pTmp = (TUint8*)tmp->DataAddress();
00281
00282 TInt y = tSz.iHeight - 1;
00283 TInt scanLineLength = tmp->ScanLineLength(tSz.iWidth,bMode);
00284 for (TInt x=0; x<bSz.iWidth; ++x)
00285 {
00286 TPtr8 buf(pTmp + (y * scanLineLength), scanLineLength);
00287
00288
00289 aBitmap.GetVerticalScanLine(buf, x, bMode);
00290
00291 --y;
00292 }
00293
00294
00295 User::LeaveIfError(aBitmap.SwapWidthAndHeight());
00296 Mem::Move(aBitmap.DataAddress(), tmp->DataAddress(), scanLineLength * tSz.iHeight);
00297
00298 CleanupStack::PopAndDestroy(tmp);
00299 }
00300
00301 #endif