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 module gtk.PrintOperationPreviewT; 26 27 public import gobject.Signals; 28 public import gtk.PageSetup; 29 public import gtk.PrintContext; 30 public import gtkc.gtk; 31 public import gtkc.gtktypes; 32 public import std.algorithm; 33 34 35 /** */ 36 public template PrintOperationPreviewT(TStruct) 37 { 38 /** Get the main Gtk struct */ 39 public GtkPrintOperationPreview* getPrintOperationPreviewStruct(bool transferOwnership = false) 40 { 41 if (transferOwnership) 42 ownedRef = false; 43 return cast(GtkPrintOperationPreview*)getStruct(); 44 } 45 46 47 /** 48 * Ends a preview. 49 * 50 * This function must be called to finish a custom print preview. 51 * 52 * Since: 2.10 53 */ 54 public void endPreview() 55 { 56 gtk_print_operation_preview_end_preview(getPrintOperationPreviewStruct()); 57 } 58 59 /** 60 * Returns whether the given page is included in the set of pages that 61 * have been selected for printing. 62 * 63 * Params: 64 * pageNr = a page number 65 * 66 * Returns: %TRUE if the page has been selected for printing 67 * 68 * Since: 2.10 69 */ 70 public bool isSelected(int pageNr) 71 { 72 return gtk_print_operation_preview_is_selected(getPrintOperationPreviewStruct(), pageNr) != 0; 73 } 74 75 /** 76 * Renders a page to the preview, using the print context that 77 * was passed to the #GtkPrintOperation::preview handler together 78 * with @preview. 79 * 80 * A custom iprint preview should use this function in its ::expose 81 * handler to render the currently selected page. 82 * 83 * Note that this function requires a suitable cairo context to 84 * be associated with the print context. 85 * 86 * Params: 87 * pageNr = the page to render 88 * 89 * Since: 2.10 90 */ 91 public void renderPage(int pageNr) 92 { 93 gtk_print_operation_preview_render_page(getPrintOperationPreviewStruct(), pageNr); 94 } 95 96 protected class OnGotPageSizeDelegateWrapper 97 { 98 static OnGotPageSizeDelegateWrapper[] listeners; 99 void delegate(PrintContext, PageSetup, PrintOperationPreviewIF) dlg; 100 gulong handlerId; 101 102 this(void delegate(PrintContext, PageSetup, PrintOperationPreviewIF) dlg) 103 { 104 this.dlg = dlg; 105 this.listeners ~= this; 106 } 107 108 void remove(OnGotPageSizeDelegateWrapper source) 109 { 110 foreach(index, wrapper; listeners) 111 { 112 if (wrapper.handlerId == source.handlerId) 113 { 114 listeners[index] = null; 115 listeners = std.algorithm.remove(listeners, index); 116 break; 117 } 118 } 119 } 120 } 121 122 /** 123 * The ::got-page-size signal is emitted once for each page 124 * that gets rendered to the preview. 125 * 126 * A handler for this signal should update the @context 127 * according to @page_setup and set up a suitable cairo 128 * context, using gtk_print_context_set_cairo_context(). 129 * 130 * Params: 131 * context = the current #GtkPrintContext 132 * pageSetup = the #GtkPageSetup for the current page 133 */ 134 gulong addOnGotPageSize(void delegate(PrintContext, PageSetup, PrintOperationPreviewIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 135 { 136 auto wrapper = new OnGotPageSizeDelegateWrapper(dlg); 137 wrapper.handlerId = Signals.connectData( 138 this, 139 "got-page-size", 140 cast(GCallback)&callBackGotPageSize, 141 cast(void*)wrapper, 142 cast(GClosureNotify)&callBackGotPageSizeDestroy, 143 connectFlags); 144 return wrapper.handlerId; 145 } 146 147 extern(C) static void callBackGotPageSize(GtkPrintOperationPreview* printoperationpreviewStruct, GtkPrintContext* context, GtkPageSetup* pageSetup, OnGotPageSizeDelegateWrapper wrapper) 148 { 149 wrapper.dlg(ObjectG.getDObject!(PrintContext)(context), ObjectG.getDObject!(PageSetup)(pageSetup), wrapper.outer); 150 } 151 152 extern(C) static void callBackGotPageSizeDestroy(OnGotPageSizeDelegateWrapper wrapper, GClosure* closure) 153 { 154 wrapper.remove(wrapper); 155 } 156 157 protected class OnReadyDelegateWrapper 158 { 159 static OnReadyDelegateWrapper[] listeners; 160 void delegate(PrintContext, PrintOperationPreviewIF) dlg; 161 gulong handlerId; 162 163 this(void delegate(PrintContext, PrintOperationPreviewIF) dlg) 164 { 165 this.dlg = dlg; 166 this.listeners ~= this; 167 } 168 169 void remove(OnReadyDelegateWrapper source) 170 { 171 foreach(index, wrapper; listeners) 172 { 173 if (wrapper.handlerId == source.handlerId) 174 { 175 listeners[index] = null; 176 listeners = std.algorithm.remove(listeners, index); 177 break; 178 } 179 } 180 } 181 } 182 183 /** 184 * The ::ready signal gets emitted once per preview operation, 185 * before the first page is rendered. 186 * 187 * A handler for this signal can be used for setup tasks. 188 * 189 * Params: 190 * context = the current #GtkPrintContext 191 */ 192 gulong addOnReady(void delegate(PrintContext, PrintOperationPreviewIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 193 { 194 auto wrapper = new OnReadyDelegateWrapper(dlg); 195 wrapper.handlerId = Signals.connectData( 196 this, 197 "ready", 198 cast(GCallback)&callBackReady, 199 cast(void*)wrapper, 200 cast(GClosureNotify)&callBackReadyDestroy, 201 connectFlags); 202 return wrapper.handlerId; 203 } 204 205 extern(C) static void callBackReady(GtkPrintOperationPreview* printoperationpreviewStruct, GtkPrintContext* context, OnReadyDelegateWrapper wrapper) 206 { 207 wrapper.dlg(ObjectG.getDObject!(PrintContext)(context), wrapper.outer); 208 } 209 210 extern(C) static void callBackReadyDestroy(OnReadyDelegateWrapper wrapper, GClosure* closure) 211 { 212 wrapper.remove(wrapper); 213 } 214 }