|
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 #if !defined(__EIKDPAGE_H__) |
|
20 #define __EIKDPAGE_H__ |
|
21 |
|
22 #include <coeccntx.h> |
|
23 #include <eiksbfrm.h> |
|
24 #include <coecobs.h> |
|
25 #include <eikedwob.h> |
|
26 #include <AknPopupFieldText.h> |
|
27 #include <AknControl.h> |
|
28 |
|
29 // |
|
30 // Forward declarations. |
|
31 // |
|
32 |
|
33 class CEikCapCArray; |
|
34 class CEikCaptionedControl; |
|
35 class CEikDialogPageContainer; |
|
36 class CEikEdwin; |
|
37 class CEikLabel; |
|
38 class MEikDialogPageObserver; |
|
39 struct SEikControlInfo; |
|
40 class CAknLayoutData; |
|
41 class CDialogPageExtension; |
|
42 |
|
43 class CEikFormAnim; |
|
44 class MEikFormAnimObserver; |
|
45 class CAknPaneScroll; |
|
46 class CAknFormPhysics; |
|
47 |
|
48 /** |
|
49 * The CEikDialogPage class implements a scrollable dialog page control. |
|
50 * |
|
51 * @internal |
|
52 * @since ER5U |
|
53 */ |
|
54 NONSHARABLE_CLASS(CEikDialogPage) : |
|
55 public CAknControl, |
|
56 public MCoeControlObserver, |
|
57 public MEikScrollBarObserver, |
|
58 public MEikEdwinSizeObserver, |
|
59 public MAknPopupFieldObserver, |
|
60 public MEikEdwinObserver |
|
61 { |
|
62 public: |
|
63 enum TFocusNavigationMode |
|
64 { |
|
65 ECyclic, |
|
66 ENonCyclic |
|
67 }; |
|
68 enum TAScrollBarBreadthAllocationMode |
|
69 { |
|
70 ENone =0x0000, |
|
71 EScrollBarBreadthPreAllocated =0x1000 |
|
72 }; |
|
73 /** |
|
74 * Enumeration to express what layout is currently being used. Note that the use of |
|
75 * bitmaps on the left is controlled by D |
|
76 * |
|
77 */ |
|
78 enum TFormLayoutSelection |
|
79 { |
|
80 ESingle, |
|
81 EDouble |
|
82 }; |
|
83 |
|
84 /** |
|
85 * Used with iFormFlags to indicate where optimisations may or may not occur. |
|
86 * Uses bits above 0x100 as those below are used as static form flags for configuration by resource file. |
|
87 */ |
|
88 enum TDynamicFormFlags |
|
89 { |
|
90 EFormResizeOptimisationFlag = 0x100 , |
|
91 EFormForceEdwinResizeFlag = 0x200 |
|
92 } ; |
|
93 |
|
94 public: |
|
95 ~CEikDialogPage(); |
|
96 static CEikDialogPage* NewL(TInt aId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver); |
|
97 static CEikDialogPage* NewLC(TInt aId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver); |
|
98 static CEikDialogPage* NewL(TInt aId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver,TResourceReader& aReader); |
|
99 static CEikDialogPage* NewLC(TInt aId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver,TResourceReader& aReader); |
|
100 void SetDataPosition( TInt aTopY, TInt aBottomY, TBool aForceResize ); |
|
101 TSize PreferredSize() const; |
|
102 void SetActiveL(); |
|
103 void SetActiveAndFocusL(); |
|
104 void SetInactiveL(); |
|
105 TInt PageId() const; |
|
106 TInt LineId(const CCoeControl& aControl) const; |
|
107 TBool SetInitialFocus(); |
|
108 CCoeControl* CreateLineByTypeL(const TDesC& aCaption,TInt aLineId,TInt aControlType,TAny* aReturnValue); |
|
109 CCoeControl* Control(TInt aLineId) const; |
|
110 CCoeControl* ControlOrNull(TInt aLineId) const; |
|
111 TInt ControlHeight(TInt aLineIndex) const; |
|
112 CEikCaptionedControl* Line(TInt aLineId) const; |
|
113 CEikCaptionedControl* LineOrNull(TInt aLineId) const; |
|
114 CEikCaptionedControl* CurrentLine() const; |
|
115 void SetDensePacking(TBool aDensePacking); |
|
116 void InsertLineL(TInt aPosition,TInt aResourceId); |
|
117 void DeleteLine(TInt aLineId,TBool aRedrawNow); |
|
118 void AdjustAllIds(TInt aControlIdDelta); |
|
119 TInt FocusLineL(TInt aLineId); |
|
120 TInt FocusedLineId() const; |
|
121 void GetAutoValues(); |
|
122 TKeyResponse OfferUpDownKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType,TFocusNavigationMode aFocusNavigationMode); |
|
123 TBool OwnsLine(TInt aLineId) const; |
|
124 void ResetLineMinimumSizes(); |
|
125 TInt FindLineIndex(const CCoeControl* aControl) const; |
|
126 TBool RotateFocusByL(TInt aDelta); |
|
127 TKeyResponse OfferHotKeysKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
128 TBool TakesEnterKey(); |
|
129 TInt LineIndex(TInt aLineId); |
|
130 void ReportPageChangedL(); |
|
131 TInt GetFormFlags() const; |
|
132 void SetFormFlag( TInt16 aFlag, TBool aEnable ) ; // used with TDynamicFormFlags |
|
133 void ConstructFormFromResourceL( TResourceReader& aReader ) ; |
|
134 void SetEditableL( TBool aEditable, TBool aActivePage ) ; |
|
135 TBool IsEditable() const; |
|
136 TBool IsForm() const; |
|
137 |
|
138 void SetDoubleQuery(TBool aIsDoubleQuery); |
|
139 |
|
140 CEikFormAnim* AcquireAnim( TBool aAcquire, MEikFormAnimObserver* aObserver ) const; |
|
141 |
|
142 public: |
|
143 void UpdateScrollBarL(); |
|
144 TBool LineHandlerCalled() const; |
|
145 |
|
146 public: // from CCoeControl |
|
147 TSize MinimumSize(); |
|
148 virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const; |
|
149 virtual void HandleResourceChange(TInt aType); |
|
150 virtual void PrepareForFocusLossL(); |
|
151 virtual void SetDimmed(TBool aDimmed); |
|
152 virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
153 public: // from MCoeControlObserver |
|
154 virtual void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType); |
|
155 public: // from MEikEdwinSizeObserver |
|
156 virtual TBool HandleEdwinSizeEventL(CEikEdwin* aEdwin, TEdwinSizeEvent aEventType, TSize aDesirableEdwinSize); |
|
157 public: // from MEikEdwinObserver |
|
158 virtual void HandleEdwinEventL(CEikEdwin* aEdwin,TEdwinEvent aEventType); |
|
159 |
|
160 public: // from MAknPopupFieldObserver |
|
161 virtual void HandlePopupFieldEventL(CAknPopupField* aPopupField, TAknPopupFieldEvent aEventType, TInt aHint); |
|
162 public: |
|
163 void SetPageContainer(const CEikDialogPageContainer* aPageContainer); |
|
164 const CEikDialogPageContainer* PageContainer() const; |
|
165 protected: // from CCoeControl |
|
166 void WriteInternalStateL(RWriteStream& aWriteStream) const; |
|
167 void SizeChanged(); |
|
168 TInt CountComponentControls() const; |
|
169 CCoeControl* ComponentControl(TInt aIndex) const; |
|
170 void FocusChanged(TDrawNow aDrawNow); |
|
171 void Draw(const TRect& aRect) const; |
|
172 public: |
|
173 // added to allow Form format to be set by API |
|
174 IMPORT_C void SetFormLayout(TFormLayoutSelection aLayout); |
|
175 IMPORT_C TFormLayoutSelection FormLayout() const; |
|
176 public: |
|
177 public: |
|
178 TBool IsAtOrOffTopOfPage(const CCoeControl* aControl) const; |
|
179 TBool IsAtOrOffBottomOfPage(const CCoeControl* aControl) const ; |
|
180 public: |
|
181 TBool VisibleSizeOnPage(TInt& aHeightOfControlVisibleOnPage, const CCoeControl* aControl) const; |
|
182 |
|
183 /** |
|
184 * Scrolls cached drawing commands by @c aDelta pixels in y direction. |
|
185 * |
|
186 * @param aDelta A y-asix base on the sliding control's coordinate. |
|
187 * @param aDebugMsg Not used. |
|
188 * @param aDrawNow Whether or not the view should be drawn. |
|
189 */ |
|
190 void ScrollCacheByPixels( TInt aDelta, |
|
191 const TDesC& aDebugMsg, |
|
192 TBool aDrawNow = ETrue ); |
|
193 |
|
194 /** |
|
195 * Updates line's cached drawing commands. |
|
196 */ |
|
197 void UpdateLineInCache( CEikCaptionedControl* aLine ); |
|
198 |
|
199 /** |
|
200 * Physics simulation ended. |
|
201 */ |
|
202 void Synchronize(); |
|
203 |
|
204 /** |
|
205 * Can be used to query whether highlight graphics should be drawn. |
|
206 * |
|
207 * @since S60 5.2 |
|
208 * |
|
209 * @return ETrue if highlight should be drawn. |
|
210 */ |
|
211 TBool HighlightVisible() const; |
|
212 |
|
213 protected: // from MEikScrollBarObserver |
|
214 virtual void HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType); |
|
215 |
|
216 private: // new functions |
|
217 void AfterAddingNewLinesL(TInt aNewLineAdded); |
|
218 |
|
219 CEikDialogPage(TInt aId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,MEikDialogPageObserver* aPageObserver); |
|
220 void ConstructL(); |
|
221 void ConstructFromResourceL(TResourceReader& aReader, TBool aFormControl = EFalse ); |
|
222 void ConstructByTypeL(TInt aControlType,CEikCaptionedControl* aLine,CCoeControl* aContainer); |
|
223 void ShowFocus(TBool aFocus, TBool aRedraw=ETrue); |
|
224 SEikControlInfo CreateCustomControlL(TInt aControlType); |
|
225 void ChangeFocusTo(TInt aLineIndex); |
|
226 void PrepareForFocusTransitionL(); |
|
227 void ChangeFocusToAndExposeL(TInt aLine,TBool aShowWholeControl=EFalse); |
|
228 TInt TopFocusableLine() const; |
|
229 TInt BottomFocusableLine() const; |
|
230 TBool LineIsFocusable(TInt aLine) const; |
|
231 TBool ResizeEdwinToFitTextL(CEikEdwin* aEdwin, TDrawNow aDrawNow, TSize aDesirableEdwinSize); |
|
232 TInt YPosToLine2(TInt aYPos) const; |
|
233 TInt LineToYPos(TInt& aLine) const; |
|
234 void ExposeLine(TInt aLine, TBool aForceResize, TBool aShowWholeLine = EFalse ); |
|
235 void PassOnEventL(CCoeControl* aControl,MCoeControlObserver::TCoeEvent aEvent); |
|
236 CEikCaptionedControl* ConstructLineL(TInt aResourceId); |
|
237 CEikCaptionedControl* ConstructLineL(TResourceReader& aReader); |
|
238 TKeyResponse HandleCyclicFocusNavigationKeyL(const TKeyEvent& aKeyEvent); |
|
239 TKeyResponse HandleNonCyclicFocusNavigationKeyL(const TKeyEvent& aKeyEvent); |
|
240 void MakeEdwinScrollbarsVisibleL(TBool aVisible); |
|
241 void LineChangedL(TInt aControlId); |
|
242 void UpdateScrollBarThumb(); |
|
243 void ReconsiderPageSize(); |
|
244 void PrepareToDrawVerticalLine() const; |
|
245 |
|
246 /** |
|
247 * Specialized pointer event handling for forms. |
|
248 */ |
|
249 void HandleFormPointerEventL( const TPointerEvent& aPointerEvent ); |
|
250 |
|
251 /** |
|
252 * Updates physics data. |
|
253 */ |
|
254 void UpdatePhysics(); |
|
255 |
|
256 /** |
|
257 * Callback for highlight timer. |
|
258 */ |
|
259 static TInt HighlightTimerCallBack( TAny* aPtr ); |
|
260 |
|
261 /** |
|
262 * Handles highlight timer's expiration. |
|
263 */ |
|
264 void HandleHighlightTimer(); |
|
265 |
|
266 /** |
|
267 * Performs forced redraw of aControl and its component controls. |
|
268 */ |
|
269 void DrawControl( CCoeControl* aControl ) const; |
|
270 |
|
271 /** |
|
272 * Record all lines drawing commands to the cache. Existing cache is purged. |
|
273 */ |
|
274 void RecordLinesL(); |
|
275 |
|
276 /** |
|
277 * Records one line's drawing commands to the cache replacing existing commands for that line. |
|
278 */ |
|
279 void RecordLineL( TInt aLine ); |
|
280 |
|
281 /** |
|
282 * Scrolls all lines by aPixels in y direction. |
|
283 */ |
|
284 void ScrollByPixels( TInt aDelta ); |
|
285 |
|
286 /** |
|
287 * Removes pressed down highlight. |
|
288 */ |
|
289 void RemovePressedDownHighlight(); |
|
290 |
|
291 /** |
|
292 * Sets highlight's visibility. |
|
293 * |
|
294 * @since S60 5.2 |
|
295 * |
|
296 * @param aVisible ETrue to set highlight visible. |
|
297 */ |
|
298 void HighlightVisible( TBool aVisible ); |
|
299 |
|
300 enum TScrollDirection |
|
301 { |
|
302 ESingleLineScrollUp , |
|
303 ESingleLineScrollDown |
|
304 } ; |
|
305 void RegisterComponentL(TInt aControlType, CCoeControl* aControl, CEikCaptionedControl* aLine); |
|
306 static void CommonConstructCodeBetweenNewL(CEikDialogPage& aDialogPage, const CEikDialogPageContainer& aParent); |
|
307 |
|
308 public: |
|
309 TBool AnythingToDisplay() const; |
|
310 void DrawVerticalLine() const; |
|
311 CEikCaptionedControl* LineOnPageOrNull(TInt aLine) const; |
|
312 TSize RealDataSize() const; |
|
313 TInt NumberOfLines() const; |
|
314 CEikCaptionedControl* LineByIndex(TInt aIndex) const; |
|
315 |
|
316 private: |
|
317 CEikCapCArray* iLines; |
|
318 MEikDialogPageObserver* iPageObserver; |
|
319 TInt iPageId; |
|
320 TInt iCurrentLine; |
|
321 TInt16 iFormFlags ; |
|
322 TBool iIsEditable; |
|
323 TBool iFormControl ; |
|
324 TInt iLastExposedLine; |
|
325 TInt iLastExposedLineViewWinYPosition; |
|
326 const CEikDialogPageContainer* iPageContainer; |
|
327 TFormLayoutSelection iFormLayout; |
|
328 CAknPaneScroll *iScroll; |
|
329 public: |
|
330 mutable CEikEdwin* iIgnoreFurtherEdwinResizeEvents; |
|
331 private: |
|
332 CDialogPageExtension* iExtension; |
|
333 void DrawEmptyListL( CWindowGc& aGc ); |
|
334 CAknFormPhysics* iPhysics; |
|
335 |
|
336 /** |
|
337 * Stores highlight's visibility. |
|
338 */ |
|
339 TBool iHighlightVisible; |
|
340 |
|
341 public: |
|
342 /** |
|
343 * HandlePointerEventL |
|
344 * Function notifys the pages observer that the page has been tapped. (stylus down&up) |
|
345 * @param aPointerEvent the pointer event. |
|
346 */ |
|
347 virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
348 |
|
349 void SetScbState(TBool aExternal); |
|
350 TBool ScbState() const; |
|
351 |
|
352 private: |
|
353 /** |
|
354 * From CAknControl |
|
355 */ |
|
356 IMPORT_C void* ExtensionInterface( TUid aInterface ); |
|
357 }; |
|
358 |
|
359 |
|
360 /** |
|
361 * The CEikDialogPageContainer class contains one or more dialog pages and provides an interface to the active |
|
362 * page. |
|
363 * |
|
364 * @internal |
|
365 * @since ER5U |
|
366 */ |
|
367 NONSHARABLE_CLASS(CEikDialogPageContainer) : public CAknControl, public MCoeControlContext, public MCoeControlHitTest |
|
368 { |
|
369 public: |
|
370 ~CEikDialogPageContainer(); |
|
371 static CEikDialogPageContainer* NewL(const CCoeControl& aParent,MEikDialogPageObserver* aPageObserver); |
|
372 static CEikDialogPageContainer* NewLC(const CCoeControl& aParent,MEikDialogPageObserver* aPageObserver); |
|
373 TSize PreferredSize(const TSize& aMaxSize) const; |
|
374 void SetActivePageByIdL(TInt aPageId); |
|
375 void SetActivePageByIndexL(TInt aPageIndex); |
|
376 TInt ActivateFirstPageL(); |
|
377 void AddPageL(TInt aPageId); |
|
378 void AddPageL(TInt aPageId,TResourceReader& aReader); |
|
379 TBool SetInitialFocus(); |
|
380 CEikCaptionedControl* Line(TInt aLineId) const; |
|
381 CEikCaptionedControl* LineOrNull(TInt aLineId) const; |
|
382 CEikCaptionedControl* CurrentLine() const; |
|
383 void SetPageDensePacked(TInt aPageId,TBool aDensePacked); |
|
384 void SetAllPagesDensePacked(TBool aDensePacked); |
|
385 void SetPageDimmed(TInt aPageId,TBool aDimmed,TDrawNow aDrawNow); |
|
386 TBool IsActivePageDimmed() const; |
|
387 TInt LineId(const CCoeControl& aControl) const; |
|
388 void InsertLineL(TInt aPosition,TInt aPageId,TInt aResourceId); |
|
389 void DeleteLine(TInt aLineId, TBool aRedrawNow); |
|
390 void AdjustAllIds(TInt aPageId,TInt aControlIdDelta); |
|
391 CCoeControl* CreateLineByTypeL(const TDesC& aCaption,TInt aLineId,TInt aControlType,TAny* aReturnValue); |
|
392 CCoeControl* CreateLineByTypeL(const TDesC& aCaption,TInt aPageId,TInt aLineId,TInt aControlType,TAny* aReturnValue); |
|
393 TInt FocusLineL(TInt aLineId); |
|
394 TInt FocusedLineId() const; |
|
395 void GetAutoValues(); |
|
396 TKeyResponse OfferUpDownKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType,CEikDialogPage::TFocusNavigationMode aFocusNavigationMode); |
|
397 TInt ActivePageId() const; |
|
398 TInt ActivePageIndex() const; |
|
399 void ResetLineMinimumSizes(); |
|
400 TInt FindLineIndex(const CCoeControl& aControl) const; |
|
401 TBool RotateFocusByL(TInt aDelta); |
|
402 TInt NumPages() const; |
|
403 TKeyResponse OfferHotKeysKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
404 TBool TakesEnterKey(); |
|
405 TInt FindPageIndexForLineId(TInt aLineId); |
|
406 CEikDialogPage* Page( TInt aPageID ) ; |
|
407 void SetEditableL( TBool aEditable ) ; |
|
408 |
|
409 CEikFormAnim* AcquireAnim( TBool aAcquire, MEikFormAnimObserver* aObserver ) const; |
|
410 |
|
411 public: // from CCoeControl |
|
412 virtual void Draw(const TRect& aRect) const; |
|
413 virtual TSize MinimumSize(); |
|
414 virtual void PrepareForFocusLossL(); |
|
415 virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
416 virtual void HandleResourceChange(TInt aType); |
|
417 public: // from MCoeControlContext |
|
418 virtual void PrepareContext(CWindowGc& aGc) const; |
|
419 public: |
|
420 TBool HitRegionContains( const TPoint& aPoint, const CCoeControl& aControl ) const; |
|
421 public: |
|
422 void SetPageFormSized(); |
|
423 protected: // from CCoeControl |
|
424 virtual void SizeChanged(); |
|
425 virtual TInt CountComponentControls() const; |
|
426 virtual CCoeControl* ComponentControl(TInt aIndex) const; |
|
427 virtual void ActivateL(); |
|
428 virtual void FocusChanged(TDrawNow aDrawNow); |
|
429 virtual void WriteInternalStateL(RWriteStream& aWriteStream) const; |
|
430 public: |
|
431 void SetPageSelector(const CEikDialogPageSelector* aPageSelector); |
|
432 const CEikDialogPageSelector* PageSelector() const; |
|
433 private: |
|
434 CEikDialogPageContainer(MEikDialogPageObserver* aPageObserver); |
|
435 void ConstructL(const CCoeControl& aParent); |
|
436 void ConstructFromResourceL(TResourceReader& aReader,const CCoeControl& aParent); |
|
437 void CommonConstructL(const CCoeControl& aParent); |
|
438 void CreatePageArrayL(); |
|
439 TInt PageIndex(TInt aPageId) const; |
|
440 TInt PageId(TInt aIndex) const; |
|
441 TInt PageIdFromLineId(TInt aLineId) const; |
|
442 public: |
|
443 void CreateScrollBarL(const CCoeControl& aParent); |
|
444 CEikScrollBarFrame* ScrollBar() const; |
|
445 |
|
446 private: |
|
447 CEikScrollBarFrame* iSBFrame; |
|
448 CArrayPtr<CEikDialogPage>* iPageArray; |
|
449 MEikDialogPageObserver* iPageObserver; |
|
450 TInt iActivePage; |
|
451 const CEikDialogPageSelector* iPageSelector; |
|
452 TBool iForm; |
|
453 TBool iIsEditable; |
|
454 |
|
455 /** |
|
456 * A singleton animation object for interfacing AknsEffectAnimation. All |
|
457 * captioned controls (in all dialog pages) share the same animation. |
|
458 * Only animation creation and memory management is vested here. Actual |
|
459 * animation usage is implemented in CaptionedControl. |
|
460 */ |
|
461 CEikFormAnim* iAnimation; |
|
462 }; |
|
463 |
|
464 #endif |