javauis/mmapi_qt/baseline/src/eswtdisplay.cpp
changeset 50 023eef975703
equal deleted inserted replaced
49:35baca0e7a2e 50:023eef975703
       
     1 /*
       
     2 * Copyright (c) 2010 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:
       
    15 *
       
    16 */
       
    17 #include "com_nokia_microedition_media_control_MMAeSWTDisplay.h"
       
    18 #include "logger.h"
       
    19 #include "qwidget.h"
       
    20 #include "cmmadcdisplay.h"
       
    21 
       
    22 JNIEXPORT void JNICALL Java_com_nokia_microedition_media_control_MMAeSWTDisplay__1setVisible
       
    23 (JNIEnv *, jobject, jint nativeDisplayHandle, jboolean isVisible)
       
    24 {
       
    25     LOG(EJavaMMAPI,EInfo,"JNI_eswtdisplay.cpp : setVisible +");
       
    26     CMMADisplay* display = reinterpret_cast<CMMADisplay*>(nativeDisplayHandle);
       
    27     TBool visible = (TBool)isVisible;
       
    28     display ->SetVisible(visible);
       
    29     LOG(EJavaMMAPI,EInfo,"JNI_eswtdisplay.cpp : setVisible -");
       
    30 }
       
    31 
       
    32 
       
    33 JNIEXPORT void JNICALL Java_com_nokia_microedition_media_control_MMAeSWTDisplay__1setContainerVisible
       
    34 (JNIEnv *, jobject, jint /*nativeDisplayHandle*/, jboolean /*isActive*/)
       
    35 {
       
    36     LOG(EJavaMMAPI,EInfo,"JNI_eswtdisplay.cpp : setContainerVisible +");
       
    37     /*        CMMADisplay* display = reinterpret_cast<CMMADisplay*>(nativeDisplayHandle);
       
    38             TBool visible = (TBool)isActive;
       
    39             display ->SetContainerVisibility(visible);*/
       
    40     LOG(EJavaMMAPI,EInfo,"JNI_eswtdisplay.cpp : setContainerVisible -");
       
    41 }
       
    42 
       
    43 JNIEXPORT void JNICALL Java_com_nokia_microedition_media_control_MMAeSWTDisplay__1setFullScreenMode
       
    44 (JNIEnv *, jobject, jint nativeDisplayHandle, jboolean isFullScreen)
       
    45 {
       
    46     LOG(EJavaMMAPI,EInfo,"JNI_eswtdisplay.cpp : setFullScreenMode  +");
       
    47     CMMADisplay* display = reinterpret_cast<CMMADisplay*>(nativeDisplayHandle);
       
    48     TBool mode = (TBool)isFullScreen;
       
    49     TRAP_IGNORE(display ->SetFullScreenL(mode));
       
    50     LOG(EJavaMMAPI,EInfo,"JNI_eswtdisplay.cpp : setFullScreenMode  -");
       
    51 }
       
    52 
       
    53 JNIEXPORT void JNICALL Java_com_nokia_microedition_media_control_MMAeSWTDisplay__1setWindowToNative
       
    54 (JNIEnv *, jobject,jint nativeDisplayHandle, jint qtWidgetHandle)
       
    55 {
       
    56     LOG(EJavaMMAPI,EInfo,"JNI_eswtdisplay.cpp : setWindowToNative + ");
       
    57     QWidget *widget = reinterpret_cast<QWidget*>(qtWidgetHandle);
       
    58     CMMADisplay* display = reinterpret_cast<CMMADisplay*>(nativeDisplayHandle);
       
    59     display->SetWindowResources(widget);
       
    60     LOG(EJavaMMAPI,EInfo,"JNI_eswtdisplay.cpp : setWindowToNative - ");
       
    61 }
       
    62 
       
    63 LOCAL_C void LocalSourceSizeChanged(CMMADisplay* display,TInt width,TInt height)
       
    64 {
       
    65     TRect temp(0,0,0,0);
       
    66     LOG2(EJavaMMAPI,EInfo,"JNI_eswtdisplay.cpp : setWindowToNative + %d %d",width,height);
       
    67     display->SourceSizeChanged(width,height,0,0,temp);
       
    68 }
       
    69 
       
    70 JNIEXPORT void JNICALL Java_com_nokia_microedition_media_control_MMAeSWTDisplay__1setNativeWindowSize
       
    71 (JNIEnv *, jobject,jint nativeDisplayHandle, jint /*aEventSourceHandle*/, jint eswtControlwidth,jint eswtControlheight)
       
    72 {
       
    73     LOG(EJavaMMAPI,EInfo,"JNI_eswtdisplay.cpp : setNativeWindowSize + ");
       
    74     CMMADisplay* display = reinterpret_cast<CMMADisplay*>(nativeDisplayHandle);
       
    75     TInt width = eswtControlwidth;
       
    76     TInt height = eswtControlheight;
       
    77     // TSize srcsize = TSize(360,487);
       
    78     // TO-DO remove JavaUnhand in final code
       
    79     //MMAFunctionServer* eventSource =  reinterpret_cast<MMAFunctionServer *>(aEventSourceHandle);
       
    80     // need to call in Function server thread context because CMMADisplay's JNI pointer
       
    81     // is valid in that thread context only.
       
    82     /*TInt error = eventSource->ExecuteTrap(&LocalSourceSizeChanged,
       
    83                                                           display,
       
    84                                                           width,
       
    85                                                           height);*/
       
    86     LocalSourceSizeChanged(display, width, height);
       
    87 
       
    88     LOG(EJavaMMAPI,EInfo,"JNI_eswtdisplay.cpp : setNativeWindowSize - ");
       
    89 }
       
    90 
       
    91 /*
       
    92 LOCAL_C void LocalSetDisplayPosition(CMMADisplay* display,TInt uiX,TInt uiY,TInt vcX,TInt vcY)
       
    93 {
       
    94     display->SetDisplayPosition(uiX,uiY,vcX,vcY);
       
    95 }
       
    96 */
       
    97 JNIEXPORT void JNICALL Java_com_nokia_microedition_media_control_MMAeSWTDisplay__1setPosition
       
    98 (JNIEnv *, jobject,jint /*nativeDisplayHandle*/,jint /*aEventSourceHandle*/,jint /*uiX*/,jint /*uiY*/,jint /*vcX*/,jint /*vcY*/)
       
    99 {
       
   100     /*  LOG(EJavaMMAPI,EInfo,"JNI_canvasdisplay.cpp : _setPosition + ");
       
   101       CMMADisplay* display = reinterpret_cast<CMMADisplay*>(nativeDisplayHandle);
       
   102       TInt uiControlLocationX = uiX;
       
   103       TInt uiControlLocationY = uiY;
       
   104       TInt videoControlLocationX = vcX;
       
   105       TInt videoControlLocationY = vcY;
       
   106       MMAFunctionServer* eventSource =  reinterpret_cast<MMAFunctionServer *>(aEventSourceHandle);
       
   107       // need to call in Function server thread context because CMMADisplay's JNI pointer
       
   108       // is valid in that thread context only.
       
   109       TInt error = eventSource->ExecuteTrap(&LocalSetDisplayPosition,
       
   110                                                                display,
       
   111                                                                      uiControlLocationX,
       
   112                                                                              uiControlLocationY,
       
   113                                                                                      videoControlLocationX,
       
   114                                                                                              videoControlLocationY);
       
   115 
       
   116       LOG(EJavaMMAPI,EInfo,"JNI_canvasdisplay.cpp : _setPosition - ");*/
       
   117 }
       
   118 
       
   119 
       
   120 
       
   121 
       
   122 LOCAL_C void LocalSetDisplaySize(CMMADisplay* display,TInt vcX,TInt vcY)
       
   123 {
       
   124     LOG2(EJavaMMAPI,EInfo,"JNI_canvasdisplay.cpp : LocalSetDisplaySize vcX = %d,vcY=%d ",vcX,vcY);
       
   125     TSize size(vcX,vcY);
       
   126     TRAP_IGNORE(display->SetDisplaySizeL(size));
       
   127 }
       
   128 
       
   129 JNIEXPORT void JNICALL Java_com_nokia_microedition_media_control_MMAeSWTDisplay__1setDisplaySize
       
   130 (JNIEnv *, jobject,jint nativeDisplayHandle,jint /*aEventSourceHandle*/,jint width,jint height)
       
   131 {
       
   132     LOG2(EJavaMMAPI,EInfo,"JNI_eswtDisplay.cpp : _setDisplaySize +  width = %d,height = %d",width,height);
       
   133     CMMADisplay* display = reinterpret_cast<CMMADisplay*>(nativeDisplayHandle);
       
   134     TInt vc_width = width;
       
   135     TInt vc_height = height;
       
   136     //MMAFunctionServer* eventSource =  reinterpret_cast<MMAFunctionServer *>(aEventSourceHandle);
       
   137     // need to call in Function server thread context because CMMADisplay's JNI pointer
       
   138     // is valid in that thread context only.
       
   139     LOG2(EJavaMMAPI,EInfo,"JNI_eswtdisplay.cpp : _setDisplaySize +  vc_width = %d,vc_height = %d",vc_width,vc_height);
       
   140     /*TInt error = eventSource->ExecuteTrap(&LocalSetDisplaySize,
       
   141                                                              display,
       
   142                                                                    vc_width,
       
   143                                                                            vc_height);
       
   144     */
       
   145     LocalSetDisplaySize(display, vc_width, vc_height);
       
   146     LOG(EJavaMMAPI,EInfo,"JNI_ESWTDisplay.cpp : _setDisplaySize - ");
       
   147 }