comparison dwtx/jface/fieldassist/ControlDecoration.d @ 70:46a6e0e6ccd4

Merge with d-fied sources of 3.4M7
author Frank Benoit <benoit@tionex.de>
date Thu, 22 May 2008 01:36:46 +0200
parents b3c8e32d406f
children c3583c6ec027
comparison
equal deleted inserted replaced
69:07b9d96fd764 70:46a6e0e6ccd4
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2006, 2007 IBM Corporation and others. 2 * Copyright (c) 2006, 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 *
119 * The decoration's visibility flag 119 * The decoration's visibility flag
120 */ 120 */
121 private bool visible = true; 121 private bool visible = true;
122 122
123 /** 123 /**
124 * bool indicating whether the decoration should only be shown when the 124 * Boolean indicating whether the decoration should only be shown when the
125 * control has focus 125 * control has focus
126 */ 126 */
127 private bool showOnlyOnFocus = false; 127 private bool showOnlyOnFocus = false;
128 128
129 /** 129 /**
130 * bool indicating whether the decoration should show its description 130 * Boolean indicating whether the decoration should show its description
131 * text in a hover when the user hovers over the decoration. 131 * text in a hover when the user hovers over the decoration.
132 */ 132 */
133 private bool showHover = true; 133 private bool showHover = true;
134 134
135 /** 135 /**
247 * The region used to manage the shell shape 247 * The region used to manage the shell shape
248 */ 248 */
249 Region region; 249 Region region;
250 250
251 /** 251 /**
252 * bool indicating whether the last computed polygon location had an 252 * Boolean indicating whether the last computed polygon location had an
253 * arrow on left. (true if left, false if right). 253 * arrow on left. (true if left, false if right).
254 */ 254 */
255 bool arrowOnLeft = true; 255 bool arrowOnLeft = true;
256 256
257 /* 257 /*
258 * Create a hover parented by the specified shell. 258 * Create a hover parented by the specified shell.
259 */ 259 */
260 this(Shell parent) { 260 this(Shell parent) {
261 Display display = parent.getDisplay(); 261 Display display = parent.getDisplay();
262 hoverShell = new Shell(parent, DWT.NO_TRIM | DWT.ON_TOP 262 hoverShell = new Shell(parent, DWT.NO_TRIM | DWT.ON_TOP
263 | DWT.NO_FOCUS); 263 | DWT.NO_FOCUS | DWT.TOOL);
264 hoverShell.setBackground(display 264 hoverShell.setBackground(display
265 .getSystemColor(DWT.COLOR_INFO_BACKGROUND)); 265 .getSystemColor(DWT.COLOR_INFO_BACKGROUND));
266 hoverShell.setForeground(display 266 hoverShell.setForeground(display
267 .getSystemColor(DWT.COLOR_INFO_FOREGROUND)); 267 .getSystemColor(DWT.COLOR_INFO_FOREGROUND));
268 hoverShell.addPaintListener(new class PaintListener { 268 hoverShell.addPaintListener(new class PaintListener {
822 * decorator descriptions. When {@link #setShowHover(bool)} has been set 822 * decorator descriptions. When {@link #setShowHover(bool)} has been set
823 * to <code>true</code>, a decoration's description text will be shown in 823 * to <code>true</code>, a decoration's description text will be shown in
824 * an info hover over the field's control whenever the mouse hovers over the 824 * an info hover over the field's control whenever the mouse hovers over the
825 * decoration. This method can be used to show a decoration's description 825 * decoration. This method can be used to show a decoration's description
826 * text at other times (such as when the control receives focus), or to show 826 * text at other times (such as when the control receives focus), or to show
827 * other text associated with the field. 827 * other text associated with the field. The hover will not be shown if the
828 * decoration is hidden.
828 * 829 *
829 * @param text 830 * @param text
830 * the text to be shown in the info hover, or <code>null</code> 831 * the text to be shown in the info hover, or <code>null</code>
831 * if no text should be shown. 832 * if no text should be shown.
832 */ 833 */
868 update(); 869 update();
869 } 870 }
870 } 871 }
871 872
872 /** 873 /**
873 * Hide the control decoration. This message has no effect if the decoration 874 * Hide the control decoration and any associated hovers. This message has
874 * is already hidden. 875 * no effect if the decoration is already hidden.
875 */ 876 */
876 public void hide() { 877 public void hide() {
877 if (visible) { 878 if (visible) {
878 visible = false; 879 visible = false;
880 hideHover();
879 update(); 881 update();
880 } 882 }
881 } 883 }
882 884
883 /** 885 /**
917 /** 919 /**
918 * Set the image shown in this control decoration. Update the rendered 920 * Set the image shown in this control decoration. Update the rendered
919 * decoration. 921 * decoration.
920 * 922 *
921 * @param image 923 * @param image
922 * the image to be shown adjacent to the control 924 * the image to be shown adjacent to the control. Should never be
925 * <code>null</code>.
923 */ 926 */
924 public void setImage(Image image) { 927 public void setImage(Image image) {
925 this.image = image; 928 this.image = image;
926 update(); 929 update();
927 } 930 }
1041 * specified control. 1044 * specified control.
1042 */ 1045 */
1043 private void showHoverText(String text, Control hoverNear) { 1046 private void showHoverText(String text, Control hoverNear) {
1044 // If we aren't to show a hover, don't do anything. 1047 // If we aren't to show a hover, don't do anything.
1045 if (!showHover) { 1048 if (!showHover) {
1049 return;
1050 }
1051
1052 // If we are not visible, don't show the hover.
1053 if (!visible) {
1046 return; 1054 return;
1047 } 1055 }
1048 // If there is no text, don't do anything. 1056 // If there is no text, don't do anything.
1049 if (text is null) { 1057 if (text is null) {
1050 hideHover(); 1058 hideHover();