epoc32/include/coecntrl.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // 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
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __COECNTRL_H__
    17 #define __COECNTRL_H__
    18 
    19 #include <e32std.h>
    20 #include <e32base.h>
    21 #include <w32std.h>
    22 #include <gulalign.h>
    23 #include <coedef.h>
    24 #include <coecobs.h>
    25 #include <coehelp.h>
    26 #include <coeinput.h>
    27 #include <coemop.h>
    28 #include <coemain.h>
    29 #include <coefont.h>
    30 #include <coetextdrawer.h>
    31 #include <coecontrolarray.h>
    32 
    33 #include <coecoloruse.h>	// class TCoeColorUse
    34 
    35 class TResourceReader;
    36 class CCoeEnv;
    37 class MCoeControlContext;
    38 class RCoeDynamicDataStorage;
    39 
    40 class MCoeLayoutManager;
    41 class TCoeZoomWithType; 
    42 class CCoeFontProvider;
    43 
    44 // forward declarations.	
    45 class CCoeControl;
    46 class CCoeTextDrawerBase;
    47 
    48 /** Interface to be used if a control elects to be a background drawer.
    49 
    50 Parent controls can elect to take responsibility for drawing the background for their child
    51 controls. To achieve this, they should aggregate an object that implements this interface.
    52 CCoeControl::SetBackground() accepts the object and sets it as the background drawer
    53 
    54 @see CCoeControl::EnableWindowTransparency()
    55 @publishedAll
    56 @released
    57 */
    58 class MCoeControlBackground
    59 	{
    60 public:
    61 	/** Draw the background for a given control.
    62 	The text drawer that shall be used to draw text on the specific background can be 
    63 	fetched through the GetTextDrawer() method. 
    64 
    65 	@param aGc Graphics context used for drawing
    66 	@param aControl The control being drawn (may be a child of the drawer)
    67 	@param aRect The area to be redrawn
    68 
    69 	@publishedAll
    70 	@released
    71 	*/
    72 	virtual void Draw(CWindowGc& aGc, const CCoeControl& aControl, const TRect& aRect) const = 0;
    73 	/**
    74 	This function retrieves the text drawer associated with the background.
    75 	@param aTextDrawer The text drawer associated with the background. This may be null. The default implementation
    76 	always sets this to 0.
    77 	@param aDrawingControl The control that is requesting the text drawer.
    78 	*/
    79 	IMPORT_C virtual void GetTextDrawer(CCoeTextDrawerBase*& aTextDrawer, const CCoeControl* aDrawingControl) const;
    80 protected:
    81 	IMPORT_C MCoeControlBackground();
    82 private:  
    83   	IMPORT_C virtual void MCoeControlBackground_Reserved1();
    84   	IMPORT_C virtual void MCoeControlBackground_Reserved2();
    85   	IMPORT_C virtual void MCoeControlBackground_Reserved3();
    86   	IMPORT_C virtual void MCoeControlBackground_Reserved4();
    87   	IMPORT_C virtual void MCoeControlBackground_Reserved5();
    88 private:
    89 	TInt iMCoeControlBackground_Reserved1();
    90 	};
    91 
    92 /** Abstract interface for defining a control's hit region.
    93 
    94 This could be implemented by a CCoeControl-derived class to 
    95 define hit region checking. The object is installed by calling CCoeControl::SetHitTest().
    96 
    97 The hit region is the area inside the control's rectangle in which pointer events are handled.
    98 It can be any shape, not necessarily rectangular.
    99 
   100 @publishedAll
   101 @released
   102 */
   103 class MCoeControlHitTest
   104 	{
   105 public:	
   106 	/** Tests whether a pointer event occurred inside the control's hit region.
   107 	This function is called by CCoeControl::HandlePointerEventL().
   108 
   109 	@param aPoint The position of the pointer event.
   110 	@return ETrue if the specified point lies inside the hit region, EFalse if not.
   111 
   112 	@publishedAll
   113 	@released
   114 	*/
   115 	virtual TBool HitRegionContains(const TPoint& aPoint, const CCoeControl& aControl) const = 0;
   116 protected:
   117 	IMPORT_C MCoeControlHitTest();
   118 private:
   119 	IMPORT_C virtual void MCoeControlHitTest_Reserved1();
   120 	IMPORT_C virtual void MCoeControlHitTest_Reserved2();
   121 private: 
   122     TInt iMCoeControlHitTest_Reserved1;
   123 	};
   124 
   125 
   126 /** 
   127 Control base class from which all other controls are derived. 
   128 
   129 @publishedAll
   130 @released 
   131 */
   132 class CCoeControl : public CBase, public MObjectProvider
   133 	{
   134 public:
   135     enum TZoomType 
   136         { 
   137         EAbsoluteZoom,        // absolute 
   138         ERelativeZoom         // relative to parent's zoom 
   139         }; 
   140 public:    
   141     // Construction and destruction    
   142 	IMPORT_C CCoeControl();
   143 	IMPORT_C CCoeControl(CCoeEnv* aCoeEnv);
   144 	IMPORT_C ~CCoeControl();
   145 	IMPORT_C TBool ComponentArrayExists() const;
   146 public: // Virtuals (see more related non-virtuals further down)
   147 	// Key input
   148 	IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
   149 	// Visual state
   150 	IMPORT_C virtual void MakeVisible(TBool aVisible);
   151 	IMPORT_C virtual void SetDimmed(TBool aDimmed);
   152 	// Construction
   153 	IMPORT_C virtual void SetContainerWindowL(const CCoeControl& aContainer);
   154 	IMPORT_C virtual void ConstructFromResourceL(TResourceReader& aReader);
   155 	IMPORT_C virtual void ActivateL();
   156 	// Focus
   157 	IMPORT_C virtual void PrepareForFocusLossL();
   158 	IMPORT_C virtual void PrepareForFocusGainL();
   159 	// Control proximity
   160 	IMPORT_C virtual void SetAdjacent(TInt aAdjacent);
   161 	IMPORT_C virtual void SetNeighbor(CCoeControl* aNeighbor);
   162 	IMPORT_C virtual TBool HasBorder() const;	// deprecated from 9.2
   163 	// Control size
   164 	IMPORT_C virtual TSize MinimumSize();
   165 	// Resource change handling
   166 	IMPORT_C virtual void HandleResourceChange(TInt aType);
   167 	// Logical color use (for Java)
   168 	IMPORT_C virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const;
   169 	// User help
   170 	IMPORT_C virtual void GetHelpContext(TCoeHelpContext& aContext) const;
   171 	// Text input
   172 	IMPORT_C virtual TCoeInputCapabilities InputCapabilities() const;
   173 public:	
   174 	// Environment
   175 	inline CCoeEnv* ControlEnv() const;
   176 	// Container window
   177 	IMPORT_C RDrawableWindow* DrawableWindow() const;
   178 	IMPORT_C TBool OwnsWindow() const;
   179 	IMPORT_C TBool IsBackedUp() const;
   180 	IMPORT_C void SetContainerWindowL(RWindow& aWindow); 			// deprecated from 9.2
   181 	IMPORT_C void SetContainerWindowL(RBackedUpWindow& aWindow);	// deprecated from 9.2
   182 	// Control parent
   183 	IMPORT_C CCoeControl* Parent();
   184 	IMPORT_C const CCoeControl* Parent() const;
   185 	IMPORT_C virtual TInt SetParent(CCoeControl* aParent);
   186 	// Size and position
   187 	IMPORT_C TRect Rect() const;
   188 	IMPORT_C void SetRect(const TRect& aRect);
   189 	IMPORT_C void SetExtent(const TPoint& aPosition,const TSize& aSize);
   190 	IMPORT_C void SetExtentToWholeScreen();
   191 	IMPORT_C TSize Size() const;
   192 	IMPORT_C void SetSize(const TSize& aSize);
   193 	IMPORT_C TPoint Position() const;
   194 	IMPORT_C TPoint PositionRelativeToScreen() const;
   195 	IMPORT_C void SetPosition(const TPoint& aPosition);
   196 	IMPORT_C TInt MaximumWidth() const;
   197 	IMPORT_C TInt SetMaximumWidth(TInt aMaxWidth);
   198 	// Layout	
   199 	IMPORT_C MCoeLayoutManager* LayoutManager() const;
   200 	IMPORT_C virtual void SetLayoutManagerL(MCoeLayoutManager* aLayout);
   201 	IMPORT_C virtual TBool RequestRelayout(const CCoeControl* aChildControl);
   202 	// Visibility
   203 	IMPORT_C TBool IsVisible() const;
   204 	IMPORT_C void SetComponentsToInheritVisibility(TBool aInherit=ETrue);
   205 	// Dimmed
   206 	IMPORT_C TBool IsDimmed() const;
   207 	// State observer
   208 	IMPORT_C void SetObserver(MCoeControlObserver* aObserver);
   209 	IMPORT_C MCoeControlObserver* Observer() const;
   210 	// Focus
   211 	IMPORT_C TBool IsFocused() const;
   212 	IMPORT_C void SetFocus(TBool aFocus,TDrawNow aDrawNow=ENoDrawNow);
   213 	IMPORT_C void SetNonFocusing();
   214 	IMPORT_C void SetFocusing(TBool aFocusing);
   215 	IMPORT_C TBool IsNonFocusing() const;
   216 	// Drawing (see also Draw() below)
   217 	IMPORT_C void DrawNow() const;
   218 	IMPORT_C void DrawNow(const TRect &aRect) const;
   219 	IMPORT_C void DrawDeferred() const;
   220 	IMPORT_C CWindowGc& SystemGc() const;
   221 	IMPORT_C TInt SetCustomGc(CWindowGc* aGraphicsContext);
   222 	IMPORT_C CWindowGc* CustomGc() const;	
   223 	// Control context (background color etc). Deprecated (use MCoeControlBackground)
   224 	IMPORT_C void SetControlContext(MCoeControlContext* aContext);		// deprecated from 9.2
   225 	IMPORT_C void CopyControlContextFrom(const CCoeControl* aControl);	// deprecated from 9.2
   226 	IMPORT_C MCoeControlContext* ControlContext() const;				// deprecated from 9.2
   227 	// Pointer events
   228 	IMPORT_C void SetPointerCapture(TBool aCapture=ETrue);
   229 	IMPORT_C void ClaimPointerGrab(TBool aSendUpEvent=ETrue);
   230 	IMPORT_C void IgnoreEventsUntilNextPointerUp();
   231 	IMPORT_C void SetGloballyCapturing(TBool aGlobal);
   232 	// Pointer hit test
   233 	IMPORT_C TInt SetHitTest(const MCoeControlHitTest* aHitTestControl);
   234 	IMPORT_C const MCoeControlHitTest* HitTest() const;
   235 	// Logical colors
   236 	IMPORT_C void OverrideColorL(TInt aLogicalColor,TRgb aColor);
   237 	IMPORT_C TBool GetColor(TInt aLogicalColor,TRgb& aColor) const;
   238 	// Control background
   239 	IMPORT_C void DrawBackground(const TRect& aRect) const;
   240 	IMPORT_C void DrawForeground(const TRect& aRect) const;
   241 	IMPORT_C const MCoeControlBackground* Background() const;
   242 	IMPORT_C const MCoeControlBackground* FindBackground() const;
   243 	IMPORT_C void SetBackground(const MCoeControlBackground* aBackground);
   244 	// Zooming
   245 	IMPORT_C void SetZoomFactorL(TInt aZoomFactor, TZoomType aZoomType = ERelativeZoom);
   246    	IMPORT_C TZoomFactor AccumulatedZoom() const;
   247    	IMPORT_C const TCoeZoomWithType* ZoomWithType() const;
   248   	// Font provider (see ScreenFont() below)
   249     IMPORT_C const CCoeFontProvider& FindFontProvider() const;
   250 	IMPORT_C void SetFontProviderL(const CCoeFontProvider& aFontProvider);
   251 	// Text baseline (virtuals)
   252 	IMPORT_C virtual TInt TextBaselineOffset(const TSize& aSize) const;
   253 	IMPORT_C virtual void SetTextBaselineSpacing(TInt aSpacing);
   254 	// Input capabilities
   255 	IMPORT_C TCoeInputCapabilities RecursivelyMergedInputCapabilities() const;
   256 	// Interface access
   257 	IMPORT_C void SetMopParent(MObjectProvider* aParent);
   258 	// Instance identification
   259 	IMPORT_C TInt UniqueHandle() const;
   260 	IMPORT_C TInt SetUniqueHandle(TInt aUniqueHandle); 
   261 public: // Pointer events (virtuals)
   262 	IMPORT_C virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
   263 protected: // Virtuals. Override to handle these events.
   264 	IMPORT_C virtual void HandlePointerBufferReadyL();	// See HandlePointerEventL()
   265 	// Change of focus
   266 	IMPORT_C virtual void FocusChanged(TDrawNow aDrawNow);
   267 	// Change of size and position
   268 	IMPORT_C virtual void SizeChanged();
   269 	IMPORT_C virtual void PositionChanged();
   270 public:
   271 	// Component control access
   272 	IMPORT_C virtual TInt CountComponentControls() const;
   273 	IMPORT_C virtual CCoeControl* ComponentControl(TInt aIndex) const;
   274 	IMPORT_C TInt Index(const CCoeControl* aControl) const;
   275 protected:
   276 	// Control state	
   277 	IMPORT_C TBool IsActivated() const;
   278 	IMPORT_C TBool IsBeingDestroyed() const;
   279 	// Component ownership
   280 	IMPORT_C void InitComponentArrayL();
   281 	IMPORT_C CCoeControlArray& Components();
   282 	IMPORT_C const CCoeControlArray& Components() const;
   283 	// Container window
   284 	IMPORT_C RWindow& Window() const;
   285 	IMPORT_C RBackedUpWindow& BackedUpWindow() const;
   286 	IMPORT_C void CloseWindow();
   287 	IMPORT_C void CreateWindowL();
   288 	IMPORT_C void CreateWindowL(const CCoeControl* aParent);
   289 	IMPORT_C void CreateWindowL(RWindowTreeNode& aParent);
   290 	IMPORT_C void CreateWindowL(RWindowGroup* aParent);
   291 	IMPORT_C void CreateBackedUpWindowL(RWindowTreeNode& aParent);
   292 	IMPORT_C void CreateBackedUpWindowL(RWindowTreeNode& aParent,TDisplayMode aDisplayMode);
   293 	IMPORT_C void EnableWindowTransparency();
   294 	// Size and position
   295 	IMPORT_C void SetCornerAndSize(TGulAlignment aCorner,const TSize& aSize);
   296 	IMPORT_C void SetSizeWithoutNotification(const TSize& aSize);
   297 	// Font access
   298 	IMPORT_C const CFont& ScreenFont(const TCoeFont& aFont) const;
   299 	// Text drawer
   300 	IMPORT_C CCoeTextDrawerBase& TextDrawer(TInt aKey = KErrNotFound) const; 
   301 	// Pointer events
   302 	IMPORT_C void EnableDragEvents();
   303 	IMPORT_C void HandleRedrawEvent(const TRect& aRect) const;
   304 	IMPORT_C void SetAllowStrayPointers();
   305 	IMPORT_C CCoeControl* GrabbingComponent() const;
   306 	IMPORT_C TBool CapturesPointer() const;
   307 	// Drawing	
   308 	IMPORT_C TBool IsReadyToDraw() const;
   309 	IMPORT_C TBool IsBlank() const;
   310 	IMPORT_C void SetBlank();
   311 	IMPORT_C void SetCanDrawOutsideRect();
   312 	IMPORT_C void ActivateGc() const;
   313 	IMPORT_C void DeactivateGc() const;
   314 	IMPORT_C void ResetGc() const;
   315 	// State events
   316 	IMPORT_C void ReportEventL(MCoeControlObserver::TCoeEvent aEvent);
   317 	// Resource changes	
   318 	IMPORT_C void HandleComponentControlsResourceChange(TInt aType);
   319 	// Copy Constructor and Assignment Operator
   320 	inline CCoeControl(const CCoeControl& aControl);
   321 	inline CCoeControl& operator=(const CCoeControl& aControl);
   322 protected:	
   323 	friend class CCoeControlArray;   
   324 	IMPORT_C virtual void HandleControlArrayEventL(CCoeControlArray::TEvent aEvent, const CCoeControlArray* aArray, CCoeControl* aControl, TInt aControlId);
   325 private: // reserved
   326 	IMPORT_C virtual void Reserved_CCoeControl_10();
   327 	IMPORT_C virtual void Reserved_CCoeControl_11();
   328 	IMPORT_C virtual void Reserved_CCoeControl_12();
   329 	IMPORT_C virtual void Reserved_CCoeControl_13();
   330 private:
   331 	IMPORT_C virtual void GetTextDrawer(CCoeTextDrawerBase*& aTextDrawer, const CCoeControl* aDrawingControl, TInt aKey) const;
   332 private: // reserved
   333 	IMPORT_C virtual void Reserved_CCoeControl_8();
   334 	IMPORT_C virtual void Reserved_CCoeControl_9();
   335 protected: // from MObjectProvider
   336 	IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
   337 private: // from MObjectProvider
   338 	IMPORT_C MObjectProvider* MopNext();
   339 private: 
   340 	// Drawing (override this to draw)
   341 	IMPORT_C virtual void Draw(const TRect& aRect) const;
   342 protected: 
   343 	// Debugging
   344 	IMPORT_C virtual void WriteInternalStateL(RWriteStream& aWriteStream) const;
   345 private: // reserved
   346 	IMPORT_C virtual void Reserved_2();
   347 public: // but not exported
   348 	void ProcessPointerEventL(const TPointerEvent& aPointerEvent);
   349 	void ProcessPointerBufferReadyL();
   350 	void RecursivelyMergeInputCapabilities(TCoeInputCapabilities& aInputCapabilities) const;
   351 	void WriteInternalStateNowL(RWriteStream& aWriteStream) const;
   352     void NotifyFontChange(const CCoeFontProvider* aFontProvider);
   353     void RemoveFromParent();
   354     void RefetchPixelMappingL();
   355 public: // deprecated
   356 	inline TInt SetGc(CWindowGc* aGraphicsContext) const;
   357 	inline CWindowGc* GetGc() const;
   358 private:
   359 	friend class CCoeRedrawer;
   360 	void DrawComponents(const TRect& aRect) const;	
   361 	void DrawWindowOwningComponentsNow() const;
   362 	void DrawWindowOwningComponentsNow(const TRect &aRect) const;	
   363 	void SetGrabbed(TBool aGrabbed);
   364 	TBool IsGrabbed() const;
   365 	void DoMakeVisible(TBool aVisible);
   366 	void CheckPointerEventPurge() const;
   367 	void RecursivelyMergeTextDrawers(CCoeTextDrawerBase*& aTextDrawer, const CCoeControl* aDrawingControl, TInt aKey) const;
   368 	CCoeControl* WindowOwningParent();
   369 	const CCoeControl* WindowOwningParent() const { return const_cast<CCoeControl*>(this)->WindowOwningParent(); }
   370 	const CCoeControl* SearchParent(const CCoeControl* aParentToFind) const;
   371 	TInt SetZoomWithType(TCoeZoomWithType* aZoomWithType);
   372 	TCoeZoomWithType* GetZoomWithType() const;
   373 	TInt SetFontProvider(const CCoeFontProvider* aFontProvider);
   374 	const CCoeFontProvider* GetFontProvider() const;
   375 	TInt FindColor(TInt aLogicalColor) const;
   376 	void ActivateGcRecursive() const;
   377 	void DeactivateGcRecursive() const;
   378 	void ReportControlStateChange(MCoeControlStateObserver::TCoeState aType);
   379 public:	
   380 	IMPORT_C void EnableReportControlStateChange(TBool aState);
   381 
   382 protected:
   383 	CCoeEnv* iCoeEnv;
   384 	MCoeControlContext* iContext;	// deprecated
   385 	TPoint iPosition;
   386 	TSize iSize;
   387 private:
   388 	TInt iFlags;
   389 	RDrawableWindow* iWin;
   390 	RCoeDynamicDataStorage* iData;
   391 	MObjectProvider* iMopParent;
   392 	};
   393 
   394 
   395 /** 
   396 Gets the control environment object for this control.
   397 
   398 @return The control's control environment object. 
   399 */
   400 inline CCoeEnv* CCoeControl::ControlEnv() const
   401 	{ return(iCoeEnv); }
   402 
   403 /**
   404 Deprecated. See CCoeControl::SetCustomGc().
   405 @deprecated
   406 */
   407 inline TInt CCoeControl::SetGc(CWindowGc* aGraphicsContext) const
   408 	{ return const_cast<CCoeControl*>(this)->SetCustomGc(aGraphicsContext); }
   409 	
   410 /**
   411 Deprecated. See CCoeControl::CustomGc().
   412 @deprecated
   413 */
   414 inline CWindowGc* CCoeControl::GetGc() const
   415 	{ return CustomGc(); }
   416 
   417 
   418 #endif	// __COECNTRL_H__