uifw/AvKon/src/akncolourselectiongrid.cpp
branchRCL_3
changeset 10 9f56a4e1b8ab
parent 0 2f259fa3e83a
child 15 08e69e956a8c
equal deleted inserted replaced
9:aabf2c525e0f 10:9f56a4e1b8ab
   190         transApi->StopDrawing();
   190         transApi->StopDrawing();
   191         }
   191         }
   192 #endif
   192 #endif
   193     aGc.DrawRect( gridRect );
   193     aGc.DrawRect( gridRect );
   194 };
   194 };
   195  
   195 
       
   196 // CLASS DECLARATION
       
   197 
       
   198 /**
       
   199 * CMainTextArray
       
   200 *
       
   201 * 
       
   202 *
       
   203 *  @lib avkon
       
   204 *  @since 2.0
       
   205 */
       
   206 
       
   207 NONSHARABLE_CLASS(CMainTextArray) : public MDesCArray, public CBase
       
   208     {
       
   209     public:
       
   210 
       
   211         /**
       
   212         * C++ default constructor.
       
   213         */
       
   214         CMainTextArray(TBool &aNoneExist);
       
   215         /**
       
   216         * Destructor.
       
   217         */
       
   218         ~CMainTextArray();
       
   219     
       
   220         /**
       
   221         * MdcaCount
       
   222         * @since 2.0
       
   223         * @return 
       
   224         */
       
   225         virtual TInt MdcaCount() const;
       
   226         
       
   227         /**
       
   228         * MdcaPoint
       
   229         * @since 2.0
       
   230         * @param aIndex 
       
   231         * @return 
       
   232         */
       
   233         virtual TPtrC MdcaPoint(TInt aIndex) const;
       
   234         
       
   235         /**
       
   236         * ConstructL
       
   237         * @since 2.0
       
   238         * @param aColours Array of colours to be in grid
       
   239         */
       
   240         void ConstructL(CArrayFixFlat<TRgb>* aColours);
       
   241         
       
   242         /**
       
   243         * ReSizeIcons
       
   244         * @since 5.2
       
   245         * @param aWidth the width of icon
       
   246         * @param aheight the height of icon
       
   247         */
       
   248         void ReSizeIcons( TInt aWidth, TInt aHeight );
       
   249 
       
   250     public: // Data
       
   251         CGulIcon* iIcon[16];
       
   252 
       
   253     private:    // Data
       
   254         mutable TInt iIndex;
       
   255         TInt iColourNmbr;
       
   256         TBool iNoneExist;
       
   257         CArrayFixFlat<TRgb>* iColours;
       
   258         CFbsBitmap* iBitmap[16];
       
   259         CFbsBitmapDevice* iBmpDevice[16];
       
   260         HBufC *iString;
       
   261 
       
   262     };
       
   263 
       
   264 // ---------------------------------------------------------
       
   265 // CMainTextArray::CMainTextArray()
       
   266 //
       
   267 // ---------------------------------------------------------
       
   268 //
       
   269 CMainTextArray::CMainTextArray(TBool &aNoneExist)
       
   270         : iNoneExist(aNoneExist)
       
   271     {
       
   272     }
       
   273 // ---------------------------------------------------------
       
   274 // CMainTextArray::~CMainTextArray()
       
   275 //
       
   276 // ---------------------------------------------------------
       
   277 //
       
   278 CMainTextArray::~CMainTextArray()
       
   279     {
       
   280     for (TInt i = 0;i<iColourNmbr;i++)
       
   281         {
       
   282         delete iBitmap[i];
       
   283         delete iBmpDevice[i];
       
   284         }
       
   285     delete iString;
       
   286     }
       
   287 
       
   288 // ---------------------------------------------------------
       
   289 // CMainTextArray::ConstructL()
       
   290 // 
       
   291 // ---------------------------------------------------------
       
   292 //
       
   293 void CMainTextArray::ConstructL(CArrayFixFlat<TRgb>* aColours)
       
   294     {
       
   295 
       
   296     this->iColours = aColours;
       
   297     iColourNmbr = aColours->Count();
       
   298     if (iColourNmbr > 16)
       
   299         {
       
   300         iColourNmbr = 16;
       
   301         }
       
   302     TAknLayoutRect r;
       
   303     TAknLayoutRect rectPane;
       
   304     rectPane.LayoutRect( TRect( 0, 0, 0, 0 ), 
       
   305                        AknLayoutScalable_Avkon::cell_large_graphic_colour_popup_pane(
       
   306                                                                                      iNoneExist, 
       
   307                                                                                      0, 
       
   308                                                                                      0).LayoutLine());
       
   309     r.LayoutRect( rectPane.Rect(), 
       
   310                   AknLayoutScalable_Avkon::cell_large_graphic_colour_popup_pane_g1().LayoutLine());
       
   311     TSize bmpsize( r.Rect().Width(), r.Rect().Height() );
       
   312     for ( TInt i = 0; i < iColourNmbr; i++ )
       
   313          {
       
   314          iBitmap[i] = new (ELeave) CFbsBitmap();
       
   315          iBitmap[i]->Create(bmpsize,EColor4K);
       
   316          iIcon[i] = CGulIcon::NewL(iBitmap[i]);
       
   317          iIcon[i]->SetBitmapsOwnedExternally(ETrue);
       
   318          iBmpDevice[i] = CFbsBitmapDevice::NewL(iBitmap[i]);
       
   319          iBmpDevice[i]->Resize(iBitmap[i]->SizeInPixels());
       
   320          }
       
   321     iString = HBufC::NewL(10);
       
   322     }
       
   323 
       
   324 // ---------------------------------------------------------
       
   325 // CMainTextArray::ReSizeIcons()
       
   326 //
       
   327 // ---------------------------------------------------------
       
   328 //
       
   329 void CMainTextArray::ReSizeIcons( TInt aWidth, TInt aHeight )
       
   330 	{
       
   331 	TSize bmpsize( aWidth, aHeight );
       
   332 	for ( TInt i = 0; i < iColourNmbr; i++ )
       
   333 		 {
       
   334 	     if ( iBitmap[i] )
       
   335 	    	 {
       
   336 	         iBitmap[i]->Resize( bmpsize );
       
   337 	    	 }
       
   338 	     if ( iBmpDevice[i] )
       
   339 	    	 {
       
   340 	         iBmpDevice[i]->Resize( iBitmap[i]->SizeInPixels() ); 	
       
   341 	    	 }
       
   342 		 }
       
   343 	}
       
   344 
       
   345 // ---------------------------------------------------------
       
   346 // CMainTextArray::MdcaCount()
       
   347 //
       
   348 // ---------------------------------------------------------
       
   349 //
       
   350 TInt CMainTextArray::MdcaCount() const
       
   351     {
       
   352     return(iColourNmbr);
       
   353     }
       
   354 
       
   355 // ---------------------------------------------------------
       
   356 // CMainTextArray::MdcaPoint()
       
   357 //
       
   358 // ---------------------------------------------------------
       
   359 //
       
   360 TPtrC CMainTextArray::MdcaPoint(TInt aIndex) const
       
   361     {
       
   362     TRAP_IGNORE(
       
   363         {
       
   364 
       
   365         CFbsBitGc* fbsBitGc = CFbsBitGc::NewL();
       
   366         CleanupStack::PushL( fbsBitGc );
       
   367         
       
   368         fbsBitGc->Activate(iBmpDevice[aIndex]);
       
   369 
       
   370         fbsBitGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   371         if (aIndex < iColourNmbr)
       
   372             {
       
   373             fbsBitGc->SetBrushColor(iColours->At(aIndex));
       
   374             }
       
   375         fbsBitGc->Clear();
       
   376 
       
   377         CleanupStack::PopAndDestroy(); // fbsBitGc
       
   378         });
       
   379     //fix for TSW error AJUA-7MTAXE
       
   380     iString->Des().Num(aIndex); 
       
   381     
       
   382     return *iString;
       
   383     }
       
   384 
   196 // CLASS DECLARATION
   385 // CLASS DECLARATION
   197 
   386 
   198 /**
   387 /**
   199 * CColorGridView
   388 * CColorGridView
   200 *
   389 *
   392         colourCellSize.LayoutRect(gridRect, AknLayoutScalable_Avkon::aid_size_cell_colour_1_pane(1));
   581         colourCellSize.LayoutRect(gridRect, AknLayoutScalable_Avkon::aid_size_cell_colour_1_pane(1));
   393         }
   582         }
   394 
   583 
   395     TInt cellWidth = colourCellSize.Rect().Width() - 1;
   584     TInt cellWidth = colourCellSize.Rect().Width() - 1;
   396     TInt cellHeight = colourCellSize.Rect().Height() - 1;
   585     TInt cellHeight = colourCellSize.Rect().Height() - 1;
       
   586     
       
   587     TAknLayoutRect r;
       
   588     TAknLayoutRect rectPane;
       
   589     rectPane.LayoutRect( gridRect, 
       
   590                        AknLayoutScalable_Avkon::cell_large_graphic_colour_popup_pane( 
       
   591                     		                                                          iNoneExist, 
       
   592                     		                                                          0, 
       
   593                     		                                                          0 ).LayoutLine() );
       
   594     r.LayoutRect( rectPane.Rect(), 
       
   595     		      AknLayoutScalable_Avkon::cell_large_graphic_colour_popup_pane_g1().LayoutLine() );
       
   596     MDesCArray* iconArray = Model()->ItemTextArray();
       
   597     static_cast<CMainTextArray*>(iconArray)->ReSizeIcons( r.Rect().Width(), r.Rect().Height() );
   397     
   598     
   398     // Define the overall size of the cell
   599     // Define the overall size of the cell
   399     AknListBoxLayouts::SetupGridPos(*this, 0, 0, 0, 0, cellWidth, cellHeight);
   600     AknListBoxLayouts::SetupGridPos(*this, 0, 0, 0, 0, cellWidth, cellHeight);
   400     
   601     
   401     TPoint pointLT(0,0);
   602     TPoint pointLT(0,0);
  1336         }
  1537         }
  1337     _AKNTRACE_FUNC_EXIT;
  1538     _AKNTRACE_FUNC_EXIT;
  1338     }
  1539     }
  1339     
  1540     
  1340 
  1541 
  1341 // CLASS DECLARATION
  1542 
  1342 
       
  1343 /**
       
  1344 * CMainTextArray
       
  1345 *
       
  1346 * 
       
  1347 *
       
  1348 *  @lib avkon
       
  1349 *  @since 2.0
       
  1350 */
       
  1351 
       
  1352 NONSHARABLE_CLASS(CMainTextArray) : public MDesCArray, public CBase
       
  1353     {
       
  1354     public:
       
  1355 
       
  1356         /**
       
  1357         * C++ default constructor.
       
  1358         */
       
  1359         CMainTextArray(TBool &aNoneExist);
       
  1360         /**
       
  1361         * Destructor.
       
  1362         */
       
  1363         ~CMainTextArray();
       
  1364     
       
  1365         /**
       
  1366         * MdcaCount
       
  1367         * @since 2.0
       
  1368         * @return 
       
  1369         */
       
  1370         virtual TInt MdcaCount() const;
       
  1371         
       
  1372         /**
       
  1373         * MdcaPoint
       
  1374         * @since 2.0
       
  1375         * @param aIndex 
       
  1376         * @return 
       
  1377         */
       
  1378         virtual TPtrC MdcaPoint(TInt aIndex) const;
       
  1379         
       
  1380         /**
       
  1381         * ConstructL
       
  1382         * @since 2.0
       
  1383         * @param aColours Array of colours to be in grid
       
  1384         */
       
  1385         void ConstructL(CArrayFixFlat<TRgb>* aColours);
       
  1386 
       
  1387     public: // Data
       
  1388         CGulIcon* iIcon[16];
       
  1389 
       
  1390     private:    // Data
       
  1391         mutable TInt iIndex;
       
  1392         TInt iColourNmbr;
       
  1393         TBool iNoneExist;
       
  1394         CArrayFixFlat<TRgb>* iColours;
       
  1395         CFbsBitmap* iBitmap[16];
       
  1396         CFbsBitmapDevice* iBmpDevice[16];
       
  1397         HBufC *iString;
       
  1398 
       
  1399     };
       
  1400 
       
  1401 // ---------------------------------------------------------
       
  1402 // CMainTextArray::CMainTextArray()
       
  1403 //
       
  1404 // ---------------------------------------------------------
       
  1405 //
       
  1406 CMainTextArray::CMainTextArray(TBool &aNoneExist)
       
  1407         : iNoneExist(aNoneExist)
       
  1408     {
       
  1409     }
       
  1410 // ---------------------------------------------------------
       
  1411 // CMainTextArray::~CMainTextArray()
       
  1412 //
       
  1413 // ---------------------------------------------------------
       
  1414 //
       
  1415 CMainTextArray::~CMainTextArray()
       
  1416     {
       
  1417     for (TInt i = 0;i<iColourNmbr;i++)
       
  1418         {
       
  1419         delete iBitmap[i];
       
  1420         delete iBmpDevice[i];
       
  1421         }
       
  1422     delete iString;
       
  1423     }
       
  1424 
       
  1425 // ---------------------------------------------------------
       
  1426 // CMainTextArray::ConstructL()
       
  1427 // 
       
  1428 // ---------------------------------------------------------
       
  1429 //
       
  1430 void CMainTextArray::ConstructL(CArrayFixFlat<TRgb>* aColours)
       
  1431     {
       
  1432 
       
  1433     this->iColours = aColours;
       
  1434     iColourNmbr = aColours->Count();
       
  1435     if (iColourNmbr > 16)
       
  1436         {
       
  1437         iColourNmbr = 16;
       
  1438         }
       
  1439 
       
  1440     TAknLayoutRect r;
       
  1441     TAknLayoutRect r_pane;
       
  1442     TInt w, h;
       
  1443         r_pane.LayoutRect(TRect(0,0,0,0), AknLayoutScalable_Avkon::cell_large_graphic_colour_popup_pane(iNoneExist, 0, 0).LayoutLine());
       
  1444         r.LayoutRect(r_pane.Rect(), AknLayoutScalable_Avkon::cell_large_graphic_colour_popup_pane_g1().LayoutLine());
       
  1445         w = r.Rect().Width();
       
  1446         h = r.Rect().Height();
       
  1447     TSize bmpsize(w,h);
       
  1448 
       
  1449     for (TInt i = 0;i<iColourNmbr;i++)
       
  1450         {
       
  1451         iBitmap[i] = new (ELeave) CFbsBitmap();
       
  1452         iBitmap[i]->Create(bmpsize,EColor4K);
       
  1453         iIcon[i] = CGulIcon::NewL(iBitmap[i]);
       
  1454         iIcon[i]->SetBitmapsOwnedExternally(ETrue);
       
  1455         iBmpDevice[i] = CFbsBitmapDevice::NewL(iBitmap[i]);
       
  1456         iBmpDevice[i]->Resize(iBitmap[i]->SizeInPixels());
       
  1457         }
       
  1458 
       
  1459     iString = HBufC::NewL(10);
       
  1460     }
       
  1461 
       
  1462 
       
  1463 // ---------------------------------------------------------
       
  1464 // CMainTextArray::MdcaCount()
       
  1465 //
       
  1466 // ---------------------------------------------------------
       
  1467 //
       
  1468 TInt CMainTextArray::MdcaCount() const
       
  1469     {
       
  1470     return(iColourNmbr);
       
  1471     }
       
  1472 
       
  1473 // ---------------------------------------------------------
       
  1474 // CMainTextArray::MdcaPoint()
       
  1475 //
       
  1476 // ---------------------------------------------------------
       
  1477 //
       
  1478 TPtrC CMainTextArray::MdcaPoint(TInt aIndex) const
       
  1479     {
       
  1480     TRAP_IGNORE(
       
  1481         {
       
  1482 
       
  1483         CFbsBitGc* fbsBitGc = CFbsBitGc::NewL();
       
  1484         CleanupStack::PushL( fbsBitGc );
       
  1485 
       
  1486         fbsBitGc->Activate(iBmpDevice[aIndex]);
       
  1487 
       
  1488         fbsBitGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1489         if (aIndex < iColourNmbr)
       
  1490             {
       
  1491             fbsBitGc->SetBrushColor(iColours->At(aIndex));
       
  1492             }
       
  1493 
       
  1494         fbsBitGc->Clear();
       
  1495 
       
  1496         CleanupStack::PopAndDestroy(); // fbsBitGc
       
  1497         });
       
  1498     //fix for TSW error AJUA-7MTAXE
       
  1499     iString->Des().Num(aIndex); 
       
  1500     
       
  1501     return *iString;
       
  1502     }
       
  1503 
  1543 
  1504 // ============================ MEMBER FUNCTIONS ===============================
  1544 // ============================ MEMBER FUNCTIONS ===============================
  1505 
  1545 
  1506 // ----------------------------------------------------------------------------
  1546 // ----------------------------------------------------------------------------
  1507 // Extension class
  1547 // Extension class