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 / +19 lines)
Lines 1870-1875 Link Here
1870
				}
1870
				}
1871
			}
1871
			}
1872
			if (index < 0 || index >= count) return;
1872
			if (index < 0 || index >= count) return;
1873
			while (!items[index].enabled) {
1874
			    	index = index + offset;
1875
			    	if (index < 0 || index >= count) return;
1876
			}
1873
			setSelection (index, true);
1877
			setSelection (index, true);
1874
			forceFocus();
1878
			forceFocus();
1875
	}
1879
	}
Lines 1932-1938 Link Here
1932
	if (selectedIndex >= 0) {
1936
	if (selectedIndex >= 0) {
1933
		redraw();
1937
		redraw();
1934
	} else {
1938
	} else {
1935
		setSelection(0, true);
1939
	    	int index = 0;
1940
	    	int count = items.length;
1941
	    	for (index = 0; index < count; index++) {
1942
	    	    if (items[index].enabled) break;
1943
	    	}
1944
		setSelection(index, true);
1936
	}
1945
	}
1937
}
1946
}
1938
boolean onMnemonic (Event event, boolean doit) {
1947
boolean onMnemonic (Event event, boolean doit) {
Lines 1956-1962 Link Here
1956
		(event.stateMask & SWT.BUTTON3) != 0) return;
1965
		(event.stateMask & SWT.BUTTON3) != 0) return;
1957
	Event e = new Event();
1966
	Event e = new Event();
1958
	e.item = getItem(new Point(event.x, event.y));
1967
	e.item = getItem(new Point(event.x, event.y));
1959
	if (e.item != null) {
1968
	if ((e.item != null) && ((CTabItem)e.item).enabled) {
1960
		notifyListeners(SWT.DefaultSelection, e);
1969
		notifyListeners(SWT.DefaultSelection, e);
1961
	}
1970
	}
1962
}
1971
}
Lines 2034-2039 Link Here
2034
				}
2043
				}
2035
			}
2044
			}
2036
			if (item != null) {
2045
			if (item != null) {
2046
			    	if (!item.enabled) return;
2037
				if (item.closeRect.contains(x,y)){
2047
				if (item.closeRect.contains(x,y)){
2038
					item.closeImageState = SELECTED;
2048
					item.closeImageState = SELECTED;
2039
					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);
2049
					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);
Lines 2088-2093 Link Here
2088
				CTabItem item = items[i];
2098
				CTabItem item = items[i];
2089
				close = false;
2099
				close = false;
2090
				if (item.getBounds().contains(x, y)) {
2100
				if (item.getBounds().contains(x, y)) {
2101
				    	if (!item.enabled) return;
2091
					close = true;
2102
					close = true;
2092
					if (item.closeRect.contains(x, y)) {
2103
					if (item.closeRect.contains(x, y)) {
2093
						if (item.closeImageState != SELECTED && item.closeImageState != HOT) {
2104
						if (item.closeImageState != SELECTED && item.closeImageState != HOT) {
Lines 2184-2189 Link Here
2184
				}
2195
				}
2185
			}
2196
			}
2186
			if (item != null) {
2197
			if (item != null) {
2198
			    	if (!item.enabled) return;
2187
				if (item.closeRect.contains(x,y)) {
2199
				if (item.closeRect.contains(x,y)) {
2188
					boolean selected = item.closeImageState == SELECTED;
2200
					boolean selected = item.closeImageState == SELECTED;
2189
					item.closeImageState = HOT;
2201
					item.closeImageState = HOT;
Lines 2269-2274 Link Here
2269
				}
2281
				}
2270
			}
2282
			}
2271
		}
2283
		}
2284
		while (!items[index].enabled && index != selectedIndex) {
2285
		    	index = (index + offset + count) % count;
2286
		}
2272
	}
2287
	}
2273
	setSelection (index, true);
2288
	setSelection (index, true);
2274
}
2289
}
Lines 3220-3226 Link Here
3220
		showItem(selection);
3235
		showItem(selection);
3221
		return;
3236
		return;
3222
	}
3237
	}
3223
	
3238
	if (!items[index].enabled) return;
3224
	int oldIndex = selectedIndex;
3239
	int oldIndex = selectedIndex;
3225
	selectedIndex = index;
3240
	selectedIndex = index;
3226
	if (oldIndex != -1) {
3241
	if (oldIndex != -1) {
Lines 4022-4027 Link Here
4022
	if (showChevron && chevronRect.contains(x, y)) return SWT.getMessage("SWT_ShowList"); //$NON-NLS-1$
4037
	if (showChevron && chevronRect.contains(x, y)) return SWT.getMessage("SWT_ShowList"); //$NON-NLS-1$
4023
	CTabItem item = getItem(new Point (x, y));
4038
	CTabItem item = getItem(new Point (x, y));
4024
	if (item == null) return null;
4039
	if (item == null) return null;
4040
	if (!item.enabled) return null;
4025
	if (!item.showing) return null;
4041
	if (!item.showing) return null;
4026
	if ((showClose || item.showClose) && item.closeRect.contains(x, y)) {
4042
	if ((showClose || item.showClose) && item.closeRect.contains(x, y)) {
4027
		return SWT.getMessage("SWT_Close"); //$NON-NLS-1$
4043
		return SWT.getMessage("SWT_Close"); //$NON-NLS-1$
(-)Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java (+48 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;
53
54
54
	// internal constants
55
	// internal constants
55
	static final int TOP_MARGIN = 2;
56
	static final int TOP_MARGIN = 2;
Lines 718-723 Link Here
718
	return disabledImage;
719
	return disabledImage;
719
}
720
}
720
/**
721
/**
722
 * Returns <code>true</code> if the receiver is enabled, and
723
 * <code>false</code> otherwise. A disabled CTabItem is
724
 * not selectable from the user interface.
725
 *
726
 * @return the receiver's enabled state
727
 *
728
 * @exception SWTException <ul>
729
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
730
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
731
 * </ul>
732
 * 
733
 * @since 3.6
734
 */
735
public boolean getEnabled () {
736
    	checkWidget();
737
	return this.enabled;
738
}
739
/**
721
 * Returns the font that the receiver will use to paint textual information.
740
 * Returns the font that the receiver will use to paint textual information.
722
 *
741
 *
723
 * @return the receiver's font
742
 * @return the receiver's font
Lines 923-928 Link Here
923
	}
942
	}
924
	this.disabledImage = image;
943
	this.disabledImage = image;
925
}
944
}
945
946
/**
947
 * Enables the receiver if the argument is <code>true</code>, and disables
948
 * it otherwise. A disabled CTabItem is not selectable from the user
949
 * interface. When a selected CTabItem is disabled, it is no longer the 
950
 * selected tab-item and the selected index changes to -1.
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 (!enabled && (parent.getSelection() == this)) {
967
    	    	if (control != null) control.setVisible(false);
968
    	    	parent.selectedIndex = -1;
969
    	    	closeImageState = CTabFolder.NONE;
970
    	    	parent.updateItems();
971
        	parent.redrawTabs();
972
    	}
973
}
926
/**
974
/**
927
 * Sets the font that the receiver will use to paint textual information
975
 * 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
976
 * for this item to the font specified by the argument, or to the default font

Return to bug 73012