Mercurial > projects > dwt-mac
comparison dwt/browser/WindowEvent.d @ 125:5583f8eeee6c
Synced mozilla with dwt-linux
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Fri, 16 Jan 2009 12:49:08 +0100 |
parents | d8635bb48c7c |
children |
comparison
equal
deleted
inserted
replaced
124:540fa4e9974a | 125:5583f8eeee6c |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2003, 2008 IBM Corporation and others. | 2 * Copyright (c) 2003, 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 |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * | |
11 * Port to the D programming language: | 10 * Port to the D programming language: |
12 * Jacob Carlborg <doob@me.com> | 11 * John Reimer <terminal.node@gmail.com> |
13 *******************************************************************************/ | 12 *******************************************************************************/ |
14 module dwt.browser.WindowEvent; | 13 module dwt.browser.WindowEvent; |
15 | 14 |
16 import dwt.browser.Browser; | 15 import tango.text.convert.Format; |
16 | |
17 import dwt.dwthelper.utils; | 17 import dwt.dwthelper.utils; |
18 | |
18 import dwt.events.TypedEvent; | 19 import dwt.events.TypedEvent; |
19 import dwt.graphics.Point; | 20 import dwt.graphics.Point; |
20 import dwt.widgets.Widget; | 21 import dwt.widgets.Widget; |
22 import dwt.browser.Browser; | |
21 | 23 |
22 /** | 24 /** |
23 * A <code>WindowEvent</code> is sent by a {@link Browser} when | 25 * A <code>WindowEvent</code> is sent by a {@link Browser} when |
24 * a new window needs to be created or when an existing window needs to be | 26 * a new window needs to be created or when an existing window needs to be |
25 * closed. This notification occurs when a javascript command such as | 27 * closed. This notification occurs when a javascript command such as |
64 * event.browser = browser; | 66 * event.browser = browser; |
65 * } | 67 * } |
66 * }); | 68 * }); |
67 * browser.addVisibilityWindowListener(new VisibilityWindowListener() { | 69 * browser.addVisibilityWindowListener(new VisibilityWindowListener() { |
68 * public void hide(WindowEvent event) { | 70 * public void hide(WindowEvent event) { |
69 * Browser browser = cast(Browser)event.widget; | 71 * Browser browser = (Browser)event.widget; |
70 * Shell shell = browser.getShell(); | 72 * Shell shell = browser.getShell(); |
71 * shell.setVisible(false); | 73 * shell.setVisible(false); |
72 * } | 74 * } |
73 * public void show(WindowEvent event) { | 75 * public void show(WindowEvent event) { |
74 * Browser browser = cast(Browser)event.widget; | 76 * Browser browser = (Browser)event.widget; |
75 * Shell shell = browser.getShell(); | 77 * Shell shell = browser.getShell(); |
76 * if (event.location !is null) shell.setLocation(event.location); | 78 * if (event.location !is null) shell.setLocation(event.location); |
77 * if (event.size !is null) { | 79 * if (event.size !is null) { |
78 * Point size = event.size; | 80 * Point size = event.size; |
79 * shell.setSize(shell.computeSize(size.x, size.y)); | 81 * shell.setSize(shell.computeSize(size.x, size.y)); |
86 * shell.open(); | 88 * shell.open(); |
87 * } | 89 * } |
88 * }); | 90 * }); |
89 * browser.addCloseWindowListener(new CloseWindowListener() { | 91 * browser.addCloseWindowListener(new CloseWindowListener() { |
90 * public void close(WindowEvent event) { | 92 * public void close(WindowEvent event) { |
91 * Browser browser = cast(Browser)event.widget; | 93 * Browser browser = (Browser)event.widget; |
92 * Shell shell = browser.getShell(); | 94 * Shell shell = browser.getShell(); |
93 * shell.close(); | 95 * shell.close(); |
94 * } | 96 * } |
95 * }); | 97 * }); |
96 * } | 98 * } |
121 * </ul> | 123 * </ul> |
122 * | 124 * |
123 * @see CloseWindowListener | 125 * @see CloseWindowListener |
124 * @see OpenWindowListener | 126 * @see OpenWindowListener |
125 * @see VisibilityWindowListener | 127 * @see VisibilityWindowListener |
126 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
127 * | 128 * |
128 * @since 3.0 | 129 * @since 3.0 |
129 */ | 130 */ |
130 public class WindowEvent : TypedEvent { | 131 public class WindowEvent : TypedEvent { |
131 | 132 |
134 * <code>Browser</code> to handle the new window. | 135 * <code>Browser</code> to handle the new window. |
135 * | 136 * |
136 * @since 3.1 | 137 * @since 3.1 |
137 */ | 138 */ |
138 public bool required; | 139 public bool required; |
139 | 140 |
141 | |
140 /** | 142 /** |
141 * <code>Browser</code> provided by the application. | 143 * <code>Browser</code> provided by the application. |
142 */ | 144 */ |
143 public Browser browser; | 145 public Browser browser; |
144 | 146 |
152 * Requested <code>Browser</code> size. The client area of the <code>Shell</code> | 154 * Requested <code>Browser</code> size. The client area of the <code>Shell</code> |
153 * hosting the <code>Browser</code> should be large enough to accommodate that size. | 155 * hosting the <code>Browser</code> should be large enough to accommodate that size. |
154 * It is <code>null</code> if no size has been requested. | 156 * It is <code>null</code> if no size has been requested. |
155 */ | 157 */ |
156 public Point size; | 158 public Point size; |
157 | 159 |
158 /** | 160 /** |
159 * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should | 161 * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should |
160 * display an address bar. | 162 * display an address bar. |
161 * | 163 * |
162 * @since 3.1 | 164 * @since 3.1 |
168 * display a menu bar. | 170 * display a menu bar. |
169 * | 171 * |
170 * @since 3.1 | 172 * @since 3.1 |
171 */ | 173 */ |
172 public bool menuBar; | 174 public bool menuBar; |
173 | 175 |
174 /** | 176 /** |
175 * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should | 177 * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should |
176 * display a status bar. | 178 * display a status bar. |
177 * | 179 * |
178 * @since 3.1 | 180 * @since 3.1 |
179 */ | 181 */ |
180 public bool statusBar; | 182 public bool statusBar; |
181 | 183 |
182 /** | 184 /** |
183 * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should | 185 * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should |
184 * display a tool bar. | 186 * display a tool bar. |
185 * | 187 * |
186 * @since 3.1 | 188 * @since 3.1 |
187 */ | 189 */ |
188 public bool toolBar; | 190 public bool toolBar; |
189 | 191 |
190 static final long serialVersionUID = 3617851997387174969L; | 192 static final long serialVersionUID = 3617851997387174969L; |
191 | 193 |
192 this (Widget w) { | 194 this(Widget w) { |
193 super(w); | 195 super(w); |
194 } | |
195 | |
196 /** | |
197 * Returns a String containing a concise, human-readable | |
198 * description of the receiver. | |
199 * | |
200 * @return a String representation of the event | |
201 */ | |
202 public String toString () { | |
203 String str = super.toString(); | |
204 return str.substring(0, str.length() - 1) // remove trailing '}' | |
205 + " required=" + required + " browser=" + browser + " location=" + location + " size=" + size + " addressBar=" + addressBar + " menuBar=" + menuBar + " statusBar=" + statusBar + " toolBar=" + toolBar + "}"; | |
206 } | |
207 } | 196 } |
197 | |
198 /** | |
199 * Returns a string containing a concise, human-readable | |
200 * description of the receiver. | |
201 * | |
202 * @return a string representation of the event | |
203 */ | |
204 | |
205 public String toString() { | |
206 return Format( "{} {required = {}, browser = {}, location = {}, size = {}, addressbar = {}, menubar = {}, statusbar = {}, toolbar = {}}", | |
207 super.toString[1 .. $-2], | |
208 required, browser, | |
209 location, size, addressBar, | |
210 menuBar, statusBar, toolBar ); | |
211 } | |
212 } |