public void createControl(Composite parent) { Composite pageContent = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 3; pageContent.setLayout(layout); pageContent.setLayoutData(new GridData(GridData.FILL_BOTH)); // variable never used ... is pageContent.getLayoutData() needed? // GridData outerFrameGridData = (GridData) pageContent.getLayoutData(); // outerFrameGridData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_FILL; // outerFrameGridData.verticalAlignment = GridData.VERTICAL_ALIGN_FILL; // WorkbenchHelp.setHelp( // pageContent, // B2BGUIContextIds.BTBG_SELECT_MULTI_FILE_PAGE); createLabels(pageContent); createSourceViewer(pageContent); createButtonPanel(pageContent); createSelectedListBox(pageContent); createImportButton(pageContent); setControl(pageContent); if (isFileMandatory) setPageComplete(false); }
void drawRectangles(Rectangle[] rects, boolean stippled) { int xDisplay = display.xDisplay; int color = OS.XWhitePixel(xDisplay, 0); int xWindow = OS.XDefaultRootWindow(xDisplay); if (parent != null) { xWindow = OS.XtWindow(parent.handle); if (xWindow == 0) return; int foreground = parent.getForegroundPixel(); Control control = parent.findBackgroundControl(); if (control == null) control = parent; int background = control.getBackgroundPixel(); color = foreground ^ background; } int gc = OS.XCreateGC(xDisplay, xWindow, 0, null); OS.XSetForeground(xDisplay, gc, color); OS.XSetSubwindowMode(xDisplay, gc, OS.IncludeInferiors); OS.XSetFunction(xDisplay, gc, OS.GXxor); int stipplePixmap = 0; if (stippled) { byte[] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0}; stipplePixmap = OS.XCreateBitmapFromData(xDisplay, xWindow, bits, 8, 8); OS.XSetStipple(xDisplay, gc, stipplePixmap); OS.XSetFillStyle(xDisplay, gc, OS.FillStippled); OS.XSetLineAttributes(xDisplay, gc, 3, OS.LineSolid, OS.CapButt, OS.JoinMiter); } for (int i = 0; i < rects.length; i++) { Rectangle rect = rects[i]; OS.XDrawRectangle(xDisplay, xWindow, gc, rect.x, rect.y, rect.width, rect.height); } if (stippled) { OS.XFreePixmap(xDisplay, stipplePixmap); } OS.XFreeGC(xDisplay, gc); }
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); final ScrolledComposite sc = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Composite c = new Composite(sc, SWT.NONE); c.setLayout(new GridLayout(10, true)); for (int i = 0; i < 300; i++) { Button b = new Button(c, SWT.PUSH); b.setText("Button " + i); } sc.setContent(c); sc.setExpandHorizontal(true); sc.setExpandVertical(true); sc.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT)); sc.setShowFocusedControl(true); shell.setSize(300, 500); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("SWT and Swing DND Example"); GridLayout layout = new GridLayout(1, false); shell.setLayout(layout); Text swtText = new Text(shell, SWT.BORDER); swtText.setText("SWT Text"); GridData data = new GridData(GridData.FILL_HORIZONTAL); swtText.setLayoutData(data); setDragDrop(swtText); Composite comp = new Composite(shell, SWT.EMBEDDED); java.awt.Frame frame = SWT_AWT.new_Frame(comp); JTextField swingText = new JTextField(40); swingText.setText("Swing Text"); swingText.setDragEnabled(true); frame.add(swingText); data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = swingText.getPreferredSize().height; comp.setLayoutData(data); shell.setSize(400, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
/** * Creates an instance of a ControlExample embedded inside the supplied parent Composite. * * @param parent the container of the example */ public ControlExample(Composite parent) { initResources(); tabFolder = new TabFolder(parent, SWT.NONE); tabs = createTabs(); for (Tab tab : tabs) { TabItem item = new TabItem(tabFolder, SWT.NONE); item.setText(tab.getTabText()); item.setControl(tab.createTabFolderPage(tabFolder)); item.setData(tab); } /* Workaround: if the tab folder is wider than the screen, * Mac platforms clip instead of somehow scrolling the tab items. * We try to recover some width by using shorter tab names. */ Point size = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle monitorArea = parent.getMonitor().getClientArea(); boolean isMac = SWT.getPlatform().equals("cocoa"); if (size.x > monitorArea.width && isMac) { TabItem[] tabItems = tabFolder.getItems(); for (int i = 0; i < tabItems.length; i++) { tabItems[i].setText(tabs[i].getShortTabText()); } } startup = false; }
void update() { if (parent != null) { if (parent.isDisposed()) return; parent.getShell().update(); } else { display.update(); } }
public TermWinUI(Shell parent) { self = new Shell(parent, SWT.SHELL_TRIM); self.setLayout(new GridLayout()); mainPane = new Composite(self, SWT.NONE); mainPane.setLayout(new GridLayout(3, false)); mainPane.setLayoutData(new GridData(GridData.FILL_BOTH)); createContent(); }
protected Control createContents(Composite parent) { initializeValues(); Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout(1, false)); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); createControls(composite); return getControl(); }
public void createContents(Composite parent) { shell = parent.getShell(); parent.setLayout(new FillLayout()); folder = new TabFolder(shell, SWT.BORDER); labelTab(); directoryDialogTab(); buttonTab(); sliderTab(); scribbleTab(); browserTab(); }
public SpinnerFieldEditor( String name, String labelText, Composite parent, int min, int max, int increment, int pageIncrement) { init(name, labelText); GridLayout layout = new GridLayout(); layout.numColumns = getNumberOfControls(); layout.marginWidth = 0; layout.marginHeight = 0; layout.horizontalSpacing = HORIZONTAL_GAP; parent.setLayout(layout); // create label control getLabelControl(parent); spinner = new BigDecimalSpinner(parent, SWT.NONE, 0, min, max, increment, pageIncrement); spinner.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { valueChanged(); } }); doFillIntoGrid(parent, layout.numColumns); }
private int QueryContinueDrag(int fEscapePressed, int grfKeyState) { if (topControl != null && topControl.isDisposed()) return COM.DRAGDROP_S_CANCEL; if (fEscapePressed != 0) { if (hwndDrag != 0) OS.ImageList_DragLeave(hwndDrag); return COM.DRAGDROP_S_CANCEL; } /* * Bug in Windows. On some machines that do not have XBUTTONs, * the MK_XBUTTON1 and OS.MK_XBUTTON2 bits are sometimes set, * causing mouse capture to become stuck. The fix is to test * for the extra buttons only when they exist. */ int mask = OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON; // if (display.xMouse) mask |= OS.MK_XBUTTON1 | OS.MK_XBUTTON2; if ((grfKeyState & mask) == 0) { if (hwndDrag != 0) OS.ImageList_DragLeave(hwndDrag); return COM.DRAGDROP_S_DROP; } if (hwndDrag != 0) { POINT pt = new POINT(); OS.GetCursorPos(pt); RECT rect = new RECT(); OS.GetWindowRect(hwndDrag, rect); OS.ImageList_DragMove(pt.x - rect.left, pt.y - rect.top); } return COM.S_OK; }
public static void sliderTab() { TabItem tab = new TabItem(folder, SWT.CLOSE); tab.setText("Sliders and Progress bars"); tab.setToolTipText("Tied Slider to ProgressBar"); Composite composite = new Composite(folder, SWT.NONE); composite.setLayout(new GridLayout(2, true)); final Slider slider = new Slider(composite, SWT.HORIZONTAL); final ProgressBar progress = new ProgressBar(composite, SWT.HORIZONTAL); slider.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { progress.setSelection(slider.getSelection()); } }); tab.setControl(composite); }
public Control createControl(Composite parent) { control = new Composite(parent, SWT.NONE); control.setLayout(bl); constants.createControl(control); dependency.createControl(control); enableComponent(-1); return control; }
public static void buttonTab() { TabItem tab = new TabItem(folder, SWT.CLOSE); tab.setText("Buttons"); tab.setToolTipText("Different kinds of Buttons"); Composite composite = new Composite(folder, SWT.NONE); composite.setLayout(new GridLayout(4, true)); for (int dir : new int[] {SWT.UP, SWT.RIGHT, SWT.LEFT, SWT.DOWN}) { Button b = new Button(composite, SWT.ARROW | dir); b.addListener(SWT.MouseDown, listener); } newButton(composite, SWT.CHECK, "Check button"); newButton(composite, SWT.PUSH, "Push button"); newButton(composite, SWT.RADIO, "Radio button"); newButton(composite, SWT.TOGGLE, "Toggle button"); newButton(composite, SWT.FLAT, "Flat button"); tab.setControl(composite); }
void setOrientation(boolean create) { super.setOrientation(create); if (items != null) { for (int i = 0; i < items.length; i++) { if (items[i] != null) items[i].setOrientation(create); } } }
public MainWindow(Composite parent, int style) { super(parent, style); initGUI(); setPreferences(); waitCursor = getDisplay().getSystemCursor(SWT.CURSOR_WAIT); defaultCursor = getDisplay().getSystemCursor(SWT.CURSOR_ARROW); clientArea.setFocus(); }
@Override void setOrientation(boolean create) { super.setOrientation(create); ToolItem[] items = _getItems(); for (int i = 0; i < items.length; i++) { items[i].setOrientation(create); } }
void removeControl(Control control) { super.removeControl(control); int count = getItemCount(); for (int i = 0; i < count; i++) { TabItem item = items[i]; if (item.control == control) item.setControl(null); } }
@Override void setForegroundColor(GdkColor color) { super.setForegroundColor(color); ToolItem[] items = getItems(); for (int i = 0; i < items.length; i++) { items[i].setForegroundColor(color); } }
void setForegroundColor(GdkColor color) { super.setForegroundColor(color); TabItem[] items = getItems(); for (int i = 0; i < items.length; i++) { if (items[i] != null) { items[i].setForegroundColor(color); } } }
void setFontDescription(long /*int*/ font) { super.setFontDescription(font); TabItem[] items = getItems(); for (int i = 0; i < items.length; i++) { if (items[i] != null) { items[i].setFontDescription(font); } } }
@Override void setFontDescription(long /*int*/ font) { super.setFontDescription(font); ToolItem[] items = getItems(); for (int i = 0; i < items.length; i++) { items[i].setFontDescription(font); } relayout(); }
@Override void setBackgroundColor(long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) { if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) { String css = "GtkToolbar {background-color: " + gtk_rgba_to_css_string(rgba) + "}"; gtk_css_provider_load_from_css(context, css); } else { super.setBackgroundColor(context, handle, rgba); } }
@Override void removeControl(Control control) { super.removeControl(control); ToolItem[] items = getItems(); for (int i = 0; i < items.length; i++) { ToolItem item = items[i]; if (item.control == control) item.setControl(null); } }
private void createButtonPanel(Composite pageContent) { Composite buttonPanel = new Composite(pageContent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 1; buttonPanel.setLayout(layout); GridData gridData = new GridData(); gridData.grabExcessHorizontalSpace = false; gridData.grabExcessVerticalSpace = true; gridData.verticalAlignment = GridData.CENTER; gridData.horizontalAlignment = GridData.CENTER; buttonPanel.setLayoutData(gridData); addButton = new Button(buttonPanel, SWT.PUSH); addButton.setText(Messages._UI_ADD_BUTTON); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.CENTER; addButton.setLayoutData(gridData); addButton.addSelectionListener(new ButtonSelectListener()); addButton.setToolTipText(Messages._UI_ADD_BUTTON_TOOL_TIP); addButton.setEnabled(false); removeButton = new Button(buttonPanel, SWT.PUSH); removeButton.setText(Messages._UI_REMOVE_BUTTON); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.CENTER; removeButton.setLayoutData(gridData); removeButton.addSelectionListener(new ButtonSelectListener()); removeButton.setToolTipText(Messages._UI_REMOVE_BUTTON_TOOL_TIP); removeButton.setEnabled(false); removeAllButton = new Button(buttonPanel, SWT.PUSH); removeAllButton.setText(Messages._UI_REMOVE_ALL_BUTTON); gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.verticalAlignment = GridData.CENTER; removeAllButton.setLayoutData(gridData); removeAllButton.addSelectionListener(new ButtonSelectListener()); removeAllButton.setToolTipText(Messages._UI_REMOVE_ALL_BUTTON_TOOL_TIP); removeAllButton.setEnabled(false); }
@Override public void setToolTipText(String string) { checkWidget(); super.setToolTipText(string); Shell shell = _getShell(); ToolItem[] items = getItems(); for (int i = 0; i < items.length; i++) { String newString = string != null ? null : items[i].toolTipText; shell.setToolTipText(items[i].handle, newString); } }
@Override void reskinChildren(int flags) { ToolItem[] items = _getItems(); if (items != null) { for (int i = 0; i < items.length; i++) { ToolItem item = items[i]; if (item != null) item.reskin(flags); } } super.reskinChildren(flags); }
@Override void releaseChildren(boolean destroy) { ToolItem[] items = getItems(); for (int i = 0; i < items.length; i++) { ToolItem item = items[i]; if (item != null && !item.isDisposed()) { item.release(false); } } super.releaseChildren(destroy); }
void releaseChildren(boolean destroy) { if (items != null) { for (int i = 0; i < items.length; i++) { TabItem item = items[i]; if (item != null && !item.isDisposed()) { item.release(false); } } items = null; } super.releaseChildren(destroy); }
@Override void releaseChildren(boolean destroy) { if (caret != null) { caret.release(false); caret = null; } if (ime != null) { ime.release(false); ime = null; } super.releaseChildren(destroy); }