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 9622 Details for
Bug 24796
DCR - No printing on Linux GTK
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
SWT snippet patched to involve printing multi page documents
Main.java (text/x-java), 3.58 KB, created by
christophe dufaza
on 2004-04-17 15:20:22 EDT
(
hide
)
Description:
SWT snippet patched to involve printing multi page documents
Filename:
MIME Type:
Creator:
christophe dufaza
Created:
2004-04-17 15:20:22 EDT
Size:
3.58 KB
patch
obsolete
>/* > * Copyright (c) 2000, 2003 IBM Corp. All rights reserved. > * This file is made available under the terms of the Common Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/cpl-v10.html > */ > >/* modified to test both single/ multi page document print > */ > >/* > * Printing example snippet: print "Hello World!" in black, outlined in red, to default printer > * > * For a list of all SWT example snippets see > * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets > */ >import org.eclipse.swt.*; >import org.eclipse.swt.widgets.*; >import org.eclipse.swt.graphics.*; >import org.eclipse.swt.printing.*; > >public class Main { > >public static void main (String [] args) { > Display display = new Display(); > Shell shell = new Shell(display); > shell.open (); > PrinterData data = Printer.getDefaultPrinterData(); > if (data == null) { > System.out.println("Warning: No default printer."); > return; > } > > System.out.println(Printer.getPrinterList()); > Printer printer = new Printer(data); > > if (printer.startJob("SWT Printing Snippet")) { > Color black = printer.getSystemColor(SWT.COLOR_BLACK); > Color white = printer.getSystemColor(SWT.COLOR_WHITE); > Color red = printer.getSystemColor(SWT.COLOR_RED); > Rectangle trim = printer.computeTrim(0, 0, 0, 0); > Point dpi = printer.getDPI(); > int leftMargin = dpi.x + trim.x; // one inch from left side of paper > int topMargin = dpi.y / 2 + trim.y; // one-half inch from top edge of paper > GC gc = new GC(printer); > Font font = gc.getFont(); // example just uses printer's default font > if (printer.startPage()) { > gc.setBackground(white); > gc.setForeground(black); > String testString = "Hello World!"; > Point extent = gc.stringExtent(testString); > gc.drawString(testString, leftMargin, topMargin + font.getFontData()[0].getHeight()); > gc.setForeground(red); > gc.drawRectangle(leftMargin, topMargin, extent.x, extent.y); > printer.endPage(); > } > gc.dispose(); > printer.endJob(); > } > > if (printer.startJob("SWT Printing Snippet2")) { > Color black = printer.getSystemColor(SWT.COLOR_BLACK); > Color white = printer.getSystemColor(SWT.COLOR_WHITE); > Color red = printer.getSystemColor(SWT.COLOR_RED); > Rectangle trim = printer.computeTrim(0, 0, 0, 0); > Point dpi = printer.getDPI(); > int leftMargin = dpi.x + trim.x; // one inch from left side of paper > int topMargin = dpi.y / 2 + trim.y; // one-half inch from top edge of paper > GC gc = new GC(printer); > Font font = gc.getFont(); // example just uses printer's default font > if (printer.startPage()) { > gc.setBackground(white); > gc.setForeground(black); > String testString = "Hello World! 1/2"; > Point extent = gc.stringExtent(testString); > // System.out.println("Extent: " + extent.x + "," + extent.y); > gc.drawString(testString, leftMargin, topMargin + font.getFontData()[0].getHeight()); > gc.setForeground(red); > gc.drawRectangle(leftMargin, topMargin, extent.x, extent.y); > printer.endPage(); > } > if (printer.startPage()) { > gc.setBackground(white); > gc.setForeground(black); > String testString = "Hello World! 2/2"; > Point extent = gc.stringExtent(testString); > // System.out.println("Extent: " + extent.x + "," + extent.y); > gc.drawString(testString, leftMargin, topMargin + font.getFontData()[0].getHeight()); > gc.setForeground(red); > gc.drawRectangle(leftMargin, topMargin, extent.x, extent.y); > printer.endPage(); > } > gc.dispose(); > printer.endJob(); > } > > printer.dispose(); > 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 24796
:
9621
|
9622
|
9687
|
30663
|
41817