Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 277346 Details for
Bug 543910
[Wayland] CTabFolder DragDetect signals inconsistency
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
CTab DnD
Bug543655_WaylandCTabDnD.java (text/x-java), 5.04 KB, created by
Xi Yan
on 2019-01-28 12:02:45 EST
(
hide
)
Description:
CTab DnD
Filename:
MIME Type:
Creator:
Xi Yan
Created:
2019-01-28 12:02:45 EST
Size:
5.04 KB
patch
obsolete
>/******************************************************************************* > * Copyright (c) 2018 Red Hat and others. All rights reserved. > * The contents of this file are made available under the terms > * of the GNU Lesser General Public License (LGPL) Version 2.1 that > * accompanies this distribution (lgpl-v21.txt). The LGPL is also > * available at http://www.gnu.org/licenses/lgpl.html. If the version > * of the LGPL at http://www.gnu.org is different to the version of > * the LGPL accompanying this distribution and there is any conflict > * between the two license versions, the terms of the LGPL accompanying > * this distribution shall govern. > * > * Contributors: > * Red Hat - initial API and implementation > *******************************************************************************/ >package org.eclipse.swt.tests.gtk.snippets; > >import org.eclipse.swt.SWT; >import org.eclipse.swt.custom.CTabFolder; >import org.eclipse.swt.custom.CTabItem; >import org.eclipse.swt.graphics.Point; >import org.eclipse.swt.graphics.Rectangle; >import org.eclipse.swt.layout.GridData; >import org.eclipse.swt.layout.GridLayout; >import org.eclipse.swt.widgets.Control; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Event; >import org.eclipse.swt.widgets.Listener; >import org.eclipse.swt.widgets.Shell; >import org.eclipse.swt.widgets.Text; > >public class Bug543655_WaylandCTabDnD { > > public static void main(String[] args) { > final Display display = new Display(); > Shell shell = new Shell(display); > shell.setLayout(new GridLayout()); > final CTabFolder folder = new CTabFolder(shell, SWT.BORDER); > folder.setLayoutData(new GridData(GridData.FILL_BOTH)); > for (int i = 0; i < 10; i++) { > CTabItem item = new CTabItem(folder, SWT.NONE); > item.setText("item " + i); > Text text = new Text(folder, SWT.BORDER | SWT.MULTI | SWT.VERTICAL); > text.setText("Text control for " + i); > item.setControl(text); > } > > Listener listener = new Listener() { > boolean drag = false; > boolean exitDrag = false; > CTabItem dragItem; > > @Override > public void handleEvent(Event e) { > Point p = new Point(e.x, e.y); > if (e.type == SWT.DragDetect) { > p = folder.toControl(display.getCursorLocation()); // see bug 43251 > } > switch (e.type) { > case SWT.DragDetect: { > System.out.println("DragDetect"); > CTabItem item = folder.getItem(p); > if (item == null) { > return; > } >// if (item.getBounds().width < 0 || item.getBounds().height < 0 || item.getControl().getBounds().height < 0) { >// return; >// } >// GC gc = new GC(folder); >// Image tabImage = new Image(null, item.getBounds().width, item.getBounds().height); >// gc.copyArea(tabImage, item.getBounds().x, item.getBounds().y); >// >// Image entireImage = new Image(null, item.getControl().getBounds().width, item.getControl().getBounds().height + item.getBounds().height); >// gc.copyArea(entireImage, 0, 0); >// >// Cursor tabCursor = new Cursor(display, tabImage.getImageData(), 0, 0); >// folder.setCursor(tabCursor); >// >// Cursor bigCursor = new Cursor(display, entireImage.getImageData(), item.getBounds().x, item.getBounds().y); >// item.getControl().setCursor(bigCursor); > > drag = true; > exitDrag = false; > dragItem = item; > break; > } > case SWT.MouseEnter: > if (exitDrag) { > exitDrag = false; > drag = e.button != 0; > } > break; > case SWT.MouseExit: > if (drag) { > folder.setInsertMark(null, false); > exitDrag = true; > drag = false; > } > break; > case SWT.MouseUp: { > System.out.println("MouseUp"); > folder.setCursor(null); > if (!drag) > return; > dragItem.getControl().setCursor(null); > folder.setInsertMark(null, false); > CTabItem item = folder.getItem(new Point(p.x, 1)); > if (item != null) { > Rectangle rect = item.getBounds(); > boolean after = p.x > rect.x + rect.width / 2; > int index = folder.indexOf(item); > index = after ? index + 1 : index - 1; > index = Math.max(0, index); > CTabItem newItem = new CTabItem(folder, SWT.NONE, index); > newItem.setText(dragItem.getText()); > Control c = dragItem.getControl(); > dragItem.setControl(null); > newItem.setControl(c); > dragItem.dispose(); > folder.setSelection(newItem); > } > drag = false; > exitDrag = false; > dragItem = null; > break; > } > case SWT.MouseMove: { > if (!drag) > return; > CTabItem item = folder.getItem(new Point(p.x, 2)); > if (item == null) { > folder.setInsertMark(null, false); > return; > } > Rectangle rect = item.getBounds(); > boolean after = p.x > rect.x + rect.width / 2; > folder.setInsertMark(item, after); > break; > } > } > } > }; > folder.addListener(SWT.DragDetect, listener); > folder.addListener(SWT.MouseUp, listener); > folder.addListener(SWT.MouseMove, listener); > folder.addListener(SWT.MouseExit, listener); > folder.addListener(SWT.MouseEnter, listener); > shell.open(); > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) > display.sleep(); > } > display.dispose(); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 543910
: 277346