1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/mw/coecntrl.h Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,418 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// 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.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __COECNTRL_H__
1.20 +#define __COECNTRL_H__
1.21 +
1.22 +#include <e32std.h>
1.23 +#include <e32base.h>
1.24 +#include <w32std.h>
1.25 +#include <gulalign.h>
1.26 +#include <coedef.h>
1.27 +#include <coecobs.h>
1.28 +#include <coehelp.h>
1.29 +#include <coeinput.h>
1.30 +#include <coemop.h>
1.31 +#include <coemain.h>
1.32 +#include <coefont.h>
1.33 +#include <coetextdrawer.h>
1.34 +#include <coecontrolarray.h>
1.35 +
1.36 +#include <coecoloruse.h> // class TCoeColorUse
1.37 +
1.38 +class TResourceReader;
1.39 +class CCoeEnv;
1.40 +class MCoeControlContext;
1.41 +class RCoeDynamicDataStorage;
1.42 +
1.43 +class MCoeLayoutManager;
1.44 +class TCoeZoomWithType;
1.45 +class CCoeFontProvider;
1.46 +
1.47 +// forward declarations.
1.48 +class CCoeControl;
1.49 +class CCoeTextDrawerBase;
1.50 +
1.51 +/** Interface to be used if a control elects to be a background drawer.
1.52 +
1.53 +Parent controls can elect to take responsibility for drawing the background for their child
1.54 +controls. To achieve this, they should aggregate an object that implements this interface.
1.55 +CCoeControl::SetBackground() accepts the object and sets it as the background drawer
1.56 +
1.57 +@see CCoeControl::EnableWindowTransparency()
1.58 +@publishedAll
1.59 +@released
1.60 +*/
1.61 +class MCoeControlBackground
1.62 + {
1.63 +public:
1.64 + /** Draw the background for a given control.
1.65 + The text drawer that shall be used to draw text on the specific background can be
1.66 + fetched through the GetTextDrawer() method.
1.67 +
1.68 + @param aGc Graphics context used for drawing
1.69 + @param aControl The control being drawn (may be a child of the drawer)
1.70 + @param aRect The area to be redrawn
1.71 +
1.72 + @publishedAll
1.73 + @released
1.74 + */
1.75 + virtual void Draw(CWindowGc& aGc, const CCoeControl& aControl, const TRect& aRect) const = 0;
1.76 + /**
1.77 + This function retrieves the text drawer associated with the background.
1.78 + @param aTextDrawer The text drawer associated with the background. This may be null. The default implementation
1.79 + always sets this to 0.
1.80 + @param aDrawingControl The control that is requesting the text drawer.
1.81 + */
1.82 + IMPORT_C virtual void GetTextDrawer(CCoeTextDrawerBase*& aTextDrawer, const CCoeControl* aDrawingControl) const;
1.83 +protected:
1.84 + IMPORT_C MCoeControlBackground();
1.85 +private:
1.86 + IMPORT_C virtual void MCoeControlBackground_Reserved1();
1.87 + IMPORT_C virtual void MCoeControlBackground_Reserved2();
1.88 + IMPORT_C virtual void MCoeControlBackground_Reserved3();
1.89 + IMPORT_C virtual void MCoeControlBackground_Reserved4();
1.90 + IMPORT_C virtual void MCoeControlBackground_Reserved5();
1.91 +private:
1.92 + TInt iMCoeControlBackground_Reserved1();
1.93 + };
1.94 +
1.95 +/** Abstract interface for defining a control's hit region.
1.96 +
1.97 +This could be implemented by a CCoeControl-derived class to
1.98 +define hit region checking. The object is installed by calling CCoeControl::SetHitTest().
1.99 +
1.100 +The hit region is the area inside the control's rectangle in which pointer events are handled.
1.101 +It can be any shape, not necessarily rectangular.
1.102 +
1.103 +@publishedAll
1.104 +@released
1.105 +*/
1.106 +class MCoeControlHitTest
1.107 + {
1.108 +public:
1.109 + /** Tests whether a pointer event occurred inside the control's hit region.
1.110 + This function is called by CCoeControl::HandlePointerEventL().
1.111 +
1.112 + @param aPoint The position of the pointer event.
1.113 + @return ETrue if the specified point lies inside the hit region, EFalse if not.
1.114 +
1.115 + @publishedAll
1.116 + @released
1.117 + */
1.118 + virtual TBool HitRegionContains(const TPoint& aPoint, const CCoeControl& aControl) const = 0;
1.119 +protected:
1.120 + IMPORT_C MCoeControlHitTest();
1.121 +private:
1.122 + IMPORT_C virtual void MCoeControlHitTest_Reserved1();
1.123 + IMPORT_C virtual void MCoeControlHitTest_Reserved2();
1.124 +private:
1.125 + TInt iMCoeControlHitTest_Reserved1;
1.126 + };
1.127 +
1.128 +
1.129 +/**
1.130 +Control base class from which all other controls are derived.
1.131 +
1.132 +@publishedAll
1.133 +@released
1.134 +*/
1.135 +class CCoeControl : public CBase, public MObjectProvider
1.136 + {
1.137 +public:
1.138 + enum TZoomType
1.139 + {
1.140 + EAbsoluteZoom, // absolute
1.141 + ERelativeZoom // relative to parent's zoom
1.142 + };
1.143 +public:
1.144 + // Construction and destruction
1.145 + IMPORT_C CCoeControl();
1.146 + IMPORT_C CCoeControl(CCoeEnv* aCoeEnv);
1.147 + IMPORT_C ~CCoeControl();
1.148 + IMPORT_C TBool ComponentArrayExists() const;
1.149 +public: // Virtuals (see more related non-virtuals further down)
1.150 + // Key input
1.151 + IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
1.152 + // Visual state
1.153 + IMPORT_C virtual void MakeVisible(TBool aVisible);
1.154 + IMPORT_C virtual void SetDimmed(TBool aDimmed);
1.155 + // Construction
1.156 + IMPORT_C virtual void SetContainerWindowL(const CCoeControl& aContainer);
1.157 + IMPORT_C virtual void ConstructFromResourceL(TResourceReader& aReader);
1.158 + IMPORT_C virtual void ActivateL();
1.159 + // Focus
1.160 + IMPORT_C virtual void PrepareForFocusLossL();
1.161 + IMPORT_C virtual void PrepareForFocusGainL();
1.162 + // Control proximity
1.163 + IMPORT_C virtual void SetAdjacent(TInt aAdjacent);
1.164 + IMPORT_C virtual void SetNeighbor(CCoeControl* aNeighbor);
1.165 + IMPORT_C virtual TBool HasBorder() const; // deprecated from 9.2
1.166 + // Control size
1.167 + IMPORT_C virtual TSize MinimumSize();
1.168 + // Resource change handling
1.169 + IMPORT_C virtual void HandleResourceChange(TInt aType);
1.170 + // Logical color use (for Java)
1.171 + IMPORT_C virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const;
1.172 + // User help
1.173 + IMPORT_C virtual void GetHelpContext(TCoeHelpContext& aContext) const;
1.174 + // Text input
1.175 + IMPORT_C virtual TCoeInputCapabilities InputCapabilities() const;
1.176 +public:
1.177 + // Environment
1.178 + inline CCoeEnv* ControlEnv() const;
1.179 + // Container window
1.180 + IMPORT_C RDrawableWindow* DrawableWindow() const;
1.181 + IMPORT_C TBool OwnsWindow() const;
1.182 + IMPORT_C TBool IsBackedUp() const;
1.183 + IMPORT_C void SetContainerWindowL(RWindow& aWindow); // deprecated from 9.2
1.184 + IMPORT_C void SetContainerWindowL(RBackedUpWindow& aWindow); // deprecated from 9.2
1.185 + // Control parent
1.186 + IMPORT_C CCoeControl* Parent();
1.187 + IMPORT_C const CCoeControl* Parent() const;
1.188 + IMPORT_C virtual TInt SetParent(CCoeControl* aParent);
1.189 + // Size and position
1.190 + IMPORT_C TRect Rect() const;
1.191 + IMPORT_C void SetRect(const TRect& aRect);
1.192 + IMPORT_C void SetExtent(const TPoint& aPosition,const TSize& aSize);
1.193 + IMPORT_C void SetExtentToWholeScreen();
1.194 + IMPORT_C TSize Size() const;
1.195 + IMPORT_C void SetSize(const TSize& aSize);
1.196 + IMPORT_C TPoint Position() const;
1.197 + IMPORT_C TPoint PositionRelativeToScreen() const;
1.198 + IMPORT_C void SetPosition(const TPoint& aPosition);
1.199 + IMPORT_C TInt MaximumWidth() const;
1.200 + IMPORT_C TInt SetMaximumWidth(TInt aMaxWidth);
1.201 + // Layout
1.202 + IMPORT_C MCoeLayoutManager* LayoutManager() const;
1.203 + IMPORT_C virtual void SetLayoutManagerL(MCoeLayoutManager* aLayout);
1.204 + IMPORT_C virtual TBool RequestRelayout(const CCoeControl* aChildControl);
1.205 + // Visibility
1.206 + IMPORT_C TBool IsVisible() const;
1.207 + IMPORT_C void SetComponentsToInheritVisibility(TBool aInherit=ETrue);
1.208 + // Dimmed
1.209 + IMPORT_C TBool IsDimmed() const;
1.210 + // State observer
1.211 + IMPORT_C void SetObserver(MCoeControlObserver* aObserver);
1.212 + IMPORT_C MCoeControlObserver* Observer() const;
1.213 + // Focus
1.214 + IMPORT_C TBool IsFocused() const;
1.215 + IMPORT_C void SetFocus(TBool aFocus,TDrawNow aDrawNow=ENoDrawNow);
1.216 + IMPORT_C void SetNonFocusing();
1.217 + IMPORT_C void SetFocusing(TBool aFocusing);
1.218 + IMPORT_C TBool IsNonFocusing() const;
1.219 + // Drawing (see also Draw() below)
1.220 + IMPORT_C void DrawNow() const;
1.221 + IMPORT_C void DrawNow(const TRect &aRect) const;
1.222 + IMPORT_C void DrawDeferred() const;
1.223 + IMPORT_C CWindowGc& SystemGc() const;
1.224 + IMPORT_C TInt SetCustomGc(CWindowGc* aGraphicsContext);
1.225 + IMPORT_C CWindowGc* CustomGc() const;
1.226 + // Control context (background color etc). Deprecated (use MCoeControlBackground)
1.227 + IMPORT_C void SetControlContext(MCoeControlContext* aContext); // deprecated from 9.2
1.228 + IMPORT_C void CopyControlContextFrom(const CCoeControl* aControl); // deprecated from 9.2
1.229 + IMPORT_C MCoeControlContext* ControlContext() const; // deprecated from 9.2
1.230 + // Pointer events
1.231 + IMPORT_C void SetPointerCapture(TBool aCapture=ETrue);
1.232 + IMPORT_C void ClaimPointerGrab(TBool aSendUpEvent=ETrue);
1.233 + IMPORT_C void IgnoreEventsUntilNextPointerUp();
1.234 + IMPORT_C void SetGloballyCapturing(TBool aGlobal);
1.235 + // Pointer hit test
1.236 + IMPORT_C TInt SetHitTest(const MCoeControlHitTest* aHitTestControl);
1.237 + IMPORT_C const MCoeControlHitTest* HitTest() const;
1.238 + // Logical colors
1.239 + IMPORT_C void OverrideColorL(TInt aLogicalColor,TRgb aColor);
1.240 + IMPORT_C TBool GetColor(TInt aLogicalColor,TRgb& aColor) const;
1.241 + // Control background
1.242 + IMPORT_C void DrawBackground(const TRect& aRect) const;
1.243 + IMPORT_C void DrawForeground(const TRect& aRect) const;
1.244 + IMPORT_C const MCoeControlBackground* Background() const;
1.245 + IMPORT_C const MCoeControlBackground* FindBackground() const;
1.246 + IMPORT_C void SetBackground(const MCoeControlBackground* aBackground);
1.247 + // Zooming
1.248 + IMPORT_C void SetZoomFactorL(TInt aZoomFactor, TZoomType aZoomType = ERelativeZoom);
1.249 + IMPORT_C TZoomFactor AccumulatedZoom() const;
1.250 + IMPORT_C const TCoeZoomWithType* ZoomWithType() const;
1.251 + // Font provider (see ScreenFont() below)
1.252 + IMPORT_C const CCoeFontProvider& FindFontProvider() const;
1.253 + IMPORT_C void SetFontProviderL(const CCoeFontProvider& aFontProvider);
1.254 + // Text baseline (virtuals)
1.255 + IMPORT_C virtual TInt TextBaselineOffset(const TSize& aSize) const;
1.256 + IMPORT_C virtual void SetTextBaselineSpacing(TInt aSpacing);
1.257 + // Input capabilities
1.258 + IMPORT_C TCoeInputCapabilities RecursivelyMergedInputCapabilities() const;
1.259 + // Interface access
1.260 + IMPORT_C void SetMopParent(MObjectProvider* aParent);
1.261 + // Instance identification
1.262 + IMPORT_C TInt UniqueHandle() const;
1.263 + IMPORT_C TInt SetUniqueHandle(TInt aUniqueHandle);
1.264 +public: // Pointer events (virtuals)
1.265 + IMPORT_C virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
1.266 +protected: // Virtuals. Override to handle these events.
1.267 + IMPORT_C virtual void HandlePointerBufferReadyL(); // See HandlePointerEventL()
1.268 + // Change of focus
1.269 + IMPORT_C virtual void FocusChanged(TDrawNow aDrawNow);
1.270 + // Change of size and position
1.271 + IMPORT_C virtual void SizeChanged();
1.272 + IMPORT_C virtual void PositionChanged();
1.273 +public:
1.274 + // Component control access
1.275 + IMPORT_C virtual TInt CountComponentControls() const;
1.276 + IMPORT_C virtual CCoeControl* ComponentControl(TInt aIndex) const;
1.277 + IMPORT_C TInt Index(const CCoeControl* aControl) const;
1.278 +protected:
1.279 + // Control state
1.280 + IMPORT_C TBool IsActivated() const;
1.281 + IMPORT_C TBool IsBeingDestroyed() const;
1.282 + // Component ownership
1.283 + IMPORT_C void InitComponentArrayL();
1.284 + IMPORT_C CCoeControlArray& Components();
1.285 + IMPORT_C const CCoeControlArray& Components() const;
1.286 + // Container window
1.287 + IMPORT_C RWindow& Window() const;
1.288 + IMPORT_C RBackedUpWindow& BackedUpWindow() const;
1.289 + IMPORT_C void CloseWindow();
1.290 + IMPORT_C void CreateWindowL();
1.291 + IMPORT_C void CreateWindowL(const CCoeControl* aParent);
1.292 + IMPORT_C void CreateWindowL(RWindowTreeNode& aParent);
1.293 + IMPORT_C void CreateWindowL(RWindowGroup* aParent);
1.294 + IMPORT_C void CreateBackedUpWindowL(RWindowTreeNode& aParent);
1.295 + IMPORT_C void CreateBackedUpWindowL(RWindowTreeNode& aParent,TDisplayMode aDisplayMode);
1.296 + IMPORT_C void EnableWindowTransparency();
1.297 + // Size and position
1.298 + IMPORT_C void SetCornerAndSize(TGulAlignment aCorner,const TSize& aSize);
1.299 + IMPORT_C void SetSizeWithoutNotification(const TSize& aSize);
1.300 + // Font access
1.301 + IMPORT_C const CFont& ScreenFont(const TCoeFont& aFont) const;
1.302 + // Text drawer
1.303 + IMPORT_C CCoeTextDrawerBase& TextDrawer(TInt aKey = KErrNotFound) const;
1.304 + // Pointer events
1.305 + IMPORT_C void EnableDragEvents();
1.306 + IMPORT_C void HandleRedrawEvent(const TRect& aRect) const;
1.307 + IMPORT_C void SetAllowStrayPointers();
1.308 + IMPORT_C CCoeControl* GrabbingComponent() const;
1.309 + IMPORT_C TBool CapturesPointer() const;
1.310 + // Drawing
1.311 + IMPORT_C TBool IsReadyToDraw() const;
1.312 + IMPORT_C TBool IsBlank() const;
1.313 + IMPORT_C void SetBlank();
1.314 + IMPORT_C void SetCanDrawOutsideRect();
1.315 + IMPORT_C void ActivateGc() const;
1.316 + IMPORT_C void DeactivateGc() const;
1.317 + IMPORT_C void ResetGc() const;
1.318 + // State events
1.319 + IMPORT_C void ReportEventL(MCoeControlObserver::TCoeEvent aEvent);
1.320 + // Resource changes
1.321 + IMPORT_C void HandleComponentControlsResourceChange(TInt aType);
1.322 + // Copy Constructor and Assignment Operator
1.323 + inline CCoeControl(const CCoeControl& aControl);
1.324 + inline CCoeControl& operator=(const CCoeControl& aControl);
1.325 +protected:
1.326 + friend class CCoeControlArray;
1.327 + IMPORT_C virtual void HandleControlArrayEventL(CCoeControlArray::TEvent aEvent, const CCoeControlArray* aArray, CCoeControl* aControl, TInt aControlId);
1.328 +private: // reserved
1.329 + IMPORT_C virtual void Reserved_CCoeControl_10();
1.330 + IMPORT_C virtual void Reserved_CCoeControl_11();
1.331 + IMPORT_C virtual void Reserved_CCoeControl_12();
1.332 + IMPORT_C virtual void Reserved_CCoeControl_13();
1.333 +private:
1.334 + IMPORT_C virtual void GetTextDrawer(CCoeTextDrawerBase*& aTextDrawer, const CCoeControl* aDrawingControl, TInt aKey) const;
1.335 +private: // reserved
1.336 + IMPORT_C virtual void Reserved_CCoeControl_8();
1.337 + IMPORT_C virtual void Reserved_CCoeControl_9();
1.338 +protected: // from MObjectProvider
1.339 + IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
1.340 +private: // from MObjectProvider
1.341 + IMPORT_C MObjectProvider* MopNext();
1.342 +private:
1.343 + // Drawing (override this to draw)
1.344 + IMPORT_C virtual void Draw(const TRect& aRect) const;
1.345 +protected:
1.346 + // Debugging
1.347 + IMPORT_C virtual void WriteInternalStateL(RWriteStream& aWriteStream) const;
1.348 +private: // reserved
1.349 + IMPORT_C virtual void Reserved_2();
1.350 +public: // but not exported
1.351 + void ProcessPointerEventL(const TPointerEvent& aPointerEvent);
1.352 + void ProcessPointerBufferReadyL();
1.353 + void RecursivelyMergeInputCapabilities(TCoeInputCapabilities& aInputCapabilities) const;
1.354 + void WriteInternalStateNowL(RWriteStream& aWriteStream) const;
1.355 + void NotifyFontChange(const CCoeFontProvider* aFontProvider);
1.356 + void RemoveFromParent();
1.357 + void RefetchPixelMappingL();
1.358 +public: // deprecated
1.359 + inline TInt SetGc(CWindowGc* aGraphicsContext) const;
1.360 + inline CWindowGc* GetGc() const;
1.361 +private:
1.362 + friend class CCoeRedrawer;
1.363 + void DrawComponents(const TRect& aRect) const;
1.364 + void DrawWindowOwningComponentsNow() const;
1.365 + void DrawWindowOwningComponentsNow(const TRect &aRect) const;
1.366 + void SetGrabbed(TBool aGrabbed);
1.367 + TBool IsGrabbed() const;
1.368 + void DoMakeVisible(TBool aVisible);
1.369 + void CheckPointerEventPurge() const;
1.370 + void RecursivelyMergeTextDrawers(CCoeTextDrawerBase*& aTextDrawer, const CCoeControl* aDrawingControl, TInt aKey) const;
1.371 + CCoeControl* WindowOwningParent();
1.372 + const CCoeControl* WindowOwningParent() const { return const_cast<CCoeControl*>(this)->WindowOwningParent(); }
1.373 + const CCoeControl* SearchParent(const CCoeControl* aParentToFind) const;
1.374 + TInt SetZoomWithType(TCoeZoomWithType* aZoomWithType);
1.375 + TCoeZoomWithType* GetZoomWithType() const;
1.376 + TInt SetFontProvider(const CCoeFontProvider* aFontProvider);
1.377 + const CCoeFontProvider* GetFontProvider() const;
1.378 + TInt FindColor(TInt aLogicalColor) const;
1.379 + void ActivateGcRecursive() const;
1.380 + void DeactivateGcRecursive() const;
1.381 + void ReportControlStateChange(MCoeControlStateObserver::TCoeState aType);
1.382 +public:
1.383 + IMPORT_C void EnableReportControlStateChange(TBool aState);
1.384 +
1.385 +protected:
1.386 + CCoeEnv* iCoeEnv;
1.387 + MCoeControlContext* iContext; // deprecated
1.388 + TPoint iPosition;
1.389 + TSize iSize;
1.390 +private:
1.391 + TInt iFlags;
1.392 + RDrawableWindow* iWin;
1.393 + RCoeDynamicDataStorage* iData;
1.394 + MObjectProvider* iMopParent;
1.395 + };
1.396 +
1.397 +
1.398 +/**
1.399 +Gets the control environment object for this control.
1.400 +
1.401 +@return The control's control environment object.
1.402 +*/
1.403 +inline CCoeEnv* CCoeControl::ControlEnv() const
1.404 + { return(iCoeEnv); }
1.405 +
1.406 +/**
1.407 +Deprecated. See CCoeControl::SetCustomGc().
1.408 +@deprecated
1.409 +*/
1.410 +inline TInt CCoeControl::SetGc(CWindowGc* aGraphicsContext) const
1.411 + { return const_cast<CCoeControl*>(this)->SetCustomGc(aGraphicsContext); }
1.412 +
1.413 +/**
1.414 +Deprecated. See CCoeControl::CustomGc().
1.415 +@deprecated
1.416 +*/
1.417 +inline CWindowGc* CCoeControl::GetGc() const
1.418 + { return CustomGc(); }
1.419 +
1.420 +
1.421 +#endif // __COECNTRL_H__