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