Java Code Examples for org.eclipse.swt.widgets.Composite#getSize()
The following examples show how to use
org.eclipse.swt.widgets.Composite#getSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChartPrintJob.java From openstock with GNU General Public License v3.0 | 6 votes |
private void printComposite(Composite elementToPrint, GC gc, Rectangle printArea) { Image image = new Image(elementToPrint.getDisplay(), elementToPrint.getSize().x, elementToPrint.getSize().y); try { GC imageGC = new GC(image); try { elementToPrint.print(imageGC); Point fittedSize = calcFittedSize(printArea, elementToPrint.getSize()); gc.drawImage(image, 0, 0, elementToPrint.getSize().x, elementToPrint.getSize().y, printArea.x, printArea.y, fittedSize.x, fittedSize.y); } finally { imageGC.dispose(); } } finally { image.dispose(); } }
Example 2
Source File: HeaderLayout.java From nebula with Eclipse Public License 2.0 | 6 votes |
protected void layout(final Composite child, boolean flushCache) { storeHeader(child); int childWidth = child.getSize().x; int shellWidth = child.getShell().getSize().x; if (childWidth == lastChildWidth && shellWidth > lastShellWidth) return; if (childWidth > lastChildWidth) { final Table headerTable = getHeader(child).headerTable; headerTable.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { headerTable.removePaintListener(this); layout(child); } }); } else { layout(child); } lastChildWidth = childWidth; lastShellWidth = shellWidth; }
Example 3
Source File: ChartPrintJob.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
private void printComposite(Composite elementToPrint, GC gc, Rectangle printArea) { Image image = new Image(elementToPrint.getDisplay(), elementToPrint.getSize().x, elementToPrint.getSize().y); try { GC imageGC = new GC(image); try { elementToPrint.print(imageGC); Point fittedSize = calcFittedSize(printArea, elementToPrint.getSize()); gc.drawImage(image, 0, 0, elementToPrint.getSize().x, elementToPrint.getSize().y, printArea.x, printArea.y, fittedSize.x, fittedSize.y); } finally { imageGC.dispose(); } } finally { image.dispose(); } }
Example 4
Source File: ChartPrintJob.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
private void printComposite(Composite elementToPrint, GC gc, Rectangle printArea) { Image image = new Image(elementToPrint.getDisplay(), elementToPrint.getSize().x, elementToPrint.getSize().y); try { GC imageGC = new GC(image); try { elementToPrint.print(imageGC); Point fittedSize = calcFittedSize(printArea, elementToPrint.getSize()); gc.drawImage(image, 0, 0, elementToPrint.getSize().x, elementToPrint.getSize().y, printArea.x, printArea.y, fittedSize.x, fittedSize.y); } finally { imageGC.dispose(); } } finally { image.dispose(); } }
Example 5
Source File: DecisionTableGridPaintListener.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public void paintControl(final PaintEvent event) { Composite composite = (Composite) event.widget; Point size = composite.getSize(); List<List<Control>> controls = getChildrenByRow(composite); int i = 0; for (List<Control> line : controls) { if(selectedRowIndex != -1 && controls.indexOf(line) == selectedRowIndex+1){ event.gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION)); }else{ event.gc.setBackground(COLORS[i]); } for (Control control : line) { if(controls.indexOf(line) == 0){ event.gc.fillRectangle(new Rectangle(0, 0, size.x, size.y)); }else{ event.gc.fillRectangle(new Rectangle(0, control.getLocation().y-3, size.x, size.y-3)); } } i = (i + 1) % 2; } }
Example 6
Source File: ChartPrintJob.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
private void printComposite(Composite elementToPrint, GC gc, Rectangle printArea) { Image image = new Image(elementToPrint.getDisplay(), elementToPrint.getSize().x, elementToPrint.getSize().y); try { GC imageGC = new GC(image); try { elementToPrint.print(imageGC); Point fittedSize = calcFittedSize(printArea, elementToPrint.getSize()); gc.drawImage(image, 0, 0, elementToPrint.getSize().x, elementToPrint.getSize().y, printArea.x, printArea.y, fittedSize.x, fittedSize.y); } finally { imageGC.dispose(); } } finally { image.dispose(); } }
Example 7
Source File: ChartPrintJob.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
private void printComposite(Composite elementToPrint, GC gc, Rectangle printArea) { Image image = new Image(elementToPrint.getDisplay(), elementToPrint.getSize().x, elementToPrint.getSize().y); try { GC imageGC = new GC(image); try { elementToPrint.print(imageGC); Point fittedSize = calcFittedSize(printArea, elementToPrint.getSize()); gc.drawImage(image, 0, 0, elementToPrint.getSize().x, elementToPrint.getSize().y, printArea.x, printArea.y, fittedSize.x, fittedSize.y); } finally { imageGC.dispose(); } } finally { image.dispose(); } }
Example 8
Source File: TimeSlice.java From nebula with Eclipse Public License 2.0 | 5 votes |
protected void layout(Composite composite, boolean flushCache) { Point parentSize = composite.getSize(); Control[] children = composite.getChildren(); // layout 0th control Integer preferredWidth = (Integer) children[0].getLayoutData(); if (preferredWidth == null) { preferredWidth = new Integer(children[0].computeSize( SWT.DEFAULT, SWT.DEFAULT).x); } children[0].setBounds(0, 0, preferredWidth.intValue(), parentSize.y); // layout the rest of the controls int controlWidth = 0; int extraWidth = 0; if (children.length >= 2) { controlWidth = (parentSize.x - preferredWidth.intValue()) / (children.length - 1); extraWidth = (parentSize.x - preferredWidth.intValue()) % (children.length - 1); } int leftPosition = preferredWidth.intValue(); for (int i = 1; i < children.length; i++) { Control control = children[i]; int width = controlWidth; if (extraWidth > 0) { ++width; --extraWidth; } control.setBounds(leftPosition, 0, width, parentSize.y); leftPosition += width; } }
Example 9
Source File: RelationDialog.java From ermaster-b with Apache License 2.0 | 5 votes |
private int createParentGroup(Composite composite) { GridLayout gridLayout = new GridLayout(); gridLayout.verticalSpacing = 10; gridLayout.marginHeight = 10; GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; Group group = new Group(composite, SWT.NONE); group.setLayoutData(gridData); group.setLayout(gridLayout); group.setText(ResourceString.getResourceString("label.parent")); Composite upperComposite = new Composite(group, SWT.NONE); upperComposite.setLayoutData(gridData); upperComposite.setLayout(gridLayout); Label label1 = new Label(upperComposite, SWT.NONE); label1.setText(ResourceString .getResourceString("label.reference.table")); parentTableNameText = new Text(upperComposite, SWT.BORDER | SWT.READ_ONLY); parentTableNameText.setLayoutData(gridData); Label label2 = new Label(upperComposite, SWT.NONE); label2.setText(ResourceString .getResourceString("label.reference.column")); this.createColumnCombo(upperComposite); this.createParentMandatoryGroup(group); upperComposite.pack(); return upperComposite.getSize().y; }
Example 10
Source File: ExtnlResBindSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
@Override public void initialize(IManagedForm form) { super.initialize(form); // set up Composite to hold widgets in the section sectionClient = new2ColumnComposite(getSection()); tree = newTree(sectionClient); // Buttons Composite buttonContainer = newButtonContainer(sectionClient); addButton = newPushButton(buttonContainer, S_ADD, "Click to add a new External Resource definition"); editButton = newPushButton(buttonContainer, S_EDIT, "Click to edit an External Resource definition"); removeButton = newPushButton(buttonContainer, "Remove", "Click to remove selected binding or External Resource"); bindButton = newPushButton(buttonContainer, "Bind", "Click to bind selected dependency with selected Resource"); exportButton = newPushButton(buttonContainer, S_EXPORT, S_EXPORT_TIP); buttonContainer.pack(); getSection().getParent().getParent().pack(); getSection().getParent().getParent().layout(); initialFormWidth = getSection().getSize().x; ((GridData) tree.getLayoutData()).widthHint = initialFormWidth - buttonContainer.getSize().x; enableBorders(sectionClient); toolkit.paintBordersFor(sectionClient); tree.addListener(SWT.MouseDoubleClick, this); }
Example 11
Source File: DataWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void handleValueChange(final ValueChangeEvent event) { final DataType newType = (DataType) event.diff.getNewValue(); if (newType instanceof JavaType && !(data instanceof JavaObjectData)) { final JavaObjectData javaData = ProcessFactory.eINSTANCE.createJavaObjectData(); javaData.setDataType(newType); javaData.setClassName(List.class.getName()); copyDataFeature(javaData); data = javaData; updateDatabinding(); } else if (newType instanceof XMLType && !(data instanceof XMLData)) { final XMLData xmlData = ProcessFactory.eINSTANCE.createXMLData(); xmlData.setDataType(newType); copyDataFeature(xmlData); data = xmlData; } else { if (!data.eClass().equals(ProcessPackage.Literals.DATA)) { Data simpleData = ProcessFactory.eINSTANCE.createData(); simpleData.setDataType(newType); copyDataFeature(simpleData); data = simpleData; } else { data.setDataType(newType); } } updateMoreSection(newType); updateBrowseXMLButton(newType); if (mainComposite != null && !mainComposite.isDisposed()) { final Composite parent = mainComposite.getParent(); final Point defaultSize = parent.getSize(); final Point size = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); parent.setSize(defaultSize.x, size.y); parent.layout(true, true); } updateDatabinding(); }
Example 12
Source File: WizardPageOperationsComposite.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void refresh() { final Composite shell = parent.getShell(); final Point compositesize = parent.getSize(); final Point newcompositesize = computeSize(SWT.DEFAULT, SWT.DEFAULT, true); final Point defaultSize = shell.getSize(); final Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); if (compositesize.x < newcompositesize.x) { shell.setSize(size.x, defaultSize.y); } shell.layout(true, true); if (parent.getParent() instanceof ScrolledComposite) { final ScrolledComposite scrolledComposite = (ScrolledComposite) parent.getParent(); scrolledComposite.setMinSize(computeSize(SWT.DEFAULT, SWT.DEFAULT)); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { scrolledComposite.getVerticalBar().setSelection(scrolledComposite.getVerticalBar().getMaximum()); } }); } if (tabbedPropertySheetPage != null) { tabbedPropertySheetPage.resizeScrolledComposite(); } }
Example 13
Source File: UIUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Notice: Please dispose the image after done. * * @param composite * @return */ public static Image newImageFromComposite( Composite composite ) { Point compositeSize = composite.getSize( ); GC gc = new GC( composite ); Image image = new Image( Display.getCurrent( ), compositeSize.x, compositeSize.y ); gc.copyArea( image, 0, 0 ); gc.dispose( ); return image; }
Example 14
Source File: RelationshipDialog.java From erflute with Apache License 2.0 | 5 votes |
private int createParentGroup(Composite composite) { final GridLayout gridLayout = new GridLayout(); gridLayout.verticalSpacing = 10; gridLayout.marginHeight = 10; final GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; final Group group = new Group(composite, SWT.NONE); group.setLayoutData(gridData); group.setLayout(gridLayout); group.setText(DisplayMessages.getMessage("label.parent")); final Composite upperComposite = new Composite(group, SWT.NONE); upperComposite.setLayoutData(gridData); upperComposite.setLayout(gridLayout); final Label label1 = new Label(upperComposite, SWT.NONE); label1.setText(DisplayMessages.getMessage("label.reference.table")); parentTableNameText = new Text(upperComposite, SWT.BORDER | SWT.READ_ONLY); parentTableNameText.setLayoutData(gridData); final Label label2 = new Label(upperComposite, SWT.NONE); label2.setText("Referred Column"); createColumnCombo(upperComposite); createParentMandatoryGroup(group); upperComposite.pack(); return upperComposite.getSize().y; }
Example 15
Source File: TLACoverageEditor.java From tlaplus with MIT License | 5 votes |
@Override public void handleEvent(final Event event) { final Widget widget = event.widget; if (widget instanceof Composite) { final Composite c = (Composite) widget; size.x = c.getSize().x; size.y = c.getSize().y; } }
Example 16
Source File: RelationDialog.java From ermasterr with Apache License 2.0 | 5 votes |
private int createParentGroup(final Composite composite) { final GridLayout gridLayout = new GridLayout(); gridLayout.verticalSpacing = 10; gridLayout.marginHeight = 10; final GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; final Group group = new Group(composite, SWT.NONE); group.setLayoutData(gridData); group.setLayout(gridLayout); group.setText(ResourceString.getResourceString("label.parent")); final Composite upperComposite = new Composite(group, SWT.NONE); upperComposite.setLayoutData(gridData); upperComposite.setLayout(gridLayout); final Label label1 = new Label(upperComposite, SWT.NONE); label1.setText(ResourceString.getResourceString("label.reference.table")); parentTableNameText = new Text(upperComposite, SWT.BORDER | SWT.READ_ONLY); parentTableNameText.setLayoutData(gridData); final Label label2 = new Label(upperComposite, SWT.NONE); label2.setText(ResourceString.getResourceString("label.reference.column")); createColumnCombo(upperComposite); createParentMandatoryGroup(group); upperComposite.pack(); return upperComposite.getSize().y; }
Example 17
Source File: ViewFreezer.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public void freeze() { release(); if (sourceViewer instanceof SourceViewer) { Control viewerControl = ((SourceViewer) sourceViewer).getControl(); if (viewerControl instanceof Composite) { Composite composite = (Composite) viewerControl; Display display = composite.getDisplay(); // Flush pending redraw requests: while (!display.isDisposed() && display.readAndDispatch()) { } // Copy editor area: GC gc = new GC(composite); Point size; try { size = composite.getSize(); image = new Image(gc.getDevice(), size.x, size.y); gc.copyArea(image, 0, 0); } finally { gc.dispose(); gc = null; } // Persist editor area while executing refactoring: label = new Label(composite, SWT.NONE); label.setImage(image); label.setBounds(0, 0, size.x, size.y); label.moveAbove(null); } } }
Example 18
Source File: ScrollView.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
@Override protected void layout(Composite composite, boolean flushCache) { if (dontLayout) { return; } seek++; if (seek > MAX_SEEK) { dontLayout = true; } Point cs = composite.getSize(); int barVis = computeBarVisibility(cs.x, cs.y, false, false); boolean vbVis = (barVis & VBAR) != 0; boolean hbVis = (barVis & HBAR) != 0; fVertScrollBar.setVisible(vbVis); fHorScrollBar.setVisible(hbVis); int vbw = getVerticalBarWidth(); int hbh = getHorizontalBarHeight(); int wb = vbVis ? vbw : 0; int hb = hbVis ? hbh : 0; int cww = 0, cwh = 0; if (fCornerControl != null && (vbVis || hbVis)) { // corner_control_.getVisible()) fCornerControl.setVisible(true); cww = vbw; cwh = hbh; if (wb == 0) { wb = vbw; } if (hb == 0) { hb = hbh; } } else if (vbVis && hbVis) { if (fCornerControl != null) { fCornerControl.setVisible(false); } cww = vbw; cwh = hbh; } if (vbVis || hbVis) { updateScrollBarsValues(); } int vw = cs.x - (vbVis ? vbw : 0); int vh = cs.y - (hbVis ? hbh : 0); int vbx = cs.x - wb; int hby = cs.y - hb; fViewControl.setBounds(0, 0, vw, vh); if (vbVis) { fVertScrollBar.setBounds(vbx, 0, wb, cs.y - cwh); } if (hbVis) { fHorScrollBar.setBounds(0, hby, cs.x - cww, hb); } if (fCornerControl != null && fCornerControl.getVisible()) { fCornerControl.setBounds(vbx, hby, vbw, hbh); } updateScrollBarsValues(); seek--; if (seek == MIN_SEEK) { dontLayout = false; } }
Example 19
Source File: MultiChoice.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * Create the popup that contains all checkboxes */ private void createPopup() { this.popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP); this.popup.setLayout(new FillLayout()); final int[] popupEvents = { SWT.Close, SWT.Deactivate, SWT.Dispose }; for (final int popupEvent : popupEvents) { this.popup.addListener(popupEvent, this.listener); } if (this.elements == null) { return; } this.scrolledComposite = new ScrolledComposite(this.popup, SWT.BORDER | SWT.V_SCROLL); final Composite content = new Composite(this.scrolledComposite, SWT.NONE); content.setLayout(new GridLayout(this.numberOfColumns, true)); this.checkboxes = new ArrayList<>(this.elements.size()); for (final T o : this.elements) { final Button checkBoxButton = new Button(content, SWT.CHECK); if (this.font != null) { checkBoxButton.setFont(this.font); } if (this.foreground != null) { checkBoxButton.setForeground(this.foreground); } if (this.background != null) { checkBoxButton.setBackground(this.background); } checkBoxButton.setEnabled(text.getEditable()); checkBoxButton.setData(o); checkBoxButton.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false)); checkBoxButton.setText(this.labelProvider.getText(o)); checkBoxButton.addListener(SWT.Selection, e -> { if (checkBoxButton.getSelection()) { MultiChoice.this.selection.add(o); } else { MultiChoice.this.selection.remove(o); } MultiChoice.this.lastModified = o; setLabel(); }); if (this.selectionListener != null) { checkBoxButton.addSelectionListener(this.selectionListener); } checkBoxButton.setSelection(this.selection.contains(o)); this.checkboxes.add(checkBoxButton); } this.scrolledComposite.setContent(content); this.scrolledComposite.setExpandHorizontal(false); this.scrolledComposite.setExpandVertical(true); content.pack(); this.preferredHeightOfPopup = content.getSize().y; }