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
00029 #include <eiklabel.h>
00030 #include <eikenv.h>
00031
00032 #include <aknutils.h>
00033
00034
00035 #include "ControlsContainer.h"
00036
00037 #include "Image_Control.h"
00038 #include "Animation_Control.h"
00039
00040
00041
00042
00043
00044 CControlsContainer* CControlsContainer::NewL( const TRect& aRect )
00045 {
00046 CControlsContainer* self = CControlsContainer::NewLC( aRect );
00047 CleanupStack::Pop( self );
00048 return self;
00049 }
00050
00051
00052
00053
00054 CControlsContainer* CControlsContainer::NewLC( const TRect& aRect )
00055 {
00056 CControlsContainer* self = new ( ELeave ) CControlsContainer;
00057 CleanupStack::PushL( self );
00058 self->ConstructL( aRect );
00059 return self;
00060 }
00061
00062
00063
00064
00065 CControlsContainer::~CControlsContainer()
00066 {
00067 delete iImageControl;
00068 delete iAnimationControl;
00069 delete iBitmap;
00070 }
00071
00072
00073
00074
00075 void CControlsContainer::ConstructL( const TRect& aRect )
00076 {
00077 CreateWindowL();
00078 SetRect( aRect );
00079
00080 ActivateL();
00081
00082
00083
00084 TRect tmpAnimationRect(iAnimationRect);
00085 TRect tmpImageRect(iImageRect);
00086
00087
00088 tmpAnimationRect.Shrink(2,2);
00089 tmpImageRect.Shrink(2,2);
00090
00091 TFindFile imageFile3(CCoeEnv::Static()->FsSession());
00092 if(KErrNone == imageFile3.FindByDir(KTxImage3, KNullDesC))
00093 {
00094 iImageControl = CImageControl::NewL(*this,tmpImageRect,imageFile3.File());
00095 }
00096
00097 TFindFile bitFile(CCoeEnv::Static()->FsSession());
00098 if(KErrNone == bitFile.FindByDir(KTxBitmap2, KNullDesC))
00099 {
00100
00101
00102
00103 iBitmap = new(ELeave)CFbsBitmap();
00104
00105
00106 TInt err = iBitmap->Load(bitFile.File(),0);
00107
00108
00109
00110
00111
00112
00113 }
00114
00115 TFindFile aniFile3(CCoeEnv::Static()->FsSession());
00116 if(KErrNone == aniFile3.FindByDir(KTxAnimation3, KNullDesC))
00117 {
00118 iAnimationControl = CAnimationControl::NewL(*this,tmpAnimationRect,aniFile3.File());
00119 }
00120
00121 DrawNow();
00122 }
00123
00124
00125
00126
00127
00128
00129
00130 TInt CControlsContainer::CountComponentControls() const
00131 {
00132 if(iImageControl
00133 && iAnimationControl )
00134 {
00135 return 2;
00136 }
00137 else
00138 {
00139 return 0;
00140 }
00141 }
00142
00143
00144
00145
00146
00147
00148
00149 CCoeControl* CControlsContainer::ComponentControl( TInt aIndex ) const
00150 {
00151 switch (aIndex)
00152 {
00153 case 0:
00154 return iImageControl;
00155
00156 case 1:
00157 return iAnimationControl;
00158
00159 default:
00160 return NULL;
00161 }
00162 }
00163
00164
00165
00166
00167
00168
00169
00170 TKeyResponse CControlsContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode )
00171 {
00172 TKeyResponse myRet = EKeyWasNotConsumed;
00173
00174 switch (aKeyEvent.iCode)
00175 {
00176 case EKeyDevice3:
00177 {
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 }
00190 break;
00191
00192
00193
00194
00195 case EKeyLeftArrow:
00196
00197 if(iSelected == 1)
00198 {
00199 iSelected = 0;
00200 }
00201 else if(iSelected == 3)
00202 {
00203 iSelected = 2;
00204 }
00205 DrawNow();
00206 break;
00207
00208 case EKeyRightArrow:
00209
00210 if(iSelected == 0)
00211 {
00212 iSelected = 1;
00213 }
00214 else if(iSelected == 2)
00215 {
00216 iSelected = 3;
00217 }
00218 DrawNow();
00219 break;
00220
00221 case EKeyUpArrow:
00222
00223 if(iSelected == 2)
00224 {
00225 iSelected = 0;
00226 }
00227 else if(iSelected == 3)
00228 {
00229 iSelected = 1;
00230 }
00231 DrawNow();
00232 break;
00233
00234
00235 case EKeyDownArrow:
00236
00237 if(iSelected == 0)
00238 {
00239 iSelected = 2;
00240 }
00241 else if(iSelected == 1)
00242 {
00243 iSelected = 3;
00244 }
00245 DrawNow();
00246 break;
00247 default:
00248 break;
00249 }
00250
00251 return myRet;
00252 }
00253
00254
00255
00256
00257
00258
00259 void CControlsContainer::Draw( const TRect& ) const
00260 {
00261 CWindowGc& gc = SystemGc();
00262
00263 gc.Clear();
00264
00265
00266 gc.DrawLine(iBitmapRect2.iTl,TPoint(iBitmapRect2.iTl.iX,iBitmapRect2.iBr.iY));
00267 gc.DrawLine(iBitmapRect2.iTl,TPoint(iBitmapRect2.iBr.iX,iBitmapRect2.iTl.iY));
00268 gc.DrawLine(TPoint(iBitmapRect2.iTl.iX,iBitmapRect2.iBr.iY),iBitmapRect2.iBr);
00269 gc.DrawLine(TPoint(iBitmapRect2.iBr.iX,iBitmapRect2.iTl.iY),iBitmapRect2.iBr);
00270
00271
00272 gc.DrawLine(iAnimationRect.iTl,TPoint(iAnimationRect.iTl.iX,iAnimationRect.iBr.iY));
00273 gc.DrawLine(iAnimationRect.iTl,TPoint(iAnimationRect.iBr.iX,iAnimationRect.iTl.iY));
00274 gc.DrawLine(TPoint(iAnimationRect.iTl.iX,iAnimationRect.iBr.iY),iAnimationRect.iBr);
00275 gc.DrawLine(TPoint(iAnimationRect.iBr.iX,iAnimationRect.iTl.iY),iAnimationRect.iBr);
00276
00277
00278 gc.DrawLine(iImageRect.iTl,TPoint(iImageRect.iTl.iX,iImageRect.iBr.iY));
00279 gc.DrawLine(iImageRect.iTl,TPoint(iImageRect.iBr.iX,iImageRect.iTl.iY));
00280 gc.DrawLine(TPoint(iImageRect.iTl.iX,iImageRect.iBr.iY),iImageRect.iBr);
00281 gc.DrawLine(TPoint(iImageRect.iBr.iX,iImageRect.iTl.iY),iImageRect.iBr);
00282
00283
00284 gc.DrawLine(iBitmapRect.iTl,TPoint(iBitmapRect.iTl.iX,iBitmapRect.iBr.iY));
00285 gc.DrawLine(iBitmapRect.iTl,TPoint(iBitmapRect.iBr.iX,iBitmapRect.iTl.iY));
00286 gc.DrawLine(TPoint(iBitmapRect.iTl.iX,iBitmapRect.iBr.iY),iBitmapRect.iBr);
00287 gc.DrawLine(TPoint(iBitmapRect.iBr.iX,iBitmapRect.iTl.iY),iBitmapRect.iBr);
00288
00289
00290 TRect selRect(iBitmapRect2);
00291 switch(iSelected)
00292 {
00293 case 0:
00294 selRect = iBitmapRect2;
00295 break;
00296 case 1:
00297 selRect = iAnimationRect;
00298 break;
00299 case 2:
00300 selRect = iBitmapRect;
00301 break;
00302 case 3:
00303 selRect = iImageRect;
00304 break;
00305 }
00306
00307
00308 gc.SetPenColor(KRgbGreen);
00309
00310
00311 gc.DrawLine(selRect.iTl,TPoint(selRect.iTl.iX,selRect.iBr.iY));
00312 gc.DrawLine(selRect.iTl,TPoint(selRect.iBr.iX,selRect.iTl.iY));
00313 gc.DrawLine(TPoint(selRect.iTl.iX,selRect.iBr.iY),selRect.iBr);
00314 gc.DrawLine(TPoint(selRect.iBr.iX,selRect.iTl.iY),selRect.iBr);
00315
00316
00317 selRect.Grow(1,1);
00318
00319 gc.DrawLine(selRect.iTl,TPoint(selRect.iTl.iX,selRect.iBr.iY));
00320 gc.DrawLine(selRect.iTl,TPoint(selRect.iBr.iX,selRect.iTl.iY));
00321 gc.DrawLine(TPoint(selRect.iTl.iX,selRect.iBr.iY),selRect.iBr);
00322 gc.DrawLine(TPoint(selRect.iBr.iX,selRect.iTl.iY),selRect.iBr);
00323
00324 TRect tmpBitmapRect(iBitmapRect);
00325 tmpBitmapRect.Shrink(2,2);
00326
00327 TRect tmpBitmapRect2(iBitmapRect2);
00328 tmpBitmapRect2.Shrink(2,2);
00329
00330 if(iBitmap)
00331 {
00332
00333 if(iBitmap->Handle())
00334 {
00335
00336
00337 gc.DrawBitmap(tmpBitmapRect,iBitmap);
00338 gc.DrawBitmap(tmpBitmapRect2,iBitmap);
00339 }
00340 }
00341 }
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351 void CControlsContainer::HandleResourceChange(TInt aType)
00352 {
00353 if ( aType==KEikDynamicLayoutVariantSwitch )
00354 {
00355 TRect rect;
00356 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
00357 SetRect(rect);
00358 }
00359
00360
00361 CCoeControl::HandleResourceChange(aType);
00362 }
00363
00364
00365
00366
00367
00368
00369 void CControlsContainer::SizeChanged()
00370 {
00371 TRect rect(Rect());
00372
00373 rect.Shrink(2,2);
00374
00375 iImageRect = iBitmapRect = iBitmapRect2 = iAnimationRect = rect;
00376
00377
00378 TInt helfHeight= (rect.Height()/ 2);
00379 TInt helfWidth = (rect.Width() / 2);
00380
00381
00382 iBitmapRect2.iBr.iY = iAnimationRect.iBr.iY = (iAnimationRect.iTl.iY + helfHeight);
00383
00384
00385 iImageRect.iTl.iY = iBitmapRect.iTl.iY = iBitmapRect2.iBr.iY;
00386
00387
00388 iBitmapRect2.iBr.iX = (iBitmapRect2.iTl.iX + helfWidth);
00389 iAnimationRect.iTl.iX = iBitmapRect2.iBr.iX;
00390
00391
00392 iBitmapRect.iBr.iX = (iBitmapRect.iTl.iX + helfWidth);
00393 iImageRect.iTl.iX = iBitmapRect.iBr.iX;
00394
00395
00396 TRect tmpAnimationRect(iAnimationRect);
00397 TRect tmpImageRect(iImageRect);
00398
00399
00400 tmpAnimationRect.Shrink(2,2);
00401 tmpImageRect.Shrink(2,2);
00402
00403 if(iAnimationControl)
00404 {
00405 iAnimationControl->SetRect(tmpAnimationRect);
00406 }
00407
00408 if(iImageControl)
00409 {
00410 iImageControl->SetRect(tmpImageRect);
00411 }
00412 }
00413
00414
00415
00416