## Documentation

Table of Contents
Class Inheritance Tree
Widget Screenshots
Package groups

## Index

Package: Printing

- Goto spec source

# Description

    package Gtkada.Printing is

This package provides a ready-to-use high level printing object.

Use functionality from Gtk.Print_Operation to manipulate the printing object, and the functionality in this package to provide the handlers for the printing operation.

Typically, to use this high-level printing API: - derive from the Gtkada_Print_Operation_Record object - override the Draw_Page operation - (optional) override any other operation useful to you - start the print operation by - first setting the number of pages through Set_N_Pages - then calling Connect_And_Run.

A dialog will be displayed, letting the user select a printer and options.

When the user finishes the dialog, various signals will be emitted on the Gtkada_Print_Operation, which will call the operations on your object.

Note: on UNIX/Linux, Gtk+ is loading at run-time the libraries for printing support. You will need to point the environment variable GTK_EXE_PREFIX to the root directory of your Gtk+ install before calling Connect_And_Run.

-- Create a derived type type Print_Op_Record is new Gtkada_Print_Operation_Record with record My_Data : My_Type; end record; type Print_Op_Access is access all Print_Op_Record'Class; -- Override Draw_Page procedure Draw_Page (Print_Operation : access Print_Op_Record; Context : Gtk_Print_Context; Page_Num : Gint) is Cr : Cairo_Context; begin Cr := Get_Cairo_Context (Context); -- Do drawing here end Draw_Page; -- Do the printing declare Print_Op : Print_Op_Access; Result : Gtk_Print_Operation_Result; begin -- Initialize Print_Op := new Print_Op_Record; Print_Op.My_Data := Some_Data; -- Set the number of pages to print Set_N_Pages (Print_Op, 2); -- Launch the printing Result := Connect_And_Run (Print_Op, Action_Print_Dialog, Gtk_Window (Get_Toplevel (Frame))); end;

# Classes

### Gtkada_Print_Operation_Record

- Goto declaration in source
- Goto full declaration in source

    type Gtkada_Print_Operation_Record is new
         Gtk_Print_Operation_Record with private;

#### Ancestors:

Gtk.Print_Operation.Gtk_Print_Operation_Record
Glib.Object.GObject_Record

#### Primitive operations:

Begin_Print

- To API doc
- To spec

Done

- To API doc
- To spec

Draw_Page

- To API doc
- To spec

End_Print

- To API doc
- To spec

Glib.Object.Deallocate

- To API doc
- To spec

(Inherited)
Glib.Object.Get_Type

- To API doc
- To spec

(Inherited)
Glib.Object.Notify

- To API doc
- To spec

(Inherited)
Glib.Object.Ref

- To API doc
- To spec

(Inherited)
Glib.Object.Ref_Sink

- To API doc
- To spec

(Inherited)
Glib.Object.Unref

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Cancel

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Draw_Page_Finish

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Get_Default_Page_Setup

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Get_Error

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Get_Print_Settings

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Get_Status

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Get_Status

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Is_Finished

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Run

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Set_Allow_Async

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Set_Current_Page

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Set_Custom_Tab_Label

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Set_Default_Page_Setup

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Set_Defer_Drawing

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Set_Export_Filename

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Set_Job_Name

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Set_N_Pages

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Set_Print_Settings

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Set_Show_Progress

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Set_Track_Print_Status

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Set_Unit

- To API doc
- To spec

(Inherited)
Gtk.Print_Operation.Set_Use_Full_Page

- To API doc
- To spec

(Inherited)
Paginate

- To API doc
- To spec

Preview

- To API doc
- To spec

Request_Page_Setup

- To API doc
- To spec

Status_Changed

- To API doc
- To spec

# Types

### Gtkada_Print_Operation

- Goto declaration in source

    type Gtkada_Print_Operation is access all Gtkada_Print_Operation_Record;

# Subprograms & Entries

### Gtk_New

- Goto spec in source

    procedure Gtk_New (Op: out Gtkada_Print_Operation);

### Initialize

