comparison dwt/widgets/ColorDialog.d @ 213:36f5cb12e1a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents 07e8963537b7
children fd9c62a2998e
comparison
equal deleted inserted replaced
212:ab60f3309436 213:36f5cb12e1a2
63 * @see DWT 63 * @see DWT
64 * @see Widget#checkSubclass 64 * @see Widget#checkSubclass
65 * @see Widget#getStyle 65 * @see Widget#getStyle
66 */ 66 */
67 public this (Shell parent) { 67 public this (Shell parent) {
68 this (parent, DWT.PRIMARY_MODAL); 68 this (parent, DWT.APPLICATION_MODAL);
69 } 69 }
70 70
71 /** 71 /**
72 * Constructs a new instance of this class given its parent 72 * Constructs a new instance of this class given its parent
73 * and a style value describing its behavior and appearance. 73 * and a style value describing its behavior and appearance.
95 * @see DWT 95 * @see DWT
96 * @see Widget#checkSubclass 96 * @see Widget#checkSubclass
97 * @see Widget#getStyle 97 * @see Widget#getStyle
98 */ 98 */
99 public this (Shell parent, int style) { 99 public this (Shell parent, int style) {
100 super (parent, style); 100 super (parent, checkStyle (parent, style));
101 checkSubclass (); 101 checkSubclass ();
102 } 102 }
103 103
104 private static extern(Windows) uint CCHookFunc (HWND hdlg, uint uiMsg, uint lParam, int lpData) { 104 private static extern(Windows) uint CCHookFunc (HWND hdlg, uint uiMsg, uint lParam, int lpData) {
105 return sThis.CCHookProc( hdlg, uiMsg, lParam ); 105 return sThis.CCHookProc( hdlg, uiMsg, lParam );
163 */ 163 */
164 public RGB open () { 164 public RGB open () {
165 165
166 /* Get the owner HWND for the dialog */ 166 /* Get the owner HWND for the dialog */
167 auto hwndOwner = parent.handle; 167 auto hwndOwner = parent.handle;
168 auto hwndParent = parent.handle;
169
170 /*
171 * Feature in Windows. There is no API to set the orientation of a
172 * color dialog. It is always inherited from the parent. The fix is
173 * to create a hidden parent and set the orientation in the hidden
174 * parent for the dialog to inherit.
175 */
176 bool enabled = false;
177 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION(4, 10)) {
178 int dialogOrientation = style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT);
179 int parentOrientation = parent.style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT);
180 if (dialogOrientation !is parentOrientation) {
181 int exStyle = OS.WS_EX_NOINHERITLAYOUT;
182 if (dialogOrientation is DWT.RIGHT_TO_LEFT) exStyle |= OS.WS_EX_LAYOUTRTL;
183 hwndOwner = OS.CreateWindowEx (
184 exStyle,
185 Shell.DialogClass.ptr,
186 null,
187 0,
188 OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0,
189 hwndParent,
190 null,
191 OS.GetModuleHandle (null),
192 null);
193 enabled = OS.IsWindowEnabled (hwndParent) !is 0;
194 if (enabled) OS.EnableWindow (hwndParent, false);
195 }
196 }
168 197
169 /* Create the CCHookProc */ 198 /* Create the CCHookProc */
170 //Callback callback = new Callback (this, "CCHookProc", 4); //$NON-NLS-1$ 199 //Callback callback = new Callback (this, "CCHookProc", 4); //$NON-NLS-1$
171 //int lpfnHook = callback.getAddress (); 200 //int lpfnHook = callback.getAddress ();
172 //if (lpfnHook is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS); 201 //if (lpfnHook is 0) DWT.error(DWT.ERROR_NO_MORE_CALLBACKS);
194 int blue = (rgb.blue << 16) & 0xFF0000; 223 int blue = (rgb.blue << 16) & 0xFF0000;
195 lpcc.rgbResult = red | green | blue; 224 lpcc.rgbResult = red | green | blue;
196 } 225 }
197 226
198 /* Make the parent shell be temporary modal */ 227 /* Make the parent shell be temporary modal */
199 Shell oldModal = null; 228 Dialog oldModal = null;
200 if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) { 229 if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) {
201 oldModal = display.getModalDialogShell (); 230 oldModal = display.getModalDialog ();
202 display.setModalDialogShell (parent); 231 display.setModalDialog (this);
203 } 232 }
204 233
205 /* Open the dialog */ 234 /* Open the dialog */
206 bool success; 235 bool success;
207 synchronized { 236 synchronized {
210 sThis = null; 239 sThis = null;
211 } 240 }
212 241
213 /* Clear the temporary dialog modal parent */ 242 /* Clear the temporary dialog modal parent */
214 if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) { 243 if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) {
215 display.setModalDialogShell (oldModal); 244 display.setModalDialog (oldModal);
216 } 245 }
217 246
218 if (success) { 247 if (success) {
219 int red = lpcc.rgbResult & 0xFF; 248 int red = lpcc.rgbResult & 0xFF;
220 int green = (lpcc.rgbResult >> 8) & 0xFF; 249 int green = (lpcc.rgbResult >> 8) & 0xFF;
232 * The memory associated with these colors is released 261 * The memory associated with these colors is released
233 * when the display is disposed. 262 * when the display is disposed.
234 */ 263 */
235 // if (lpCustColors !is 0) OS.HeapFree (hHeap, 0, lpCustColors); 264 // if (lpCustColors !is 0) OS.HeapFree (hHeap, 0, lpCustColors);
236 265
266 /* Destroy the BIDI orientation window */
267 if (hwndParent !is hwndOwner) {
268 if (enabled) OS.EnableWindow (hwndParent, true);
269 OS.SetActiveWindow (hwndParent);
270 OS.DestroyWindow (hwndOwner);
271 }
272
237 /* 273 /*
238 * This code is intentionally commented. On some 274 * This code is intentionally commented. On some
239 * platforms, the owner window is repainted right 275 * platforms, the owner window is repainted right
240 * away when a dialog window exits. This behavior 276 * away when a dialog window exits. This behavior
241 * is currently unspecified. 277 * is currently unspecified.
242 */ 278 */
243 // if (hwndOwner !is 0) OS.UpdateWindow (hwndOwner); 279 // if (hwndOwner !is 0) OS.UpdateWindow (hwndOwner);
244 280
281 display = null;
245 if (!success) return null; 282 if (!success) return null;
246 return rgb; 283 return rgb;
247 } 284 }
248 285
249 /** 286 /**