View | Details | Raw Unified | Return to bug 73012 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java (-3 / +28 lines)
Lines 1167-1172 Link Here
1167
		gc.drawPolyline(shape);
1167
		gc.drawPolyline(shape);
1168
	}	
1168
	}	
1169
}
1169
}
1170
public boolean forceFocus() {
1171
	if (selectedIndex > 0 && !items[selectedIndex].enabled) return false;
1172
	return super.forceFocus();
1173
}
1170
/**
1174
/**
1171
 * Returns <code>true</code> if the receiver's border is visible.
1175
 * Returns <code>true</code> if the receiver's border is visible.
1172
 *
1176
 *
Lines 1870-1875 Link Here
1870
				}
1874
				}
1871
			}
1875
			}
1872
			if (index < 0 || index >= count) return;
1876
			if (index < 0 || index >= count) return;
1877
			while (!items[index].enabled) {
1878
			    	index = index + offset;
1879
			    	if (index < 0 || index >= count) return;
1880
			}
1873
			setSelection (index, true);
1881
			setSelection (index, true);
1874
			forceFocus();
1882
			forceFocus();
1875
	}
1883
	}
Lines 1932-1938 Link Here
1932
	if (selectedIndex >= 0) {
1940
	if (selectedIndex >= 0) {
1933
		redraw();
1941
		redraw();
1934
	} else {
1942
	} else {
1935
		setSelection(0, true);
1943
	    	int index = 0;
1944
	    	int count = items.length;
1945
	    	for (index = 0; index < count; index++) {
1946
	    	    if (items[index].enabled) break;
1947
	    	}
1948
		setSelection(index, true);
1936
	}
1949
	}
1937
}
1950
}
1938
boolean onMnemonic (Event event, boolean doit) {
1951
boolean onMnemonic (Event event, boolean doit) {
Lines 1956-1962 Link Here
1956
		(event.stateMask & SWT.BUTTON3) != 0) return;
1969
		(event.stateMask & SWT.BUTTON3) != 0) return;
1957
	Event e = new Event();
1970
	Event e = new Event();
1958
	e.item = getItem(new Point(event.x, event.y));
1971
	e.item = getItem(new Point(event.x, event.y));
1959
	if (e.item != null) {
1972
	if ((e.item != null) && ((CTabItem)e.item).enabled) {
1960
		notifyListeners(SWT.DefaultSelection, e);
1973
		notifyListeners(SWT.DefaultSelection, e);
1961
	}
1974
	}
1962
}
1975
}
Lines 2034-2039 Link Here
2034
				}
2047
				}
2035
			}
2048
			}
2036
			if (item != null) {
2049
			if (item != null) {
2050
			    	if (!item.enabled) return;
2037
				if (item.closeRect.contains(x,y)){
2051
				if (item.closeRect.contains(x,y)){
2038
					item.closeImageState = SELECTED;
2052
					item.closeImageState = SELECTED;
2039
					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);
2053
					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);
Lines 2088-2093 Link Here
2088
				CTabItem item = items[i];
2102
				CTabItem item = items[i];
2089
				close = false;
2103
				close = false;
2090
				if (item.getBounds().contains(x, y)) {
2104
				if (item.getBounds().contains(x, y)) {
2105
				    	if (!item.enabled) return;
2091
					close = true;
2106
					close = true;
2092
					if (item.closeRect.contains(x, y)) {
2107
					if (item.closeRect.contains(x, y)) {
2093
						if (item.closeImageState != SELECTED && item.closeImageState != HOT) {
2108
						if (item.closeImageState != SELECTED && item.closeImageState != HOT) {
Lines 2184-2189 Link Here
2184
				}
2199
				}
2185
			}
2200
			}
2186
			if (item != null) {
2201
			if (item != null) {
2202
			    	if (!item.enabled) return;
2187
				if (item.closeRect.contains(x,y)) {
2203
				if (item.closeRect.contains(x,y)) {
2188
					boolean selected = item.closeImageState == SELECTED;
2204
					boolean selected = item.closeImageState == SELECTED;
2189
					item.closeImageState = HOT;
2205
					item.closeImageState = HOT;
Lines 2269-2274 Link Here
2269
				}
2285
				}
2270
			}
2286
			}
2271
		}
2287
		}
2288
		while (!items[index].enabled && index != selectedIndex) {
2289
		    	index = (index + offset + count) % count;
2290
		}
2272
	}
2291
	}
2273
	setSelection (index, true);
2292
	setSelection (index, true);
2274
}
2293
}
Lines 3220-3226 Link Here
3220
		showItem(selection);
3239
		showItem(selection);
3221
		return;
3240
		return;
3222
	}
3241
	}
3223
	
3242
	if (!items[index].enabled) return;
3224
	int oldIndex = selectedIndex;
3243
	int oldIndex = selectedIndex;
3225
	selectedIndex = index;
3244
	selectedIndex = index;
3226
	if (oldIndex != -1) {
3245
	if (oldIndex != -1) {
Lines 3244-3249 Link Here
3244
			oldControl.setVisible(false);
3263
			oldControl.setVisible(false);
3245
		}
3264
		}
3246
	}
3265
	}
3266
	if (oldIndex != -1 && !items[oldIndex].enabled) {
3267
	    	if (oldControl != null && !oldControl.isDisposed() && !oldControl.isEnabled()) {
3268
	    	    	oldControl.setEnabled(items[oldIndex].controlEnabled);
3269
	    	}
3270
	}
3247
	showItem(selection);
3271
	showItem(selection);
3248
	redraw();
3272
	redraw();
3249
}
3273
}
Lines 4022-4027 Link Here
4022
	if (showChevron && chevronRect.contains(x, y)) return SWT.getMessage("SWT_ShowList"); //$NON-NLS-1$
4046
	if (showChevron && chevronRect.contains(x, y)) return SWT.getMessage("SWT_ShowList"); //$NON-NLS-1$
4023
	CTabItem item = getItem(new Point (x, y));
4047
	CTabItem item = getItem(new Point (x, y));
4024
	if (item == null) return null;
4048
	if (item == null) return null;
4049
	if (!item.enabled) return null;
4025
	if (!item.showing) return null;
4050
	if (!item.showing) return null;
4026
	if ((showClose || item.showClose) && item.closeRect.contains(x, y)) {
4051
	if ((showClose || item.showClose) && item.closeRect.contains(x, y)) {
4027
		return SWT.getMessage("SWT_Close"); //$NON-NLS-1$
4052
		return SWT.getMessage("SWT_Close"); //$NON-NLS-1$
(-)Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java (+51 lines)
Lines 50-55 Link Here
50
	int closeImageState = CTabFolder.NONE;
50
	int closeImageState = CTabFolder.NONE;
51
	boolean showClose = false;
51
	boolean showClose = false;
52
	boolean showing = false;
52
	boolean showing = false;
53
	boolean enabled = true;
54
	boolean controlEnabled = true;
53
55
54
	// internal constants
56
	// internal constants
55
	static final int TOP_MARGIN = 2;
57
	static final int TOP_MARGIN = 2;
Lines 718-723 Link Here
718
	return disabledImage;
720
	return disabledImage;
719
}
721
}
720
/**
722
/**
723
 * Returns <code>true</code> if the receiver is enabled, and
724
 * <code>false</code> otherwise. A disabled CTabItem is
725
 * not selectable from the user interface.
726
 *
727
 * @return the receiver's enabled state
728
 *
729
 * @exception SWTException <ul>
730
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
731
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
732
 * </ul>
733
 * 
734
 * @since 3.6
735
 */
