Mercurial > projects > dwt-mac
comparison dwt/widgets/ToolTip.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | 642f460a0908 |
children | 6d9ec9ccdcdd |
comparison
equal
deleted
inserted
replaced
44:ca5e494f2bbf | 45:d8635bb48c7c |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 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 * | 10 * |
11 * Port to the D programming language: | 11 * Port to the D programming language: |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | 12 * Jacob Carlborg <doob@me.com> |
13 *******************************************************************************/ | 13 *******************************************************************************/ |
14 module dwt.widgets.ToolTip; | 14 module dwt.widgets.ToolTip; |
15 | 15 |
16 | 16 |
17 import dwt.DWT; | 17 import dwt.DWT; |
54 * and ICON_WARNING may be specified. | 54 * and ICON_WARNING may be specified. |
55 * </p><p> | 55 * </p><p> |
56 * IMPORTANT: This class is intended to be subclassed <em>only</em> | 56 * IMPORTANT: This class is intended to be subclassed <em>only</em> |
57 * within the DWT implementation. | 57 * within the DWT implementation. |
58 * </p> | 58 * </p> |
59 * | |
60 * @see <a href="http://www.eclipse.org/swt/snippets/#tooltips">Tool Tips snippets</a> | |
61 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a> | |
62 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
59 * | 63 * |
60 * @since 3.2 | 64 * @since 3.2 |
61 */ | 65 */ |
62 public class ToolTip : Widget { | 66 public class ToolTip : Widget { |
63 Shell parent, tip; | 67 Shell parent, tip; |
172 void configure () { | 176 void configure () { |
173 Display display = parent.getDisplay (); | 177 Display display = parent.getDisplay (); |
174 int x = this.x; | 178 int x = this.x; |
175 int y = this.y; | 179 int y = this.y; |
176 if (x is -1 || y is -1) { | 180 if (x is -1 || y is -1) { |
177 Point point = display.getCursorLocation (); | 181 Point point; |
182 if (item !is null) { | |
183 point = item.getLocation (); | |
184 } else { | |
185 point = display.getCursorLocation (); | |
186 } | |
178 x = point.x; | 187 x = point.x; |
179 y = point.y; | 188 y = point.y; |
180 } | 189 } |
181 dwt.widgets.Monitor.Monitor monitor = parent.getMonitor (); | 190 dwt.widgets.Monitor.Monitor monitor = parent.getMonitor (); |
182 Rectangle dest = monitor.getBounds (); | 191 Rectangle dest = monitor.getBounds (); |
291 if (layoutMessage !is null) { | 300 if (layoutMessage !is null) { |
292 layoutMessage.setWidth (-1); | 301 layoutMessage.setWidth (-1); |
293 messageWidth = layoutMessage.getBounds ().width; | 302 messageWidth = layoutMessage.getBounds ().width; |
294 } | 303 } |
295 int messageTrim = 2 * INSET + 2 * BORDER + 2 * PADDING; | 304 int messageTrim = 2 * INSET + 2 * BORDER + 2 * PADDING; |
296 bool hasImage = layoutText !is null && (style & DWT.BALLOON) !is 0 && (style & (DWT.ICON_ERROR | DWT.ICON_INFORMATION | DWT.ICON_WARNING)) !is 0; | 305 bool hasImage = layoutText !is null && (style & DWT.BALLOON) !is 0 && (style & (DWT.ICON_ERROR | DWT.ICON_INFORMATION | DWT.ICON_WARNING)) !is 0; |
297 int textTrim = messageTrim + (hasImage ? IMAGE_SIZE : 0); | 306 int textTrim = messageTrim + (hasImage ? IMAGE_SIZE : 0); |
298 int width = Math.min (maxWidth, Math.max (textWidth + textTrim, messageWidth + messageTrim)); | 307 int width = Math.min (maxWidth, Math.max (textWidth + textTrim, messageWidth + messageTrim)); |
299 int textHeight = 0, messageHeight = 0; | 308 int textHeight = 0, messageHeight = 0; |
300 if (layoutText !is null) { | 309 if (layoutText !is null) { |
301 layoutText.setWidth (maxWidth - textTrim); | 310 layoutText.setWidth (maxWidth - textTrim); |