1.1 --- a/epoc32/include/mw/eikcapc.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/mw/eikcapc.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,502 @@
1.4 -eikcapc.h
1.5 +/*
1.6 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.7 +* All rights reserved.
1.8 +* This component and the accompanying materials are made available
1.9 +* 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
1.10 +* which accompanies this distribution, and is available
1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.12 +*
1.13 +* Initial Contributors:
1.14 +* Nokia Corporation - initial contribution.
1.15 +*
1.16 +* Contributors:
1.17 +*
1.18 +* Description:
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +#if !defined(__EIKCAPC_H__)
1.24 +#define __EIKCAPC_H__
1.25 +
1.26 +#if !defined(__COECNTRL_H__)
1.27 +#include <coecntrl.h>
1.28 +#endif
1.29 +
1.30 +#if !defined(__FEPBASE_H__)
1.31 +#include <fepbase.h>
1.32 +#endif
1.33 +
1.34 +#if !defined(__EIKLABEL_H__)
1.35 +#include <eiklabel.h>
1.36 +#endif
1.37 +
1.38 +#include <eikdialg.h>
1.39 +#include <eikdpage.h>
1.40 +
1.41 +#include <AknControl.h>
1.42 +
1.43 +class CEikImage ;
1.44 +class CEikDialogPage;
1.45 +// Forward declaration of types used in layout routines.
1.46 +class CAknPopupField;
1.47 +class CAknSlider;
1.48 +class CEikEdwin;
1.49 +class CEikMfne;
1.50 +class CEikSecretEditor;
1.51 +class CEikCapCLabel ;
1.52 +class CEikCapCExtension;
1.53 +class MPointerEventObserver;
1.54 +class MAknsControlContext;
1.55 +
1.56 +/** CaptionedControl
1.57 + *
1.58 + * CaptionedControl is part of the dialogs. All dialogs and forms use captionedcontrol
1.59 + * as a control for one DLG_LINE. Each DLG_LINE has one captionedcontrol in it.
1.60 + *
1.61 + * Rectangle of the captionedcontrol is single form field / form line or DLG_LINE's
1.62 + * rectangle dependent on the dialog type.
1.63 + */
1.64 +class CEikCaptionedControl : public CAknControl, public MCoeCaptionRetrieverForFep, public MCoeControlObserver
1.65 + {
1.66 + friend class CEikCapCExtension;
1.67 +public:
1.68 + enum TSpaceSharingFlags
1.69 + {
1.70 + EIfTooSmallCtlGetsWidthLast =0x0,
1.71 + EIfTooSmallCtlGetsWidthFirst =0x1,
1.72 + EIfTooSmallCtlGetsEqualShareOfWidth =0x2,
1.73 + EIfTooBigCtlStaysMinHeight =0x4,
1.74 + EIfTooBigCtlStaysMinWidth =0x8,
1.75 + EIfTooBigCtlStaysMinSize =0xc,
1.76 + EIfTooSmallDontStrech =0x10
1.77 + };
1.78 + enum TCaptionExpandingState
1.79 + {
1.80 + EInitial = 0,
1.81 + EExtended =1,
1.82 + ERetracted =2
1.83 + };
1.84 +
1.85 +public:
1.86 + /** Constructor
1.87 + */
1.88 + IMPORT_C CEikCaptionedControl();
1.89 + /** Destructor
1.90 + */
1.91 + IMPORT_C ~CEikCaptionedControl();
1.92 +public: // new functions
1.93 + /** SetUsesEars() sets a flag Uses Ears.
1.94 + */
1.95 + IMPORT_C void SetUsesEars();
1.96 + /** SetSpaceSharingFlags() sets flags for space sharing
1.97 + */
1.98 + IMPORT_C void SetSpaceSharingFlags(TInt aFlags);
1.99 + /** SetExtraAscent() modifies layout to include extra ascent for fonts
1.100 + */
1.101 + IMPORT_C void SetExtraAscent();
1.102 + /** SetCaptionL() Sets label of the DLG_LINE
1.103 + * @param aText Descriptor
1.104 + */
1.105 + IMPORT_C void SetCaptionL(const TDesC& aText);
1.106 + /** SetTrailerL() Sets trailer
1.107 + * Should not be used
1.108 + * @param aText Descriptor
1.109 + */
1.110 + IMPORT_C void SetTrailerL(const TDesC& aText);
1.111 + /** Sets the captionedcontrol to be currently focused or not
1.112 + * @param aSelected whether captionedcontrol is focused
1.113 + */
1.114 + IMPORT_C void SetCurrent(TBool aSelected);
1.115 + /** Updates captionedcontrol's dimmed state
1.116 + */
1.117 + IMPORT_C void CheckDimmedDisplayState();
1.118 + /** Sets minimumsizes to zero
1.119 + */
1.120 + IMPORT_C void ResetMinimumSizes();
1.121 + /** Whether captionedcontrol is latent
1.122 + *
1.123 + * @return true if is latent
1.124 + */
1.125 + IMPORT_C TBool IsLatent() const;
1.126 + /** Sets captionedcontrol latent status
1.127 + */
1.128 + IMPORT_C void SetLatent(TBool aLatent);
1.129 + /** Whether captionedcontrol has latent group following it
1.130 + * @returns true if has latent group following
1.131 + */
1.132 + IMPORT_C TBool LatentGroupLineFollows() const;
1.133 + /** Sets latent group following flag
1.134 + * @param aLglf true if latent group following
1.135 + */
1.136 + IMPORT_C void SetLatentGroupLineFollows(TBool aLglf);
1.137 + /** Whether there is a divider after the captionedcontrol
1.138 + */
1.139 + IMPORT_C TBool DividerAfter() const;
1.140 + /** Sets divider after the captionedcontrol
1.141 + */
1.142 + IMPORT_C void SetDividerAfter(TBool aDividerAfter);
1.143 + /** Whether captionedcontrol consumes enter key
1.144 + */
1.145 + IMPORT_C TBool TakesEnterKey() const;
1.146 + /** Sets captionedcontrol to take enter key
1.147 + * @param aTakesEnter true if takes enter key, false if not
1.148 + */
1.149 + IMPORT_C void SetTakesEnterKey(TBool aTakesEnter);
1.150 + /** Whether offers hot keys
1.151 + * @return boolean true if offers hotkeys
1.152 + */
1.153 + IMPORT_C TBool OfferHotKeys() const;
1.154 + /** Sets captionedcontrol to offer hotkeys
1.155 + */
1.156 + IMPORT_C void SetOfferHotKeys(TBool aOffer);
1.157 +
1.158 +
1.159 + /**
1.160 + * From MCoeControlObserver:
1.161 + * Acts upon changes in the hosted control's state.
1.162 + *
1.163 + * This class's implementation handles events from MFNE editor editing
1.164 + * buttons in touch enabled builds
1.165 + *
1.166 + * @param aControl The control changing its state (not used)
1.167 + * @param aEventType The type of control event
1.168 + */
1.169 + IMPORT_C virtual void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
1.170 +
1.171 +public:
1.172 + TInt MaximumNumberOfControlLinesOnVisiblePage() const;
1.173 + TInt NumberOfLines() const;
1.174 + TInt NumberOfLinesForScrollBar() const;
1.175 +public:
1.176 + TBool ControlIsAnEdwin(TInt aControlType) const;
1.177 + TBool ControlIsAMfne(TInt aControlType) const;
1.178 + TBool ControlIsAPopfield(TInt aControlType) const;
1.179 + TBool ControlIsASecretEditor(TInt aControlType) const;
1.180 + TBool ControlIsASlider(TInt aControlType) const;
1.181 + TBool ControlIsAColourSelGrid(TInt aControlType) const;
1.182 + TInt ControlType() const;
1.183 +
1.184 +public: // from CCoeControl
1.185 + /** MinimumSize() returns minimum size of the control
1.186 + */
1.187 + IMPORT_C TSize MinimumSize();
1.188 + /** ConstructFromResourceL() constructs the captionedcontrol from DLG_LINE resource
1.189 + *
1.190 + * usually called with the following code:
1.191 + * TResourceReader reader;
1.192 + * iCoeEnv->CreateResourceReaderLC(reader, resId);
1.193 + * control->ConstructFromResourceL(reader);
1.194 + * CleanupStack::PopAndDestroy();
1.195 + */
1.196 + IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
1.197 + /** OfferKeyEventL() handles key events
1.198 + */
1.199 + IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
1.200 + /** GetColorUseListL() gets color use list
1.201 + */
1.202 + IMPORT_C virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const; // not available before Release 005u
1.203 + /** HandleResourceChange handles several kinds of resource change event
1.204 + */
1.205 + IMPORT_C virtual void HandleResourceChange(TInt aType); // not available before Release 005u
1.206 + /** Provides ability to get input capabilities needed for fep
1.207 + */
1.208 + IMPORT_C TCoeInputCapabilities InputCapabilities() const;
1.209 + /** SetDimmed sets captionedcontrol to dimmed state
1.210 + */
1.211 + IMPORT_C void SetDimmed(TBool aDimmed);
1.212 + /** HandlePointerEventL handles touch pointer events
1.213 + */
1.214 + IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
1.215 +public:
1.216 + void RegisterPageWithCaptionControl(CEikDialogPage* aPage);
1.217 +
1.218 +public: // internal layout properties
1.219 + //void SetProperties(const TRegion &aRegion, const RArray<TCapCProperty> &aProperties);
1.220 + //TRect Line(TInt aLineIndex); // text line rectangles
1.221 + //TInt LineIndex(TPoint aPoint);
1.222 + //TPoint LineControlPoint(TInt aLineIndex);
1.223 + //RArray<TInt> LineIndexesIntersecting(TRect aRect);
1.224 + //void SetProperty(TInt aLine, TCapCProperty &aProperty);
1.225 + //void ClearProperty(TInt aLine, TCapCProperty &aProperty);
1.226 + //TCapCProperty Properties(TInt aLine);
1.227 + //void LineRegions(TRegion &aRegion);
1.228 + //void SetVisibleArea(TRect aRect);
1.229 + //void RemoveVisibleArea();
1.230 +private: // from CCoeControl
1.231 + IMPORT_C TInt CountComponentControls() const;
1.232 + IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const;
1.233 + IMPORT_C void SizeChanged();
1.234 + IMPORT_C void FocusChanged(TDrawNow aDrawNow);
1.235 +protected: // from CCoeControl
1.236 + IMPORT_C void Draw(const TRect& aRect) const;
1.237 + IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const;
1.238 +private: // from CCoeControl
1.239 + IMPORT_C void Reserved_2();
1.240 + // from MCoeCaptionRetrieverForFep
1.241 + IMPORT_C virtual void GetCaptionForFep(TDes& aCaption) const;
1.242 + IMPORT_C virtual void MCoeCaptionRetrieverForFep_Reserved_1();
1.243 + IMPORT_C virtual void MCoeCaptionRetrieverForFep_Reserved_2();
1.244 +private:
1.245 + /**
1.246 + * From CAknControl
1.247 + */
1.248 + IMPORT_C void* ExtensionInterface( TUid aInterface );
1.249 +
1.250 +protected: // from MObjectProvider
1.251 + IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
1.252 +
1.253 +public:
1.254 + /** SetToolTipTextL() sets tooltip text
1.255 + * @param aText descriptor for tooltip text
1.256 + */
1.257 +
1.258 + IMPORT_C void SetToolTipTextL( const TDesC& aText ) ;
1.259 + /** Ability to query tooltip text string
1.260 + */
1.261 + IMPORT_C const TDesC* ToolTipText() const ;
1.262 + /** SetBitmapFromFileL() sets icon contents for the captionedcontrol
1.263 + */
1.264 + IMPORT_C void SetBitmapFromFileL( const TDesC& aFilename,TInt aMainId,TInt aMaskId =-1 ) ;
1.265 + /** SetEditable sets captionedcontrol to editable state
1.266 + */
1.267 + IMPORT_C void SetEditableL( TBool aEditable, TBool aShowEmptyFields = ETrue ) ;
1.268 +
1.269 + IMPORT_C void SetFormFlags( TInt aFlags ) ;
1.270 + void GetAknLayoutValuesL() ; // Visible within DLL only.
1.271 + TBool HasSeparator() const;
1.272 + /** GetFullCaptionText() gets caption descriptor
1.273 + *
1.274 + */
1.275 + IMPORT_C const TPtrC GetFullCaptionText() const;
1.276 + TBool IsDisplayable() const;
1.277 + /**
1.278 + * Allows clients of CEikCaptionedControl to turn off drawing
1.279 + * of white background of captionedcontrol.
1.280 + *
1.281 + * @since 2.1
1.282 + */
1.283 + IMPORT_C void SetDrawNoWhiteBackground(TBool aEnabled); // for list queries with find.
1.284 +
1.285 + /**
1.286 + * In case of an editor control residing in a form,
1.287 + * sets up a pictograph animation callback to redraw the form highlight
1.288 + * control when pictograph animations are updated.
1.289 + */
1.290 + void SetPictographCallBack();
1.291 +
1.292 + /**
1.293 + * Sets icon and sets its size.
1.294 + * @param aBitmap a bitmap which has already been loaded. Must not be NULL.
1.295 + * @param aMask a mask bitmap which has already been loaded. Can be NULL.
1.296 + * Takes ownership of the bitmap objects.
1.297 + * @since 2.8
1.298 + */
1.299 + IMPORT_C void SetIconL( CFbsBitmap* aBitmap, CFbsBitmap* aMask );
1.300 +
1.301 + /**
1.302 + * Sets one of the two small indicator icons
1.303 + * @param aIcon a index 0 or 1 depending on which icon to set
1.304 + * @param aBitmap a bitmap pointer or NULL
1.305 + * @param aMask a mask pointer or NULL
1.306 + */
1.307 + IMPORT_C void SetIndicatorIconL( TInt aIcon, CFbsBitmap *aBitmap, CFbsBitmap *aMask );
1.308 +
1.309 + /** SetPointerEventObserver
1.310 + * Low level observer for touch related pointer events.
1.311 + * This can be used to receive low level pointer events.
1.312 + */
1.313 + IMPORT_C void SetPointerEventObserver(MPointerEventObserver *aObserver);
1.314 + MPointerEventObserver *PointerEventObserver() const;
1.315 +protected:
1.316 + TRect ViewRect() const;
1.317 + TRect EditRect() const;
1.318 +
1.319 +private:
1.320 + enum TWhichEars
1.321 + {
1.322 + ENoEar=0x00,
1.323 + ELeftEar=0x01,
1.324 + ERightEar=0x02,
1.325 + EBothEars=0x03
1.326 + };
1.327 +private: // new functions
1.328 + TInt WidthForEars(TInt aWidthRemaining) const;
1.329 + void DrawEarsNow(TWhichEars aEar) const;
1.330 + void DrawEars(TWhichEars aEar) const;
1.331 + void DrawSingleEar(TWhichEars aEar,TBool aPressed) const;
1.332 + TRect EarRect(TWhichEars aEar) const;
1.333 + void FireEarL(TWhichEars aEar,TInt aEarRepeat);
1.334 + TInt SquashComponentWidth(TInt& aTotalWidth,const TInt aComponentWidthHint);
1.335 + void StretchComponents();
1.336 + void SetVertEdgeSpacing( TInt aVertEdgeSpacing );
1.337 + void SetHorzEdgeSpacing( TInt aHorzEdgeSpacing );
1.338 + void SquashComponents();
1.339 + void CalculateNumberOfLinesForControl( TInt aLines ) ;
1.340 + void SizeDialogComponents() ;
1.341 + void PositionDialogComponents() ;
1.342 + static TInt PictographAnimationCallBack( TAny* aPtr );
1.343 + /**
1.344 + * Sets a size for a bitmap that has already been loaded.
1.345 + * @since 2.8
1.346 + */
1.347 + void SetIconSizeL(CFbsBitmap* aBitmap);
1.348 + /**
1.349 + * Gets control context for the given control
1.350 + * @param aDialog a dialog to get context for
1.351 + * If aDialog provided does not exist, TODO
1.352 + */
1.353 + MAknsControlContext* GetDialogControlContext(const CCoeControl* aDialog) const;
1.354 +
1.355 + /**
1.356 + * Searches recursively for control's parents until it finds a window owning control
1.357 + */
1.358 + const CCoeControl* WindowOwningParent() const;
1.359 +
1.360 +public:
1.361 + /**
1.362 + * Positions form components in accordance with dialog page flags.
1.363 + * If the dialog instance is not registered, them flags set with SetFormFlags() are used.
1.364 + */
1.365 + void PositionFormComponents();
1.366 + void ScrollBackEditor();
1.367 +
1.368 +public:
1.369 + void DrawClosingLine() const;
1.370 + const CEikDialogPage* DialogPage() const { return iDialogPage; }
1.371 + void SetPartiallyVisible( TBool aPVisible );
1.372 + TBool PressedDownState() const;
1.373 + void SetPressedDownState( TBool aPressed );
1.374 +private:
1.375 + TSize EditorControlSize() const ;
1.376 + void SetElementBrushColorsL( TRgb aColor ) ;
1.377 + void SetElementTextColorsL( TRgb aColor ) ;
1.378 +
1.379 + TBool ShowBitmap() const;
1.380 + void LayoutBitmap(const TRect& aRect);
1.381 + void LayoutCaption(const TRect& aRect);
1.382 + void DoFormCaptionSettingsL(const TDesC& aText);
1.383 +private:
1.384 + static void FormLayoutControlBitmap(CEikImage* aBitmap, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines);
1.385 + static void FormLayoutControlEdwin(CEikEdwin* aEdwin, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent, TBool aIsFocused);
1.386 + static void FormLayoutControlLabel(CEikLabel* aSlider, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool aLayoutWithBitmap, TBool aIsFocused, TInt aIconCount);
1.387 + static void FormLayoutControlMfne(CEikMfne* aMfne, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent, TBool aIsFocused );
1.388 + static void FormLayoutControlPopfield(CAknPopupField* aPopfield, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent, TBool aIsFocused);
1.389 + static void FormLayoutControlSecretEditor(CEikSecretEditor* aSecretEd, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent, TBool aIsFocused );
1.390 + static void FormLayoutControlSlider(CAknSlider* aSlider, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent);
1.391 + static void ConvertViewRectToEditRect(TRect& aRect);
1.392 + static void ConvertEditRectToViewRect(TRect& aRect);
1.393 +
1.394 + /*
1.395 + *
1.396 + * Access method for use in a CAknForm context.
1.397 + *
1.398 + * @return Enumeration for layout for the CAknForm
1.399 + * Layout value is received from owning CEikDialogPage, if it is not defined then EEikFormUseDoubleSpacedFormat flag is checked.
1.400 + * Default value is CEikDialogPage::ESingle
1.401 + */
1.402 + CEikDialogPage::TFormLayoutSelection FormLayout() const;
1.403 +
1.404 + /**
1.405 + * Draws the separator between (at the top of current ) caption control(s)
1.406 + *
1.407 + * @param gc Current graphics contect
1.408 + */
1.409 + void DrawFormSeparator( CWindowGc& gc ) const;
1.410 +
1.411 + /**
1.412 + * Constructs the extension object.
1.413 + * There is no base constructL, so it is necessary to call this in several places
1.414 + */
1.415 + void ConstructExtensionL() ;
1.416 +
1.417 + void DrawAsSkinnedForm( CWindowGc& aGc, const TRect& aRect ) const;
1.418 + void LayoutSkinControlContexts();
1.419 + TBool DrawingSkins() const;
1.420 + void DrawAsForm( const TRect& aRect ) const;
1.421 + void DrawAsEikonDialog( const TRect& aRect ) const;
1.422 + void DrawAsFormInEditMode( const TRect& aRect ) const;
1.423 + void DrawAsFormInViewMode( const TRect& aRect ) const;
1.424 + void DrawAsFormUnFocusedLine( const TRect& aRect ) const;
1.425 +
1.426 +public:
1.427 + CCoeControl* iControl;
1.428 + CEikCapCLabel* iCaption;
1.429 + HBufC* iCaptionText;
1.430 +
1.431 + CEikLabel* iTrailer;
1.432 + TInt iId;
1.433 + TInt iControlType;
1.434 + TAny* iReturnValue;
1.435 + TBool iIsFormControl ;
1.436 + CEikImage* iBitmap ;
1.437 + TBool iIsEditable ;
1.438 +
1.439 +private:
1.440 + TBool iHasAppendedEditIndicator;
1.441 + TSize iMinSize;
1.442 + TInt iCapCFlags;
1.443 + TInt iCaptionWidth;
1.444 + TInt iFullWidth;
1.445 + TSize iNormalSize ;
1.446 + HBufC*iToolTipText ;
1.447 + TBool iDoNotDisplay ;
1.448 +
1.449 + TInt iVertEdgeSpacing ;
1.450 + TInt iHorzEdgeSpacing ;
1.451 + TInt iOriginalHeight ;
1.452 +
1.453 + TSize iEditorControlSize ;
1.454 + TInt iNumberOfLines ;
1.455 +
1.456 + friend class CEikCapCArray;
1.457 +
1.458 + enum { ENotSupplied = -1 } ;
1.459 + TInt iFlags ;
1.460 +
1.461 + TBool iRefresh ;
1.462 +
1.463 + TInt iCaptionFontId ;
1.464 + TInt iEditorFontId ;
1.465 + TInt iVerticalLineXPosition; //iAknTopSpacing ;
1.466 + CCoeControl* iHighlightControl;
1.467 + CEikCapCExtension* iExtension ; // BC extension for additional Data members.
1.468 + TInt iAknFormControlHeight ;
1.469 + TInt iAknFormControlWidth ;
1.470 + TInt iPenColor ;
1.471 + TInt iShadowColor ;
1.472 + TBool iIsCurrentLine;
1.473 + CEikDialogPage* iDialogPage;
1.474 +
1.475 +
1.476 + };
1.477 +
1.478 +
1.479 +/*
1.480 + * Special Label Class which appends colon to label text
1.481 + */
1.482 +
1.483 +NONSHARABLE_CLASS(CEikCapCLabel) : public CEikLabel
1.484 + {
1.485 +public :
1.486 + CEikCapCLabel() ;
1.487 + ~CEikCapCLabel() ;
1.488 +
1.489 + TBool ColonEnabled() const ;
1.490 + void EnableColon( TBool aEnable ) ;
1.491 +
1.492 +protected :
1.493 + void Draw(const TRect& aRect) const ;
1.494 + void DrawL(const TRect& aRect) ;
1.495 +
1.496 +private:
1.497 + TBool iIsColonEnabled ;
1.498 + } ;
1.499 +
1.500 +class MPointerEventObserver
1.501 + {
1.502 +public:
1.503 + virtual bool PointerEvent(CEikCaptionedControl *aControl, const TPointerEvent& aPointerEvent)=0;
1.504 + };
1.505 +
1.506 +#endif