2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #if !defined(__EIKDPAGE_H__)
20 #define __EIKDPAGE_H__
26 #include <AknPopupFieldText.h>
27 #include <AknControl.h>
30 // Forward declarations.
34 class CEikCaptionedControl;
35 class CEikDialogPageContainer;
38 class MEikDialogPageObserver;
39 struct SEikControlInfo;
41 class CDialogPageExtension;
44 class MEikFormAnimObserver;
46 class CAknFormPhysics;
49 * The CEikDialogPage class implements a scrollable dialog page control.
54 NONSHARABLE_CLASS(CEikDialogPage) :
56 public MCoeControlObserver,
57 public MEikScrollBarObserver,
58 public MEikEdwinSizeObserver,
59 public MAknPopupFieldObserver,
60 public MEikEdwinObserver
63 enum TFocusNavigationMode
68 enum TAScrollBarBreadthAllocationMode
71 EScrollBarBreadthPreAllocated =0x1000
74 * Enumeration to express what layout is currently being used. Note that the use of
75 * bitmaps on the left is controlled by D
78 enum TFormLayoutSelection
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.
88 enum TDynamicFormFlags
90 EFormResizeOptimisationFlag = 0x100 ,
91 EFormForceEdwinResizeFlag = 0x200
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;
103 void SetActiveAndFocusL();
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;
138 void SetDoubleQuery(TBool aIsDoubleQuery);
140 CEikFormAnim* AcquireAnim( TBool aAcquire, MEikFormAnimObserver* aObserver ) const;
143 void UpdateScrollBarL();
144 TBool LineHandlerCalled() const;
146 public: // from CCoeControl
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);
160 public: // from MAknPopupFieldObserver
161 virtual void HandlePopupFieldEventL(CAknPopupField* aPopupField, TAknPopupFieldEvent aEventType, TInt aHint);
163 void SetPageContainer(const CEikDialogPageContainer* aPageContainer);
164 const CEikDialogPageContainer* PageContainer() const;
165 protected: // from CCoeControl
166 void WriteInternalStateL(RWriteStream& aWriteStream) const;
168 TInt CountComponentControls() const;
169 CCoeControl* ComponentControl(TInt aIndex) const;
170 void FocusChanged(TDrawNow aDrawNow);
171 void Draw(const TRect& aRect) const;
173 // added to allow Form format to be set by API
174 IMPORT_C void SetFormLayout(TFormLayoutSelection aLayout);
175 IMPORT_C TFormLayoutSelection FormLayout() const;
178 TBool IsAtOrOffTopOfPage(const CCoeControl* aControl) const;
179 TBool IsAtOrOffBottomOfPage(const CCoeControl* aControl) const ;
181 TBool VisibleSizeOnPage(TInt& aHeightOfControlVisibleOnPage, const CCoeControl* aControl) const;
184 * Scrolls cached drawing commands by @c aDelta pixels in y direction.
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.
190 void ScrollCacheByPixels( TInt aDelta,
191 const TDesC& aDebugMsg,
192 TBool aDrawNow = ETrue );
195 * Updates line's cached drawing commands.
197 void UpdateLineInCache( CEikCaptionedControl* aLine );
200 * Physics simulation ended.
205 * Can be used to query whether highlight graphics should be drawn.
209 * @return ETrue if highlight should be drawn.
211 TBool HighlightVisible() const;
213 protected: // from MEikScrollBarObserver
214 virtual void HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType);
216 private: // new functions
217 void AfterAddingNewLinesL(TInt aNewLineAdded);
219 CEikDialogPage(TInt aId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,MEikDialogPageObserver* aPageObserver);
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;
247 * Specialized pointer event handling for forms.
249 void HandleFormPointerEventL( const TPointerEvent& aPointerEvent );
252 * Updates physics data.
254 void UpdatePhysics();
257 * Callback for highlight timer.
259 static TInt HighlightTimerCallBack( TAny* aPtr );
262 * Handles highlight timer's expiration.
264 void HandleHighlightTimer();
267 * Performs forced redraw of aControl and its component controls.
269 void DrawControl( CCoeControl* aControl ) const;
272 * Record all lines drawing commands to the cache. Existing cache is purged.
277 * Records one line's drawing commands to the cache replacing existing commands for that line.
279 void RecordLineL( TInt aLine );
282 * Scrolls all lines by aPixels in y direction.
284 void ScrollByPixels( TInt aDelta );
287 * Removes pressed down highlight.
289 void RemovePressedDownHighlight();
292 * Sets highlight's visibility.
296 * @param aVisible ETrue to set highlight visible.
298 void HighlightVisible( TBool aVisible );
300 enum TScrollDirection
302 ESingleLineScrollUp ,
303 ESingleLineScrollDown
305 void RegisterComponentL(TInt aControlType, CCoeControl* aControl, CEikCaptionedControl* aLine);
306 static void CommonConstructCodeBetweenNewL(CEikDialogPage& aDialogPage, const CEikDialogPageContainer& aParent);
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;
317 CEikCapCArray* iLines;
318 MEikDialogPageObserver* iPageObserver;
324 TInt iLastExposedLine;
325 TInt iLastExposedLineViewWinYPosition;
326 const CEikDialogPageContainer* iPageContainer;
327 TFormLayoutSelection iFormLayout;
328 CAknPaneScroll *iScroll;
330 mutable CEikEdwin* iIgnoreFurtherEdwinResizeEvents;
332 CDialogPageExtension* iExtension;
333 void DrawEmptyListL( CWindowGc& aGc );
334 CAknFormPhysics* iPhysics;
337 * Stores highlight's visibility.
339 TBool iHighlightVisible;
343 * HandlePointerEventL
344 * Function notifys the pages observer that the page has been tapped. (stylus down&up)
345 * @param aPointerEvent the pointer event.
347 virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
349 void SetScbState(TBool aExternal);
350 TBool ScbState() const;
356 IMPORT_C void* ExtensionInterface( TUid aInterface );
361 * The CEikDialogPageContainer class contains one or more dialog pages and provides an interface to the active
367 NONSHARABLE_CLASS(CEikDialogPageContainer) : public CAknControl, public MCoeControlContext, public MCoeControlHitTest
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 ) ;
409 CEikFormAnim* AcquireAnim( TBool aAcquire, MEikFormAnimObserver* aObserver ) const;
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;
420 TBool HitRegionContains( const TPoint& aPoint, const CCoeControl& aControl ) const;
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;
431 void SetPageSelector(const CEikDialogPageSelector* aPageSelector);
432 const CEikDialogPageSelector* PageSelector() const;
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;
443 void CreateScrollBarL(const CCoeControl& aParent);
444 CEikScrollBarFrame* ScrollBar() const;
447 CEikScrollBarFrame* iSBFrame;
448 CArrayPtr<CEikDialogPage>* iPageArray;
449 MEikDialogPageObserver* iPageObserver;
451 const CEikDialogPageSelector* iPageSelector;
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.
461 CEikFormAnim* iAnimation;