|
1 /* |
|
2 * Copyright (c) 2003-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Array of chat info structure |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CCAChatInfoArrayPC.h" |
|
21 #include "ChatDefinitions.h" |
|
22 #include <eikenv.h> |
|
23 #include <aknutils.h> |
|
24 #include <aknlayoutscalable_avkon.cdl.h> |
|
25 |
|
26 // ================= MEMBER FUNCTIONS ======================= |
|
27 |
|
28 // C++ default constructor can NOT contain any code, that |
|
29 // might leave. |
|
30 // |
|
31 CCAChatInfoArray::CCAChatInfoArray() |
|
32 { |
|
33 } |
|
34 |
|
35 // Symbian OS default constructor can leave. |
|
36 void CCAChatInfoArray::ConstructL() |
|
37 { |
|
38 iLine = HBufC::NewL( KMaxLengthOfHBufC + KMaxTabLength ); |
|
39 iTextFields = new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
40 iLineWidthArray = new ( ELeave ) CArrayFixFlat<TInt>( KArrayGranularity ); |
|
41 |
|
42 iFont = LatinBold13(); // LAF |
|
43 |
|
44 TAknLayoutRect temp, layout; |
|
45 TAknLayoutText myLayoutText; |
|
46 |
|
47 TRect myMainPaneRect; |
|
48 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
49 myMainPaneRect ); |
|
50 |
|
51 layout.LayoutRect( myMainPaneRect, AknLayoutScalable_Avkon::main_pane( 1 ) ); |
|
52 temp.LayoutRect( layout.Rect(), AknLayoutScalable_Avkon::popup_menu_window( 13 ) ); |
|
53 layout.LayoutRect( temp.Rect(), AknLayoutScalable_Avkon::listscroll_menu_pane( 0 ) ); |
|
54 temp.LayoutRect( layout.Rect(), AknLayoutScalable_Avkon::list_menu_pane( 0 ) ); |
|
55 myLayoutText.LayoutText( temp.Rect(), |
|
56 AknLayoutScalable_Avkon::list_single_heading_pane_t1_cp2( 0 ) ); |
|
57 |
|
58 iFont = myLayoutText.Font(); |
|
59 |
|
60 |
|
61 iSubCellWidth = myLayoutText.TextRect().Size().iWidth; // * 4 / 11; |
|
62 |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------- |
|
66 // CCAChatInfoArray::SetLineWidthArrayL() |
|
67 // Sets the linewidth array full of integers |
|
68 // (other items were commented in a header). |
|
69 // --------------------------------------------------------- |
|
70 // |
|
71 void CCAChatInfoArray::SetLineWidthArrayL( CArrayFix<TInt>* aLineWidthArray, |
|
72 const TDesC& aTextField ) |
|
73 { |
|
74 |
|
75 |
|
76 TInt maxSize( iFont->TextWidthInPixels( aTextField ) / iSubCellWidth ); |
|
77 for ( TInt i( 0 ); i <= maxSize; ++i ) |
|
78 { |
|
79 aLineWidthArray->AppendL( iSubCellWidth ); |
|
80 } |
|
81 } |
|
82 |
|
83 // Two-phased constructor. |
|
84 CCAChatInfoArray* CCAChatInfoArray::NewL() |
|
85 { |
|
86 CCAChatInfoArray* self = new ( ELeave ) CCAChatInfoArray; |
|
87 |
|
88 CleanupStack::PushL( self ); |
|
89 self->ConstructL(); |
|
90 CleanupStack::Pop(); //Codescanner warning ignored |
|
91 return self; |
|
92 } |
|
93 |
|
94 // Destructor |
|
95 CCAChatInfoArray::~CCAChatInfoArray() |
|
96 { |
|
97 delete iLine; |
|
98 delete iTextFields; |
|
99 delete iLineWidthArray; |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------- |
|
103 // CCAChatInfoArray::AddLabelAndTextL() |
|
104 // Add labels and field texts to array |
|
105 // (other items were commented in a header). |
|
106 // --------------------------------------------------------- |
|
107 // |
|
108 void CCAChatInfoArray::AddLabelAndTextL( TInt aLabelResourceId, |
|
109 const TDesC& aFieldText, |
|
110 TBool /*aWrap*/ ) |
|
111 { |
|
112 SetLineWidthArrayL( iLineWidthArray, aFieldText ); |
|
113 |
|
114 //temp array that contains TPtrC values. Number 1 is granularity |
|
115 CArrayFixFlat<TPtrC>* tempArray = new ( ELeave ) CArrayFixFlat<TPtrC>( 1 ); |
|
116 CleanupStack::PushL( tempArray ); |
|
117 AknTextUtils::WrapToArrayL( aFieldText, *iLineWidthArray, *iFont, |
|
118 *tempArray ); |
|
119 |
|
120 HBufC* itemBuf = HBufC::NewLC( KMaxLengthOfHBufC ); |
|
121 TPtr itemPtr( itemBuf->Des() ); |
|
122 |
|
123 // since we can not appui fromave to pc |
|
124 // hence codescanner warning can be ignored |
|
125 HBufC* label = CEikonEnv::Static()-> |
|
126 AllocReadResourceLC( aLabelResourceId ); |
|
127 |
|
128 TInt arrayCount( tempArray->Count() ); |
|
129 for ( TInt i( 0 ); i < arrayCount; i++ ) |
|
130 { |
|
131 itemPtr.Copy( tempArray->At( i ).Left( itemPtr.MaxLength() ) ); |
|
132 itemPtr.Insert( 0, KTabulator ); |
|
133 if ( i == 0 ) |
|
134 { |
|
135 itemPtr.Insert( 0, *label ); |
|
136 } |
|
137 iTextFields->AppendL( *itemBuf ); |
|
138 itemPtr.Zero(); |
|
139 } |
|
140 //Codescanner warning ignored |
|
141 CleanupStack::PopAndDestroy( 3, tempArray ); // itemBuf, label, tempArray |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------- |
|
145 // CCAChatInfoArray::MdcaCount() const |
|
146 // Returns number of items that are in array |
|
147 // (other items were commented in a header). |
|
148 // --------------------------------------------------------- |
|
149 // |
|
150 TInt CCAChatInfoArray::MdcaCount() const |
|
151 { |
|
152 __ASSERT_ALWAYS( iTextFields, |
|
153 User::Panic( KPanicText, EChatInfoArrayNotExists ) ); |
|
154 return iTextFields->MdcaCount(); |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------- |
|
158 // CCAChatInfoArray::MdcaPoint( TInt aIndex ) const |
|
159 // Returns formatted descriptor for given index |
|
160 // (other items were commented in a header). |
|
161 // --------------------------------------------------------- |
|
162 // |
|
163 TPtrC CCAChatInfoArray::MdcaPoint( TInt aIndex ) const |
|
164 { |
|
165 __ASSERT_ALWAYS( iTextFields, |
|
166 User::Panic( KPanicText, EChatInfoArrayNotExists ) ); |
|
167 |
|
168 __ASSERT_DEBUG( aIndex >= 0, |
|
169 User::Panic( KPanicText, EChatInfoArrayIndexOutOfBounds ) ); |
|
170 |
|
171 __ASSERT_DEBUG( aIndex < iTextFields->MdcaCount(), |
|
172 User::Panic( KPanicText, EChatInfoArrayIndexOutOfBounds ) ) ; |
|
173 |
|
174 return iTextFields->MdcaPoint( aIndex ); |
|
175 } |
|
176 |
|
177 // End of File |