javauis/lcdui_akn/javalcdui/inc/CMIDToLcduiObserver.h
branchRCL_3
changeset 19 04becd199f91
child 60 6c158198356e
equal deleted inserted replaced
16:f5050f1da672 19: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:  Provides a way to invoke some functionality
       
    15 *                which can run in LCDUI ES thread only
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CMIDTOLCDUIOBSERVER_H
       
    21 #define CMIDTOLCDUIOBSERVER_H
       
    22 
       
    23 // Using RPointerArray
       
    24 #include <e32std.h>
       
    25 // Using RMsgQueue
       
    26 #include <e32msgqueue.h>
       
    27 
       
    28 #include "lcdui.h"
       
    29 
       
    30 // Forward declarations
       
    31 class MUiEventConsumer;
       
    32 class CCoeControl;
       
    33 
       
    34 /**
       
    35  * Provides a way to make calls to functions which are able
       
    36  * to run in LCDUI Event Server thread only and
       
    37  * which may origin in non-lcdui thread (MMAPI for instance).
       
    38  *
       
    39  * The calls are kept in queue and processed serially.
       
    40  *
       
    41  * If the call works with some CCoeControl instance,
       
    42  * ther control must be registered by RegisterControl().
       
    43  *
       
    44  * Some events may invoke a callback into specified callback interface.
       
    45  * The receiver of this callback must not be deleted if there is
       
    46  * a possibility of having some events, which will call this, in queue.
       
    47  *
       
    48  * The callback receiver can for example implement
       
    49  * its instance deletion via event using this observer,
       
    50  * so this deletion event will be the last one for that receiver.
       
    51  *
       
    52  * @lib    lcdui.dll
       
    53  * @since  S60 v5.0
       
    54  */
       
    55 class CMIDToLcduiObserver : public CActive, public MMIDToLcduiObserver
       
    56 {
       
    57 public:
       
    58     /**
       
    59      * Constructor.
       
    60      */
       
    61     CMIDToLcduiObserver();
       
    62 
       
    63     /**
       
    64      * Destructor.
       
    65      */
       
    66     ~CMIDToLcduiObserver();
       
    67 
       
    68 // from base MMIDToLcduiObserver
       
    69 
       
    70     /**
       
    71      * From MMIDToLcduiObserver.
       
    72      * Allows a control to be used during event processing.
       
    73      *
       
    74      * @since S60 5.0
       
    75      * @param aControl Control to be registered.
       
    76      * @param aCallbackContainer MDirectContainer that is nofied in LCDUI thread
       
    77      *                           about added MDirectContent. NULL, if notification
       
    78      *                           is not needed.
       
    79      */
       
    80 #ifdef RD_JAVA_NGA_ENABLED
       
    81     virtual void RegisterControl(CCoeControl& aControl,
       
    82                                  MDirectContainer* aCallbackContainer = NULL);
       
    83 #else
       
    84     virtual void RegisterControl(CCoeControl& aControl);
       
    85 #endif
       
    86 
       
    87     /**
       
    88      * From MMIDToLcduiObserver.
       
    89      * Removes a control from the list of controls allowed
       
    90      * to be used in event processing.
       
    91      * Events which works with this control will be ignored.
       
    92      *
       
    93      * @since S60 5.0
       
    94      * @param aControl Control to be unregistered.
       
    95      */
       
    96     virtual void UnregisterControl(CCoeControl& aControl);
       
    97 
       
    98     /**
       
    99      * From MMIDToLcduiObserver.
       
   100      * Flushes the control's graphics content on screen.
       
   101      * The call may origin in other than LCDUI ES thread.
       
   102      *
       
   103      * @since S60 5.0
       
   104      * @param aControl Control used to get DSA resources from.
       
   105      * @param aRect An area of the control to flush.
       
   106      */
       
   107     virtual void FlushControl(CCoeControl& aControl, const TRect &aRect);
       
   108 
       
   109     /**
       
   110      * From MMIDToLcduiObserver.
       
   111      * Invokes aConsumer->MdcDSAResourcesCallback from LCDUI ES thread.
       
   112      * The call may origin in other than LCDUI ES thread.
       
   113      *
       
   114      * @since S60 5.0
       
   115      * @param aControl Control used to get DSA resources from.
       
   116      * @param aConsumer Consumer of the callback.  The instance
       
   117      *                  must not be deleted before the event processed.
       
   118      */
       
   119     void InvokeDSAResourcesCallback(
       
   120         CCoeControl& aControl,
       
   121         MUiEventConsumer& aConsumer);
       
   122 
       
   123     /**
       
   124      * From MMIDToLcduiObserver.
       
   125      * Invokes aConsumer->MdcUICallback( aCallbackId ) from LCDUI ES thread.
       
   126      * The call may origin in other than LCDUI ES thread.
       
   127      *
       
   128      * @since S60 5.0
       
   129      * @param aConsumer Consumer of the callback.
       
   130      * @param aCallbackId Id which is provided to the callback
       
   131      */
       
   132     void InvokeUICallback(MUiEventConsumer& aConsumer, TInt aCallbackId);
       
   133 
       
   134 private:
       
   135     /** CMIDToLcduiObserver event datatype */
       
   136     enum TToLcduiEventType
       
   137     {
       
   138         EFlushEvent,
       
   139         EDSAResourcesCallbackEvent,
       
   140         EUICallbackEvent
       
   141 #ifdef RD_JAVA_NGA_ENABLED
       
   142         ,ENotifyContentAdded
       
   143 #endif
       
   144     };
       
   145 
       
   146     /** CMIDToLcduiObserver event content datatype */
       
   147     struct TToLcduiEventData
       
   148     {
       
   149         TToLcduiEventType iType;
       
   150         CCoeControl* iControl;
       
   151         TRect iRect;
       
   152         MUiEventConsumer* iConsumer;
       
   153         TInt iId;
       
   154 #ifdef RD_JAVA_NGA_ENABLED
       
   155         MDirectContainer* iContainer;
       
   156 #endif
       
   157     };
       
   158 
       
   159     /**
       
   160      * Redraws area on component.
       
   161      *
       
   162      * @since S60 5.0
       
   163      * @param aControl Control to redraw.
       
   164      *                 Must be registered by RegisterControl.
       
   165      * @param aRect Area to redraw.
       
   166      */
       
   167     void DoFlushControl(CCoeControl* aControl, const TRect& aRect);
       
   168 
       
   169     /**
       
   170      * Invokes callback aConsumer->MdcDSAResourcesCallback.
       
   171      *
       
   172      * @since S60 5.0
       
   173      * @param aControl Control used to get DSA resources from.
       
   174      *                 Must be registered by RegisterControl.
       
   175      * @param aConsumer Consumer of the callback.
       
   176      */
       
   177     void DoInvokeDSAResourcesCallback(
       
   178         CCoeControl* aControl,
       
   179         MUiEventConsumer *aConsumer);
       
   180 
       
   181     /**
       
   182      * Invokes callback aConsumer->MdcUICallback.
       
   183      *
       
   184      * @since S60 5.0
       
   185      * @param aConsumer Consumer of the callback.
       
   186      * @param aCallbackId Id which is provided to the callback
       
   187      */
       
   188     void DoInvokeUICallback(
       
   189         MUiEventConsumer *aConsumer,
       
   190         TInt aCallbackId);
       
   191 
       
   192 
       
   193 #ifdef RD_JAVA_NGA_ENABLED
       
   194     /**
       
   195      * Invokes MDirectContainer::MdcNotifyContentAdded in UI thread.
       
   196      *
       
   197      * @since S60 9.2
       
   198      * @param aControl CCoeControl pointer needed for checking that registered
       
   199      *                 control has not unregistered yet.
       
   200      * @param aContainer The container to be notifed.
       
   201      */
       
   202     void DoInvokeNotifyContentAdded(
       
   203         CCoeControl* aControl,
       
   204         MDirectContainer *aContainer);
       
   205 #endif
       
   206 
       
   207 // from base class CActive
       
   208 
       
   209     /**
       
   210      * From CActive.
       
   211      * Handles an active object’s request completion event.
       
   212      * Processes the first available event in queue.
       
   213      *
       
   214      * @since S60 5.0
       
   215      */
       
   216     virtual void RunL();
       
   217 
       
   218     /**
       
   219      * From CActive.
       
   220      * Implements cancellation of an outstanding request.
       
   221      *
       
   222      * @since S60 5.0
       
   223      */
       
   224     virtual void DoCancel();
       
   225 
       
   226 private:
       
   227     /**
       
   228      * Event queue to store the call requests
       
   229      * Own.
       
   230      */
       
   231     RMsgQueue<TToLcduiEventData> iEventQueue;
       
   232 
       
   233     /**
       
   234      * List of controls registered to allowed its usage
       
   235      * during event processing.
       
   236      * Controls are not owned.
       
   237      * Own.
       
   238      */
       
   239     RPointerArray<CCoeControl> iRegisteredControls;
       
   240 };
       
   241 
       
   242 
       
   243 #endif // CMIDTOLCDUIOBSERVER_H