Mercurial > projects > dwt-win
comparison dwt/widgets/FontDialog.d @ 213:36f5cb12e1a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 17 May 2008 17:34:28 +0200 |
parents | 25f88bf5a6df |
children | fd9c62a2998e |
comparison
equal
deleted
inserted
replaced
212:ab60f3309436 | 213:36f5cb12e1a2 |
---|---|
56 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | 56 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> |
57 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> | 57 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> |
58 * </ul> | 58 * </ul> |
59 */ | 59 */ |
60 public this (Shell parent) { | 60 public this (Shell parent) { |
61 this (parent, DWT.PRIMARY_MODAL); | 61 this (parent, DWT.APPLICATION_MODAL); |
62 } | 62 } |
63 | 63 |
64 /** | 64 /** |
65 * Constructs a new instance of this class given its parent | 65 * Constructs a new instance of this class given its parent |
66 * and a style value describing its behavior and appearance. | 66 * and a style value describing its behavior and appearance. |
84 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | 84 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> |
85 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> | 85 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> |
86 * </ul> | 86 * </ul> |
87 */ | 87 */ |
88 public this (Shell parent, int style) { | 88 public this (Shell parent, int style) { |
89 super (parent, style); | 89 super (parent, checkStyle (parent, style)); |
90 checkSubclass (); | 90 checkSubclass (); |
91 } | 91 } |
92 | 92 |
93 /** | 93 /** |
94 * Returns a FontData object describing the font that was | 94 * Returns a FontData object describing the font that was |
143 */ | 143 */ |
144 public FontData open () { | 144 public FontData open () { |
145 static if (OS.IsWinCE) DWT.error (DWT.ERROR_NOT_IMPLEMENTED); | 145 static if (OS.IsWinCE) DWT.error (DWT.ERROR_NOT_IMPLEMENTED); |
146 | 146 |
147 /* Get the owner HWND for the dialog */ | 147 /* Get the owner HWND for the dialog */ |
148 HWND hwndOwner; | 148 HWND hwndOwner = parent.handle; |
149 if (parent !is null) hwndOwner = parent.handle; | 149 auto hwndParent = parent.handle; |
150 | |
151 /* | |
152 * Feature in Windows. There is no API to set the orientation of a | |
153 * font dialog. It is always inherited from the parent. The fix is | |
154 * to create a hidden parent and set the orientation in the hidden | |
155 * parent for the dialog to inherit. | |
156 */ | |
157 bool enabled = false; | |
158 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION(4, 10)) { | |
159 int dialogOrientation = style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT); | |
160 int parentOrientation = parent.style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT); | |
161 if (dialogOrientation !is parentOrientation) { | |
162 int exStyle = OS.WS_EX_NOINHERITLAYOUT; | |
163 if (dialogOrientation is DWT.RIGHT_TO_LEFT) exStyle |= OS.WS_EX_LAYOUTRTL; | |
164 hwndOwner = OS.CreateWindowEx ( | |
165 exStyle, | |
166 Shell.DialogClass.ptr, | |
167 null, | |
168 0, | |
169 OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0, | |
170 hwndParent, | |
171 null, | |
172 OS.GetModuleHandle (null), | |
173 null); | |
174 enabled = OS.IsWindowEnabled (hwndParent) !is 0; | |
175 if (enabled) OS.EnableWindow (hwndParent, false); | |
176 } | |
177 } | |
150 | 178 |
151 /* Open the dialog */ | 179 /* Open the dialog */ |
152 auto hHeap = OS.GetProcessHeap (); | 180 auto hHeap = OS.GetProcessHeap (); |
153 CHOOSEFONT lpcf; | 181 CHOOSEFONT lpcf; |
154 lpcf.lStructSize = CHOOSEFONT.sizeof; | 182 lpcf.lStructSize = CHOOSEFONT.sizeof; |
173 int blue = (rgb.blue << 16) & 0xFF0000; | 201 int blue = (rgb.blue << 16) & 0xFF0000; |
174 lpcf.rgbColors = red | green | blue; | 202 lpcf.rgbColors = red | green | blue; |
175 } | 203 } |
176 | 204 |
177 /* Make the parent shell be temporary modal */ | 205 /* Make the parent shell be temporary modal */ |
178 Shell oldModal = null; | 206 Dialog oldModal = null; |
179 Display display = null; | 207 Display display = null; |
180 if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) { | 208 if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) { |
181 display = parent.getDisplay (); | 209 display = parent.getDisplay (); |
182 oldModal = display.getModalDialogShell (); | 210 oldModal = display.getModalDialog (); |
183 display.setModalDialogShell (parent); | 211 display.setModalDialog (this); |
184 } | 212 } |
185 | 213 |
186 /* Open the dialog */ | 214 /* Open the dialog */ |
187 bool success = cast(bool) OS.ChooseFont (&lpcf); | 215 bool success = cast(bool) OS.ChooseFont (&lpcf); |
188 | 216 |
189 /* Clear the temporary dialog modal parent */ | 217 /* Clear the temporary dialog modal parent */ |
190 if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) { | 218 if ((style & (DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL)) !is 0) { |
191 display.setModalDialogShell (oldModal); | 219 display.setModalDialog (oldModal); |
192 } | 220 } |
193 | 221 |
194 /* Compute the result */ | 222 /* Compute the result */ |
195 if (success) { | 223 if (success) { |
196 LOGFONT* logFont = lpLogFont; | 224 LOGFONT* logFont = lpLogFont; |
233 } | 261 } |
234 | 262 |
235 /* Free the OS memory */ | 263 /* Free the OS memory */ |
236 if (lpLogFont !is null) OS.HeapFree (hHeap, 0, lpLogFont); | 264 if (lpLogFont !is null) OS.HeapFree (hHeap, 0, lpLogFont); |
237 | 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 | |
238 /* | 273 /* |
239 * This code is intentionally commented. On some | 274 * This code is intentionally commented. On some |
240 * platforms, the owner window is repainted right | 275 * platforms, the owner window is repainted right |
241 * away when a dialog window exits. This behavior | 276 * away when a dialog window exits. This behavior |
242 * is currently unspecified. | 277 * is currently unspecified. |