From 624fe0d237e0e92c9ffdc3054ab74ad1325da881 Mon Sep 17 00:00:00 2001 From: ncazottes Date: Sun, 8 Apr 2018 22:37:58 +0200 Subject: Bug 533124 - Allow multi line text in CTabFolder. CTabFolderRenderer with flag that take into account carriage return for multi line. Addition of Snippet371. Addition of Javadoc on CTabItem.setText. Addition of same cross platform behavior relating to the drop-down menu for additional tabs. Change-Id: Ib45891dcc90727830262887745c8ec1ad9be451d Signed-off-by: ncazottes --- .../common/org/eclipse/swt/custom/CTabFolder.java | 3 ++- .../common/org/eclipse/swt/custom/CTabFolderRenderer.java | 2 +- .../common/org/eclipse/swt/custom/CTabItem.java | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt') diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java index f2f875a314..3c3d6ce74c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java @@ -3674,7 +3674,8 @@ void showList (Rectangle rect) { CTabItem tab = items[i]; if (tab.showing) continue; MenuItem item = new MenuItem(showMenu, SWT.NONE); - item.setText(tab.getText()); + // Bug 533124 In the case where you have multi line tab text, we force the drop-down menu to have single line entries to ensure consistent behavior across platforms. + item.setText(tab.getText().replace("\n", " ")); item.setImage(tab.getImage()); item.setData(id, tab); item.addSelectionListener(new SelectionAdapter() { diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java index 9d9bc6f608..9a966a435d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderRenderer.java @@ -93,7 +93,7 @@ public class CTabFolderRenderer { static final int ITEM_LEFT_MARGIN = 4; static final int ITEM_RIGHT_MARGIN = 4; static final int INTERNAL_SPACING = 4; - static final int FLAGS = SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC; + static final int FLAGS = SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC | SWT.DRAW_DELIMITER; static final String ELLIPSIS = "..."; //$NON-NLS-1$ //Part constants diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java index 20dc1aa0e1..5b30686160 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java @@ -398,6 +398,17 @@ public void setShowClose(boolean close) { showClose = close; parent.updateFolder(CTabFolder.REDRAW_TABS); } +/** + * Sets the text to display on the tab. + * A carriage return '\n' allows to display multi line text. + * + * @param string the tab name + * + * @exception SWTException + */ @Override public void setText (String string) { checkWidget(); -- cgit v1.2.3