comparison dwt/widgets/ColorDialog.d @ 240:ce446666f5a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Mon, 12 May 2008 19:13:01 +0200
parents 0f12f6bb9739
children 5a30aa9820f3
comparison
equal deleted inserted replaced
239:06a1f6829310 240:ce446666f5a2
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2000, 2007 IBM Corporation and others. 2 * Copyright (c) 2000, 2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
57 * @see DWT 57 * @see DWT
58 * @see Widget#checkSubclass 58 * @see Widget#checkSubclass
59 * @see Widget#getStyle 59 * @see Widget#getStyle
60 */ 60 */
61 public this (Shell parent) { 61 public this (Shell parent) {
62 this (parent, DWT.NONE); 62 this (parent, DWT.APPLICATION_MODAL);
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.
67 * <p> 67 * <p>
88 * @see DWT 88 * @see DWT
89 * @see Widget#checkSubclass 89 * @see Widget#checkSubclass
90 * @see Widget#getStyle 90 * @see Widget#getStyle
91 */ 91 */
92 public this (Shell parent, int style) { 92 public this (Shell parent, int style) {
93 super (parent, style); 93 super (parent, checkStyle (parent, style));
94 checkSubclass (); 94 checkSubclass ();
95 } 95 }
96 96
97 /** 97 /**
98 * Returns the currently selected color in the receiver. 98 * Returns the currently selected color in the receiver.
118 * </ul> 118 * </ul>
119 */ 119 */
120 public RGB open () { 120 public RGB open () {
121 char* buffer = toStringz(title); 121 char* buffer = toStringz(title);
122 auto handle = cast(GtkWidget*)OS.gtk_color_selection_dialog_new (buffer); 122 auto handle = cast(GtkWidget*)OS.gtk_color_selection_dialog_new (buffer);
123 Display display = parent !is null ? parent.getDisplay (): Display.getCurrent ();
123 if (parent !is null) { 124 if (parent !is null) {
124 auto shellHandle = parent.topHandle (); 125 auto shellHandle = parent.topHandle ();
125 OS.gtk_window_set_transient_for (handle, shellHandle); 126 OS.gtk_window_set_transient_for (handle, shellHandle);
126 auto pixbufs = OS.gtk_window_get_icon_list (shellHandle); 127 auto pixbufs = OS.gtk_window_get_icon_list (shellHandle);
127 if (pixbufs !is null) { 128 if (pixbufs !is null) {
136 color.green = cast(short)((rgb.green & 0xFF) | ((rgb.green & 0xFF) << 8)); 137 color.green = cast(short)((rgb.green & 0xFF) | ((rgb.green & 0xFF) << 8));
137 color.blue = cast(short)((rgb.blue & 0xFF) | ((rgb.blue & 0xFF) << 8)); 138 color.blue = cast(short)((rgb.blue & 0xFF) | ((rgb.blue & 0xFF) << 8));
138 OS.gtk_color_selection_set_current_color (dialog.colorsel, &color); 139 OS.gtk_color_selection_set_current_color (dialog.colorsel, &color);
139 } 140 }
140 OS.gtk_color_selection_set_has_palette (dialog.colorsel, true); 141 OS.gtk_color_selection_set_has_palette (dialog.colorsel, true);
141 Display display = parent !is null ? parent.getDisplay (): Display.getCurrent ();
142 display.addIdleProc (); 142 display.addIdleProc ();
143 Dialog oldModal = null;
144 if (OS.gtk_window_get_modal (handle)) {
145 oldModal = display.getModalDialog ();
146 display.setModalDialog (this);
147 }
148 int signalId = 0;
149 int /*long*/ hookId = 0;
150 CallbackData emissionData;
151 emissionData.display = display;
152 emissionData.data = handle;
153 if ((style & DWT.RIGHT_TO_LEFT) !is 0) {
154 signalId = OS.g_signal_lookup (OS.map.ptr, OS.GTK_TYPE_WIDGET());
155 hookId = OS.g_signal_add_emission_hook (signalId, 0, &Display.emissionFunc, &emissionData, null);
156 }
143 int response = OS.gtk_dialog_run (handle); 157 int response = OS.gtk_dialog_run (handle);
158 if ((style & DWT.RIGHT_TO_LEFT) !is 0) {
159 OS.g_signal_remove_emission_hook (signalId, hookId);
160 }
161 if (OS.gtk_window_get_modal (handle)) {
162 display.setModalDialog (oldModal);
163 }
144 bool success = response is OS.GTK_RESPONSE_OK; 164 bool success = response is OS.GTK_RESPONSE_OK;
145 if (success) { 165 if (success) {
146 OS.gtk_color_selection_get_current_color (dialog.colorsel, &color); 166 OS.gtk_color_selection_get_current_color (dialog.colorsel, &color);
147 int red = (color.red >> 8) & 0xFF; 167 int red = (color.red >> 8) & 0xFF;
148 int green = (color.green >> 8) & 0xFF; 168 int green = (color.green >> 8) & 0xFF;