textrendering/word/SRC/WPLBOX.CPP
changeset 0 1fb32624e06b
equal deleted inserted replaced
-1:000000000000 0:1fb32624e06b
       
     1 /*
       
     2 * Copyright (c) 1997-2009 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <txtrich.h>
       
    20 
       
    21 #include <frmtlay.h>
       
    22 
       
    23 #include <prnsetup.h>
       
    24 
       
    25 #include <barsread.h>
       
    26 #include <badesca.h>
       
    27 
       
    28 #include <eikenv.h>
       
    29 #include <techview/eikrted.h>
       
    30 #include <techview/eiktbar.h>
       
    31 #include <techview/eiktxlbm.h>
       
    32 #include <techview/eikclbd.h>
       
    33 #include <techview/eiklbi.h>
       
    34 #include <techview/eikcmbut.h>
       
    35 #include <eikon.mbg>
       
    36 #include <gulicon.h>
       
    37 
       
    38 #include "WPAPPUI.H"
       
    39 #include <word.rsg>
       
    40 #include "WORD.HRH"
       
    41 #include <word.mbg>
       
    42 #include "WPLBOX.H"
       
    43 
       
    44 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    45 #include "txtfmlyr_internal.h"
       
    46 #endif
       
    47 
       
    48 const TInt KBmpListVertItemGap=8;
       
    49 const TInt KMaxTotalBorderBitmaps=8;
       
    50 
       
    51 CDesCArray* CWordAppUi::BuildFontNameListLC() const
       
    52     {
       
    53 	CDesCArray* fontList=new(ELeave) CDesCArrayFlat(4);
       
    54 	CleanupStack::PushL(fontList);
       
    55 	FontUtils::GetAvailableFontsL(*iCoeEnv->ScreenDevice(),*fontList,EGulNoSymbolFonts);
       
    56 	return fontList;
       
    57     }
       
    58 
       
    59 CDesCArray* CWordAppUi::BuildStyleNameListLC() const
       
    60 	{
       
    61 	const CStyleList& styleData=*iModel->StyleList();
       
    62 	TInt count=styleData.Count();
       
    63 	CDesCArray* styleList=new(ELeave) CDesCArrayFlat(count+1);  // +1 for Normal (global layers)
       
    64 	CleanupStack::PushL(styleList);
       
    65 	TParagraphStyleName name;
       
    66 	iCoeEnv->ReadResource(name,R_WORD_NORMAL);
       
    67 	styleList->AppendL(name);
       
    68 	for (TInt ii=0;ii<count;ii++)
       
    69 		{
       
    70 		name.Zero();
       
    71 		name.Append(styleData.At(ii).iStyle->iName);
       
    72 		styleList->AppendL(name);
       
    73 		}
       
    74 	styleList->Sort();
       
    75 	return styleList;
       
    76 	}
       
    77 
       
    78 CDesCArray* CWordAppUi::BuildAlignListLC(CArrayPtrFlat<CGulIcon>& aIcons) const
       
    79     {
       
    80 	CDesCArray* text = new(ELeave) CDesCArrayFlat(4);
       
    81 	CleanupStack::PushL(text);
       
    82 	for (TInt ii = (TInt)CParaFormat::ELeftAlign; ii <= (TInt)CParaFormat::EJustifiedAlign; ii++)
       
    83 		{
       
    84 		TBuf<8> buf;
       
    85 		buf.Num(ii);
       
    86 		buf.Append(TChar(KColumnListSeparator));
       
    87 		text->AppendL(buf);
       
    88 		CGulIcon* icon = STATIC_CAST(CGulIcon*, iEikonEnv->CreateIconL(TPtrC(), AlignmentBitmapId(ii)));
       
    89 		aIcons.AppendL(icon);
       
    90 		}
       
    91 	return text;
       
    92 	}
       
    93 
       
    94 
       
    95 TInt CWordAppUi::AlignmentBitmapId(TInt aId)const
       
    96 	{
       
    97 	switch(aId)
       
    98 		{
       
    99 		case(CParaFormat::ELeftAlign):
       
   100 			return EMbmEikonLefta;
       
   101 		case(CParaFormat::ECenterAlign):
       
   102 			return EMbmEikonCenta;
       
   103 		case(CParaFormat::ERightAlign):
       
   104 			return EMbmEikonRighta;
       
   105 		case(CParaFormat::EJustifiedAlign):
       
   106 			return EMbmEikonJusta;
       
   107 		default:
       
   108 			return EMbmEikonLefta;
       
   109 		}
       
   110 	}
       
   111 
       
   112 
       
   113 TInt CWordAppUi::FindFontName(CDesCArray* aFontList) const
       
   114 	{
       
   115 	TCharFormat charFormat;
       
   116 	TCharFormatMask charUndeterminedMask;
       
   117     const TCursorSelection selection=iRichEd->Selection();
       
   118 	Text()->GetCharFormat(charFormat,charUndeterminedMask,selection.LowerPos(),selection.Length());
       
   119 	//
       
   120 	TInt index=0;
       
   121 	if (aFontList->Find(charFormat.iFontSpec.iTypeface.iName,index))
       
   122         index=0; // !! reset if can't find - daft API to Find()
       
   123 	return index;
       
   124 	}
       
   125 
       
   126 TInt CWordAppUi::FindStyleName(CDesCArray* aStyleList) const
       
   127 	{
       
   128 	TInt index=0;
       
   129 	TParagraphStyleName name;
       
   130 	iCoeEnv->ReadResource(name , R_WORD_NORMAL);
       
   131     const TCursorSelection selection=iRichEd->Selection();
       
   132 	TBool styleChange;
       
   133 	const CParaFormatLayer* style=Text()->ParagraphStyle(styleChange,selection.LowerPos(),selection.Length());
       
   134 	TUid id=style->Type();
       
   135 	if (id==KNormalParagraphStyleUid)
       
   136 		aStyleList->Find(name,index);
       
   137 	else
       
   138 		aStyleList->Find(((CParagraphStyle*)style)->iName,index);
       
   139 	return index;
       
   140 	}
       
   141 
       
   142 TInt CWordAppUi::NearestHeightIndex() const
       
   143 	{
       
   144 	TCharFormat charFormat;
       
   145 	TCharFormatMask charUndeterminedMask;
       
   146 	const TCursorSelection selection=iRichEd->Selection();
       
   147 	Text()->GetCharFormat(charFormat,charUndeterminedMask,selection.LowerPos(),selection.Length());
       
   148 	const TInt heightInTwips=charFormat.iFontSpec.iHeight;
       
   149 	return FontUtils::IndexOfNearestHeight(*iTwipsList,heightInTwips);
       
   150 	}
       
   151 
       
   152 TInt CWordAppUi::FindAlignmentL() const
       
   153 	{
       
   154 	TInt index=0;
       
   155 	CParaFormat* paraFormat=CParaFormat::NewLC();
       
   156 	TParaFormatMask paraUndeterminedMask;
       
   157 	const TCursorSelection selection=iRichEd->Selection();
       
   158 	Text()->GetParaFormatL(paraFormat,paraUndeterminedMask,selection.LowerPos(),selection.Length());
       
   159 	if (!paraUndeterminedMask.AttribIsSet(EAttAlignment))
       
   160 		{
       
   161 		switch (paraFormat->iHorizontalAlignment)
       
   162 			{
       
   163 		case CParaFormat::ELeftAlign:
       
   164 			index=0;
       
   165 			break;
       
   166 		case CParaFormat::ECenterAlign:	
       
   167 			index=1;
       
   168 			break;
       
   169 		case CParaFormat::ERightAlign:
       
   170 			index=2;
       
   171 			break;
       
   172 		case CParaFormat::EJustifiedAlign:
       
   173 			index=3;
       
   174 			break;
       
   175 		default:
       
   176 			break;
       
   177 			}
       
   178 		}
       
   179 	CleanupStack::PopAndDestroy();
       
   180 	return index;
       
   181 	}
       
   182 
       
   183 CDesCArray* CWordAppUi::UpdateHeightListLC()
       
   184 	{
       
   185 	TCharFormat charFormat;
       
   186 	TCharFormatMask charUndeterminedMask;
       
   187     const TCursorSelection selection=iRichEd->Selection();
       
   188 	Text()->GetCharFormat(charFormat,charUndeterminedMask,selection.LowerPos(),selection.Length());
       
   189 	CDesCArray* pointsList=new(ELeave) CDesCArrayFlat(4);
       
   190 	CleanupStack::PushL(pointsList);
       
   191 	iTwipsList=new(ELeave) CArrayFixFlat<TInt>(4);
       
   192 	TInt err=FontUtils::GetAvailableHeightsInTwipsAndPointsL(*iCoeEnv->ScreenDevice(),charFormat.iFontSpec.iTypeface.iName,*iTwipsList,*pointsList);
       
   193 	if (err==KErrNotSupported)
       
   194 		{// This is a foreign font, so preserve current height only.
       
   195 		TBuf<4> num;
       
   196 		num.Num(FontUtils::PointsFromTwips(charFormat.iFontSpec.iHeight));
       
   197 		pointsList->AppendL(num);
       
   198 		iTwipsList->AppendL(charFormat.iFontSpec.iHeight);
       
   199 		}
       
   200 	return pointsList;
       
   201 	}
       
   202 
       
   203 void CWordAppUi::LaunchStylesPopupL()
       
   204 	{
       
   205 	if (iWordFlags & EStyleBoxPopped)
       
   206 		return;
       
   207 	CDesCArray* styleList = BuildStyleNameListLC();		
       
   208 	CEikCommandButtonBase* nameButton = STATIC_CAST(CEikCommandButtonBase*, iEikonEnv->AppUiFactory()->ToolBand()->ControlById(EWordButtonStyle));
       
   209 	const TInt index = FindStyleName(styleList);
       
   210 	DoCreatePopoutL(styleList, index, nameButton, EToolBand, EFalse);
       
   211 	iWordFlags |= EStyleBoxPopped;
       
   212 	}
       
   213 
       
   214 void CWordAppUi::LaunchFontsPopupL()
       
   215 	{
       
   216 	if (iWordFlags & EFNameBoxPopped)
       
   217 		return;
       
   218 	CDesCArray* fontList = BuildFontNameListLC();		
       
   219 	CEikCommandButtonBase* nameButton = STATIC_CAST(CEikCommandButtonBase*, iEikonEnv->AppUiFactory()->ToolBand()->ControlById(EWordButtonFont));
       
   220 	const TInt index = FindFontName(fontList);
       
   221 	DoCreatePopoutL(fontList, index, nameButton, EToolBand, ETrue);
       
   222 	iWordFlags |= EFNameBoxPopped;
       
   223 	}
       
   224 
       
   225 void CWordAppUi::LaunchAlignPopupL()
       
   226 	{
       
   227 	if (iWordFlags & EAlignBoxPopped)
       
   228 		return;
       
   229 	CArrayPtrFlat<CGulIcon>* icons = new(ELeave) CArrayPtrFlat<CGulIcon>(4);
       
   230 	CleanupStack::PushL(icons);
       
   231 	CDesCArray* text = BuildAlignListLC(*icons);		
       
   232 	CEikCommandButtonBase* nameButton = STATIC_CAST(CEikCommandButtonBase*, iEikonEnv->AppUiFactory()->ToolBand()->ControlById(EWordButtonAlign));
       
   233 	const TInt index = FindAlignmentL();
       
   234 	DoCreateBitmapPopoutL(text, icons, index, nameButton, EToolBand);
       
   235 	iWordFlags |= EAlignBoxPopped;
       
   236 	}
       
   237 
       
   238 void CWordAppUi::LaunchFontHeightsPopupL()
       
   239 	{
       
   240 	if (iWordFlags & EFHeightBoxPopped)
       
   241 		return;
       
   242 	CDesCArray* pointsList = UpdateHeightListLC();
       
   243 	CEikCommandButtonBase* sizeButton = STATIC_CAST(CEikCommandButtonBase*, iEikonEnv->AppUiFactory()->ToolBand()->ControlById(EWordButtonFontSize));
       
   244 	const TInt index = NearestHeightIndex();
       
   245 	DoCreatePopoutL(pointsList, index, sizeButton, EToolBand, ETrue);
       
   246 	iWordFlags |= EFHeightBoxPopped;
       
   247 	}
       
   248 
       
   249 void CWordAppUi::LaunchBordersPopupL()
       
   250 	{
       
   251 	if (iWordFlags & EBordersPopped)
       
   252 		return;
       
   253 	CDesCArray* array = new(ELeave) CDesCArrayFlat(KMaxTotalBorderBitmaps);
       
   254 	CleanupStack::PushL(array);
       
   255 	CArrayPtrFlat<CGulIcon>* icons = new(ELeave) CArrayPtrFlat<CGulIcon>(KMaxTotalBorderBitmaps);
       
   256 	CleanupStack::PushL(icons);
       
   257 	for (TInt ii = (TInt)EMbmWordFullsbrd; ii <= (TInt)EMbmWordNullbrd; ii++)
       
   258 		{
       
   259 		TBuf<8> buf;
       
   260 		buf.Num(ii - EMbmWordFullsbrd);
       
   261 		buf.Append(TChar(KColumnListSeparator));
       
   262 		array->AppendL(buf);
       
   263 		CGulIcon* icon = NULL;
       
   264 		icon = ((CGulIcon*)iEikonEnv->CreateIconL(BitmapStore(), ii));
       
   265 		CleanupStack::PushL(icon);
       
   266 		icons->AppendL(icon);
       
   267 		}
       
   268 	CEikCommandButtonBase* bordersButton = STATIC_CAST(CEikCommandButtonBase*, iEikonEnv->AppUiFactory()->ToolBand()->ControlById(EWordButtonBorders));
       
   269 	TPoint pos = bordersButton->PositionRelativeToScreen();
       
   270 	TSize size((*icons)[0]->Bitmap()->SizeInPixels());
       
   271 	const TInt width = size.iWidth + 6;
       
   272 	size.iHeight += KBmpListVertItemGap;
       
   273 	size.iHeight *= 4;
       
   274 	size.iWidth = width << 1;
       
   275 	pos.iY += bordersButton->Size().iHeight;  // draw popout below the borders button
       
   276 	// determine current borders
       
   277 	TParaFormatMask mask;
       
   278 	CParaFormat* paraFormat = CParaFormat::NewLC();
       
   279 	const TCursorSelection selection = iRichEd->TextView()->Selection();
       
   280 	Text()->GetParaFormatL(paraFormat, mask, selection.LowerPos(), selection.Length());
       
   281 	TInt index = 0;
       
   282 	if (mask.AttribIsSet(EAttTopBorder) || mask.AttribIsSet(EAttBottomBorder) || mask.AttribIsSet(EAttLeftBorder) ||
       
   283 				mask.AttribIsSet(EAttRightBorder))
       
   284 		; // leave index as zero
       
   285 	else if (!paraFormat->BordersPresent())
       
   286 		index = ENullBorder-ESingleFull;
       
   287 	else
       
   288 		{
       
   289 		TParaBorder left = paraFormat->ParaBorder(CParaFormat::EParaBorderLeft);
       
   290 		TParaBorder right = paraFormat->ParaBorder(CParaFormat::EParaBorderRight);
       
   291 		TParaBorder top = paraFormat->ParaBorder(CParaFormat::EParaBorderTop);
       
   292 		TParaBorder bottom = paraFormat->ParaBorder(CParaFormat::EParaBorderBottom);
       
   293 		if (top.iThickness == bottom.iThickness && left.iThickness == right.iThickness && top.iThickness == KThickBorderThicknessInTwips &&
       
   294 				top.iLineStyle == bottom.iLineStyle && left.iLineStyle == right.iLineStyle &&
       
   295 				top.iLineStyle == TParaBorder::ESolid)
       
   296 			index = EDoubleFull - ESingleFull;
       
   297 		else if (left.iThickness || right.iThickness)
       
   298 			;
       
   299 		else if (top.iThickness == bottom.iThickness && left.iThickness == right.iThickness && top.iThickness == KThinBorderThicknessInTwips &&
       
   300 				top.iLineStyle == bottom.iLineStyle && left.iLineStyle == right.iLineStyle &&
       
   301 				top.iLineStyle == TParaBorder::ESolid)
       
   302 			index = ESingleTopAndBottom - ESingleFull;
       
   303 		else if (top.iLineStyle == TParaBorder::ESolid && (top.iThickness == KThinBorderThicknessInTwips || top.iThickness == KThickBorderThicknessInTwips) &&
       
   304 					bottom.iThickness == 0)
       
   305 			{
       
   306 			if (top.iThickness == KThinBorderThicknessInTwips)
       
   307 				index = ESingleTop - ESingleFull;
       
   308 			else
       
   309 				index = EDoubleTop - ESingleFull;
       
   310 			}
       
   311 		else if (bottom.iLineStyle == TParaBorder::ESolid && (bottom.iThickness == KThinBorderThicknessInTwips || bottom.iThickness == KThickBorderThicknessInTwips) &&
       
   312 					top.iThickness == 0)
       
   313 			{
       
   314 			if (bottom.iThickness == KThinBorderThicknessInTwips)
       
   315 				index = ESingleBottom - ESingleFull;
       
   316 			else
       
   317 				index = EDoubleBottom - ESingleFull;
       
   318 			}
       
   319 		}
       
   320 	CleanupStack::PopAndDestroy(); // paraFormat
       
   321 	//
       
   322 	DoCreateMcBitmapPopoutL(array, icons, index, bordersButton, width, TRect(pos, size));
       
   323 	iWordFlags |= EBordersPopped;
       
   324 	}
       
   325 
       
   326 void CWordAppUi::DestroyPopoutLBox()
       
   327 	{
       
   328 	if (iPopoutListBox)
       
   329         {
       
   330         iEikonEnv->RemoveFromStack(iPopoutListBox);
       
   331         delete iPopoutListBox;
       
   332         iPopoutListBox=NULL;
       
   333 		delete iTwipsList;
       
   334 		iTwipsList=NULL;
       
   335         }
       
   336 	else if (iBitmapPopout)
       
   337 		{
       
   338 		iEikonEnv->RemoveFromStack(iBitmapPopout);
       
   339 		delete iBitmapPopout;
       
   340 		iBitmapPopout=NULL;
       
   341 		}
       
   342 	else if (iMcBitmapPopout)
       
   343 		{
       
   344 		iEikonEnv->RemoveFromStack(iMcBitmapPopout);
       
   345 		delete iMcBitmapPopout;
       
   346 		iMcBitmapPopout=NULL;
       
   347 		}
       
   348  	}
       
   349 
       
   350 void CWordAppUi::DoCreatePopoutL(CDesCArray* aText,TInt aIndex,CEikCommandButtonBase* aLaunchingButton,TToolBarType aType,TBool aLimitWidth)
       
   351 	{
       
   352 	CWordTextListBox* popout = new(ELeave) CWordTextListBox;
       
   353 	CleanupStack::PushL(popout);
       
   354   	popout->ConstructL(NULL, CEikListBox::EPopout | CEikListBox::ELeftDownInViewRect);
       
   355 	popout->CreateScrollBarFrameL();
       
   356 	popout->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
   357     popout->SetObserver(this);
       
   358 	iEikonEnv->AddWindowShadow(popout);
       
   359 	popout->Model()->SetItemTextArray(aText);
       
   360 	CleanupStack::Pop(); // aText
       
   361 	const TSize screenSize = iEikonEnv->ScreenDevice()->SizeInPixels();
       
   362 	TSize butSize = aLaunchingButton->Size();
       
   363 	TInt width = Max(butSize.iWidth, popout->MaxWidth());
       
   364 	if (aType == EToolBar)
       
   365 		{
       
   366 		if (width + butSize.iWidth > screenSize.iWidth)
       
   367 			width = screenSize.iWidth - butSize.iWidth; // assume word is always full screen
       
   368 		}
       
   369 	else
       
   370 		{
       
   371 		if (width > screenSize.iWidth)
       
   372 			width = screenSize.iWidth;
       
   373 		if (aLimitWidth)
       
   374 			{
       
   375 			width = Max(butSize.iWidth, popout->MaxWidth());
       
   376 			if (width > 2 * butSize.iWidth)
       
   377 				width = 2 * butSize.iWidth;
       
   378 			}
       
   379 		}
       
   380 	TPoint pos = aLaunchingButton->PositionRelativeToScreen();
       
   381 	if (aType == EToolBand)
       
   382 		pos.iY += butSize.iHeight;
       
   383 	TRect listBoxRect(pos, TSize(width, 0));
       
   384 	popout->CalculatePopoutRect(0, pos.iY, listBoxRect);
       
   385 	if (aType == EToolBar)
       
   386 		pos.iX -= listBoxRect.Width();
       
   387 	else if (listBoxRect.iTl.iY < pos.iY)
       
   388 		{
       
   389 		const TInt itemHeight = popout->ItemHeight();
       
   390 		while (listBoxRect.iTl.iY < pos.iY)
       
   391 			listBoxRect.iTl.iY += itemHeight;
       
   392 		listBoxRect.iTl.iY = pos.iY;
       
   393 		}
       
   394 	if (aType == EToolBand && listBoxRect.iBr.iX > screenSize.iWidth)
       
   395 		listBoxRect.Move(listBoxRect.iBr.iX - screenSize.iWidth, 0);
       
   396 	popout->SetExtent(TPoint(pos.iX, listBoxRect.iTl.iY), listBoxRect.Size());
       
   397 	popout->SetCurrentItemIndex(aIndex);
       
   398     iEikonEnv->AddDialogLikeControlToStackL(popout);
       
   399 	popout->SetLaunchingButton(aLaunchingButton);
       
   400 	popout->ActivateL();
       
   401 	CleanupStack::Pop(); // popout
       
   402 	iPopoutListBox = popout;
       
   403 	aLaunchingButton->SetIgnoreNextPointerUp();
       
   404 	iPopoutListBox->ClaimPointerGrab();
       
   405 	}
       
   406 
       
   407 void CWordAppUi::DoCreateBitmapPopoutL(CDesCArray* aText, CArrayPtrFlat<CGulIcon>* aIcons, TInt aIndex,
       
   408 									   CEikCommandButtonBase* aControl, TToolBarType aType)
       
   409 	{
       
   410 	CEikColumnListBox* popout = new(ELeave) CEikColumnListBox;
       
   411 	CleanupStack::PushL(popout);
       
   412   	popout->ConstructL(NULL, CEikListBox::EPopout | CEikListBox::ELeftDownInViewRect | CEikListBox::ENoFirstLetterMatching);
       
   413 	popout->CreateScrollBarFrameL();
       
   414 	popout->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
   415     popout->SetObserver(this);
       
   416 	popout->SetItemHeightL((*aIcons)[0]->Bitmap()->SizeInPixels().iHeight + KBmpListVertItemGap);
       
   417 	iEikonEnv->AddWindowShadow(popout);
       
   418 	popout->Model()->SetItemTextArray(aText);
       
   419 	CleanupStack::Pop(); // aText
       
   420 	popout->ItemDrawer()->ColumnData()->SetIconArray(aIcons);
       
   421 	CleanupStack::Pop(); // aIcons
       
   422 	popout->ItemDrawer()->ColumnData()->SetColumnAlignmentL(0, CGraphicsContext::ECenter);
       
   423 	popout->ItemDrawer()->ColumnData()->SetGraphicsColumnL(0, ETrue);
       
   424 	TPoint pos = aControl->PositionRelativeToScreen();
       
   425 	if (aType == EToolBand)
       
   426 		pos.iY += aControl->Size().iHeight;
       
   427 	TRect listBoxRect(pos, TSize(aControl->Size().iWidth, 0));
       
   428 	popout->CalculatePopoutRect(0, pos.iY, listBoxRect);
       
   429 	if (aType == EToolBar)
       
   430 		pos.iX -= listBoxRect.Width();
       
   431 	// assume list is not too wide or high to fit on screen
       
   432 	const TSize screenSize = iCoeEnv->ScreenDevice()->SizeInPixels();
       
   433 	const TSize listSize = listBoxRect.Size();
       
   434 	if (listBoxRect.iTl.iX + listSize.iWidth > screenSize.iWidth)
       
   435 		listBoxRect.iTl.iX = screenSize.iWidth - listSize.iWidth;
       
   436 	popout->SetRect(listBoxRect);
       
   437 	//	
       
   438 	popout->ItemDrawer()->ColumnData()->SetColumnWidthPixelL(0, popout->View()->ViewRect().Width());
       
   439 	popout->SetCurrentItemIndex(aIndex);
       
   440     iEikonEnv->AddDialogLikeControlToStackL(popout);
       
   441 	popout->ActivateL();
       
   442 	CleanupStack::Pop(); // popout
       
   443 	iBitmapPopout = popout;
       
   444 	iBitmapPopout->SetLaunchingButton(aControl);
       
   445 	aControl->SetIgnoreNextPointerUp();
       
   446 	iBitmapPopout->ClaimPointerGrab();
       
   447 	}
       
   448 
       
   449 void CWordAppUi::DoCreateMcBitmapPopoutL(CDesCArray* aText, CArrayPtrFlat<CGulIcon>* aIcons, TInt aIndex,
       
   450 									   CEikCommandButtonBase* aLaunchingButton, TInt aColumnWidth, const TRect& aRect)
       
   451 	{
       
   452 	CWordSnakingColumnListBox* popout = new(ELeave) CWordSnakingColumnListBox;
       
   453 	CleanupStack::PushL(popout);
       
   454 	popout->ConstructL(NULL, CEikListBox::EPopout | CEikListBox::ELeftDownInViewRect | CEikListBox::ENoFirstLetterMatching);
       
   455 	popout->CreateScrollBarFrameL();
       
   456 	popout->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
   457     popout->SetObserver(this);
       
   458 	popout->SetItemHeightL((*aIcons)[0]->Bitmap()->SizeInPixels().iHeight + KBmpListVertItemGap);
       
   459 	iEikonEnv->AddWindowShadow(popout);
       
   460 	popout->Model()->SetItemTextArray(aText);
       
   461 	CleanupStack::Pop(); // aText
       
   462 	popout->ItemDrawer()->ColumnData()->SetColumnWidthPixelL(0, aColumnWidth);
       
   463 	popout->ItemDrawer()->ColumnData()->SetIconArray(aIcons);
       
   464 	CleanupStack::Pop(EMbmWordNullbrd - EMbmWordFullsbrd + 2); // aBitmaps
       
   465 	popout->ItemDrawer()->ColumnData()->SetColumnAlignmentL(0, CGraphicsContext::ECenter);
       
   466 	popout->ItemDrawer()->ColumnData()->SetGraphicsColumnL(0, ETrue);
       
   467 	popout->SetColumnWidth(aColumnWidth);
       
   468 	// assume list is not too wide or high to fit on screen
       
   469 	TRect rect(aRect);
       
   470 	const TSize size = rect.Size() + popout->BorderSize();
       
   471 	rect.SetSize(size);
       
   472 	const TSize screenSize = iCoeEnv->ScreenDevice()->SizeInPixels();
       
   473 	if (rect.iTl.iX + size.iWidth > screenSize.iWidth)
       
   474 		rect.iTl.iX = screenSize.iWidth - size.iWidth;
       
   475 	popout->SetRect(rect);
       
   476 	//	
       
   477 	popout->SetCurrentItemIndex(aIndex);
       
   478     iEikonEnv->AddDialogLikeControlToStackL(popout);
       
   479 	popout->ActivateL();
       
   480 	CleanupStack::Pop(); // popout
       
   481 	iMcBitmapPopout = popout;
       
   482 	iMcBitmapPopout->SetLaunchingButton(aLaunchingButton);
       
   483 	aLaunchingButton->SetIgnoreNextPointerUp();
       
   484 	iMcBitmapPopout->ClaimPointerGrab();
       
   485 	}
       
   486 
       
   487 //
       
   488 // class CWordTextListBox
       
   489 //
       
   490 
       
   491 TInt CWordTextListBox::MaxWidth()
       
   492 	{
       
   493 	iView->CalcDataWidth();
       
   494 	TInt width=iView->DataWidth();
       
   495 	width+=(HorizontalMargin()<<1)+iBorder.SizeDelta().iWidth;
       
   496 	return width;
       
   497 	}
       
   498 
       
   499 //
       
   500 // class CWordSnakingColumnListBox
       
   501 //
       
   502 
       
   503 void CWordSnakingColumnListBox::ConstructL(const CCoeControl* aParent,TInt aFlags)
       
   504 	{
       
   505 	CTextListBoxModel* model = new(ELeave) CTextListBoxModel;
       
   506 	iModel = model;
       
   507 	model->ConstructL();
       
   508 	CColumnListBoxData* data = CColumnListBoxData::NewL();
       
   509 	CleanupStack::PushL(data);
       
   510 	iItemDrawer = new(ELeave) CColumnListBoxItemDrawer(model, iEikonEnv->NormalFont(), data);
       
   511 	CleanupStack::Pop();	//data
       
   512 	iItemDrawer->SetDrawMark(EFalse);
       
   513 	CEikListBox::ConstructL(aParent, aFlags|ELeftDownInViewRect);
       
   514 	}
       
   515 
       
   516 CTextListBoxModel* CWordSnakingColumnListBox::Model() const
       
   517 	{
       
   518 	return(CTextListBoxModel*)iModel;
       
   519 	}
       
   520 
       
   521 CColumnListBoxItemDrawer* CWordSnakingColumnListBox::ItemDrawer() const
       
   522 	{
       
   523 	return(CColumnListBoxItemDrawer*)iItemDrawer;
       
   524 	}
       
   525 
       
   526 TSize CWordSnakingColumnListBox::BorderSize() const
       
   527 	{
       
   528 	TSize size(HorizontalMargin()<<1,VerticalMargin()<<1);
       
   529 	size+=iBorder.SizeDelta();
       
   530 	return size;
       
   531 	}