Mercurial > projects > dwt-addons
annotate dwtx/jface/text/DefaultInformationControl.d @ 162:1a5b8f8129df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 08 Sep 2008 00:51:37 +0200 |
parents | 25f1f92fa3df |
children |
rev | line source |
---|---|
129 | 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 module dwtx.jface.text.DefaultInformationControl; | |
14 | |
131 | 15 import dwtx.jface.text.IDocumentPartitioningListener; // packageimport |
16 import dwtx.jface.text.DefaultTextHover; // packageimport | |
17 import dwtx.jface.text.AbstractInformationControl; // packageimport | |
18 import dwtx.jface.text.TextUtilities; // packageimport | |
19 import dwtx.jface.text.IInformationControlCreatorExtension; // packageimport | |
20 import dwtx.jface.text.AbstractInformationControlManager; // packageimport | |
21 import dwtx.jface.text.ITextViewerExtension2; // packageimport | |
22 import dwtx.jface.text.IDocumentPartitioner; // packageimport | |
23 import dwtx.jface.text.DefaultIndentLineAutoEditStrategy; // packageimport | |
24 import dwtx.jface.text.ITextSelection; // packageimport | |
25 import dwtx.jface.text.Document; // packageimport | |
26 import dwtx.jface.text.FindReplaceDocumentAdapterContentProposalProvider; // packageimport | |
27 import dwtx.jface.text.ITextListener; // packageimport | |
28 import dwtx.jface.text.BadPartitioningException; // packageimport | |
29 import dwtx.jface.text.ITextViewerExtension5; // packageimport | |
30 import dwtx.jface.text.IDocumentPartitionerExtension3; // packageimport | |
31 import dwtx.jface.text.IUndoManager; // packageimport | |
32 import dwtx.jface.text.ITextHoverExtension2; // packageimport | |
33 import dwtx.jface.text.IRepairableDocument; // packageimport | |
34 import dwtx.jface.text.IRewriteTarget; // packageimport | |
35 import dwtx.jface.text.DefaultPositionUpdater; // packageimport | |
36 import dwtx.jface.text.RewriteSessionEditProcessor; // packageimport | |
37 import dwtx.jface.text.TextViewerHoverManager; // packageimport | |
38 import dwtx.jface.text.DocumentRewriteSession; // packageimport | |
39 import dwtx.jface.text.TextViewer; // packageimport | |
40 import dwtx.jface.text.ITextViewerExtension8; // packageimport | |
41 import dwtx.jface.text.RegExMessages; // packageimport | |
42 import dwtx.jface.text.IDelayedInputChangeProvider; // packageimport | |
43 import dwtx.jface.text.ITextOperationTargetExtension; // packageimport | |
44 import dwtx.jface.text.IWidgetTokenOwner; // packageimport | |
45 import dwtx.jface.text.IViewportListener; // packageimport | |
46 import dwtx.jface.text.GapTextStore; // packageimport | |
47 import dwtx.jface.text.MarkSelection; // packageimport | |
48 import dwtx.jface.text.IDocumentPartitioningListenerExtension; // packageimport | |
49 import dwtx.jface.text.IDocumentAdapterExtension; // packageimport | |
50 import dwtx.jface.text.IInformationControlExtension; // packageimport | |
51 import dwtx.jface.text.IDocumentPartitioningListenerExtension2; // packageimport | |
52 import dwtx.jface.text.DefaultDocumentAdapter; // packageimport | |
53 import dwtx.jface.text.ITextViewerExtension3; // packageimport | |
54 import dwtx.jface.text.IInformationControlCreator; // packageimport | |
55 import dwtx.jface.text.TypedRegion; // packageimport | |
56 import dwtx.jface.text.ISynchronizable; // packageimport | |
57 import dwtx.jface.text.IMarkRegionTarget; // packageimport | |
58 import dwtx.jface.text.TextViewerUndoManager; // packageimport | |
59 import dwtx.jface.text.IRegion; // packageimport | |
60 import dwtx.jface.text.IInformationControlExtension2; // packageimport | |
61 import dwtx.jface.text.IDocumentExtension4; // packageimport | |
62 import dwtx.jface.text.IDocumentExtension2; // packageimport | |
63 import dwtx.jface.text.IDocumentPartitionerExtension2; // packageimport | |
64 import dwtx.jface.text.Assert; // packageimport | |
65 import dwtx.jface.text.IWidgetTokenOwnerExtension; // packageimport | |
66 import dwtx.jface.text.DocumentClone; // packageimport | |
67 import dwtx.jface.text.DefaultUndoManager; // packageimport | |
68 import dwtx.jface.text.IFindReplaceTarget; // packageimport | |
69 import dwtx.jface.text.IAutoEditStrategy; // packageimport | |
70 import dwtx.jface.text.ILineTrackerExtension; // packageimport | |
71 import dwtx.jface.text.IUndoManagerExtension; // packageimport | |
72 import dwtx.jface.text.TextSelection; // packageimport | |
73 import dwtx.jface.text.DefaultAutoIndentStrategy; // packageimport | |
74 import dwtx.jface.text.IAutoIndentStrategy; // packageimport | |
75 import dwtx.jface.text.IPainter; // packageimport | |
76 import dwtx.jface.text.IInformationControl; // packageimport | |
77 import dwtx.jface.text.IInformationControlExtension3; // packageimport | |
78 import dwtx.jface.text.ITextViewerExtension6; // packageimport | |
79 import dwtx.jface.text.IInformationControlExtension4; // packageimport | |
80 import dwtx.jface.text.DefaultLineTracker; // packageimport | |
81 import dwtx.jface.text.IDocumentInformationMappingExtension; // packageimport | |
82 import dwtx.jface.text.IRepairableDocumentExtension; // packageimport | |
83 import dwtx.jface.text.ITextHover; // packageimport | |
84 import dwtx.jface.text.FindReplaceDocumentAdapter; // packageimport | |
85 import dwtx.jface.text.ILineTracker; // packageimport | |
86 import dwtx.jface.text.Line; // packageimport | |
87 import dwtx.jface.text.ITextViewerExtension; // packageimport | |
88 import dwtx.jface.text.IDocumentAdapter; // packageimport | |
89 import dwtx.jface.text.TextEvent; // packageimport | |
90 import dwtx.jface.text.BadLocationException; // packageimport | |
91 import dwtx.jface.text.AbstractDocument; // packageimport | |
92 import dwtx.jface.text.AbstractLineTracker; // packageimport | |
93 import dwtx.jface.text.TreeLineTracker; // packageimport | |
94 import dwtx.jface.text.ITextPresentationListener; // packageimport | |
95 import dwtx.jface.text.Region; // packageimport | |
96 import dwtx.jface.text.ITextViewer; // packageimport | |
97 import dwtx.jface.text.IDocumentInformationMapping; // packageimport | |
98 import dwtx.jface.text.MarginPainter; // packageimport | |
99 import dwtx.jface.text.IPaintPositionManager; // packageimport | |
100 import dwtx.jface.text.TextPresentation; // packageimport | |
101 import dwtx.jface.text.IFindReplaceTargetExtension; // packageimport | |
102 import dwtx.jface.text.ISlaveDocumentManagerExtension; // packageimport | |
103 import dwtx.jface.text.ISelectionValidator; // packageimport | |
104 import dwtx.jface.text.IDocumentExtension; // packageimport | |
105 import dwtx.jface.text.PropagatingFontFieldEditor; // packageimport | |
106 import dwtx.jface.text.ConfigurableLineTracker; // packageimport | |
107 import dwtx.jface.text.SlaveDocumentEvent; // packageimport | |
108 import dwtx.jface.text.IDocumentListener; // packageimport | |
109 import dwtx.jface.text.PaintManager; // packageimport | |
110 import dwtx.jface.text.IFindReplaceTargetExtension3; // packageimport | |
111 import dwtx.jface.text.ITextDoubleClickStrategy; // packageimport | |
112 import dwtx.jface.text.IDocumentExtension3; // packageimport | |
113 import dwtx.jface.text.Position; // packageimport | |
114 import dwtx.jface.text.TextMessages; // packageimport | |
115 import dwtx.jface.text.CopyOnWriteTextStore; // packageimport | |
116 import dwtx.jface.text.WhitespaceCharacterPainter; // packageimport | |
117 import dwtx.jface.text.IPositionUpdater; // packageimport | |
118 import dwtx.jface.text.DefaultTextDoubleClickStrategy; // packageimport | |
119 import dwtx.jface.text.ListLineTracker; // packageimport | |
120 import dwtx.jface.text.ITextInputListener; // packageimport | |
121 import dwtx.jface.text.BadPositionCategoryException; // packageimport | |
122 import dwtx.jface.text.IWidgetTokenKeeperExtension; // packageimport | |
123 import dwtx.jface.text.IInputChangedListener; // packageimport | |
124 import dwtx.jface.text.ITextOperationTarget; // packageimport | |
125 import dwtx.jface.text.IDocumentInformationMappingExtension2; // packageimport | |
126 import dwtx.jface.text.ITextViewerExtension7; // packageimport | |
127 import dwtx.jface.text.IInformationControlExtension5; // packageimport | |
128 import dwtx.jface.text.IDocumentRewriteSessionListener; // packageimport | |
129 import dwtx.jface.text.JFaceTextUtil; // packageimport | |
130 import dwtx.jface.text.AbstractReusableInformationControlCreator; // packageimport | |
131 import dwtx.jface.text.TabsToSpacesConverter; // packageimport | |
132 import dwtx.jface.text.CursorLinePainter; // packageimport | |
133 import dwtx.jface.text.ITextHoverExtension; // packageimport | |
134 import dwtx.jface.text.IEventConsumer; // packageimport | |
135 import dwtx.jface.text.IDocument; // packageimport | |
136 import dwtx.jface.text.IWidgetTokenKeeper; // packageimport | |
137 import dwtx.jface.text.DocumentCommand; // packageimport | |
138 import dwtx.jface.text.TypedPosition; // packageimport | |
139 import dwtx.jface.text.IEditingSupportRegistry; // packageimport | |
140 import dwtx.jface.text.IDocumentPartitionerExtension; // packageimport | |
141 import dwtx.jface.text.AbstractHoverInformationControlManager; // packageimport | |
142 import dwtx.jface.text.IEditingSupport; // packageimport | |
143 import dwtx.jface.text.IMarkSelection; // packageimport | |
144 import dwtx.jface.text.ISlaveDocumentManager; // packageimport | |
145 import dwtx.jface.text.DocumentEvent; // packageimport | |
146 import dwtx.jface.text.DocumentPartitioningChangedEvent; // packageimport | |
147 import dwtx.jface.text.ITextStore; // packageimport | |
148 import dwtx.jface.text.JFaceTextMessages; // packageimport | |
149 import dwtx.jface.text.DocumentRewriteSessionEvent; // packageimport | |
150 import dwtx.jface.text.SequentialRewriteTextStore; // packageimport | |
151 import dwtx.jface.text.DocumentRewriteSessionType; // packageimport | |
152 import dwtx.jface.text.TextAttribute; // packageimport | |
153 import dwtx.jface.text.ITextViewerExtension4; // packageimport | |
154 import dwtx.jface.text.ITypedRegion; // packageimport | |
155 | |
156 | |
129 | 157 import dwt.dwthelper.utils; |
158 | |
159 | |
160 | |
161 import dwt.DWT; | |
162 import dwt.custom.StyledText; | |
163 import dwt.events.DisposeEvent; | |
164 import dwt.events.DisposeListener; | |
165 import dwt.graphics.Color; | |
166 import dwt.graphics.Drawable; | |
167 import dwt.graphics.Point; | |
168 import dwt.graphics.Rectangle; | |
169 import dwt.layout.FillLayout; | |
170 import dwt.widgets.Composite; | |
171 import dwt.widgets.Display; | |
172 import dwt.widgets.Shell; | |
173 import dwtx.jface.action.ToolBarManager; | |
174 import dwtx.jface.internal.text.html.HTMLTextPresenter; | |
175 import dwtx.jface.resource.JFaceResources; | |
176 import dwtx.jface.util.Geometry; | |
177 | |
178 /** | |
179 * An information presenter determines the style presentation | |
180 * of information displayed in the default information control. | |
181 * The interface can be implemented by clients. | |
182 */ | |
183 public interface IInformationPresenter { | |
184 | |
185 /** | |
186 * Updates the given presentation of the given information and | |
187 * thereby may manipulate the information to be displayed. The manipulation | |
188 * could be the extraction of textual encoded style information etc. Returns the | |
189 * manipulated information. | |
190 * <p> | |
191 * <strong>Note:</strong> The given display must only be used for measuring.</p> | |
192 * | |
193 * @param display the display of the information control | |
194 * @param hoverInfo the information to be presented | |
195 * @param presentation the presentation to be updated | |
196 * @param maxWidth the maximal width in pixels | |
197 * @param maxHeight the maximal height in pixels | |
198 * | |
199 * @return the manipulated information | |
200 * @deprecated As of 3.2, replaced by {@link DefaultInformationControl.IInformationPresenterExtension#updatePresentation(Drawable, String, TextPresentation, int, int)} | |
201 */ | |
202 String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight); | |
203 } | |
158 | 204 alias IInformationPresenter DefaultInformationControl_IInformationPresenter; |
156 | 205 |
129 | 206 /** |
207 * An information presenter determines the style presentation | |
208 * of information displayed in the default information control. | |
209 * The interface can be implemented by clients. | |
156 | 210 * |
129 | 211 * @since 3.2 |
212 */ | |
213 public interface IInformationPresenterExtension { | |
156 | 214 |
129 | 215 /** |
216 * Updates the given presentation of the given information and | |
217 * thereby may manipulate the information to be displayed. The manipulation | |
218 * could be the extraction of textual encoded style information etc. Returns the | |
219 * manipulated information. | |
220 * <p> | |
221 * Replaces {@link DefaultInformationControl.IInformationPresenter#updatePresentation(Display, String, TextPresentation, int, int)} | |
222 * Implementations should use the font of the given <code>drawable</code> to calculate | |
223 * the size of the text to be presented. | |
224 * </p> | |
225 * | |
226 * @param drawable the drawable of the information control | |
227 * @param hoverInfo the information to be presented | |
228 * @param presentation the presentation to be updated | |
229 * @param maxWidth the maximal width in pixels | |
230 * @param maxHeight the maximal height in pixels | |
231 * | |
232 * @return the manipulated information | |
233 */ | |
234 String updatePresentation(Drawable drawable, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight); | |
235 } | |
158 | 236 alias IInformationPresenterExtension DefaultInformationControl_IInformationPresenterExtension; |
156 | 237 |
129 | 238 |
158 | 239 /** |
240 * Default implementation of {@link dwtx.jface.text.IInformationControl}. | |
241 * <p> | |
242 * Displays textual information in a {@link dwt.custom.StyledText} | |
243 * widget. Before displaying, the information set to this information control is | |
244 * processed by an <code>IInformationPresenter</code>. | |
245 * | |
246 * @since 2.0 | |
247 */ | |
248 public class DefaultInformationControl : AbstractInformationControl , DisposeListener { | |
249 | |
129 | 250 /** |
251 * Inner border thickness in pixels. | |
252 * @since 3.1 | |
253 */ | |
147 | 254 private static const int INNER_BORDER= 1; |
129 | 255 |
256 /** The control's text widget */ | |
257 private StyledText fText; | |
258 /** The information presenter, or <code>null</code> if none. */ | |
146 | 259 private const IInformationPresenter fPresenter; |
129 | 260 /** A cached text presentation */ |
162 | 261 private const TextPresentation fPresentation; |
156 | 262 |
129 | 263 /** |
264 * Additional styles to use for the text control. | |
265 * @since 3.4, previously called <code>fTextStyle</code> | |
266 */ | |
146 | 267 private const int fAdditionalTextStyles; |
129 | 268 |
269 /** | |
270 * Creates a default information control with the given shell as parent. An information | |
271 * presenter that can handle simple HTML is used to process the information to be displayed. | |
156 | 272 * |
129 | 273 * @param parent the parent shell |
274 * @param isResizeable <code>true</code> if the control should be resizable | |
275 * @since 3.4 | |
276 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
277 public this(Shell parent, bool isResizeable) { |
162 | 278 fPresentation= new TextPresentation(); |
129 | 279 super(parent, isResizeable); |
280 fAdditionalTextStyles= isResizeable ? DWT.V_SCROLL | DWT.H_SCROLL : DWT.NONE; | |
281 fPresenter= new HTMLTextPresenter(!isResizeable); | |
282 create(); | |
283 } | |
284 | |
285 /** | |
286 * Creates a default information control with the given shell as parent. An information | |
287 * presenter that can handle simple HTML is used to process the information to be displayed. | |
156 | 288 * |
129 | 289 * @param parent the parent shell |
290 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field | |
291 * @since 3.4 | |
292 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
293 public this(Shell parent, String statusFieldText) { |
129 | 294 this(parent, statusFieldText, new HTMLTextPresenter(true)); |
295 } | |
296 | |
297 /** | |
298 * Creates a default information control with the given shell as parent. The | |
299 * given information presenter is used to process the information to be | |
300 * displayed. | |
156 | 301 * |
129 | 302 * @param parent the parent shell |
303 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field | |
304 * @param presenter the presenter to be used, or <code>null</code> if no presenter should be used | |
305 * @since 3.4 | |
306 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
307 public this(Shell parent, String statusFieldText, IInformationPresenter presenter) { |
162 | 308 fPresentation= new TextPresentation(); |
129 | 309 super(parent, statusFieldText); |
310 fAdditionalTextStyles= DWT.NONE; | |
311 fPresenter= presenter; | |
312 create(); | |
313 } | |
314 | |
315 /** | |
316 * Creates a resizable default information control with the given shell as parent. An | |
317 * information presenter that can handle simple HTML is used to process the information to be | |
318 * displayed. | |
156 | 319 * |
129 | 320 * @param parent the parent shell |
321 * @param toolBarManager the manager or <code>null</code> if toolbar is not desired | |
322 * @since 3.4 | |
323 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
324 public this(Shell parent, ToolBarManager toolBarManager) { |
129 | 325 this(parent, toolBarManager, new HTMLTextPresenter(false)); |
326 } | |
327 | |
328 /** | |
329 * Creates a resizable default information control with the given shell as | |
330 * parent. The given information presenter is used to process the | |
331 * information to be displayed. | |
156 | 332 * |
129 | 333 * @param parent the parent shell |
334 * @param toolBarManager the manager or <code>null</code> if toolbar is not desired | |
335 * @param presenter the presenter to be used, or <code>null</code> if no presenter should be used | |
336 * @since 3.4 | |
337 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
338 public this(Shell parent, ToolBarManager toolBarManager, IInformationPresenter presenter) { |
162 | 339 fPresentation= new TextPresentation(); |
129 | 340 super(parent, toolBarManager); |
341 fAdditionalTextStyles= DWT.V_SCROLL | DWT.H_SCROLL; | |
342 fPresenter= presenter; | |
343 create(); | |
344 } | |
345 | |
346 /** | |
347 * Creates a default information control with the given shell as parent. | |
348 * No information presenter is used to process the information | |
349 * to be displayed. | |
350 * | |
351 * @param parent the parent shell | |
352 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
353 public this(Shell parent) { |
134 | 354 this(parent, cast(String)null, null); |
129 | 355 } |
356 | |
357 /** | |
358 * Creates a default information control with the given shell as parent. The given | |
359 * information presenter is used to process the information to be displayed. | |
360 * | |
361 * @param parent the parent shell | |
362 * @param presenter the presenter to be used | |
363 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
364 public this(Shell parent, IInformationPresenter presenter) { |
134 | 365 this(parent, cast(String)null, presenter); |
129 | 366 } |
367 | |
368 /** | |
369 * Creates a default information control with the given shell as parent. The | |
370 * given information presenter is used to process the information to be | |
371 * displayed. The given styles are applied to the created styled text | |
372 * widget. | |
156 | 373 * |
129 | 374 * @param parent the parent shell |
375 * @param shellStyle the additional styles for the shell | |
376 * @param style the additional styles for the styled text widget | |
377 * @param presenter the presenter to be used | |
378 * @deprecated As of 3.4, replaced by simpler constructors | |
379 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
380 public this(Shell parent, int shellStyle, int style, IInformationPresenter presenter) { |
129 | 381 this(parent, shellStyle, style, presenter, null); |
382 } | |
383 | |
384 /** | |
385 * Creates a default information control with the given shell as parent. The | |
386 * given information presenter is used to process the information to be | |
387 * displayed. The given styles are applied to the created styled text | |
388 * widget. | |
156 | 389 * |
129 | 390 * @param parentShell the parent shell |
391 * @param shellStyle the additional styles for the shell | |
392 * @param style the additional styles for the styled text widget | |
393 * @param presenter the presenter to be used | |
394 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field | |
395 * @since 3.0 | |
396 * @deprecated As of 3.4, replaced by simpler constructors | |
397 */ | |
156 | 398 public this(Shell parentShell, int shellStyle, int style, IInformationPresenter presenter, String statusFieldText) { |
162 | 399 fPresentation= new TextPresentation(); |
129 | 400 super(parentShell, DWT.NO_FOCUS | DWT.ON_TOP | shellStyle, statusFieldText, null); |
401 fAdditionalTextStyles= style; | |
402 fPresenter= presenter; | |
403 create(); | |
404 } | |
405 | |
406 /** | |
407 * Creates a default information control with the given shell as parent. The | |
408 * given information presenter is used to process the information to be | |
409 * displayed. | |
156 | 410 * |
129 | 411 * @param parent the parent shell |
412 * @param textStyles the additional styles for the styled text widget | |
413 * @param presenter the presenter to be used | |
414 * @deprecated As of 3.4, replaced by {@link #DefaultInformationControl(Shell, DefaultInformationControl.IInformationPresenter)} | |
415 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
416 public this(Shell parent, int textStyles, IInformationPresenter presenter) { |
129 | 417 this(parent, textStyles, presenter, null); |
418 } | |
419 | |
420 /** | |
421 * Creates a default information control with the given shell as parent. The | |
422 * given information presenter is used to process the information to be | |
423 * displayed. | |
156 | 424 * |
129 | 425 * @param parent the parent shell |
426 * @param textStyles the additional styles for the styled text widget | |
427 * @param presenter the presenter to be used | |
428 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field | |
429 * @since 3.0 | |
430 * @deprecated As of 3.4, replaced by {@link #DefaultInformationControl(Shell, String, DefaultInformationControl.IInformationPresenter)} | |
431 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
432 public this(Shell parent, int textStyles, IInformationPresenter presenter, String statusFieldText) { |
162 | 433 fPresentation= new TextPresentation(); |
129 | 434 super(parent, statusFieldText); |
435 fAdditionalTextStyles= textStyles; | |
436 fPresenter= presenter; | |
437 create(); | |
438 } | |
439 | |
440 /* | |
441 * @see dwtx.jface.text.AbstractInformationControl#createContent(dwt.widgets.Composite) | |
442 */ | |
443 protected void createContent(Composite parent) { | |
444 fText= new StyledText(parent, DWT.MULTI | DWT.READ_ONLY | fAdditionalTextStyles); | |
445 fText.setForeground(parent.getForeground()); | |
446 fText.setBackground(parent.getBackground()); | |
447 fText.setFont(JFaceResources.getDialogFont()); | |
134 | 448 FillLayout layout= cast(FillLayout)parent.getLayout(); |
129 | 449 if (fText.getWordWrap()) { |
156 | 450 // indent does not work for wrapping StyledText, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=56342 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=115432 |
129 | 451 layout.marginHeight= INNER_BORDER; |
452 layout.marginWidth= INNER_BORDER; | |
453 } else { | |
454 fText.setIndent(INNER_BORDER); | |
455 } | |
456 } | |
156 | 457 |
129 | 458 /* |
459 * @see IInformationControl#setInformation(String) | |
460 */ | |
461 public void setInformation(String content) { | |
462 if (fPresenter is null) { | |
463 fText.setText(content); | |
464 } else { | |
465 fPresentation.clear(); | |
156 | 466 |
129 | 467 int maxWidth= -1; |
468 int maxHeight= -1; | |
469 Point constraints= getSizeConstraints(); | |
470 if (constraints !is null) { | |
471 maxWidth= constraints.x; | |
472 maxHeight= constraints.y; | |
473 if (fText.getWordWrap()) { | |
474 maxWidth-= INNER_BORDER * 2; | |
475 maxHeight-= INNER_BORDER * 2; | |
476 } else { | |
477 maxWidth-= INNER_BORDER; // indent | |
478 } | |
479 Rectangle trim= computeTrim(); | |
480 maxWidth-= trim.width; | |
481 maxHeight-= trim.height; | |
482 maxWidth-= fText.getCaret().getSize().x; // StyledText adds a border at the end of the line for the caret. | |
483 } | |
484 if (isResizable()) | |
485 maxHeight= Integer.MAX_VALUE; | |
156 | 486 |
138 | 487 if ( cast(IInformationPresenterExtension)fPresenter ) |
134 | 488 content= (cast(IInformationPresenterExtension)fPresenter).updatePresentation(fText, content, fPresentation, maxWidth, maxHeight); |
129 | 489 else |
490 content= fPresenter.updatePresentation(getShell().getDisplay(), content, fPresentation, maxWidth, maxHeight); | |
491 | |
492 if (content !is null) { | |
493 fText.setText(content); | |
494 TextPresentation.applyTextPresentation(fPresentation, fText); | |
495 } else { | |
496 fText.setText(""); //$NON-NLS-1$ | |
497 } | |
498 } | |
499 } | |
500 | |
501 /* | |
502 * @see IInformationControl#setVisible(bool) | |
503 */ | |
504 public void setVisible(bool visible) { | |
505 if (visible) { | |
506 if (fText.getWordWrap()) { | |
507 Point currentSize= getShell().getSize(); | |
508 getShell().pack(true); | |
509 Point newSize= getShell().getSize(); | |
510 if (newSize.x > currentSize.x || newSize.y > currentSize.y) | |
511 setSize(currentSize.x, currentSize.y); // restore previous size | |
512 } | |
513 } | |
156 | 514 |
129 | 515 super.setVisible(visible); |
516 } | |
517 | |
518 /* | |
519 * @see IInformationControl#computeSizeHint() | |
520 */ | |
521 public Point computeSizeHint() { | |
522 // see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=117602 | |
523 int widthHint= DWT.DEFAULT; | |
524 Point constraints= getSizeConstraints(); | |
525 if (constraints !is null && fText.getWordWrap()) | |
526 widthHint= constraints.x; | |
156 | 527 |
129 | 528 return getShell().computeSize(widthHint, DWT.DEFAULT, true); |
529 } | |
156 | 530 |
129 | 531 /* |
532 * @see dwtx.jface.text.AbstractInformationControl#computeTrim() | |
533 */ | |
534 public Rectangle computeTrim() { | |
535 return Geometry.add(super.computeTrim(), fText.computeTrim(0, 0, 0, 0)); | |
536 } | |
537 | |
538 /* | |
539 * @see IInformationControl#setForegroundColor(Color) | |
540 */ | |
541 public void setForegroundColor(Color foreground) { | |
542 super.setForegroundColor(foreground); | |
543 fText.setForeground(foreground); | |
544 } | |
545 | |
546 /* | |
547 * @see IInformationControl#setBackgroundColor(Color) | |
548 */ | |
549 public void setBackgroundColor(Color background) { | |
550 super.setBackgroundColor(background); | |
551 fText.setBackground(background); | |
552 } | |
553 | |
554 /* | |
555 * @see IInformationControlExtension#hasContents() | |
556 */ | |
557 public bool hasContents() { | |
558 return fText.getCharCount() > 0; | |
559 } | |
560 | |
561 /** | |
562 * @see dwt.events.DisposeListener#widgetDisposed(dwt.events.DisposeEvent) | |
563 * @since 3.0 | |
564 * @deprecated As of 3.2, no longer used and called | |
565 */ | |
566 public void widgetDisposed(DisposeEvent event) { | |
567 } | |
568 | |
569 /* | |
570 * @see dwtx.jface.text.IInformationControlExtension5#getInformationPresenterControlCreator() | |
571 * @since 3.4 | |
572 */ | |
573 public IInformationControlCreator getInformationPresenterControlCreator() { | |
135 | 574 return new class() IInformationControlCreator { |
129 | 575 /* |
576 * @see dwtx.jface.text.IInformationControlCreator#createInformationControl(dwt.widgets.Shell) | |
577 */ | |
578 public IInformationControl createInformationControl(Shell parent) { | |
134 | 579 return new DefaultInformationControl(parent, cast(ToolBarManager) null, fPresenter); |
129 | 580 } |
581 }; | |
582 } | |
156 | 583 |
129 | 584 } |