javauis/lcdui_akn/lcdui/inc/CMIDCanvasGraphicsItemPainter.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 Painter class.
       
    15 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CMIDCANVASGRAPHICSITEMPAINTER_H
       
    21 #define CMIDCANVASGRAPHICSITEMPAINTER_H
       
    22 
       
    23 // EXTERNAL INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <MMIDCanvasGraphicsItemPainter.h>
       
    26 #include <MMIDCustomComponent.h>
       
    27 
       
    28 #include <reflcdui.h>
       
    29 #include <coecntrl.h>
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CCoeControl;
       
    33 class MMIDCustomComponentContainer;
       
    34 class CMIDCanvasGraphicsItem;
       
    35 
       
    36 
       
    37 // CLASS DESCRIPTION
       
    38 /**
       
    39  * Defines the Canvas Graphics Item Painter native side component.
       
    40  */
       
    41 NONSHARABLE_CLASS(CMIDCanvasGraphicsItemPainter) :
       
    42         public CCoeControl,
       
    43         public MMIDCanvasGraphicsItemPainter,
       
    44         public MMIDBufferProcessor,
       
    45         public MDirectContent
       
    46 {
       
    47 public: // Type definitions
       
    48 
       
    49     class TCtorParams
       
    50     {
       
    51     public:
       
    52         // The width of the graphics item in pixels.
       
    53         TInt iWidth;
       
    54 
       
    55         // The height of the graphics item in pixels or in rows.
       
    56         TInt iHeight;
       
    57 
       
    58         // Environment instance
       
    59         MMIDEnv* iEnv;
       
    60 
       
    61         TCtorParams::TCtorParams() :
       
    62                 iWidth(0),
       
    63                 iHeight(0),
       
    64                 iEnv(NULL)
       
    65         {}
       
    66     };
       
    67 
       
    68 public: // Constructors and destructor
       
    69 
       
    70     /**
       
    71      * Two-phased constructor. Creates an instance from this class
       
    72      * The caller takes the ownership of the returned instance
       
    73      *
       
    74      * @param aParams The construction parameters of this class.
       
    75      * @return New instance from this class
       
    76      */
       
    77     static CMIDCanvasGraphicsItemPainter* NewL(const TCtorParams& aParams);
       
    78 
       
    79     /**
       
    80      * Destructor.
       
    81      */
       
    82     virtual ~CMIDCanvasGraphicsItemPainter();
       
    83 
       
    84 // from base class MMIDCanvasGraphicsItemPainter
       
    85 
       
    86     /**
       
    87      * From MMIDComponent
       
    88      * Invoked by the framework to clean up any  resources used by the
       
    89      * implementation.
       
    90      *
       
    91      * Typically, the implementation will do "delete this" but is clearly
       
    92      * not restricted to
       
    93      *
       
    94      * @since S60 5.0
       
    95      */
       
    96     void Dispose();
       
    97 
       
    98     /**
       
    99      * From MMIDComponent.
       
   100      * Returns buffer processor associated with this component.
       
   101      *
       
   102      * @since  S60 v3.0
       
   103      * @return Always returns this.
       
   104      */
       
   105     MMIDBufferProcessor* Processor();
       
   106 
       
   107     /**
       
   108      * From MMIDCanvasGraphicsItemPainter
       
   109      * Sets the position of this canvas graphics item component.
       
   110      *
       
   111      * @param aX The x coordinate of the anchor point.
       
   112      * @param aY The y coordinate of the anchor point.
       
   113      * @since S60 5.0
       
   114      */
       
   115     void SetPosition(const TInt aX, const TInt aY);
       
   116 
       
   117     /**
       
   118      * From MMIDCanvasGraphicsItemPainter
       
   119      * Sets the size of this graphics item component.
       
   120      *
       
   121      * @param aWidth The width value of the anchor point.
       
   122      * @param aHeight The height value of the anchor point.
       
   123      * @since S60 5.0
       
   124      */
       
   125     void SetItemSizeL(const TInt aWidth, const TInt aHeight);
       
   126 
       
   127     /**
       
   128      * From MMIDCanvasGraphicsItemPainter
       
   129      * Sets the direct container of this canvas graphics item component.
       
   130      *
       
   131      * Note that the canvas graphics item does not necessary need to have
       
   132      * direct container. If the parent component is responsible for somekind
       
   133      * of custom drawing using direct screena access, this method can be used
       
   134      * to register the direct container.
       
   135      *
       
   136      * The canvas graphics item adds itself to the direct container so that it
       
   137      * is not able to draw on top of the canvas graphics item when direct
       
   138      * content is added to the screen.
       
   139      *
       
   140      * @param aDirectContainer The direct container of this compoennt if
       
   141      *        any. <code>NULL</code> removes the current container.
       
   142      * @since S60 5.0
       
   143      */
       
   144     void SetDirectContainerL(MDirectContainer* aDirectContainer);
       
   145 
       
   146     /**
       
   147      * Propagates the parent to set window of this
       
   148      * canvas graphics item component.
       
   149      *
       
   150      * @param aContainer The parent MIDP custom component
       
   151      *        container.
       
   152      * @since S60 5.0
       
   153      */
       
   154     void SetParentL(MMIDCustomComponentContainer* aComponentContainer);
       
   155 
       
   156     /**
       
   157      * Sets this canvas graphics item component visible if it is hidden.
       
   158      *
       
   159      * Depending on the current status of the canvas graphics item, this
       
   160      * operation is no-op if there is nothing to do. (i.e. the canvas graphics
       
   161      * item is set hidden when it is already hidden).
       
   162      *
       
   163      * @param aVisible Indicates the visibility status of the canvas graphics
       
   164      *        item.
       
   165      * @since S60 5.0
       
   166      */
       
   167     void SetVisibleL(TBool aVisible);
       
   168 
       
   169     /**
       
   170      * Returns painter's frame buffer
       
   171      *
       
   172      * @since S60 5.0
       
   173      */
       
   174     CFbsBitmap* FrameBuffer() const;
       
   175 
       
   176     /**
       
   177      * Resets frame buffer bitmap before paint method is called.
       
   178      */
       
   179     void ResetFrameBuffer(const TPoint& aPosition, const TSize& aSize);
       
   180 
       
   181 // from base class MMIDBufferProcessor
       
   182 
       
   183     /**
       
   184      * From MMIDBufferProcessor.
       
   185      * Process a block of commands, updating read pointer as you go.
       
   186      *
       
   187      * @since  S60 v3.0
       
   188      * @param  aRead The address of the first command in the buffer for this
       
   189      *         processor.
       
   190      * @param  aEnd The address of the command *after* the last command in the
       
   191      *         buffer for this processor.
       
   192      * @param  aCycles The amount of 'compute effort' remaining in the current
       
   193      *         AO RunL.
       
   194      * @param  aStatus The request status.
       
   195      * @return Returns ETrue if processing will be async.
       
   196      */
       
   197 #ifdef RD_JAVA_NGA_ENABLED
       
   198     virtual TBool ProcessL(
       
   199         const TMIDBufferOp*& aRead, const TMIDBufferOp* aEnd,
       
   200         TInt& aCycles, java::util::Monitor* aMonitor);
       
   201 #else
       
   202     virtual TBool ProcessL(
       
   203         const TMIDBufferOp*& aRead, const TMIDBufferOp* aEnd,
       
   204         TInt& aCycles, TRequestStatus* aStatus = NULL);
       
   205 #endif
       
   206 
       
   207     /**
       
   208      * From MMIDBufferProcessor.
       
   209      * Called by framework if the processor is doing some async operation
       
   210      * when the MIDlet is closed down. Processor should cancel the async
       
   211      * operation and clean up any resources.
       
   212      *
       
   213      * @since  S60 v3.0
       
   214      */
       
   215     void AbortAsync();
       
   216 
       
   217 
       
   218 // From basic class MDirectContent
       
   219 
       
   220     /**
       
   221      * Notify content that container window has changed.
       
   222      * This should only be called when the content is displayed on an
       
   223      * Item.
       
   224      *
       
   225      * @param aWindow New window on which content can be displayed or NULL
       
   226      *        if the Item has been removed from the Form
       
   227      * @since S60 5.0
       
   228      */
       
   229     void MdcContainerWindowRectChanged(const TRect& /*aRect*/);
       
   230 
       
   231     /**
       
   232      * Notify content that container visiblity has changed. The content
       
   233      * must not be displayed when it's container is invisible.
       
   234      *
       
   235      * @param aVisible ETrue if the container is visible, EFalse if it is
       
   236      *        invisible.
       
   237      * @since S60 5.0
       
   238      */
       
   239     void MdcContainerVisibilityChanged(TBool aVisible);
       
   240 
       
   241     /**
       
   242      * Notify content that the container bounds have changed.
       
   243      *
       
   244      * @param aRect Maximum area the content can occupy in screen
       
   245      *        co-ordinates. The content should be clipped to this area.
       
   246      * @since S60 5.0
       
   247      */
       
   248     void MdcContentBoundsChanged(const TRect& aRect);
       
   249 
       
   250     /**
       
   251      * Notify content that its display area has changed.
       
   252      * This should only be called when the content is displayed on an
       
   253      * Item.
       
   254      *
       
   255      * @param aDisplayRect Display area in Item co-ordinates.
       
   256      * @param aScreenRect Display area in screen co-ordinates.
       
   257      * @since S60 5.0
       
   258      */
       
   259     void MdcItemContentRectChanged(
       
   260         const TRect& aContentRect, const TRect& aScreenRect);
       
   261 
       
   262     /**
       
   263      * Notify content that container is about to be destoryed.
       
   264      *
       
   265      * @since S60 5.0
       
   266      */
       
   267     void MdcContainerDestroyed();
       
   268 
       
   269     /**
       
   270      * Aborts DSA.
       
   271      *
       
   272      * @since S60 5.0
       
   273      */
       
   274     void MdcAbortDSA();
       
   275 
       
   276     /**
       
   277      * Resumes DSA.
       
   278      *
       
   279      * @since S60 5.0
       
   280      */
       
   281     void MdcResumeDSA();
       
   282 
       
   283 private: // Construtors
       
   284 
       
   285     /**
       
   286      * C++ constructor.
       
   287      */
       
   288     CMIDCanvasGraphicsItemPainter(MMIDEnv& aEnv);
       
   289 
       
   290     /**
       
   291      * Second phase constructor
       
   292      *
       
   293      * @param aParams The construction parameters of this class.
       
   294      * @since S60 5.0
       
   295      */
       
   296     void ConstructL(const TCtorParams& aParams);
       
   297 
       
   298     /**
       
   299      * Resets buffers of painter.
       
   300      *
       
   301      * @since S60 5.0
       
   302      */
       
   303     void ResetBuffers();
       
   304 
       
   305     /**
       
   306      * Creates buffers for painter.
       
   307      *
       
   308      * Creates the frame buffer with its associated device and context and the
       
   309      * offscreen buffer with its device and context. They are both of the same size,
       
   310      * the size of the content rect. The skin background is then printed on the
       
   311      * frame buffer via the frame context.
       
   312      *
       
   313      * @since S60 5.0
       
   314      */
       
   315     void CreateBuffersL();
       
   316 
       
   317     /**
       
   318      * Draws painter.
       
   319      *
       
   320      * If painter is visible, blits his frame buffer.
       
   321      *
       
   322      * @since S60 5.0
       
   323      */
       
   324     void Draw(const TRect& aRect) const;
       
   325 
       
   326 private: // Data
       
   327 
       
   328     // Canvas graphics item control. Owned.
       
   329     CMIDCanvasGraphicsItem* iItem;
       
   330 
       
   331     // Container for the direct content. Not owned.
       
   332     MDirectContainer* iDirectContainer;
       
   333 
       
   334     /**
       
   335      * Frame buffer.
       
   336      * Own.
       
   337      */
       
   338     CFbsBitmap* iFrameBuffer;
       
   339 
       
   340     /**
       
   341      * Frame bitmapped graphics context.
       
   342      * Own.
       
   343      */
       
   344     CFbsBitGc* iFrameContext;
       
   345 
       
   346     /**
       
   347      * Frame bitmap graphics device.
       
   348      * Own.
       
   349      */
       
   350     CFbsBitmapDevice* iFrameDevice;
       
   351 
       
   352     /**
       
   353      * Canvas graphics item rect
       
   354      */
       
   355     TRect iContentRect;
       
   356 
       
   357     /**
       
   358      * Canvas graphics item painter inner visibility
       
   359      */
       
   360     TBool iVisible;
       
   361 
       
   362     // A MIDlet environment.
       
   363     MMIDEnv& iEnv;
       
   364 };
       
   365 
       
   366 #endif // CMIDCANVASGRAPHICSITEMPAINTER_H
       
   367 
       
   368 // End of file