|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __LAFMAIN_H__ |
|
17 #define __LAFMAIN_H__ |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <e32base.h> |
|
21 #include <gulbordr.h> |
|
22 #include <gulcolor.h> |
|
23 #include <frmtlay.h> |
|
24 |
|
25 class CCoeControl; |
|
26 class CFont; |
|
27 class TLogicalFont; |
|
28 class MLafEnv; |
|
29 |
|
30 |
|
31 class CLafEdwinCustomDrawBase : public CBase, public MFormCustomDraw |
|
32 /** LAF support for custom drawing of Edwins. |
|
33 |
|
34 This class is used by CEikEdwin to draw lines in plain text editors. It does |
|
35 not work in rich text editors, as it assumes the line spacing is constant. |
|
36 |
|
37 The custom drawing interface is defined by the MFormCustomDraw class. |
|
38 |
|
39 @publishedPartner |
|
40 @released */ |
|
41 { |
|
42 public: |
|
43 /** Allocates and constructs the custom drawer. |
|
44 |
|
45 @param aEnv LAF environment functions |
|
46 @param aControl The Edwin control |
|
47 @return New custom drawer */ |
|
48 IMPORT_C static CLafEdwinCustomDrawBase* NewL(const MLafEnv& aEnv,const CCoeControl& aControl); |
|
49 public: // from MFormCustomDraw |
|
50 /** Implements MFormCustomDraw::DrawBackground() to draw the Edwin background. |
|
51 |
|
52 See that function for a full description. |
|
53 |
|
54 @param aParam Drawing parameters |
|
55 @param aBackground Default background colour |
|
56 @param aDrawn On return, the rectangle to which the function has drawn */ |
|
57 IMPORT_C void DrawBackground(const TParam& aParam,const TRgb& aBackground,TRect& aDrawn) const; |
|
58 /** Gets the physical colour that maps to a specified logical colour. |
|
59 |
|
60 @param aColorIndex Logical colour |
|
61 @param aDefaultColor The default physical colour. This is the colour to be |
|
62 used if no translation is performed. This allows translation to change certain |
|
63 indices but not others ( by passing the default colour back unchanged). |
|
64 @return Physical colour */ |
|
65 IMPORT_C TRgb SystemColor(TUint aColorIndex,TRgb aDefaultColor) const; |
|
66 public: |
|
67 /** Notifies the drawer that a MEikEdwinObserver::EEventFormatChanged event has |
|
68 occurred for the Edwin. */ |
|
69 IMPORT_C virtual void LineSpacingChanged(); |
|
70 protected: |
|
71 /** Constructor that initialises data members. |
|
72 |
|
73 @param aEnv LAF environment functions |
|
74 @param aControl The Edwin control */ |
|
75 IMPORT_C CLafEdwinCustomDrawBase(const MLafEnv& aEnv,const CCoeControl& aControl); |
|
76 protected: |
|
77 /** LAF environment functions |
|
78 |
|
79 This is initialised by the constructor. */ |
|
80 const MLafEnv& iEnv; |
|
81 /** The Edwin control. |
|
82 |
|
83 This is initialised by the constructor. */ |
|
84 const CCoeControl& iControl; |
|
85 private: |
|
86 /** Unused. */ |
|
87 TInt iSpare; |
|
88 }; |
|
89 |
|
90 |
|
91 class CLafEdwinCustomWrapBase : public CBase, public MFormCustomWrap |
|
92 /** LAF support for custom line breaking in Edwins. |
|
93 |
|
94 This class is used by CEikEdwin to determine how to place line breaks. |
|
95 |
|
96 The custom line breaking interface is defined by the MFormCustomWrap class. |
|
97 |
|
98 @publishedPartner |
|
99 @released */ |
|
100 { |
|
101 public: |
|
102 /** Allocates and constructs the custom line breaker. |
|
103 |
|
104 @param aControl The Edwin control |
|
105 @return The new line breaker */ |
|
106 IMPORT_C static CLafEdwinCustomWrapBase* NewL(const CCoeControl& aControl); |
|
107 /** Destructor. */ |
|
108 IMPORT_C ~CLafEdwinCustomWrapBase(); |
|
109 public: // from MFormCustomWrap |
|
110 /** Gets the line break class for a Unicode character. |
|
111 |
|
112 This implements MFormCustomWrap::LineBreakClass(). |
|
113 |
|
114 @param aCode The Unicode character code |
|
115 @param aRangeStart On return, contains the Unicode character code at the start |
|
116 of the range including aCode that shares the same line break class as aCode. |
|
117 @param aRangeEnd On return, contains the Unicode character code at the end |
|
118 of the range including aCode that shares the same line break class as aCode |
|
119 @return The line break class assigned to the character. Line break classes |
|
120 are enumerated with MTmCustom::EOpLineBreakClass etc. */ |
|
121 IMPORT_C TUint LineBreakClass(TUint aCode,TUint& aRangeStart,TUint& aRangeEnd) const; |
|
122 /** Tests whether a line break is possible between two characters. |
|
123 |
|
124 This implements MFormCustomWrap::LineBreakPossible(). |
|
125 |
|
126 @param aPrevClass The line break class of the previous non-space character. |
|
127 @param aNextClass The line break class of the next non-space character. |
|
128 @param aHaveSpaces True if there are one or more space characters (with a line |
|
129 break class of MTmCustom::ESpLineBreakClass) between aPrevClass and aNextClass; |
|
130 false if not. |
|
131 @return ool True if a line break is possible between characters with the two |
|
132 line break classes, false if not */ |
|
133 IMPORT_C TBool LineBreakPossible(TUint aPrevClass,TUint aNextClass,TBool aHaveSpaces) const; |
|
134 /** Gets the position of the first or last possible line break position in a text |
|
135 string. |
|
136 |
|
137 This implements MFormCustomWrap::GetLineBreakInContext(). |
|
138 |
|
139 @param aText A string containing characters of class MTmCustom::ESaLineBreakClass. |
|
140 |
|
141 @param aMinBreakPos A position within aText at which to begin searching for |
|
142 a possible line break position. |
|
143 @param aMaxBreakPos A position within aText at which to stop searching for |
|
144 a possible line break position. |
|
145 @param aForwards If ETrue, the function gets the first possible line break |
|
146 position (searches forwards from aMinBreakPos); if EFalse, gets the last one |
|
147 (searches backwards from aMaxBreakPos). |
|
148 @param aBreakPos On return, the position of the first or last possible line |
|
149 break within aText. This must be greater than zero and less than aText.Length() |
|
150 - 1, and must also be in the range aMinBreakPos to aMaxBreakPos. |
|
151 @return True if a possible line break position is found, false if not */ |
|
152 IMPORT_C TBool GetLineBreakInContext(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos,TBool aForwards,TInt& aBreakPos) const; |
|
153 /** Tests whether a character can overhang the right margin. |
|
154 |
|
155 @param aChar The Unicode character code of interest |
|
156 @return True if the character specified can overhang the right margin, false |
|
157 if not */ |
|
158 IMPORT_C TBool IsHangingCharacter(TUint aChar) const; |
|
159 private: |
|
160 /** Unused. */ |
|
161 IMPORT_C void MFormCustomWrap_Reserved_1(); |
|
162 /** Unused. */ |
|
163 IMPORT_C void MFormCustomWrap_Reserved_2(); |
|
164 |
|
165 protected: |
|
166 /** Constructor. |
|
167 |
|
168 @param aControl The Edwin control */ |
|
169 IMPORT_C CLafEdwinCustomWrapBase(const CCoeControl& aControl); |
|
170 protected: |
|
171 /** The Edwin control, initialised by the constructor. */ |
|
172 const CCoeControl& iControl; |
|
173 private: |
|
174 /** Unused. */ |
|
175 TInt iSpare; |
|
176 }; |
|
177 |
|
178 class MLafEnv |
|
179 /** LAF interface to access the current system environment settings. |
|
180 |
|
181 It is implemented by the Uikon Core, and effectively allows the LAF |
|
182 limited access to the current thread's CEikonEnv. |
|
183 |
|
184 @publishedPartner |
|
185 @released |
|
186 */ |
|
187 { |
|
188 public: |
|
189 /** Gets the environment's nearest match to the specified logical font. |
|
190 |
|
191 The return value is never NULL. |
|
192 |
|
193 @param aLogicalFont Logical font to match. |
|
194 @return The font that most closely matches aLogicalFont. */ |
|
195 virtual const CFont* Font(const TLogicalFont& aLogicalFont) const=0; |
|
196 |
|
197 /** Gets an environment bitmap specified by UID. |
|
198 |
|
199 @param aBmpUid The UID of the bitmap to retrieve. |
|
200 @return The bitmap. */ |
|
201 virtual const CFbsBitmap* Bitmap(TUid aBmpUid) const=0; |
|
202 |
|
203 /** Gets the physical (TRgb) colour that corresponds to the specified |
|
204 logical colour, for a specified control. |
|
205 |
|
206 @param aLogicalColor Logical colour. |
|
207 @param aControl Control for which to get the mapping. Note controls can override |
|
208 the system mappings. |
|
209 @return Physical colour. */ |
|
210 virtual TRgb ControlColor(TLogicalColor aLogicalColor, const CCoeControl& aControl) const=0; |
|
211 |
|
212 /** Gets the environment's physical (TRgb) colour that corresponds to |
|
213 the specified logical colour. |
|
214 |
|
215 @param aLogicalColor Logical colour. |
|
216 @param aColorListUid UID of the colour list from which to get the mapping. The default |
|
217 value is the environment's list. |
|
218 @return Physical colour. */ |
|
219 virtual TRgb Color(TLogicalColor aLogicalColor, TUid aColorListUid=KNullUid) const=0; |
|
220 |
|
221 /** Gets the environment setting for the default display mode. |
|
222 |
|
223 @return Display mode. */ |
|
224 virtual TDisplayMode DefaultDisplayMode() const=0; |
|
225 }; |
|
226 |
|
227 class MLafClientRectResolver |
|
228 /** Interface that works out how screen furniture reduces the available screen area |
|
229 for applications. |
|
230 |
|
231 The interface is implemented by the UI and can be called by the LAF to get information |
|
232 on the areas of screen furniture. |
|
233 |
|
234 @see LafAppUi::ClientRect() |
|
235 @publishedPartner |
|
236 @released */ |
|
237 { |
|
238 public: |
|
239 /** Flags for types of screen furniture. */ |
|
240 enum TScreenFurniture |
|
241 { |
|
242 /** Menu bar. */ |
|
243 EMenuBar, |
|
244 /** Button group. */ |
|
245 EButtonGroup, |
|
246 /** Tool band. */ |
|
247 EToolBand, |
|
248 /** Title band. */ |
|
249 ETitleBand, |
|
250 /** Status pane. */ |
|
251 EStatusPane, |
|
252 /** Command Button Array */ |
|
253 ECba |
|
254 }; |
|
255 public: |
|
256 /** Calculates how a specified type of screen furniture reduces the application |
|
257 area of a specified screen rectangle. |
|
258 |
|
259 @param aScreenFurniture Type of screen furniture. |
|
260 @param aRect Screen rectangle from which to remove area of specified furniture. |
|
261 On return, the modified rectangle. */ |
|
262 virtual void ReduceRect(TScreenFurniture aScreenFurniture,TRect& aRect) const=0; |
|
263 }; |
|
264 |
|
265 #endif //__LAFMAIN_H__ |