- Goto spec in source

    procedure Initialize (Widget: access Gtkada_Print_Operation_Record'Class);

Initialize the print operation

### Connect_And_Run

- Goto spec in source

    function Connect_And_Run (Op: access Gtkada_Print_Operation_Record'Class;Action: Gtk_Print_Operation_Action;Parent: access Gtk_Window_Record'Class;Error: Glib.Error.GError := null) return Gtk_Print_Operation_Result;

Runs the print operation, using the handlers installed in Op. See Gtk.Print_Operations.Run.

### Draw_Page

- Goto spec in source

    procedure Draw_Page (Op: access Gtkada_Print_Operation_Record;Context: Gtk_Print_Context;Page_Number: Gint);

Called for every page that is printed. This handler must render the page Page_Number onto the cairo context obtained from Context using Gtk.Print_Context.Get_Cairo_Context. Use Gtk.Print_Operation.Set_Use_Full_Page and Gtk.Print_Operation.Set_Unit before starting the print operation to set up the transformation of the cairo context according to your needs. This is the main printing handler. This has to be overriden for the printing operation to work.

### Begin_Print

- Goto spec in source

    procedure Begin_Print (Op: access Gtkada_Print_Operation_Record;Context: Gtk_Print_Context);

Called after the user has finished changing print settings in the dialog, before the actual rendering starts. A typical use is to use the parameters from the Gtk_Print_Context and paginate the document accordingly, and then set the number of pages with Gtk.Print_Operation.Set_N_Pages.

### Done

- Goto spec in source

    procedure Done (Op: access Gtkada_Print_Operation_Record;Result: Gtk_Print_Operation_Result);

Called when the print operation run has finished doing everything required for printing. Result gives you information about what happened during the run. If Result is Result_Error then you can call Get_Error for more information. If you enabled print status tracking then Gtk.Print_Operation.Is_Finished may still return False after done was emitted.

### End_Print

- Goto spec in source

    procedure End_Print (Op: access Gtkada_Print_Operation_Record;Context: Gtk_Print_Context);

Called after all pages have been rendered. This handler can clean up any resources that have been allocated in Begin_Print.

### Paginate

- Goto spec in source

    function Paginate (Op: access Gtkada_Print_Operation_Record;Context: Gtk_Print_Context) return Boolean;

Called after the "begin-print" signal, but before the actual rendering starts. It keeps getting called until it returns True. The "paginate" signal is intended to be used for paginating a document in small chunks, to avoid blocking the user interface for a long time. This function should update the number of pages using Gtk.Print_Operation.Set_N_Pages, and return True if the document has been completely paginated. If you don't need to do pagination in chunks, you can simply do it all in the "begin-print" handler, and set the number of pages from there.

### Preview

- Goto spec in source

    function Preview (Op: access Gtkada_Print_Operation_Record;Preview: Gtk_Print_Operation_Preview;Context: Gtk_Print_Context;Parent: Gtk_Window) return Boolean;

Called when a preview is requested from the native dialog. This should return True if the in order to take over control of the preview. The default handler for this signal uses an external viewer application to preview. To implement a custom print preview, the overridden implementation should return True In order to use the provided Context for the preview implementation, it must be given a suitable cairo context with Set_Cairo_Context. The custom preview implementation can use Gtk.Print_Operation_Preview.Is_Selected and Gtk.Print_Operation_Preview.Render_Page to find pages which are selected for print and render them. The preview must be finished by calling Gtk.Print_Operation_Preview.End_Preview (typically in response to the user clicking a close button).

### Request_Page_Setup

- Goto spec in source

    procedure Request_Page_Setup (Op: access Gtkada_Print_Operation_Record;Context: Gtk_Print_Context;Page_Number: Gint;Setup: Gtk_Page_Setup);

Called once for every page that is printed, to give the application a chance to modify the page setup. Any changes done to setup will be in force only for printing this page.

### Status_Changed

- Goto spec in source

    procedure Status_Changed (Op: access Gtkada_Print_Operation_Record);

Called between the various phases of the print operation. See Gtk_Print_Status for the phases that are being discriminated. Use Gtk.Print_Operation.Get_Status to find out the current status.