29
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2005, 2006 IBM Corporation and others.
|
|
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 * IBM Corporation - initial API and implementation
|
|
10 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwtx.jface.fieldassist.IControlContentAdapter;
|
|
14
|
|
15 import dwt.graphics.Rectangle;
|
|
16 import dwt.widgets.Control;
|
|
17
|
|
18 import dwt.dwthelper.utils;
|
|
19
|
|
20 /**
|
|
21 * This interface is used to set and retrieve text content from an arbitrary
|
|
22 * control. Clients are expected to implement this interface when defining a
|
|
23 * {@link ContentProposalAdapter}, in order to specify how to retrieve and set
|
|
24 * the contents of the control being adapted.
|
|
25 *
|
|
26 * @since 3.2
|
|
27 */
|
|
28 public interface IControlContentAdapter {
|
|
29 /**
|
|
30 * Set the contents of the specified control to the specified text. Must not
|
|
31 * be <code>null</code>.
|
|
32 *
|
|
33 * @param control
|
|
34 * the control whose contents are to be set (replaced).
|
|
35 * @param contents
|
|
36 * the String specifying the new control content.
|
|
37 * @param cursorPosition
|
|
38 * the zero-based index representing the desired cursor position
|
|
39 * in the control's contents after the contents are set.
|
|
40 */
|
|
41 public void setControlContents(Control control, String contents,
|
|
42 int cursorPosition);
|
|
43
|
|
44 /**
|
|
45 * Insert the specified contents into the control's current contents. Must
|
|
46 * not be <code>null</code>.
|
|
47 *
|
|
48 * @param control
|
|
49 * the control whose contents are to be altered.
|
|
50 * @param contents
|
|
51 * the String to be inserted into the control contents.
|
|
52 * @param cursorPosition
|
|
53 * the zero-based index representing the desired cursor position
|
|
54 * within the inserted contents after the insertion is made.
|
|
55 */
|
|
56 public void insertControlContents(Control control, String contents,
|
|
57 int cursorPosition);
|
|
58
|
|
59 /**
|
|
60 * Get the text contents of the control.
|
|
61 *
|
|
62 * @param control
|
|
63 * the control whose contents are to be retrieved.
|
|
64 * @return the String contents of the control.
|
|
65 */
|
|
66 public String getControlContents(Control control);
|
|
67
|
|
68 /**
|
|
69 * Get the current cursor position in the control. The position is specified
|
|
70 * as a zero-based index into the string. Valid ranges are from 0 to N,
|
|
71 * where N is the size of the contents string. A value of N indicates that
|
|
72 * the cursor is at the end of the contents.
|
|
73 *
|
|
74 * @param control
|
|
75 * the control whose position is to be retrieved.
|
|
76 * @return the zero-based index representing the cursor position in the
|
|
77 * control's contents.
|
|
78 */
|
|
79 public int getCursorPosition(Control control);
|
|
80
|
|
81 /**
|
|
82 * Get the bounds (in pixels) of the insertion point for the control
|
|
83 * content. This is a rectangle, in coordinates relative to the control,
|
|
84 * where the insertion point is displayed. If the implementer does not have
|
|
85 * an insertion point, or cannot determine the location of the insertion
|
|
86 * point, it is appropriate to return the bounds of the entire control. This
|
|
87 * value may be used to position a content proposal popup.
|
|
88 *
|
|
89 * @param control
|
|
90 * the control whose offset is to be retrieved.
|
|
91 * @return the pixel width representing the distance between the edge of the
|
|
92 * control and the insertion point.
|
|
93 */
|
|
94 public Rectangle getInsertionBounds(Control control);
|
|
95
|
|
96 /**
|
|
97 * Set the current cursor position in the control. The position is specified
|
|
98 * as a zero-based index into the string. Valid ranges are from 0 to N,
|
|
99 * where N is the size of the contents string. A value of N indicates that
|
|
100 * the cursor is at the end of the contents.
|
|
101 *
|
|
102 * @param control
|
|
103 * the control whose cursor position is to be set.
|
|
104 * @param index
|
|
105 * the zero-based index representing the cursor position in the
|
|
106 * control's contents.
|
|
107 */
|
|
108 public void setCursorPosition(Control control, int index);
|
|
109 }
|