4050 if (font==NULL) |
4063 if (font==NULL) |
4051 { |
4064 { |
4052 font=CEikonEnv::Static()->NormalFont(); |
4065 font=CEikonEnv::Static()->NormalFont(); |
4053 } |
4066 } |
4054 |
4067 |
4055 TInt extraVerticalSpace=(aRect.Height()-font->HeightInPixels()); |
|
4056 TInt baseLineOffset=extraVerticalSpace/2+font->AscentInPixels(); |
|
4057 TRect textRect=aRect; |
4068 TRect textRect=aRect; |
4058 textRect.iBr.iX=aRect.iTl.iX; |
4069 textRect.iBr.iX=aRect.iTl.iX; |
4059 TInt subcell=0; |
4070 TInt subcell=0; |
4060 TInt subcell2=0; |
4071 TInt subcell2=0; |
4061 TPtrC text; |
4072 |
4062 TBool textNull[30]; |
4073 TCellInfo textNull[30]; |
4063 TRgb bmpBackColor, bmpForeColor; |
|
4064 TRect textShadowRect; // For transparent list |
4074 TRect textShadowRect; // For transparent list |
4065 TRgb textShadowColour = AKN_LAF_COLOR_STATIC(215); // Black shadow for item text. |
4075 TRgb textShadowColour = AKN_LAF_COLOR_STATIC(215); // Black shadow for item text. |
4066 |
4076 |
4067 MAknsControlContext *cc = AknsDrawUtils::ControlContext( Control() ); |
|
4068 TBool layoutMirrored = AknLayoutUtils::LayoutMirrored(); |
4077 TBool layoutMirrored = AknLayoutUtils::LayoutMirrored(); |
4069 TBool skinEnabled = AknsUtils::AvkonSkinEnabled(); |
4078 TBool skinEnabled = AknsUtils::AvkonSkinEnabled(); |
4070 |
4079 |
4071 if (!cc) |
|
4072 { |
|
4073 cc = SkinBackgroundContext(); |
|
4074 } |
|
4075 |
|
4076 Mem::FillZ( textNull, sizeof( textNull ) ); |
|
4077 |
4080 |
4078 // cache the text states. |
4081 // cache the text states. |
4079 subcell = 0; |
4082 subcell = 0; |
|
4083 |
|
4084 SSubCell defaultCell; |
|
4085 TMargins tm = {0,0,0,0}; |
|
4086 defaultCell.iPosition = TPoint(0,0); |
|
4087 defaultCell.iSize = TSize(0,0); |
|
4088 defaultCell.iRealSize = TSize(0,0); |
|
4089 defaultCell.iRealTextSize = TSize(0,0); |
|
4090 defaultCell.iMargin = tm; |
|
4091 defaultCell.iUseSubCellColors = EFalse; |
|
4092 defaultCell.iColors = defaultcolors; |
|
4093 defaultCell.iGraphics = EFalse; |
|
4094 defaultCell.iAlign = CGraphicsContext::ELeft; |
|
4095 defaultCell.iBaseline = 0; |
|
4096 defaultCell.iNumberCell = EFalse; |
|
4097 defaultCell.iTextClipGap = 0; |
|
4098 defaultCell.iNotAlwaysDrawn = EFalse; |
|
4099 defaultCell.iTransparent = EFalse; |
|
4100 defaultCell.iBaseFont = 0; |
|
4101 SSubCell* sc; |
|
4102 |
|
4103 |
4080 for(;;) |
4104 for(;;) |
4081 { |
4105 { |
4082 if (subcell>lastSubCell) |
4106 if (subcell>lastSubCell) |
4083 { |
4107 { |
4084 break; |
4108 break; |
4085 } |
4109 } |
4086 |
4110 |
4087 TextUtils::ColumnText(text,subcell, aText); |
4111 TInt subcellindex = 0; |
4088 if (text == KNullDesC && SubCellIsNotAlwaysDrawn(subcell)) |
4112 TInt subcellfound = 0; |
4089 { |
4113 subcellfound = FindSubCellIndex(subcellindex,subcell); |
4090 textNull[subcell] = ETrue; |
4114 if (subcellfound != KErrNotFound) |
|
4115 { |
|
4116 sc = &(iSubCellArray->At(subcellindex)); |
|
4117 } |
|
4118 else |
|
4119 { |
|
4120 sc = &defaultCell; |
|
4121 } |
|
4122 |
|
4123 TextUtils::ColumnText(textNull[subcell].iTextPtr,subcell, aText); |
|
4124 |
|
4125 if (textNull[subcell].iTextPtr == KNullDesC && sc->iNotAlwaysDrawn) |
|
4126 { |
|
4127 textNull[subcell].iTextNull = ETrue; |
|
4128 } |
|
4129 else |
|
4130 { |
|
4131 textNull[subcell].iTextNull = EFalse; |
4091 } |
4132 } |
4092 |
4133 |
4093 subcell++; |
4134 subcell++; |
4094 } |
4135 } |
4095 |
4136 |
4101 if (subcell>lastSubCell) |
4142 if (subcell>lastSubCell) |
4102 { |
4143 { |
4103 break; |
4144 break; |
4104 } |
4145 } |
4105 |
4146 |
4106 if (textNull[subcell]) |
4147 if (textNull[subcell].iTextNull) |
4107 { |
4148 { |
4108 ++subcell; |
4149 ++subcell; |
4109 continue; |
4150 continue; |
4110 } |
4151 } |
4111 |
4152 |
4112 TRect bRect(SubCellPosition(subcell),SubCellSize(subcell)); |
4153 TInt subcellindex = 0; |
4113 TMargins m(SubCellMargins(subcell)); |
4154 TInt subcellfound = 0; |
4114 TRect cRect(bRect.iTl+TSize(m.iLeft,m.iTop),bRect.Size()-TSize(m.iRight+m.iLeft,m.iBottom+m.iTop)); |
4155 subcellfound = FindSubCellIndex(subcellindex,subcell); |
|
4156 if (subcellfound != KErrNotFound) |
|
4157 { |
|
4158 sc = &(iSubCellArray->At(subcellindex)); |
|
4159 } |
|
4160 else |
|
4161 { |
|
4162 sc = &defaultCell; |
|
4163 } |
4115 |
4164 |
4116 for (subcell2=subcell+1; subcell2<=lastSubCell; subcell2++) |
4165 TRect bRect = TRect(sc->iPosition,sc->iSize); |
4117 { |
4166 TMargins m = sc->iMargin; |
4118 if (textNull[subcell2]) |
4167 TRect cRect = TRect(bRect.iTl+TSize(m.iLeft,m.iTop),bRect.Size()-TSize(m.iRight+m.iLeft,m.iBottom+m.iTop)); |
|
4168 const TBool istrans = sc->iTransparent; |
|
4169 if (!layoutMirrored) |
|
4170 { |
|
4171 for (subcell2=subcell+1; subcell2<=lastSubCell; subcell2++) |
4119 { |
4172 { |
4120 continue; |
4173 if (textNull[subcell2].iTextNull) |
4121 } |
4174 { |
4122 |
4175 continue; |
4123 // This is called O(N^2) times - Do not put anything extra to it, it'll slow down drawing! |
4176 } |
4124 TRect bRect2 = TRect(SubCellPosition(subcell2),SubCellSize(subcell2)); |
4177 |
4125 if (cRect.Intersects(bRect2) && bRect.Intersects(bRect2) && !SubCellIsTransparent(subcell) && !SubCellIsTransparent(subcell2)) |
4178 // This is called O(N^2) times - Do not put anything extra to it, it'll slow down drawing! |
4126 { |
4179 TRect bRect2 = TRect(SubCellPosition(subcell2),SubCellSize(subcell2)); |
4127 if (!layoutMirrored) |
4180 if (cRect.Intersects(bRect2) && bRect.Intersects(bRect2) && !istrans && !SubCellIsTransparent(subcell2)) |
4128 { |
4181 { |
4129 cRect.iBr.iX = bRect2.iTl.iX; |
4182 cRect.iBr.iX = bRect2.iTl.iX; |
4130 bRect.iBr.iX = bRect2.iTl.iX; |
4183 bRect.iBr.iX = bRect2.iTl.iX; |
4131 } |
4184 } |
4132 else |
4185 } |
|
4186 } |
|
4187 else |
|
4188 { |
|
4189 for (subcell2=subcell+1; subcell2<=lastSubCell; subcell2++) |
|
4190 { |
|
4191 if (textNull[subcell2].iTextNull) |
|
4192 { |
|
4193 continue; |
|
4194 } |
|
4195 |
|
4196 // This is called O(N^2) times - Do not put anything extra to it, it'll slow down drawing! |
|
4197 TRect bRect2 = TRect(SubCellPosition(subcell2),SubCellSize(subcell2)); |
|
4198 if (cRect.Intersects(bRect2) && bRect.Intersects(bRect2) && !istrans && !SubCellIsTransparent(subcell2)) |
4133 { |
4199 { |
4134 cRect.iTl.iX = bRect2.iBr.iX; |
4200 cRect.iTl.iX = bRect2.iBr.iX; |
4135 bRect.iTl.iX = bRect2.iBr.iX; |
4201 bRect.iTl.iX = bRect2.iBr.iX; |
4136 } |
4202 } |
4137 } |
4203 } |
4138 } |
4204 } |
4139 SetSubCellRealTextSize(subcell, cRect.Size()); |
4205 SetSubCellRealTextSize(subcell, cRect.Size()); |
4140 SetSubCellRealSize(subcell, bRect.Size()); |
4206 SetSubCellRealSize(subcell, bRect.Size()); |
|
4207 sc->iRealTextSize = cRect.Size(); |
|
4208 sc->iRealSize = bRect.Size(); |
4141 subcell++; |
4209 subcell++; |
4142 } |
4210 } |
4143 |
4211 |
4144 // This loop does the drawing. |
4212 // This loop does the drawing. |
4145 aGc.SetPenStyle(CGraphicsContext::ENullPen); |
4213 aGc.SetPenStyle(CGraphicsContext::ENullPen); |
4149 if (subcell>lastSubCell) |
4217 if (subcell>lastSubCell) |
4150 { |
4218 { |
4151 break; |
4219 break; |
4152 } |
4220 } |
4153 |
4221 |
4154 if (textNull[subcell]) |
4222 if (textNull[subcell].iTextNull) |
4155 { |
4223 { |
4156 ++ subcell; |
4224 ++ subcell; |
4157 continue; |
4225 continue; |
4158 } |
4226 } |
4159 |
4227 |
|
4228 |
|
4229 TInt subcellindex = 0; |
|
4230 TInt subcellfound = 0; |
|
4231 subcellfound = FindSubCellIndex(subcellindex,subcell); |
|
4232 if (subcellfound != KErrNotFound) |
|
4233 { |
|
4234 sc = &(iSubCellArray->At(subcellindex)); |
|
4235 } |
|
4236 else |
|
4237 { |
|
4238 sc = &defaultCell; |
|
4239 } |
|
4240 |
4160 // SetPosition, SetSize and margins support |
4241 // SetPosition, SetSize and margins support |
4161 TRect bRect(SubCellPosition(subcell),SubCellRealSize(subcell)); |
4242 TRect bRect = TRect(sc->iPosition,sc->iRealSize); |
4162 TMargins m(SubCellMargins(subcell)); |
4243 TMargins m = sc->iMargin; |
4163 TRect cRect(bRect.iTl+TSize(m.iLeft,m.iTop),SubCellRealTextSize(subcell)); |
4244 TRect cRect = TRect(bRect.iTl+TSize(m.iLeft,m.iTop),sc->iRealTextSize); |
4164 |
4245 |
4165 |
4246 |
4166 if (bRect.iBr.iX == 0) |
4247 if (bRect.iBr.iX == 0) |
4167 { |
4248 { |
4168 ++subcell; |
4249 ++subcell; |
4169 continue; |
4250 continue; |
4170 } |
4251 } |
4171 |
4252 |
4172 if ( layoutMirrored ) |
4253 if ( layoutMirrored ) |
4173 { |
4254 { |
4174 TRect bRect = TRect(SubCellPosition(subcell),SubCellSize(subcell)); |
4255 TRect bRect = TRect(sc->iPosition,sc->iSize); |
4175 TRect cRect2 = TRect(bRect.iTl+TSize(m.iLeft,m.iTop),bRect.Size()-TSize(m.iRight+m.iLeft,m.iBottom+m.iTop)); |
4256 TRect cRect2 = TRect(bRect.iTl+TSize(m.iLeft,m.iTop),bRect.Size()-TSize(m.iRight+m.iLeft,m.iBottom+m.iTop)); |
4176 |
4257 |
4177 TInt shift = (cRect2.Size() - SubCellRealTextSize(subcell)).iWidth; |
4258 TInt shift = (cRect2.Size() - sc->iRealTextSize).iWidth; |
4178 cRect.iTl.iX += shift; |
4259 cRect.iTl.iX += shift; |
4179 cRect.iBr.iX += shift; |
4260 cRect.iBr.iX += shift; |
4180 } |
4261 } |
4181 |
4262 |
4182 textRect.SetRect(aItemRect.iTl+cRect.iTl,cRect.Size()); |
4263 textRect=TRect(aItemRect.iTl+cRect.iTl,cRect.Size()); |
4183 |
4264 |
4184 if (UseSubCellColors(subcell)) |
4265 if (sc->iUseSubCellColors) |
4185 { |
4266 { |
4186 subcellColors = &SubCellColors(subcell); |
4267 subcellColors = &sc->iColors; |
4187 } |
4268 } |
4188 else |
4269 else |
4189 { |
4270 { |
4190 subcellColors = &aColors; |
4271 subcellColors = &aColors; |
4191 } |
4272 } |
4192 |
4273 |
4193 if (aHighlight) |
4274 if (aHighlight) |
4194 { |
4275 { |
4195 aGc.SetPenColor(subcellColors->iHighlightedText); |
4276 aGc.SetPenColor(subcellColors->iHighlightedText); |
4196 aGc.SetBrushColor(subcellColors->iHighlightedBack); |
4277 aGc.SetBrushColor(subcellColors->iHighlightedBack); |
4197 bmpBackColor = subcellColors->iHighlightedBack; |
|
4198 bmpForeColor = subcellColors->iHighlightedText; |
|
4199 if ( skinEnabled && iExtension ) |
4278 if ( skinEnabled && iExtension ) |
4200 { |
4279 { |
4201 if ( iExtension->iHighlightedTextColor != NULL ) |
4280 if ( iExtension->iHighlightedTextColor != NULL ) |
4202 { |
4281 { |
4203 aGc.SetPenColor( iExtension->iHighlightedTextColor ); |
4282 aGc.SetPenColor( iExtension->iHighlightedTextColor ); |
4204 bmpForeColor = iExtension->iHighlightedTextColor; |
|
4205 } |
4283 } |
4206 } |
4284 } |
4207 } |
4285 } |
4208 else |
4286 else |
4209 { |
4287 { |
4210 aGc.SetPenColor(subcellColors->iText); |
4288 aGc.SetPenColor(subcellColors->iText); |
4211 aGc.SetBrushColor(subcellColors->iBack); |
4289 aGc.SetBrushColor(subcellColors->iBack); |
4212 bmpBackColor = subcellColors->iBack; |
|
4213 bmpForeColor = subcellColors->iText; |
|
4214 |
4290 |
4215 if ( skinEnabled && iExtension ) |
4291 if ( skinEnabled && iExtension ) |
4216 { |
4292 { |
4217 if ( iExtension->iTextColor != NULL ) |
4293 if ( iExtension->iTextColor != NULL ) |
4218 { |
4294 { |
4219 aGc.SetPenColor( iExtension->iTextColor ); |
4295 aGc.SetPenColor( iExtension->iTextColor ); |
4220 bmpForeColor = iExtension->iTextColor; |
|
4221 } |
4296 } |
4222 } |
4297 } |
4223 } |
4298 } |
4224 |
4299 |
4225 aGc.SetBrushStyle(CGraphicsContext::ENullBrush); |
4300 aGc.SetBrushStyle(CGraphicsContext::ENullBrush); |
4226 |
4301 |
4227 // The following draws subcells to textRect |
4302 // The following draws subcells to textRect |
4228 if (textRect.iBr.iX!=textRect.iTl.iX) |
4303 if (textRect.iBr.iX!=textRect.iTl.iX) |
4229 { |
4304 { |
4230 TextUtils::ColumnText(text,subcell,aText); |
|
4231 |
|
4232 // graphics or text column |
4305 // graphics or text column |
4233 CGraphicsContext::TTextAlign align=SubCellAlignment(subcell); |
4306 CGraphicsContext::TTextAlign align=sc->iAlign; |
4234 if (!SubCellIsGraphics(subcell)) |
4307 if (!sc->iGraphics) |
4235 { |
4308 { |
4236 const CFont* rowAndCellFont=RowAndSubCellFont(iExtension->iCurrentlyDrawnItemIndex,subcell); |
4309 const CFont* rowAndCellFont=RowAndSubCellFont(iExtension->iCurrentlyDrawnItemIndex,subcell); |
4237 const CFont* cellFont=Font(aProperties, subcell); |
4310 const CFont* cellFont=sc->iBaseFont; |
4238 const CFont* tempFont=(cellFont) ? cellFont : font; |
4311 const CFont* tempFont=(cellFont) ? cellFont : font; |
4239 const CFont* usedFont=(rowAndCellFont) ? rowAndCellFont : tempFont; |
4312 const CFont* usedFont=(rowAndCellFont) ? rowAndCellFont : tempFont; |
4240 aGc.UseFont(usedFont); |
4313 aGc.UseFont(usedFont); |
4241 SetUnderlineStyle( aProperties, aGc, subcell ); |
4314 SetUnderlineStyle( aProperties, aGc, subcell ); |
4242 |
4315 |
4243 // baseline calc needed for each cell. |
4316 // baseline calc needed for each cell. |
4244 baseLineOffset = SubCellBaselinePos(subcell); |
4317 TInt baseLineOffset = sc->iBaseline; |
4245 baseLineOffset -= cRect.iTl.iY; |
4318 baseLineOffset -= cRect.iTl.iY; |
4246 if (!baseLineOffset) |
4319 if (!baseLineOffset) |
4247 { |
4320 { |
4248 baseLineOffset = (cRect.Size().iHeight-usedFont->HeightInPixels())/2 + usedFont->AscentInPixels(); |
4321 baseLineOffset = (cRect.Size().iHeight-usedFont->HeightInPixels())/2 + usedFont->AscentInPixels(); |
4249 } |
4322 } |
4250 |
4323 |
4251 TBuf<KMaxColumnDataLength + KAknBidiExtraSpacePerLine> clipbuf = |
4324 TBuf<KMaxColumnDataLength + KAknBidiExtraSpacePerLine> clipbuf;// = sc->iColumnText.Left(KMaxColumnDataLength); |
4252 text.Left(KMaxColumnDataLength); |
|
4253 |
4325 |
4254 // Note that this potentially modifies the text so its lenght in pixels |
4326 // Note that this potentially modifies the text so its lenght in pixels |
4255 // might increase. Therefore, this should always be done before |
4327 // might increase. Therefore, this should always be done before |
4256 // wrapping/clipping text. In some cases, WordWrapListItem is called |
4328 // wrapping/clipping text. In some cases, WordWrapListItem is called |
4257 // before coming here. Is it certain that it is not done for number subcells? |
4329 // before coming here. Is it certain that it is not done for number subcells? |
4258 if (SubCellIsNumberCell(subcell)) |
4330 TBool bufset = EFalse; |
|
4331 if (sc->iNumberCell) |
4259 { |
4332 { |
|
4333 clipbuf = textNull[subcell].iTextPtr.Left(KMaxColumnDataLength); |
4260 AknTextUtils::LanguageSpecificNumberConversion(clipbuf); |
4334 AknTextUtils::LanguageSpecificNumberConversion(clipbuf); |
|
4335 bufset = ETrue; |
4261 } |
4336 } |
4262 |
4337 |
4263 TBool clipped( EFalse ); |
4338 TBool clipped( EFalse ); |
4264 TInt clipgap = SubCellTextClipGap( subcell ); |
4339 TInt clipgap = sc->iTextClipGap; |
4265 |
4340 |
4266 if ( iExtension->iUseLogicalToVisualConversion && |
4341 if ( iExtension->iUseLogicalToVisualConversion && |
4267 subcell != iExtension->iFirstWordWrappedSubcellIndex && |
4342 subcell != iExtension->iFirstWordWrappedSubcellIndex && |
4268 subcell != iExtension->iSecondWordWrappedSubcellIndex ) |
4343 subcell != iExtension->iSecondWordWrappedSubcellIndex ) |
4269 { |
4344 { |
4270 TInt maxClipWidth = textRect.Size().iWidth + clipgap; |
4345 TInt maxClipWidth = textRect.Size().iWidth + clipgap; |
4271 |
4346 |
4272 clipped = AknBidiTextUtils::ConvertToVisualAndClip( |
4347 clipped = AknBidiTextUtils::ConvertToVisualAndClip( |
4273 text.Left(KMaxColumnDataLength), |
4348 textNull[subcell].iTextPtr.Left(KMaxColumnDataLength), |
4274 clipbuf, |
4349 clipbuf, |
4275 *usedFont, |
4350 *usedFont, |
4276 textRect.Size().iWidth, |
4351 textRect.Width(), |
4277 maxClipWidth ); |
4352 maxClipWidth ); |
|
4353 } |
|
4354 else if (!bufset) |
|
4355 { |
|
4356 clipbuf = textNull[subcell].iTextPtr.Left(KMaxColumnDataLength); |
4278 } |
4357 } |
4279 |
4358 |
4280 if (clipped) |
4359 if (clipped) |
4281 { |
4360 { |
4282 if (!layoutMirrored) |
4361 if (!layoutMirrored) |