javauis/lcdui_akn/javalcdui/src/Item.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 1999-2001 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 
       
    18 
       
    19 
       
    20 #include "CMIDToolkit.h"
       
    21 #include "MIDUtils.h"
       
    22 #include "javax_microedition_lcdui_Item.h"
       
    23 
       
    24 /*
       
    25  * Server-side methods
       
    26  */
       
    27 LOCAL_C void SetLabelL(jint aItem,const TDesC* aLabel)
       
    28 {
       
    29     MIDUnhand<MMIDItem>(aItem)->SetLabelL(*aLabel);
       
    30 }
       
    31 
       
    32 LOCAL_C void SetLayoutL(jint aItem,MMIDItem::TLayout aLayout)
       
    33 {
       
    34     MIDUnhand<MMIDItem>(aItem)->SetLayoutL(aLayout);
       
    35 }
       
    36 
       
    37 LOCAL_C void MinimumSize(jint aItem,TSize* aSize)
       
    38 {
       
    39     *aSize = MIDUnhand<MMIDItem>(aItem)->MinimumSize();
       
    40 }
       
    41 
       
    42 LOCAL_C void PreferredSize(jint aItem,TSize* aSize)
       
    43 {
       
    44     *aSize = MIDUnhand<MMIDItem>(aItem)->PreferredSize();
       
    45 }
       
    46 
       
    47 LOCAL_C void SetPreferredSizeL(jint aItem, TInt aWidth, TInt aHeight)
       
    48 {
       
    49     TSize size(aWidth,aHeight);
       
    50     MIDUnhand<MMIDItem>(aItem)->SetPreferredSizeL(size);
       
    51 }
       
    52 
       
    53 LOCAL_C void AddCommandL(jint aItem, jint aCommand)
       
    54 {
       
    55     MIDUnhand<MMIDItem>(aItem)->AddCommandL(MIDUnhand<MMIDCommand>(aCommand));
       
    56 }
       
    57 
       
    58 LOCAL_C void RemoveCommand(jint aItem, jint aCommand)
       
    59 {
       
    60     MIDUnhand<MMIDItem>(aItem)->RemoveCommand(MIDUnhand<MMIDCommand>(aCommand));
       
    61 }
       
    62 
       
    63 LOCAL_C void SetDefaultCommand(jint aItem, jint aCommand)
       
    64 {
       
    65     MIDUnhand<MMIDItem>(aItem)->SetDefaultCommand(MIDUnhand<MMIDCommand>(aCommand));
       
    66 }
       
    67 
       
    68 //
       
    69 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Item__1setLabel
       
    70 (JNIEnv* aEnv,jobject,jint aItem,jint aToolkit,jstring aLabel)
       
    71 {
       
    72     CMIDToolkit* toolkit = JavaUnhand<CMIDToolkit>(aToolkit);
       
    73     RJString label(*aEnv,aLabel);
       
    74     return toolkit->ExecuteTrap(&SetLabelL, aItem, (const TDesC*)&label);
       
    75 }
       
    76 
       
    77 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Item__1setLayout(JNIEnv*,jobject,jint aItem,jint aToolkit,jint aLayout)
       
    78 {
       
    79     return JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteTrap(&SetLayoutL, aItem, (MMIDItem::TLayout)aLayout);
       
    80 }
       
    81 
       
    82 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Item__1getMinimumSizeWidth(JNIEnv*,jobject,jint aItem,jint aToolkit)
       
    83 {
       
    84     TSize size;
       
    85     JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteV(&MinimumSize, aItem, &size);
       
    86     return size.iWidth;
       
    87 }
       
    88 
       
    89 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Item__1getMinimumSizeHeight(JNIEnv*,jobject,jint aItem,jint aToolkit)
       
    90 {
       
    91     TSize size;
       
    92     JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteV(&MinimumSize, aItem, &size);
       
    93     return size.iHeight;
       
    94 }
       
    95 
       
    96 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Item__1getPreferredSizeWidth(JNIEnv*, jobject, jint aItem, jint aToolkit)
       
    97 {
       
    98     TSize size;
       
    99     JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteV(&PreferredSize, aItem, &size);
       
   100     return size.iWidth;
       
   101 }
       
   102 
       
   103 
       
   104 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Item__1getPreferredSizeHeight(JNIEnv*, jobject, jint aItem, jint aToolkit)
       
   105 {
       
   106     TSize size;
       
   107     JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteV(&PreferredSize, aItem, &size);
       
   108     return size.iHeight;
       
   109 }
       
   110 
       
   111 
       
   112 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Item__1setPreferredSize
       
   113 (JNIEnv*,jobject,jint aItem,jint aToolkit,jint aWidth,jint aHeight)
       
   114 {
       
   115     return JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteTrap(&SetPreferredSizeL, aItem, aWidth, aHeight);
       
   116 }
       
   117 
       
   118 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Item__1addCommand
       
   119 (JNIEnv*,jobject,jint aItem,jint aToolkit,jint aCommand)
       
   120 {
       
   121     return JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteTrap(&AddCommandL, aItem, aCommand);
       
   122 }
       
   123 
       
   124 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Item__1removeCommand
       
   125 (JNIEnv*,jobject,jint aItem,jint aToolkit,jint aCommand)
       
   126 {
       
   127     return JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteTrap(&RemoveCommand, aItem, aCommand);
       
   128 }
       
   129 
       
   130 JNIEXPORT void JNICALL Java_javax_microedition_lcdui_Item__1setDefaultCommand
       
   131 (JNIEnv*,jobject,jint aItem,jint aToolkit,jint aCommand)
       
   132 {
       
   133     JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteV(&SetDefaultCommand, aItem, aCommand);
       
   134 }