/** * Print header or footer decorations. * * @param page page number to print, if specified in the StyledTextPrintOptions header or footer. * @param header true = print the header, false = print the footer */ void printDecoration(int page, boolean header, TextLayout layout) { String text = header ? printOptions.header : printOptions.footer; if (text == null) return; int lastSegmentIndex = 0; for (int i = 0; i < 3; i++) { int segmentIndex = text.indexOf(StyledTextPrintOptions.SEPARATOR, lastSegmentIndex); String segment; if (segmentIndex == -1) { segment = text.substring(lastSegmentIndex); printDecorationSegment(segment, i, page, header, layout); break; } else { segment = text.substring(lastSegmentIndex, segmentIndex); printDecorationSegment(segment, i, page, header, layout); lastSegmentIndex = segmentIndex + StyledTextPrintOptions.SEPARATOR.length(); } } } /**
if (paintY == clientArea.y) { printer.startPage(); printDecoration(page, true, printLayout); printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); paintY = paragraphBottom; } else { printDecoration(page, false, printLayout); printer.endPage(); page++; if (page <= endPage) { printer.startPage(); printDecoration(page, true, printLayout); paintY = clientArea.y; printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); paintY += layout.getBounds().height; printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); gc.setClipping((Rectangle)null); printDecoration(page, false, printLayout); printer.endPage(); page++; if (page <= endPage) { printer.startPage(); printDecoration(page, true, printLayout); paintY = clientArea.y - height; int layoutHeight = layout.getBounds().height; gc.setClipping(clientArea.x, clientArea.y, clientArea.width, layoutHeight - height);
if (paintY == clientArea.y) { printer.startPage(); printDecoration(page, true, printLayout); printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); paintY = paragraphBottom; } else { printDecoration(page, false, printLayout); printer.endPage(); page++; if (page <= endPage) { printer.startPage(); printDecoration(page, true, printLayout); paintY = clientArea.y; printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); paintY += layout.getBounds().height; printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); gc.setClipping((Rectangle)null); printDecoration(page, false, printLayout); printer.endPage(); page++; if (page <= endPage) { printer.startPage(); printDecoration(page, true, printLayout); paintY = clientArea.y - height; int layoutHeight = layout.getBounds().height; gc.setClipping(clientArea.x, clientArea.y, clientArea.width, layoutHeight - height);
if (paintY == clientArea.y) { printer.startPage(); printDecoration(page, true, printLayout); printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); paintY = paragraphBottom; } else { printDecoration(page, false, printLayout); printer.endPage(); page++; if (page <= endPage) { printer.startPage(); printDecoration(page, true, printLayout); paintY = clientArea.y; printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); paintY += layout.getBounds().height; printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); gc.setClipping((Rectangle)null); printDecoration(page, false, printLayout); printer.endPage(); page++; if (page <= endPage) { printer.startPage(); printDecoration(page, true, printLayout); paintY = clientArea.y - height; int layoutHeight = layout.getBounds().height; gc.setClipping(clientArea.x, clientArea.y, clientArea.width, layoutHeight - height);
if (paintY == clientArea.y) { printer.startPage(); printDecoration(page, true, printLayout); printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); paintY = paragraphBottom; } else { printDecoration(page, false, printLayout); printer.endPage(); page++; if (page <= endPage) { printer.startPage(); printDecoration(page, true, printLayout); paintY = clientArea.y; printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); paintY += layout.getBounds().height; printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); gc.setClipping((Rectangle)null); printDecoration(page, false, printLayout); printer.endPage(); page++; if (page <= endPage) { printer.startPage(); printDecoration(page, true, printLayout); paintY = clientArea.y - height; int layoutHeight = layout.getBounds().height; gc.setClipping(clientArea.x, clientArea.y, clientArea.width, layoutHeight - height);
if (paintY == clientArea.y) { printer.startPage(); printDecoration(page, true, printLayout); printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); paintY = paragraphBottom; } else { printDecoration(page, false, printLayout); printer.endPage(); page++; if (page <= endPage) { printer.startPage(); printDecoration(page, true, printLayout); paintY = clientArea.y; printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); paintY += layout.getBounds().height; printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i); gc.setClipping((Rectangle)null); printDecoration(page, false, printLayout); printer.endPage(); page++; if (page <= endPage) { printer.startPage(); printDecoration(page, true, printLayout); paintY = clientArea.y - height; int layoutHeight = layout.getBounds().height; gc.setClipping(clientArea.x, clientArea.y, clientArea.width, layoutHeight - height);
printerRenderer.setContent(copyContent(styledText.getContent())); cacheLineData(styledText);
printerRenderer.setContent(copyContent(styledText.getContent())); cacheLineData(styledText);
printerRenderer.setContent(copyContent(styledText.getContent())); cacheLineData(styledText);
printerRenderer.setContent(copyContent(styledText.getContent())); cacheLineData(styledText);
printerRenderer.setContent(copyContent(styledText.getContent())); cacheLineData(styledText);
/** * Returns a runnable that will print the widget's text * to the specified printer. * <p> * The runnable may be run in a non-UI thread. * </p> * * @param printer the printer to print to * @param options print options to use during printing * * @return a <code>Runnable</code> for printing the receiver's text * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT when printer or options is null</li> * </ul> * @since 2.1 */ public Runnable print(Printer printer, StyledTextPrintOptions options) { checkWidget(); if (printer == null || options == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); } return new Printing(this, printer, options); } /**
/** * Returns a runnable that will print the widget's text * to the specified printer. * <p> * The runnable may be run in a non-UI thread. * </p> * * @param printer the printer to print to * @param options print options to use during printing * * @return a <code>Runnable</code> for printing the receiver's text * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT when printer or options is null</li> * </ul> * @since 2.1 */ public Runnable print(Printer printer, StyledTextPrintOptions options) { checkWidget(); if (printer == null || options == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); } return new Printing(this, printer, options); } /**
/** * Returns a runnable that will print the widget's text * to the specified printer. * <p> * The runnable may be run in a non-UI thread. * </p> * * @param printer the printer to print to * @param options print options to use during printing * * @return a <code>Runnable</code> for printing the receiver's text * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT when printer or options is null</li> * </ul> * @since 2.1 */ public Runnable print(Printer printer, StyledTextPrintOptions options) { checkWidget(); if (printer == null || options == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); } return new Printing(this, printer, options); } /**
/** * Returns a runnable that will print the widget's text * to the specified printer. * <p> * The runnable may be run in a non-UI thread. * </p> * * @param printer the printer to print to * @param options print options to use during printing * * @return a <code>Runnable</code> for printing the receiver's text * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT when printer or options is null</li> * </ul> * @since 2.1 */ public Runnable print(Printer printer, StyledTextPrintOptions options) { checkWidget(); if (printer == null || options == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); } return new Printing(this, printer, options); } /**
/** * Returns a runnable that will print the widget's text * to the specified printer. * <p> * The runnable may be run in a non-UI thread. * </p> * * @param printer the printer to print to * @param options print options to use during printing * * @return a <code>Runnable</code> for printing the receiver's text * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT when printer or options is null</li> * </ul> * @since 2.1 */ public Runnable print(Printer printer, StyledTextPrintOptions options) { checkWidget(); if (printer == null || options == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); } return new Printing(this, printer, options); } /**
/** * Print header or footer decorations. * * @param page page number to print, if specified in the StyledTextPrintOptions header or footer. * @param header true = print the header, false = print the footer */ void printDecoration(int page, boolean header, TextLayout layout) { String text = header ? printOptions.header : printOptions.footer; if (text == null) return; int lastSegmentIndex = 0; for (int i = 0; i < 3; i++) { int segmentIndex = text.indexOf(StyledTextPrintOptions.SEPARATOR, lastSegmentIndex); String segment; if (segmentIndex == -1) { segment = text.substring(lastSegmentIndex); printDecorationSegment(segment, i, page, header, layout); break; } else { segment = text.substring(lastSegmentIndex, segmentIndex); printDecorationSegment(segment, i, page, header, layout); lastSegmentIndex = segmentIndex + StyledTextPrintOptions.SEPARATOR.length(); } } } /**
/** * Print header or footer decorations. * * @param page page number to print, if specified in the StyledTextPrintOptions header or footer. * @param header true = print the header, false = print the footer */ void printDecoration(int page, boolean header, TextLayout layout) { String text = header ? printOptions.header : printOptions.footer; if (text == null) return; int lastSegmentIndex = 0; for (int i = 0; i < 3; i++) { int segmentIndex = text.indexOf(StyledTextPrintOptions.SEPARATOR, lastSegmentIndex); String segment; if (segmentIndex == -1) { segment = text.substring(lastSegmentIndex); printDecorationSegment(segment, i, page, header, layout); break; } else { segment = text.substring(lastSegmentIndex, segmentIndex); printDecorationSegment(segment, i, page, header, layout); lastSegmentIndex = segmentIndex + StyledTextPrintOptions.SEPARATOR.length(); } } } /**
/** * Print header or footer decorations. * * @param page page number to print, if specified in the StyledTextPrintOptions header or footer. * @param header true = print the header, false = print the footer */ void printDecoration(int page, boolean header, TextLayout layout) { String text = header ? printOptions.header : printOptions.footer; if (text == null) return; int lastSegmentIndex = 0; for (int i = 0; i < 3; i++) { int segmentIndex = text.indexOf(StyledTextPrintOptions.SEPARATOR, lastSegmentIndex); String segment; if (segmentIndex == -1) { segment = text.substring(lastSegmentIndex); printDecorationSegment(segment, i, page, header, layout); break; } else { segment = text.substring(lastSegmentIndex, segmentIndex); printDecorationSegment(segment, i, page, header, layout); lastSegmentIndex = segmentIndex + StyledTextPrintOptions.SEPARATOR.length(); } } } /**
/** * Print header or footer decorations. * * @param page page number to print, if specified in the StyledTextPrintOptions header or footer. * @param header true = print the header, false = print the footer */ void printDecoration(int page, boolean header, TextLayout layout) { String text = header ? printOptions.header : printOptions.footer; if (text == null) return; int lastSegmentIndex = 0; for (int i = 0; i < 3; i++) { int segmentIndex = text.indexOf(StyledTextPrintOptions.SEPARATOR, lastSegmentIndex); String segment; if (segmentIndex == -1) { segment = text.substring(lastSegmentIndex); printDecorationSegment(segment, i, page, header, layout); break; } else { segment = text.substring(lastSegmentIndex, segmentIndex); printDecorationSegment(segment, i, page, header, layout); lastSegmentIndex = segmentIndex + StyledTextPrintOptions.SEPARATOR.length(); } } } /**