Bug 330970 - printing composite with children is not printing properly
Summary: printing composite with children is not printing properly
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact: Carolyn MacLeod CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-23 15:50 EST by Grant Gayed CLA
Modified: 2019-09-06 15:32 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Grant Gayed CLA 2010-11-23 15:50:31 EST
snippet:

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    final Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayout(new GridLayout());
    Button button = new Button(composite, SWT.PUSH);
    button.setText("Print Composite");

    for (int i = 0; i < 9; i++) {
        Composite child = new Composite(composite,SWT.BORDER);
        child.setLayoutData(new GridData(200, SWT.DEFAULT));
        child.setLayout(new GridLayout());
        new Label(child,SWT.NONE).setText("asdf: " + i);
    }

    button.addSelectionListener(new SelectionAdapter () {
        public void widgetSelected(SelectionEvent e) {
            PrintDialog dialog = new PrintDialog(shell, SWT.NONE);
            PrinterData data = dialog.open();
            if (data != null) {
                Printer printer = new Printer(data);
                if (printer.startJob("Print Control")) {
                    if (printer.startPage()) {
                        GC gc = new GC(printer);
                        Point screenDPI = display.getDPI();
                        Point printerDPI = printer.getDPI();
                        float scaleFactor = (float)printerDPI.x / screenDPI.x;
                        Transform transform = new Transform(display, scaleFactor, 0, 0, scaleFactor, 0, 0);
                        transform.translate(200,200);
                        gc.setTransform(transform);
                        composite.print(gc);
                        transform.dispose();
                        gc.dispose();
                        printer.endPage();
                    }
                    printer.endJob();
                }
                printer.dispose();
            }
        }
    });
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
}
Comment 1 Eclipse Webmaster CLA 2019-09-06 15:32:40 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.