Class PrintPreview
java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Canvas
org.eclipse.nebula.paperclips.widgets.PrintPreview
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class PrintPreview
extends org.eclipse.swt.widgets.Canvas
A WYSIWYG (what you see is what you get) print preview panel. This control
displays a preview of what a PrintJob will look like on paper, depending on
the selected printer.
- Styles:
- (none)
- Events:
- (none)
-
Field Summary
-
Constructor Summary
Constructors Constructor Description PrintPreview(org.eclipse.swt.widgets.Composite parent, int style)
Constructs a PrintPreview control. -
Method Summary
Modifier and Type Method Description org.eclipse.swt.graphics.Point
computeSize(double scale)
Returns the control size needed to display a full page at the given scale.org.eclipse.swt.graphics.Point
computeSize(int wHint, int hHint, boolean changed)
float
getAbsoluteScale()
Calculates the absolute scale that the print preview is displaying at.int
getHorizontalPageCount()
Returns how many pages will be displayed in the horizontal direction.org.eclipse.swt.graphics.Rectangle
getMargins()
Returns a Rectangle whose x, y, width, and height fields respectively indicate the margin at the left, top, right, and bottom edges of the control.int
getPageCount()
Returns the known number of pages in the print job.int
getPageIndex()
Returns the index of the first visible page.org.eclipse.swt.graphics.Point
getPageSpacing()
Returns a Point whose x and y fields respectively indicate the horizontal and vertical spacing between pages on the control.org.eclipse.swt.printing.PrinterData
getPrinterData()
Returns the PrinterData for the printer to preview on.PrintJob
getPrintJob()
Returns the print job.float
getScale()
Returns the view scale.int
getVerticalPageCount()
Returns how many pages will be displayed in the vertical direction.boolean
isFitHorizontal()
Returns whether the page scales to fit the document horizontally.boolean
isFitVertical()
Returns whether the page scales to fit the document vertically.boolean
isLazyPageLayout()
Returns whether the preview lays out pages lazily.boolean
isPageLayoutComplete()
Returns whether all pages have been laid out.void
setFitHorizontal(boolean fitHorizontal)
Sets whether the page scales to fit the document horizontally.void
setFitVertical(boolean fitVertical)
Sets whether the page scales to fit the document vertically.void
setHorizontalPageCount(int horizontalPages)
Sets how many pages will be displayed in the horizontal direction.void
setLazyPageLayout(boolean lazy)
Sets whether the preview lays out pages lazily.void
setMargins(org.eclipse.swt.graphics.Rectangle margins)
Sets the margins at each edge of the control to the argument.void
setPageIndex(int pageIndex)
Sets the index of the first visible page to the argument.void
setPageSpacing(org.eclipse.swt.graphics.Point pageSpacing)
Sets the horizontal and vertical spacing between pages to the argument.void
setPrinterData(org.eclipse.swt.printing.PrinterData printerData)
Sets the PrinterData for the printer to preview on.void
setPrintJob(PrintJob printJob)
Sets the print job to preview.void
setScale(float scale)
Sets the view scale.void
setVerticalPageCount(int verticalPages)
Sets how many pages will be displayed in the vertical direction.void
startBackgroundLayout(java.lang.Runnable callback)
Begins lazy loading in the background, invoking the callback runnable periodically as pages are laid out.Methods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIME
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toString
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData
-
Constructor Details
-
PrintPreview
public PrintPreview(org.eclipse.swt.widgets.Composite parent, int style)Constructs a PrintPreview control.- Parameters:
parent
- the parent control.style
- the control style.
-
-
Method Details
-
getPrintJob
Returns the print job.- Returns:
- the print job.
-
setPrintJob
Sets the print job to preview.- Parameters:
printJob
- the print job to preview.
-
getPrinterData
public org.eclipse.swt.printing.PrinterData getPrinterData()Returns the PrinterData for the printer to preview on.- Returns:
- the PrinterData for the printer to preview on.
-
setPrinterData
public void setPrinterData(org.eclipse.swt.printing.PrinterData printerData)Sets the PrinterData for the printer to preview on.- Parameters:
printerData
- the PrinterData for the printer to preview on.
-
getPageIndex
public int getPageIndex()Returns the index of the first visible page.- Returns:
- the index of the first visible page.
-
setPageIndex
public void setPageIndex(int pageIndex)Sets the index of the first visible page to the argument.- Parameters:
pageIndex
- the page index.
-
getPageCount
public int getPageCount()Returns the known number of pages in the print job. IfsetLazyPageLayout(boolean)
is set to true, this method returns the number of pages laid out so far. This method returns 0 whengetPrintJob()
is null orgetPrinterData()
is null.- Returns:
- the known number of pages in the print job.
-
isPageLayoutComplete
public boolean isPageLayoutComplete()Returns whether all pages have been laid out.- Returns:
- whether all pages have been laid out.
-
isFitHorizontal
public boolean isFitHorizontal()Returns whether the page scales to fit the document horizontally.- Returns:
- whether the page scales to fit the document horizontally.
-
setFitHorizontal
public void setFitHorizontal(boolean fitHorizontal)Sets whether the page scales to fit the document horizontally.- Parameters:
fitHorizontal
- whether the page scales to fit the document horizontally.
-
isFitVertical
public boolean isFitVertical()Returns whether the page scales to fit the document vertically.- Returns:
- whether the page scales to fit the document vertically.
-
setFitVertical
public void setFitVertical(boolean fitVertical)Sets whether the page scales to fit the document vertically.- Parameters:
fitVertical
- whether the page scales to fit the document vertically.
-
getScale
public float getScale()Returns the view scale. The document displays at this scale when !(isFitHorizontal() || isFitVertical()).- Returns:
- the view scale.
-
setScale
public void setScale(float scale)Sets the view scale.- Parameters:
scale
- the view scale. A scale of 1.0 causes the document to appear at full size on the computer screen.
-
getHorizontalPageCount
public int getHorizontalPageCount()Returns how many pages will be displayed in the horizontal direction.THIS API IS EXPERIMENTAL AND MAY BE REMOVED OR CHANGED IN THE FUTURE.
- Returns:
- how many pages will be displayed in the horizontal direction.
-
setHorizontalPageCount
public void setHorizontalPageCount(int horizontalPages)Sets how many pages will be displayed in the horizontal direction.THIS API IS EXPERIMENTAL AND MAY BE REMOVED OR CHANGED IN THE FUTURE.
- Parameters:
horizontalPages
- how many pages will be displayed in the horizontal direction.
-
getVerticalPageCount
public int getVerticalPageCount()Returns how many pages will be displayed in the vertical direction.THIS API IS EXPERIMENTAL AND MAY BE REMOVED OR CHANGED IN THE FUTURE.
- Returns:
- how many pages will be displayed in the vertical direction.
-
setVerticalPageCount
public void setVerticalPageCount(int verticalPages)Sets how many pages will be displayed in the vertical direction.THIS API IS EXPERIMENTAL AND MAY BE REMOVED OR CHANGED IN THE FUTURE.
- Parameters:
verticalPages
- how many pages will be displayed in the vertical direction.
-
isLazyPageLayout
public boolean isLazyPageLayout()Returns whether the preview lays out pages lazily. Note that total page counts in page numbers will not display correctly when this is enabled.- Returns:
- whether the preview lays out pages lazily.
-
setLazyPageLayout
public void setLazyPageLayout(boolean lazy)Sets whether the preview lays out pages lazily. Note that total page counts in page numbers will not display correctly when this is enabled.- Parameters:
lazy
- whether the preview lays out pages lazily.
-
startBackgroundLayout
public void startBackgroundLayout(java.lang.Runnable callback)Begins lazy loading in the background, invoking the callback runnable periodically as pages are laid out.NOTE: This API is experimental and subject to change.
- Parameters:
callback
- runnable that will be invoked periodically as pages are laid out.
-
getAbsoluteScale
public float getAbsoluteScale()Calculates the absolute scale that the print preview is displaying at. If either of the fitHorizontal or fitVertical properties are true, this is the scale allows the page to fit within this control's current bounds. Otherwise the value of the scale property is returned.- Returns:
- the absolute scale that the print preview is displaying at.
-
getMargins
public org.eclipse.swt.graphics.Rectangle getMargins()Returns a Rectangle whose x, y, width, and height fields respectively indicate the margin at the left, top, right, and bottom edges of the control.THIS API IS EXPERIMENTAL AND MAY BE REMOVED OR CHANGED IN THE FUTURE.
- Returns:
- a Rectangle whose x, y, width, and height fields respectively indicate the margin at the left, top, right, and bottom edges of the control.
-
setMargins
public void setMargins(org.eclipse.swt.graphics.Rectangle margins)Sets the margins at each edge of the control to the argument.THIS API IS EXPERIMENTAL AND MAY BE REMOVED OR CHANGED IN THE FUTURE.
- Parameters:
margins
- a Rectangle whose x, y, width, and height fields respectively indicate the margin at the left, top, right, and bottom edges of the control.
-
getPageSpacing
public org.eclipse.swt.graphics.Point getPageSpacing()Returns a Point whose x and y fields respectively indicate the horizontal and vertical spacing between pages on the control.THIS API IS EXPERIMENTAL AND MAY BE REMOVED OR CHANGED IN THE FUTURE.
- Returns:
- a Point whose x and y fields respectively indicate the horizontal and vertical spacing between pages on the control.
-
setPageSpacing
public void setPageSpacing(org.eclipse.swt.graphics.Point pageSpacing)Sets the horizontal and vertical spacing between pages to the argument.THIS API IS EXPERIMENTAL AND MAY BE REMOVED OR CHANGED IN THE FUTURE.
- Parameters:
pageSpacing
- a Point whose x and y fields respectively indicate the horizontal and vertical spacing between pages on the control.
-
computeSize
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)- Overrides:
computeSize
in classorg.eclipse.swt.widgets.Control
-
computeSize
public org.eclipse.swt.graphics.Point computeSize(double scale)Returns the control size needed to display a full page at the given scale.- Parameters:
scale
- the absolute scale. A scale of 1, for example, yields a "life size" preview.- Returns:
- the control size needed to display a full page at the given scale.
-