epoc32/include/mw/eikcapc.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 
    18 
    19 #if !defined(__EIKCAPC_H__)
    20 #define __EIKCAPC_H__
    21 
    22 #if !defined(__COECNTRL_H__)
    23 #include <coecntrl.h>
    24 #endif
    25 
    26 #if !defined(__FEPBASE_H__)
    27 #include <fepbase.h>
    28 #endif
    29 
    30 #if !defined(__EIKLABEL_H__)
    31 #include <eiklabel.h>
    32 #endif
    33 
    34 #include <eikdialg.h>
    35 #include <eikdpage.h>
    36 
    37 #include <AknControl.h>
    38 
    39 class CEikImage ;
    40 class CEikDialogPage;
    41 // Forward declaration of types used in layout routines.
    42 class CAknPopupField;
    43 class CAknSlider;
    44 class CEikEdwin;
    45 class CEikMfne; 
    46 class CEikSecretEditor;
    47 class CEikCapCLabel ;
    48 class CEikCapCExtension;
    49 class MPointerEventObserver;
    50 class MAknsControlContext;
    51 
    52 /** CaptionedControl
    53  *
    54  * CaptionedControl is part of the dialogs. All dialogs and forms use captionedcontrol
    55  * as a control for one DLG_LINE. Each DLG_LINE has one captionedcontrol in it.
    56  * 
    57  * Rectangle of the captionedcontrol is single form field / form line or DLG_LINE's
    58  * rectangle dependent on the dialog type.
    59  */
    60 class CEikCaptionedControl : public CAknControl, public MCoeCaptionRetrieverForFep, public MCoeControlObserver
    61     {
    62     friend class CEikCapCExtension;
    63 public:
    64     enum TSpaceSharingFlags
    65         {
    66         EIfTooSmallCtlGetsWidthLast         =0x0,
    67         EIfTooSmallCtlGetsWidthFirst        =0x1,
    68         EIfTooSmallCtlGetsEqualShareOfWidth =0x2,
    69         EIfTooBigCtlStaysMinHeight          =0x4,
    70         EIfTooBigCtlStaysMinWidth           =0x8,
    71         EIfTooBigCtlStaysMinSize            =0xc,
    72         EIfTooSmallDontStrech               =0x10
    73         };
    74     enum TCaptionExpandingState
    75         {
    76         EInitial = 0,
    77         EExtended =1,
    78         ERetracted =2
    79         };
    80 
    81 public:
    82  	/** Constructor
    83  	 */	
    84     IMPORT_C CEikCaptionedControl();
    85     /** Destructor
    86      */
    87     IMPORT_C ~CEikCaptionedControl();
    88 public: // new functions
    89 	/** SetUsesEars() sets a flag Uses Ears.
    90 	 */
    91     IMPORT_C void SetUsesEars();
    92     /** SetSpaceSharingFlags() sets flags for space sharing
    93      */
    94     IMPORT_C void SetSpaceSharingFlags(TInt aFlags);
    95     /** SetExtraAscent() modifies layout to include extra ascent for fonts
    96      */
    97     IMPORT_C void SetExtraAscent();
    98     /** SetCaptionL() Sets label of the DLG_LINE
    99      * @param aText Descriptor
   100      */
   101     IMPORT_C void SetCaptionL(const TDesC& aText);
   102     /** SetTrailerL() Sets trailer
   103      * Should not be used
   104      * @param aText Descriptor
   105      */
   106     IMPORT_C void SetTrailerL(const TDesC& aText);
   107 	/** Sets the captionedcontrol to be currently focused or not
   108      * @param aSelected whether captionedcontrol is focused
   109 	 */
   110     IMPORT_C void SetCurrent(TBool aSelected);
   111 	/** Updates captionedcontrol's dimmed state
   112 	 */
   113     IMPORT_C void CheckDimmedDisplayState();
   114 	/** Sets minimumsizes to zero
   115 	 */
   116     IMPORT_C void ResetMinimumSizes();
   117 	/** Whether captionedcontrol is latent
   118 	 *
   119 	 * @return true if is latent
   120 	 */
   121     IMPORT_C TBool IsLatent() const;
   122 	/** Sets captionedcontrol latent status
   123 	 */
   124     IMPORT_C void SetLatent(TBool aLatent);
   125 	/** Whether captionedcontrol has latent group following it
   126      * @returns true if has latent group following
   127 	 */
   128     IMPORT_C TBool LatentGroupLineFollows() const;
   129 	/** Sets latent group following flag
   130      * @param aLglf true if latent group following
   131 	 */
   132     IMPORT_C void SetLatentGroupLineFollows(TBool aLglf);
   133 	/** Whether there is a divider after the captionedcontrol
   134 	 */
   135     IMPORT_C TBool DividerAfter() const;
   136     /** Sets divider after the captionedcontrol
   137      */
   138     IMPORT_C void SetDividerAfter(TBool aDividerAfter);
   139     /** Whether captionedcontrol consumes enter key
   140      */
   141     IMPORT_C TBool TakesEnterKey() const;
   142     /** Sets captionedcontrol to take enter key
   143      * @param aTakesEnter true if takes enter key, false if not
   144      */
   145     IMPORT_C void SetTakesEnterKey(TBool aTakesEnter);
   146     /** Whether offers hot keys
   147      * @return boolean true if offers hotkeys
   148      */
   149     IMPORT_C TBool OfferHotKeys() const;
   150     /** Sets captionedcontrol to offer hotkeys
   151      */
   152     IMPORT_C void SetOfferHotKeys(TBool aOffer);
   153     
   154 
   155     /**
   156      * From MCoeControlObserver:
   157      * Acts upon changes in the hosted control's state. 
   158      * 
   159      * This class's implementation handles events from MFNE editor editing
   160      * buttons in touch enabled builds
   161      *
   162      * @param	aControl	The control changing its state (not used)
   163      * @param	aEventType	The type of control event 
   164      */
   165 	IMPORT_C virtual void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
   166 	
   167 public:
   168     TInt MaximumNumberOfControlLinesOnVisiblePage() const;
   169 	TInt NumberOfLines() const;
   170 	TInt NumberOfLinesForScrollBar() const;
   171 public:
   172     TBool ControlIsAnEdwin(TInt aControlType) const;
   173     TBool ControlIsAMfne(TInt aControlType) const;
   174     TBool ControlIsAPopfield(TInt aControlType) const;
   175     TBool ControlIsASecretEditor(TInt aControlType) const;
   176     TBool ControlIsASlider(TInt aControlType) const;
   177     TBool ControlIsAColourSelGrid(TInt aControlType) const;
   178 	TInt ControlType() const;
   179 
   180 public: // from CCoeControl
   181     /** MinimumSize() returns minimum size of the control
   182      */
   183     IMPORT_C TSize MinimumSize();
   184     /** ConstructFromResourceL() constructs the captionedcontrol from DLG_LINE resource
   185      *
   186      * usually called with the following code:
   187      * TResourceReader reader;
   188      * iCoeEnv->CreateResourceReaderLC(reader, resId);
   189      * control->ConstructFromResourceL(reader);
   190      * CleanupStack::PopAndDestroy();
   191      */
   192     IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
   193     /** OfferKeyEventL() handles key events
   194      */
   195     IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
   196     /** GetColorUseListL() gets color use list
   197      */
   198     IMPORT_C virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const; // not available before Release 005u
   199     /** HandleResourceChange handles several kinds of resource change event
   200      */
   201     IMPORT_C virtual void HandleResourceChange(TInt aType);         // not available before Release 005u
   202     /** Provides ability to get input capabilities needed for fep
   203      */
   204     IMPORT_C TCoeInputCapabilities InputCapabilities() const;
   205     /** SetDimmed sets captionedcontrol to dimmed state
   206      */
   207     IMPORT_C void SetDimmed(TBool aDimmed);
   208     /** HandlePointerEventL handles touch pointer events
   209      */
   210     IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
   211 public:
   212     void RegisterPageWithCaptionControl(CEikDialogPage* aPage);
   213 
   214 public: // internal layout properties
   215 	//void SetProperties(const TRegion &aRegion, const RArray<TCapCProperty> &aProperties);
   216 	//TRect Line(TInt aLineIndex); // text line rectangles
   217 	//TInt LineIndex(TPoint aPoint);
   218 	//TPoint LineControlPoint(TInt aLineIndex);
   219 	//RArray<TInt> LineIndexesIntersecting(TRect aRect);
   220 	//void SetProperty(TInt aLine, TCapCProperty &aProperty);
   221 	//void ClearProperty(TInt aLine, TCapCProperty &aProperty);
   222 	//TCapCProperty Properties(TInt aLine);
   223 	//void LineRegions(TRegion &aRegion);
   224 	//void SetVisibleArea(TRect aRect);
   225 	//void RemoveVisibleArea();
   226 private: // from CCoeControl
   227     IMPORT_C TInt CountComponentControls() const;
   228     IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const;
   229     IMPORT_C void SizeChanged();
   230     IMPORT_C void FocusChanged(TDrawNow aDrawNow);
   231 protected: // from CCoeControl
   232     IMPORT_C void Draw(const TRect& aRect) const;
   233     IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const;
   234 private: // from CCoeControl
   235     IMPORT_C void Reserved_2();
   236     // from MCoeCaptionRetrieverForFep
   237     IMPORT_C virtual void GetCaptionForFep(TDes& aCaption) const;
   238     IMPORT_C virtual void MCoeCaptionRetrieverForFep_Reserved_1();
   239     IMPORT_C virtual void MCoeCaptionRetrieverForFep_Reserved_2();
   240 private:
   241     /**
   242     * From CAknControl
   243     */
   244     IMPORT_C void* ExtensionInterface( TUid aInterface );
   245 
   246 protected: // from MObjectProvider
   247     IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
   248 
   249 public:
   250     /** SetToolTipTextL() sets tooltip text
   251      * @param aText descriptor for tooltip text
   252      */
   253       
   254     IMPORT_C void SetToolTipTextL( const TDesC& aText ) ;
   255     /** Ability to query tooltip text string
   256      */
   257     IMPORT_C const TDesC* ToolTipText() const ;
   258     /** SetBitmapFromFileL() sets icon contents for the captionedcontrol
   259      */
   260     IMPORT_C void SetBitmapFromFileL( const TDesC& aFilename,TInt aMainId,TInt aMaskId =-1 ) ;
   261     /** SetEditable sets captionedcontrol to editable state
   262      */
   263     IMPORT_C void SetEditableL( TBool aEditable, TBool aShowEmptyFields = ETrue ) ;
   264     
   265     IMPORT_C void SetFormFlags( TInt aFlags ) ;
   266     void GetAknLayoutValuesL() ;  // Visible within DLL only.
   267     TBool HasSeparator() const;
   268     /** GetFullCaptionText() gets caption descriptor
   269      *
   270      */
   271     IMPORT_C const TPtrC GetFullCaptionText() const;
   272     TBool   IsDisplayable() const;
   273     /** 
   274      * Allows clients of CEikCaptionedControl to turn off drawing 
   275      * of white background of captionedcontrol.
   276      *
   277      * @since 2.1
   278      */
   279     IMPORT_C void SetDrawNoWhiteBackground(TBool aEnabled); // for list queries with find.
   280 
   281     /**
   282     * In case of an editor control residing in a form,
   283     * sets up a pictograph animation callback to redraw the form highlight
   284     * control when pictograph animations are updated.
   285     */
   286     void SetPictographCallBack();
   287     
   288     /**
   289     * Sets icon and sets its size.
   290     * @param aBitmap a bitmap which has already been loaded. Must not be NULL.
   291     * @param aMask a mask bitmap which has already been loaded. Can be NULL.
   292     * Takes ownership of the bitmap objects.
   293     * @since 2.8
   294     */
   295     IMPORT_C void SetIconL( CFbsBitmap* aBitmap, CFbsBitmap* aMask ); 
   296 
   297     /**
   298      * Sets one of the two small indicator icons
   299      * @param aIcon a index 0 or 1 depending on which icon to set
   300      * @param aBitmap a bitmap pointer or NULL
   301      * @param aMask a mask pointer or NULL
   302      */
   303 	IMPORT_C void SetIndicatorIconL( TInt aIcon, CFbsBitmap *aBitmap, CFbsBitmap *aMask );
   304 
   305     /** SetPointerEventObserver
   306      * Low level observer for touch related pointer events.
   307      * This can be used to receive low level pointer events.
   308      */
   309 	IMPORT_C void SetPointerEventObserver(MPointerEventObserver *aObserver);
   310 	MPointerEventObserver *PointerEventObserver() const;
   311 protected:
   312     TRect ViewRect() const;
   313     TRect EditRect() const;
   314 
   315 private:
   316     enum TWhichEars
   317         {
   318         ENoEar=0x00,
   319         ELeftEar=0x01,
   320         ERightEar=0x02,
   321         EBothEars=0x03
   322         };
   323 private: // new functions
   324     TInt WidthForEars(TInt aWidthRemaining) const;
   325     void DrawEarsNow(TWhichEars aEar) const;
   326     void DrawEars(TWhichEars aEar) const;
   327     void DrawSingleEar(TWhichEars aEar,TBool aPressed) const;
   328     TRect EarRect(TWhichEars aEar) const;
   329     void FireEarL(TWhichEars aEar,TInt aEarRepeat);
   330     TInt SquashComponentWidth(TInt& aTotalWidth,const TInt aComponentWidthHint);
   331     void StretchComponents();
   332     void SetVertEdgeSpacing( TInt aVertEdgeSpacing );
   333     void SetHorzEdgeSpacing( TInt aHorzEdgeSpacing );
   334     void SquashComponents();
   335     void CalculateNumberOfLinesForControl( TInt aLines ) ;
   336     void SizeDialogComponents() ;
   337     void PositionDialogComponents() ;
   338     static TInt PictographAnimationCallBack( TAny* aPtr );
   339     /**
   340     * Sets a size for a bitmap that has already been loaded.
   341     * @since 2.8
   342     */    
   343     void SetIconSizeL(CFbsBitmap* aBitmap);
   344     /**
   345     * Gets control context for the given control
   346     * @param aDialog a dialog to get context for
   347     * If aDialog provided does not exist, TODO
   348     */
   349     MAknsControlContext* GetDialogControlContext(const CCoeControl* aDialog) const;
   350 
   351     /**
   352      * Searches recursively for control's parents until it finds a window owning control
   353      */
   354     const CCoeControl* WindowOwningParent() const;
   355 
   356 public:
   357     /**
   358      * Positions form components in accordance with dialog page flags. 
   359      * If the dialog instance is not registered, them flags set with SetFormFlags() are used. 
   360      */	
   361     void PositionFormComponents();
   362     void ScrollBackEditor();
   363     
   364 public:
   365     void DrawClosingLine() const;
   366 	const CEikDialogPage* DialogPage() const { return iDialogPage; }
   367 	void SetPartiallyVisible( TBool aPVisible );
   368     TBool PressedDownState() const;
   369 	void SetPressedDownState( TBool aPressed );
   370 private:
   371     TSize EditorControlSize() const ;
   372     void SetElementBrushColorsL( TRgb aColor ) ;
   373     void SetElementTextColorsL( TRgb aColor ) ;
   374 
   375     TBool ShowBitmap() const;
   376     void  LayoutBitmap(const TRect& aRect);
   377     void  LayoutCaption(const TRect& aRect);
   378     void DoFormCaptionSettingsL(const TDesC& aText);
   379 private:
   380     static void FormLayoutControlBitmap(CEikImage* aBitmap, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines);
   381     static void FormLayoutControlEdwin(CEikEdwin* aEdwin, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent, TBool aIsFocused);
   382     static void FormLayoutControlLabel(CEikLabel* aSlider, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool aLayoutWithBitmap, TBool aIsFocused, TInt aIconCount);
   383     static void FormLayoutControlMfne(CEikMfne* aMfne,  const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent, TBool aIsFocused );
   384     static void FormLayoutControlPopfield(CAknPopupField* aPopfield, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent, TBool aIsFocused);
   385     static void FormLayoutControlSecretEditor(CEikSecretEditor* aSecretEd, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent, TBool aIsFocused );
   386     static void FormLayoutControlSlider(CAknSlider* aSlider, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent);
   387     static void ConvertViewRectToEditRect(TRect& aRect);
   388     static void ConvertEditRectToViewRect(TRect& aRect);
   389 
   390     /*	
   391     *
   392     * Access method for use in a CAknForm context. 
   393     *
   394     * @return   Enumeration for layout for the CAknForm
   395     *           Layout value is received from owning CEikDialogPage, if it is not defined then EEikFormUseDoubleSpacedFormat flag is checked.
   396     *           Default value is CEikDialogPage::ESingle
   397     */
   398     CEikDialogPage::TFormLayoutSelection FormLayout() const;
   399 
   400     /**
   401     * Draws the separator between (at the top of current ) caption control(s)
   402     *
   403     * @param    gc  Current graphics contect
   404     */
   405     void DrawFormSeparator( CWindowGc& gc ) const;
   406 
   407     /**
   408     * Constructs the extension object.
   409     * There is no base constructL, so it is necessary to call this in several places
   410     */
   411     void ConstructExtensionL() ;
   412 
   413     void DrawAsSkinnedForm( CWindowGc& aGc, const TRect& aRect ) const;
   414     void LayoutSkinControlContexts();
   415     TBool DrawingSkins() const;
   416     void DrawAsForm( const TRect& aRect ) const;
   417     void DrawAsEikonDialog( const TRect& aRect ) const;
   418     void DrawAsFormInEditMode( const TRect& aRect ) const;
   419     void DrawAsFormInViewMode( const TRect& aRect ) const;
   420     void DrawAsFormUnFocusedLine( const TRect& aRect ) const;
   421 
   422 public:
   423     CCoeControl* iControl;
   424     CEikCapCLabel* iCaption;
   425     HBufC* iCaptionText;
   426 
   427     CEikLabel* iTrailer;
   428     TInt iId;
   429     TInt iControlType;
   430     TAny* iReturnValue;
   431     TBool iIsFormControl ;
   432     CEikImage* iBitmap ;
   433     TBool iIsEditable ;
   434 
   435 private:
   436     TBool iHasAppendedEditIndicator;
   437     TSize iMinSize;
   438     TInt  iCapCFlags;
   439     TInt  iCaptionWidth;
   440     TInt  iFullWidth;
   441     TSize iNormalSize ;
   442     HBufC*iToolTipText ;
   443     TBool iDoNotDisplay ;
   444 
   445     TInt iVertEdgeSpacing ;
   446     TInt iHorzEdgeSpacing ;
   447     TInt iOriginalHeight ;
   448 
   449     TSize iEditorControlSize ;
   450     TInt iNumberOfLines ;
   451 
   452     friend class CEikCapCArray;
   453 
   454     enum { ENotSupplied = -1 } ;
   455     TInt iFlags ;
   456 
   457     TBool iRefresh ;
   458 
   459     TInt iCaptionFontId ;
   460     TInt iEditorFontId ;
   461     TInt iVerticalLineXPosition; //iAknTopSpacing ;         
   462     CCoeControl* iHighlightControl;
   463     CEikCapCExtension* iExtension ;  // BC extension for additional Data members.
   464     TInt iAknFormControlHeight ;
   465     TInt iAknFormControlWidth ;
   466     TInt iPenColor ;
   467     TInt iShadowColor ;
   468     TBool iIsCurrentLine;
   469     CEikDialogPage* iDialogPage;
   470 
   471 
   472     };
   473 
   474 
   475 /*
   476  * Special Label Class which appends colon to label text
   477  */
   478 
   479 NONSHARABLE_CLASS(CEikCapCLabel) : public CEikLabel
   480     {
   481 public :
   482     CEikCapCLabel() ;
   483     ~CEikCapCLabel() ;
   484 
   485     TBool ColonEnabled() const ;
   486     void EnableColon( TBool aEnable ) ;
   487 
   488 protected :
   489     void Draw(const TRect& aRect) const ;
   490     void DrawL(const TRect& aRect) ;
   491 
   492 private:
   493     TBool iIsColonEnabled ;
   494     } ;
   495 
   496 class MPointerEventObserver
   497 	{
   498 public:
   499 	virtual bool PointerEvent(CEikCaptionedControl *aControl, const TPointerEvent& aPointerEvent)=0;
   500 	};
   501 
   502 #endif