phonebookui/Phonebook2/UIControls/src/CPbk2ContactViewListBox.cpp
branchRCL_3
changeset 58 d4f567ce2e7c
parent 57 2666d9724c76
child 64 c1e8ba0c2b16
--- a/phonebookui/Phonebook2/UIControls/src/CPbk2ContactViewListBox.cpp	Thu Jul 15 18:22:55 2010 +0300
+++ b/phonebookui/Phonebook2/UIControls/src/CPbk2ContactViewListBox.cpp	Thu Aug 19 09:41:07 2010 +0300
@@ -41,6 +41,7 @@
 
 #include <aknappui.h>
 #include <aknViewAppUi.h>
+#include <aknlayoutscalable_avkon.cdl.h>
 
 // Debugging headers
 #include <Pbk2Debug.h>
@@ -59,6 +60,7 @@
 // LOCAL FUNCTIONS
 
 _LIT( KTabChar, "\t" );
+const TInt KCheckboxMargin = 1; // Checkbox margin pixels
 
 /**
  * Returns icon array from given list box.
@@ -109,7 +111,8 @@
                 iContainer(aContainer), 
                 iChangedIndexes( 1 ), // allocation granularity
                 iUiExtension( aUiExtension ),
-                iSearchFilter( aSearchFilter )
+                iSearchFilter( aSearchFilter ),
+                iMarkingModeOn( EFalse )
     {
     }
 
@@ -442,9 +445,28 @@
 TBool CPbk2ContactViewListBox::ClipFromBeginning
         ( TDes& aBuffer, TInt aItemIndex, TInt aSubCellNumber )
     {
-    return AknTextUtils::ClipToFit( aBuffer,
-        AknTextUtils::EClipFromBeginning, this,  aItemIndex,
-        aSubCellNumber );
+    CColumnListBoxData *data = ItemDrawer()->ColumnData();
+    const CFont *font =
+        data->Font(ItemDrawer()->Properties(aItemIndex), aSubCellNumber);
+    // The width of the subcell displaying the characters.
+    TInt cellWidth = data->ColumnWidthPixel(aSubCellNumber);
+    // The margin of the subcell.
+    TMargins margin = data->ColumnMargins(aSubCellNumber);
+    // The valid width width displaying the characters.
+    TInt width = cellWidth - margin.iLeft - margin.iRight;
+    // If Marking mode is active, recalculate the valid width displaying characters.
+    // contact entry of name list view in marking mode
+    //
+    // |checkbox|Icon|name  |
+    // |        |    |number|
+    if( iMarkingModeOn )
+        {
+        RecalcWidthInMarkingMode(width, *font, aBuffer[0]);
+        }
+    TInt clipGap = data->ColumnTextClipGap(aSubCellNumber);
+    
+    return AknTextUtils::ClipToFit(
+        aBuffer, *font, width, AknTextUtils::EClipFromBeginning, width + clipGap);
     }
 
 // --------------------------------------------------------------------------
@@ -531,9 +553,9 @@
         }
     // Wrap the original model.
     iListboxModelDecorator = DoCreateDecoratorL( 
-    		*IconArray( *this ),
-			iResourceData.iEmptyIconId,
-			iResourceData.iDefaultIconId );
+            *IconArray( *this ),
+            iResourceData.iEmptyIconId,
+            iResourceData.iDefaultIconId );
     
     
     iListboxModelDecorator->SetDecoratedModel( *iModel );
@@ -557,15 +579,15 @@
 // --------------------------------------------------------------------------
 //
 CPbk2ListboxModelCmdDecorator* CPbk2ContactViewListBox::DoCreateDecoratorL( 
-        		const CPbk2IconArray& aIconArray,
-        		TPbk2IconId aEmptyIconId,
-        		TPbk2IconId aDefaultIconId )
-	{
-	return CPbk2ListboxModelCmdDecorator::NewL(
-				aIconArray,
-				aEmptyIconId,
-				aDefaultIconId );
-	}
+                const CPbk2IconArray& aIconArray,
+                TPbk2IconId aEmptyIconId,
+                TPbk2IconId aDefaultIconId )
+    {
+    return CPbk2ListboxModelCmdDecorator::NewL(
+                aIconArray,
+                aEmptyIconId,
+                aDefaultIconId );
+    }
 
 
 // --------------------------------------------------------------------------
@@ -622,7 +644,7 @@
 //
 void CPbk2ContactViewListBox::HandleGainingForeground()
     {
-	DrawDeferred();
+    DrawDeferred();
     }
 
 // --------------------------------------------------------------------------
@@ -704,7 +726,7 @@
         textLayout.LayoutText(layout.Rect(), AknLayoutScalable_Apps::popup_navstr_preview_pane_t1(0).LayoutLine());
 
         TPtrC desc(Model()->ItemTextArray()->MdcaPoint(View()->TopItemIndex()));
-		
+        
         //Add "if-clause" to avaid the error that argument of Mid() out of range.
         TInt index = desc.Find( KTabChar );
         if ( index != KErrNotFound && index < desc.Length()-1 )
@@ -720,4 +742,56 @@
             }
         }
     }
+
+// --------------------------------------------------------------------------
+// CPbk2ContactViewListBox::RecalcWidthInMarkingMode
+// Recalculate the width of space displaying the third column of the schema
+// below when Marking Mode is active.
+// contact entry of name list view in marking mode
+// The schema:
+// |checkbox|Icon|name  |
+// |        |    |number|
+// --------------------------------------------------------------------------
+//
+void CPbk2ContactViewListBox::RecalcWidthInMarkingMode(
+                              TInt& aWidth,
+                              const CFont& aFont,
+                              TChar aChar )
+    {
+    if( aWidth > 0 )
+        {
+        aWidth -= KCheckboxMargin;
+        // Get the coordinate for the right margin of the checkbox.
+        TInt checkBoxRight = AknLayoutScalable_Avkon::list_single_graphic_pane_t1( 0 ).r();
+        // Get the coordinate for the left margin of the checkbox.
+        TInt checkBoxLeft = AknLayoutScalable_Avkon::list_single_graphic_pane_t1( 0 ).l();
+        // The width to display one char.
+        TInt charWidth = aFont.CharWidthInPixels(aChar);
+        TInt checkBoxWidth = checkBoxRight - checkBoxLeft;
+        if( 0 > checkBoxWidth )
+            {
+            checkBoxWidth *= -1; // To make sure the value is positive.
+            }
+        if( charWidth > 0 && checkBoxWidth > 0 )
+            {
+            // The width of the characters which should be dropped, when marking
+            // mode is active.
+            TInt width;
+            if( 0 == checkBoxWidth%charWidth )
+                {
+                width = checkBoxWidth;
+                }
+            else
+                {
+                // The width should be divisible by charWidth.
+                width = ( checkBoxWidth/charWidth + 1 ) * charWidth;
+                }
+            // When marking mode is on,
+            // the width should minus the part of checkbox in the front of
+            // a listbox item.
+            aWidth -= width;
+            }
+        }
+    }
+
 // End of File