javauis/lcdui_akn/javalcdui/src/CMIDToLcduiObserver.cpp
branchRCL_3
changeset 24 6c158198356e
parent 14 04becd199f91
equal deleted inserted replaced
23:e5618cc85d74 24:6c158198356e
    73 // Allows a control to be used during event processing.
    73 // Allows a control to be used during event processing.
    74 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
    75 //
    75 //
    76 #ifdef RD_JAVA_NGA_ENABLED
    76 #ifdef RD_JAVA_NGA_ENABLED
    77 void CMIDToLcduiObserver::RegisterControl(
    77 void CMIDToLcduiObserver::RegisterControl(
    78     CCoeControl& aControl, MDirectContainer* aCallbackContainer /*= NULL*/)
    78     CCoeControl& aControl, MDirectContainer* /*aCallbackContainer*/)
    79 #else
    79 #else
    80 void CMIDToLcduiObserver::RegisterControl(CCoeControl& aControl)
    80 void CMIDToLcduiObserver::RegisterControl(CCoeControl& aControl)
    81 #endif
    81 #endif
    82 {
    82 {
    83     TInt index = iRegisteredControls.Find(&aControl);
    83     TInt index = iRegisteredControls.Find(&aControl);
    88         if (iRegisteredControls.Append(&aControl) != KErrNone)
    88         if (iRegisteredControls.Append(&aControl) != KErrNone)
    89         {
    89         {
    90             // Appending of control failed
    90             // Appending of control failed
    91             DEBUG("CMIDToLcduiObserver::RegisterControl - Append failed");
    91             DEBUG("CMIDToLcduiObserver::RegisterControl - Append failed");
    92         }
    92         }
    93 
       
    94 #ifdef RD_JAVA_NGA_ENABLED
       
    95         if (aCallbackContainer)
       
    96         {
       
    97             TToLcduiEventData data;
       
    98             data.iType = ENotifyContentAdded;
       
    99             data.iContainer = aCallbackContainer;
       
   100             data.iControl = &aControl;
       
   101             data.iConsumer = NULL;
       
   102             iEventQueue.Send(data);
       
   103         }
       
   104 #endif
       
   105     }
    93     }
   106 }
    94 }
   107 
    95 
   108 
    96 
   109 // ---------------------------------------------------------------------------
    97 // ---------------------------------------------------------------------------
   162 
   150 
   163     // Prepare event data
   151     // Prepare event data
   164     TToLcduiEventData data;
   152     TToLcduiEventData data;
   165     data.iType = EDSAResourcesCallbackEvent;
   153     data.iType = EDSAResourcesCallbackEvent;
   166     data.iControl = &aControl;
   154     data.iControl = &aControl;
   167     data.iConsumer = &aConsumer;
   155     data.iConsumer = (void*)&aConsumer;
   168 
   156 
   169     // Add event to the queue
   157     // Add event to the queue
   170     iEventQueue.Send(data);
   158     iEventQueue.Send(data);
   171 }
   159 }
   172 
   160 
   185     // Can run in non lcdui thread
   173     // Can run in non lcdui thread
   186 
   174 
   187     // Prepare event data
   175     // Prepare event data
   188     TToLcduiEventData data;
   176     TToLcduiEventData data;
   189     data.iType = EUICallbackEvent;
   177     data.iType = EUICallbackEvent;
   190     data.iConsumer = &aConsumer;
   178     data.iConsumer = (void*)&aConsumer;
   191     data.iId = aCallbackId;
   179     data.iId = aCallbackId;
   192 
   180 
   193     // Add event to the queue
   181     // Add event to the queue
   194     iEventQueue.Send(data);
   182     iEventQueue.Send(data);
   195 }
   183 }
   213     {
   201     {
   214     case EFlushEvent:
   202     case EFlushEvent:
   215         DoFlushControl(data.iControl, data.iRect);
   203         DoFlushControl(data.iControl, data.iRect);
   216         break;
   204         break;
   217     case EDSAResourcesCallbackEvent:
   205     case EDSAResourcesCallbackEvent:
   218         DoInvokeDSAResourcesCallback(data.iControl, data.iConsumer);
   206         DoInvokeDSAResourcesCallback(data.iControl, (MUiEventConsumer*)data.iConsumer);
   219         break;
   207         break;
   220     case EUICallbackEvent:
   208     case EUICallbackEvent:
   221         DoInvokeUICallback(data.iConsumer, data.iId);
   209         DoInvokeUICallback((MUiEventConsumer*)data.iConsumer, data.iId);
       
   210         break;
       
   211     case ELcduiEvent:
       
   212         DoInvokeLcduiEvent((MMIDLcduiEventConsumer*)data.iConsumer,data.iId);
   222         break;
   213         break;
   223 #ifdef RD_JAVA_NGA_ENABLED
   214 #ifdef RD_JAVA_NGA_ENABLED
   224     case ENotifyContentAdded:
   215     case ENotifyContentAdded:
   225         DoInvokeNotifyContentAdded(data.iControl, data.iContainer);
   216         DoInvokeNotifyContentAdded(data.iControl, data.iContainer);
   226         break;
   217         break;
   284 
   275 
   285         aConsumer->MdcDSAResourcesCallback(session, *device, *window);
   276         aConsumer->MdcDSAResourcesCallback(session, *device, *window);
   286     }
   277     }
   287 }
   278 }
   288 
   279 
       
   280 void CMIDToLcduiObserver::DoInvokeLcduiEvent(
       
   281     MMIDLcduiEventConsumer* aConsumer,
       
   282     TInt aCallbackId)
       
   283 {
       
   284     if (aConsumer)
       
   285     {
       
   286         aConsumer->HandleLcduiEvent(aCallbackId);
       
   287     }
       
   288 }
   289 
   289 
   290 // ---------------------------------------------------------------------------
   290 // ---------------------------------------------------------------------------
   291 // CMIDToLcduiObserver::DoInvokeUICallback
   291 // CMIDToLcduiObserver::DoInvokeUICallback
   292 // Processes the event invoked by InvokeUICallback.
   292 // Processes the event invoked by InvokeUICallback.
   293 // ---------------------------------------------------------------------------
   293 // ---------------------------------------------------------------------------
   297     TInt aCallbackId)
   297     TInt aCallbackId)
   298 {
   298 {
   299     aConsumer->MdcUICallback(aCallbackId);
   299     aConsumer->MdcUICallback(aCallbackId);
   300 }
   300 }
   301 
   301 
       
   302 
   302 #ifdef RD_JAVA_NGA_ENABLED
   303 #ifdef RD_JAVA_NGA_ENABLED
   303 // ---------------------------------------------------------------------------
   304 // ---------------------------------------------------------------------------
   304 // CMIDToLcduiObserver::DoInvokeNotifyContentAdded
   305 // CMIDToLcduiObserver::DoInvokeNotifyContentAdded
   305 // ---------------------------------------------------------------------------
   306 // ---------------------------------------------------------------------------
   306 void CMIDToLcduiObserver::DoInvokeNotifyContentAdded(
   307 void CMIDToLcduiObserver::DoInvokeNotifyContentAdded(
   312     {
   313     {
   313         aContainer->MdcNotifyContentAdded();
   314         aContainer->MdcNotifyContentAdded();
   314     }
   315     }
   315 }
   316 }
   316 #endif
   317 #endif
       
   318 
       
   319 // ---------------------------------------------------------------------------
       
   320 // CSwtDcObserver::InvokeDcEvent
       
   321 // Asynchronously sends an event into a consumer.
       
   322 // The call may origin in other than eswt thread.
       
   323 // ---------------------------------------------------------------------------
       
   324 //
       
   325 void CMIDToLcduiObserver::InvokeLcduiEvent(
       
   326     MMIDLcduiEventConsumer& aConsumer,
       
   327     TInt aCallbackId)
       
   328 {
       
   329     // Can run in non lcdui thread
       
   330 
       
   331     // Prepare event data
       
   332     TToLcduiEventData data;
       
   333     data.iType = ELcduiEvent;
       
   334     data.iConsumer = (void*)&aConsumer;
       
   335     data.iId = aCallbackId;
       
   336 
       
   337     // Add event to the queue
       
   338     iEventQueue.Send(data);
       
   339 }
       
   340