736
public boolean getEnabled () {
737
	checkWidget();
738
	return this.enabled;
739
}
740
/**
721
 * Returns the font that the receiver will use to paint textual information.
741
 * Returns the font that the receiver will use to paint textual information.
722
 *
742
 *
723
 * @return the receiver's font
743
 * @return the receiver's font
Lines 901-906 Link Here
901
		} else {
921
		} else {
902
			this.control.setVisible(false);
922
			this.control.setVisible(false);
903
		}
923
		}
924
		this.controlEnabled = control.getEnabled();
904
	}
925
	}
905
}
926
}
906
/**
927
/**
Lines 924-929 Link Here
924
	this.disabledImage = image;
945
	this.disabledImage = image;
925
}
946
}
926
/**
947
/**
948
 * Enables the receiver if the argument is <code>true</code>,
949
 * and disables it otherwise. A disabled CTabItem is typically
950
 * not selectable from the user interface.
951
 *
952
 * @param enabled the new enabled state
953
 *
954
 * @exception SWTException <ul>
955
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
956
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
957
 * </ul>
958
 * 
959
 * @since 3.6
960
 */
961
public void setEnabled (boolean enabled) {
962
    	checkWidget();
963
    	if (this.enabled == enabled) return;
964
    	
965
    	this.enabled = enabled;
966
    	if (this.control != null) {
967
    	     	if (!enabled && (parent.getSelection() == this)) {
968
    	    	    	this.controlEnabled = this.control.getEnabled();
969
    	    	    	this.control.setEnabled(enabled);
970
    	    	} else if (enabled && (parent.getSelection() == this)) {
971
    	    	    	if (!this.control.getEnabled()) {
972
    	    	    	    	this.control.setEnabled(this.controlEnabled);
973
    	    	    	}
974
    	    	}
975
    	}
976
}
977
/**
927
 * Sets the font that the receiver will use to paint textual information
978
 * Sets the font that the receiver will use to paint textual information
928
 * for this item to the font specified by the argument, or to the default font
979
 * for this item to the font specified by the argument, or to the default font
929
 * for that kind of control if the argument is null.
980
 * for that kind of control if the argument is null.

Return to bug 73012