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 * imports: 57 * - gtk.Widget 58 * - gtk.PageSetup 59 * - gtk.PrintSettings 60 * structWrap: 61 * - GtkPageSetup* -> PageSetup 62 * - GtkPrintSettings* -> PrintSettings 63 * - GtkWidget* -> Widget 64 * module aliases: 65 * local aliases: 66 * overrides: 67 */ 68 69 module gtk.PrintOperationPreviewT; 70 71 public import gtkc.gtktypes; 72 73 public import gtkc.gtk; 74 public import glib.ConstructionException; 75 public import gobject.ObjectG; 76 77 public import gobject.Signals; 78 public import gtkc.gdktypes; 79 80 public import gtk.Widget; 81 public import gtk.PageSetup; 82 public import gtk.PrintSettings; 83 84 85 86 87 /** 88 * Description 89 * GtkPrintOperation is the high-level, portable printing API. It looks 90 * a bit different than other GTK+ dialogs such as the GtkFileChooser, 91 * since some platforms don't expose enough infrastructure to implement 92 * a good print dialog. On such platforms, GtkPrintOperation uses the 93 * native print dialog. On platforms which do not provide a native 94 * print dialog, GTK+ uses its own, see GtkPrintUnixDialog. 95 * The typical way to use the high-level printing API is to create a 96 * GtkPrintOperation object with gtk_print_operation_new() when the user 97 * selects to print. Then you set some properties on it, e.g. the page size, 98 * any GtkPrintSettings from previous print operations, the number of pages, 99 * the current page, etc. 100 * Then you start the print operation by calling gtk_print_operation_run(). 101 * It will then show a dialog, let the user select a printer and options. 102 * When the user finished the dialog various signals will be emitted on the 103 * GtkPrintOperation, the main one being ::draw-page, which you are supposed 104 * to catch and render the page on the provided GtkPrintContext using Cairo. 105 * $(DDOC_COMMENT example) 106 * By default GtkPrintOperation uses an external application to do 107 * print preview. To implement a custom print preview, an application 108 * must connect to the preview signal. The functions 109 * gtk_print_operation_print_preview_render_page(), 110 * gtk_print_operation_preview_end_preview() and 111 * gtk_print_operation_preview_is_selected() are useful 112 * when implementing a print preview. 113 * Printing support was added in GTK+ 2.10. 114 */ 115 public template PrintOperationPreviewT(TStruct) 116 { 117 118 /** the main Gtk struct */ 119 protected GtkPrintOperationPreview* gtkPrintOperationPreview; 120 121 122 public GtkPrintOperationPreview* getPrintOperationPreviewTStruct() 123 { 124 return cast(GtkPrintOperationPreview*)getStruct(); 125 } 126 127 128 /** 129 */ 130 int[string] connectedSignals; 131 132 void delegate(Widget, PageSetup, PrintSettings, PrintOperationPreviewIF)[] _onUpdateCustomWidgetListeners; 133 void delegate(Widget, PageSetup, PrintSettings, PrintOperationPreviewIF)[] onUpdateCustomWidgetListeners() 134 { 135 return _onUpdateCustomWidgetListeners; 136 } 137 /** 138 * Emitted after change of selected printer. The actual page setup and 139 * print settings are passed to the custom widget, which can actualize 140 * itself according to this change. 141 * Since 2.18 142 */ 143 void addOnUpdateCustomWidget(void delegate(Widget, PageSetup, PrintSettings, PrintOperationPreviewIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 144 { 145 if ( !("update-custom-widget" in connectedSignals) ) 146 { 147 Signals.connectData( 148 getStruct(), 149 "update-custom-widget", 150 cast(GCallback)&callBackUpdateCustomWidget, 151 cast(void*)cast(PrintOperationPreviewIF)this, 152 null, 153 connectFlags); 154 connectedSignals["update-custom-widget"] = 1; 155 } 156 _onUpdateCustomWidgetListeners ~= dlg; 157 } 158 extern(C) static void callBackUpdateCustomWidget(GtkPrintOperation* operationStruct, GtkWidget* widget, GtkPageSetup* setup, GtkPrintSettings* settings, PrintOperationPreviewIF _printOperationPreviewIF) 159 { 160 foreach ( void delegate(Widget, PageSetup, PrintSettings, PrintOperationPreviewIF) dlg ; _printOperationPreviewIF.onUpdateCustomWidgetListeners ) 161 { 162 dlg(ObjectG.getDObject!(Widget)(widget), ObjectG.getDObject!(PageSetup)(setup), ObjectG.getDObject!(PrintSettings)(settings), _printOperationPreviewIF); 163 } 164 } 165 166 void delegate(GtkPrintContext*, PageSetup, PrintOperationPreviewIF)[] _onGotPageSizeListeners; 167 void delegate(GtkPrintContext*, PageSetup, PrintOperationPreviewIF)[] onGotPageSizeListeners() 168 { 169 return _onGotPageSizeListeners; 170 } 171 /** 172 * The ::got-page-size signal is emitted once for each page 173 * that gets rendered to the preview. 174 * A handler for this signal should update the context 175 * according to page_setup and set up a suitable cairo 176 * context, using gtk_print_context_set_cairo_context(). 177 */ 178 void addOnGotPageSize(void delegate(GtkPrintContext*, PageSetup, PrintOperationPreviewIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 179 { 180 if ( !("got-page-size" in connectedSignals) ) 181 { 182 Signals.connectData( 183 getStruct(), 184 "got-page-size", 185 cast(GCallback)&callBackGotPageSize, 186 cast(void*)cast(PrintOperationPreviewIF)this, 187 null, 188 connectFlags); 189 connectedSignals["got-page-size"] = 1; 190 } 191 _onGotPageSizeListeners ~= dlg; 192 } 193 extern(C) static void callBackGotPageSize(GtkPrintOperationPreview* previewStruct, GtkPrintContext* context, GtkPageSetup* pageSetup, PrintOperationPreviewIF _printOperationPreviewIF) 194 { 195 foreach ( void delegate(GtkPrintContext*, PageSetup, PrintOperationPreviewIF) dlg ; _printOperationPreviewIF.onGotPageSizeListeners ) 196 { 197 dlg(context, ObjectG.getDObject!(PageSetup)(pageSetup), _printOperationPreviewIF); 198 } 199 } 200 201 void delegate(GtkPrintContext*, PrintOperationPreviewIF)[] _onReadyListeners; 202 void delegate(GtkPrintContext*, PrintOperationPreviewIF)[] onReadyListeners() 203 { 204 return _onReadyListeners; 205 } 206 /** 207 * The ::ready signal gets emitted once per preview operation, 208 * before the first page is rendered. 209 * A handler for this signal can be used for setup tasks. 210 * See Also 211 * GtkPrintContext, GtkPrintUnixDialog 212 */ 213 void addOnReady(void delegate(GtkPrintContext*, PrintOperationPreviewIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 214 { 215 if ( !("ready" in connectedSignals) ) 216 { 217 Signals.connectData( 218 getStruct(), 219 "ready", 220 cast(GCallback)&callBackReady, 221 cast(void*)cast(PrintOperationPreviewIF)this, 222 null, 223 connectFlags); 224 connectedSignals["ready"] = 1; 225 } 226 _onReadyListeners ~= dlg; 227 } 228 extern(C) static void callBackReady(GtkPrintOperationPreview* previewStruct, GtkPrintContext* context, PrintOperationPreviewIF _printOperationPreviewIF) 229 { 230 foreach ( void delegate(GtkPrintContext*, PrintOperationPreviewIF) dlg ; _printOperationPreviewIF.onReadyListeners ) 231 { 232 dlg(context, _printOperationPreviewIF); 233 } 234 } 235 236 237 /** 238 * Ends a preview. 239 * This function must be called to finish a custom print preview. 240 * Since 2.10 241 */ 242 public void endPreview() 243 { 244 // void gtk_print_operation_preview_end_preview (GtkPrintOperationPreview *preview); 245 gtk_print_operation_preview_end_preview(getPrintOperationPreviewTStruct()); 246 } 247 248 /** 249 * Returns whether the given page is included in the set of pages that 250 * have been selected for printing. 251 * Since 2.10 252 * Params: 253 * pageNr = a page number 254 * Returns: TRUE if the page has been selected for printing 255 */ 256 public int isSelected(int pageNr) 257 { 258 // gboolean gtk_print_operation_preview_is_selected (GtkPrintOperationPreview *preview, gint page_nr); 259 return gtk_print_operation_preview_is_selected(getPrintOperationPreviewTStruct(), pageNr); 260 } 261 262 /** 263 * Renders a page to the preview, using the print context that 264 * was passed to the "preview" handler together 265 * with preview. 266 * A custom iprint preview should use this function in its ::expose 267 * handler to render the currently selected page. 268 * Note that this function requires a suitable cairo context to 269 * be associated with the print context. 270 * Since 2.10 271 * Params: 272 * pageNr = the page to render 273 */ 274 public void renderPage(int pageNr) 275 { 276 // void gtk_print_operation_preview_render_page (GtkPrintOperationPreview *preview, gint page_nr); 277 gtk_print_operation_preview_render_page(getPrintOperationPreviewTStruct(), pageNr); 278 } 279 }