00001 // EIKDPAGE.H 00002 // 00003 // Copyright (c) 1997-1999 Symbian Ltd. All rights reserved. 00004 // 00005 00006 #if !defined(__EIKDPAGE_H__) 00007 #define __EIKDPAGE_H__ 00008 00009 #include <coeccntx.h> 00010 #include <eiksbfrm.h> 00011 #include <coecobs.h> 00012 #include <eikedwob.h> 00013 #include <aknpopupfieldtext.h> 00014 #include <AknControl.h> 00015 00016 // 00017 // Forward declarations. 00018 // 00019 00020 class CEikCapCArray; 00021 class CEikCaptionedControl; 00022 class CEikDialogPageContainer; 00023 class CEikEdwin; 00024 class CEikLabel; 00025 class MEikDialogPageObserver; 00026 struct SEikControlInfo; 00027 class CAknLayoutData; 00028 #start_since SINCE_3_1_SDK 00029 class CDialogPageExtension; 00030 #end_since SINCE_3_1_SDK 00031 00032 class CEikFormAnim; 00033 class MEikFormAnimObserver; 00034 class CAknPaneScroll; 00035 00036 class CEikDlgToolTipMgr ; 00043 NONSHARABLE_CLASS(CEikDialogPage) : 00044 public CAknControl, 00045 public MCoeControlObserver, 00046 public MEikScrollBarObserver, 00047 public MEikEdwinSizeObserver, 00048 public MAknPopupFieldObserver, 00049 public MEikEdwinObserver 00050 { 00051 public: 00052 enum TFocusNavigationMode 00053 { 00054 ECyclic, 00055 ENonCyclic 00056 }; 00057 enum TAScrollBarBreadthAllocationMode 00058 { 00059 ENone =0x0000, 00060 EScrollBarBreadthPreAllocated =0x1000 00061 }; 00067 enum TFormLayoutSelection 00068 { 00069 ESingle, 00070 EDouble 00071 }; 00072 00077 enum TDynamicFormFlags 00078 { 00079 EFormResizeOptimisationFlag = 0x100 , 00080 EFormForceEdwinResizeFlag = 0x200 00081 } ; 00082 00083 00084 public: 00085 ~CEikDialogPage(); 00086 static CEikDialogPage* NewL(TInt aId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver); 00087 static CEikDialogPage* NewLC(TInt aId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver); 00088 static CEikDialogPage* NewL(TInt aId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver,TResourceReader& aReader); 00089 static CEikDialogPage* NewLC(TInt aId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver,TResourceReader& aReader); 00090 void SetDataPosition(TInt aPosition); 00091 TSize PreferredSize() const; 00092 void SetActiveL(); 00093 void SetActiveAndFocusL(); 00094 void SetInactiveL(); 00095 TInt PageId() const; 00096 TInt LineId(const CCoeControl& aControl) const; 00097 TBool SetInitialFocus(); 00098 CCoeControl* CreateLineByTypeL(const TDesC& aCaption,TInt aLineId,TInt aControlType,TAny* aReturnValue); 00099 void SetControlCaptionL(TInt aLineId,const TDesC& aText); 00100 void SetControlCaptionL(TInt aLineId,TInt aResourceId); 00101 CCoeControl* Control(TInt aLineId) const; 00102 CCoeControl* ControlOrNull(TInt aLineId) const; 00103 TInt ControlHeight(TInt aLineIndex) const; 00104 CEikCaptionedControl* Line(TInt aLineId) const; 00105 CEikCaptionedControl* LineOrNull(TInt aLineId) const; 00106 CEikCaptionedControl* CurrentLine() const; 00107 void SetDensePacking(TBool aDensePacking); 00108 void InsertLineL(TInt aPosition,TInt aResourceId); 00109 void DeleteLine(TInt aLineId,TBool aRedrawNow); 00110 void AdjustAllIds(TInt aControlIdDelta); 00111 TInt FocusLineL(TInt aLineId); 00112 TInt FocusedLineId() const; 00113 void GetAutoValues(); 00114 TKeyResponse OfferUpDownKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType,TFocusNavigationMode aFocusNavigationMode); 00115 TBool OwnsLine(TInt aLineId) const; 00116 void ResetLineMinimumSizes(); 00117 TInt FindLineIndex(const CCoeControl* aControl) const; 00118 TBool RotateFocusByL(TInt aDelta); 00119 TKeyResponse OfferHotKeysKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); 00120 TBool TakesEnterKey(); 00121 TInt LineIndex(TInt aLineId); 00122 void ReportPageChangedL(); 00123 void SetFlag(TInt aFlag); 00124 TInt GetFormFlags() const; 00125 void SetFormFlag( TInt16 aFlag, TBool aEnable ) ; // used with TDynamicFormFlags 00126 void ConstructFormFromResourceL( TResourceReader& aReader ) ; 00127 void SetEditableL( TBool aEditable, TBool aActivePage ) ; 00128 void SetTipManager( CEikDlgToolTipMgr* aTipManager ) ; 00129 TBool IsEditable() const; 00130 TBool IsForm() const; 00131 00132 CEikFormAnim* AcquireAnim( TBool aAcquire, MEikFormAnimObserver* aObserver ) const; 00133 00134 public: 00135 void UpdateScrollBarL(); 00136 00137 00138 public: // from CCoeControl 00139 TSize MinimumSize(); 00140 virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const; 00141 virtual void HandleResourceChange(TInt aType); 00142 virtual void PrepareForFocusLossL(); 00143 virtual void SetDimmed(TBool aDimmed); 00144 virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); 00145 //virtual TTypeUid::Ptr MopSupplyObject(TTypeUid aId); 00146 public: // from MCoeControlObserver 00147 virtual void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType); 00148 public: // from MEikEdwinSizeObserver 00149 virtual TBool HandleEdwinSizeEventL(CEikEdwin* aEdwin, TEdwinSizeEvent aEventType, TSize aDesirableEdwinSize); 00150 public: // from MEikEdwinObserver 00151 virtual void HandleEdwinEventL(CEikEdwin* aEdwin,TEdwinEvent aEventType); 00152 00153 public: // from MAknPopupFieldObserver 00154 virtual void HandlePopupFieldEventL(CAknPopupField* aPopupField, TAknPopupFieldEvent aEventType, TInt aHint); 00155 public: 00156 void SetPageContainer(const CEikDialogPageContainer* aPageContainer); 00157 const CEikDialogPageContainer* PageContainer() const; 00158 void RedrawNecessaryDataNow(const TRect& aRect) const; 00159 protected: // from CCoeControl 00160 void WriteInternalStateL(RWriteStream& aWriteStream) const; 00161 void SizeChanged(); 00162 TInt CountComponentControls() const; 00163 CCoeControl* ComponentControl(TInt aIndex) const; 00164 void FocusChanged(TDrawNow aDrawNow); 00165 void Draw(const TRect& aRect) const; 00166 public: 00167 // added to allow Form format to be set by API 00168 IMPORT_C void SetFormLayout(TFormLayoutSelection aLayout); 00169 IMPORT_C TFormLayoutSelection FormLayout() const; 00170 public: 00171 CEikCaptionedControl* FindNextControlOnPageWithHeight(TBool aUpwards,const CEikCaptionedControl* aLineYouAreOn) const; 00172 public: 00173 TBool IsAtOrOffTopOfPage(const CCoeControl* aControl) const; 00174 TBool IsAtOrOffBottomOfPage(const CCoeControl* aControl) const ; 00175 public: 00176 TBool VisibleSizeOnPage(TInt& aHeightOfControlVisibleOnPage, const CCoeControl* aControl) const; 00177 00178 protected: // from MEikScrollBarObserver 00179 virtual void HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType); 00180 00181 private: // from CCoeControl 00182 void Reserved_2(); 00183 private: 00184 enum TFlag 00185 { 00186 EWindowsSizedForScrollBar=0x0001 00187 }; 00188 private: // new functions 00189 void AfterAddingNewLinesL(TInt aNewLineAdded); 00190 00191 CEikDialogPage(TInt aId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,MEikDialogPageObserver* aPageObserver); 00192 void ConstructL(); 00193 void ConstructFromResourceL(TResourceReader& aReader, TBool aFormControl = EFalse ); 00194 void ConstructByTypeL(TInt aControlType,CEikCaptionedControl* aLine,CCoeControl* aContainer); 00195 void ShowFocus(TBool aFocus, TBool aRedraw=ETrue); 00196 SEikControlInfo CreateCustomControlL(TInt aControlType); 00197 void ChangeFocusTo(TInt aLineIndex); 00198 void PrepareForFocusTransitionL(); 00199 TInt IdOfFocusControl() const; 00200 void UpdateScrollBar(); 00201 void ChangeFocusToAndExposeL(TInt aLine,TBool aShowWholeControl=EFalse); 00202 TInt TopFocusableLine() const; 00203 TInt BottomFocusableLine() const; 00204 TBool LineIsFocusable(TInt aLine) const; 00205 TBool ResizeEdwinToFitTextL(CEikEdwin* aEdwin, TDrawNow aDrawNow, TSize aDesirableEdwinSize); 00206 TSize SizeDeltaOfEdwinBorderPlusMargins(CEikEdwin* aEdwin) const; 00207 TInt YPosToLine(TInt& aYPos) const; 00208 TInt YPosToLine2(TInt aYPos) const; 00209 TInt LineToYPos(TInt& aLine) const; 00210 void ExposeLine(TInt aLine, TBool aShowWholeLine=EFalse); 00211 void SetDataWinSize(); 00212 void PassOnEventL(CCoeControl* aControl,MCoeControlObserver::TCoeEvent aEvent); 00213 CEikCaptionedControl* ConstructLineL(TInt aResourceId); 00214 CEikCaptionedControl* ConstructLineL(TResourceReader& aReader); 00215 void ConstructLineL(TResourceReader& aReader,CEikCaptionedControl* aLine); 00216 TKeyResponse HandleCyclicFocusNavigationKeyL(const TKeyEvent& aKeyEvent); 00217 TKeyResponse HandleNonCyclicFocusNavigationKeyL(const TKeyEvent& aKeyEvent); 00218 void MakeEdwinScrollbarsVisibleL(TBool aVisible); 00219 TBool Flag(TFlag aFlag) const; 00220 void SetFlag(TFlag aFlag); 00221 void ClearFlag(TFlag aFlag); 00222 void LineChangedL(TInt aControlId); 00223 00224 void UpdateToolTipL() ; 00225 void UpdateScrollBarThumb(); 00226 00227 TInt CalculateEdwinCursorPosition( CEikEdwin* aEdwin , TInt& aLineNumber ) const ; 00228 TInt GetPositionOfEdwinCursorInDataWin(CEikEdwin* aEdwin) const; 00229 void ReconsiderPageSize(); 00230 void PrepareToDrawVerticalLine() const; 00231 00232 enum TScrollDirection 00233 { 00234 ESingleLineScrollUp , 00235 ESingleLineScrollDown 00236 } ; 00237 void RegisterComponentL(TInt aControlType, CCoeControl* aControl, CEikCaptionedControl* aLine); 00238 static void CommonConstructCodeBetweenNewL(CEikDialogPage& aDialogPage, const CEikDialogPageContainer& aParent); 00239 00240 // some private layout methods 00241 TInt NumberOfLinesOfContent(TInt aLineIndex); 00242 TInt MaxNumberOfLinesOnPage(); 00243 TInt PositionOneDataPane(TInt aLineIndex, TInt aFirstLineOffsetOnScreen, TInt aLinesHidden); 00244 void PositionFormFields(TInt aFirstLineIndex, TInt aLastLineIndex, TInt aFirstTextLineIndex); 00245 00246 TBool IsDataPane(TInt aLineIndex); 00247 TBool IsDataWidePane(TInt aLineIndex); 00248 TBool IsPopupPane(TInt aLineIndex); 00249 TBool IsPopupWidePane(TInt aLineIndex); 00250 TBool IsSliderPane(TInt aLineIndex); 00251 TBool IsSliderWidePane(TInt aLineIndex); 00252 public: 00253 TInt TopLineIndex() const; 00254 TInt BottomLineIndex() const; 00255 TInt HiddenLines() const; 00256 00257 public: 00258 TBool AnythingToDisplay() const; 00259 void DrawVerticalLine() const; 00260 CEikCaptionedControl* LineOnPageOrNull(TInt aLine) const; 00261 TSize RealDataSize() const; 00262 TInt NumberOfLines() const; 00263 CEikCaptionedControl* LineByIndex(TInt aIndex) const; 00264 private: 00265 RWindow& iViewWin; 00266 CEikScrollBarFrame& iSBFrame; //no longer in use. SB is used via iPageContainer->ScrollBar() 00267 CEikCapCArray* iLines; 00268 MEikDialogPageObserver* iPageObserver; 00269 TInt iPageId; 00270 TInt iCurrentLine; 00271 TPoint iViewWinPos; 00272 TSize iViewWinSize; 00273 TPoint iDataWinPos; 00274 TSize iDataWinSize; 00275 TInt iFlags; 00276 TInt16 iFormFlags ; 00277 TBool iIsEditable; 00278 00279 TBool iFormControl ; 00280 CEikDlgToolTipMgr* iTipManager ; 00281 00282 TInt iLastExposedLine; 00283 TInt iLastExposedLineViewWinYPosition; 00284 const CEikDialogPageContainer* iPageContainer; 00285 TFormLayoutSelection iFormLayout; 00286 00287 // Offset necessary because LAF instructs use of List Layout for Forms but the parent panes have different origins. 00288 TInt iXOffsetForDataPaneInEditMode ; 00289 TInt iYOffsetForDataPaneInEditMode ; 00290 00291 // Variables set from LAF to replace hard coded constants. 00292 TInt iDialogPageScreenWidth ; 00293 TInt iDialogPageScreenHeight ; 00294 TInt iDialogPageDataHeight ; 00295 CAknPaneScroll *iScroll; 00296 // this iBgContext is different from dialog's context that its used only inside dialogpage's window. 00297 //CAknsListBoxBackgroundControlContext *iBgContext; 00298 public: 00299 mutable CEikEdwin* iIgnoreFurtherEdwinResizeEvents; 00300 private: 00301 CDialogPageExtension* iExtension; 00302 void DrawEmptyListL( CWindowGc& aGc ); 00303 00304 public: 00310 virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent); 00311 00312 #start_since SINCE_3_1_SDK 00313 00316 void SetScbState(TBool aExternal); 00320 TBool ScbState() const; 00321 #end_since SINCE_3_1_SDK 00322 00323 private: 00327 IMPORT_C void* ExtensionInterface( TUid aInterface ); 00328 }; 00329 00330 00338 NONSHARABLE_CLASS(CEikDialogPageContainer) : public CAknControl, public MCoeControlContext 00339 { 00340 public: 00341 ~CEikDialogPageContainer(); 00342 static CEikDialogPageContainer* NewL(const CCoeControl& aParent,MEikDialogPageObserver* aPageObserver); 00343 static CEikDialogPageContainer* NewLC(const CCoeControl& aParent,MEikDialogPageObserver* aPageObserver); 00344 TSize PreferredSize(const TSize& aMaxSize) const; 00345 void SetActivePageByIdL(TInt aPageId); 00346 void SetActivePageByIndexL(TInt aPageIndex); 00347 TInt ActivateFirstPageL(); 00348 void AddPageL(TInt aPageId); 00349 void AddPageL(TInt aPageId,TResourceReader& aReader); 00350 TBool SetInitialFocus(); 00351 CEikCaptionedControl* Line(TInt aLineId) const; 00352 CEikCaptionedControl* LineOrNull(TInt aLineId) const; 00353 CEikCaptionedControl* CurrentLine() const; 00354 void SetPageDensePacked(TInt aPageId,TBool aDensePacked); 00355 void SetAllPagesDensePacked(TBool aDensePacked); 00356 void SetPageDimmed(TInt aPageId,TBool aDimmed,TDrawNow aDrawNow); 00357 TBool IsActivePageDimmed() const; 00358 TInt LineId(const CCoeControl& aControl) const; 00359 void InsertLineL(TInt aPosition,TInt aPageId,TInt aResourceId); 00360 void DeleteLine(TInt aLineId, TBool aRedrawNow); 00361 void AdjustAllIds(TInt aPageId,TInt aControlIdDelta); 00362 CCoeControl* CreateLineByTypeL(const TDesC& aCaption,TInt aLineId,TInt aControlType,TAny* aReturnValue); 00363 CCoeControl* CreateLineByTypeL(const TDesC& aCaption,TInt aPageId,TInt aLineId,TInt aControlType,TAny* aReturnValue); 00364 TInt FocusLineL(TInt aLineId); 00365 TInt FocusedLineId() const; 00366 void GetAutoValues(); 00367 TKeyResponse OfferUpDownKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType,CEikDialogPage::TFocusNavigationMode aFocusNavigationMode); 00368 TInt ActivePageId() const; 00369 TInt ActivePageIndex() const; 00370 void ResetLineMinimumSizes(); 00371 TInt FindLineIndex(const CCoeControl& aControl) const; 00372 TBool RotateFocusByL(TInt aDelta); 00373 TInt NumPages() const; 00374 TKeyResponse OfferHotKeysKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); 00375 TBool TakesEnterKey(); 00376 TInt FindPageIndexForLineId(TInt aLineId); 00377 void SetPageFlag(TInt aPageId, TInt aFlag); 00378 00379 CEikDialogPage* Page( TInt aPageID ) ; 00380 void SetEditableL( TBool aEditable ) ; 00381 void SetTipManager( CEikDlgToolTipMgr* aTipManager ) ; 00382 00383 CEikFormAnim* AcquireAnim( TBool aAcquire, MEikFormAnimObserver* aObserver ) const; 00384 00385 public: // from CCoeControl 00386 virtual void Draw(const TRect& aRect) const; 00387 virtual TSize MinimumSize(); 00388 virtual void PrepareForFocusLossL(); 00389 virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); 00390 virtual void HandleResourceChange(TInt aType); 00391 public: // from MCoeControlContext 00392 virtual void PrepareContext(CWindowGc& aGc) const; 00393 public: 00394 void SetPageFormSized(); 00395 protected: // from CCoeControl 00396 virtual void SizeChanged(); 00397 virtual TInt CountComponentControls() const; 00398 virtual CCoeControl* ComponentControl(TInt aIndex) const; 00399 virtual void ActivateL(); 00400 virtual void FocusChanged(TDrawNow aDrawNow); 00401 virtual void WriteInternalStateL(RWriteStream& aWriteStream) const; 00402 virtual void Reserved_2(); 00403 public: 00404 void SetPageSelector(const CEikDialogPageSelector* aPageSelector); 00405 const CEikDialogPageSelector* PageSelector() const; 00406 void DrawBackgroundNow(const TRect& aRect) const; 00407 private: 00408 void DrawBackground(const TRect& aRect) const; 00409 private: 00410 CEikDialogPageContainer(MEikDialogPageObserver* aPageObserver); 00411 void ConstructL(const CCoeControl& aParent); 00412 void ConstructFromResourceL(TResourceReader& aReader,const CCoeControl& aParent); 00413 void CommonConstructL(const CCoeControl& aParent); 00414 void CreatePageArrayL(); 00415 //void CreateScrollBarL(const CCoeControl& aParent); ->public 00416 void CreateViewWinL(const CCoeControl& aParent); 00417 TInt PageIndex(TInt aPageId) const; 00418 TInt PageId(TInt aIndex) const; 00419 TInt PageIdFromLineId(TInt aLineId) const; 00420 void SetToolTips() ; 00421 public: 00422 void CreateScrollBarL(const CCoeControl& aParent); 00423 CEikScrollBarFrame* ScrollBar() const; 00424 00425 private: 00426 CEikScrollBarFrame* iSBFrame; 00427 CArrayPtr<CEikDialogPage>* iPageArray; 00428 MEikDialogPageObserver* iPageObserver; 00429 TInt iActivePage; 00430 CEikDlgToolTipMgr* iTipManager ; 00431 const CEikDialogPageSelector* iPageSelector; 00432 TBool iForm; 00433 TBool iIsEditable; 00434 00435 // Variables set from LAF to replace hard coded constants. 00436 TInt iDialogPageScreenWidth ; 00437 TInt iDialogPageScreenHeight ; 00438 TInt iDialogPageDataHeight ; 00439 00440 CAknLayoutData *iLayoutData; // deprecated 00447 CEikFormAnim* iAnimation; 00448 }; 00449 00450 #endif