📄 ctabfolder.java
字号:
* * @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 int getItemCount(){ //checkWidget(); return items.length;}/** * Return the tab items. * * @return the tab items * * @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 [] getItems() { //checkWidget(); CTabItem[] tabItems = new CTabItem [items.length]; System.arraycopy(items, 0, tabItems, 0, items.length); return tabItems;}int getLastIndex() { if (single) return selectedIndex; if (items.length == 0) return -1; for (int i = firstIndex; i < items.length; i++) { CTabItem item = items[i]; if (item.isShowing()) continue; return i == firstIndex ? firstIndex : i - 1; } return items.length - 1;}char getMnemonic (String string) { int index = 0; int length = string.length (); do { while ((index < length) && (string.charAt (index) != '&')) index++; if (++index >= length) return '\0'; if (string.charAt (index) != '&') return string.charAt (index); index++; } while (index < length); return '\0';}/** * Returns <code>true</code> if the receiver is minimized. * * @return the receiver's minimized 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 getMinimized() { checkWidget(); return minimized;}/** * Returns <code>true</code> if the minimize button * is visible. * * @return the visibility of the minimized button * * @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 getMinimizeVisible() { checkWidget(); return showMin;}/** * Returns the number of characters that will * appear in a fully compressed tab. * * @return number of characters that will appear in a fully compressed tab * * @since 3.0 */public int getMinimumCharacters() { checkWidget(); return minChars;}/** * Returns <code>true</code> if the receiver is maximized. * <p> * * @return the receiver's maximized 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 getMaximized() { checkWidget(); return maximized;}/** * Returns <code>true</code> if the maximize button * is visible. * * @return the visibility of the maximized button * * @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 getMaximizeVisible() { checkWidget(); return showMax;}int getRightItemEdge (){ int x = getSize().x - borderRight - 3; if (showMin) x -= BUTTON_SIZE; if (showMax) x -= BUTTON_SIZE; if (showChevron) x -= 3*BUTTON_SIZE/2; if (topRight != null && topRightAlignment != SWT.FILL) x -= topRightRect.width + 3; return x;}/** * Return the selected tab item, or an empty array if there * is no selection. * * @return the selected tab item * * @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 getSelection() { //checkWidget(); if (selectedIndex == -1) return null; return items[selectedIndex];}/** * Returns the receiver's selection background color. * * @return the selection background color of the receiver * * @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 Color getSelectionBackground() { checkWidget(); return selectionBackground;}/** * Returns the receiver's selection foreground color. * * @return the selection foreground color of the receiver * * @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 Color getSelectionForeground() { checkWidget(); return selectionForeground;}/** * Return the index of the selected tab item, or -1 if there * is no selection. * * @return the index of the selected tab item or -1 * * @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 int getSelectionIndex() { //checkWidget(); return selectedIndex;}/** * Returns <code>true</code> if the CTabFolder is rendered * with a simple, traditional shape. * * @return <code>true</code> if the CTabFolder is rendered with a simple shape * * @since 3.0 */public boolean getSimple() { checkWidget(); return simple;}/** * Returns <code>true</code> if the CTabFolder only displys the selected tab * and <code>false</code> if the CTabFolder displays multiple tabs. * * @return <code>true</code> if the CTabFolder only displys the selected tab and <code>false</code> if the CTabFolder displays multiple tabs * * @since 3.0 */public boolean getSingle() { checkWidget(); return single;}public int getStyle() { int style = super.getStyle(); style &= ~(SWT.TOP | SWT.BOTTOM); style |= onBottom ? SWT.BOTTOM : SWT.TOP; style &= ~(SWT.SINGLE | SWT.MULTI); style |= single ? SWT.SINGLE : SWT.MULTI; if (borderLeft != 0) style |= SWT.BORDER; return style;}/** * Returns the height of the tab * * @return the height of the tab * * @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 int getTabHeight(){ checkWidget(); if (fixedTabHeight != SWT.DEFAULT) return fixedTabHeight; return tabHeight - 1; // -1 for line drawn across top of tab}/** * Returns the position of the tab. Possible values are SWT.TOP or SWT.BOTTOM. * * @return the position of the tab * * @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 int getTabPosition(){ checkWidget(); return onBottom ? SWT.BOTTOM : SWT.TOP;}/** * Returns the control in the top right corner of the tab folder. * Typically this is a close button or a composite with a menu and close button. * * @return the control in the top right corner of the tab folder 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> * * @since 2.1 */public Control getTopRight() { checkWidget(); return topRight;}/** * Returns <code>true</code> if the close button appears * when the user hovers over an unselected tabs. * * @return <code>true</code> if the close button appears on unselected tabs * * @since 3.0 */public boolean getUnselectedCloseVisible() { checkWidget(); return showUnselectedClose;}/** * Returns <code>true</code> if an image appears * in unselected tabs. * * @return <code>true</code> if an image appears in unselected tabs * * @since 3.0 */public boolean getUnselectedImageVisible() { checkWidget(); return showUnselectedImage;}/** * Return the index of the specified tab or -1 if the tab is not * in the receiver. * * @param item the tab item for which the index is required * * @return the index of the specified tab item or -1 * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</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 int indexOf(CTabItem item) { checkWidget(); if (item == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); } for (int i = 0; i < items.length; i++) { if (items[i] == item) return i; } return -1;}void initAccessible() { final Accessible accessible = getAccessible(); accessible.addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent e) { String name = null; int childID = e.childID; if (childID >= 0 && childID < items.length) { name = items[childID].getText(); int index = name.indexOf('&'); if (index > 0) { name = name.substring(0, index) + name.substring(index + 1); } } e.result = name; } public void getHelp(AccessibleEvent e) { String help = null; int childID = e.childID; if (childID == ACC.CHILDID_SELF) { help = getToolTipText(); } else if (childID >= 0 && childID < items.length) { help = items[childID].getToolTipText(); } e.result = help; } public void getKeyboardShortcut(AccessibleEvent e) { String shortcut = null; int childID = e.childID; if (childID >= 0 && childID < items.length) { String text = items[childID].getText(); if (text != null) { char mnemonic = getMnemonic(text); if (mnemonic != '\0') { shortcut = "Alt+"+mnemonic; //$NON-NLS-1$ } } } e.result = shortcut; } }); accessible.addAccessibleControlListener(new AccessibleControlAdapter() { public void getChildAtPoint(AccessibleControlEvent e) { Point testPoint = toControl(new Point(e.x, e.y)); int childID = ACC.CHILDID_NONE; for (int i = 0; i < items.length; i++) { if (items[i].getBounds().contains(testPoint)) { childID = i; break; } } if (childID == ACC.CHILDID_NONE) { Rectangle location = getBounds(); location.height = location.height - getClientArea().height; if (location.contains(testPoint)) { childID = ACC.CHILDID_SELF; } } e.childID = childID; } public void getLocation(AccessibleControlEvent e) { Rectangle location = null; int childID = e.childID; if (childID == ACC.CHILDID_SELF) { location = getBounds(); } if (childID >= 0 && childID < items.length) { location = items[childID].getBounds(); } if (location != null) { Point pt = toDisplay(new Point(location.x, location.y)); e.x = pt.x; e.y = pt.y; e.width = location.width; e.height = location.height; } } public void getChildCount(AccessibleControlEvent e) { e.detail = items.length; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -