javauis/nokiauiapi_qt/javasrc_j2me/com/nokia/mid/ui/TactileFeedback.java
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 04 Oct 2010 00:10:53 +0300
changeset 79 2f468c1958d0
child 78 71ad690e91f5
permissions -rw-r--r--
Revision: v2.2.15 Kit: 201039
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
79
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
package com.nokia.mid.ui;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
import org.eclipse.swt.widgets.Internal_PackageSupport;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
import com.nokia.mid.ui.internal.OS;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
/**
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
 * This class is a Java extension to support tactile feedback (audio, vibra,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
 * piezo, etc.) on touch-enabled devices. Tactile feedback is meant to give user
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
 * more clear feeling of touch events, like tapping and dragging. The actual
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
 * physical tactile feedback depends on the device tactile feedback
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
 * implementation, hardware and device settings. A device may implement the
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
 * feedback with different hardware methods, for example, vibra, audio or piezo
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
 * hardware.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
 * <p>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
 * The API supports both LCDUI and eSWT UI toolkits.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
 * <p>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
 * Using this class is safe when a device does not support tactile feedback. In
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
 * this case methods of this class can be called but this has no effect.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
 * <p>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
 * Tactile feedback can be generated in two ways:
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
 * <ul>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
 * <li>By producing direct feedback from the application.</li>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
 * <li>By adding feedback areas to area registry, in which case the feedback
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
 * will be produced by the tactile feedback system automatically when the
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
 * defined screen area (with defined feedback) is touched.</li>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
 * </ul>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
 * <p>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
 * Direct feedback is given instantly with {@link #directFeedback
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
 * directFeedback} specifying the feedback type. Direct feedback can be used
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
 * when the user action is not just a tap in a certain area. For example if the
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
 * user drags from one menu item to the other the application may give direct
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
 * feedback to emphasize focus traverse.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
 * <p>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
 * In case of area registry for eSWT Control, the registry needs to be updated
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
 * every time when the size or position of a UI component changes, or when e.g.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
 * a state of a UI component changes in such way that feedback type also
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
 * changes. Typically the area update may be implemented in
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
 * <code>controlMoved</code> and <code>controlResized</code> methods of
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
 * <code>ControlListener</code> interface.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
 * <p>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
 * In case of area registry for LCDUI Canvas or CustomItem no further actions
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
 * are required to update tactile feedback areas when a CustomItem is moved in a
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
 * Form or when a Canvas is changed due to e.g. orientation switch.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
 * <p>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
 * There are quite tight latency requirements for tactile feedback, and in most
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
 * cases feedback should be triggered in less than 30ms from the time when user
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
 * touched the screen. For the area registry the feedback system is responsible
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
 * of fulfilling this requirement, but in case of direct feedback it is the
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
 * responsibility of the user of this API.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
 * <p>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
 * The tactile feedback has 2 different styles: Basic and Sensitive. Each type
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
 * is defined in the device settings, not by this API. Each style of feedback is
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
 * used in different cases. Typically Basic style is used to emphasize the tap
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
 * event, while Sensitive style is used mostly at dragging operations, to
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
 * emphasize focus traverse, text selection, etc. Choosing a specific style for
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
 * each use case in up to developer, however it is good to follow the behavior
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
 * of native applications.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
 * <p>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
 * The goal of the API is to enable user-created UI components to have tactile
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
 * feedback. The UI component types supported by the API are limited to
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
 * user-defined components only: <code>javax.microedition.lcdui.Canvas</code>,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
 * <code>javax.microedition.lcdui.CustomItem</code>,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
 * <code>org.eclipse.swt.widgets.Control</code>. Other UI components (i.e. List,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
 * TextBox, etc.) get default tactile feedback automatically from the platform.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
 *
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
 * @version 0.001
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
 * @since 1.2
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
 */
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
public class TactileFeedback
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
{
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    /**
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
     * Constant for specifying basic tactile feedback style. Actual style
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
     * behaviour is set through device settings.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
     */
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
    public static final int FEEDBACK_STYLE_BASIC = 1;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
    /**
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
     * Constant for specifying sensitive tactile feedback style. Actual style
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
     * behaviour is set through device settings.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
     */
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
    public static final int FEEDBACK_STYLE_SENSITIVE = 2;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
    private final String invalidFeedbackStyleMsg = "Invalid feedback style specified";
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
    private final String invalidControlTypeMsg = "Invalid object provided for tactile feedback registration";
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
    private static final int TYPE_INVALID = 0;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
    private static final int TYPE_ESWT = 1;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
    private static final int TYPE_LCDUI = 2;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
    private static boolean feedbackEnabled;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    /**
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
     * Constructs tactile feedback engine object. The object may be used in both
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
     * LCDUI and eSWT java UI toolkits. TactileFeedback object must be
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
     * constructed before using any tactile feedback methods.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
     */
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
    public TactileFeedback()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
    {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
    }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    /**
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
     * Triggers direct tactile feedback of the specified style.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
     *
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
     * @param style
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
     *            The style of the direct feedback. Use predefined values
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
     *            FEEDBACK_STYLE_BASIC, FEEDBACK_STYLE_SENSITIVE. Actual style
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
     *            behavior is set through device settings.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
     * @throws IllegalArgumentException
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
     *             if the style parameter has invalid type.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
     */
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
    public void directFeedback(int style) throws IllegalArgumentException
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
    {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
        if ((style != FEEDBACK_STYLE_BASIC)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
                && (style != FEEDBACK_STYLE_SENSITIVE))
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
            throw new IllegalArgumentException(invalidFeedbackStyleMsg);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
        if (org.eclipse.swt.widgets.Display.getCurrent() == null)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
            final int fStyle = style;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
            com.nokia.mj.impl.nokialcdui.LCDUIInvoker
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
            .eSWTUIThreadRunnerSyncExec(new Runnable()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
            {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
                public void run()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
                {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
                    OS.MTouchFeedback_InstantFeedback(fStyle);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
                }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
            });
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
        else
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
            OS.MTouchFeedback_InstantFeedback(style);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
    }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    /**
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
     * Queries the device if it supports tactile feedback. It is safe to use
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
     * this class even if the device does not support tactile feedback. Methods
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
     * of this class can be called but this has no effect.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
     *
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
     * @return true if the device supports tactile feedback, false otherwise.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
     */
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
    public boolean isTouchFeedbackSupported()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
        if (org.eclipse.swt.widgets.Display.getCurrent() == null)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
            com.nokia.mj.impl.nokialcdui.LCDUIInvoker
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
            .eSWTUIThreadRunnerSyncExec(new Runnable()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
            {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
                public void run()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
                {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
                    feedbackEnabled = OS
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
                                      .MTouchFeedback_TouchFeedbackSupported();
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
                }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
            });
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
        else
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
            feedbackEnabled = OS.MTouchFeedback_TouchFeedbackSupported();
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
        return feedbackEnabled;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
    }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
    /**
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
     * Registers area within a UI component for tactile feedback. If areas
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
     * overlap then the feedback is given from the last registered area.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
     * {@link #moveFeedbackAreaToFirstPriority moveFeedbackAreaToFirstPriority}
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
     * can be used to bring a certain area covered by another area into action.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
     * If an area with specified <code>id</code> is already registered it is
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
     * updated. When updating an existing area there is no need to unregister it
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
     * before re-registering again with new coordinates and/or feedback style.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
     * The area specified by <code>x</code>, <code>y</code>, <code>width</code>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
     * and <code>height</code> parameters may be located on the screen just
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
     * partially.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
     *
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
     * <p>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
     * In case of area registry for eSWT Control, the registry needs to be
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
     * updated every time when the size or position of a UI component changes,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
     * or when e.g. a state of a UI component changes in such way that feedback
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
     * type also changes. Typically the area update may be implemented in
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
     * <code>controlMoved</code> and <code>controlResized</code> methods of
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
     * <code>ControlListener</code> interface. The update of an area may be
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
     * implemented by calling registerFeedbackArea with the same area id but new
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
     * coordinates and/or feedback style.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
     * <p>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
     * In case of area registry for LCDUI Canvas or CustomItem no further
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
     * actions are required to update tactile feedback areas when a CustomItem
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
     * is moved in a Form or when a Canvas is changed due to e.g. orientation
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
     * switch.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
     *
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
     * @param uiObject
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
     *            The UI component for tactile feedback registration. Valid
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
     *            object types are: <code>javax.microedition.lcdui.Canvas</code>
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
     *            , <code>javax.microedition.lcdui.CustomItem</code>,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
     *            <code>org.eclipse.swt.widgets.Control</code>.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
     * @param id
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
     *            Id of the new tactile feedback area to be registered. Id's are
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
     *            used to identify particular tactile feedback area within one
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
     *            UI component. Id's do not need to be consecutive numbers.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
     * @param x
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
     *            x-coordinate of the top-left corner of tactile feedback
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
     *            rectangle to register.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
     * @param y
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
     *            y-coordinate of the top-left corner of tactile feedback
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
     *            rectangle to register.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
     * @param width
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
     *            Width of tactile feedback rectangle to register.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
     * @param height
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
     *            Height of tactile feedback rectangle to register.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
     * @param style
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
     *            The style of the feedback for specified area. Use predefined
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
     *            values <code>FEEDBACK_STYLE_BASIC</code>,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
     *            <code>FEEDBACK_STYLE_SENSITIVE</code>. Actual style behaviour
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
     *            is defined through device settings.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
     * @throws IllegalArgumentException
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
     *             if the uiObject parameter has invalid type.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
     * @throws IllegalArgumentException
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
     *             if the style parameter has invalid type.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
     */
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
    public void registerFeedbackArea(Object uiObject, int id, int x, int y,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
                                     int width, int height, int style) throws IllegalArgumentException
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
    {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
        int type = controlType(uiObject);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
        if (type == TYPE_INVALID)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
            throw new IllegalArgumentException(invalidControlTypeMsg);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
        if ((style != FEEDBACK_STYLE_BASIC)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
                && (style != FEEDBACK_STYLE_SENSITIVE))
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
            throw new IllegalArgumentException(invalidFeedbackStyleMsg);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
        int controlHandle = getControlHandle(uiObject);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
        if (type == TYPE_LCDUI)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
            final int fControlHandle = controlHandle;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
            final int fId = id;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
            final int fX = x;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
            final int fY = y;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
            final int fWidth = width;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
            final int fHeight = height;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
            final int fStyle = style;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
            com.nokia.mj.impl.nokialcdui.LCDUIInvoker
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
            .eSWTUIThreadRunnerSyncExec(new Runnable()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
            {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
                public void run()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
                {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
                    OS.MTouchFeedback_SetFeedbackArea(fControlHandle,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
                                                      fId, fX, fY, fWidth, fHeight, fStyle);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
                }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
            });
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
        else
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
            OS.MTouchFeedback_SetFeedbackArea(controlHandle, id, x, y, width,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
                                              height, style);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
    }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
    /**
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
     * Unregisters tactile feedback area within a UI component.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
     *
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
     * @param uiObject
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
     *            The UI component for tactile feedback area de-registration.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
     *            Valid object types are:
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
     *            <code>javax.microedition.lcdui.Canvas</code>,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
     *            <code>javax.microedition.lcdui.CustomItem</code>,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
     *            <code>org.eclipse.swt.widgets.Control</code>.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
     * @param id
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
     *            Id of the tactile feedback area to be unregistered. Id's are
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
     *            used to identify particular tactile feedback area within one
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
     *            UI component. If given id was not registered by
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
     *            {@link #registerFeedbackArea registerFeedbackArea} then the
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
     *            call has no effect.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
     * @throws IllegalArgumentException
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
     *             if the uiObject parameter has invalid type.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
     */
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
    public void unregisterFeedbackArea(Object uiObject, int id)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
    throws IllegalArgumentException
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
    {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
        int type = controlType(uiObject);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
        if (type == TYPE_INVALID)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
            throw new IllegalArgumentException(invalidControlTypeMsg);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
        int controlHandle = getControlHandle(uiObject);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
        if (type == TYPE_LCDUI)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
            final int fControlHandle = controlHandle;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
            final int fId = id;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
            com.nokia.mj.impl.nokialcdui.LCDUIInvoker
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
            .eSWTUIThreadRunnerSyncExec(new Runnable()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
            {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
                public void run()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
                {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
                    OS.MTouchFeedback_RemoveFeedbackArea(
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
                        fControlHandle, fId);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
                }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
            });
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
        else
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
            OS.MTouchFeedback_RemoveFeedbackArea(controlHandle, id);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
    }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
    /**
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
     * Removes all tactile feedback for a UI component.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
     *
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
     * @param uiObject
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
     *            The UI component for tactile feedback area de-registration.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
     *            Valid object types are:
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
     *            <code>javax.microedition.lcdui.Canvas</code>,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
     *            <code>javax.microedition.lcdui.CustomItem</code>,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
     *            <code>org.eclipse.swt.widgets.Control</code>.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
     * @throws IllegalArgumentException
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
     *             if the uiObject parameter has invalid type.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
     */
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
    public void removeFeedbackForComponent(Object uiObject)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
    {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
        if (isTouchFeedbackSupported() == false)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
            return;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
        int type = controlType(uiObject);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
        if (type == TYPE_INVALID)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
            throw new IllegalArgumentException(invalidControlTypeMsg);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
        int controlHandle = getControlHandle(uiObject);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
        if (type == TYPE_LCDUI)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
            final int fControlHandle = controlHandle;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
            com.nokia.mj.impl.nokialcdui.LCDUIInvoker
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
            .eSWTUIThreadRunnerSyncExec(new Runnable()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
            {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
                public void run()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
                {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
                    OS.MTouchFeedback_RemoveFeedbackForControl(fControlHandle);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
                }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
            });
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
        else
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
            OS.MTouchFeedback_RemoveFeedbackForControl(controlHandle);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
    }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
    /**
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
     * Moves the specified tactile feedback area to first priority. Priority is
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
     * significant in case of overlapping tactile feedback areas. If the tactile
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
     * feedback styles of registered areas are different, the feedback from
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
     * first-priority area will be given.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
     *
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
     * @param uiObject
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
     *            The UI component for tactile feedback area de-registration.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
     *            Valid object types are:
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
     *            <code>javax.microedition.lcdui.Canvas</code>,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
     *            <code>javax.microedition.lcdui.CustomItem</code>,
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
     *            <code>org.eclipse.swt.widgets.Control</code>.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
     * @param id
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
     *            Id of the tactile feedback area to be unregistered. Id's are
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
     *            used to identify particular tactile feedback area within one
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
     *            UI component. If given id was not registered by
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
     *            {@link #registerFeedbackArea registerFeedbackArea} then the
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
     *            call has no effect.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
     * @throws IllegalArgumentException
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
     *             if the uiObject parameter has invalid type.
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
     */
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
    public void moveFeedbackAreaToFirstPriority(Object uiObject, int id)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
    {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
        if (isTouchFeedbackSupported() == false)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
            return;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
        int type = controlType(uiObject);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
        if (type == TYPE_INVALID)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
            throw new IllegalArgumentException(invalidControlTypeMsg);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
        int controlHandle = getControlHandle(uiObject);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
        if (type == TYPE_LCDUI)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
            final int fControlHandle = controlHandle;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
            final int fId = id;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
            com.nokia.mj.impl.nokialcdui.LCDUIInvoker
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
            .eSWTUIThreadRunnerSyncExec(new Runnable()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
            {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
                public void run()
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
                {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
                    OS.MTouchFeedback_MoveFeedbackAreaToFirstPriority(
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
                        fControlHandle, fId);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
                }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
            });
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
        else
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
            OS.MTouchFeedback_MoveFeedbackAreaToFirstPriority(
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
                controlHandle, id);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
    }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
    private int controlType(Object obj)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
    {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
        if ((obj instanceof javax.microedition.lcdui.Canvas)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
                || (obj instanceof javax.microedition.lcdui.CustomItem))
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
            return TYPE_LCDUI;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
        else if ((obj instanceof org.eclipse.swt.widgets.Control))
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
            return TYPE_ESWT;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
        return TYPE_INVALID;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
    }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
    private int getControlHandle(Object uiObject)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
    {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
        int controlHandle = 0;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
        org.eclipse.swt.widgets.Control eSwtControl = null;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
        if (uiObject instanceof javax.microedition.lcdui.Canvas
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
                || uiObject instanceof javax.microedition.lcdui.CustomItem)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
            eSwtControl = com.nokia.mj.impl.nokialcdui.LCDUIInvoker
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
                          .getEswtControl(uiObject);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
        else if (uiObject instanceof org.eclipse.swt.widgets.Control)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
            eSwtControl = (org.eclipse.swt.widgets.Control) uiObject;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
        if (eSwtControl != null)
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
        {
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
            controlHandle = Internal_PackageSupport.topHandle(eSwtControl);
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
        }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
        return controlHandle;
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
    }
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
2f468c1958d0 Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
}