comparison dwt/widgets/MessageBox.d @ 238:380bad9f6852

reverted char[] to String
author Frank Benoit <benoit@tionex.de>
date Mon, 05 May 2008 00:42:55 +0200
parents e3472c527a14
children ce446666f5a2
comparison
equal deleted inserted replaced
237:98b80b00af79 238:380bad9f6852
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * Port to the D programming language: 10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de> 11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/ 12 *******************************************************************************/
13 module dwt.widgets.MessageBox; 13 module dwt.widgets.MessageBox;
14
15 import dwt.dwthelper.utils;
14 16
15 17
16 18
17 import dwt.DWT; 19 import dwt.DWT;
18 import dwt.DWTException; 20 import dwt.DWTException;
43 * within the DWT implementation. 45 * within the DWT implementation.
44 * </p> 46 * </p>
45 */ 47 */
46 public class MessageBox : Dialog { 48 public class MessageBox : Dialog {
47 49
48 char[] message = ""; 50 String message = "";
49 GtkWidget* handle; 51 GtkWidget* handle;
50 private bool allowNullParent = false; 52 private bool allowNullParent = false;
51 /** 53 /**
52 * Constructs a new instance of this class given only its parent. 54 * Constructs a new instance of this class given only its parent.
53 * 55 *
114 * The message is a description of the purpose for which the dialog was opened. 116 * The message is a description of the purpose for which the dialog was opened.
115 * This message will be visible in the dialog while it is open. 117 * This message will be visible in the dialog while it is open.
116 * 118 *
117 * @return the message 119 * @return the message
118 */ 120 */
119 public char[] getMessage () { 121 public String getMessage () {
120 return message; 122 return message;
121 } 123 }
122 124
123 /** 125 /**
124 * Sets the dialog's message, which is a description of 126 * Sets the dialog's message, which is a description of
129 * 131 *
130 * @exception IllegalArgumentException <ul> 132 * @exception IllegalArgumentException <ul>
131 * <li>ERROR_NULL_ARGUMENT - if the string is null</li> 133 * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
132 * </ul> 134 * </ul>
133 */ 135 */
134 public void setMessage (char[] string) { 136 public void setMessage (String string) {
135 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 137 if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
136 message = string; 138 message = string;
137 } 139 }
138 140
139 /** 141 /**
198 if (bits is (DWT.RETRY | DWT.CANCEL) || bits is (DWT.ABORT | DWT.RETRY | DWT.IGNORE)) return style; 200 if (bits is (DWT.RETRY | DWT.CANCEL) || bits is (DWT.ABORT | DWT.RETRY | DWT.IGNORE)) return style;
199 style = (style & ~mask) | DWT.OK; 201 style = (style & ~mask) | DWT.OK;
200 return style; 202 return style;
201 } 203 }
202 204
203 char[] fixPercent (char[] string) { 205 char[] fixPercent (String string) {
204 int i = 0, j = 0; 206 int i = 0, j = 0;
205 char [] result = new char[]( string.length * 2 ); 207 char [] result = new String( string.length * 2 );
206 while (i < string.length) { 208 while (i < string.length) {
207 switch (string [i]) { 209 switch (string [i]) {
208 case '%': 210 case '%':
209 result [j++] = '%'; 211 result [j++] = '%';
210 break; 212 break;
217 219
218 220
219 /++ 221 /++
220 + DWT extension 222 + DWT extension
221 +/ 223 +/
222 public static int showMessageBox(char[] str, char[] title, Shell shell, int style) { 224 public static int showMessageBox(String str, String title, Shell shell, int style) {
223 MessageBox msgBox = (shell is null ) ? new MessageBox( style ) : new MessageBox(shell, style); 225 MessageBox msgBox = (shell is null ) ? new MessageBox( style ) : new MessageBox(shell, style);
224 msgBox.setMessage(str); 226 msgBox.setMessage(str);
225 if(title !is null){ 227 if(title !is null){
226 msgBox.setText(title); 228 msgBox.setText(title);
227 } 229 }
228 return msgBox.open(); 230 return msgBox.open();
229 } 231 }
230 232
231 /// DWT extension 233 /// DWT extension
232 public static int showInfo(char[] str, char[] title = null, Shell shell = null) { 234 public static int showInfo(String str, String title = null, Shell shell = null) {
233 return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_INFORMATION ); 235 return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_INFORMATION );
234 } 236 }
235 /// DWT extension 237 /// DWT extension
236 alias showInfo showInformation; 238 alias showInfo showInformation;
237 239
238 /// DWT extension 240 /// DWT extension
239 public static int showWarning(char[] str, char[] title = null, Shell shell = null) { 241 public static int showWarning(String str, String title = null, Shell shell = null) {
240 return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_WARNING ); 242 return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_WARNING );
241 } 243 }
242 /// DWT extension 244 /// DWT extension
243 public static int showError(char[] str, char[] title = null, Shell shell = null) { 245 public static int showError(String str, String title = null, Shell shell = null) {
244 return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_ERROR ); 246 return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_ERROR );
245 } 247 }
246 248
247 } 249 }