Mercurial > projects > dwt-addons
comparison dwtx/jface/text/DefaultInformationControl.d @ 156:a9566845f1cb
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 25 Aug 2008 19:03:46 +0200 |
parents | 000f9136b8f7 |
children | 25f1f92fa3df |
comparison
equal
deleted
inserted
replaced
155:8442b6b2da2d | 156:a9566845f1cb |
---|---|
211 * @return the manipulated information | 211 * @return the manipulated information |
212 * @deprecated As of 3.2, replaced by {@link DefaultInformationControl.IInformationPresenterExtension#updatePresentation(Drawable, String, TextPresentation, int, int)} | 212 * @deprecated As of 3.2, replaced by {@link DefaultInformationControl.IInformationPresenterExtension#updatePresentation(Drawable, String, TextPresentation, int, int)} |
213 */ | 213 */ |
214 String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight); | 214 String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight); |
215 } | 215 } |
216 | 216 |
217 | 217 |
218 /** | 218 /** |
219 * An information presenter determines the style presentation | 219 * An information presenter determines the style presentation |
220 * of information displayed in the default information control. | 220 * of information displayed in the default information control. |
221 * The interface can be implemented by clients. | 221 * The interface can be implemented by clients. |
222 * | 222 * |
223 * @since 3.2 | 223 * @since 3.2 |
224 */ | 224 */ |
225 public interface IInformationPresenterExtension { | 225 public interface IInformationPresenterExtension { |
226 | 226 |
227 /** | 227 /** |
228 * Updates the given presentation of the given information and | 228 * Updates the given presentation of the given information and |
229 * thereby may manipulate the information to be displayed. The manipulation | 229 * thereby may manipulate the information to be displayed. The manipulation |
230 * could be the extraction of textual encoded style information etc. Returns the | 230 * could be the extraction of textual encoded style information etc. Returns the |
231 * manipulated information. | 231 * manipulated information. |
243 * | 243 * |
244 * @return the manipulated information | 244 * @return the manipulated information |
245 */ | 245 */ |
246 String updatePresentation(Drawable drawable, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight); | 246 String updatePresentation(Drawable drawable, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight); |
247 } | 247 } |
248 | 248 |
249 | 249 |
250 /** | 250 /** |
251 * Inner border thickness in pixels. | 251 * Inner border thickness in pixels. |
252 * @since 3.1 | 252 * @since 3.1 |
253 */ | 253 */ |
257 private StyledText fText; | 257 private StyledText fText; |
258 /** The information presenter, or <code>null</code> if none. */ | 258 /** The information presenter, or <code>null</code> if none. */ |
259 private const IInformationPresenter fPresenter; | 259 private const IInformationPresenter fPresenter; |
260 /** A cached text presentation */ | 260 /** A cached text presentation */ |
261 private const TextPresentation fPresentation= new TextPresentation(); | 261 private const TextPresentation fPresentation= new TextPresentation(); |
262 | 262 |
263 /** | 263 /** |
264 * Additional styles to use for the text control. | 264 * Additional styles to use for the text control. |
265 * @since 3.4, previously called <code>fTextStyle</code> | 265 * @since 3.4, previously called <code>fTextStyle</code> |
266 */ | 266 */ |
267 private const int fAdditionalTextStyles; | 267 private const int fAdditionalTextStyles; |
268 | 268 |
269 /** | 269 /** |
270 * Creates a default information control with the given shell as parent. An information | 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. | 271 * presenter that can handle simple HTML is used to process the information to be displayed. |
272 * | 272 * |
273 * @param parent the parent shell | 273 * @param parent the parent shell |
274 * @param isResizeable <code>true</code> if the control should be resizable | 274 * @param isResizeable <code>true</code> if the control should be resizable |
275 * @since 3.4 | 275 * @since 3.4 |
276 */ | 276 */ |
277 public this(Shell parent, bool isResizeable) { | 277 public this(Shell parent, bool isResizeable) { |
282 } | 282 } |
283 | 283 |
284 /** | 284 /** |
285 * Creates a default information control with the given shell as parent. An information | 285 * Creates a default information control with the given shell as parent. An information |
286 * presenter that can handle simple HTML is used to process the information to be displayed. | 286 * presenter that can handle simple HTML is used to process the information to be displayed. |
287 * | 287 * |
288 * @param parent the parent shell | 288 * @param parent the parent shell |
289 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field | 289 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field |
290 * @since 3.4 | 290 * @since 3.4 |
291 */ | 291 */ |
292 public this(Shell parent, String statusFieldText) { | 292 public this(Shell parent, String statusFieldText) { |
295 | 295 |
296 /** | 296 /** |
297 * Creates a default information control with the given shell as parent. The | 297 * Creates a default information control with the given shell as parent. The |
298 * given information presenter is used to process the information to be | 298 * given information presenter is used to process the information to be |
299 * displayed. | 299 * displayed. |
300 * | 300 * |
301 * @param parent the parent shell | 301 * @param parent the parent shell |
302 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field | 302 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field |
303 * @param presenter the presenter to be used, or <code>null</code> if no presenter should be used | 303 * @param presenter the presenter to be used, or <code>null</code> if no presenter should be used |
304 * @since 3.4 | 304 * @since 3.4 |
305 */ | 305 */ |
312 | 312 |
313 /** | 313 /** |
314 * Creates a resizable default information control with the given shell as parent. An | 314 * Creates a resizable default information control with the given shell as parent. An |
315 * information presenter that can handle simple HTML is used to process the information to be | 315 * information presenter that can handle simple HTML is used to process the information to be |
316 * displayed. | 316 * displayed. |
317 * | 317 * |
318 * @param parent the parent shell | 318 * @param parent the parent shell |
319 * @param toolBarManager the manager or <code>null</code> if toolbar is not desired | 319 * @param toolBarManager the manager or <code>null</code> if toolbar is not desired |
320 * @since 3.4 | 320 * @since 3.4 |
321 */ | 321 */ |
322 public this(Shell parent, ToolBarManager toolBarManager) { | 322 public this(Shell parent, ToolBarManager toolBarManager) { |
325 | 325 |
326 /** | 326 /** |
327 * Creates a resizable default information control with the given shell as | 327 * Creates a resizable default information control with the given shell as |
328 * parent. The given information presenter is used to process the | 328 * parent. The given information presenter is used to process the |
329 * information to be displayed. | 329 * information to be displayed. |
330 * | 330 * |
331 * @param parent the parent shell | 331 * @param parent the parent shell |
332 * @param toolBarManager the manager or <code>null</code> if toolbar is not desired | 332 * @param toolBarManager the manager or <code>null</code> if toolbar is not desired |
333 * @param presenter the presenter to be used, or <code>null</code> if no presenter should be used | 333 * @param presenter the presenter to be used, or <code>null</code> if no presenter should be used |
334 * @since 3.4 | 334 * @since 3.4 |
335 */ | 335 */ |
365 /** | 365 /** |
366 * Creates a default information control with the given shell as parent. The | 366 * Creates a default information control with the given shell as parent. The |
367 * given information presenter is used to process the information to be | 367 * given information presenter is used to process the information to be |
368 * displayed. The given styles are applied to the created styled text | 368 * displayed. The given styles are applied to the created styled text |
369 * widget. | 369 * widget. |
370 * | 370 * |
371 * @param parent the parent shell | 371 * @param parent the parent shell |
372 * @param shellStyle the additional styles for the shell | 372 * @param shellStyle the additional styles for the shell |
373 * @param style the additional styles for the styled text widget | 373 * @param style the additional styles for the styled text widget |
374 * @param presenter the presenter to be used | 374 * @param presenter the presenter to be used |
375 * @deprecated As of 3.4, replaced by simpler constructors | 375 * @deprecated As of 3.4, replaced by simpler constructors |
381 /** | 381 /** |
382 * Creates a default information control with the given shell as parent. The | 382 * Creates a default information control with the given shell as parent. The |
383 * given information presenter is used to process the information to be | 383 * given information presenter is used to process the information to be |
384 * displayed. The given styles are applied to the created styled text | 384 * displayed. The given styles are applied to the created styled text |
385 * widget. | 385 * widget. |
386 * | 386 * |
387 * @param parentShell the parent shell | 387 * @param parentShell the parent shell |
388 * @param shellStyle the additional styles for the shell | 388 * @param shellStyle the additional styles for the shell |
389 * @param style the additional styles for the styled text widget | 389 * @param style the additional styles for the styled text widget |
390 * @param presenter the presenter to be used | 390 * @param presenter the presenter to be used |
391 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field | 391 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field |
392 * @since 3.0 | 392 * @since 3.0 |
393 * @deprecated As of 3.4, replaced by simpler constructors | 393 * @deprecated As of 3.4, replaced by simpler constructors |
394 */ | 394 */ |
395 public this(Shell parentShell, int shellStyle, final int style, IInformationPresenter presenter, String statusFieldText) { | 395 public this(Shell parentShell, int shellStyle, int style, IInformationPresenter presenter, String statusFieldText) { |
396 super(parentShell, DWT.NO_FOCUS | DWT.ON_TOP | shellStyle, statusFieldText, null); | 396 super(parentShell, DWT.NO_FOCUS | DWT.ON_TOP | shellStyle, statusFieldText, null); |
397 fAdditionalTextStyles= style; | 397 fAdditionalTextStyles= style; |
398 fPresenter= presenter; | 398 fPresenter= presenter; |
399 create(); | 399 create(); |
400 } | 400 } |
401 | 401 |
402 /** | 402 /** |
403 * Creates a default information control with the given shell as parent. The | 403 * Creates a default information control with the given shell as parent. The |
404 * given information presenter is used to process the information to be | 404 * given information presenter is used to process the information to be |
405 * displayed. | 405 * displayed. |
406 * | 406 * |
407 * @param parent the parent shell | 407 * @param parent the parent shell |
408 * @param textStyles the additional styles for the styled text widget | 408 * @param textStyles the additional styles for the styled text widget |
409 * @param presenter the presenter to be used | 409 * @param presenter the presenter to be used |
410 * @deprecated As of 3.4, replaced by {@link #DefaultInformationControl(Shell, DefaultInformationControl.IInformationPresenter)} | 410 * @deprecated As of 3.4, replaced by {@link #DefaultInformationControl(Shell, DefaultInformationControl.IInformationPresenter)} |
411 */ | 411 */ |
415 | 415 |
416 /** | 416 /** |
417 * Creates a default information control with the given shell as parent. The | 417 * Creates a default information control with the given shell as parent. The |
418 * given information presenter is used to process the information to be | 418 * given information presenter is used to process the information to be |
419 * displayed. | 419 * displayed. |
420 * | 420 * |
421 * @param parent the parent shell | 421 * @param parent the parent shell |
422 * @param textStyles the additional styles for the styled text widget | 422 * @param textStyles the additional styles for the styled text widget |
423 * @param presenter the presenter to be used | 423 * @param presenter the presenter to be used |
424 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field | 424 * @param statusFieldText the text to be used in the status field or <code>null</code> to hide the status field |
425 * @since 3.0 | 425 * @since 3.0 |
440 fText.setForeground(parent.getForeground()); | 440 fText.setForeground(parent.getForeground()); |
441 fText.setBackground(parent.getBackground()); | 441 fText.setBackground(parent.getBackground()); |
442 fText.setFont(JFaceResources.getDialogFont()); | 442 fText.setFont(JFaceResources.getDialogFont()); |
443 FillLayout layout= cast(FillLayout)parent.getLayout(); | 443 FillLayout layout= cast(FillLayout)parent.getLayout(); |
444 if (fText.getWordWrap()) { | 444 if (fText.getWordWrap()) { |
445 // 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 | 445 // 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 |
446 layout.marginHeight= INNER_BORDER; | 446 layout.marginHeight= INNER_BORDER; |
447 layout.marginWidth= INNER_BORDER; | 447 layout.marginWidth= INNER_BORDER; |
448 } else { | 448 } else { |
449 fText.setIndent(INNER_BORDER); | 449 fText.setIndent(INNER_BORDER); |
450 } | 450 } |
451 } | 451 } |
452 | 452 |
453 /* | 453 /* |
454 * @see IInformationControl#setInformation(String) | 454 * @see IInformationControl#setInformation(String) |
455 */ | 455 */ |
456 public void setInformation(String content) { | 456 public void setInformation(String content) { |
457 if (fPresenter is null) { | 457 if (fPresenter is null) { |
458 fText.setText(content); | 458 fText.setText(content); |
459 } else { | 459 } else { |
460 fPresentation.clear(); | 460 fPresentation.clear(); |
461 | 461 |
462 int maxWidth= -1; | 462 int maxWidth= -1; |
463 int maxHeight= -1; | 463 int maxHeight= -1; |
464 Point constraints= getSizeConstraints(); | 464 Point constraints= getSizeConstraints(); |
465 if (constraints !is null) { | 465 if (constraints !is null) { |
466 maxWidth= constraints.x; | 466 maxWidth= constraints.x; |
476 maxHeight-= trim.height; | 476 maxHeight-= trim.height; |
477 maxWidth-= fText.getCaret().getSize().x; // StyledText adds a border at the end of the line for the caret. | 477 maxWidth-= fText.getCaret().getSize().x; // StyledText adds a border at the end of the line for the caret. |
478 } | 478 } |
479 if (isResizable()) | 479 if (isResizable()) |
480 maxHeight= Integer.MAX_VALUE; | 480 maxHeight= Integer.MAX_VALUE; |
481 | 481 |
482 if ( cast(IInformationPresenterExtension)fPresenter ) | 482 if ( cast(IInformationPresenterExtension)fPresenter ) |
483 content= (cast(IInformationPresenterExtension)fPresenter).updatePresentation(fText, content, fPresentation, maxWidth, maxHeight); | 483 content= (cast(IInformationPresenterExtension)fPresenter).updatePresentation(fText, content, fPresentation, maxWidth, maxHeight); |
484 else | 484 else |
485 content= fPresenter.updatePresentation(getShell().getDisplay(), content, fPresentation, maxWidth, maxHeight); | 485 content= fPresenter.updatePresentation(getShell().getDisplay(), content, fPresentation, maxWidth, maxHeight); |
486 | 486 |
504 Point newSize= getShell().getSize(); | 504 Point newSize= getShell().getSize(); |
505 if (newSize.x > currentSize.x || newSize.y > currentSize.y) | 505 if (newSize.x > currentSize.x || newSize.y > currentSize.y) |
506 setSize(currentSize.x, currentSize.y); // restore previous size | 506 setSize(currentSize.x, currentSize.y); // restore previous size |
507 } | 507 } |
508 } | 508 } |
509 | 509 |
510 super.setVisible(visible); | 510 super.setVisible(visible); |
511 } | 511 } |
512 | 512 |
513 /* | 513 /* |
514 * @see IInformationControl#computeSizeHint() | 514 * @see IInformationControl#computeSizeHint() |
517 // see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=117602 | 517 // see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=117602 |
518 int widthHint= DWT.DEFAULT; | 518 int widthHint= DWT.DEFAULT; |
519 Point constraints= getSizeConstraints(); | 519 Point constraints= getSizeConstraints(); |
520 if (constraints !is null && fText.getWordWrap()) | 520 if (constraints !is null && fText.getWordWrap()) |
521 widthHint= constraints.x; | 521 widthHint= constraints.x; |
522 | 522 |
523 return getShell().computeSize(widthHint, DWT.DEFAULT, true); | 523 return getShell().computeSize(widthHint, DWT.DEFAULT, true); |
524 } | 524 } |
525 | 525 |
526 /* | 526 /* |
527 * @see dwtx.jface.text.AbstractInformationControl#computeTrim() | 527 * @see dwtx.jface.text.AbstractInformationControl#computeTrim() |
528 */ | 528 */ |
529 public Rectangle computeTrim() { | 529 public Rectangle computeTrim() { |
530 return Geometry.add(super.computeTrim(), fText.computeTrim(0, 0, 0, 0)); | 530 return Geometry.add(super.computeTrim(), fText.computeTrim(0, 0, 0, 0)); |
573 public IInformationControl createInformationControl(Shell parent) { | 573 public IInformationControl createInformationControl(Shell parent) { |
574 return new DefaultInformationControl(parent, cast(ToolBarManager) null, fPresenter); | 574 return new DefaultInformationControl(parent, cast(ToolBarManager) null, fPresenter); |
575 } | 575 } |
576 }; | 576 }; |
577 } | 577 } |
578 | 578 |
579 } | 579 } |