63
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2007 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: Phonebook 2 presentation utilities.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef PBK2PRESENTATIONUTILS_H
|
|
20 |
#define PBK2PRESENTATIONUTILS_H
|
|
21 |
|
|
22 |
#include <e32std.h>
|
|
23 |
|
|
24 |
class CFbsBitmap;
|
|
25 |
|
|
26 |
/**
|
|
27 |
* Util class with static text formatting functions
|
|
28 |
*/
|
|
29 |
class Pbk2PresentationUtils
|
|
30 |
{
|
|
31 |
public: // Interface
|
|
32 |
|
|
33 |
/**
|
|
34 |
* Appends given text to given descriptor. Ignores all leading
|
|
35 |
* and trailing spaces in the given text and converts consencutive
|
|
36 |
* space characters to a single space character.
|
|
37 |
*
|
|
38 |
* @precond aDest.MaxLength()-aDest.Length() >= TrimAllLength(aText)
|
|
39 |
* @postcond aDest.Length()-old(aDest.Length()) == TrimAllLength(aText)
|
|
40 |
* @param aText Text to append as a trimmed version.
|
|
41 |
* @param aDest Buffer where thed trimmed text is appended.
|
|
42 |
* Must have enough room for the copied text.
|
|
43 |
* @return Number of characters appended.
|
|
44 |
*/
|
|
45 |
static TInt TrimAllAppend(
|
|
46 |
const TDesC& aText,
|
|
47 |
TDes& aDest );
|
|
48 |
|
|
49 |
/**
|
|
50 |
* Appends given text to given descriptor. Ignores all trailing
|
|
51 |
* spaces in the given text and converts consencutive space
|
|
52 |
* characters to a single space character. Leading spaces remain
|
|
53 |
* unaffected.
|
|
54 |
*
|
|
55 |
* @precond aDest.MaxLength()-aDest.Length() >= TrimRightLength(aText)
|
|
56 |
* @postcond aDest.Length()-old(aDest.Length())==TrimRightLength(aText)
|
|
57 |
* @param aText Text to append as a trimmed version.
|
|
58 |
* @param aDest Buffer where the trimmed text is appended.
|
|
59 |
* Must have enough room for the copied text.
|
|
60 |
* @return Number of characters appended.
|
|
61 |
*/
|
|
62 |
IMPORT_C static TInt TrimRightAppend(
|
|
63 |
const TDesC& aText,
|
|
64 |
TDes& aDest );
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Appends a descriptor to another and replaces characters while
|
|
68 |
* appending.
|
|
69 |
*
|
|
70 |
* @precond (aDest.MaxLength()-aDest.Length()) >= aSrc.Length()
|
|
71 |
* @precond aCharsToReplace.Length() == aReplaceChars.Length()
|
|
72 |
* @param aDest Destination descriptor.
|
|
73 |
* @param aSrc Source descriptor.
|
|
74 |
* @param aCharsToReplace Characters to replace.
|
|
75 |
* @param aReplaceChars Replace characters. The replace position
|
|
76 |
* maps to the position in aCharsToReplace.
|
|
77 |
* @return Number of characters replaced.
|
|
78 |
*/
|
|
79 |
IMPORT_C static TInt AppendAndReplaceChars(
|
|
80 |
TDes& aDest,
|
|
81 |
const TDesC& aSrc,
|
|
82 |
const TDesC& aCharsToReplace,
|
|
83 |
const TDesC& aReplaceChars );
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Replaces all non-graphic characters (!TChar::IsGraph()) in
|
|
87 |
* a string with the specified character.
|
|
88 |
*
|
|
89 |
* @param aText The string where to replace
|
|
90 |
* non-graphics characters.
|
|
91 |
* @param aChar The character used to replace non-graphic
|
|
92 |
* characters.
|
|
93 |
*/
|
|
94 |
IMPORT_C static void ReplaceNonGraphicCharacters(
|
|
95 |
TDes& aText,
|
|
96 |
TText aChar );
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Replaces all CR, LF or CRLF characters with unicode Paragraph
|
|
100 |
* Separator (0x2029) character that for example Avkon controls
|
|
101 |
* understand. Copies all other text as-is. Copies only as many
|
|
102 |
* characters from the beginning of aText as aBuffer has space for.
|
|
103 |
*
|
|
104 |
* @param aBuffer Destination buffer where aText is appended with
|
|
105 |
* newlines translated to Paragraph Separators.
|
|
106 |
* @param aText Source text to be translated.
|
|
107 |
*/
|
|
108 |
IMPORT_C static void AppendWithNewlineTranslationL(
|
|
109 |
TDes& aBuffer,
|
|
110 |
const TDesC& aText );
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Solves the correct language specific resource filename.
|
|
114 |
* With all resource files the same pbk2presentation.rsg can be used.
|
|
115 |
*
|
|
116 |
* @return A reference to resource file
|
|
117 |
*/
|
|
118 |
IMPORT_C static const TDesC& PresentationResourceFile();
|
|
119 |
|
|
120 |
private: // Disabled functions
|
|
121 |
Pbk2PresentationUtils();
|
|
122 |
};
|
|
123 |
|
|
124 |
class Pbk2PresentationImageUtils
|
|
125 |
{
|
|
126 |
public:
|
|
127 |
enum TCroppingMode
|
|
128 |
{
|
|
129 |
/// Image is cropped to square, target size is not used
|
|
130 |
ECropping = 0x0,
|
|
131 |
/**
|
|
132 |
* Image is cropped to square and optimized to target size.
|
|
133 |
* Cropped bitmap minimum width/height is aTargetSize width/height.
|
|
134 |
*/
|
|
135 |
EOptimizedCropping
|
|
136 |
};
|
|
137 |
|
|
138 |
IMPORT_C static void CropImageL(
|
|
139 |
CFbsBitmap& aBitmap,
|
|
140 |
TCroppingMode aCroppingMode,
|
|
141 |
const TSize& aTargetSize );
|
|
142 |
|
|
143 |
private: // Disabled functions
|
|
144 |
Pbk2PresentationImageUtils();
|
|
145 |
};
|
|
146 |
|
|
147 |
|
|
148 |
#endif // PBK2PRESENTATIONUTILS_H
|
|
149 |
|
|
150 |
// End of File
|