|
1 /* |
|
2 * Copyright (c) 1997-1999 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 #if !defined(__EIKPROGI_H__) |
|
20 #define __EIKPROGI_H__ |
|
21 |
|
22 #if !defined(__EIKBCTRL_H__) |
|
23 #include <eikbctrl.h> |
|
24 #endif |
|
25 |
|
26 #if !defined(__EIKON_HRH__) |
|
27 #include <eikon.hrh> |
|
28 #endif |
|
29 |
|
30 class TGulBorder; |
|
31 class CEikProgressInfoExtension; |
|
32 |
|
33 /** |
|
34 * Control used to indicate the progress of an operation. |
|
35 * |
|
36 * Progress consists of a rectangular block that grows during an increment and |
|
37 * shrinks during a decrement. The control can have progress text within the bar |
|
38 * that provides updated information on how far the operation has progressed. |
|
39 * The text can be displayed as either a percentage or a fraction. The bar can |
|
40 * also have a series of invisible splits, or lines. These splits are displayed |
|
41 * by the rectangular blocks as it fills the bar. When the control is in this |
|
42 * mode progress text cannot be used. |
|
43 * |
|
44 * This class has an associated @c PROGRESSINFO resource and @c EEikCtProgInfo |
|
45 * control factory identifier. |
|
46 */ |
|
47 class CEikProgressInfo : public CEikBorderedControl |
|
48 { |
|
49 |
|
50 public: |
|
51 |
|
52 /** |
|
53 * Defines the progress control's type. |
|
54 */ |
|
55 struct SInfo |
|
56 { |
|
57 /** |
|
58 * The type of text for the progress information control. This can be |
|
59 * percentage or fraction. See the @c TEikProgressTextType enum. |
|
60 */ |
|
61 TEikProgressTextType iTextType; |
|
62 |
|
63 /** |
|
64 * The total number of splits in the progress information control. This |
|
65 * is optional. |
|
66 */ |
|
67 TInt iSplitsInBlock; |
|
68 |
|
69 /** |
|
70 * The final value of the progress information control that, when |
|
71 * reached, indicates completion. |
|
72 */ |
|
73 TInt iFinalValue; |
|
74 |
|
75 /** The width of the control in pixels. */ |
|
76 TInt iWidth; |
|
77 |
|
78 /** The height of the progress information control. */ |
|
79 TInt iHeight; |
|
80 }; |
|
81 |
|
82 /** |
|
83 * Defines the layout and colours for a progress information control. |
|
84 */ |
|
85 struct SLayout |
|
86 { |
|
87 /** |
|
88 * The colour for the part of the control that indicates the progress |
|
89 * that has been made. By default, the value of the @c TLogicalColor |
|
90 * enum's @c EColorControlHighlightBackground datum. |
|
91 */ |
|
92 TRgb iFillColor; |
|
93 |
|
94 /** |
|
95 * The colour for sections of the control that indicate the progress yet |
|
96 * to be made. By default, the value of the @c TLogicalColor enum's |
|
97 * @c EColorControlBackground datum. |
|
98 */ |
|
99 TRgb iEmptyColor; |
|
100 |
|
101 /** |
|
102 * The colour for the optional progress text that is displayed i.e. |
|
103 * the filled portion of the control. By default, the value of the |
|
104 * @c TLogicalColor enum's @c EColorControlHighlightText datum. |
|
105 */ |
|
106 TRgb iFillTextColor; |
|
107 |
|
108 /** |
|
109 * Optional progress text that appears in the empty portion of the |
|
110 * control. By default, the value of the @c TLogicalColor enum's |
|
111 * @c EColorControlText datum. |
|
112 */ |
|
113 TRgb iEmptyTextColor; |
|
114 |
|
115 /** |
|
116 * The font to use for the optional progress text. By default, the |
|
117 * environment's normal font. |
|
118 */ |
|
119 const CFont* iFont; |
|
120 |
|
121 /** |
|
122 * The gap between the blocks in the control that indicate the progress |
|
123 * made. By default, one pixel. |
|
124 */ |
|
125 TInt iGapBetweenBlocks; |
|
126 }; |
|
127 |
|
128 /** |
|
129 * Destructor. |
|
130 */ |
|
131 IMPORT_C ~CEikProgressInfo(); |
|
132 |
|
133 /** |
|
134 * C++ default constructor. |
|
135 */ |
|
136 IMPORT_C CEikProgressInfo(); |
|
137 |
|
138 /** |
|
139 * Constructs a progress information control using the information held in |
|
140 * the specified @c SInfo struct. Uses default layout values. |
|
141 * |
|
142 * @param aProgInfo Holds information about the type of progress |
|
143 * information control. |
|
144 */ |
|
145 IMPORT_C CEikProgressInfo(const SInfo& aProgInfo); |
|
146 |
|
147 /** |
|
148 * Adds the specified increment to the current progress value and, if the |
|
149 * progress value has increased, redraws the control. |
|
150 * |
|
151 * @param aInc The increment to add to the current progress value. |
|
152 */ |
|
153 IMPORT_C void IncrementAndDraw(TInt aInc); |
|
154 |
|
155 /** |
|
156 * Sets the specified value as the new progress value and redraws the |
|
157 * control if the new value differs from the old value. |
|
158 * |
|
159 * @param aValue The new progress value. |
|
160 */ |
|
161 IMPORT_C void SetAndDraw(TInt aValue); |
|
162 |
|
163 /** |
|
164 * From @c CCoeControl. |
|
165 * |
|
166 * Constructs a progress information control from a @c PROGRESSINFO |
|
167 * resource. Uses default layout values. |
|
168 * |
|
169 * @param aReader The resource reader to use. |
|
170 */ |
|
171 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); |
|
172 |
|
173 /** |
|
174 * Sets the layout for the control. |
|
175 * |
|
176 * @param aLayout The layout for the control. |
|
177 */ |
|
178 IMPORT_C void SetLayout(const SLayout& aLayout); |
|
179 |
|
180 /** |
|
181 * Sets the control's border. |
|
182 * |
|
183 * @param aBorder The control's border. |
|
184 */ |
|
185 IMPORT_C void SetBorder(const TGulBorder& aBorder); |
|
186 |
|
187 /** |
|
188 * Sets the final value for the progress information control. This value |
|
189 * indicates the operation being monitored is complete. |
|
190 * |
|
191 * @param aFinalValue The final value for the progress information control. |
|
192 * If this is specified as zero, the value is set to one. |
|
193 */ |
|
194 IMPORT_C void SetFinalValue(TInt aFinalValue); |
|
195 |
|
196 /** |
|
197 * By default Symbian 2nd phase constructor is private. |
|
198 */ |
|
199 IMPORT_C void ConstructL(); // AKNLAF |
|
200 |
|
201 /** |
|
202 * Gets a pointer to the information used to define the progress information |
|
203 * control's type. |
|
204 * |
|
205 * @return The information that defines the type of progress |
|
206 * information control. |
|
207 */ |
|
208 inline const SInfo& Info() const { return(iInfo); } |
|
209 |
|
210 /** |
|
211 * Gets a pointer to the colours and layout of the progress information |
|
212 * control. |
|
213 * |
|
214 * @return Defines the layout of the control. |
|
215 */ |
|
216 inline const SLayout& Layout() const { return(iLayout); } |
|
217 |
|
218 /** |
|
219 * Gets the current value, indicating how far the operation has progressed. |
|
220 * |
|
221 * @return The value for how far the operation has progressed. |
|
222 */ |
|
223 inline TInt CurrentValue() const { return(iCurrentValue); } |
|
224 |
|
225 protected: |
|
226 |
|
227 /** |
|
228 * Evaluates the progress text. |
|
229 * |
|
230 * @param[out] aTextBuf On return, the evaluted text. This is the same |
|
231 * as the return value. |
|
232 * @return The evaluated text. Null if progress information is not |
|
233 * held as text. A percentage if it is held as a percentage. |
|
234 * Otherwise, the current value and final value separated by |
|
235 * a slash. Subclassers may wish to use their own buffer. |
|
236 **/ |
|
237 IMPORT_C virtual const TDesC* EvaluateText(TDes& aTextBuf) const; |
|
238 |
|
239 public: // from CCoeControl |
|
240 |
|
241 /** |
|
242 * From @c CCoeControl. |
|
243 * |
|
244 * Activates the progress information control. |
|
245 */ |
|
246 IMPORT_C void ActivateL(); |
|
247 |
|
248 /** |
|
249 * From @c CCoeControl. |
|
250 * |
|
251 * Gets the minimum size required to draw the control. |
|
252 * |
|
253 * @return Two-dimensional size as a width and a height value. |
|
254 */ |
|
255 IMPORT_C TSize MinimumSize(); |
|
256 |
|
257 /** |
|
258 * From @c CCoeControl. |
|
259 * |
|
260 * Recalculates the control's size in response to a size change. |
|
261 */ |
|
262 IMPORT_C void SizeChanged(); |
|
263 |
|
264 /** |
|
265 * From @c CCoeControl. |
|
266 * |
|
267 * Gets a list of the logical colours used to draw the control, appended |
|
268 * to @c aColorUseList. |
|
269 * |
|
270 * @param[out] aColorUseList On return, the colours used to draw |
|
271 * the control. |
|
272 */ |
|
273 IMPORT_C virtual void GetColorUseListL( |
|
274 CArrayFix<TCoeColorUse>& aColorUseList) const; |
|
275 |
|
276 /** |
|
277 * From @c CCoeControl. |
|
278 * |
|
279 * Handles a change to the control's resources. |
|
280 * |
|
281 * @param aType A message UID value. |
|
282 */ |
|
283 IMPORT_C virtual void HandleResourceChange(TInt aType); |
|
284 |
|
285 /** |
|
286 * From @c CCoeControl. |
|
287 * |
|
288 * Handles pointer events. This function gets called whenever a pointer |
|
289 * event occurs in the control, i.e. when the pointer is within |
|
290 * the control's extent, or when the control has grabbed the pointer. |
|
291 * The control should implement this function to handle pointer events. |
|
292 * |
|
293 * Note: events of type @c EButton1Down are processed before |
|
294 * @c HandlePointerEventL() is called, in order to transfer keyboard focus |
|
295 * to the control in which the @c EButton1Down event occurred. |
|
296 * If overriding @c HandlePointerEventL(), the implementation must include |
|
297 * a base call to @c CCoeControl's @c HandlePointerEventL(). |
|
298 * |
|
299 * @param aPointerEvent The pointer event. |
|
300 */ |
|
301 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
302 |
|
303 protected: //from CCoeControl |
|
304 |
|
305 /** |
|
306 * From @c CCoeControl. |
|
307 * |
|
308 * Writes the internal state of the control and its components to a stream. |
|
309 * This function is empty in release builds. It is intended to be overridden |
|
310 * and base called by subclasses. |
|
311 * |
|
312 * @since App-Framework_6.1 |
|
313 * @param aWriteStream The internal state of the control and its components. |
|
314 */ |
|
315 IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const; |
|
316 |
|
317 private: // from CCoeControl |
|
318 |
|
319 IMPORT_C void Draw(const TRect& aRect) const; |
|
320 IMPORT_C void Reserved_2(); |
|
321 |
|
322 private: |
|
323 |
|
324 /** |
|
325 * From CAknControl |
|
326 */ |
|
327 IMPORT_C void* ExtensionInterface( TUid aInterface ); |
|
328 |
|
329 private: // internal use |
|
330 |
|
331 void Construct(); |
|
332 void CheckSizeCalculated(); |
|
333 void DrawPartial()const; // AKNLAF |
|
334 void DrawProgressBarForeground(CWindowGc& aGc) const; //AKNLAF |
|
335 void DrawProgressBarBackground(CWindowGc& aGc) const; //AKNLAF |
|
336 TInt FilledWidth() const; //AKNLAF |
|
337 |
|
338 private: |
|
339 |
|
340 SInfo iInfo; |
|
341 SLayout iLayout; |
|
342 TInt iCurrentValue; |
|
343 TBool iHeightWasSupplied; |
|
344 CFbsBitmap* iBitmap; // AKNLAF |
|
345 CFbsBitmap* iBackgroundBitmap; // AKNLAF Not used, extension! |
|
346 CFbsBitmap* iBitmapMask; // AKNLAF |
|
347 //CFbsBitmap* iBackgroundBitmapMask; // AKNLAF |
|
348 CEikProgressInfoExtension* iExtension; |
|
349 |
|
350 private: |
|
351 |
|
352 void LoadBitmapsL(); |
|
353 void SetBitmapSizes(); |
|
354 void DeleteBitmaps(); |
|
355 }; |
|
356 |
|
357 |
|
358 #endif // __EIKPROGI_H__ |