javauis/lcdui_akn/javalcdui/javasrc.nokialcdui/com/nokia/mid/ui/TextEditorTouchControl.java
branchRCL_3
changeset 83 26b2b12093af
parent 77 7cee158cb8cd
child 84 0553e2305d00
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  TextEditor-API alignment for Nokia-UI
       
    15 *
       
    16 */
       
    17 package com.nokia.mid.ui;
       
    18 
       
    19 import com.nokia.mid.ui.TextEditorListener;
       
    20 
       
    21 /**
       
    22  * Touch-devices can use a virtual control-panel to replace physical keys, and to facilitate
       
    23  * textual input. The purpose of this interface is to provide some level of access and control over such a panel, when
       
    24  * using the TextEditor-API. <p>
       
    25  *
       
    26  * MIDlets can obtain an instance of this interface via the {@link TextEditorExtensionAccess} in the
       
    27  * following way:
       
    28  * <pre>
       
    29  * TextEditor editor = com.nokia.mid.ui.TextEditor.createTextEditor("hello world", 50, TextField.ANY, 100, 100);
       
    30  * TextEditorTouchControl touchControl = ((TextEditorExtensionAccess)editor).getTouchControl();
       
    31  * if(touchControl!=null){
       
    32  *   // this is a touch-device
       
    33  * }
       
    34  * else{
       
    35  *   // this is a non-touch-device
       
    36  * }
       
    37  * </pre>
       
    38  * The instance is associated with the editor it has been obtained from, and controls only this editor.<p>
       
    39  *
       
    40  * Because a control-panel covers parts of the display which would otherwise be available to the application, MIDlets may
       
    41  * choose to only display the panel at certain times, e.g. when the editor is focussed. This is possible with
       
    42  * {@link TextEditorTouchControl#setPanelMode(int)}. Furthermore, a panel can be positioned anywhere an the display via
       
    43  * {@link TextEditorTouchControl#setPanelPosition(int, int)}. This interface also allows to query the size of the panel, so
       
    44  * that applications can integrate it into the Canvas. <p>
       
    45  *
       
    46  * On touch-devices, the platform can make use of pointer-input to let the user interact with a TextEditor on a Canvas, without
       
    47  * that the application knows about this. For example, if the user taps with his stylus or finger somewhere inside a visible
       
    48  * and focussed TextEditor, the MIDlet might not receive any notification about this via the Canvas-methods pointerPressed,
       
    49  * pointerDragged or pointerReleased. Instead, the platform could change the position of the cursor and generate the
       
    50  * according event for the editors {@link TextEditorListener}. Or it may even just ignore this event completely. In general,
       
    51  * an application should not expect to receive any pointer-events after a "press" inside a focussed TextEditor.
       
    52  * Under certain circumstances however, for example as a response to the {@link com.nokia.mid.ui.TextEditorListener#ACTION_TRAVERSE_OUT_SCROLL_UP}
       
    53  * or {@link com.nokia.mid.ui.TextEditorListener#ACTION_TRAVERSE_OUT_SCROLL_DOWN} event, an application can decide at any time to override this
       
    54  * behaviour, and force the platform to deliver all subsequent pointer-events to the Canvas.
       
    55  * This can be done with {@link TextEditorTouchControl#setTouchEnabled(boolean)}. Note that a TextEditor which has been touch-disabled
       
    56  * this way will not be able to perform any interaction like cursor-positioning or scrolling via touch-input, until is has been
       
    57  * enabled again.
       
    58  */
       
    59 public interface TextEditorTouchControl
       
    60 {
       
    61 
       
    62 
       
    63     //native_const(JAVA_TEXTEDITOR)
       
    64     //{
       
    65 
       
    66     /**
       
    67      * Constant to disable the display of a keypad/control-panel
       
    68      */
       
    69     public static final int PANEL_OFF = 1;
       
    70 
       
    71     /**
       
    72      * Constant to enable the display of a keypad/control-panel.
       
    73      * In this mode the user cannot change the position of the panel, however
       
    74      * the MIDlet can still do so via {@link TextEditorTouchControl#setPanelPosition(int, int)}
       
    75      */
       
    76     public static final int PANEL_FIXED_POSITION = 2;
       
    77 
       
    78     /**
       
    79      * Constant to enable the display of a keypad/control-panel.
       
    80      * In this mode, the user can change the position of the panel of the display e.g. by
       
    81      * dragging, if this is supported by the device. Changes to the position will generate the
       
    82      * {@link TextEditorTouchControl#ACTION_PANEL_MOVED}-event. The current panel-position is
       
    83      * provided via {@link TextEditorTouchControl#getPanelX()} and {@link TextEditorTouchControl#getPanelY()}
       
    84      */
       
    85     public static final int PANEL_FLOATING = 3;
       
    86     //}
       
    87 
       
    88     /**
       
    89      * Event to indicate that the keypad/control-panel has been moved by the user
       
    90      */
       
    91     public static final int ACTION_PANEL_MOVED = 0x10000000;
       
    92 
       
    93 
       
    94     /**
       
    95      * Controls the behaviour of the virtual keypad/control-panel, if the device provides one.
       
    96      * This is a hint which may be disregarded if the device does not support a virtual keypad/control-panel.
       
    97      * @param mode One of {@link TextEditorTouchControl#PANEL_OFF} {@link TextEditorTouchControl#PANEL_FIXED_POSITION}
       
    98      * or {@link TextEditorTouchControl#PANEL_FLOATING}
       
    99      */
       
   100     public void setPanelMode(int mode);
       
   101 
       
   102     /**
       
   103      * Gets the current panel-mode
       
   104      * @return the mode, see {@link TextEditorTouchControl#setPanelMode(int)}
       
   105      */
       
   106     public int getPanelMode();
       
   107 
       
   108     /**
       
   109      * Sets the position of the panel on the display.
       
   110      * @param x x-position of the keypad
       
   111      * @param y y-position of the keypad
       
   112      */
       
   113     public void setPanelPosition(int x, int y);
       
   114 
       
   115     /**
       
   116      * Gets the width of the panel
       
   117      * @return the width
       
   118      */
       
   119     public int getPanelWidth();
       
   120 
       
   121     /**
       
   122      * Gets the height of the panel
       
   123      * @return the height
       
   124      */
       
   125     public int getPanelHeight();
       
   126 
       
   127     /**
       
   128      * Gets the current x-position of the panel on the display
       
   129      * @return the x-coordinate
       
   130      */
       
   131     public int getPanelX();
       
   132 
       
   133     /**
       
   134      * Gets the current y-position of the panel on the display
       
   135      * @return the y-coordinate
       
   136      */
       
   137     public int getPanelY();
       
   138 
       
   139     /**
       
   140      * Specifies whether or not the editor will receive touch-events. This is enabled by default.
       
   141      * An editor with touch-event disabled won't be able to perform any touch-related functionality
       
   142      * such as scrolling or positioning the cursor. It may however still be controlled via the
       
   143      * virtual keypad/control-panel if that is enabled, or receive other input e.g. via physical
       
   144      * keys
       
   145      * @param enabled true to enabled touch-event, false to disable
       
   146      */
       
   147     public void setTouchEnabled(boolean enabled);
       
   148 
       
   149     /**
       
   150      * Gets the current touch-enabled state
       
   151      * @return true if the editor is touch-enabled, false otherwise
       
   152      */
       
   153     public boolean isTouchEnabled();
       
   154 
       
   155     /**
       
   156      * Sets the caret as close as possible to a given x/y location. This is a hint to the implementation
       
   157      * that may be disregarded.
       
   158      * @param x new x-coordinate for the caret, relative to the editors origin
       
   159      * @param y new y-coordinate for the caret, relative to the editors origin
       
   160      */
       
   161     public void setCaret(int x, int y);
       
   162 
       
   163 
       
   164 }