Mercurial > projects > dwt-addons
comparison dwtx/jface/text/IInformationControl.d @ 129:eb30df5ca28b
Added JFace Text sources
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 23 Aug 2008 19:10:48 +0200 |
parents | |
children | c4fb132a086c |
comparison
equal
deleted
inserted
replaced
128:8df1d4193877 | 129:eb30df5ca28b |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2008 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 | |
14 module dwtx.jface.text.IInformationControl; | |
15 | |
16 import dwt.dwthelper.utils; | |
17 | |
18 | |
19 import dwt.DWT; | |
20 import dwt.events.DisposeListener; | |
21 import dwt.events.FocusListener; | |
22 import dwt.graphics.Color; | |
23 import dwt.graphics.Point; | |
24 | |
25 | |
26 /** | |
27 * Interface of a control presenting information. The information is given in | |
28 * the form of an input object. It can be either the content itself or a | |
29 * description of the content. The specification of what is required from an | |
30 * input object is left to the implementers of this interface. | |
31 * <p> | |
32 * <em>If this information control is used by a {@link AbstractHoverInformationControlManager} | |
33 * then that manager will own this control and override any properties that | |
34 * may have been set before by any other client.</em></p> | |
35 * <p> | |
36 * The information control must not grab focus when made visible using | |
37 * <code>setVisible(true)</code>. | |
38 * | |
39 * In order to provide backward compatibility for clients of | |
40 * <code>IInformationControl</code>, extension interfaces are used as a means | |
41 * of evolution. The following extension interfaces exist: | |
42 * <ul> | |
43 * <li>{@link dwtx.jface.text.IInformationControlExtension} since | |
44 * version 2.0 introducing the predicate of whether the control has anything to | |
45 * show or would be empty</li> | |
46 * <li>{@link dwtx.jface.text.IInformationControlExtension2} since | |
47 * version 2.1 replacing the original concept of textual input by general input | |
48 * objects.</li> | |
49 * <li>{@link dwtx.jface.text.IInformationControlExtension3} since | |
50 * version 3.0 providing access to the control's bounds and introducing | |
51 * the concept of persistent size and location.</li> | |
52 * <li>{@link dwtx.jface.text.IInformationControlExtension4} since | |
53 * version 3.3, adding API which allows to set this information control's status field text.</li> | |
54 * <li>{@link dwtx.jface.text.IInformationControlExtension5} since | |
55 * version 3.4, adding API to get the visibility of the control, to | |
56 * test whether another control is a child of the information control, | |
57 * to compute size constraints based on the information control's main font | |
58 * and to return a control creator for an enriched version of this information control.</li> | |
59 * </ul> | |
60 * <p> | |
61 * Clients can implement this interface and its extension interfaces, | |
62 * subclass {@link AbstractInformationControl}, or use the (text-based) | |
63 * default implementation {@link DefaultInformationControl}. | |
64 * | |
65 * @see dwtx.jface.text.IInformationControlExtension | |
66 * @see dwtx.jface.text.IInformationControlExtension2 | |
67 * @see dwtx.jface.text.IInformationControlExtension3 | |
68 * @see dwtx.jface.text.IInformationControlExtension4 | |
69 * @see dwtx.jface.text.IInformationControlExtension5 | |
70 * @see AbstractInformationControl | |
71 * @see DefaultInformationControl | |
72 * @since 2.0 | |
73 */ | |
74 public interface IInformationControl { | |
75 | |
76 /** | |
77 * Sets the information to be presented by this information control. | |
78 * <p> | |
79 * Replaced by {@link IInformationControlExtension2#setInput(Object)}. | |
80 * | |
81 * @param information the information to be presented | |
82 */ | |
83 void setInformation(String information); | |
84 | |
85 /** | |
86 * Sets the information control's size constraints. A constraint value of | |
87 * {@link DWT#DEFAULT} indicates no constraint. This method must be called before | |
88 * {@link #computeSizeHint()} is called. | |
89 * <p> | |
90 * Note: An information control which implements {@link IInformationControlExtension3} | |
91 * may ignore this method or use it as hint for its very first appearance. | |
92 * </p> | |
93 * @param maxWidth the maximal width of the control to present the information, or {@link DWT#DEFAULT} for not constraint | |
94 * @param maxHeight the maximal height of the control to present the information, or {@link DWT#DEFAULT} for not constraint | |
95 */ | |
96 void setSizeConstraints(int maxWidth, int maxHeight); | |
97 | |
98 /** | |
99 * Computes and returns a proposal for the size of this information control depending | |
100 * on the information to present. The method tries to honor known size constraints but might | |
101 * return a size that exceeds them. | |
102 * | |
103 * @return the computed size hint | |
104 */ | |
105 Point computeSizeHint(); | |
106 | |
107 /** | |
108 * Controls the visibility of this information control. | |
109 * <p> | |
110 * <strong>Note:</strong> The information control must not grab focus when | |
111 * made visible. | |
112 * </p> | |
113 * | |
114 * @param visible <code>true</code> if the control should be visible | |
115 */ | |
116 void setVisible(bool visible); | |
117 | |
118 /** | |
119 * Sets the size of this information control. | |
120 * | |
121 * @param width the width of the control | |
122 * @param height the height of the control | |
123 */ | |
124 void setSize(int width, int height); | |
125 | |
126 /** | |
127 * Sets the location of this information control. | |
128 * | |
129 * @param location the location | |
130 */ | |
131 void setLocation(Point location); | |
132 | |
133 /** | |
134 * Disposes this information control. | |
135 */ | |
136 void dispose(); | |
137 | |
138 /** | |
139 * Adds the given listener to the list of dispose listeners. | |
140 * If the listener is already registered it is not registered again. | |
141 * | |
142 * @param listener the listener to be added | |
143 */ | |
144 void addDisposeListener(DisposeListener listener); | |
145 | |
146 /** | |
147 * Removes the given listeners from the list of dispose listeners. | |
148 * If the listener is not registered this call has no effect. | |
149 * | |
150 * @param listener the listener to be removed | |
151 */ | |
152 void removeDisposeListener(DisposeListener listener); | |
153 | |
154 /** | |
155 * Sets the foreground color of this information control. | |
156 * | |
157 * @param foreground the foreground color of this information control | |
158 */ | |
159 void setForegroundColor(Color foreground); | |
160 | |
161 /** | |
162 * Sets the background color of this information control. | |
163 * | |
164 * @param background the background color of this information control | |
165 */ | |
166 void setBackgroundColor(Color background); | |
167 | |
168 /** | |
169 * Returns whether this information control (or one of its children) has the focus. | |
170 * The suggested implementation is like this (<code>fShell</code> is this information control's shell): | |
171 * <pre>return fShell.getDisplay().getActiveShell() is fShell</pre> | |
172 * | |
173 * @return <code>true</code> when the information control has the focus, otherwise <code>false</code> | |
174 */ | |
175 bool isFocusControl(); | |
176 | |
177 /** | |
178 * Sets the keyboard focus to this information control. | |
179 */ | |
180 void setFocus(); | |
181 | |
182 /** | |
183 * Adds the given listener to the list of focus listeners. | |
184 * If the listener is already registered it is not registered again. | |
185 * <p> | |
186 * The suggested implementation is to install listeners for {@link DWT#Activate} and {@link DWT#Deactivate} | |
187 * on the shell and forward events to the focus listeners. Clients are | |
188 * encouraged to subclass {@link AbstractInformationControl}, which does this | |
189 * for free. | |
190 * </p> | |
191 * | |
192 * @param listener the listener to be added | |
193 */ | |
194 void addFocusListener(FocusListener listener); | |
195 | |
196 /** | |
197 * Removes the given listeners from the list of focus listeners. | |
198 * If the listener is not registered this call has no affect. | |
199 * | |
200 * @param listener the listener to be removed | |
201 */ | |
202 void removeFocusListener(FocusListener listener); | |
203 } |