Mercurial > projects > dwt-linux
comparison dwt/widgets/MessageBox.d @ 240:ce446666f5a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 12 May 2008 19:13:01 +0200 |
parents | 380bad9f6852 |
children | 5a30aa9820f3 |
comparison
equal
deleted
inserted
replaced
239:06a1f6829310 | 240:ce446666f5a2 |
---|---|
45 * within the DWT implementation. | 45 * within the DWT implementation. |
46 * </p> | 46 * </p> |
47 */ | 47 */ |
48 public class MessageBox : Dialog { | 48 public class MessageBox : Dialog { |
49 | 49 |
50 alias Dialog.checkStyle checkStyle; | |
51 | |
50 String message = ""; | 52 String message = ""; |
51 GtkWidget* handle; | 53 GtkWidget* handle; |
52 private bool allowNullParent = false; | 54 private bool allowNullParent = false; |
53 /** | 55 /** |
54 * Constructs a new instance of this class given only its parent. | 56 * Constructs a new instance of this class given only its parent. |
89 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | 91 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> |
90 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> | 92 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> |
91 * </ul> | 93 * </ul> |
92 */ | 94 */ |
93 public this (Shell parent, int style) { | 95 public this (Shell parent, int style) { |
94 super(parent, checkStyle(style)); | 96 super (parent, checkStyle (parent, checkStyle (style))); |
95 checkSubclass (); | 97 checkSubclass (); |
96 } | 98 } |
97 | 99 |
98 /++ | 100 /++ |
99 + DWT extension, a MessageBox with no parent | 101 + DWT extension, a MessageBox with no parent |
100 +/ | 102 +/ |
101 public this (int style) { | 103 public this (int style) { |
102 allowNullParent = true; | 104 allowNullParent = true; |
103 super (parent, checkStyle (style)); | 105 super (parent, checkStyle (parent, checkStyle (style))); |
104 checkSubclass (); | 106 checkSubclass (); |
105 } | 107 } |
106 // PORT | 108 // PORT |
107 // actually, the parent can be null | 109 // actually, the parent can be null |
108 override void checkParent (Shell parent){ | 110 override void checkParent (Shell parent){ |
174 createButtons(); | 176 createButtons(); |
175 buffer = toStringz(title); | 177 buffer = toStringz(title); |
176 OS.gtk_window_set_title(handle,buffer); | 178 OS.gtk_window_set_title(handle,buffer); |
177 Display display = parent !is null ? parent.getDisplay (): Display.getCurrent (); | 179 Display display = parent !is null ? parent.getDisplay (): Display.getCurrent (); |
178 display.addIdleProc (); | 180 display.addIdleProc (); |
179 int result = OS.gtk_dialog_run (handle); | 181 Dialog oldModal = null; |
182 if (OS.gtk_window_get_modal (handle)) { | |
183 oldModal = display.getModalDialog (); | |
184 display.setModalDialog (this); | |
185 } | |
186 int signalId = 0; | |
187 int /*long*/ hookId = 0; | |
188 CallbackData emissionData; | |
189 emissionData.display = display; | |
190 emissionData.data = handle; | |
191 if ((style & DWT.RIGHT_TO_LEFT) !is 0) { | |
192 signalId = OS.g_signal_lookup (OS.map.ptr, OS.GTK_TYPE_WIDGET()); | |
193 hookId = OS.g_signal_add_emission_hook (signalId, 0, &Display.emissionFunc, &emissionData, null); | |
194 } | |
195 int response = OS.gtk_dialog_run (handle); | |
196 if ((style & DWT.RIGHT_TO_LEFT) !is 0) { | |
197 OS.g_signal_remove_emission_hook (signalId, hookId); | |
198 } | |
199 if (OS.gtk_window_get_modal (handle)) { | |
200 display.setModalDialog (oldModal); | |
201 } | |
180 display.removeIdleProc (); | 202 display.removeIdleProc (); |
181 OS.gtk_widget_destroy (handle); | 203 OS.gtk_widget_destroy (handle); |
182 return result; | 204 return response; |
183 } | 205 } |
184 | 206 |
185 private void createButtons() { | 207 private void createButtons() { |
186 if ((style & DWT.OK) !is 0) OS.gtk_dialog_add_button(handle, "gtk-ok".ptr, DWT.OK); | 208 if ((style & DWT.OK) !is 0) OS.gtk_dialog_add_button(handle, "gtk-ok".ptr, DWT.OK); |
187 if ((style & DWT.CANCEL) !is 0) OS.gtk_dialog_add_button(handle, "gtk-cancel".ptr, DWT.CANCEL); | 209 if ((style & DWT.CANCEL) !is 0) OS.gtk_dialog_add_button(handle, "gtk-cancel".ptr, DWT.CANCEL); |