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

📄 ctabfolder.java

📁 源码为Eclipse开源开发平台桌面开发工具SWT的源代码,
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		} else {			gc.drawLine(x1, y2, x2, y2); // bottom		}	}}void drawChevron(GC gc) {	if (chevronRect.width == 0 || chevronRect.height == 0) return;	// draw chevron (10x7)	Display display = getDisplay();	FontData fd = getFont().getFontData()[0];	fd.setHeight(7);	Font f = new Font(display, fd);	int fHeight = f.getFontData()[0].getHeight() * display.getDPI().y / 72;	int indent = Math.max(2, (chevronRect.height - fHeight - 4) /2);	int x = chevronRect.x + 2;	int y = chevronRect.y + indent;	int count;	if (single) {		count = selectedIndex == -1 ? items.length : items.length - 1;	} else {		int lastIndex = getLastIndex();		count = Math.max(0, items.length - (lastIndex - firstIndex + 1));	}	switch (chevronImageState) {		case NORMAL: {			Color chevronBorder = single ? getSelectionForeground() : getForeground();			gc.setForeground(chevronBorder);			gc.setFont(f);			gc.drawLine(x,y,     x+2,y+2);			gc.drawLine(x+2,y+2, x,y+4);			gc.drawLine(x+1,y,   x+3,y+2);			gc.drawLine(x+3,y+2, x+1,y+4);			gc.drawLine(x+4,y,   x+6,y+2);			gc.drawLine(x+6,y+2, x+5,y+4);			gc.drawLine(x+5,y,   x+7,y+2);			gc.drawLine(x+7,y+2, x+4,y+4);			gc.drawString(String.valueOf(count), x+7, y+3, true);			break;		}		case HOT: {			gc.setForeground(display.getSystemColor(BUTTON_BORDER));			gc.setBackground(display.getSystemColor(BUTTON_FILL));			gc.setFont(f);			gc.fillRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, 6, 6);			gc.drawRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width - 1, chevronRect.height - 1, 6, 6);			gc.drawLine(x,y,     x+2,y+2);			gc.drawLine(x+2,y+2, x,y+4);			gc.drawLine(x+1,y,   x+3,y+2);			gc.drawLine(x+3,y+2, x+1,y+4);			gc.drawLine(x+4,y,   x+6,y+2);			gc.drawLine(x+6,y+2, x+5,y+4);			gc.drawLine(x+5,y,   x+7,y+2);			gc.drawLine(x+7,y+2, x+4,y+4);			gc.drawString(String.valueOf(count), x+7, y+3, true);			break;		}		case SELECTED: {			gc.setForeground(display.getSystemColor(BUTTON_BORDER));			gc.setBackground(display.getSystemColor(BUTTON_FILL));			gc.setFont(f);			gc.fillRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, 6, 6);			gc.drawRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width - 1, chevronRect.height - 1, 6, 6);			gc.drawLine(x+1,y+1, x+3,y+3);			gc.drawLine(x+3,y+3, x+1,y+5);			gc.drawLine(x+2,y+1, x+4,y+3);			gc.drawLine(x+4,y+3, x+2,y+5);			gc.drawLine(x+5,y+1, x+7,y+3);			gc.drawLine(x+7,y+3, x+6,y+5);			gc.drawLine(x+6,y+1, x+8,y+3);			gc.drawLine(x+8,y+3, x+5,y+5);			gc.drawString(String.valueOf(count), x+8, y+4, true);			break;		}	}	f.dispose();}void drawMaximize(GC gc) {	if (maxRect.width == 0 || maxRect.height == 0) return;	Display display = getDisplay();	// 5x4 or 7x9	int x = maxRect.x + (CTabFolder.BUTTON_SIZE - 10)/2;	int y = maxRect.y + 3;		gc.setForeground(display.getSystemColor(BUTTON_BORDER));	gc.setBackground(display.getSystemColor(BUTTON_FILL));		switch (maxImageState) {		case NORMAL: {			if (!maximized) {				gc.fillRectangle(x, y, 9, 9);				gc.drawRectangle(x, y, 9, 9);				gc.drawLine(x+1, y+2, x+8, y+2);							} else {				gc.fillRectangle(x, y+3, 5, 4);				gc.fillRectangle(x+2, y, 5, 4);				gc.drawRectangle(x, y+3, 5, 4);				gc.drawRectangle(x+2, y, 5, 4);				gc.drawLine(x+3, y+1, x+6, y+1);				gc.drawLine(x+1, y+4, x+4, y+4);			}			break;		}		case HOT: {			gc.fillRoundRectangle(maxRect.x, maxRect.y, maxRect.width, maxRect.height, 6, 6);			gc.drawRoundRectangle(maxRect.x, maxRect.y, maxRect.width - 1, maxRect.height - 1, 6, 6);			if (!maximized) {				gc.fillRectangle(x, y, 9, 9);				gc.drawRectangle(x, y, 9, 9);				gc.drawLine(x+1, y+2, x+8, y+2);			} else {				gc.fillRectangle(x, y+3, 5, 4);				gc.fillRectangle(x+2, y, 5, 4);				gc.drawRectangle(x, y+3, 5, 4);				gc.drawRectangle(x+2, y, 5, 4);				gc.drawLine(x+3, y+1, x+6, y+1);				gc.drawLine(x+1, y+4, x+4, y+4);			}			break;		}		case SELECTED: {			gc.fillRoundRectangle(maxRect.x, maxRect.y, maxRect.width, maxRect.height, 6, 6);			gc.drawRoundRectangle(maxRect.x, maxRect.y, maxRect.width - 1, maxRect.height - 1, 6, 6);			if (!maximized) {				gc.fillRectangle(x+1, y+1, 9, 9);				gc.drawRectangle(x+1, y+1, 9, 9);				gc.drawLine(x+2, y+3, x+9, y+3);			} else {				gc.fillRectangle(x+1, y+4, 5, 4);				gc.fillRectangle(x+3, y+1, 5, 4);				gc.drawRectangle(x+1, y+4, 5, 4);				gc.drawRectangle(x+3, y+1, 5, 4);				gc.drawLine(x+4, y+2, x+7, y+2);				gc.drawLine(x+2, y+5, x+5, y+5);			}			break;		}	}}void drawMinimize(GC gc) {	if (minRect.width == 0 || minRect.height == 0) return;	Display display = getDisplay();	// 5x4 or 9x3	int x = minRect.x + (BUTTON_SIZE - 10)/2;	int y = minRect.y + 3;		gc.setForeground(display.getSystemColor(BUTTON_BORDER));	gc.setBackground(display.getSystemColor(BUTTON_FILL));		switch (minImageState) {		case NORMAL: {			if (!minimized) {				gc.fillRectangle(x, y, 9, 3);				gc.drawRectangle(x, y, 9, 3);			} else {				gc.fillRectangle(x, y+3, 5, 4);				gc.fillRectangle(x+2, y, 5, 4);				gc.drawRectangle(x, y+3, 5, 4);				gc.drawRectangle(x+2, y, 5, 4);				gc.drawLine(x+3, y+1, x+6, y+1);				gc.drawLine(x+1, y+4, x+4, y+4);			}			break;		}		case HOT: {			gc.fillRoundRectangle(minRect.x, minRect.y, minRect.width, minRect.height, 6, 6);			gc.drawRoundRectangle(minRect.x, minRect.y, minRect.width - 1, minRect.height - 1, 6, 6);			if (!minimized) {				gc.fillRectangle(x, y, 9, 3);				gc.drawRectangle(x, y, 9, 3);			} else {				gc.fillRectangle(x, y+3, 5, 4);				gc.fillRectangle(x+2, y, 5, 4);				gc.drawRectangle(x, y+3, 5, 4);				gc.drawRectangle(x+2, y, 5, 4);				gc.drawLine(x+3, y+1, x+6, y+1);				gc.drawLine(x+1, y+4, x+4, y+4);			}			break;		}		case SELECTED: {			gc.fillRoundRectangle(minRect.x, minRect.y, minRect.width, minRect.height, 6, 6);			gc.drawRoundRectangle(minRect.x, minRect.y, minRect.width - 1, minRect.height - 1, 6, 6);			if (!minimized) {				gc.fillRectangle(x+1, y+1, 9, 3);				gc.drawRectangle(x+1, y+1, 9, 3);			} else {				gc.fillRectangle(x+1, y+4, 5, 4);				gc.fillRectangle(x+3, y+1, 5, 4);				gc.drawRectangle(x+1, y+4, 5, 4);				gc.drawRectangle(x+3, y+1, 5, 4);				gc.drawLine(x+4, y+2, x+7, y+2);				gc.drawLine(x+2, y+5, x+5, y+5);			}			break;		}	}}void drawTabArea(Event event) {	GC gc = event.gc;	Point size = getSize();	int[] shape = null;		if (tabHeight == 0) {		int x1 = borderLeft - 1;		int x2 = size.x - borderRight;		int y1 = onBottom ? size.y - borderBottom - highlight_header - 1 : borderTop + highlight_header;		int y2 = onBottom ? size.y - borderBottom : borderTop;		if (borderLeft > 0 && onBottom) y2 -= 1;				shape = new int[] {x1, y1, x1,y2, x2,y2, x2,y1};		// If horizontal gradient, show gradient across the whole area		if (selectedIndex != -1 && selectionGradientColors != null && selectionGradientColors.length > 1 && !selectionGradientVertical) {			drawBackground(gc, shape, true);		} else if (selectedIndex == -1 && gradientColors != null && gradientColors.length > 1 && !gradientVertical) {			drawBackground(gc, shape, false);		} else {			gc.setBackground(selectedIndex == -1 ? getBackground() : selectionBackground);			gc.fillPolygon(shape);		}				//draw 1 pixel border		if (borderLeft > 0) {			gc.setForeground(borderColor);			gc.drawPolyline(shape); 		}		return;	}		int x = Math.max(0, borderLeft - 1);	int y = onBottom ? size.y - borderBottom - tabHeight : borderTop;	int width = size.x - borderLeft - borderRight + 1;	int height = tabHeight - 1;		// Draw Tab Header	if (onBottom) {		int[] left = simple ? SIMPLE_BOTTOM_LEFT_CORNER : BOTTOM_LEFT_CORNER;		int[] right = simple ? SIMPLE_BOTTOM_RIGHT_CORNER : BOTTOM_RIGHT_CORNER;		shape = new int[left.length + right.length + 4];		int index = 0;		shape[index++] = x;		shape[index++] = y-highlight_header;		for (int i = 0; i < left.length/2; i++) {			shape[index++] = x+left[2*i];			shape[index++] = y+height+left[2*i+1];			if (borderLeft == 0) shape[index-1] += 1;		}		for (int i = 0; i < right.length/2; i++) {			shape[index++] = x+width+right[2*i];			shape[index++] = y+height+right[2*i+1];			if (borderLeft == 0) shape[index-1] += 1;		}		shape[index++] = x+width;		shape[index++] = y-highlight_header;	} else {		int[] left = simple ? SIMPLE_TOP_LEFT_CORNER : TOP_LEFT_CORNER;		int[] right = simple ? SIMPLE_TOP_RIGHT_CORNER : TOP_RIGHT_CORNER;		shape = new int[left.length + right.length + 4];		int index = 0;		shape[index++] = x;		shape[index++] = y+height+highlight_header + 1;		for (int i = 0; i < left.length/2; i++) {			shape[index++] = x+left[2*i];			shape[index++] = y+left[2*i+1];		}		for (int i = 0; i < right.length/2; i++) {			shape[index++] = x+width+right[2*i];			shape[index++] = y+right[2*i+1];		}		shape[index++] = x+width;		shape[index++] = y+height+highlight_header + 1;	}	// Fill in background	boolean bkSelected = single && selectedIndex != -1;	drawBackground(gc, shape, bkSelected);	// Fill in parent background for non-rectangular shape	Region r = new Region();	r.add(new Rectangle(x, y, width + 1, height + 1));	r.subtract(shape);	gc.setBackground(getParent().getBackground());	fillRegion(gc, r);	r.dispose();	// Draw border line	if (borderLeft > 0) {		RGB outside = getParent().getBackground().getRGB();		antialias(shape, borderColor.getRGB(), null, outside, gc);		gc.setForeground(borderColor);		gc.drawPolyline(shape);	}			// Draw the unselected tabs.	if (!single) {		for (int i=0; i < items.length; i++) {			if (i != selectedIndex && event.getBounds().intersects(items[i].getBounds())) {				items[i].onPaint(gc, false);			}		}	}		// Draw selected tab	if (selectedIndex != -1) {		CTabItem item = items[selectedIndex];		item.onPaint(gc, true);	} else {		// if no selected tab - draw line across bottom of all tabs		int x1 = borderLeft;		int y1 = (onBottom) ? size.y - borderBottom - tabHeight - 1 : borderTop + tabHeight;		int x2 = size.x - borderRight;		gc.setForeground(borderColor);		gc.drawLine(x1, y1, x2, y1);	}		// Draw Buttons	if (items.length > 0) {		drawChevron(gc);		drawMinimize(gc);		drawMaximize(gc);	}		// Draw insertion mark//	if (insertionIndex > -2) {//		gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));//		if (insertionIndex == -1) {//			Rectangle bounds = items[0].getBounds();//			gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);//			gc.drawLine(bounds.x - 2, bounds.y, bounds.x + 2, bounds.y);//			gc.drawLine(bounds.x - 1, bounds.y + 1, bounds.x + 1, bounds.y + 1);//			gc.drawLine(bounds.x - 1, bounds.y + bounds.height - 2, bounds.x + 1, bounds.y + bounds.height - 2);//			gc.drawLine(bounds.x - 2, bounds.y + bounds.height - 1, bounds.x + 2, bounds.y + bounds.height - 1);////		} else {//			Rectangle bounds = items[insertionIndex].getBounds();//			gc.drawLine(bounds.x + bounds.width, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height - 1);//			gc.drawLine(bounds.x + bounds.width - 2, bounds.y, bounds.x + bounds.width + 2, bounds.y);//			gc.drawLine(bounds.x + bounds.width - 1, bounds.y + 1, bounds.x + bounds.width + 1, bounds.y + 1);//			gc.drawLine(bounds.x + bounds.width - 1, bounds.y + bounds.height - 2, bounds.x + bounds.width + 1, bounds.y + bounds.height - 2);//			gc.drawLine(bounds.x + bounds.width - 2, bounds.y + bounds.height - 1, bounds.x + bounds.width + 2, bounds.y + bounds.height - 1);//		}//	}}/** * Returns <code>true</code> if the receiver's border is visible. * * @return the receiver's border visibility state * * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> *  * @since 3.0 */public boolean getBorderVisible() {	checkWidget();	return borderLeft == 1;}public Rectangle getClientArea() {	checkWidget();	if (minimized) return new Rectangle(xClient, yClient, 0, 0);	Point size = getSize();	int width = size.x  - borderLeft - borderRight - 2*marginWidth - 2*highlight_margin;	int height = size.y - borderTop - borderBottom - 2*marginHeight - highlight_margin - highlight_header;	height -= tabHeight;	return new Rectangle(xClient, yClient, width, height);}/** * Return the tab that is located at the specified index. *  * @param index the index of the tab item * @return the item at the specified index *  * @exception IllegalArgumentException <ul> *    <li>ERROR_INVALID_RANGE - if the index is out of range</li> * </ul> *  * @exception SWTError <ul> *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> */public CTabItem getItem (int index) {	//checkWidget();	if (index  < 0 || index >= items.length) 		SWT.error(SWT.ERROR_INVALID_RANGE);	return items [index];}/** * Gets the item at a point in the widget. * * @param pt the point in coordinates relative to the CTabFolder * @return the item at a point or null *  * @exception SWTError <ul> *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> *	</ul> */public CTabItem getItem (Point pt) {	//checkWidget();	if (items.length == 0) return null;	Point size = getSize();	if (size.x <= borderLeft + borderRight) return null;	for (int index = firstIndex; index < items.length; index++) {		CTabItem item = items[index];		Rectangle rect = item.getBounds();		if (rect.contains(pt)) return item;	}	return null;}/** * Return the number of tabs in the folder. *  * @return the number of tabs in the folder

⌨️ 快捷键说明

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