Mercurial > projects > dwt-addons
comparison dwtx/jface/dialogs/TitleAreaDialog.d @ 12:8ec40848221b
TitleAreaDialog
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 31 Mar 2008 01:07:26 +0200 |
parents | 6c14e54dfc11 |
children | ea8ff534f622 |
comparison
equal
deleted
inserted
replaced
11:11bd25f93332 | 12:8ec40848221b |
---|---|
14 * Port to the D programming language: | 14 * Port to the D programming language: |
15 * Frank Benoit <benoit@tionex.de> | 15 * Frank Benoit <benoit@tionex.de> |
16 *******************************************************************************/ | 16 *******************************************************************************/ |
17 module dwtx.jface.dialogs.TitleAreaDialog; | 17 module dwtx.jface.dialogs.TitleAreaDialog; |
18 | 18 |
19 import dwt.dwthelper.utils; | 19 import dwtx.jface.dialogs.IDialogConstants; |
20 pragma( msg, "FIXME dwtx.jface.dialogs.TitleAreaDialog" ); | 20 import dwtx.jface.dialogs.TrayDialog; |
21 class TitleAreaDialog{ | 21 import dwtx.jface.dialogs.IMessageProvider; |
22 public static const String DLG_IMG_TITLE_BANNER = "dialog_title_banner_image";//$NON-NLS-1$ | 22 |
23 } | |
24 | |
25 | |
26 /++ | |
27 import dwt.DWT; | 23 import dwt.DWT; |
28 import dwt.events.DisposeEvent; | 24 import dwt.events.DisposeEvent; |
29 import dwt.events.DisposeListener; | 25 import dwt.events.DisposeListener; |
30 import dwt.graphics.Color; | 26 import dwt.graphics.Color; |
31 import dwt.graphics.Image; | 27 import dwt.graphics.Image; |
43 import dwt.widgets.Shell; | 39 import dwt.widgets.Shell; |
44 import dwt.widgets.Text; | 40 import dwt.widgets.Text; |
45 import dwtx.jface.resource.JFaceColors; | 41 import dwtx.jface.resource.JFaceColors; |
46 import dwtx.jface.resource.JFaceResources; | 42 import dwtx.jface.resource.JFaceResources; |
47 | 43 |
44 import dwt.dwthelper.utils; | |
45 | |
48 /** | 46 /** |
49 * A dialog that has a title area for displaying a title and an image as well as | 47 * A dialog that has a title area for displaying a title and an image as well as |
50 * a common area for displaying a description, a message, or an error message. | 48 * a common area for displaying a description, a message, or an error message. |
51 * <p> | 49 * <p> |
52 * This dialog class may be subclassed. | 50 * This dialog class may be subclassed. |
53 */ | 51 */ |
54 public class TitleAreaDialog extends TrayDialog { | 52 public class TitleAreaDialog : TrayDialog { |
55 /** | 53 /** |
56 * Image registry key for error message image. | 54 * Image registry key for error message image. |
57 */ | 55 */ |
58 public static final String DLG_IMG_TITLE_ERROR = DLG_IMG_MESSAGE_ERROR; | 56 public static const String DLG_IMG_TITLE_ERROR = DLG_IMG_MESSAGE_ERROR; |
59 | 57 |
60 /** | 58 /** |
61 * Image registry key for banner image (value | 59 * Image registry key for banner image (value |
62 * <code>"dialog_title_banner_image"</code>). | 60 * <code>"dialog_title_banner_image"</code>). |
63 */ | 61 */ |
64 public static final String DLG_IMG_TITLE_BANNER = "dialog_title_banner_image";//$NON-NLS-1$ | 62 public static const String DLG_IMG_TITLE_BANNER = "dialog_title_banner_image";//$NON-NLS-1$ |
65 | 63 |
66 /** | 64 /** |
67 * Message type constant used to display an info icon with the message. | 65 * Message type constant used to display an info icon with the message. |
68 * | 66 * |
69 * @since 2.0 | 67 * @since 2.0 |
70 * @deprecated | 68 * @deprecated |
71 */ | 69 */ |
72 public final static String INFO_MESSAGE = "INFO_MESSAGE"; //$NON-NLS-1$ | 70 public const static String INFO_MESSAGE = "INFO_MESSAGE"; //$NON-NLS-1$ |
73 | 71 |
74 /** | 72 /** |
75 * Message type constant used to display a warning icon with the message. | 73 * Message type constant used to display a warning icon with the message. |
76 * | 74 * |
77 * @since 2.0 | 75 * @since 2.0 |
78 * @deprecated | 76 * @deprecated |
79 */ | 77 */ |
80 public final static String WARNING_MESSAGE = "WARNING_MESSAGE"; //$NON-NLS-1$ | 78 public const static String WARNING_MESSAGE = "WARNING_MESSAGE"; //$NON-NLS-1$ |
81 | 79 |
82 // Space between an image and a label | 80 // Space between an image and a label |
83 private static final int H_GAP_IMAGE = 5; | 81 private static const int H_GAP_IMAGE = 5; |
84 | 82 |
85 // Minimum dialog width (in dialog units) | 83 // Minimum dialog width (in dialog units) |
86 private static final int MIN_DIALOG_WIDTH = 350; | 84 private static const int MIN_DIALOG_WIDTH = 350; |
87 | 85 |
88 // Minimum dialog height (in dialog units) | 86 // Minimum dialog height (in dialog units) |
89 private static final int MIN_DIALOG_HEIGHT = 150; | 87 private static const int MIN_DIALOG_HEIGHT = 150; |
90 | 88 |
91 private Label titleLabel; | 89 private Label titleLabel; |
92 | 90 |
93 private Label titleImageLabel; | 91 private Label titleImageLabel; |
94 | 92 |
124 * Instantiate a new title area dialog. | 122 * Instantiate a new title area dialog. |
125 * | 123 * |
126 * @param parentShell | 124 * @param parentShell |
127 * the parent DWT shell | 125 * the parent DWT shell |
128 */ | 126 */ |
129 public TitleAreaDialog(Shell parentShell) { | 127 public this(Shell parentShell) { |
130 super(parentShell); | 128 super(parentShell); |
131 } | 129 } |
132 | 130 |
133 /* | 131 /* |
134 * @see Dialog.createContents(Composite) | 132 * @see Dialog.createContents(Composite) |
198 * @return Control with the highest x axis value. | 196 * @return Control with the highest x axis value. |
199 */ | 197 */ |
200 private Control createTitleArea(Composite parent) { | 198 private Control createTitleArea(Composite parent) { |
201 | 199 |
202 // add a dispose listener | 200 // add a dispose listener |
203 parent.addDisposeListener(new DisposeListener() { | 201 parent.addDisposeListener(new class DisposeListener { |
204 public void widgetDisposed(DisposeEvent e) { | 202 public void widgetDisposed(DisposeEvent e) { |
205 if (titleAreaColor !is null) { | 203 if (titleAreaColor !is null) { |
206 titleAreaColor.dispose(); | 204 titleAreaColor.dispose(); |
207 } | 205 } |
208 } | 206 } |
393 messageImageLabel.setImage(messageImage); | 391 messageImageLabel.setImage(messageImage); |
394 setImageLabelVisible(messageImage !is null); | 392 setImageLabelVisible(messageImage !is null); |
395 } else { | 393 } else { |
396 // Add in a space for layout purposes but do not | 394 // Add in a space for layout purposes but do not |
397 // change the instance variable | 395 // change the instance variable |
398 String displayedErrorMessage = " " + errorMessage; //$NON-NLS-1$ | 396 String displayedErrorMessage = " " ~ errorMessage; //$NON-NLS-1$ |
399 updateMessage(displayedErrorMessage); | 397 updateMessage(displayedErrorMessage); |
400 if (!showingError) { | 398 if (!showingError) { |
401 // we were not previously showing an error | 399 // we were not previously showing an error |
402 showingError = true; | 400 showingError = true; |
403 messageImageLabel.setImage(JFaceResources | 401 messageImageLabel.setImage(JFaceResources |
534 message = newMessage; | 532 message = newMessage; |
535 if (message is null) | 533 if (message is null) |
536 message = "";//$NON-NLS-1$ | 534 message = "";//$NON-NLS-1$ |
537 // Message string to be shown - if there is an image then add in | 535 // Message string to be shown - if there is an image then add in |
538 // a space to the message for layout purposes | 536 // a space to the message for layout purposes |
539 String shownMessage = (newImage is null) ? message : " " + message; //$NON-NLS-1$ | 537 String shownMessage = (newImage is null) ? message : " " ~ message; //$NON-NLS-1$ |
540 messageImage = newImage; | 538 messageImage = newImage; |
541 if (!showingError) { | 539 if (!showingError) { |
542 // we are not showing an error | 540 // we are not showing an error |
543 updateMessage(shownMessage); | 541 updateMessage(shownMessage); |
544 messageImageLabel.setImage(messageImage); | 542 messageImageLabel.setImage(messageImage); |
633 childData.left = new FormAttachment(0, 0); | 631 childData.left = new FormAttachment(0, 0); |
634 childData.bottom = new FormAttachment(100, 0); | 632 childData.bottom = new FormAttachment(100, 0); |
635 workArea.setLayoutData(childData); | 633 workArea.setLayoutData(childData); |
636 } | 634 } |
637 } | 635 } |
638 ++/ |