javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/org_eclipse_swt_internal_symbian_OS.cpp
branchRCL_3
changeset 66 2455ef1f5bbc
child 83 26b2b12093af
equal deleted inserted replaced
65:ae942d28ec0e 66:2455ef1f5bbc
       
     1 /*******************************************************************************
       
     2  * Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved. This program and the accompanying materials
       
     4  * are made available under the terms of the Eclipse Public License v1.0
       
     5  * which accompanies this distribution, and is available at
       
     6  * http://www.eclipse.org/legal/epl-v10.html
       
     7  *
       
     8  * Contributors:
       
     9  *     Nokia Corporation - S60 implementation
       
    10  *******************************************************************************/
       
    11 
       
    12 
       
    13 #include <gulutil.h>
       
    14 #include "org_eclipse_swt_internal_symbian_OS.h"
       
    15 #include "eswtwidgetscore.h"
       
    16 #include "swtimagedata.h"
       
    17 #include "templatehelpers.h"
       
    18 #include "utils.h"
       
    19 #include "swtimagedataloader.h"
       
    20 #include "swtdialogbroker.h"
       
    21 
       
    22 
       
    23 // ======== LOCAL FUNCTIONS ========
       
    24 
       
    25 
       
    26 template<class C>
       
    27 static jint NewCoreWidget(JNIEnv* aJniEnv,
       
    28                           C*(MSwtFactory::*aMethodL)(MSwtDisplay&, TSwtPeer, MSwtComposite&, TInt) const,
       
    29                           jobject aPeer,
       
    30                           jint aParent,
       
    31                           jint aStyle)
       
    32 {
       
    33     CSwtDisplay& display = CSwtDisplay::Current();
       
    34     const MSwtFactory& factory = display.Factory();
       
    35     return NewWidget(aJniEnv, &factory, aMethodL, display, aPeer, aParent, aStyle);
       
    36 }
       
    37 
       
    38 
       
    39 extern "C"
       
    40 {
       
    41 
       
    42     /*
       
    43      *  Class Device
       
    44      */
       
    45     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Device_1GetBounds(JNIEnv* aJniEnv, jclass, jint aHandle)
       
    46     {
       
    47         ASSERT(aHandle!=0);
       
    48         const MSwtDevice* device = reinterpret_cast<MSwtDevice*>(aHandle);
       
    49         TRect       bounds(TRect::EUninitialized);
       
    50         CallMethod(bounds, device, &MSwtDevice::Bounds);
       
    51         return NewJavaRectangle(aJniEnv, bounds);
       
    52     }
       
    53 
       
    54     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Device_1GetClientArea(JNIEnv* aJniEnv, jclass, jint aHandle)
       
    55     {
       
    56         ASSERT(aHandle!=0);
       
    57         const MSwtDevice* device = reinterpret_cast<MSwtDevice*>(aHandle);
       
    58         TRect       clientArea(TRect::EUninitialized);
       
    59         CallMethod(clientArea, device, &MSwtDevice::ClientArea);
       
    60         return NewJavaRectangle(aJniEnv, clientArea);
       
    61     }
       
    62 
       
    63     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Device_1GetDepth(JNIEnv* , jclass, jint aHandle)
       
    64     {
       
    65         ASSERT(aHandle!=0);
       
    66         const MSwtDevice* device = reinterpret_cast<MSwtDevice*>(aHandle);
       
    67         TInt        depth;
       
    68         CallMethod(depth, device, &MSwtDevice::Depth);
       
    69         return depth;
       
    70     }
       
    71 
       
    72     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Device_1GetDPI(JNIEnv* aJniEnv, jclass, jint aHandle)
       
    73     {
       
    74         ASSERT(aHandle!=0);
       
    75         const MSwtDevice* device = reinterpret_cast<MSwtDevice*>(aHandle);
       
    76         TSize       dpi(TSize::EUninitialized);
       
    77         CallMethod(dpi, device, &MSwtDevice::Dpi);
       
    78         return NewJavaPoint(aJniEnv, TPoint(dpi.iWidth, dpi.iHeight));
       
    79     }
       
    80 
       
    81     static TInt ConvertFontStyle(const TFontStyle& aFontStyle)
       
    82     {
       
    83         TInt result = KSwtNormal;
       
    84 
       
    85         if (aFontStyle.StrokeWeight() == EStrokeWeightBold)
       
    86             result |= KSwtBold;
       
    87 
       
    88         if (aFontStyle.Posture() == EPostureItalic)
       
    89             result |= KSwtItalic;
       
    90 
       
    91         return result;
       
    92     }
       
    93 
       
    94     static jobjectArray Device_GetFontListL(JNIEnv* aJniEnv, const MSwtDevice* aDevice, jstring aFaceName, TBool aScalable)
       
    95     {
       
    96         HBufC* faceName = ConvertStringLC(aJniEnv, aFaceName);
       
    97         TDesC& nameDesc = const_cast<TDesC&>((faceName!=NULL) ? static_cast<const TDesC&>(*faceName) : KNullDesC());
       
    98         CArrayFixFlat<TSwtFontData>* fontDataArray = NULL;
       
    99         CallMethodL(fontDataArray, aDevice, &MSwtDevice::GetFontListL, nameDesc, aScalable);
       
   100         if (faceName!=NULL)
       
   101             CleanupStack::PopAndDestroy(faceName);
       
   102 
       
   103         // Construct the array of Java Fontdata
       
   104         jobjectArray javaFontDataArray = NULL;
       
   105         TInt nbFontData = fontDataArray->Count();
       
   106         if (nbFontData > 0)
       
   107         {
       
   108             jclass fontDataClass = aJniEnv->FindClass("org/eclipse/swt/graphics/FontData");
       
   109             if (fontDataClass != NULL)
       
   110             {
       
   111                 javaFontDataArray = aJniEnv->NewObjectArray(nbFontData, fontDataClass, NULL);
       
   112                 if (javaFontDataArray != NULL)
       
   113                 {
       
   114                     jmethodID constructId = aJniEnv->GetMethodID(fontDataClass, "<init>", "(Ljava/lang/String;II)V");
       
   115                     if (constructId != NULL)
       
   116                     {
       
   117                         for (TInt i=0; i<nbFontData; ++i)
       
   118                         {
       
   119                             // Construct a Java Fontdata object
       
   120                             const TFontSpec& fontSpec = (*fontDataArray)[i].iFontSpec;
       
   121                             jstring fontDataName   = NewJavaString(aJniEnv, fontSpec.iTypeface.iName);
       
   122                             jint    heightInPoints = FontUtils::PointsFromTwips(fontSpec.iHeight);
       
   123                             jint    style          = ConvertFontStyle(fontSpec.iFontStyle);
       
   124                             jobject fontDataObj    = aJniEnv->NewObject(fontDataClass, constructId, fontDataName, heightInPoints, style);
       
   125                             aJniEnv->DeleteLocalRef(fontDataName);
       
   126 
       
   127                             // Append to font data array
       
   128                             aJniEnv->SetObjectArrayElement(javaFontDataArray, i, fontDataObj); //lint !e613
       
   129                             aJniEnv->DeleteLocalRef(fontDataObj);
       
   130                         }
       
   131                     }
       
   132                 }
       
   133                 aJniEnv->DeleteLocalRef(fontDataClass);
       
   134             }
       
   135         }
       
   136 
       
   137         DeleteInUiHeap(fontDataArray);
       
   138 
       
   139         return javaFontDataArray;
       
   140     }
       
   141 
       
   142     JNIEXPORT jobjectArray JNICALL Java_org_eclipse_swt_internal_symbian_OS_Device_1GetFontList(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aFaceName, jboolean aScalable)
       
   143     {
       
   144         ASSERT(aHandle!=0);
       
   145         const MSwtDevice* device = reinterpret_cast<MSwtDevice*>(aHandle);
       
   146         jobjectArray      result = NULL;
       
   147         TRAPD(error, (result=Device_GetFontListL(aJniEnv, device, aFaceName, aScalable)));
       
   148         ThrowIfError(error, aJniEnv);
       
   149         return result;
       
   150     }
       
   151 
       
   152     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Device_1GetSystemColor(JNIEnv* aJniEnv, jclass, jint aHandle, jint aId)
       
   153     {
       
   154         ASSERT(aHandle!=0);
       
   155         const MSwtDevice* device = reinterpret_cast<MSwtDevice*>(aHandle);
       
   156         TSwtColorId colorId(static_cast<TSwtColorId>(aId));
       
   157         TRgb rgb;
       
   158         CallMethod(rgb, device, &MSwtDevice::GetSystemColor, colorId);
       
   159         return NewJavaRgb(aJniEnv, rgb);
       
   160     }
       
   161 
       
   162     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Device_1GetSystemFont(JNIEnv*, jclass, jint aHandle)
       
   163     {
       
   164         CSwtDisplay* display = DisplayFromDevice(aHandle);
       
   165         const MSwtDevice* device = reinterpret_cast<MSwtDevice*>(aHandle);
       
   166         const MSwtFont* font;
       
   167         CallMethod(font, device, &MSwtDevice::GetSystemFont, display);
       
   168         ASSERT(font!=NULL);
       
   169         return reinterpret_cast<jint>(font);
       
   170     }
       
   171 
       
   172 
       
   173     /*
       
   174      * Class Display
       
   175      */
       
   176     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1New(JNIEnv* aJniEnv, jclass, jobject aPeer, jint aDisplayParameter)
       
   177     {
       
   178         CSwtDisplay* display = NULL;
       
   179         TRAPD(error, (display=CSwtDisplay::NewL(*aJniEnv, aPeer, aDisplayParameter)));
       
   180         ThrowIfError(error, aJniEnv);
       
   181         return reinterpret_cast<jint>(display);
       
   182     }
       
   183 
       
   184     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1DeviceHandle(JNIEnv*, jclass, jint aHandle)
       
   185     {
       
   186         ASSERT(aHandle!=0);
       
   187         return reinterpret_cast<jint>(static_cast<MSwtDevice*>(reinterpret_cast<CSwtDisplay*>(aHandle)));
       
   188     }
       
   189 
       
   190     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1Dispose(JNIEnv* aJniEnv, jclass, jint aHandle)
       
   191     {
       
   192         ASSERT(aHandle!=0);
       
   193         if (!aHandle)
       
   194             return;
       
   195 
       
   196         CSwtDisplay* display = reinterpret_cast<CSwtDisplay*>(aHandle);
       
   197 
       
   198 #if defined(__WINS__) && defined(_DEBUG)
       
   199         display->iInstanceCounts.CheckForLeaks();
       
   200 #endif
       
   201 
       
   202         display->Dispose(*aJniEnv);
       
   203     }
       
   204 
       
   205     static void Display_SetAppNameL(JNIEnv* aJniEnv, jstring aString)
       
   206     {
       
   207         MSwtDisplay* display = CSwtDisplay::CurrentOrNull();
       
   208         if (display)
       
   209         {
       
   210             HBufC* buf = ConvertStringLC(aJniEnv, aString);
       
   211             CallMethodL(&display->UiUtils(), &MSwtUiUtils::SetAppNameL, buf);
       
   212             CallMethodL(display, &MSwtDisplay::SetNameInTaskListL, buf);
       
   213             if (buf)
       
   214             {
       
   215                 CleanupStack::PopAndDestroy(buf);
       
   216             }
       
   217         }
       
   218     }
       
   219 
       
   220     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1SetAppName(
       
   221         JNIEnv* aJniEnv, jclass, jstring aString)
       
   222     {
       
   223         TRAPD(error, Display_SetAppNameL(aJniEnv, aString));
       
   224         ThrowIfError(error, aJniEnv);
       
   225     }
       
   226 
       
   227     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1Sleep(JNIEnv*, jclass, jint aHandle)
       
   228     {
       
   229         ASSERT(aHandle!=0);
       
   230         TBool result = reinterpret_cast<CSwtDisplay*>(aHandle)->Sleep(); //lint !e613
       
   231         return ConvertBoolean(result);
       
   232     }
       
   233 
       
   234     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1Wake(JNIEnv*, jclass, jint aHandle)
       
   235     {
       
   236         ASSERT(aHandle!=0);
       
   237         reinterpret_cast<CSwtDisplay*>(aHandle)->Wake();
       
   238     }
       
   239 
       
   240     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1ReadAndDispatch(JNIEnv* aJniEnv, jclass, jint aHandle)
       
   241     {
       
   242         ASSERT(aHandle!=0);
       
   243         TBool result = reinterpret_cast<CSwtDisplay*>(aHandle)->ReadAndDispatch(*aJniEnv);
       
   244         return ConvertBoolean(result);
       
   245     }
       
   246 
       
   247     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1GetActiveShell(JNIEnv*, jclass, jint)
       
   248     {
       
   249         const MSwtUiUtils& utils = CSwtDisplay::Current().UiUtils();
       
   250         TSwtPeer peer;
       
   251         CallMethod(peer, &utils, &MSwtUiUtils::GetActiveShellPeer);
       
   252         return peer;
       
   253     }
       
   254 
       
   255     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1getDoubleClickTime(JNIEnv *, jclass, jint)
       
   256     {
       
   257         const ASwtDisplayBase& display = CSwtDisplay::Current();
       
   258         TInt result;
       
   259 
       
   260         CallMethod(result, &display, &ASwtDisplayBase::GetDoubleClickTime);
       
   261         return result;
       
   262     }
       
   263 
       
   264     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1getIconDepth(JNIEnv *, jclass, jint)
       
   265     {
       
   266         const ASwtDisplayBase& display = CSwtDisplay::Current();
       
   267         TInt result;
       
   268 
       
   269         CallMethod(result, &display, &ASwtDisplayBase::GetIconDepth);
       
   270         return result;
       
   271     }
       
   272 
       
   273     JNIEXPORT jobjectArray JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1GetShells(JNIEnv* aJniEnv, jclass, jint)
       
   274     {
       
   275         const MSwtUiUtils& utils = CSwtDisplay::Current().UiUtils();
       
   276 
       
   277         CSwtPeerArray* shells  = NULL;
       
   278         TRAPD(error, CallMethodL(shells, &utils, &MSwtUiUtils::GetShellPeersL));
       
   279         if (error)
       
   280         {
       
   281             Throw(error, aJniEnv);
       
   282             return NULL;
       
   283         }
       
   284 
       
   285         jobjectArray result = NewJavaControlArray(aJniEnv, shells);
       
   286         DeleteInUiHeap(shells);
       
   287 
       
   288         return result;
       
   289     }
       
   290 
       
   291     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1Beep(JNIEnv *, jclass, jint)
       
   292     {
       
   293         const ASwtDisplayBase& display = CSwtDisplay::Current();
       
   294         CallMethod(&display, &ASwtDisplayBase::Beep);
       
   295     }
       
   296 
       
   297     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1GetFocusControl(JNIEnv *, jclass, jint)
       
   298     {
       
   299         const MSwtUiUtils& utils = CSwtDisplay::Current().UiUtils();
       
   300         TSwtPeer peer;
       
   301 
       
   302         CallMethod(peer, &utils, &MSwtUiUtils::GetFocusControl);
       
   303         return peer;
       
   304     }
       
   305 
       
   306     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1StartTimer(JNIEnv* aJniEnv, jclass, jint, jint aDelayInMilliSeconds, jint aTimerHandle)
       
   307     {
       
   308         ASwtDisplayBase& display = CSwtDisplay::Current();
       
   309 
       
   310         TRAPD(error, CallMethodL(&display, &ASwtDisplayBase::AddTimerL, aDelayInMilliSeconds, aTimerHandle));
       
   311         ThrowIfError(error, aJniEnv);
       
   312     }
       
   313 
       
   314 
       
   315     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1Post
       
   316     (JNIEnv*, jclass, jint aEventType, jchar aEventCharacter, jint aEventKeyCode, jint aEventStateMask)
       
   317     {
       
   318         ASwtDisplayBase& display = CSwtDisplay::Current();
       
   319         TSwtKeyEventData data;
       
   320         data.iType           = static_cast<TSwtEventType>(aEventType);
       
   321         data.iCharacter      = aEventCharacter;
       
   322         data.iKeyCode        = aEventKeyCode;
       
   323         data.iStateMask      = aEventStateMask;
       
   324         TRAPD(ignore, CallMethodL(&display, &ASwtDisplayBase::PostL, data));
       
   325         return ConvertBoolean(ignore == KErrNone);
       
   326     }
       
   327 
       
   328     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1MousePost
       
   329     (JNIEnv* aJniEnv, jclass, jint aEventType, jint xPos, jint yPos, jint aEventStateMask)
       
   330     {
       
   331         ASwtDisplayBase& display = CSwtDisplay::Current();
       
   332 
       
   333         TPoint point;
       
   334         point=TPoint(xPos, yPos);
       
   335         TSwtKeyEventData data;
       
   336         data.iType           = static_cast<TSwtEventType>(aEventType);
       
   337         data.iStateMask      = aEventStateMask;
       
   338         TBool results;
       
   339         TRAPD(error, CallMethodL(results, &display, &ASwtDisplayBase::MousePostL, data, point));
       
   340         ThrowIfError(error, aJniEnv);
       
   341         return ConvertBoolean(results);
       
   342     }
       
   343 
       
   344     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1SetAppUID
       
   345     (JNIEnv* , jclass, jint aUID)
       
   346     {
       
   347         MSwtDisplay* display = CSwtDisplay::CurrentOrNull();
       
   348         if (display)
       
   349         {
       
   350             CallMethod(display, &MSwtDisplay::SetUIDInTaskList, aUID);
       
   351         }
       
   352     }
       
   353 
       
   354     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1SetAppVisible
       
   355     (JNIEnv *, jclass, jboolean aVisible)
       
   356     {
       
   357         MSwtDisplay* display = CSwtDisplay::CurrentOrNull();
       
   358         if (display)
       
   359         {
       
   360             CallMethod(display, &MSwtDisplay::SetAppVisible, aVisible);
       
   361         }
       
   362     }
       
   363 
       
   364     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1SetOptimizedPaint
       
   365     (JNIEnv *, jclass, jint aHandle, jboolean aStatus)
       
   366     {
       
   367         CSwtDisplay* display = reinterpret_cast<CSwtDisplay*>(aHandle);
       
   368         if (display)
       
   369         {
       
   370             CSwtEventQueue* queue = display->EventQueue();
       
   371             if (queue)
       
   372             {
       
   373                 CallMethod(queue, &CSwtEventQueue::SetOptimizedPaint, aStatus);
       
   374             }
       
   375         }
       
   376     }
       
   377 
       
   378     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Display_1NotifyFirstPaintComplete
       
   379     (JNIEnv *, jclass, jboolean aTopShell)
       
   380     {
       
   381         MSwtDisplay* display = CSwtDisplay::CurrentOrNull();
       
   382         if (display)
       
   383         {
       
   384             CallMethod(display, &MSwtDisplay::SetUiReady, aTopShell);
       
   385         }
       
   386     }
       
   387 
       
   388     /*
       
   389      * Class DisplayExtension
       
   390      */
       
   391     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_DisplayExtension_1getBestImageSize
       
   392     (JNIEnv* aJniEnv, jclass, jint aImageType)
       
   393     {
       
   394         MSwtUiUtils& utils = CSwtDisplay::Current().UiUtils();
       
   395         TSize       imageSize(TSize::EUninitialized);
       
   396         CallMethod(imageSize, &utils, &MSwtUiUtils::GetBestImageSize, aImageType);
       
   397         return NewJavaPoint(aJniEnv, TPoint(imageSize.iWidth, imageSize.iHeight));
       
   398     }
       
   399 
       
   400     /*
       
   401      * Class Canvas
       
   402      */
       
   403     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Canvas_1New(JNIEnv* aJniEnv, jclass, jobject aPeer, jint aParent, jint aStyle)
       
   404     {
       
   405         jint handle = NewCoreWidget(aJniEnv, &MSwtFactory::NewCanvasL, aPeer, aParent, aStyle);
       
   406         INCREASE_INSTANCE_COUNT(handle, Canvas);
       
   407         return handle;
       
   408     }
       
   409 
       
   410     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Canvas_1CompositeHandle(JNIEnv*, jclass, jint aHandle)
       
   411     {
       
   412         MSwtCanvas*    canvas = reinterpret_cast<MSwtCanvas*>(aHandle);
       
   413         MSwtComposite* result;
       
   414         CallMethod(result, canvas, &MSwtCanvas::Composite);
       
   415         return reinterpret_cast<jint>(result);
       
   416     }
       
   417 
       
   418     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Canvas_1Scroll(JNIEnv*, jclass, jint aHandle, jint aDestX, jint aDestY, jint aX, jint aY, jint aWidth, jint aHeight, jboolean aAll)
       
   419     {
       
   420         MSwtCanvas* canvas = reinterpret_cast<MSwtCanvas*>(aHandle);
       
   421         TPoint      dest(aDestX, aDestY);
       
   422         TRect       rect(TPoint(aX,aY), TSize(aWidth,aHeight));
       
   423         CallMethod(canvas, &MSwtCanvas::Scroll, dest, rect, aAll);
       
   424     }
       
   425 
       
   426 
       
   427     /*
       
   428      * Class Color
       
   429      */
       
   430     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Color_1New(JNIEnv* aJniEnv, jclass, jint aDevice, jint aRed, jint aGreen, jint aBlue)
       
   431     {
       
   432         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
   433         MSwtDevice*  device  = reinterpret_cast<MSwtDevice*>(aDevice);
       
   434         TRgb         rgb(aRed, aGreen, aBlue);
       
   435         MSwtColor*   result = NULL;
       
   436         TRAPD(error, CallMethodL(result, &(display->Factory()), &MSwtFactory::NewColorL, *device, rgb, display));
       
   437         ThrowIfError(error, aJniEnv);
       
   438 
       
   439         INCREASE_INSTANCE_COUNT_USE_DISPLAY(result, Color, display);
       
   440 
       
   441         return reinterpret_cast<jint>(result);
       
   442     }
       
   443 
       
   444     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Color_1Dispose(JNIEnv*, jclass, jint aDevice, jint aHandle)
       
   445     {
       
   446         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
   447         MSwtColor* color = reinterpret_cast<MSwtColor*>(aHandle);
       
   448         CallMethod(color, &MSwtColor::Dispose, display);
       
   449 
       
   450         DECREASE_INSTANCE_COUNT_USE_DISPLAY(Color, display);
       
   451     }
       
   452 
       
   453     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Color_1RgbValue(JNIEnv*, jclass, jint aDevice, jint aHandle)
       
   454     {
       
   455         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
   456         const MSwtColor* color = reinterpret_cast<MSwtColor*>(aHandle);
       
   457         TRgb       rgb;
       
   458         CallMethod(rgb, color, &MSwtColor::RgbValue, display);
       
   459         return rgb.Value();
       
   460     }
       
   461 
       
   462 
       
   463     /*
       
   464      * Class Composite
       
   465      */
       
   466     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Composite_1New(JNIEnv* aJniEnv, jclass, jobject aPeer, jint aParent, jint aStyle)
       
   467     {
       
   468         jint result = NewCoreWidget(aJniEnv, &MSwtFactory::NewCompositeL, aPeer, aParent, aStyle);
       
   469         INCREASE_INSTANCE_COUNT(result, Composite);
       
   470         return result;
       
   471     }
       
   472 
       
   473     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Composite_1ScrollableHandle(JNIEnv*, jclass, jint aHandle)
       
   474     {
       
   475         MSwtComposite*  composite = reinterpret_cast<MSwtComposite*>(aHandle);
       
   476         MSwtScrollable* result;
       
   477         CallMethod(result, composite, &MSwtComposite::Scrollable);
       
   478         return reinterpret_cast<jint>(result);
       
   479     }
       
   480 
       
   481     JNIEXPORT jobjectArray JNICALL Java_org_eclipse_swt_internal_symbian_OS_Composite_1GetChildren(JNIEnv* aJniEnv, jclass, jint aHandle)
       
   482     {
       
   483         MSwtComposite* composite = reinterpret_cast<MSwtComposite*>(aHandle);
       
   484         CSwtPeerArray* children  = NULL;
       
   485         TRAPD(error, CallMethodL(children, composite, &MSwtComposite::GetChildrenPeersL));
       
   486         if (error)
       
   487         {
       
   488             Throw(error, aJniEnv);
       
   489             return NULL;
       
   490         }
       
   491 
       
   492         jobjectArray result = NewJavaControlArray(aJniEnv, children);
       
   493         DeleteInUiHeap(children);
       
   494         return result;
       
   495     }
       
   496 
       
   497     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Composite_1SetTabList(JNIEnv* aJniEnv, jclass, jint aHandle, jintArray aList)
       
   498     {
       
   499         jboolean isCopy;
       
   500         TInt* intList = NULL;
       
   501         TInt  count   = 0;
       
   502         if (aList != NULL)
       
   503         {
       
   504             intList = aJniEnv->GetIntArrayElements(aList, &isCopy);
       
   505             count   = aJniEnv->GetArrayLength(aList);
       
   506         }
       
   507 
       
   508         MSwtComposite* composite = reinterpret_cast<MSwtComposite*>(aHandle);
       
   509         // This cast are safe : in JAVA side the array are fill with the handle 's control.
       
   510         MSwtControl**  ctrlList  = reinterpret_cast<MSwtControl**>(intList); //lint !e740
       
   511         TRAPD(error, CallMethodL(composite, &MSwtComposite::SetTabListL, ctrlList, count));
       
   512 
       
   513         if (intList != NULL)
       
   514             aJniEnv->ReleaseIntArrayElements(aList, intList, JNI_ABORT);
       
   515 
       
   516         ThrowIfError(error, aJniEnv);
       
   517     }
       
   518 
       
   519     JNIEXPORT jobjectArray JNICALL Java_org_eclipse_swt_internal_symbian_OS_Composite_1GetTabList(JNIEnv* aJniEnv, jclass, jint aHandle)
       
   520     {
       
   521         const MSwtComposite* composite = reinterpret_cast<MSwtComposite*>(aHandle);
       
   522         CSwtPeerArray*       tabList   = NULL;
       
   523         TRAPD(error, CallMethodL(tabList, composite, &MSwtComposite::GetTabListL));
       
   524         if (error)
       
   525         {
       
   526             Throw(error, aJniEnv);
       
   527             return NULL;
       
   528         }
       
   529 
       
   530         jobjectArray result = NewJavaControlArray(aJniEnv, tabList);
       
   531         DeleteInUiHeap(tabList);
       
   532         return result;
       
   533     }
       
   534 
       
   535     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Composite_1SetScrolledCompositeContent(JNIEnv* aJniEnv, jclass, jint aHandle, jint aContentHandle)
       
   536     {
       
   537         MSwtComposite* composite = reinterpret_cast<MSwtComposite*>(aHandle);
       
   538         MSwtControl* content = reinterpret_cast<MSwtControl*>(aContentHandle);
       
   539         TRAPD(error, CallMethodL(composite, &MSwtComposite::SetScrolledCompositeContentL, content));
       
   540         ThrowIfError(error, aJniEnv);
       
   541     }
       
   542 
       
   543     /*
       
   544      * Class Control
       
   545      */
       
   546     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1Dispose(JNIEnv* aJniEnv, jclass, jint aHandle)
       
   547     {
       
   548         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   549         TSwtPeer     peerRef;
       
   550         CallMethod(peerRef, control, &MSwtControl::Dispose);
       
   551 
       
   552         ReleasePeer(aJniEnv, peerRef);
       
   553 
       
   554 #if defined(__WINS__) && defined(_DEBUG)
       
   555         ++(CSwtDisplay::Current().iInstanceCounts.iDisposedControls);
       
   556 #endif
       
   557     }
       
   558 
       
   559     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1SetFocus(JNIEnv*, jclass, jint aHandle)
       
   560     {
       
   561         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   562         TBool        isFocused;
       
   563         CallMethod(isFocused, control, &MSwtControl::SetSwtFocus, KSwtFocusByApi);
       
   564         return ConvertBoolean(isFocused);
       
   565     }
       
   566 
       
   567     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1ForceFocus(JNIEnv*, jclass, jint aHandle)
       
   568     {
       
   569         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   570         TBool        isFocused;
       
   571         CallMethod(isFocused, control, &MSwtControl::SetSwtFocus, KSwtFocusByForce);
       
   572         return ConvertBoolean(isFocused);
       
   573     }
       
   574 
       
   575     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1GetEnabled(JNIEnv*, jclass, jint aHandle)
       
   576     {
       
   577         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   578         TBool              isEnabled;
       
   579         CallMethod(isEnabled, control, &MSwtControl::GetEnabled);
       
   580         return ConvertBoolean(isEnabled);
       
   581     }
       
   582 
       
   583     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1GetVisible(JNIEnv*, jclass, jint aDevice, jint aHandle)
       
   584     {
       
   585         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
   586         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   587         TBool              isVisible;
       
   588         CallMethod(isVisible, control, &MSwtControl::GetVisible, display);
       
   589         return ConvertBoolean(isVisible);
       
   590     }
       
   591 
       
   592     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1GetBackground(JNIEnv*, jclass, jint aHandle)
       
   593     {
       
   594         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   595         TRgb result;
       
   596         CallMethod(result, control, &MSwtControl::GetBackground);
       
   597         return result.Value();
       
   598     }
       
   599 
       
   600     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1GetForeground(JNIEnv*, jclass, jint aHandle)
       
   601     {
       
   602         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   603         TRgb result;
       
   604         CallMethod(result, control, &MSwtControl::GetForeground);
       
   605         return result.Value();
       
   606     }
       
   607 
       
   608     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1GetFont(JNIEnv*, jclass, jint aHandle)
       
   609     {
       
   610         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   611         const MSwtFont* result;
       
   612         CallMethod(result, control, &MSwtControl::GetFont);
       
   613         ASSERT(result!=NULL);
       
   614         return reinterpret_cast<jint>(result);
       
   615     }
       
   616 
       
   617     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1GetBorderWidth(JNIEnv*, jclass, jint aHandle)
       
   618     {
       
   619         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   620         TInt result;
       
   621         CallMethod(result, control, &MSwtControl::GetBorderWidth);
       
   622         return result;
       
   623     }
       
   624 
       
   625     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1GetBounds(JNIEnv* aJniEnv, jclass, jint aHandle)
       
   626     {
       
   627         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   628         TRect        boundResult(TRect::EUninitialized);
       
   629         CallMethod(boundResult, control, &MSwtControl::GetBounds);
       
   630         return NewJavaRectangle(aJniEnv, boundResult);
       
   631     }
       
   632 
       
   633     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1GetClientArea(JNIEnv* aJniEnv, jclass, jint aHandle)
       
   634     {
       
   635         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   636         TRect clientRect(TRect::EUninitialized);
       
   637         CallMethod(clientRect, control, &MSwtControl::ClientRect);
       
   638         return NewJavaRectangle(aJniEnv, TRect(clientRect.Size()));
       
   639     }
       
   640 
       
   641     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1GetSize(JNIEnv* aJniEnv, jclass, jint aHandle)
       
   642     {
       
   643         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   644         TSize              controlSize(TSize::EUninitialized);
       
   645         CallMethod(controlSize, control, &MSwtControl::GetWidgetSize);
       
   646         return NewJavaPoint(aJniEnv, controlSize.AsPoint());
       
   647     }
       
   648 
       
   649     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1GetStyle(JNIEnv*, jclass, jint aHandle)
       
   650     {
       
   651         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   652         TInt result;
       
   653         CallMethod(result, control, &MSwtControl::Style);
       
   654         return result;
       
   655     }
       
   656 
       
   657     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1HasDoNotDrawFlag(JNIEnv*, jclass, jint aHandle)
       
   658     {
       
   659         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   660         TBool hasDoNotDrawFlag;
       
   661         CallMethod(hasDoNotDrawFlag, control, &MSwtControl::HasDoNotDrawFlag);
       
   662         return ConvertBoolean(hasDoNotDrawFlag);
       
   663     }
       
   664 
       
   665     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1GetLocation(JNIEnv* aJniEnv, jclass, jint aHandle)
       
   666     {
       
   667         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   668         TPoint             controlLocation(TPoint::EUninitialized);
       
   669         CallMethod(controlLocation, control, &MSwtControl::GetLocation);
       
   670         return NewJavaPoint(aJniEnv, controlLocation);
       
   671     }
       
   672 
       
   673     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1IsFocusControl(JNIEnv*, jclass, jint aHandle)
       
   674     {
       
   675         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   676         TBool isFocused;
       
   677         CallMethod(isFocused,control, &MSwtControl::IsFocusControl);
       
   678         return ConvertBoolean(isFocused);
       
   679     }
       
   680 
       
   681     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1MoveAbove(JNIEnv*, jclass, jint aHandle, jint aControlHandle)
       
   682     {
       
   683         MSwtControl* control1 = reinterpret_cast<MSwtControl*>(aHandle);
       
   684         MSwtControl* control2 = reinterpret_cast<MSwtControl*>(aControlHandle);
       
   685         CallMethod(control1, &MSwtControl::MoveAbove, control2);
       
   686     }
       
   687 
       
   688     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1MoveBelow(JNIEnv*, jclass, jint aHandle, jint aControlHandle)
       
   689     {
       
   690         MSwtControl* control1 = reinterpret_cast<MSwtControl*>(aHandle);
       
   691         MSwtControl* control2 = reinterpret_cast<MSwtControl*>(aControlHandle);
       
   692         CallMethod(control1, &MSwtControl::MoveBelow, control2);
       
   693     }
       
   694 
       
   695     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1PostTraverseEvent
       
   696     (JNIEnv*, jclass, jint aHandle, jint aTraversal)
       
   697     {
       
   698         MSwtControl*  control = reinterpret_cast<MSwtControl*>(aHandle);
       
   699         TBool         doIt    = ETrue;
       
   700         TSwtTraversal traversal(static_cast<TSwtTraversal>(aTraversal));
       
   701         TBool result;
       
   702         CallMethod(result, control, &MSwtControl::ForceTraverseEvent, traversal, doIt);
       
   703         return ConvertBoolean(result);
       
   704     }
       
   705 
       
   706     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1Paint(
       
   707         JNIEnv* aJniEnv, jclass, jint aDevice, jint aHandle, jint aX, jint aY, jint aWidth,
       
   708         jint aHeight, jboolean aPaintNatively, jint aGcHandle, jintArray aIntParams, jint aIntCount,
       
   709         jstring aStrParams)
       
   710     {
       
   711         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
   712         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   713         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aGcHandle);
       
   714         TRect rect(TPoint(aX,aY), TSize(aWidth,aHeight));
       
   715         TInt* ints = NULL;
       
   716         if (aIntParams)
       
   717         {
       
   718             ints = JavaIntRegionToInts(aJniEnv, aIntParams, 0, aIntCount);
       
   719         }
       
   720         HBufC* strings = NULL;
       
   721         if (aStrParams)
       
   722         {
       
   723             // If this fails we proceed without strings
       
   724             TRAP_IGNORE(strings = ConvertStringL(aJniEnv, aStrParams));
       
   725         }
       
   726         CallMethod(control, &MSwtControl::Paint, rect, aPaintNatively, gc, ints, aIntCount, strings, display);
       
   727         delete[] ints;
       
   728         delete strings;
       
   729     }
       
   730 
       
   731     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1Redraw(JNIEnv*, jclass, jint aHandle)
       
   732     {
       
   733         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   734         CallMethod(control, &MSwtControl::Redraw);
       
   735     }
       
   736 
       
   737     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1RedrawRegion(JNIEnv*, jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight)
       
   738     {
       
   739         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   740         TRect rect(TPoint(aX,aY), TSize(aWidth,aHeight));
       
   741         CallMethod(control, &MSwtControl::RedrawRegion, rect);
       
   742     }
       
   743 
       
   744     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1SetRedraw(JNIEnv*, jclass, jint aHandle, jboolean aRedraw)
       
   745     {
       
   746         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   747         CallMethod(control, &MSwtControl::SetRedraw, aRedraw);
       
   748     }
       
   749 
       
   750     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1SetCapture(JNIEnv*, jclass, jint aHandle, jboolean aCapture)
       
   751     {
       
   752         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   753         CallMethod(control, &MSwtControl::SetCapture, aCapture);
       
   754     }
       
   755 
       
   756     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1SetFont(JNIEnv* aJniEnv, jclass, jint aHandle, jint aFontHandle)
       
   757     {
       
   758         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   759         MSwtFont*    font    = reinterpret_cast<MSwtFont*>(aFontHandle);
       
   760         TRAPD(error, CallMethodL(control, &MSwtControl::SetFontL, font));
       
   761         ThrowIfError(error, aJniEnv);
       
   762     }
       
   763 
       
   764     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1SetBackground(JNIEnv* aJniEnv, jclass, jint aHandle, jint aColorHandle)
       
   765     {
       
   766         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   767         MSwtColor*   color   = reinterpret_cast<MSwtColor*>(aColorHandle);
       
   768         TRAPD(error, CallMethodL(control, &MSwtControl::SetBackgroundL, color));
       
   769         ThrowIfError(error, aJniEnv);
       
   770     }
       
   771 
       
   772     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1SetForeground(JNIEnv* aJniEnv, jclass, jint aHandle, jint aColorHandle)
       
   773     {
       
   774         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   775         MSwtColor*   color   = reinterpret_cast<MSwtColor*>(aColorHandle);
       
   776         TRAPD(error, CallMethodL(control, &MSwtControl::SetForegroundL, color));
       
   777         ThrowIfError(error, aJniEnv);
       
   778     }
       
   779 
       
   780     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1SetVisible(JNIEnv*, jclass, jint aHandle, jboolean aVisible)
       
   781     {
       
   782         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   783         CallMethod(control, &MSwtControl::SetVisible, aVisible);
       
   784     }
       
   785 
       
   786     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1SetLocation(JNIEnv*, jclass, jint aHandle, jint aX, jint aY)
       
   787     {
       
   788         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   789         TPoint       point(aX, aY);
       
   790         CallMethod(control, &MSwtControl::SetLocation, point);
       
   791     }
       
   792 
       
   793     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1SetSize(JNIEnv*, jclass, jint aHandle, jint aWidth, jint aHeight)
       
   794     {
       
   795         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   796         TSize        size(aWidth, aHeight);
       
   797         CallMethod(control, &MSwtControl::SetWidgetSize, size);
       
   798     }
       
   799 
       
   800     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1ComputeSize(JNIEnv* aJniEnv, jclass, jint aHandle, jint aWHint, jint aHHint)
       
   801     {
       
   802         MSwtControl* theControl = reinterpret_cast<MSwtControl*>(aHandle);
       
   803         TSize size(0,0);
       
   804         TRAPD(error, CallMethodL(size, theControl, &MSwtControl::ComputeSizeL, aWHint, aHHint));
       
   805         if (error == KErrNone)
       
   806         {
       
   807             return NewJavaPoint(aJniEnv, size.AsPoint());
       
   808         }
       
   809         else
       
   810         {
       
   811             Throw(error, aJniEnv);
       
   812             return 0;
       
   813         }
       
   814     }
       
   815 
       
   816     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1SetEnabled(JNIEnv*, jclass, jint aHandle, jboolean aEnabled)
       
   817     {
       
   818         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   819         CallMethod(control, &MSwtControl::SetEnabled, aEnabled);
       
   820     }
       
   821 
       
   822     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1SetBounds(JNIEnv*, jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight)
       
   823     {
       
   824         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   825         TRect        rect(TPoint(aX,aY), TSize(aWidth,aHeight));
       
   826         CallMethod(control, &MSwtControl::SetBounds, rect);
       
   827     }
       
   828 
       
   829     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1SetMenu(JNIEnv* aJniEnv, jclass, jint aHandle, jint aMenuHandle)
       
   830     {
       
   831         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   832         MSwtMenu* menu = reinterpret_cast<MSwtMenu*>(aMenuHandle);
       
   833         TRAPD(error, CallMethodL(control, &MSwtControl::SetPopupMenuL, menu));
       
   834         ThrowIfError(error, aJniEnv);
       
   835     }
       
   836 
       
   837     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1ToControl(JNIEnv* aJniEnv, jclass, jint aHandle, jint aX, jint aY)
       
   838     {
       
   839         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   840         TPoint point(aX, aY);
       
   841         TPoint result(TPoint::EUninitialized);
       
   842         CallMethod(result, control, &MSwtControl::ToControl, point);
       
   843         return NewJavaPoint(aJniEnv, result);
       
   844     }
       
   845 
       
   846     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1ToDisplay(JNIEnv* aJniEnv, jclass, jint aHandle, jint aX, jint aY)
       
   847     {
       
   848         const MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   849         TPoint point(aX, aY);
       
   850         TPoint result(TPoint::EUninitialized);
       
   851         CallMethod(result, control, &MSwtControl::ToDisplay, point);
       
   852         return NewJavaPoint(aJniEnv, result);
       
   853     }
       
   854 
       
   855     static void Control_Update(JNIEnv* aJniEnv, MSwtControl* aControl)
       
   856     {
       
   857         ASSERT(aControl);
       
   858         CSwtDisplay::Current().PopAndDispatchPaintEvents(*aJniEnv, aControl);
       
   859 
       
   860         // check disposal of Display from java-side-paint-listener
       
   861         if (!CSwtDisplay::CurrentOrNull())
       
   862         {
       
   863             return;
       
   864         }
       
   865 
       
   866         MSwtComposite* composite = aControl->CompositeInterface();
       
   867 
       
   868         if (composite)
       
   869         {
       
   870             const RSwtControlArray* children = composite->Children();
       
   871             if (children)
       
   872             {
       
   873                 for (TInt i = 0; i < children->Count(); ++i)
       
   874                 {
       
   875                     MSwtControl* child = (*children)[i];
       
   876                     Control_Update(aJniEnv, child);
       
   877 
       
   878                     // check disposal of Display from java-side-paint-listener
       
   879                     if (!CSwtDisplay::CurrentOrNull())
       
   880                     {
       
   881                         return;
       
   882                     }
       
   883                 }
       
   884             }
       
   885         }
       
   886     }
       
   887 
       
   888     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Control_1Update(JNIEnv* aJniEnv, jclass, jint aHandle)
       
   889     {
       
   890         MSwtControl* control = reinterpret_cast<MSwtControl*>(aHandle);
       
   891         Control_Update(aJniEnv, control);
       
   892     }
       
   893 
       
   894 
       
   895     /*
       
   896      * Class Decorations
       
   897      */
       
   898     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Decorations_1New(JNIEnv* aJniEnv, jclass, jobject aPeer, jint aParent, jint aStyle)
       
   899     {
       
   900         jint handle = NewCoreWidget(aJniEnv, &MSwtFactory::NewDecorationsL, aPeer, aParent, aStyle);
       
   901         INCREASE_INSTANCE_COUNT(handle, Decorations);
       
   902         return handle;
       
   903     }
       
   904 
       
   905     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Decorations_1CanvasHandle(JNIEnv*, jclass, jint aHandle)
       
   906     {
       
   907         MSwtDecorations* decorations = reinterpret_cast<MSwtDecorations*>(aHandle);
       
   908         MSwtCanvas*      result;
       
   909         CallMethod(result, decorations, &MSwtDecorations::Canvas);
       
   910         return reinterpret_cast<jint>(result);
       
   911     }
       
   912 
       
   913     JNIEXPORT jstring JNICALL Java_org_eclipse_swt_internal_symbian_OS_Decorations_1GetText(JNIEnv* aJniEnv, jclass, jint aHandle)
       
   914     {
       
   915         const MSwtDecorations* decorations = reinterpret_cast<MSwtDecorations*>(aHandle);
       
   916         const TDesC* title;
       
   917         CallMethod(title, decorations, &MSwtDecorations::GetText);
       
   918         return NewJavaString(aJniEnv, (title!=NULL) ? *title : KNullDesC());
       
   919     }
       
   920 
       
   921     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Decorations_1SetImage(JNIEnv* aJniEnv, jclass, jint aHandle, jint aImageHandle)
       
   922     {
       
   923         MSwtImage* image = reinterpret_cast<MSwtImage*>(aImageHandle);
       
   924         MSwtDecorations* decorations = reinterpret_cast<MSwtDecorations*>(aHandle);
       
   925         TInt error = KErrNone;
       
   926         TRAP(error, CallMethodL(decorations, &MSwtDecorations::SetImageL, image));
       
   927         ThrowIfError(error, aJniEnv);
       
   928     }
       
   929 
       
   930     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Decorations_1SetMaximized(JNIEnv*, jclass, jint aHandle, jboolean aMaximized)
       
   931     {
       
   932         MSwtDecorations* decorations = reinterpret_cast<MSwtDecorations*>(aHandle);
       
   933         CallMethod(decorations, &MSwtDecorations::SetMaximized, aMaximized);
       
   934     }
       
   935 
       
   936     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Decorations_1GetMaximized(JNIEnv*, jclass, jint aHandle)
       
   937     {
       
   938         return ConvertBoolean(CallNonLeavingGetter(aHandle, &MSwtDecorations::GetMaximized));
       
   939     }
       
   940 
       
   941     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Decorations_1SetMinimized(JNIEnv*, jclass, jint aHandle, jboolean aMinimized)
       
   942     {
       
   943         MSwtDecorations* decorations = reinterpret_cast<MSwtDecorations*>(aHandle);
       
   944         CallMethod(decorations, &MSwtDecorations::SetMinimized, aMinimized);
       
   945     }
       
   946 
       
   947     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Decorations_1GetMinimized(JNIEnv*, jclass, jint aHandle)
       
   948     {
       
   949         return ConvertBoolean(CallNonLeavingGetter(aHandle, &MSwtDecorations::GetMinimized));
       
   950     }
       
   951 
       
   952     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Decorations_1SetMenuBar(JNIEnv*, jclass, jint aHandle, jint aMenuHandle)
       
   953     {
       
   954         MSwtDecorations*  decorations = reinterpret_cast<MSwtDecorations*>(aHandle);
       
   955         MSwtMenu*         menuBar     = reinterpret_cast<MSwtMenu*>(aMenuHandle);
       
   956         CallMethod(decorations, &MSwtDecorations::SetMenuBar, menuBar);
       
   957     }
       
   958 
       
   959     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Decorations_1SetText(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aTitle)
       
   960     {
       
   961         CallTextMethodThrow(aJniEnv, aHandle, &MSwtDecorations::SetTextL, aTitle);
       
   962     }
       
   963 
       
   964     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Decorations_1SetDefaultButton(JNIEnv* , jclass, jint aHandle, jint aDefaultButtonHandle)
       
   965     {
       
   966         MSwtDecorations*    decorations     = reinterpret_cast<MSwtDecorations*>(aHandle);
       
   967         MSwtButton* defaultButton   = reinterpret_cast<MSwtButton*>(aDefaultButtonHandle);
       
   968         CallMethod(decorations, &MSwtDecorations::SetDefaultButton, defaultButton);
       
   969     }
       
   970 
       
   971     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Decorations_1GetDefaultButton(JNIEnv*, jclass, jint aHandle)
       
   972     {
       
   973         const MSwtDecorations* decorations = reinterpret_cast<MSwtDecorations*>(aHandle);
       
   974         TSwtPeer peer;
       
   975         CallMethod(peer, decorations, &MSwtDecorations::GetDefaultButton);
       
   976         return peer;
       
   977     }
       
   978 
       
   979     /*
       
   980      * Interface Drawable
       
   981      */
       
   982     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Drawable_1NewGc(JNIEnv* aJniEnv, jclass, jint aHandle)
       
   983     {
       
   984         MSwtDrawable* drawable = reinterpret_cast<MSwtDrawable*>(aHandle);
       
   985         MSwtGc*       result   = NULL;
       
   986 
       
   987         // GCs are always constructed in the UI thread.
       
   988         // If there is no display pointer in the TLS then this is not a UI thread
       
   989         // and we must throw an exception.
       
   990         CSwtDisplay* display = CSwtDisplay::CurrentOrNull();
       
   991         if (!display)
       
   992         {
       
   993             Throw(ESwtErrorThreadInvalidAccess, aJniEnv);
       
   994             return NULL;
       
   995         }
       
   996 
       
   997         TRAPD(error, CallMethodL(result, drawable, &MSwtDrawable::NewGcL, display));
       
   998         ThrowIfError(error, aJniEnv);
       
   999 
       
  1000         INCREASE_INSTANCE_COUNT(result, Gc);
       
  1001 
       
  1002         return reinterpret_cast<jint>(result);
       
  1003     }
       
  1004 
       
  1005 
       
  1006     /*
       
  1007      * Class Font
       
  1008      */
       
  1009     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Font_1Dispose(JNIEnv*, jclass, jint aDevice, jint aHandle)
       
  1010     {
       
  1011         ASSERT(aHandle!=0);
       
  1012         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1013         MSwtFont* font = reinterpret_cast<MSwtFont*>(aHandle);
       
  1014         CallMethod(font, &MSwtFont::Dispose, display);
       
  1015 
       
  1016         DECREASE_INSTANCE_COUNT_USE_DISPLAY(Font, display);
       
  1017     }
       
  1018 
       
  1019     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Font_1GetHeight(JNIEnv*, jclass, jint aHandle)
       
  1020     {
       
  1021         ASSERT(aHandle!=0);
       
  1022         const MSwtFont* font = reinterpret_cast<MSwtFont*>(aHandle);
       
  1023         TInt height = 0;
       
  1024         CallMethod(height, font, &MSwtFont::DesignHeightInPoints);
       
  1025         return height;
       
  1026     }
       
  1027 
       
  1028     JNIEXPORT jstring JNICALL Java_org_eclipse_swt_internal_symbian_OS_Font_1GetName(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  1029     {
       
  1030         ASSERT(aHandle!=0);
       
  1031         const MSwtFont* font = reinterpret_cast<MSwtFont*>(aHandle);
       
  1032         HBufC* name = NULL;
       
  1033         TRAPD(error, CallMethodL(name, font, &MSwtFont::GetNameL));
       
  1034         ThrowIfError(error, aJniEnv);
       
  1035         jstring javaName = (name!=NULL) ? NewJavaString(aJniEnv,*name) : NULL;
       
  1036         DeleteInUiHeap(name);
       
  1037         return javaName;
       
  1038     }
       
  1039 
       
  1040     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Font_1GetStyle(JNIEnv*, jclass, jint aHandle)
       
  1041     {
       
  1042         ASSERT(aHandle!=0);
       
  1043         const MSwtFont* font = reinterpret_cast<MSwtFont*>(aHandle);
       
  1044         TInt Style = 0;
       
  1045         CallMethod(Style, font, &MSwtFont::Style);
       
  1046         return Style;
       
  1047     }
       
  1048 
       
  1049     static MSwtFont* Font_NewL(JNIEnv* aJniEnv, MSwtDevice* aDevice, const jstring aTypefaceName, TInt aHeight, TInt aStyle)
       
  1050     {
       
  1051         HBufC* typefaceName = ConvertStringLC(aJniEnv, aTypefaceName);
       
  1052         CSwtDisplay* display = DisplayFromDevice(reinterpret_cast<jint>(aDevice));
       
  1053         const MSwtFactory& factory = display->Factory();
       
  1054         MSwtFont* font;
       
  1055         CallMethodL(font, &factory, &MSwtFactory::NewFontL, *aDevice, *typefaceName, aHeight, aStyle, display);
       
  1056         CleanupStack::PopAndDestroy(typefaceName);
       
  1057         return font;
       
  1058     }
       
  1059 
       
  1060     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Font_1New(JNIEnv* aJniEnv, jclass, jint aDevice, jstring aTypefaceName, jint aHeight, jint aStyle)
       
  1061     {
       
  1062         ASSERT(aDevice!=0);
       
  1063         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1064         MSwtDevice*  device  = reinterpret_cast<MSwtDevice*>(aDevice);
       
  1065         MSwtFont*    font = NULL;
       
  1066         TRAPD(error, (font=Font_NewL(aJniEnv, device, aTypefaceName, aHeight, aStyle)));
       
  1067         ThrowIfError(error, aJniEnv);
       
  1068 
       
  1069         INCREASE_INSTANCE_COUNT_USE_DISPLAY(font, Font, display);
       
  1070 
       
  1071         return reinterpret_cast<jint>(font);
       
  1072     }
       
  1073 
       
  1074     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Font_1AddRef(JNIEnv *, jclass, jint aHandle)
       
  1075     {
       
  1076         ASSERT(aHandle);
       
  1077         const MSwtFont* font = reinterpret_cast<MSwtFont*>(aHandle);
       
  1078         CallMethod(static_cast<const MSwtRefCounted*>(font), &MSwtFont::AddRef);
       
  1079     }
       
  1080 
       
  1081     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Font_1RemoveRef(JNIEnv *, jclass, jint aHandle)
       
  1082     {
       
  1083         ASSERT(aHandle);
       
  1084         const MSwtFont* font = reinterpret_cast<MSwtFont*>(aHandle);
       
  1085         CallMethod(static_cast<const MSwtRefCounted*>(font), &MSwtFont::RemoveRef);
       
  1086     }
       
  1087 
       
  1088 
       
  1089     /*
       
  1090      * Class GC
       
  1091      */
       
  1092     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1CopyAreaToImage(JNIEnv* aJniEnv, jclass, jint aDevice, jint aHandle, jint aImageHandle, jint aX, jint aY)
       
  1093     {
       
  1094         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1095         const MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1096         MSwtImage*    image = reinterpret_cast<MSwtImage*>(aImageHandle);
       
  1097         TPoint        pos(aX, aY);
       
  1098         TRAPD(error, CallMethodL(gc, &MSwtGc::CopyAreaL, *image, pos, display));
       
  1099         ThrowIfError(error, aJniEnv);
       
  1100     }
       
  1101 
       
  1102     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1CopyArea(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aSrcX, jint aSrcY, jint aWidth, jint aHeight, jint aDestX, jint aDestY)
       
  1103     {
       
  1104         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1105         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1106         TRect   rectSource(TPoint(aSrcX, aSrcY), TSize(aWidth, aHeight));
       
  1107         TPoint  pointDest(aDestX, aDestY);
       
  1108         CallMethod(gc, &MSwtGc::CopyArea, rectSource, pointDest, display);
       
  1109     }
       
  1110 
       
  1111     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1Dispose(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  1112     {
       
  1113         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1114 
       
  1115         // GC is always disposed in the UI-thread so TLS can be used to get the display.
       
  1116         // If there is no display pointer in the TLS then this is not a UI thread
       
  1117         // and we must throw an exception.
       
  1118         CSwtDisplay* display = CSwtDisplay::CurrentOrNull();
       
  1119         if (!display)
       
  1120         {
       
  1121             Throw(ESwtErrorThreadInvalidAccess, aJniEnv);
       
  1122             return;
       
  1123         }
       
  1124 
       
  1125         // When display pointer is not passed here then TLS will be used.
       
  1126         CallMethod(gc, &MSwtGc::Dispose);
       
  1127 
       
  1128         DECREASE_INSTANCE_COUNT(Gc);
       
  1129     }
       
  1130 
       
  1131     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1SetAlpha(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aAlpha)
       
  1132     {
       
  1133         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1134         MSwtGc* gc       = reinterpret_cast<MSwtGc*>(aHandle);
       
  1135         CallMethod(gc, &MSwtGc::SetAlpha, aAlpha, display);
       
  1136     }
       
  1137 
       
  1138     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1SetBackground(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aColorHandle)
       
  1139     {
       
  1140         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1141         MSwtGc* gc       = reinterpret_cast<MSwtGc*>(aHandle);
       
  1142         MSwtColor* color = reinterpret_cast<MSwtColor*>(aColorHandle);
       
  1143         CallMethod(gc, &MSwtGc::SetBackground, *color, display);
       
  1144     }
       
  1145 
       
  1146     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1SetForeground(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aColorHandle)
       
  1147     {
       
  1148         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1149         MSwtGc* gc       = reinterpret_cast<MSwtGc*>(aHandle);
       
  1150         MSwtColor* color = reinterpret_cast<MSwtColor*>(aColorHandle);
       
  1151         CallMethod(gc, &MSwtGc::SetForeground, *color, display);
       
  1152     }
       
  1153 
       
  1154     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1SetLineStyle(JNIEnv* aJniEnv, jclass, jint aDevice, jint aHandle, jint aStyle)
       
  1155     {
       
  1156         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1157         MSwtGc*       gc        = reinterpret_cast<MSwtGc*>(aHandle);
       
  1158         TSwtLineStyle lineStyle(static_cast<TSwtLineStyle>(aStyle));
       
  1159         TRAPD(error, CallMethodL(gc, &MSwtGc::SetLineStyleL, lineStyle, display));
       
  1160         ThrowIfError(error, aJniEnv);
       
  1161     }
       
  1162 
       
  1163     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1SetLineWidth(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aWidth)
       
  1164     {
       
  1165         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1166         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1167         CallMethod(gc, &MSwtGc::SetLineWidth, aWidth, display);
       
  1168     }
       
  1169 
       
  1170     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1DrawImage(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aImageHandle, jint aSrcX, jint aSrcY, jint aSrcWidth, jint aSrcHeight, jint aDestX, jint aDestY, jint aDestWidth, jint aDestHeight)
       
  1171     {
       
  1172         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1173         MSwtGc*    gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1174         MSwtImage* image = reinterpret_cast<MSwtImage*>(aImageHandle);
       
  1175         TPoint     srcPos(aSrcX, aSrcY);
       
  1176         TSize      srcSize(aSrcWidth, aSrcHeight);
       
  1177         TPoint     destPos(aDestX, aDestY);
       
  1178         TSize      destSize(aDestWidth, aDestHeight);
       
  1179         CallMethod(gc, &MSwtGc::DrawImage, *image, srcPos, srcSize, destPos, destSize, display);
       
  1180     }
       
  1181 
       
  1182     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1DrawPoint(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aX, jint aY)
       
  1183     {
       
  1184         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1185         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1186         TPoint  pt(aX,aY);
       
  1187         CallMethod(gc, &MSwtGc::DrawPoint, pt, display);
       
  1188     }
       
  1189 
       
  1190     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1DrawLine(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aX1, jint aY1, jint aX2, jint aY2)
       
  1191     {
       
  1192         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1193         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1194         TPoint  pt1(aX1,aY1);
       
  1195         TPoint  pt2(aX2,aY2);
       
  1196         CallMethod(gc, &MSwtGc::DrawLine, pt1, pt2, display);
       
  1197     }
       
  1198 
       
  1199     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1DrawPolyline(JNIEnv* aJniEnv, jclass, jint aDevice, jint aHandle, jintArray aPointArray)
       
  1200     {
       
  1201         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1202         TPoint* points = NULL;
       
  1203         TInt    count  = JavaIntsToPoints(aJniEnv, aPointArray, points);
       
  1204         if (count == 0)
       
  1205             return;
       
  1206 
       
  1207         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1208         CallMethod(gc, &MSwtGc::DrawPolyline, points, count, display);
       
  1209         delete[] points;
       
  1210     }
       
  1211 
       
  1212     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1DrawPolygon(JNIEnv* aJniEnv, jclass, jint aDevice, jint aHandle, jintArray aPointArray, jboolean aFill)
       
  1213     {
       
  1214         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1215         TPoint* points = NULL;
       
  1216         TInt    count  = JavaIntsToPoints(aJniEnv, aPointArray, points);
       
  1217         if (count == 0)
       
  1218             return;
       
  1219 
       
  1220         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1221         CallMethod(gc, (aFill) ? &MSwtGc::FillPolygon : &MSwtGc::DrawPolygon, points, count, display);
       
  1222         delete[] points;
       
  1223     }
       
  1224 
       
  1225     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1DrawRectangle(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight, jboolean aFill)
       
  1226     {
       
  1227         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1228         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1229         TRect   rect(TPoint(aX,aY), TSize(aWidth,aHeight));
       
  1230         CallMethod(gc, (aFill) ? &MSwtGc::FillRectangle : &MSwtGc::DrawRectangle, rect, display);
       
  1231     }
       
  1232 
       
  1233     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1DrawRoundRectangle(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight, jint aArcWidth, jint aArcHeight, jboolean aFill)
       
  1234     {
       
  1235         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1236         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1237         TRect   rect(TPoint(aX,aY), TSize(aWidth,aHeight));
       
  1238         TSize   arcSize(aArcWidth, aArcHeight);
       
  1239         CallMethod(gc, (aFill) ? &MSwtGc::FillRoundRectangle : &MSwtGc::DrawRoundRectangle, rect, arcSize, display);
       
  1240     }
       
  1241 
       
  1242     static void Gc_DrawTextL(JNIEnv* aJniEnv, MSwtGc* aGc, const jstring aString, TInt aX, TInt aY, TInt aFlags, CSwtDisplay* aDevice)
       
  1243     {
       
  1244         CSwtDisplay* display = reinterpret_cast<CSwtDisplay*>(aDevice);
       
  1245         HBufC* text = ConvertStringLC(aJniEnv, aString);
       
  1246         TPoint position(aX, aY);
       
  1247         TPtr   des(text->Des());
       
  1248         CallMethodL(aGc, &MSwtGc::DrawTextL, des, position, aFlags, display);
       
  1249         CleanupStack::PopAndDestroy(text);
       
  1250     }
       
  1251 
       
  1252     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1DrawText(JNIEnv* aJniEnv, jclass, jint aDevice, jint aHandle, jstring aString, jint aX, jint aY, jint aFlags)
       
  1253     {
       
  1254         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1255         ASSERT(aHandle!=0);
       
  1256         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1257         TRAPD(error, Gc_DrawTextL(aJniEnv, gc, aString, aX, aY, aFlags, display));
       
  1258         ThrowIfError(error, aJniEnv);
       
  1259     }
       
  1260 
       
  1261     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1DrawOval(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight, jboolean aFill)
       
  1262     {
       
  1263         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1264         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1265         TRect   rect(TPoint(aX,aY), TSize(aWidth,aHeight));
       
  1266         CallMethod(gc, (aFill) ? &MSwtGc::FillOval : &MSwtGc::DrawOval, rect, display);
       
  1267     }
       
  1268 
       
  1269     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1DrawArc(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight, jint aStartAngle, jint aArcAngle, jboolean aFill)
       
  1270     {
       
  1271         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1272         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1273         TRect   rect(TPoint(aX,aY), TSize(aWidth,aHeight));
       
  1274         CallMethod(gc, (aFill) ? &MSwtGc::FillArc : &MSwtGc::DrawArc, rect, aStartAngle, aArcAngle, display);
       
  1275     }
       
  1276 
       
  1277     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1DrawFocusRect(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight)
       
  1278     {
       
  1279         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1280         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1281         TRect   rect(TPoint(aX,aY), TSize(aWidth,aHeight));
       
  1282         const MSwtUiUtils& utils = display->UiUtils();
       
  1283         CallMethod(gc, &MSwtGc::DrawFocusRect, rect, utils, display);
       
  1284     }
       
  1285 
       
  1286     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1IsClipped(JNIEnv*, jclass, jint aDevice, jint aHandle)
       
  1287     {
       
  1288         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1289         const MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1290         TBool         result;
       
  1291         CallMethod(result, gc, &MSwtGc::IsClipped, display);
       
  1292         return ConvertBoolean(result);
       
  1293     }
       
  1294 
       
  1295     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1FillGradientRectangle(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight, jboolean aVertical)
       
  1296     {
       
  1297         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1298         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1299         TBool invertGradient(EFalse);
       
  1300         TInt  width = (0 < aWidth) ? aWidth : -aWidth;
       
  1301         TInt  height = (0 < aHeight) ? aHeight : -aHeight;
       
  1302         TRect rect(TPoint(aX, aY), TSize(width, height));
       
  1303 
       
  1304         if ((aWidth < 0) || (aHeight < 0))
       
  1305         {
       
  1306             invertGradient = ETrue;
       
  1307         }
       
  1308         CallMethod(gc, &MSwtGc::FillGradientRectangle, rect, aVertical, invertGradient, display);
       
  1309     }
       
  1310 
       
  1311     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1GetAdvanceWidth(JNIEnv*, jclass, jint aDevice, jint aHandle, jchar aChar)
       
  1312     {
       
  1313         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1314         const MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1315         TInt  advWidth = 0;
       
  1316         CallMethod(advWidth, gc, &MSwtGc::GetAdvanceWidth, aChar, display);
       
  1317         return advWidth;
       
  1318     }
       
  1319 
       
  1320     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1GetCharWidth(JNIEnv*, jclass, jint aDevice, jint aHandle, jchar aChar)
       
  1321     {
       
  1322         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1323         const MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1324         TInt  width = 0;
       
  1325         CallMethod(width, gc, &MSwtGc::GetCharWidth, aChar, display);
       
  1326         return width;
       
  1327     }
       
  1328 
       
  1329     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1GetClippingRect(JNIEnv* aJniEnv, jclass, jint aDevice, jint aHandle)
       
  1330     {
       
  1331         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1332         const MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1333         TRect         result(TRect::EUninitialized);
       
  1334         CallMethod(result, gc, &MSwtGc::ClippingRect, display);
       
  1335         return NewJavaRectangle(aJniEnv, result);
       
  1336     }
       
  1337 
       
  1338     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1GetFont(JNIEnv*, jclass, jint aDevice, jint aHandle)
       
  1339     {
       
  1340         ASSERT(aHandle!=0);
       
  1341         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1342         const MSwtGc*   gc   = reinterpret_cast<MSwtGc*>(aHandle);
       
  1343         const MSwtFont* font = NULL;
       
  1344         CallMethod(font, gc, &MSwtGc::Font, display);
       
  1345         return reinterpret_cast<jint>(font);
       
  1346     }
       
  1347 
       
  1348     JNIEXPORT jintArray JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1GetFontMetrics(JNIEnv* aJniEnv, jclass, jint aDevice, jint aHandle)
       
  1349     {
       
  1350         ASSERT(aHandle!=0);
       
  1351         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1352         const MSwtGc*   gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1353         TSwtFontMetrics fontMetrics;
       
  1354         CallMethod(gc, &MSwtGc::GetFontMetrics, fontMetrics, display);
       
  1355         jintArray fontMetricsArray = aJniEnv->NewIntArray(5);
       
  1356         if (!fontMetricsArray)
       
  1357         {
       
  1358             return NULL;
       
  1359         }
       
  1360 
       
  1361         aJniEnv->SetIntArrayRegion(fontMetricsArray, 0, 1, &fontMetrics.iAscent); //lint !e613
       
  1362         aJniEnv->SetIntArrayRegion(fontMetricsArray, 1, 1, &fontMetrics.iAverageCharWidth); //lint !e613
       
  1363         aJniEnv->SetIntArrayRegion(fontMetricsArray, 2, 1, &fontMetrics.iDescent); //lint !e613
       
  1364         aJniEnv->SetIntArrayRegion(fontMetricsArray, 3, 1, &fontMetrics.iHeight); //lint !e613
       
  1365         aJniEnv->SetIntArrayRegion(fontMetricsArray, 4, 1, &fontMetrics.iLeading); //lint !e613
       
  1366         return fontMetricsArray;
       
  1367     }
       
  1368 
       
  1369     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1GetLineStyle(JNIEnv*, jclass, jint aDevice, jint aHandle)
       
  1370     {
       
  1371         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1372         const MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1373         TInt          lineStyle;
       
  1374         CallMethod(lineStyle, gc, &MSwtGc::LineStyle, display);
       
  1375         return lineStyle;
       
  1376     }
       
  1377 
       
  1378     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1GetLineWidth(JNIEnv*, jclass, jint aDevice, jint aHandle)
       
  1379     {
       
  1380         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1381         const MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1382         TInt          lineWidth;
       
  1383         CallMethod(lineWidth, gc, &MSwtGc::LineWidth, display);
       
  1384         return lineWidth;
       
  1385     }
       
  1386 
       
  1387     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1GetXORMode(JNIEnv*, jclass, jint aDevice, jint aHandle)
       
  1388     {
       
  1389         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1390         const MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1391         TBool         mode;
       
  1392         CallMethod(mode, gc, &MSwtGc::XORMode, display);
       
  1393         return ConvertBoolean(mode);
       
  1394     }
       
  1395 
       
  1396     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1SetClippingRect(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight)
       
  1397     {
       
  1398         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1399         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1400         TRect   rect(TPoint(aX,aY), TSize(aWidth,aHeight));
       
  1401         CallMethod(gc, &MSwtGc::SetClippingRect, rect, display);
       
  1402     }
       
  1403 
       
  1404     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1CancelClipping(JNIEnv*, jclass, jint aDevice, jint aHandle)
       
  1405     {
       
  1406         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1407         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1408         CallMethod(gc, &MSwtGc::CancelClipping, display);
       
  1409     }
       
  1410 
       
  1411     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1SetFont(JNIEnv*, jclass, jint aDevice, jint aHandle, jint aFontHandle)
       
  1412     {
       
  1413         ASSERT(aHandle!=0);
       
  1414         ASSERT(aFontHandle!=0);
       
  1415         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1416         MSwtGc*   gc   = reinterpret_cast<MSwtGc*>(aHandle);
       
  1417         MSwtFont* font = reinterpret_cast<MSwtFont*>(aFontHandle);
       
  1418         CallMethod(gc, &MSwtGc::SetFont, font, display);
       
  1419     }
       
  1420 
       
  1421     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1SetXORMode(JNIEnv*, jclass, jint aDevice, jint aHandle, jboolean aMode)
       
  1422     {
       
  1423         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1424         MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1425         CallMethod(gc, &MSwtGc::SetXORMode, aMode, display);
       
  1426     }
       
  1427 
       
  1428     static void Gc_TextExtentL(TSize& aResult, JNIEnv* aJniEnv, const MSwtGc* aGc, const jstring aText, TInt aFlags, CSwtDisplay* aDevice)
       
  1429     {
       
  1430         HBufC* text = ConvertStringLC(aJniEnv, aText);
       
  1431         TPtr des(text->Des());
       
  1432         CallMethodL(aResult, aGc, &MSwtGc::TextExtentL, des, aFlags, aDevice);
       
  1433         CleanupStack::PopAndDestroy(text);
       
  1434     }
       
  1435 
       
  1436     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1TextExtent(JNIEnv* aJniEnv, jclass, jint aDevice, jint aHandle, jstring aString, jint aFlags)
       
  1437     {
       
  1438         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1439         const MSwtGc* gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1440         TSize extent(TSize::EUninitialized);
       
  1441         TRAPD(error, Gc_TextExtentL(extent, aJniEnv, gc, aString, aFlags, display));
       
  1442         if (error)
       
  1443         {
       
  1444             Throw(error, aJniEnv);
       
  1445             return NULL;
       
  1446         }
       
  1447         return NewJavaPoint(aJniEnv, extent.AsPoint());
       
  1448     }
       
  1449 
       
  1450     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_GC_1DrawM2GImage(JNIEnv* aJniEnv, jclass, jint aDevice, jint aHandle, jintArray aBitmapHandles,
       
  1451             jint aSrcX, jint aSrcY, jint aSrcWidth, jint aSrcHeight, jint aDestX, jint aDestY, jint aDestWidth, jint aDestHeight, jint aUseNativeClear)
       
  1452     {
       
  1453         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1454         MSwtGc*    gc = reinterpret_cast<MSwtGc*>(aHandle);
       
  1455 
       
  1456         TInt* bitmapHandles = NULL;
       
  1457         TInt count = JavaIntsToInts(aJniEnv, aBitmapHandles, bitmapHandles);
       
  1458         if (count == 0)
       
  1459             return;
       
  1460 
       
  1461         TPoint     srcPos(aSrcX, aSrcY);
       
  1462         TSize      srcSize(aSrcWidth, aSrcHeight);
       
  1463         TPoint     destPos(aDestX, aDestY);
       
  1464         TSize      destSize(aDestWidth, aDestHeight);
       
  1465         TRAP_IGNORE(CallMethod(gc, &MSwtGc::DrawM2GImageL, bitmapHandles, srcPos, srcSize, destPos, destSize, aUseNativeClear, display));
       
  1466         delete[] bitmapHandles;
       
  1467     }
       
  1468 
       
  1469 
       
  1470     /*
       
  1471      * Class Image
       
  1472      */
       
  1473     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Image_1New(JNIEnv* aJniEnv, jclass, jint aDevice, jint aWidth, jint aHeight)
       
  1474     {
       
  1475         ASwtDisplayBase* display = DisplayFromDevice(aDevice);
       
  1476         TSize        size(aWidth, aHeight);
       
  1477         MSwtImage*   result  = NULL;
       
  1478         TRAPD(error, CallMethodL(result, display, &ASwtDisplayBase::NewImageL, size, static_cast<CSwtDisplay*>(display)));
       
  1479         ThrowIfError(error, aJniEnv);
       
  1480 
       
  1481         INCREASE_INSTANCE_COUNT_USE_DISPLAY(result, Image, display);
       
  1482 
       
  1483         return reinterpret_cast<jint>(result);
       
  1484     }
       
  1485 
       
  1486     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Image_1NewFromData(JNIEnv* aJniEnv, jclass, jint aDevice, jobject aData)
       
  1487     {
       
  1488         // Convert image data
       
  1489         MSwtImageData* data = NULL;
       
  1490         TRAPD(error, (data=CSwtImageData::NewL(aJniEnv,aData)));
       
  1491         if (data == NULL)
       
  1492         {
       
  1493             ThrowIfError(error, aJniEnv);
       
  1494             return 0;
       
  1495         }
       
  1496 
       
  1497         // Create the image
       
  1498         ASwtDisplayBase* display = DisplayFromDevice(aDevice);
       
  1499         MSwtImage*   result  = NULL;
       
  1500         TRAP(error, CallMethodL(result, display, &ASwtDisplayBase::NewImageFromDataL, *data, static_cast<CSwtDisplay*>(display)));
       
  1501         delete data;
       
  1502         ThrowIfError(error, aJniEnv);
       
  1503 
       
  1504         INCREASE_INSTANCE_COUNT_USE_DISPLAY(result, Image, display);
       
  1505 
       
  1506         return reinterpret_cast<jint>(result);
       
  1507     }
       
  1508 
       
  1509     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Image_1NewFromTheme(JNIEnv* aJniEnv, jclass, jint aDevice, jint aId)
       
  1510     {
       
  1511         ASwtDisplayBase* display = DisplayFromDevice(aDevice);
       
  1512         MSwtImage* result  = NULL;
       
  1513         TRAPD(error, CallMethodL(result, display, &ASwtDisplayBase::NewImageFromThemeL, aId));
       
  1514         ThrowIfError(error, aJniEnv);
       
  1515 
       
  1516         INCREASE_INSTANCE_COUNT_USE_DISPLAY(result, Image, display);
       
  1517 
       
  1518         return reinterpret_cast<jint>(result);
       
  1519     }
       
  1520 
       
  1521     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Image_1Dispose(JNIEnv*, jclass, jint aDevice, jint aHandle)
       
  1522     {
       
  1523         CSwtDisplay* display = DisplayFromDevice(aDevice);
       
  1524         MSwtImage* image = reinterpret_cast<MSwtImage*>(aHandle);
       
  1525         CallMethod(image, &MSwtImage::Dispose, display);
       
  1526 
       
  1527         DECREASE_INSTANCE_COUNT_USE_DISPLAY(Image, display);
       
  1528     }
       
  1529 
       
  1530     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Image_1GetBounds(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  1531     {
       
  1532         const MSwtImage* image = reinterpret_cast<MSwtImage*>(aHandle);
       
  1533         TRect            result(TRect::EUninitialized);
       
  1534         CallMethod(result, image, &MSwtImage::GetBounds);
       
  1535         return NewJavaRectangle(aJniEnv, result);
       
  1536     }
       
  1537 
       
  1538     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Image_1GetData(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  1539     {
       
  1540         const MSwtImage* image = reinterpret_cast<MSwtImage*>(aHandle);
       
  1541         MSwtImageData* data = NULL;
       
  1542         TRAPD(error, CallMethodL(data, image, &MSwtImage::GetImageDataL));
       
  1543         if (data == NULL)
       
  1544         {
       
  1545             ThrowIfError(error, aJniEnv);
       
  1546             return NULL;
       
  1547         }
       
  1548 
       
  1549         jobject result = NewJavaImageData(aJniEnv, *data);
       
  1550         DeleteInUiHeap(data);
       
  1551         return result;
       
  1552     }
       
  1553 
       
  1554     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Image_1AddRef(JNIEnv *, jclass, jint aHandle)
       
  1555     {
       
  1556         ASSERT(aHandle);
       
  1557         const MSwtImage* image = reinterpret_cast<MSwtImage*>(aHandle);
       
  1558         CallMethod(static_cast<const MSwtRefCounted*>(image), &MSwtImage::AddRef);
       
  1559     }
       
  1560 
       
  1561     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Image_1RemoveRef(JNIEnv *, jclass, jint aHandle)
       
  1562     {
       
  1563         ASSERT(aHandle);
       
  1564         const MSwtImage* image = reinterpret_cast<MSwtImage*>(aHandle);
       
  1565         CallMethod(static_cast<const MSwtRefCounted*>(image), &MSwtImage::RemoveRef);
       
  1566     }
       
  1567 
       
  1568     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Image_1Scale(JNIEnv* aJniEnv, jclass,
       
  1569             jint aDevice, jint aHandle, jint aWidth, jint aHeight, jboolean aKeepAspectRatio)
       
  1570     {
       
  1571         ASwtDisplayBase* display = DisplayFromDevice(aDevice);
       
  1572         const MSwtImage* image = reinterpret_cast<MSwtImage*>(aHandle);
       
  1573         const TSize size(aWidth, aHeight);
       
  1574         MSwtImage* result  = NULL;
       
  1575         TRAPD(error, CallMethodL(result, display, &ASwtDisplayBase::ScaleImageL, *image, size, aKeepAspectRatio));
       
  1576         ThrowIfError(error, aJniEnv);
       
  1577 
       
  1578         INCREASE_INSTANCE_COUNT_USE_DISPLAY(result, Image, display);
       
  1579 
       
  1580         return reinterpret_cast<jint>(result);
       
  1581     }
       
  1582 
       
  1583     /*
       
  1584      * Class Menu
       
  1585      */
       
  1586     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Menu_1New(JNIEnv* aJniEnv, jclass, jobject aPeer, jint aStyle)
       
  1587     {
       
  1588         jweak peerRef = aJniEnv->NewWeakGlobalRef(aPeer);
       
  1589         if (peerRef == NULL)
       
  1590             return 0;
       
  1591 
       
  1592         CSwtDisplay& display = CSwtDisplay::Current();
       
  1593         MSwtMenu*    result  = NULL;
       
  1594         TRAPD(error, CallMethodL(result, &display.Factory(), &MSwtFactory::NewMenuL, display, peerRef, aStyle));
       
  1595         if (error)
       
  1596         {
       
  1597             aJniEnv->DeleteWeakGlobalRef(peerRef);
       
  1598             Throw(error, aJniEnv);
       
  1599         }
       
  1600 
       
  1601         INCREASE_INSTANCE_COUNT(result, Menu);
       
  1602 
       
  1603         return reinterpret_cast<jint>(result);
       
  1604     }
       
  1605 
       
  1606     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Menu_1Dispose(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  1607     {
       
  1608         MSwtMenu* menu = reinterpret_cast<MSwtMenu*>(aHandle);
       
  1609         TSwtPeer  peerRef;
       
  1610         CallMethod(peerRef, menu, &MSwtMenu::Dispose);
       
  1611 
       
  1612         ReleasePeer(aJniEnv, peerRef);
       
  1613 
       
  1614         DECREASE_INSTANCE_COUNT(Menu);
       
  1615     }
       
  1616 
       
  1617     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Menu_1SetEnabled(JNIEnv*, jclass, jint aHandle, jboolean aEnabled)
       
  1618     {
       
  1619         MSwtMenu* menu = reinterpret_cast<MSwtMenu*>(aHandle);
       
  1620         CallMethod(menu, &MSwtMenu::SetEnabled, aEnabled);
       
  1621     }
       
  1622 
       
  1623     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Menu_1SetVisible(JNIEnv*, jclass, jint aHandle, jboolean aVisible)
       
  1624     {
       
  1625         MSwtMenu* menu = reinterpret_cast<MSwtMenu*>(aHandle);
       
  1626         CallMethod(menu, &MSwtMenu::SetVisible, aVisible);
       
  1627     }
       
  1628 
       
  1629     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Menu_1SetDefaultItem
       
  1630     (JNIEnv *, jclass, jint aHandle, jint aMenuItemHandle)
       
  1631     {
       
  1632         MSwtMenu* menu = reinterpret_cast<MSwtMenu*>(aHandle);
       
  1633         MSwtMenuItem* menuItem = reinterpret_cast<MSwtMenuItem*>(aMenuItemHandle);
       
  1634         CallMethod(menu, &MSwtMenu::SetDefaultItem, menuItem);
       
  1635     }
       
  1636 
       
  1637     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Menu_1SetLocation(JNIEnv *, jclass, jint aHandle, jint aX, jint aY)
       
  1638     {
       
  1639         MSwtMenu* menu = reinterpret_cast<MSwtMenu*>(aHandle);
       
  1640         CallMethod(menu, &MSwtMenu::SetLocation, aX, aY);
       
  1641     }
       
  1642 
       
  1643 
       
  1644     /*
       
  1645      * Class MenuItem
       
  1646      */
       
  1647     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_MenuItem_1New(JNIEnv* aJniEnv, jclass, jobject aPeer, jint aParent, jint aIndex, jint aStyle)
       
  1648     {
       
  1649         jweak peerRef = aJniEnv->NewWeakGlobalRef(aPeer);
       
  1650         if (peerRef == NULL)
       
  1651             return 0;
       
  1652 
       
  1653         CSwtDisplay& display = CSwtDisplay::Current();
       
  1654         MSwtMenu* parent = reinterpret_cast<MSwtMenu*>(aParent);
       
  1655         MSwtMenuItem* result = NULL;
       
  1656         TRAPD(error, CallMethodL(result, &display.Factory(), &MSwtFactory::NewMenuItemL, display, peerRef, *parent, aIndex, aStyle));
       
  1657         if (error)
       
  1658         {
       
  1659             aJniEnv->DeleteWeakGlobalRef(peerRef);
       
  1660             Throw(error, aJniEnv);
       
  1661         }
       
  1662 
       
  1663         INCREASE_INSTANCE_COUNT(result, MenuItem);
       
  1664 
       
  1665         return reinterpret_cast<jint>(result);
       
  1666     }
       
  1667 
       
  1668     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_MenuItem_1Dispose(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  1669     {
       
  1670         MSwtMenuItem* menuItem = reinterpret_cast<MSwtMenuItem*>(aHandle);
       
  1671         TSwtPeer peerRef;
       
  1672         CallMethod(peerRef, menuItem, &MSwtMenuItem::Dispose);
       
  1673 
       
  1674         ReleasePeer(aJniEnv, peerRef);
       
  1675 
       
  1676         DECREASE_INSTANCE_COUNT(MenuItem);
       
  1677     }
       
  1678 
       
  1679     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_MenuItem_1GetSelection(JNIEnv*, jclass, jint aHandle)
       
  1680     {
       
  1681         const MSwtMenuItem* menuItem = reinterpret_cast<MSwtMenuItem*>(aHandle);
       
  1682         TBool result;
       
  1683         CallMethod(result, menuItem, &MSwtMenuItem::GetSelection);
       
  1684         return ConvertBoolean(result);
       
  1685     }
       
  1686 
       
  1687     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_MenuItem_1SetAccelerator(JNIEnv* aJniEnv, jclass, jint aHandle, jint aAccelerator)
       
  1688     {
       
  1689         MSwtMenuItem* menuItem = reinterpret_cast<MSwtMenuItem*>(aHandle);
       
  1690         TRAPD(error, CallMethodL(menuItem, &MSwtMenuItem::SetAcceleratorL, aAccelerator));
       
  1691         ThrowIfError(error, aJniEnv);
       
  1692     }
       
  1693 
       
  1694     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_MenuItem_1SetEnabled(JNIEnv*, jclass, jint aHandle, jboolean aEnabled)
       
  1695     {
       
  1696         MSwtMenuItem* menuItem = reinterpret_cast<MSwtMenuItem*>(aHandle);
       
  1697         CallMethod(menuItem, &MSwtMenuItem::SetEnabled, aEnabled);
       
  1698     }
       
  1699 
       
  1700     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_MenuItem_1SetImage(JNIEnv* aJniEnv, jclass, jint aHandle, jint aImageHandle)
       
  1701     {
       
  1702         MSwtMenuItem* menuItem = reinterpret_cast<MSwtMenuItem*>(aHandle);
       
  1703         MSwtImage* image = reinterpret_cast<MSwtImage*>(aImageHandle);
       
  1704         TRAPD(error, CallMethodL(menuItem, &MSwtMenuItem::SetImageL, image));
       
  1705         ThrowIfError(error, aJniEnv);
       
  1706     }
       
  1707 
       
  1708     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_MenuItem_1SetMenu(JNIEnv* aJniEnv, jclass, jint aHandle, jint aMenuHandle)
       
  1709     {
       
  1710         MSwtMenuItem* menuItem = reinterpret_cast<MSwtMenuItem*>(aHandle);
       
  1711         MSwtMenu* menu = reinterpret_cast<MSwtMenu*>(aMenuHandle);
       
  1712         TRAPD(error, CallMethodL(menuItem, &MSwtMenuItem::SetMenuL, menu));
       
  1713         ThrowIfError(error, aJniEnv);
       
  1714     }
       
  1715 
       
  1716     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_MenuItem_1SetSelection(JNIEnv*, jclass, jint aHandle, jboolean aSelected)
       
  1717     {
       
  1718         MSwtMenuItem* menuItem = reinterpret_cast<MSwtMenuItem*>(aHandle);
       
  1719         CallMethod(menuItem, &MSwtMenuItem::SetSelection, aSelected);
       
  1720     }
       
  1721 
       
  1722     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_MenuItem_1SetText(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aText)
       
  1723     {
       
  1724         CallTextMethodThrow(aJniEnv, aHandle, &MSwtMenuItem::SetTextL, aText);
       
  1725     }
       
  1726 
       
  1727     static void MessageBox_OpenL(JNIEnv* aJniEnv, TSwtPeer aPeer,
       
  1728                                  const jstring aTitle, const jstring aMessage, TInt aStyle)
       
  1729     {
       
  1730         HBufC* message = ConvertStringLC(aJniEnv, aMessage);
       
  1731         HBufC* title   = ConvertStringLC(aJniEnv, aTitle);
       
  1732 
       
  1733         CSwtDisplay& display = CSwtDisplay::Current();
       
  1734 
       
  1735         display.RequestRunDialogL(aPeer, CSwtDialogBroker::EMessageBox, aStyle, *title, *message);
       
  1736 
       
  1737         CleanupStack::PopAndDestroy(2, message);
       
  1738     }
       
  1739 
       
  1740     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_MessageBox_1Open(
       
  1741         JNIEnv* aJniEnv,
       
  1742         jclass,
       
  1743         jobject aPeer,
       
  1744         jstring aTitle,
       
  1745         jstring aMessage,
       
  1746         jint aStyle)
       
  1747     {
       
  1748         TRAPD(error, MessageBox_OpenL(aJniEnv, reinterpret_cast<TSwtPeer>(aPeer), aTitle, aMessage, aStyle));
       
  1749         ThrowIfError(error, aJniEnv);
       
  1750     }
       
  1751 
       
  1752 
       
  1753     /*
       
  1754      * Class Scrollable
       
  1755      */
       
  1756     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Scrollable_1ControlHandle(JNIEnv*, jclass, jint aHandle)
       
  1757     {
       
  1758         MSwtScrollable* scrollable = reinterpret_cast<MSwtScrollable*>(aHandle);
       
  1759         MSwtControl*    result;
       
  1760         CallMethod(result, scrollable, &MSwtScrollable::Control);
       
  1761         return reinterpret_cast<jint>(result);
       
  1762     }
       
  1763 
       
  1764     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Scrollable_1CreateScrollBar(JNIEnv* aJniEnv, jclass, jint aHandle, jobject aPeer, jint aStyle)
       
  1765     {
       
  1766         jweak peerRef = aJniEnv->NewWeakGlobalRef(aPeer);
       
  1767         if (peerRef == NULL)
       
  1768             return 0;
       
  1769 
       
  1770         MSwtScrollable* scrollable = reinterpret_cast<MSwtScrollable*>(aHandle);
       
  1771         MSwtScrollBar*  result     = NULL;
       
  1772         TRAPD(error, CallMethodL(result, scrollable, &MSwtScrollable::CreateScrollBarL, peerRef, aStyle));
       
  1773         if (error)
       
  1774         {
       
  1775             aJniEnv->DeleteWeakGlobalRef(peerRef);
       
  1776             Throw(error, aJniEnv);
       
  1777         }
       
  1778 
       
  1779         INCREASE_INSTANCE_COUNT(result, ScrollBar);
       
  1780 
       
  1781         return reinterpret_cast<jint>(result);
       
  1782     }
       
  1783 
       
  1784     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Scrollable_1SetVisibleScrollBar(JNIEnv* /*aJniEnv*/, jclass, jint aHandle, jint aStyle, jboolean aVisible)
       
  1785     {
       
  1786         MSwtScrollable* scrollable = reinterpret_cast<MSwtScrollable*>(aHandle);
       
  1787         CallMethod(scrollable, &MSwtScrollable::SetVisibleScrollBar, aStyle, aVisible);
       
  1788     }
       
  1789 
       
  1790     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Scrollable_1ComputeTrim(JNIEnv* aJniEnv, jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight)
       
  1791     {
       
  1792         const MSwtScrollable* scrollable = reinterpret_cast<MSwtScrollable*>(aHandle);
       
  1793         TRect           rect(TPoint(aX,aY), TSize(aWidth,aHeight));
       
  1794         CallMethod(scrollable, &MSwtScrollable::ComputeTrim, rect);
       
  1795         return NewJavaRectangle(aJniEnv, rect);
       
  1796     }
       
  1797 
       
  1798 
       
  1799     /*
       
  1800      * Class ScrollBar
       
  1801      */
       
  1802     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1Dispose(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  1803     {
       
  1804         MSwtScrollBar* scrollbar = reinterpret_cast<MSwtScrollBar*>(aHandle);
       
  1805         TSwtPeer       peerRef;
       
  1806         CallMethod(peerRef, scrollbar, &MSwtScrollBar::Dispose);
       
  1807 
       
  1808         ReleasePeer(aJniEnv, peerRef);
       
  1809 
       
  1810         DECREASE_INSTANCE_COUNT(ScrollBar);
       
  1811     }
       
  1812 
       
  1813     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1GetSize(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  1814     {
       
  1815         const MSwtScrollBar* scrollbar = reinterpret_cast<MSwtScrollBar*>(aHandle);
       
  1816         TSize result(TSize::EUninitialized);
       
  1817         CallMethod(result, scrollbar, &MSwtScrollBar::GetSize);
       
  1818         return NewJavaPoint(aJniEnv, result.AsPoint());
       
  1819     }
       
  1820 
       
  1821     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1SetEnabled(JNIEnv*, jclass, jint aHandle, jboolean aEnabled)
       
  1822     {
       
  1823         MSwtScrollBar* scrollbar = reinterpret_cast<MSwtScrollBar*>(aHandle);
       
  1824         CallMethod(scrollbar, &MSwtScrollBar::SetEnabled, aEnabled);
       
  1825     }
       
  1826 
       
  1827     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1SetVisible(JNIEnv*, jclass, jint aHandle, jboolean aVisible)
       
  1828     {
       
  1829         MSwtScrollBar* scrollbar = reinterpret_cast<MSwtScrollBar*>(aHandle);
       
  1830         CallMethod(scrollbar, &MSwtScrollBar::SetVisible, aVisible);
       
  1831     }
       
  1832 
       
  1833     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1GetThumbPosition(JNIEnv*, jclass, jint aHandle)
       
  1834     {
       
  1835         return CallNonLeavingGetter(aHandle, &MSwtScrollBar::GetThumbPosition);
       
  1836     }
       
  1837 
       
  1838     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1SetThumbPosition(JNIEnv* aJniEnv, jclass, jint aHandle, jint aPosition)
       
  1839     {
       
  1840         MSwtScrollBar* scrollbar = reinterpret_cast<MSwtScrollBar*>(aHandle);
       
  1841         TRAPD(error, CallMethodL(scrollbar, &MSwtScrollBar::SetThumbPositionL, aPosition));
       
  1842         ThrowIfError(error, aJniEnv);
       
  1843     }
       
  1844 
       
  1845     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1GetThumbSpan(JNIEnv*, jclass, jint aHandle)
       
  1846     {
       
  1847         return CallNonLeavingGetter(aHandle, &MSwtScrollBar::GetThumbSpan);
       
  1848     }
       
  1849 
       
  1850     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1SetThumbSpan(JNIEnv* aJniEnv, jclass, jint aHandle, jint aSpan)
       
  1851     {
       
  1852         MSwtScrollBar* scrollbar = reinterpret_cast<MSwtScrollBar*>(aHandle);
       
  1853         TRAPD(error, CallMethodL(scrollbar, &MSwtScrollBar::SetThumbSpanL, aSpan));
       
  1854         ThrowIfError(error, aJniEnv);
       
  1855     }
       
  1856 
       
  1857     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1GetMinimum(JNIEnv*, jclass, jint aHandle)
       
  1858     {
       
  1859         return CallNonLeavingGetter(aHandle, &MSwtScrollBar::GetMinimum);
       
  1860     }
       
  1861 
       
  1862     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1SetMinimum(JNIEnv* aJniEnv, jclass, jint aHandle, jint aMinimum)
       
  1863     {
       
  1864         MSwtScrollBar* scrollbar = reinterpret_cast<MSwtScrollBar*>(aHandle);
       
  1865         TRAPD(error, CallMethodL(scrollbar, &MSwtScrollBar::SetMinimumL, aMinimum));
       
  1866         ThrowIfError(error, aJniEnv);
       
  1867     }
       
  1868 
       
  1869     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1GetMaximum(JNIEnv*, jclass, jint aHandle)
       
  1870     {
       
  1871         return CallNonLeavingGetter(aHandle, &MSwtScrollBar::GetMaximum);
       
  1872     }
       
  1873 
       
  1874     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1SetMaximum(JNIEnv* aJniEnv, jclass, jint aHandle, jint aMaximum)
       
  1875     {
       
  1876         MSwtScrollBar* scrollbar = reinterpret_cast<MSwtScrollBar*>(aHandle);
       
  1877         TRAPD(error, CallMethodL(scrollbar, &MSwtScrollBar::SetMaximumL, aMaximum));
       
  1878         ThrowIfError(error, aJniEnv);
       
  1879     }
       
  1880 
       
  1881     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1GetIncrement(JNIEnv*, jclass, jint aHandle)
       
  1882     {
       
  1883         return CallNonLeavingGetter(aHandle, &MSwtScrollBar::GetIncrement);
       
  1884     }
       
  1885 
       
  1886     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1SetIncrement(JNIEnv* , jclass, jint aHandle, jint aIncrement)
       
  1887     {
       
  1888         MSwtScrollBar* scrollbar = reinterpret_cast<MSwtScrollBar*>(aHandle);
       
  1889         CallMethod(scrollbar, &MSwtScrollBar::SetIncrement, aIncrement);
       
  1890     }
       
  1891 
       
  1892     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1GetPageIncrement(JNIEnv*, jclass, jint aHandle)
       
  1893     {
       
  1894         return CallNonLeavingGetter(aHandle, &MSwtScrollBar::GetPageIncrement);
       
  1895     }
       
  1896 
       
  1897     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1SetPageIncrement(JNIEnv* , jclass, jint aHandle, jint aPageIncrement)
       
  1898     {
       
  1899         MSwtScrollBar* scrollbar = reinterpret_cast<MSwtScrollBar*>(aHandle);
       
  1900         CallMethod(scrollbar, &MSwtScrollBar::SetPageIncrement, aPageIncrement);
       
  1901     }
       
  1902 
       
  1903     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ScrollBar_1SetValues(JNIEnv* aJniEnv, jclass, jint aHandle, jint aSelection, jint aMinimum, jint aMaximum, jint aThumb, jint aIncrement, jint aPageIncrement)
       
  1904     {
       
  1905         MSwtScrollBar* scrollbar = reinterpret_cast<MSwtScrollBar*>(aHandle);
       
  1906         TRAPD(error, CallMethodL(scrollbar, &MSwtScrollBar::SetValuesL, aSelection, aMinimum, aMaximum, aThumb, aIncrement, aPageIncrement));
       
  1907         ThrowIfError(error, aJniEnv);
       
  1908     }
       
  1909 
       
  1910 
       
  1911     /*
       
  1912      * Class Shell
       
  1913      */
       
  1914     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Shell_1New
       
  1915     (JNIEnv* aJniEnv, jclass, jobject aPeer, jint aParent, jint aStyle)
       
  1916     {
       
  1917         jweak peerRef = aJniEnv->NewWeakGlobalRef(aPeer);
       
  1918         if (peerRef == NULL)
       
  1919             return 0;
       
  1920 
       
  1921         CSwtDisplay& display = CSwtDisplay::Current();
       
  1922         MSwtShell*   parent  = reinterpret_cast<MSwtShell*>(aParent);
       
  1923         MSwtShell*   result  = NULL;
       
  1924         TRAPD(error, CallMethodL(result, &display.Factory(),
       
  1925                                  &MSwtFactory::NewShellL, display, peerRef, parent, aStyle));
       
  1926         if (error)
       
  1927         {
       
  1928             aJniEnv->DeleteWeakGlobalRef(peerRef);
       
  1929             Throw(error, aJniEnv);
       
  1930         }
       
  1931 
       
  1932         INCREASE_INSTANCE_COUNT(result, Shell);
       
  1933 
       
  1934         return reinterpret_cast<jint>(result);
       
  1935     }
       
  1936 
       
  1937     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Shell_1DecorationsHandle(
       
  1938         JNIEnv*, jclass, jint aHandle)
       
  1939     {
       
  1940         MSwtShell*       shell = reinterpret_cast<MSwtShell*>(aHandle);
       
  1941         MSwtDecorations* result;
       
  1942         CallMethod(result, shell, &MSwtShell::Decorations);
       
  1943         return reinterpret_cast<jint>(result);
       
  1944     }
       
  1945 
       
  1946     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Shell_1ForceActive(
       
  1947         JNIEnv*, jclass, jint aHandle)
       
  1948     {
       
  1949         MSwtShell* shell = reinterpret_cast<MSwtShell*>(aHandle);
       
  1950         CallMethod(shell, &MSwtShell::ForceActive);
       
  1951     }
       
  1952 
       
  1953     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Shell_1GetImeInputMode(
       
  1954         JNIEnv*, jclass, jint aHandle)
       
  1955     {
       
  1956         const MSwtShell* shell = reinterpret_cast<MSwtShell*>(aHandle);
       
  1957         TInt imeInputMode(0);
       
  1958 
       
  1959         CallMethod(imeInputMode,shell, &MSwtShell::GetImeInputMode);
       
  1960         return imeInputMode;
       
  1961     }
       
  1962 
       
  1963     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Shell_1GetMinimumSize(
       
  1964         JNIEnv* aJniEnv, jclass, jint aHandle)
       
  1965     {
       
  1966         const MSwtShell* shell = reinterpret_cast<MSwtShell*>(aHandle);
       
  1967         TSize minimumSize(TSize::EUninitialized);
       
  1968         CallMethod(minimumSize,shell, &MSwtShell::GetMinimumSize);
       
  1969         return NewJavaPoint(aJniEnv, minimumSize.AsPoint());
       
  1970     }
       
  1971 
       
  1972     JNIEXPORT jobjectArray JNICALL Java_org_eclipse_swt_internal_symbian_OS_Shell_1GetShells(
       
  1973         JNIEnv* aJniEnv, jclass, jint aHandle)
       
  1974     {
       
  1975         MSwtShell* shell = reinterpret_cast<MSwtShell*>(aHandle);
       
  1976         CSwtPeerArray* children  = NULL;
       
  1977         TRAPD(error, CallMethodL(children, shell, &MSwtShell::GetChildShellsPeersL));
       
  1978         if (error)
       
  1979         {
       
  1980             Throw(error, aJniEnv);
       
  1981             return NULL;
       
  1982         }
       
  1983 
       
  1984         jobjectArray result = NewJavaObjectArray(aJniEnv, children, "org/eclipse/swt/widgets/Shell");
       
  1985         DeleteInUiHeap(children);
       
  1986         return result;
       
  1987     }
       
  1988 
       
  1989     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Shell_1SetMinimumSize(
       
  1990         JNIEnv*, jclass, jint aHandle, jint aWidth, jint aHeight)
       
  1991     {
       
  1992         MSwtShell* shell = reinterpret_cast<MSwtShell*>(aHandle);
       
  1993         TSize minimumSize(aWidth,aHeight);
       
  1994         CallMethod(shell, &MSwtShell::SetMinimumSize, minimumSize);
       
  1995     }
       
  1996 
       
  1997     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Shell_1SetImeInputMode(
       
  1998         JNIEnv*, jclass, jint aHandle, jint aInputMode)
       
  1999     {
       
  2000         MSwtShell* shell = reinterpret_cast<MSwtShell*>(aHandle);
       
  2001         CallMethod(shell, &MSwtShell::SetImeInputMode, aInputMode);
       
  2002     }
       
  2003 
       
  2004     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Shell_1GetDefaultBounds(
       
  2005         JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2006     {
       
  2007         MSwtShell* shell = reinterpret_cast<MSwtShell*>(aHandle);
       
  2008         TRect rect(TRect::EUninitialized);
       
  2009         CallMethod(rect, shell, &MSwtShell::DefaultBounds);
       
  2010         return NewJavaRectangle(aJniEnv, rect);
       
  2011     }
       
  2012 
       
  2013     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Shell_1SetAsyncPainting(
       
  2014         JNIEnv*, jclass, jint aHandle, jboolean aStatus)
       
  2015     {
       
  2016         MSwtShell* shell = reinterpret_cast<MSwtShell*>(aHandle);
       
  2017         CallMethod(shell, &MSwtShell::SetAsyncPainting, aStatus);
       
  2018     }
       
  2019 
       
  2020     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Shell_1SetTaskTip(
       
  2021         JNIEnv*, jclass, jint aHandle)
       
  2022     {
       
  2023         MSwtShell* shell = reinterpret_cast<MSwtShell*>(aHandle);
       
  2024         CallMethod(shell, &MSwtShell::SetTaskTip);
       
  2025     }
       
  2026 
       
  2027 
       
  2028     /*
       
  2029      * Class Label
       
  2030      */
       
  2031     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Label_1ControlHandle(JNIEnv*, jclass, jint aHandle)
       
  2032     {
       
  2033         MSwtLabel* label = reinterpret_cast<MSwtLabel*>(aHandle);
       
  2034         MSwtControl*    result;
       
  2035         CallMethod(result, label, &MSwtLabel::Control);
       
  2036         return reinterpret_cast<jint>(result);
       
  2037     }
       
  2038 
       
  2039     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Label_1New(JNIEnv* aJniEnv, jclass, jobject aPeer, jint aParent, jint aStyle)
       
  2040     {
       
  2041         jint handle = NewCoreWidget(aJniEnv, &MSwtFactory::NewLabelL, aPeer, aParent, aStyle);
       
  2042         INCREASE_INSTANCE_COUNT(handle, Label);
       
  2043         return handle;
       
  2044     }
       
  2045 
       
  2046     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Label_1GetAlignment(JNIEnv* /*aJniEnv*/, jclass, jint aHandle)
       
  2047     {
       
  2048         const MSwtLabel* theLabel = reinterpret_cast<MSwtLabel*>(aHandle);
       
  2049         TInt result;
       
  2050         CallMethod(result, theLabel, &MSwtLabel::GetAlignment);
       
  2051         return result;
       
  2052     }
       
  2053 
       
  2054     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Label_1SetAlignment(JNIEnv* /*aJniEnv*/, jclass , jint aHandle, jint aAlignment)
       
  2055     {
       
  2056         MSwtLabel* theLabel = reinterpret_cast<MSwtLabel*>(aHandle);
       
  2057         CallMethod(theLabel, &MSwtLabel::SetAlignment, aAlignment);
       
  2058     }
       
  2059 
       
  2060     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Label_1SetImage(JNIEnv* aJniEnv, jclass, jint aHandle, jint aHandleImage)
       
  2061     {
       
  2062         MSwtLabel* theControl = reinterpret_cast<MSwtLabel*>(aHandle);
       
  2063         MSwtImage* image = reinterpret_cast<MSwtImage*>(aHandleImage);
       
  2064         TRAPD(error, CallMethodL(theControl, &MSwtLabel::SetImageL, image));
       
  2065         ThrowIfError(error, aJniEnv);
       
  2066     }
       
  2067 
       
  2068     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Label_1SetText(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aString)
       
  2069     {
       
  2070         CallTextMethodThrow(aJniEnv, aHandle, &MSwtLabel::SetTextL, aString);
       
  2071     }
       
  2072 
       
  2073 
       
  2074     /*
       
  2075      * Class Button
       
  2076      */
       
  2077     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Button_1ControlHandle(JNIEnv*, jclass, jint aHandle)
       
  2078     {
       
  2079         MSwtButton* theButton = reinterpret_cast<MSwtButton*>(aHandle);
       
  2080         MSwtControl*    result;
       
  2081         CallMethod(result, theButton, &MSwtButton::Control);
       
  2082         return reinterpret_cast<jint>(result);
       
  2083     }
       
  2084 
       
  2085     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Button_1New(JNIEnv* aJniEnv, jclass, jobject aPeer, jint aParent, jint aStyle)
       
  2086     {
       
  2087         jint handle = NewCoreWidget(aJniEnv, &MSwtFactory::NewButtonL, aPeer, aParent, aStyle);
       
  2088         INCREASE_INSTANCE_COUNT(handle, Button);
       
  2089         return handle;
       
  2090     }
       
  2091 
       
  2092     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Button_1GetSelection(JNIEnv* /*aJniEnv*/, jclass, jint aHandle)
       
  2093     {
       
  2094         TBool selection = EFalse;
       
  2095         const MSwtButton* theButton = reinterpret_cast<MSwtButton*>(aHandle);
       
  2096         CallMethod(selection, theButton, &MSwtButton::GetSelection);
       
  2097         return ConvertBoolean(selection);
       
  2098     }
       
  2099 
       
  2100     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Button_1SetSelection(JNIEnv* /*aJniEnv*/, jclass, jint aHandle, jboolean aActivedState)
       
  2101     {
       
  2102         MSwtButton* theButton = reinterpret_cast<MSwtButton*>(aHandle);
       
  2103         CallMethod(theButton, &MSwtButton::SetSelection, aActivedState);
       
  2104     }
       
  2105 
       
  2106     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Button_1GetAlignment(JNIEnv* /*aJniEnv*/, jclass, jint aHandle)
       
  2107     {
       
  2108         TInt result;
       
  2109         const MSwtButton* theButton = reinterpret_cast<MSwtButton*>(aHandle);
       
  2110         CallMethod(result, theButton, &MSwtButton::GetAlignment);
       
  2111         return result;
       
  2112     }
       
  2113 
       
  2114     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Button_1SetAlignment(JNIEnv* /*aJniEnv*/, jclass , jint aHandle, jint aAlignment)
       
  2115     {
       
  2116         MSwtButton* theButton = reinterpret_cast<MSwtButton*>(aHandle);
       
  2117         CallMethod(theButton, &MSwtButton::SetAlignment, aAlignment);
       
  2118     }
       
  2119 
       
  2120     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Button_1SetImage(JNIEnv* aJniEnv, jclass, jint aHandle, jint aHandleImage)
       
  2121     {
       
  2122         MSwtButton* theButton = reinterpret_cast<MSwtButton*>(aHandle);
       
  2123         MSwtImage* image = reinterpret_cast<MSwtImage*>(aHandleImage);
       
  2124         TRAPD(error, CallMethodL(theButton, &MSwtButton::SetImageL, image));
       
  2125         ThrowIfError(error, aJniEnv);
       
  2126     }
       
  2127 
       
  2128     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Button_1SetText(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aString)
       
  2129     {
       
  2130         CallTextMethodThrow(aJniEnv, aHandle, &MSwtButton::SetTextL, aString);
       
  2131     }
       
  2132 
       
  2133     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Button_1SetDefault(JNIEnv *, jclass, jint aHandle, jboolean aIsDefault)
       
  2134     {
       
  2135         MSwtButton* theButton = reinterpret_cast<MSwtButton*>(aHandle);
       
  2136         CallMethod(theButton, &MSwtButton::SetDefault, aIsDefault);
       
  2137     }
       
  2138 
       
  2139     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Button_1Click(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2140     {
       
  2141         MSwtButton* theButton = reinterpret_cast<MSwtButton*>(aHandle);
       
  2142         TRAPD(error, CallMethodL(theButton, &MSwtButton::ClickL));
       
  2143         ThrowIfError(error, aJniEnv);
       
  2144     }
       
  2145 
       
  2146 
       
  2147     /*
       
  2148      * Class Link
       
  2149      */
       
  2150 
       
  2151     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Link_1ControlHandle(
       
  2152         JNIEnv*,
       
  2153         jclass,
       
  2154         jint aHandle)
       
  2155     {
       
  2156         MSwtLink* link = reinterpret_cast<MSwtLink*>(aHandle);
       
  2157         MSwtControl*    result;
       
  2158         CallMethod(result, link, &MSwtLink::Control);
       
  2159         return reinterpret_cast<jint>(result);
       
  2160     }
       
  2161 
       
  2162     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Link_1New(
       
  2163         JNIEnv* aJniEnv,
       
  2164         jclass,
       
  2165         jobject aPeer,
       
  2166         jint aParent,
       
  2167         jint aStyle)
       
  2168     {
       
  2169         jint handle = NewCoreWidget(aJniEnv, &MSwtFactory::NewLinkL, aPeer, aParent, aStyle);
       
  2170         INCREASE_INSTANCE_COUNT(handle, Link);
       
  2171         return handle;
       
  2172     }
       
  2173 
       
  2174     static void Link_SetTextL(
       
  2175         JNIEnv* aJniEnv,
       
  2176         jint aHandle,
       
  2177         jobjectArray aTextFragments,
       
  2178         jobjectArray aLinkTargets)
       
  2179     {
       
  2180         MSwtLink* link = reinterpret_cast<MSwtLink*>(aHandle);
       
  2181         CDesCArray* fragments = ConvertStringArrayL(aJniEnv, aTextFragments);
       
  2182         CleanupStack::PushL(fragments);
       
  2183         CDesCArray* targets = ConvertStringArrayL(aJniEnv, aLinkTargets);
       
  2184         CleanupStack::PushL(targets);
       
  2185         CallMethodL(link, &MSwtLink::SetLinkDataL, fragments, targets);
       
  2186         CleanupStack::PopAndDestroy(targets);
       
  2187         CleanupStack::PopAndDestroy(fragments);
       
  2188     }
       
  2189 
       
  2190     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Link_1SetText(
       
  2191         JNIEnv* aJniEnv,
       
  2192         jclass,
       
  2193         jint aHandle,
       
  2194         jobjectArray aTextFragments,
       
  2195         jobjectArray aLinkTargets)
       
  2196     {
       
  2197         TRAPD(result, Link_SetTextL(aJniEnv, aHandle,
       
  2198                                     aTextFragments, aLinkTargets));
       
  2199         ThrowIfError(result, aJniEnv);
       
  2200     }
       
  2201 
       
  2202     /*
       
  2203      * Class List
       
  2204      */
       
  2205     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1New(JNIEnv* aJniEnv, jclass, jobject aPeer, jint aParent, jint aStyle)
       
  2206     {
       
  2207         jint handle = NewCoreWidget(aJniEnv, &MSwtFactory::NewListL, aPeer, aParent, aStyle);
       
  2208         INCREASE_INSTANCE_COUNT(handle, List);
       
  2209         return handle;
       
  2210     }
       
  2211 
       
  2212     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1ScrollableHandle(JNIEnv*, jclass, jint aHandle)
       
  2213     {
       
  2214         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2215         MSwtScrollable*      result;
       
  2216         CallMethod(result, theList, &MSwtList::Scrollable);
       
  2217         return reinterpret_cast<jint>(result);
       
  2218     }
       
  2219 
       
  2220     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1Add__ILjava_lang_String_2(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aString)
       
  2221     {
       
  2222         CallTextMethodThrow(aJniEnv, aHandle, &MSwtList::AppendL, aString);
       
  2223     }
       
  2224 
       
  2225     static void List_AddL(JNIEnv* aJniEnv, MSwtList* aList, const jstring aString, TInt aIndex)
       
  2226     {
       
  2227         HBufC* text = ConvertStringLC(aJniEnv, aString);
       
  2228         CallMethodL(aList, &MSwtList::InsertL, aIndex, *text);
       
  2229         CleanupStack::PopAndDestroy(text);
       
  2230     }
       
  2231 
       
  2232     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1Add__ILjava_lang_String_2I(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aString, jint aIndex)
       
  2233     {
       
  2234         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2235         TRAPD(error, List_AddL(aJniEnv, theList, aString, aIndex));
       
  2236         ThrowIfError(error, aJniEnv);
       
  2237     }
       
  2238 
       
  2239     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1Deselect__I_3I(JNIEnv* aJniEnv, jclass, jint aHandle, jintArray aIndices)
       
  2240     {
       
  2241         TInt* ints = NULL;
       
  2242         TInt count = JavaIntsToInts(aJniEnv, aIndices, ints);
       
  2243         if (count == 0)
       
  2244             return;
       
  2245 
       
  2246         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2247         CallMethod(theList, &MSwtList::DeselectItems, ints, count);
       
  2248         delete[] ints;
       
  2249     }
       
  2250 
       
  2251     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1Deselect__II(JNIEnv*, jclass, jint aHandle, jint aIndex)
       
  2252     {
       
  2253         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2254         CallMethod(theList, &MSwtList::DeselectItem, aIndex);
       
  2255     }
       
  2256 
       
  2257     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1Deselect__III(JNIEnv*, jclass, jint aHandle, jint aStart, jint aEnd)
       
  2258     {
       
  2259         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2260         CallMethod(theList, &MSwtList::DeselectRange, aStart, aEnd);
       
  2261     }
       
  2262 
       
  2263     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1DeselectAll(JNIEnv*, jclass, jint aHandle)
       
  2264     {
       
  2265         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2266         CallMethod(theList, &MSwtList::DeselectAll);
       
  2267     }
       
  2268 
       
  2269     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1GetFocusIndex(JNIEnv*, jclass, jint aHandle)
       
  2270     {
       
  2271         const MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2272         TInt result = 0;
       
  2273         CallMethod(result, theList, &MSwtList::GetFocusIndex);
       
  2274         return result;
       
  2275     }
       
  2276 
       
  2277     JNIEXPORT jstring JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1GetItem(JNIEnv* aJniEnv, jclass, jint aHandle, jint aIndex)
       
  2278     {
       
  2279         const MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2280         TPtrC result;
       
  2281         TRAPD(error, CallMethodL(theList, &MSwtList::GetItemL, aIndex, result));
       
  2282         if (error == KErrNone)
       
  2283         {
       
  2284             return NewJavaString(aJniEnv, result);
       
  2285         }
       
  2286         else
       
  2287         {
       
  2288             Throw(error, aJniEnv);
       
  2289             return 0;
       
  2290         }
       
  2291     }
       
  2292 
       
  2293     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1GetItemCount(JNIEnv*, jclass, jint aHandle)
       
  2294     {
       
  2295         const MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2296         TInt result = 0;
       
  2297         CallMethod(result, theList, &MSwtList::GetItemCount);
       
  2298         return result;
       
  2299     }
       
  2300 
       
  2301     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1GetItemHeight(JNIEnv*, jclass, jint aHandle)
       
  2302     {
       
  2303         const MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2304         TInt result = 0;
       
  2305         CallMethod(result, theList, &MSwtList::GetItemHeight);
       
  2306         return result;
       
  2307     }
       
  2308 
       
  2309     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1GetSelectionCount(JNIEnv*, jclass, jint aHandle)
       
  2310     {
       
  2311         const MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2312         TInt result;
       
  2313         CallMethod(result, theList, &MSwtList::GetSelectionCount);
       
  2314         return result;
       
  2315     }
       
  2316 
       
  2317     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1GetSelectionIndex(JNIEnv*, jclass, jint aHandle)
       
  2318     {
       
  2319         const MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2320         TInt result;
       
  2321         CallMethod(result, theList, &MSwtList::GetSelectionIndex);
       
  2322         return result;
       
  2323     }
       
  2324 
       
  2325     JNIEXPORT jintArray JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1GetSelectionIndices(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2326     {
       
  2327         const MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2328         const CArrayFix<TInt>* selectionArray;
       
  2329         CallMethod(selectionArray, theList, &MSwtList::GetSelectionIndices);
       
  2330         TInt count = (selectionArray!=NULL) ? selectionArray->Count() : 0;
       
  2331         jintArray result = aJniEnv->NewIntArray(count);
       
  2332         if (!result)
       
  2333         {
       
  2334             return NULL;
       
  2335         }
       
  2336 
       
  2337         for (TInt i=0; i<count; ++i)
       
  2338         {
       
  2339             TInt value = (*selectionArray)[i]; //lint !e613
       
  2340             aJniEnv->SetIntArrayRegion(result, i, 1, &value);
       
  2341         }
       
  2342         return result;
       
  2343     }
       
  2344 
       
  2345     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1GetTopIndex(JNIEnv*, jclass, jint aHandle)
       
  2346     {
       
  2347         const MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2348         TInt result;
       
  2349         CallMethod(result, theList, &MSwtList::GetTopIndex);
       
  2350         return result;
       
  2351     }
       
  2352 
       
  2353     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1IndexOf(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aString, jint aStart)
       
  2354     {
       
  2355         HBufC* string = NULL;
       
  2356         TRAPD(error, (string=ConvertStringL(aJniEnv, aString)));
       
  2357         if (string == NULL)
       
  2358         {
       
  2359             Throw(error, aJniEnv);
       
  2360             return 0;
       
  2361         }
       
  2362 
       
  2363         const MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2364         TInt result;
       
  2365         CallMethod(result, theList, &MSwtList::IndexOf, *string, aStart);
       
  2366         delete string;
       
  2367         return result;
       
  2368     }
       
  2369 
       
  2370     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1IsSelected(JNIEnv*, jclass, jint aHandle, jint aIndex)
       
  2371     {
       
  2372         const MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2373         TBool result = EFalse;
       
  2374         CallMethod(result, theList, &MSwtList::IsSelected, aIndex);
       
  2375         return ConvertBoolean(result);
       
  2376     }
       
  2377 
       
  2378     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1Remove__I_3I(JNIEnv* aJniEnv, jclass, jint aHandle, jintArray aIndices)
       
  2379     {
       
  2380         TInt* ints = NULL;
       
  2381         TInt count = JavaIntsToInts(aJniEnv, aIndices, ints);
       
  2382         if (count == 0)
       
  2383             return;
       
  2384 
       
  2385         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2386         TRAPD(error, CallMethodL(theList, &MSwtList::RemoveItemsL, ints, count));
       
  2387         ThrowIfError(error, aJniEnv);
       
  2388         delete[] ints;
       
  2389     }
       
  2390 
       
  2391     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1Remove__II(JNIEnv* aJniEnv, jclass, jint aHandle, jint aIndex)
       
  2392     {
       
  2393         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2394         TRAPD(error, CallMethodL(theList, &MSwtList::RemoveItemL, aIndex));
       
  2395         ThrowIfError(error, aJniEnv);
       
  2396     }
       
  2397 
       
  2398     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1Remove__III(JNIEnv* aJniEnv, jclass, jint aHandle, jint aStart, jint aEnd)
       
  2399     {
       
  2400         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2401         TRAPD(error, CallMethodL(theList, &MSwtList::RemoveRangeL, aStart, aEnd));
       
  2402         ThrowIfError(error, aJniEnv);
       
  2403     }
       
  2404 
       
  2405     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1RemoveAll(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2406     {
       
  2407         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2408         TRAPD(error, CallMethodL(theList, &MSwtList::RemoveAllL));
       
  2409         ThrowIfError(error, aJniEnv);
       
  2410     }
       
  2411 
       
  2412     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1Select__IIZ(JNIEnv* aJniEnv, jclass, jint aHandle, jint aIndex, jboolean aScroll)
       
  2413     {
       
  2414         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2415         TRAPD(error, CallMethodL(theList, &MSwtList::SelectItemL, aIndex, aScroll));
       
  2416         ThrowIfError(error, aJniEnv);
       
  2417     }
       
  2418 
       
  2419     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1Select__III(JNIEnv* aJniEnv, jclass, jint aHandle, jint aStart, jint aEnd)
       
  2420     {
       
  2421         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2422         TRAPD(error, CallMethodL(theList, &MSwtList::SelectRangeL, aStart, aEnd));
       
  2423         ThrowIfError(error, aJniEnv);
       
  2424     }
       
  2425 
       
  2426     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1SelectAll(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2427     {
       
  2428         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2429         TRAPD(error, CallMethodL(theList, &MSwtList::SelectAllL));
       
  2430         ThrowIfError(error, aJniEnv);
       
  2431     }
       
  2432 
       
  2433     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1SetFocusIndex(JNIEnv*, jclass, jint aHandle, jint aIndex)
       
  2434     {
       
  2435         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2436         CallMethod(theList, &MSwtList::SetFocusIndex, aIndex);
       
  2437     }
       
  2438 
       
  2439     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1SetItems(JNIEnv* aJniEnv, jclass, jint aHandle, jobjectArray aStringArray)
       
  2440     {
       
  2441         CDesCArray* resultArray = NULL;
       
  2442         TRAPD(error, (resultArray=ConvertStringArrayL(aJniEnv, aStringArray)));
       
  2443         if (error != KErrNone || resultArray == NULL)
       
  2444         {
       
  2445             delete resultArray;
       
  2446             ThrowIfError(error, aJniEnv);
       
  2447             return;
       
  2448         }
       
  2449 
       
  2450         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2451         TRAP(error, CallMethodL(theList, &MSwtList::SetItemsL, resultArray));
       
  2452         ThrowIfError(error, aJniEnv);
       
  2453         delete resultArray;
       
  2454     }
       
  2455 
       
  2456     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1SetTopIndex(JNIEnv*, jclass, jint aHandle, jint aIndex)
       
  2457     {
       
  2458         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2459         CallMethod(theList, &MSwtList::SetTopIndex, aIndex);
       
  2460     }
       
  2461 
       
  2462     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_List_1ShowSelection(JNIEnv*, jclass, jint aHandle)
       
  2463     {
       
  2464         MSwtList* theList = reinterpret_cast<MSwtList*>(aHandle);
       
  2465         CallMethod(theList, &MSwtList::ShowSelection);
       
  2466     }
       
  2467 
       
  2468 
       
  2469     /*
       
  2470      * Class Text
       
  2471      */
       
  2472     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1New(JNIEnv* aJniEnv, jclass, jobject aPeer, jint aParent, jint aStyle)
       
  2473     {
       
  2474         jint handle = NewCoreWidget(aJniEnv, &MSwtFactory::NewTextL, aPeer, aParent, aStyle);
       
  2475         INCREASE_INSTANCE_COUNT(handle, Text);
       
  2476         return handle;
       
  2477     }
       
  2478 
       
  2479     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1ScrollableHandle(JNIEnv*, jclass, jint aHandle)
       
  2480     {
       
  2481         MSwtText*       text = reinterpret_cast<MSwtText*>(aHandle);
       
  2482         MSwtScrollable* scrollable;
       
  2483         CallMethod(scrollable, text, &MSwtText::Scrollable);
       
  2484         return reinterpret_cast<jint>(scrollable);
       
  2485     }
       
  2486 
       
  2487     JNIEXPORT jstring JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetText(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2488     {
       
  2489         return CallTextGetterThrow(aJniEnv, aHandle, &MSwtText::GetTextL);
       
  2490     }
       
  2491 
       
  2492     JNIEXPORT jstring JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetTextRange(JNIEnv* aJniEnv, jclass, jint aHandle, jint aStart, jint aEnd)
       
  2493     {
       
  2494         const MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2495         HBufC* text = NULL;
       
  2496         TRAPD(error, CallMethodL(text, textCtrl, &MSwtText::GetTextRangeL, aStart, aEnd));
       
  2497         if (text == NULL)
       
  2498         {
       
  2499             ThrowIfError(error, aJniEnv);
       
  2500             return NULL;
       
  2501         }
       
  2502 
       
  2503         jstring result = NewJavaString(aJniEnv, *text);
       
  2504         DeleteInUiHeap(text);
       
  2505         return result;
       
  2506     }
       
  2507 
       
  2508     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1SetText(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aText)
       
  2509     {
       
  2510         return ConvertBoolean(CallBoolTextMethodThrow(aJniEnv, aHandle, &MSwtText::SetTextL, aText, EFalse));
       
  2511     }
       
  2512 
       
  2513     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1Append(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aText)
       
  2514     {
       
  2515         return ConvertBoolean(CallBoolTextMethodThrow(aJniEnv, aHandle, &MSwtText::AppendL, aText, EFalse));
       
  2516     }
       
  2517 
       
  2518     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1Insert(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aText)
       
  2519     {
       
  2520         return ConvertBoolean(CallBoolTextMethodThrow(aJniEnv, aHandle, &MSwtText::InsertL, aText, EFalse));
       
  2521     }
       
  2522 
       
  2523     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetCharCount(JNIEnv*, jclass, jint aHandle)
       
  2524     {
       
  2525         return CallNonLeavingGetter(aHandle, &MSwtText::GetCharCount);
       
  2526     }
       
  2527 
       
  2528     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1SetTextLimit(JNIEnv* aJniEnv, jclass, jint aHandle, jint aLimit)
       
  2529     {
       
  2530         MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2531         TBool result;
       
  2532         TRAPD(error,CallMethodL(result, textCtrl, &MSwtText::SetTextLimitL, aLimit));
       
  2533         ThrowIfError(error, aJniEnv);
       
  2534         return ConvertBoolean(result);
       
  2535     }
       
  2536 
       
  2537     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetCaretLineNumber(JNIEnv*, jclass, jint aHandle)
       
  2538     {
       
  2539         return CallNonLeavingGetter(aHandle, &MSwtText::GetCaretLineNumber);
       
  2540     }
       
  2541 
       
  2542     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetCaretLocation(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2543     {
       
  2544         const MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2545         TPoint point(0,0);
       
  2546         TRAPD(error, CallMethodL(point, textCtrl, &MSwtText::GetCaretLocationL));
       
  2547         if (error)
       
  2548         {
       
  2549             Throw(error, aJniEnv);
       
  2550             return NULL;
       
  2551         }
       
  2552         return NewJavaPoint(aJniEnv, point);
       
  2553     }
       
  2554 
       
  2555     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetCaretPosition(JNIEnv*, jclass, jint aHandle)
       
  2556     {
       
  2557         return CallNonLeavingGetter(aHandle, &MSwtText::GetCaretPosition);
       
  2558     }
       
  2559 
       
  2560     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetSelection(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2561     {
       
  2562         TPoint point(CallNonLeavingCoordsGetter(aHandle, &MSwtText::GetSelection));
       
  2563         return NewJavaPoint(aJniEnv, point);
       
  2564     }
       
  2565 
       
  2566     JNIEXPORT jstring JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetSelectionText(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2567     {
       
  2568         return CallTextGetterThrow(aJniEnv, aHandle, &MSwtText::GetSelectionTextL);
       
  2569     }
       
  2570 
       
  2571     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1SetSelection(JNIEnv* aJniEnv, jclass, jint aHandle, jint aStart, jint aEnd)
       
  2572     {
       
  2573         MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2574         TRAPD(error, CallMethodL(textCtrl, &MSwtText::SetSelectionL, aStart, aEnd));
       
  2575         ThrowIfError(error, aJniEnv);
       
  2576     }
       
  2577 
       
  2578     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1ClearSelection(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2579     {
       
  2580         MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2581         TRAPD(error, CallMethodL(textCtrl, &MSwtText::ClearSelectionL));
       
  2582         ThrowIfError(error, aJniEnv);
       
  2583     }
       
  2584 
       
  2585     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1SelectAll(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2586     {
       
  2587         MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2588         TRAPD(error, CallMethodL(textCtrl, &MSwtText::SelectAllL));
       
  2589         ThrowIfError(error, aJniEnv);
       
  2590     }
       
  2591 
       
  2592     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1ShowSelection(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2593     {
       
  2594         MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2595         TRAPD(error, CallMethodL(textCtrl, &MSwtText::ShowSelectionL));
       
  2596         ThrowIfError(error, aJniEnv);
       
  2597     }
       
  2598 
       
  2599     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1Copy(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2600     {
       
  2601         MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2602         TRAPD(error, CallMethodL(textCtrl, &MSwtText::CopyL));
       
  2603         ThrowIfError(error, aJniEnv);
       
  2604     }
       
  2605 
       
  2606     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1Paste(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2607     {
       
  2608         MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2609         TBool result = EFalse;
       
  2610         TRAPD(error, CallMethodL(result, textCtrl, &MSwtText::PasteL));
       
  2611         ThrowIfError(error, aJniEnv);
       
  2612         return ConvertBoolean(result);
       
  2613     }
       
  2614 
       
  2615     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetEditable(JNIEnv *, jclass, jint aHandle)
       
  2616     {
       
  2617         return ConvertBoolean(CallNonLeavingGetter(aHandle, &MSwtText::GetEditable));
       
  2618     }
       
  2619 
       
  2620     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1SetEditable(JNIEnv*, jclass, jint aHandle, jboolean aEditable)
       
  2621     {
       
  2622         MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2623         CallMethod(textCtrl, &MSwtText::SetEditable, aEditable);
       
  2624     }
       
  2625 
       
  2626     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetLineCount(JNIEnv*, jclass, jint aHandle)
       
  2627     {
       
  2628         return CallNonLeavingGetter(aHandle, &MSwtText::GetLineCount);
       
  2629     }
       
  2630 
       
  2631     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetLineHeight(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2632     {
       
  2633         const MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2634         TInt result = 0;
       
  2635         TRAPD(error, CallMethodL(result, textCtrl, &MSwtText::GetLineHeightL));
       
  2636         ThrowIfError(error, aJniEnv);
       
  2637         return result;
       
  2638     }
       
  2639 
       
  2640     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetTopIndex(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2641     {
       
  2642         const MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2643         TInt result = 0;
       
  2644         TRAPD(error, CallMethodL(result, textCtrl, &MSwtText::GetTopIndexL));
       
  2645         ThrowIfError(error, aJniEnv);
       
  2646         return result;
       
  2647     }
       
  2648 
       
  2649     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1SetTopIndex(JNIEnv* aJniEnv, jclass, jint aHandle, jint aIndex)
       
  2650     {
       
  2651         MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2652         TRAPD(error, CallMethodL(textCtrl, &MSwtText::SetTopIndexL, aIndex));
       
  2653         ThrowIfError(error, aJniEnv);
       
  2654     }
       
  2655 
       
  2656     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetTopPixel(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2657     {
       
  2658         const MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2659         TInt result = 0;
       
  2660         TRAPD(error, CallMethodL(result, textCtrl, &MSwtText::GetTopPixelL));
       
  2661         ThrowIfError(error, aJniEnv);
       
  2662         return result;
       
  2663     }
       
  2664 
       
  2665     JNIEXPORT jchar JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetEchoChar(JNIEnv*, jclass, jint aHandle)
       
  2666     {
       
  2667         return CallNonLeavingGetter(aHandle, &MSwtText::GetEchoChar);
       
  2668     }
       
  2669 
       
  2670     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1SetEchoChar(JNIEnv* aJniEnv, jclass, jint aHandle, jchar aEcho)
       
  2671     {
       
  2672         MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2673         TRAPD(error,CallMethodL(textCtrl, &MSwtText::SetEchoCharL, aEcho));
       
  2674         ThrowIfError(error, aJniEnv);
       
  2675     }
       
  2676 
       
  2677     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1SetDoubleClickEnabled(JNIEnv*, jclass, jint aHandle, jboolean aDoubleClick)
       
  2678     {
       
  2679         MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2680         CallMethod(textCtrl, &MSwtText::SetDoubleClickEnabled, aDoubleClick);
       
  2681     }
       
  2682 
       
  2683     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1GetOrientation(JNIEnv*, jclass, jint aHandle)
       
  2684     {
       
  2685         return CallNonLeavingGetter(aHandle, &MSwtText::GetOrientation);
       
  2686     }
       
  2687 
       
  2688 
       
  2689     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Text_1SetOrientation(JNIEnv* aJniEnv, jclass, jint aHandle, jint aOrientation)
       
  2690     {
       
  2691         MSwtText* textCtrl = reinterpret_cast<MSwtText*>(aHandle);
       
  2692         TRAPD(error, CallMethodL(textCtrl, &MSwtText::SetOrientationL, aOrientation));
       
  2693         ThrowIfError(error, aJniEnv);
       
  2694     }
       
  2695 
       
  2696 
       
  2697     /*
       
  2698      * Class Combo
       
  2699      */
       
  2700     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1New(JNIEnv* aJniEnv, jclass, jobject aPeer, jint aParent, jint aStyle)
       
  2701     {
       
  2702         jint handle = NewCoreWidget(aJniEnv, &MSwtFactory::NewComboL, aPeer, aParent, aStyle);
       
  2703         INCREASE_INSTANCE_COUNT(handle, Combo);
       
  2704         return handle;
       
  2705     }
       
  2706 
       
  2707     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1CompositeHandle(JNIEnv*, jclass, jint aHandle)
       
  2708     {
       
  2709         MSwtCombo* combo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2710         MSwtComposite* result;
       
  2711         CallMethod(result, combo, &MSwtCombo::Composite);
       
  2712         return reinterpret_cast<jint>(result);
       
  2713     }
       
  2714 
       
  2715     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1Add__ILjava_lang_String_2(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aString)
       
  2716     {
       
  2717         CallTextMethodThrow(aJniEnv, aHandle, &MSwtCombo::AppendL, aString);
       
  2718     }
       
  2719 
       
  2720     static void Combo_AddL(JNIEnv* aJniEnv, MSwtCombo* aCombo, const jstring aString, TInt aIndex)
       
  2721     {
       
  2722         HBufC* text = ConvertStringLC(aJniEnv, aString);
       
  2723         CallMethodL(aCombo, &MSwtCombo::InsertL, aIndex, *text);
       
  2724         CleanupStack::PopAndDestroy(text);
       
  2725     }
       
  2726 
       
  2727     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1Add__ILjava_lang_String_2I(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aString, jint aIndex)
       
  2728     {
       
  2729         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2730         TRAPD(error, Combo_AddL(aJniEnv, theCombo, aString, aIndex));
       
  2731         ThrowIfError(error, aJniEnv);
       
  2732     }
       
  2733 
       
  2734     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1ClearSelection(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2735     {
       
  2736         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2737         TRAPD(error, CallMethodL(theCombo, &MSwtCombo::ClearSelectionL));
       
  2738         ThrowIfError(error, aJniEnv);
       
  2739     }
       
  2740 
       
  2741     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1Copy(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2742     {
       
  2743         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2744         TRAPD(error, CallMethodL(theCombo, &MSwtCombo::CopyL));
       
  2745         ThrowIfError(error, aJniEnv);
       
  2746     }
       
  2747 
       
  2748     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1Deselect(JNIEnv*, jclass, jint aHandle, jint aIndex)
       
  2749     {
       
  2750         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2751         CallMethod(theCombo, &MSwtCombo::DeselectItem, aIndex);
       
  2752     }
       
  2753 
       
  2754     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1DeselectAll(JNIEnv*, jclass, jint aHandle)
       
  2755     {
       
  2756         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2757         CallMethod(theCombo, &MSwtCombo::DeselectAll);
       
  2758     }
       
  2759 
       
  2760     JNIEXPORT jstring JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1GetItem(JNIEnv* aJniEnv, jclass, jint aHandle, jint aIndex)
       
  2761     {
       
  2762         const MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2763         TPtrC result;
       
  2764         TRAPD(error, CallMethodL(theCombo, &MSwtCombo::GetItemL, aIndex, result));
       
  2765         if (error == KErrNone)
       
  2766         {
       
  2767             return NewJavaString(aJniEnv, result);
       
  2768         }
       
  2769         else
       
  2770         {
       
  2771             Throw(error, aJniEnv);
       
  2772             return 0;
       
  2773         }
       
  2774     }
       
  2775 
       
  2776     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1GetItemCount(JNIEnv*, jclass, jint aHandle)
       
  2777     {
       
  2778         const MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2779         TInt result = 0;
       
  2780         CallMethod(result, theCombo, &MSwtCombo::GetItemCount);
       
  2781         return result;
       
  2782     }
       
  2783 
       
  2784     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1GetItemHeight(JNIEnv*, jclass, jint aHandle)
       
  2785     {
       
  2786         const MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2787         TInt result = 0;
       
  2788         CallMethod(result, theCombo, &MSwtCombo::GetItemHeight);
       
  2789         return result;
       
  2790     }
       
  2791 
       
  2792     JNIEXPORT jobjectArray JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1GetItems(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2793     {
       
  2794         const MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2795         CPtrCArray* array = NULL;
       
  2796         TRAPD(error, CallMethodL(array, theCombo, &MSwtCombo::GetItemsL));
       
  2797         if (error != KErrNone)
       
  2798         {
       
  2799             Throw(error, aJniEnv);
       
  2800             DeleteInUiHeap(array);
       
  2801             return NULL;
       
  2802         }
       
  2803         if (array == NULL)
       
  2804         {
       
  2805             return NULL;
       
  2806         }
       
  2807 
       
  2808         // Construct the array of strings.
       
  2809         jobjectArray javaStringArray = NULL;
       
  2810         jclass stringClass = aJniEnv->FindClass("java/lang/String");
       
  2811         if (stringClass != NULL)
       
  2812         {
       
  2813             const TInt count = array->Count();
       
  2814             javaStringArray = aJniEnv->NewObjectArray(count, stringClass, NULL);
       
  2815             if (javaStringArray != NULL)
       
  2816             {
       
  2817                 jstring javaString;
       
  2818                 for (TInt i=0; i<count; ++i)
       
  2819                 {
       
  2820                     javaString = NewJavaString(aJniEnv, array->At(i));
       
  2821                     aJniEnv->SetObjectArrayElement(javaStringArray, i, javaString); //lint !e613
       
  2822                     aJniEnv->DeleteLocalRef(javaString);
       
  2823                 }
       
  2824             }
       
  2825             aJniEnv->DeleteLocalRef(stringClass);
       
  2826         }
       
  2827 
       
  2828         DeleteInUiHeap(array);
       
  2829         return javaStringArray;
       
  2830     }
       
  2831 
       
  2832     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1GetOrientation(JNIEnv*, jclass, jint aHandle)
       
  2833     {
       
  2834         return CallNonLeavingGetter(aHandle, &MSwtCombo::GetOrientation);
       
  2835     }
       
  2836 
       
  2837     JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1GetSelection(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2838     {
       
  2839         TPoint point(CallNonLeavingCoordsGetter(aHandle, &MSwtCombo::GetSelection));
       
  2840         return NewJavaPoint(aJniEnv, point);
       
  2841     }
       
  2842 
       
  2843     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1GetSelectionIndex(JNIEnv*, jclass, jint aHandle)
       
  2844     {
       
  2845         return CallNonLeavingGetter(aHandle, &MSwtCombo::GetSelectionIndex);
       
  2846     }
       
  2847 
       
  2848     JNIEXPORT jstring JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1GetText(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2849     {
       
  2850         return CallTextGetterThrow(aJniEnv, aHandle, &MSwtCombo::GetTextL);
       
  2851     }
       
  2852 
       
  2853     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1GetTextHeight(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2854     {
       
  2855         const MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2856         TInt result = 0;
       
  2857         TRAPD(error, CallMethodL(result, theCombo, &MSwtCombo::GetTextHeightL));
       
  2858         ThrowIfError(error, aJniEnv);
       
  2859         return result;
       
  2860     }
       
  2861 
       
  2862     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1GetTextLimit(JNIEnv*, jclass, jint aHandle)
       
  2863     {
       
  2864         return CallNonLeavingGetter(aHandle, &MSwtCombo::GetTextLimit);
       
  2865     }
       
  2866 
       
  2867     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1GetVisibleItemCount(JNIEnv* , jclass, jint aHandle)
       
  2868     {
       
  2869         return CallNonLeavingGetter(aHandle, &MSwtCombo::GetVisibleItemCount);
       
  2870     }
       
  2871 
       
  2872     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1IndexOf(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aString, jint aStart)
       
  2873     {
       
  2874         HBufC* string = NULL;
       
  2875         TRAPD(error, (string=ConvertStringL(aJniEnv, aString)));
       
  2876         if (error != KErrNone || string == NULL)
       
  2877         {
       
  2878             Throw(error, aJniEnv);
       
  2879             return 0;
       
  2880         }
       
  2881 
       
  2882         const MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2883         TInt result;
       
  2884         CallMethod(result, theCombo, &MSwtCombo::IndexOf, *string, aStart);
       
  2885         delete string;
       
  2886         return result;
       
  2887     }
       
  2888 
       
  2889     static TBool Combo_InsertInTextControlL(JNIEnv* aJniEnv, jint aHandle, jstring aString)
       
  2890     {
       
  2891         HBufC* string = ConvertStringLC(aJniEnv, aString);
       
  2892         if (string == NULL)
       
  2893         {
       
  2894             return EFalse;
       
  2895         }
       
  2896 
       
  2897         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2898         TBool result;
       
  2899         CallMethodL(result, theCombo, &MSwtCombo::InsertInTextControlL, *string);
       
  2900         CleanupStack::PopAndDestroy(string);
       
  2901         return result;
       
  2902     }
       
  2903 
       
  2904     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1InsertInTextControl
       
  2905     (JNIEnv* aJniEnv, jclass, jint aHandle, jstring aString)
       
  2906     {
       
  2907         TBool result = EFalse;
       
  2908         TRAPD(error, (result = Combo_InsertInTextControlL(aJniEnv, aHandle, aString)));
       
  2909         ThrowIfError(error, aJniEnv);
       
  2910         return ConvertBoolean(result);
       
  2911     }
       
  2912 
       
  2913     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1Paste(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2914     {
       
  2915         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2916         TBool result = EFalse;
       
  2917         TRAPD(error, CallMethodL(result, theCombo, &MSwtCombo::PasteL));
       
  2918         ThrowIfError(error, aJniEnv);
       
  2919         return ConvertBoolean(result);
       
  2920     }
       
  2921 
       
  2922     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1Remove__II(JNIEnv* aJniEnv, jclass, jint aHandle, jint aIndex)
       
  2923     {
       
  2924         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2925         TRAPD(error, CallMethodL(theCombo, &MSwtCombo::RemoveItemL, aIndex));
       
  2926         ThrowIfError(error, aJniEnv);
       
  2927     }
       
  2928 
       
  2929     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1Remove__III(JNIEnv* aJniEnv, jclass, jint aHandle, jint aStart, jint aEnd)
       
  2930     {
       
  2931         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2932         TRAPD(error, CallMethodL(theCombo, &MSwtCombo::RemoveRangeL, aStart, aEnd));
       
  2933         ThrowIfError(error, aJniEnv);
       
  2934     }
       
  2935 
       
  2936     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1RemoveAll(JNIEnv* aJniEnv, jclass, jint aHandle)
       
  2937     {
       
  2938         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2939         TRAPD(error, CallMethodL(theCombo, &MSwtCombo::RemoveAllL));
       
  2940         ThrowIfError(error, aJniEnv);
       
  2941     }
       
  2942 
       
  2943     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1Select(JNIEnv* aJniEnv, jclass, jint aHandle, jint aIndex)
       
  2944     {
       
  2945         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2946         TRAPD(error, CallMethodL(theCombo, &MSwtCombo::SelectItemL, aIndex));
       
  2947         ThrowIfError(error, aJniEnv);
       
  2948     }
       
  2949 
       
  2950     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1SetItems(JNIEnv* aJniEnv, jclass, jint aHandle, jobjectArray aStringArray)
       
  2951     {
       
  2952         CDesCArray* resultArray = NULL;
       
  2953         TRAPD(error, (resultArray=ConvertStringArrayL(aJniEnv, aStringArray)));
       
  2954         if (error != KErrNone || resultArray == NULL)
       
  2955         {
       
  2956             delete resultArray;
       
  2957             ThrowIfError(error, aJniEnv);
       
  2958             return;
       
  2959         }
       
  2960 
       
  2961         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2962         TRAP(error, CallMethodL(theCombo, &MSwtCombo::SetItemsL, resultArray));
       
  2963         ThrowIfError(error, aJniEnv);
       
  2964         delete resultArray;
       
  2965     }
       
  2966 
       
  2967     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1SetOrientation(JNIEnv* aJniEnv, jclass, jint aHandle, jint aOrientation)
       
  2968     {
       
  2969         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2970         TRAPD(error, CallMethodL(theCombo, &MSwtCombo::SetOrientationL, aOrientation));
       
  2971         ThrowIfError(error, aJniEnv);
       
  2972     }
       
  2973 
       
  2974     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1SetSelection(JNIEnv* aJniEnv, jclass, jint aHandle, jint aStart, jint aEnd)
       
  2975     {
       
  2976         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2977         TRAPD(error, CallMethodL(theCombo, &MSwtCombo::SetSelectionL, aStart, aEnd));
       
  2978         ThrowIfError(error, aJniEnv);
       
  2979     }
       
  2980 
       
  2981     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1SetText(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aText)
       
  2982     {
       
  2983         return ConvertBoolean(CallBoolTextMethodThrow(aJniEnv, aHandle, &MSwtCombo::SetTextL, aText, EFalse));
       
  2984     }
       
  2985 
       
  2986     JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1SetTextLimit(JNIEnv*, jclass, jint aHandle, jint aLimit)
       
  2987     {
       
  2988         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2989         TBool result;
       
  2990         CallMethod(result, theCombo, &MSwtCombo::SetTextLimit, aLimit);
       
  2991         return ConvertBoolean(result);
       
  2992     }
       
  2993 
       
  2994     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Combo_1SetVisibleItemCount(JNIEnv*, jclass, jint aHandle, jint aCount)
       
  2995     {
       
  2996         MSwtCombo* theCombo = reinterpret_cast<MSwtCombo*>(aHandle);
       
  2997         CallMethod(theCombo, &MSwtCombo::SetVisibleItemCount, aCount);
       
  2998     }
       
  2999 
       
  3000 
       
  3001     /*
       
  3002      * Class ProgressBar
       
  3003      */
       
  3004     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ProgressBar_1ControlHandle(JNIEnv*, jclass, jint aHandle)
       
  3005     {
       
  3006         MSwtProgressBar* progressBar = reinterpret_cast<MSwtProgressBar*>(aHandle);
       
  3007         MSwtControl*    result;
       
  3008         CallMethod(result, progressBar, &MSwtProgressBar::Control);
       
  3009         return reinterpret_cast<jint>(result);
       
  3010     }
       
  3011 
       
  3012     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ProgressBar_1New(JNIEnv* aJniEnv, jclass, jobject aPeer, jint aParent, jint aStyle)
       
  3013     {
       
  3014         jint handle = NewCoreWidget(aJniEnv, &MSwtFactory::NewProgressBarL, aPeer, aParent, aStyle);
       
  3015         INCREASE_INSTANCE_COUNT(handle, ProgressBar);
       
  3016         return handle;
       
  3017     }
       
  3018 
       
  3019     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ProgressBar_1GetMaximum(JNIEnv* /*aJniEnv*/, jclass, jint aHandle)
       
  3020     {
       
  3021         return CallNonLeavingGetter(aHandle, &MSwtProgressBar::GetMaximum);
       
  3022     }
       
  3023 
       
  3024     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ProgressBar_1GetMinimum(JNIEnv* /*aJniEnv*/, jclass, jint aHandle)
       
  3025     {
       
  3026         return CallNonLeavingGetter(aHandle, &MSwtProgressBar::GetMinimum);
       
  3027     }
       
  3028 
       
  3029     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ProgressBar_1GetSelection(JNIEnv* /*aJniEnv*/, jclass, jint aHandle)
       
  3030     {
       
  3031         return CallNonLeavingGetter(aHandle, &MSwtProgressBar::GetSelection);
       
  3032     }
       
  3033 
       
  3034     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ProgressBar_1SetMaximum(JNIEnv* /*aJniEnv*/, jclass , jint aHandle, jint aMaximum)
       
  3035     {
       
  3036         MSwtProgressBar* theProgressBar = reinterpret_cast<MSwtProgressBar*>(aHandle);
       
  3037         CallMethod(theProgressBar, &MSwtProgressBar::SetMaximum, aMaximum);
       
  3038     }
       
  3039 
       
  3040     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ProgressBar_1SetMinimum(JNIEnv* /*aJniEnv*/, jclass , jint aHandle, jint aMinimum)
       
  3041     {
       
  3042         MSwtProgressBar* theProgressBar = reinterpret_cast<MSwtProgressBar*>(aHandle);
       
  3043         CallMethod(theProgressBar, &MSwtProgressBar::SetMinimum, aMinimum);
       
  3044     }
       
  3045 
       
  3046     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ProgressBar_1SetSelection(JNIEnv* /*aJniEnv*/, jclass , jint aHandle, jint aSelection)
       
  3047     {
       
  3048         MSwtProgressBar* theProgressBar = reinterpret_cast<MSwtProgressBar*>(aHandle);
       
  3049         CallMethod(theProgressBar, &MSwtProgressBar::SetSelection, aSelection);
       
  3050     }
       
  3051 
       
  3052 
       
  3053     /*
       
  3054      * Class Slider
       
  3055      */
       
  3056     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Slider_1ControlHandle(JNIEnv*, jclass, jint aHandle)
       
  3057     {
       
  3058         MSwtSlider* Slider = reinterpret_cast<MSwtSlider*>(aHandle);
       
  3059         MSwtControl*    result;
       
  3060         CallMethod(result, Slider, &MSwtSlider::Control);
       
  3061         return reinterpret_cast<jint>(result);
       
  3062     }
       
  3063 
       
  3064     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Slider_1New(JNIEnv* aJniEnv, jclass, jobject aPeer, jint aParent, jint aStyle)
       
  3065     {
       
  3066         jint handle = NewCoreWidget(aJniEnv, &MSwtFactory::NewSliderL, aPeer, aParent, aStyle);
       
  3067         INCREASE_INSTANCE_COUNT(handle, Slider);
       
  3068         return handle;
       
  3069     }
       
  3070 
       
  3071     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Slider_1GetMaximum(JNIEnv* /*aJniEnv*/, jclass, jint aHandle)
       
  3072     {
       
  3073         return CallNonLeavingGetter(aHandle, &MSwtSlider::GetMaximum);
       
  3074     }
       
  3075 
       
  3076     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Slider_1GetMinimum(JNIEnv* /*aJniEnv*/, jclass, jint aHandle)
       
  3077     {
       
  3078         return CallNonLeavingGetter(aHandle, &MSwtSlider::GetMinimum);
       
  3079     }
       
  3080 
       
  3081     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Slider_1GetPageIncrement(JNIEnv* /*aJniEnv*/, jclass, jint aHandle)
       
  3082     {
       
  3083         return CallNonLeavingGetter(aHandle, &MSwtSlider::GetPageIncrement);
       
  3084     }
       
  3085 
       
  3086     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Slider_1GetIncrement(JNIEnv* /*aJniEnv*/, jclass, jint aHandle)
       
  3087     {
       
  3088         return CallNonLeavingGetter(aHandle, &MSwtSlider::GetIncrement);
       
  3089     }
       
  3090 
       
  3091     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_Slider_1GetSelection(JNIEnv* /*aJniEnv*/, jclass, jint aHandle)
       
  3092     {
       
  3093         return CallNonLeavingGetter(aHandle, &MSwtSlider::GetSelection);
       
  3094     }
       
  3095 
       
  3096     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Slider_1SetMaximum(JNIEnv* /*aJniEnv*/, jclass , jint aHandle, jint aMaximum)
       
  3097     {
       
  3098         MSwtSlider* theSlider = reinterpret_cast<MSwtSlider*>(aHandle);
       
  3099         CallMethod(theSlider, &MSwtSlider::SetMaximum, aMaximum);
       
  3100     }
       
  3101 
       
  3102     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Slider_1SetMinimum(JNIEnv* /*aJniEnv*/, jclass , jint aHandle, jint aMinimum)
       
  3103     {
       
  3104         MSwtSlider* theSlider = reinterpret_cast<MSwtSlider*>(aHandle);
       
  3105         CallMethod(theSlider, &MSwtSlider::SetMinimum, aMinimum);
       
  3106     }
       
  3107 
       
  3108 
       
  3109     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Slider_1SetIncrement(JNIEnv* /*aJniEnv*/, jclass , jint aHandle, jint aIncrement)
       
  3110     {
       
  3111         MSwtSlider* theSlider = reinterpret_cast<MSwtSlider*>(aHandle);
       
  3112         CallMethod(theSlider, &MSwtSlider::SetIncrement, aIncrement);
       
  3113     }
       
  3114 
       
  3115     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Slider_1SetPageIncrement(JNIEnv* /*aJniEnv*/, jclass , jint aHandle, jint aPageIncrement)
       
  3116     {
       
  3117         MSwtSlider* theSlider = reinterpret_cast<MSwtSlider*>(aHandle);
       
  3118         CallMethod(theSlider, &MSwtSlider::SetPageIncrement, aPageIncrement);
       
  3119     }
       
  3120 
       
  3121     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Slider_1SetSelection(JNIEnv* /*aJniEnv*/, jclass , jint aHandle, jint aSelection)
       
  3122     {
       
  3123         MSwtSlider* theSlider = reinterpret_cast<MSwtSlider*>(aHandle);
       
  3124         CallMethod(theSlider, &MSwtSlider::SetSelection, aSelection);
       
  3125     }
       
  3126 
       
  3127     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_Slider_1SetValues(JNIEnv* /*aJniEnv*/, jclass , jint aHandle, jint aSelection, jint aMinimum, jint aMaximum, jint aIncrement, jint aPageIncrement)
       
  3128     {
       
  3129         MSwtSlider* theSlider = reinterpret_cast<MSwtSlider*>(aHandle);
       
  3130         CallMethod(theSlider, &MSwtSlider::SetValues, aSelection, aMinimum, aMaximum, aIncrement, aPageIncrement);
       
  3131     }
       
  3132 
       
  3133 
       
  3134     /*
       
  3135      * Class FileDialog
       
  3136      */
       
  3137     static void FileDialog_OpenL(
       
  3138         JNIEnv* aJniEnv,
       
  3139         TSwtPeer aPeer,
       
  3140         jint aStyle,
       
  3141         jstring aTitle,
       
  3142         jstring aInitPath)
       
  3143     {
       
  3144         // Set initial path & title
       
  3145         HBufC* initPath = aInitPath ?
       
  3146                           ConvertStringLC(aJniEnv, aInitPath) :
       
  3147                           HBufC::NewLC(0);
       
  3148         HBufC* title = aTitle ?
       
  3149                        ConvertStringLC(aJniEnv, aTitle) :
       
  3150                        HBufC::NewLC(0);
       
  3151 
       
  3152         TInt dialogType = CSwtDialogBroker::EFileDialog;
       
  3153         CSwtDisplay& display = CSwtDisplay::Current();
       
  3154         display.RequestRunDialogL(aPeer, dialogType, aStyle, *title, *initPath);
       
  3155 
       
  3156         CleanupStack::PopAndDestroy(title);
       
  3157         CleanupStack::PopAndDestroy(initPath);
       
  3158     }
       
  3159 
       
  3160     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_FileDialog_1Open(
       
  3161         JNIEnv* aJniEnv,
       
  3162         jclass,
       
  3163         jobject aPeer,
       
  3164         jstring aInitPath,
       
  3165         jstring aTitle,
       
  3166         jint aStyle)
       
  3167     {
       
  3168         TRAPD(error,
       
  3169               FileDialog_OpenL(
       
  3170                   aJniEnv,
       
  3171                   reinterpret_cast<TSwtPeer>(aPeer),
       
  3172                   aStyle,
       
  3173                   aTitle,
       
  3174                   aInitPath
       
  3175               ));
       
  3176         ThrowIfError(error, aJniEnv);
       
  3177     }
       
  3178 
       
  3179 
       
  3180     /*
       
  3181      *  Class ImageDataLoader
       
  3182      */
       
  3183     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ImageDataLoader_1New(JNIEnv *aJniEnv, jclass)
       
  3184     {
       
  3185         // TRAPD(error, (result = MSwtImageDataLoader::NewImageDataLoaderL));
       
  3186         MSwtImageDataLoader* result=NULL;
       
  3187         TRAPD(error, result = CSwtImageDataLoader::NewL());
       
  3188         ThrowIfError(error, aJniEnv);
       
  3189         return reinterpret_cast<jint>(result);
       
  3190     }
       
  3191 
       
  3192 
       
  3193     static void ImageDataLoader_EncodeImageL(JNIEnv* aJniEnv, MSwtImageDataLoader* aLoader, jobject aImageData, jint aFormat, const jstring aFilename)
       
  3194     {
       
  3195         // Convert image data
       
  3196         CSwtImageData* data = CSwtImageData::NewL(aJniEnv, aImageData);
       
  3197         CleanupStack::PushL(data);
       
  3198 
       
  3199         HBufC* convertedFilename = ConvertStringLC(aJniEnv, aFilename);
       
  3200 
       
  3201         aLoader->EncodeImageToFileL(*data, aFormat, *convertedFilename);
       
  3202 
       
  3203         CleanupStack::PopAndDestroy(2, data); // convertedFilename, data
       
  3204     }
       
  3205 
       
  3206     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ImageDataLoader_1EncodeImage(JNIEnv* aJniEnv, jclass, jint aHandle, jobject aImageData, jint aFormat, jstring aFilename)
       
  3207     {
       
  3208         MSwtImageDataLoader* loader = reinterpret_cast<MSwtImageDataLoader*>(aHandle);
       
  3209         TRAPD(error, ImageDataLoader_EncodeImageL(aJniEnv, loader, aImageData, aFormat, aFilename));
       
  3210         ThrowIfError(error, aJniEnv);
       
  3211     }
       
  3212 
       
  3213     static void ImageDataLoader_EncodeImageToStreamL(JNIEnv* aJniEnv, MSwtImageDataLoader* aLoader, jobject aImageData, jint aFormat, jobject aOutputStream)
       
  3214     {
       
  3215         // Convert image data
       
  3216         CSwtImageData* data = CSwtImageData::NewL(aJniEnv,aImageData);
       
  3217         CleanupStack::PushL(data);
       
  3218 
       
  3219         HBufC8* buffer = NULL;
       
  3220         buffer = aLoader->EncodeImageToStreamL(*data, aFormat);
       
  3221         CleanupStack::PopAndDestroy(data);
       
  3222 
       
  3223         // Now: fill the OutputStream
       
  3224         jclass clazz = aJniEnv->GetObjectClass(aOutputStream);
       
  3225         if (clazz != NULL)
       
  3226         {
       
  3227             jmethodID id = aJniEnv->GetMethodID(clazz, "write", "([B)V");
       
  3228             aJniEnv->DeleteLocalRef(clazz);
       
  3229             if (id != NULL)
       
  3230             {
       
  3231 
       
  3232                 jbyteArray byte = NewJavaByteArray(aJniEnv, *buffer);
       
  3233                 if (byte != NULL)
       
  3234                 {
       
  3235                     aJniEnv->CallVoidMethod(aOutputStream, id, byte);
       
  3236                     aJniEnv->DeleteLocalRef(byte);
       
  3237                 }
       
  3238             }
       
  3239         }
       
  3240     }
       
  3241 
       
  3242     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ImageDataLoader_1EncodeImageToStream(JNIEnv* aJniEnv, jclass, jint aHandle, jobject aImageData, jint aFormat, jobject aOutputStream)
       
  3243     {
       
  3244         MSwtImageDataLoader* loader = reinterpret_cast<MSwtImageDataLoader*>(aHandle);
       
  3245         TRAPD(error, ImageDataLoader_EncodeImageToStreamL(aJniEnv, loader, aImageData, aFormat, aOutputStream));
       
  3246         ThrowIfError(error, aJniEnv);
       
  3247     }
       
  3248 
       
  3249     static jobjectArray ImageDataLoader_DecodeImageL(JNIEnv* aJniEnv, MSwtImageDataLoader* aLoader, const jstring aFilename)
       
  3250     {
       
  3251         HBufC* convertedFilename = ConvertStringLC(aJniEnv, aFilename);
       
  3252 
       
  3253         aLoader->DecodeImageL(*convertedFilename);
       
  3254         CleanupStack::PopAndDestroy(convertedFilename);
       
  3255 
       
  3256         CSwtImageDataArray* data;
       
  3257         data = aLoader->GetImageData();
       
  3258 
       
  3259         return NewJavaImageDataArray(aJniEnv, data);
       
  3260     }
       
  3261 
       
  3262     JNIEXPORT jobjectArray JNICALL Java_org_eclipse_swt_internal_symbian_OS_ImageDataLoader_1DecodeImage(JNIEnv* aJniEnv, jclass, jint aHandle, jstring aFilename)
       
  3263     {
       
  3264         MSwtImageDataLoader* loader = reinterpret_cast<MSwtImageDataLoader*>(aHandle);
       
  3265         jobjectArray result = NULL;
       
  3266         TRAPD(error, (result=ImageDataLoader_DecodeImageL(aJniEnv, loader, aFilename)));
       
  3267         ThrowIfError(error, aJniEnv);
       
  3268         return result;
       
  3269     }
       
  3270 
       
  3271     static jobjectArray ImageDataLoader_DecodeWholeImageFromBufferL(JNIEnv* aJniEnv, MSwtImageDataLoader* aLoader, jbyteArray aBuffer)
       
  3272     {
       
  3273         HBufC8* buffer = ConvertByteArrayL(aJniEnv, aBuffer);
       
  3274         CleanupStack::PushL(buffer);
       
  3275 
       
  3276         aLoader->DecodeWholeImageFromBufferL(*buffer);
       
  3277         CleanupStack::PopAndDestroy(buffer);
       
  3278 
       
  3279         CSwtImageDataArray* data;
       
  3280         data = aLoader->GetImageData();
       
  3281         if (!data)
       
  3282         {
       
  3283             return NULL;
       
  3284         }
       
  3285         return NewJavaImageDataArray(aJniEnv, data);
       
  3286     }
       
  3287 
       
  3288     JNIEXPORT jobjectArray JNICALL Java_org_eclipse_swt_internal_symbian_OS_ImageDataLoader_1DecodeWholeImageFromBuffer(JNIEnv* aJniEnv, jclass, jint aHandle, jbyteArray aBuffer)
       
  3289     {
       
  3290         MSwtImageDataLoader* loader = reinterpret_cast<MSwtImageDataLoader*>(aHandle);
       
  3291         jobjectArray result = NULL;
       
  3292         TRAPD(error, (result=ImageDataLoader_DecodeWholeImageFromBufferL(aJniEnv, loader, aBuffer)));
       
  3293         ThrowIfError(error, aJniEnv);
       
  3294         return result;
       
  3295     }
       
  3296 
       
  3297     typedef void (MSwtImageDataLoader::*TBufferDecoder)(const TDesC8&);
       
  3298 
       
  3299     static void ImageDataLoader_DecodeBufferL(JNIEnv* aJniEnv, MSwtImageDataLoader& aLoader, TBufferDecoder aDecodeMethodL, jbyteArray aBuffer)
       
  3300     {
       
  3301         HBufC8* buffer = ConvertByteArrayL(aJniEnv, aBuffer);
       
  3302         CleanupStack::PushL(buffer);
       
  3303 
       
  3304         (aLoader.*aDecodeMethodL)(*buffer);
       
  3305 
       
  3306         CleanupStack::PopAndDestroy(buffer);
       
  3307     }
       
  3308 
       
  3309     static void ImageDataLoader_DecodeBufferThrow(JNIEnv* aJniEnv, jint aHandle, TBufferDecoder aDecodeMethodL, jbyteArray aBuffer)
       
  3310     {
       
  3311         MSwtImageDataLoader* loader = reinterpret_cast<MSwtImageDataLoader*>(aHandle);
       
  3312         TRAPD(error, ImageDataLoader_DecodeBufferL(aJniEnv, *loader, aDecodeMethodL, aBuffer));
       
  3313         ThrowIfError(error, aJniEnv);
       
  3314     }
       
  3315 
       
  3316     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ImageDataLoader_1StartImageDecoding(JNIEnv* aJniEnv, jclass, jint aHandle, jbyteArray aBuffer)
       
  3317     {
       
  3318         ImageDataLoader_DecodeBufferThrow(aJniEnv, aHandle, &MSwtImageDataLoader::DecodeImageFromBufferL, aBuffer);
       
  3319     }
       
  3320 
       
  3321     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ImageDataLoader_1AppendData(JNIEnv* aJniEnv, jclass, jint aHandle, jbyteArray aBuffer)
       
  3322     {
       
  3323         ImageDataLoader_DecodeBufferThrow(aJniEnv, aHandle, &MSwtImageDataLoader::AppendDataL, aBuffer);
       
  3324     }
       
  3325 
       
  3326     JNIEXPORT jobjectArray JNICALL Java_org_eclipse_swt_internal_symbian_OS_ImageDataLoader_1GetImageData(JNIEnv *aJniEnv, jclass , jint aHandle)
       
  3327     {
       
  3328         CSwtImageDataArray* data = NULL;
       
  3329         MSwtImageDataLoader* imageDataLoader = reinterpret_cast<MSwtImageDataLoader*>(aHandle);
       
  3330         data = imageDataLoader->GetImageData();
       
  3331         return NewJavaImageDataArray(aJniEnv, data);
       
  3332     }
       
  3333 
       
  3334     JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_symbian_OS_ImageDataLoader_1Dispose(JNIEnv*, jclass, jint aHandle)
       
  3335     {
       
  3336         MSwtImageDataLoader* imageDataLoader = reinterpret_cast<MSwtImageDataLoader*>(aHandle);
       
  3337         imageDataLoader->Dispose();
       
  3338     }
       
  3339 
       
  3340     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ImageDataLoader_1GetLogicalScreenHeight(JNIEnv *, jclass, jint aHandle)
       
  3341     {
       
  3342         MSwtImageDataLoader* imageDataLoader = reinterpret_cast<MSwtImageDataLoader*>(aHandle);
       
  3343         TInt result;
       
  3344         result = imageDataLoader->GetLogicalScreenHeight();
       
  3345         return result;
       
  3346     }
       
  3347 
       
  3348     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_ImageDataLoader_1GetLogicalScreenWidth(JNIEnv *, jclass, jint aHandle)
       
  3349     {
       
  3350         MSwtImageDataLoader* imageDataLoader = reinterpret_cast<MSwtImageDataLoader*>(aHandle);
       
  3351         TInt result;
       
  3352         result = imageDataLoader->GetLogicalScreenWidth();
       
  3353         return result;
       
  3354     }
       
  3355 
       
  3356     JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_symbian_OS_windowServer(JNIEnv *, jclass)
       
  3357     {
       
  3358 #ifdef RD_JAVA_S60_RELEASE_9_2
       
  3359         return 2;
       
  3360 #else
       
  3361         return 1;
       
  3362 #endif
       
  3363     }
       
  3364 
       
  3365 } // extern "C"