javauis/lcdui_akn/lcdui/inc/CMIDCanvasGraphicsItem.h
branchRCL_3
changeset 14 04becd199f91
child 18 9ac0a0a7da70
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 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 "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  CMIDCanvasGraphicsItem - Implements the native part Canvas Graphics Item class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMIDCANVASGRAPHICSITEM_H
       
    20 #define CMIDCANVASGRAPHICSITEM_H
       
    21 
       
    22 // EXTERNAL INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <MMIDCanvasGraphicsItem.h>
       
    25 #include <MMIDCustomComponent.h>
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CMIDCanvasGraphicsItemPainter;
       
    29 class CCoeControl;
       
    30 class MMIDCustomComponentContainer;
       
    31 class CMIDUtils;
       
    32 
       
    33 // CLASS DESCRIPTION
       
    34 /**
       
    35  * Defines the Canvas Graphics Item native side component.
       
    36  */
       
    37 NONSHARABLE_CLASS(CMIDCanvasGraphicsItem) :
       
    38         public CBase,
       
    39         public MMIDCanvasGraphicsItem,
       
    40         public MMIDCustomComponent
       
    41 {
       
    42 public: // Type definitions
       
    43 
       
    44     class TCtorParams
       
    45     {
       
    46     public:
       
    47         // The CanvasGraphicsItemPainter native side peer handle. Not owned.
       
    48         CMIDCanvasGraphicsItemPainter* iPainterHandle;
       
    49         // The shared CMIDUtils instance. Not owned.
       
    50         CMIDUtils* iUtils;
       
    51 
       
    52         TCtorParams::TCtorParams() :
       
    53                 iPainterHandle(NULL),
       
    54                 iUtils(NULL) {}
       
    55     };
       
    56 
       
    57 public: // Constructors and destructor
       
    58 
       
    59     /**
       
    60      * Two-phased constructor. Creates an instance from this class
       
    61      * The caller takes the ownership of the returned instance
       
    62      *
       
    63      * @param aParams The construction parameters of this class.
       
    64      * @return New instance from this class
       
    65      */
       
    66     static CMIDCanvasGraphicsItem* NewL(const TCtorParams& aParams);
       
    67 
       
    68     /**
       
    69      * Destructor.
       
    70      */
       
    71     virtual ~CMIDCanvasGraphicsItem();
       
    72 
       
    73 
       
    74 public: // From MMIDCustomComponent
       
    75 
       
    76     /**
       
    77      * Returns the count of controls in this custom component.
       
    78      *
       
    79      * Note that the count must not change during the lifetime
       
    80      * of the object. The count of all components is updated
       
    81      * when it is added to the custom component container.
       
    82      *
       
    83      * This is done in order to improve the performance when counting
       
    84      * countrols.
       
    85      *
       
    86      * @return The count of controls in this custom component.
       
    87      * @since S60 5.0
       
    88      */
       
    89     TInt CustomComponentControlCount() const;
       
    90 
       
    91     /**
       
    92      * Returns an UI control of this custom component.
       
    93      *
       
    94      * The index specifies which component is requested. The method
       
    95      * works similar to CCoeControl::ComponentControl() method. The
       
    96      * ownership of the control is NOT transferred to the caller.
       
    97      *
       
    98      * @param aIndex The index of the control to be retrieved.
       
    99      * @return The UI control of this custom component.
       
   100      * @since S60 5.0
       
   101      */
       
   102     CCoeControl* CustomComponentControl(TInt aIndex);
       
   103 
       
   104     /**
       
   105      * Indicates that the container is about to be disposed.
       
   106      *
       
   107      * The custom component does not have to remove itself
       
   108      * from the container since the container removes all components
       
   109      * when disposing.
       
   110      *
       
   111      * @since S60 5.0
       
   112      */
       
   113     void CustomComponentContainerDisposing();
       
   114 
       
   115     /**
       
   116      * Indicates if traversal is needed and does the traverse.
       
   117      *
       
   118      * Not used on CanvasGraphicsItem.
       
   119      *
       
   120      * @param aEvent Key Event.
       
   121      * @since S60 5.0
       
   122      */
       
   123     void TraverseL(const TKeyEvent& /* aEvent */) {}
       
   124 
       
   125     /**
       
   126      * Processes the received pointer event.
       
   127      *
       
   128      * @param  aPointerEvent The pointer event. iPosition will be reset to the
       
   129      *         parent window position. iParentPosition will be invalid for the
       
   130      *         container.
       
   131      * @since S60 5.0
       
   132      */
       
   133     void ProcessPointerEventL(const TPointerEvent& /*aPointerEvent*/) {}
       
   134 
       
   135     /**
       
   136      * Gets the current touch-enabled state
       
   137      *
       
   138      * @return false, this component is not touch-enabled
       
   139      * @since S60 5.0
       
   140      */
       
   141     TBool IsTouchEnabled()
       
   142     {
       
   143         return EFalse;
       
   144     }
       
   145 
       
   146     /**
       
   147      * Handles fullscreen state of parent Canvas.
       
   148      *
       
   149      * @since S60 5.0
       
   150      */
       
   151     void HandleFullscreenModeChange();
       
   152 
       
   153     /**
       
   154      * Handles changes of screen orientation.
       
   155      *
       
   156      * @since S60 5.0
       
   157      */
       
   158     void HandleResolutionChange();
       
   159 
       
   160 public: // From MMIDCanvasGraphicsItem
       
   161 
       
   162     /**
       
   163      * Sets the parent of this canvas graphics item component. The parent must
       
   164      * implement the custom component container interface in order to
       
   165      * provide necessary services for registering custom UI components.
       
   166      *
       
   167      * The ownership of the parent is not transffered to this object.
       
   168      *
       
   169      * @param aComponentContainer The parent MIDP custom component
       
   170      *        container.
       
   171      * @since S60 5.0
       
   172      */
       
   173     void SetParentL(MMIDCustomComponentContainer* aComponentContainer);
       
   174 
       
   175     /**
       
   176      * Sets the direct container of this canvas graphics item component.
       
   177      *
       
   178      * Note that the canvas graphics item does not necessary need to have direct
       
   179      * container. If the parent component is responsible for somekind of
       
   180      * custom drawing using direct screena access, this method can be used
       
   181      * to register the direct container.
       
   182      *
       
   183      * The canvas graphics item adds itself to the direct container so that it
       
   184      * is not able to draw on top of the canvas graphics item when direct content
       
   185      * is added to the screen.
       
   186      *
       
   187      * @param aDirectContainer The direct container of this compoennt if
       
   188      *        any. <code>NULL</code> removes the current container.
       
   189      * @since S60 5.0
       
   190      */
       
   191     void SetDirectContainerL(MDirectContainer* aDirectContainer);
       
   192 
       
   193     /**
       
   194      * Sets the elevation of this canvas graphics item component.
       
   195      *
       
   196      * If the specified elevation exeeds to amount of items in the
       
   197      * custom component container, the item becomes the topmost item
       
   198      * in the custom component stack.
       
   199      *
       
   200      * Note that the elevation requsted may not be the actual elevation
       
   201      * of the item (if, for example, the elevation is higher than the
       
   202      * amount of all items, the elevation is set to the top).
       
   203      *
       
   204      * @param aElevation The new elevation (Z-position) of this item.
       
   205      * @since S60 5.0
       
   206      */
       
   207     void SetElevationL(TInt aElevation);
       
   208 
       
   209     /**
       
   210      * Returns the elevation of this canvas graphics item component.
       
   211      *
       
   212      * @return The elevation of this canvas graphics item component.
       
   213      * @since S60 5.0
       
   214      */
       
   215     TInt Elevation();
       
   216 
       
   217     /**
       
   218      * Sets this canvas graphics item component visible if it is hidden.
       
   219      *
       
   220      * Depending on the current status of the canvas graphics item, this operation
       
   221      * is no-op if there is nothing to be done. (i.e. the canvas graphics item is set
       
   222      * hidden when it is already hidden).
       
   223      *
       
   224      * @param aVisible Indicates the visibility status of the canvas graphics item.
       
   225      * @since S60 5.0
       
   226      */
       
   227     void SetVisibleL(TBool aVisible);
       
   228 
       
   229     /**
       
   230      * Sets the size of this canvas graphics item component.
       
   231      *
       
   232      * @param aWidth The width of the item.
       
   233      * @param aHeight The height of the item.
       
   234      * @since S60 5.0
       
   235      */
       
   236     void SetSizeL(const TInt aWidth, const TInt aHeight);
       
   237 
       
   238     /**
       
   239      * Sets the position of this canvas graphics item component.
       
   240      *
       
   241      * Note: Calling this function results in a call to
       
   242      *          CMIDCanvasGraphicsItemEdwin::PositionChanged().
       
   243      *
       
   244      * @param aX The x coordinate of the anchor point.
       
   245      * @param aY The y coordinate of the anchor point.
       
   246      * @since S60 5.0
       
   247      */
       
   248     void SetPosition(const TInt aX, const TInt aY);
       
   249 
       
   250 public: // From MMIDComponent
       
   251 
       
   252     /**
       
   253      * Invoked by the framework to clean up any  resources used by the
       
   254      * implementation.
       
   255      *
       
   256      * Typically, the implementation will do "delete this" but is clearly
       
   257      * not restricted to
       
   258      *
       
   259      * @since S60 5.0
       
   260      */
       
   261     void Dispose();
       
   262 
       
   263 private: // Construtors
       
   264 
       
   265     /**
       
   266      * C++ constructor.
       
   267      */
       
   268     CMIDCanvasGraphicsItem();
       
   269 
       
   270     /**
       
   271      * Second phase constructor
       
   272      *
       
   273      * @param aParams The construction parameters of this class.
       
   274      */
       
   275     void ConstructL(const TCtorParams& aParams);
       
   276 
       
   277 private: // Data
       
   278 
       
   279     // canvas graphics item control. Not owned.
       
   280     CMIDCanvasGraphicsItemPainter* iItemPainter;
       
   281 
       
   282     // Container for this object. Not owned.
       
   283     MMIDCustomComponentContainer* iComponentContainer;
       
   284 
       
   285     // The shared CMIDUtils instance. Not owned.
       
   286     CMIDUtils* iUtils;
       
   287 };
       
   288 
       
   289 #endif // CMIDCANVASGRAPHICSITEM_H
       
   290 
       
   291 // End of file