⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctabfolder.java

📁 源码为Eclipse开源开发平台桌面开发工具SWT的源代码,
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		public void getDefaultAction(AccessibleControlEvent e) {			String action = null;			int childID = e.childID;			if (childID >= 0 && childID < items.length) {				action = "Switch"; //$NON-NLS-1$			}			e.result = action;		}		public void getFocus(AccessibleControlEvent e) {			int childID = ACC.CHILDID_NONE;			if (isFocusControl()) {				if (selectedIndex == -1) {					childID = ACC.CHILDID_SELF;				} else {					childID = selectedIndex;				}			}			e.childID = childID;		}		public void getRole(AccessibleControlEvent e) {			int role = 0;			int childID = e.childID;			if (childID == ACC.CHILDID_SELF) {				role = ACC.ROLE_TABFOLDER;			} else if (childID >= 0 && childID < items.length) {				role = ACC.ROLE_TABITEM;			}			e.detail = role;		}				public void getSelection(AccessibleControlEvent e) {			e.childID = (selectedIndex == -1) ? ACC.CHILDID_NONE : selectedIndex;		}				public void getState(AccessibleControlEvent e) {			int state = 0;			int childID = e.childID;			if (childID == ACC.CHILDID_SELF) {				state = ACC.STATE_NORMAL;			} else if (childID >= 0 && childID < items.length) {				state = ACC.STATE_SELECTABLE;				if (isFocusControl()) {					state |= ACC.STATE_FOCUSABLE;				}				if (selectedIndex == childID) {					state |= ACC.STATE_SELECTED;					if (isFocusControl()) {						state |= ACC.STATE_FOCUSED;					}				}			}			e.detail = state;		}				public void getChildren(AccessibleControlEvent e) {			Object[] children = new Object[items.length];			for (int i = 0; i < items.length; i++) {				children[i] = new Integer(i);			}			e.children = children;		}	});		addListener(SWT.Selection, new Listener() {		public void handleEvent(Event event) {			if (isFocusControl()) {				if (selectedIndex == -1) {					accessible.setFocus(ACC.CHILDID_SELF);				} else {					accessible.setFocus(selectedIndex);				}			}		}	});	addListener(SWT.FocusIn, new Listener() {		public void handleEvent(Event event) {			if (selectedIndex == -1) {				accessible.setFocus(ACC.CHILDID_SELF);			} else {				accessible.setFocus(selectedIndex);			}		}	});}void onKeyDown (Event event) {	switch (event.keyCode) {		case SWT.ARROW_LEFT:		case SWT.ARROW_RIGHT:			int count = items.length;			if (count == 0) return;			if (selectedIndex  == -1) return;			int leadKey = (getStyle() & SWT.RIGHT_TO_LEFT) != 0 ? SWT.ARROW_RIGHT : SWT.ARROW_LEFT;			int offset =  event.keyCode == leadKey ? -1 : 1;			int index = selectedIndex + offset;			if (index < 0 || index >= count) return;			setSelection (index, true);			forceFocus();	}}void onDispose() {	/*	 * Usually when an item is disposed, destroyItem will change the size of the items array, 	 * reset the bounds of all the tabs and manage the widget associated with the tab.	 * Since the whole folder is being disposed, this is not necessary.  For speed	 * the inDispose flag is used to skip over this part of the item dispose.	 */	inDispose = true;		int length = items.length;	for (int i = 0; i < length; i++) {								if (items[i] != null) {			items[i].dispose();		}	}		selectionGradientColors = null;	selectionGradientPercents = null;	selectionBgImage = null;	selectionBackground = null;	selectionForeground = null;}void onDragDetect(Event event) {	boolean consume = false;	if (chevronRect.contains(event.x, event.y) ||	    minRect.contains(event.x, event.y) ||		maxRect.contains(event.x, event.y)){		consume = true;	} else {		for (int i = 0; i < items.length; i++) {			if (items[i].closeRect.contains(event.x, event.y)) {					consume = true;					break;			}		}	}	if (consume) {		event.type = SWT.None;	}}void onFocus(Event event) {	checkWidget();	if (selectedIndex >= 0) {		redraw();	} else {		setSelection(0, true);	}}boolean onMnemonic (Event event) {	char key = event.character;	for (int i = 0; i < items.length; i++) {		if (items[i] != null) {			char mnemonic = getMnemonic (items[i].getText ());			if (mnemonic != '\0') {				if (Character.toUpperCase (key) == Character.toUpperCase (mnemonic)) {					setSelection(i, true);					return true;				}			}		}	}	return false;}void onMouseDoubleClick(Event event) {		if (event.button != 1 || 		(event.stateMask & SWT.BUTTON2) != 0 || 		(event.stateMask & SWT.BUTTON3) != 0) return;	Event e = new Event();	e.item = getItem(new Point(event.x, event.y));	if (e.item != null) {		notifyListeners(SWT.DefaultSelection, e);	}}void onMouseHover(Event event) {	showToolTip(event.x, event.y);}void onMouse(Event event) {	int x = event.x, y = event.y;	switch (event.type) {		case SWT.MouseExit: {			if (minImageState != NORMAL) {				minImageState = NORMAL;				redraw(minRect.x, minRect.y, minRect.width, minRect.height, false);			}			if (maxImageState != NORMAL) {				maxImageState = NORMAL;				redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height, false);			}			if (chevronImageState != NORMAL) {				chevronImageState = NORMAL;				redraw(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, false);			}			for (int i=0; i<items.length; i++) {				CTabItem item = items[i];				if (i != selectedIndex && item.closeImageState != NONE) {					item.closeImageState = NONE;					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);				}				if (i == selectedIndex && item.closeImageState != NORMAL) {					item.closeImageState = NORMAL;					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);				}			}			break;		}		case SWT.MouseDown: {			if (minRect.contains(x, y)) {				if (event.button != 1) return;				minImageState = SELECTED;				redraw(minRect.x, minRect.y, minRect.width, minRect.height, false);				update();				return;			}			if (maxRect.contains(x, y)) {				if (event.button != 1) return;				maxImageState = SELECTED;				redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height, false);				update();				return;			}			if (chevronRect.contains(x, y)) {				if (event.button != 1) return;				if (chevronImageState != HOT) {					chevronImageState = HOT;				} else {					chevronImageState = SELECTED;				}				redraw(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, false);				update();				return;			}			CTabItem item = null;			if (single) {				if (selectedIndex != -1) {					Rectangle bounds = items[selectedIndex].getBounds();					if (bounds.contains(x, y)){						item = items[selectedIndex];					}				}			} else {				for (int i=0; i<items.length; i++) {					Rectangle bounds = items[i].getBounds();					if (bounds.contains(x, y)){						item = items[i];					}				}			}			if (item != null) {				if (item.closeRect.contains(x,y)){					if (event.button != 1) return;					item.closeImageState = SELECTED;					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);					update();					return;				}				int index = indexOf(item);				if (item.isShowing()){					setSelection(index, true);				}				return;			}			break;		}		case SWT.MouseMove: {			boolean close = false, minimize = false, maximize = false, chevron = false;			if (minRect.contains(x, y)) {				minimize = true;				if (minImageState != SELECTED && minImageState != HOT) {					minImageState = HOT;					redraw(minRect.x, minRect.y, minRect.width, minRect.height, false);				}			}			if (maxRect.contains(x, y)) {				maximize = true;				if (maxImageState != SELECTED && maxImageState != HOT) {					maxImageState = HOT;					redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height, false);				}			}			if (chevronRect.contains(x, y)) {				chevron = true;				if (chevronImageState != SELECTED && chevronImageState != HOT) {					chevronImageState = HOT;					redraw(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, false);				}			}			if (minImageState != NORMAL && !minimize) {				minImageState = NORMAL;				redraw(minRect.x, minRect.y, minRect.width, minRect.height, false);			}			if (maxImageState != NORMAL && !maximize) {				maxImageState = NORMAL;				redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height, false);			}			if (chevronImageState != NORMAL && !chevron) {				chevronImageState = NORMAL;				redraw(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, false);			}			for (int i=0; i<items.length; i++) {				CTabItem item = items[i];				close = false;				if (item.getBounds().contains(x, y)) {					close = true;					if (item.closeRect.contains(x, y)) {						if (item.closeImageState != SELECTED && item.closeImageState != HOT) {							item.closeImageState = HOT;							redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);						}					} else {						if (item.closeImageState != NORMAL) {							item.closeImageState = NORMAL;							redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);						}					}				} 				if (i != selectedIndex && item.closeImageState != NONE && !close) {					item.closeImageState = NONE;					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);				}				if (i == selectedIndex && item.closeImageState != NORMAL && !close) {					item.closeImageState = NORMAL;					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);				}			}			break;		}		case SWT.MouseUp: {			if (event.button != 1) return;			if (chevronRect.contains(x, y)) {				boolean selected = chevronImageState == SELECTED;				if (!selected) return;				CTabFolderEvent e = new CTabFolderEvent(this);				e.widget = this;				e.time = event.time;				e.x = chevronRect.x;				e.y = chevronRect.y;				e.width = chevronRect.width;				e.height = chevronRect.height;				e.doit = true;				for (int i = 0; i < folderListeners.length; i++) {					folderListeners[i].showList(e);				}				if (e.doit && !isDisposed()) {					showList(chevronRect);				}				Display display = getDisplay();				Point cursorLocation = display.getCursorLocation();				cursorLocation = display.map(null, this, cursorLocation);				chevronImageState = chevronRect.contains(cursorLocation) ? HOT : NORMAL;				redraw(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, false);				return;			}			if (minRect.contains(x, y)) {				boolean selected = minImageState == SELECTED;				minImageState = HOT;				redraw(minRect.x, minRect.y, minRect.width, minRect.height, false);				if (!selected) return;				CTabFolderEvent e = new CTabFolderEvent(this);				e.widget = this;				e.time = event.time;				for (int i = 0; i < folderListeners.length; i++) {					if (minimized) {						folderListeners[i].restore(e);					} else {						folderListeners[i].minimize(e);					}				}				return;			}			if (maxRect.contains(x, y)) {				boolean selected = maxImageState == SELECTED;				maxImageState = HOT;				redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height, false);				if (!selected) return;				CTabFolderEvent e = new CTabFolderEvent(this);				e.widget = this;				e.time = event.time;				for (int i = 0; i < folderListeners.length; i++) {					if (maximized) {						folderListeners[i].restore(e);					} else {						folderListeners[i].maximize(e);					}				}				return;			}			CTabItem item = null;			if (single) {				if (selectedIndex != -1) {					Rectangle bounds = items[selectedIndex].getBounds();					if (bounds.contains(x, y)){						item = items[selectedIndex];					}				}			} else {				for (int i=0; i<items.length; i++) {					Rectangle bounds = items[i].getBounds();					if (bounds.contains(x, y)){						item = items[i];					}				}			}			if (item != null) {				if (item.closeRect.contains(x,y)) {					boolean selected = item.closeImageState == SELECTED;					item.closeImageState = HOT;					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);					if (!selected) return;					CTabFold

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -