1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = 27 * outPack = gtk 28 * outFile = PrintOperationPreviewT 29 * strct = GtkPrintOperationPreview 30 * realStrct= 31 * ctorStrct= 32 * clss = PrintOperationPreviewT 33 * interf = PrintOperationPreviewIF 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * - TStruct 38 * extend = 39 * implements: 40 * prefixes: 41 * - gtk_print_operation_preview_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * - begin-print 47 * - create-custom-widget 48 * - custom-widget-apply 49 * - done 50 * - draw-page 51 * - end-print 52 * - paginate 53 * - preview 54 * - request-page-setup 55 * - status-changed 56 * - update-custom-widget 57 * imports: 58 * - gtk.PageSetup 59 * - gtk.PrintContext 60 * structWrap: 61 * - GtkPageSetup* -> PageSetup 62 * - GtkPrintContext* -> PrintContext 63 * module aliases: 64 * local aliases: 65 * overrides: 66 */ 67 68 module gtk.PrintOperationPreviewT; 69 70 public import gtkc.gtktypes; 71 72 public import gtkc.gtk; 73 public import glib.ConstructionException; 74 public import gobject.ObjectG; 75 76 public import gobject.Signals; 77 public import gtkc.gdktypes; 78 public import gtk.PageSetup; 79 public import gtk.PrintContext; 80 81 82 83 /** 84 * GtkPrintOperation is the high-level, portable printing API. 85 * It looks a bit different than other GTK+ dialogs such as the 86 * GtkFileChooser, since some platforms don't expose enough 87 * infrastructure to implement a good print dialog. On such 88 * platforms, GtkPrintOperation uses the native print dialog. 89 * On platforms which do not provide a native print dialog, GTK+ 90 * uses its own, see GtkPrintUnixDialog. 91 * 92 * The typical way to use the high-level printing API is to create 93 * a GtkPrintOperation object with gtk_print_operation_new() when 94 * the user selects to print. Then you set some properties on it, 95 * e.g. the page size, any GtkPrintSettings from previous print 96 * operations, the number of pages, the current page, etc. 97 * 98 * Then you start the print operation by calling gtk_print_operation_run(). 99 * It will then show a dialog, let the user select a printer and 100 * options. When the user finished the dialog various signals will 101 * be emitted on the GtkPrintOperation, the main one being 102 * "draw-page", which you are supposed to catch 103 * and render the page on the provided GtkPrintContext using Cairo. 104 * 105 * $(DDOC_COMMENT example) 106 * 107 * By default GtkPrintOperation uses an external application to do 108 * print preview. To implement a custom print preview, an application 109 * must connect to the preview signal. The functions 110 * gtk_print_operation_preview_render_page(), 111 * gtk_print_operation_preview_end_preview() and 112 * gtk_print_operation_preview_is_selected() 113 * are useful when implementing a print preview. 114 */ 115 public template PrintOperationPreviewT(TStruct) 116 { 117 118 /** the main Gtk struct */ 119 protected GtkPrintOperationPreview* gtkPrintOperationPreview; 120 121 122 /** Get the main Gtk struct */ 123 public GtkPrintOperationPreview* getPrintOperationPreviewTStruct() 124 { 125 return cast(GtkPrintOperationPreview*)getStruct(); 126 } 127 128 129 /** 130 */ 131 int[string] connectedSignals; 132 133 void delegate(PrintContext, PageSetup, PrintOperationPreviewIF)[] _onGotPageSizeListeners; 134 @property void delegate(PrintContext, PageSetup, PrintOperationPreviewIF)[] onGotPageSizeListeners() 135 { 136 return _onGotPageSizeListeners; 137 } 138 /** 139 * The ::got-page-size signal is emitted once for each page 140 * that gets rendered to the preview. 141 * A handler for this signal should update the context 142 * according to page_setup and set up a suitable cairo 143 * context, using gtk_print_context_set_cairo_context(). 144 */ 145 void addOnGotPageSize(void delegate(PrintContext, PageSetup, PrintOperationPreviewIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 146 { 147 if ( !("got-page-size" in connectedSignals) ) 148 { 149 Signals.connectData( 150 getStruct(), 151 "got-page-size", 152 cast(GCallback)&callBackGotPageSize, 153 cast(void*)cast(PrintOperationPreviewIF)this, 154 null, 155 connectFlags); 156 connectedSignals["got-page-size"] = 1; 157 } 158 _onGotPageSizeListeners ~= dlg; 159 } 160 extern(C) static void callBackGotPageSize(GtkPrintOperationPreview* previewStruct, GtkPrintContext* context, GtkPageSetup* pageSetup, PrintOperationPreviewIF _printOperationPreviewIF) 161 { 162 foreach ( void delegate(PrintContext, PageSetup, PrintOperationPreviewIF) dlg ; _printOperationPreviewIF.onGotPageSizeListeners ) 163 { 164 dlg(ObjectG.getDObject!(PrintContext)(context), ObjectG.getDObject!(PageSetup)(pageSetup), _printOperationPreviewIF); 165 } 166 } 167 168 void delegate(PrintContext, PrintOperationPreviewIF)[] _onReadyListeners; 169 @property void delegate(PrintContext, PrintOperationPreviewIF)[] onReadyListeners() 170 { 171 return _onReadyListeners; 172 } 173 /** 174 * The ::ready signal gets emitted once per preview operation, 175 * before the first page is rendered. 176 * A handler for this signal can be used for setup tasks. 177 * See Also 178 * GtkPrintContext, GtkPrintUnixDialog 179 */ 180 void addOnReady(void delegate(PrintContext, PrintOperationPreviewIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 181 { 182 if ( !("ready" in connectedSignals) ) 183 { 184 Signals.connectData( 185 getStruct(), 186 "ready", 187 cast(GCallback)&callBackReady, 188 cast(void*)cast(PrintOperationPreviewIF)this, 189 null, 190 connectFlags); 191 connectedSignals["ready"] = 1; 192 } 193 _onReadyListeners ~= dlg; 194 } 195 extern(C) static void callBackReady(GtkPrintOperationPreview* previewStruct, GtkPrintContext* context, PrintOperationPreviewIF _printOperationPreviewIF) 196 { 197 foreach ( void delegate(PrintContext, PrintOperationPreviewIF) dlg ; _printOperationPreviewIF.onReadyListeners ) 198 { 199 dlg(ObjectG.getDObject!(PrintContext)(context), _printOperationPreviewIF); 200 } 201 } 202 203 204 /** 205 * Ends a preview. 206 * This function must be called to finish a custom print preview. 207 * Since 2.10 208 */ 209 public void endPreview() 210 { 211 // void gtk_print_operation_preview_end_preview (GtkPrintOperationPreview *preview); 212 gtk_print_operation_preview_end_preview(getPrintOperationPreviewTStruct()); 213 } 214 215 /** 216 * Returns whether the given page is included in the set of pages that 217 * have been selected for printing. 218 * Since 2.10 219 * Params: 220 * pageNr = a page number 221 * Returns: TRUE if the page has been selected for printing 222 */ 223 public int isSelected(int pageNr) 224 { 225 // gboolean gtk_print_operation_preview_is_selected (GtkPrintOperationPreview *preview, gint page_nr); 226 return gtk_print_operation_preview_is_selected(getPrintOperationPreviewTStruct(), pageNr); 227 } 228 229 /** 230 * Renders a page to the preview, using the print context that 231 * was passed to the "preview" handler together 232 * with preview. 233 * A custom iprint preview should use this function in its ::expose 234 * handler to render the currently selected page. 235 * Note that this function requires a suitable cairo context to 236 * be associated with the print context. 237 * Since 2.10 238 * Params: 239 * pageNr = the page to render 240 */ 241 public void renderPage(int pageNr) 242 { 243 // void gtk_print_operation_preview_render_page (GtkPrintOperationPreview *preview, gint page_nr); 244 gtk_print_operation_preview_render_page(getPrintOperationPreviewTStruct(), pageNr); 245 } 246 }