gtkmm: Gtk::PrintContext Class Reference

A PrintContext encapsulates context information that is required when drawing pages for printing, such as the cairo context and important parameters like page size and resolution. More...

#include <gtkmm/printcontext.h>

Inheritance diagram for Gtk::PrintContext:

Public Member Functions

 PrintContext (PrintContext&& src) noexcept
 
PrintContextoperator= (PrintContext&& src) noexcept
 
 ~PrintContext () noexcept override
 
GtkPrintContext* gobj ()
 Provides access to the underlying C GObject. More...

 
const GtkPrintContext* gobj () const
 Provides access to the underlying C GObject. More...

 
GtkPrintContext* gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...

 
Cairo::RefPtr< Cairo::Contextget_cairo_context ()
 Obtains the cairo context that is associated with the Gtk::PrintContext. More...

 
Cairo::RefPtr< const Cairo::Contextget_cairo_context () const
 Obtains the cairo context that is associated with the Gtk::PrintContext. More...

 
Glib::RefPtr< PageSetupget_page_setup ()
 Obtains the Gtk::PageSetup that determines the page dimensions of the Gtk::PrintContext. More...

 
Glib::RefPtr< const PageSetupget_page_setup () const
 Obtains the Gtk::PageSetup that determines the page dimensions of the Gtk::PrintContext. More...

 
double get_width () const
 Obtains the width of the Gtk::PrintContext, in pixels. More...

 
double get_height () const
 Obtains the height of the Gtk::PrintContext, in pixels. More...

 
double get_dpi_x () const
 Obtains the horizontal resolution of the Gtk::PrintContext, in dots per inch. More...

 
double get_dpi_y () const
 Obtains the vertical resolution of the Gtk::PrintContext, in dots per inch. More...

 
bool get_hard_margins (double& top, double& bottom, double&left, double&right) const
 Obtains the hardware printer margins of the Gtk::PrintContext, in units. More...

 
Glib::RefPtr< Pango::FontMapget_pango_fontmap ()
 Returns a Pango::FontMap that is suitable for use with the Gtk::PrintContext. More...

 
Glib::RefPtr< const Pango::FontMapget_pango_fontmap () const
 Returns a Pango::FontMap that is suitable for use with the Gtk::PrintContext. More...

 
Glib::RefPtr< Pango::Contextcreate_pango_context ()
 Creates a new Pango::Context that can be used with the Gtk::PrintContext. More...

 
Glib::RefPtr< Pango::Layoutcreate_pango_layout ()
 Creates a new Pango::Layout that is suitable for use with the Gtk::PrintContext. More...

 
void set_cairo_context (const Cairo::RefPtr< Cairo::Context >& cr, double dpi_x, double dpi_y)
 Sets a new cairo context on a print context. More...

 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
void * get_data (const QueryQuark &key)
 
void set_data (const Quark &key, void *data)
 
void set_data (const Quark &key, void *data, DestroyNotify notify)
 
void remove_data (const QueryQuark &quark)
 
void * steal_data (const QueryQuark &quark)
 
Glib::RefPtr< Glib::Objectwrap (GObject *object, bool take_copy=false)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
 
void get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
 
void set_property (const Glib::ustring &property_name, const PropertyType &value)
 
void get_property (const Glib::ustring &property_name, PropertyType &value) const
 
PropertyType get_property (const Glib::ustring &property_name) const
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot)
 
void freeze_notify ()
 
void thaw_notify ()
 
virtual void reference () const
 
virtual void unreference () const
 
GObject * gobj ()
 
const GObject * gobj () const
 
GObject * gobj_copy () const
 
- Public Member Functions inherited from sigc::trackable
 trackable () noexcept
 
 trackable (const trackable &src) noexcept
 
 trackable (trackable &&src) noexcept
 
 ~trackable ()
 
void add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const
 
void notify_callbacks ()
 
trackableoperator= (const trackable &src)
 
trackableoperator= (trackable &&src) noexcept
 
void remove_destroy_notify_callback (notifiable *data) const
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...

 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::PrintContextwrap (GtkPrintContext* object, bool take_copy=false)
 A Glib::wrap() method for this object. More...

 

Additional Inherited Members

- Public Types inherited from Glib::Object
typedef void(*)(gpointer data DestroyNotify)
 
- Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify func_destroy_notify
 
- Public Types inherited from sigc::notifiable
typedef internal::func_destroy_notify func_destroy_notify
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexcept override
 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 
 ObjectBase (const char *custom_type_name)
 
 ObjectBase (const std::type_info &custom_type_info)
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Detailed Description

A PrintContext encapsulates context information that is required when drawing pages for printing, such as the cairo context and important parameters like page size and resolution.

It also lets you easily create Pango::Layout and Pango::Context objects that match the font metrics of the cairo surface.

PrintContext objects gets passed to the begin-print, end-print, request-page-setup and draw-page signals on the PrintOperation.

Since gtkmm 2.10:

Constructor & Destructor Documentation

Gtk::PrintContext::PrintContext ( PrintContext&&  src)
noexcept
Gtk::PrintContext::~PrintContext ( )
overridenoexcept

Member Function Documentation

Glib::RefPtr<Pango::Context> Gtk::PrintContext::create_pango_context ( )

Creates a new Pango::Context that can be used with the Gtk::PrintContext.

Returns
A new Pango context for context.
Glib::RefPtr<Pango::Layout> Gtk::PrintContext::create_pango_layout ( )

Creates a new Pango::Layout that is suitable for use with the Gtk::PrintContext.

Returns
A new Pango layout for context.
Cairo::RefPtr<Cairo::Context> Gtk::PrintContext::get_cairo_context ( )

Obtains the cairo context that is associated with the Gtk::PrintContext.

Returns
The cairo context of context.
Cairo::RefPtr<const Cairo::Context> Gtk::PrintContext::get_cairo_context ( ) const

Obtains the cairo context that is associated with the Gtk::PrintContext.

Returns
The cairo context of context.
double Gtk::PrintContext::get_dpi_x ( ) const

Obtains the horizontal resolution of the Gtk::PrintContext, in dots per inch.

Returns
The horizontal resolution of context.
double Gtk::PrintContext::get_dpi_y ( ) const

Obtains the vertical resolution of the Gtk::PrintContext, in dots per inch.

Returns
The vertical resolution of context.
bool Gtk::PrintContext::get_hard_margins ( double &  top,
double &  bottom,
double &  left,
double &  right 
) const

Obtains the hardware printer margins of the Gtk::PrintContext, in units.

Parameters
topTop hardware printer margin.
bottomBottom hardware printer margin.
leftLeft hardware printer margin.
rightRight hardware printer margin.
Returns
true if the hard margins were retrieved.
double Gtk::PrintContext::get_height ( ) const

Obtains the height of the Gtk::PrintContext, in pixels.

Returns
The height of context.
Glib::RefPtr<PageSetup> Gtk::PrintContext::get_page_setup ( )

Obtains the Gtk::PageSetup that determines the page dimensions of the Gtk::PrintContext.

Returns
The page setup of context.
Glib::RefPtr<const PageSetup> Gtk::PrintContext::get_page_setup ( ) const

Obtains the Gtk::PageSetup that determines the page dimensions of the Gtk::PrintContext.

Returns
The page setup of context.
Glib::RefPtr<Pango::FontMap> Gtk::PrintContext::get_pango_fontmap ( )

Returns a Pango::FontMap that is suitable for use with the Gtk::PrintContext.

Returns
The font map of context.
Glib::RefPtr<const Pango::FontMap> Gtk::PrintContext::get_pango_fontmap ( ) const

Returns a Pango::FontMap that is suitable for use with the Gtk::PrintContext.

Returns
The font map of context.
static GType Gtk::PrintContext::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

double Gtk::PrintContext::get_width ( ) const

Obtains the width of the Gtk::PrintContext, in pixels.

Returns
The width of context.
GtkPrintContext* Gtk::PrintContext::gobj ( )
inline

Provides access to the underlying C GObject.

const GtkPrintContext* Gtk::PrintContext::gobj ( ) const
inline

Provides access to the underlying C GObject.

GtkPrintContext* Gtk::PrintContext::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

PrintContext& Gtk::PrintContext::operator= ( PrintContext&&  src)
noexcept
void Gtk::PrintContext::set_cairo_context ( const Cairo::RefPtr< Cairo::Context > &  cr,
double  dpi_x,
double  dpi_y 
)

Sets a new cairo context on a print context.

This function is intended to be used when implementing an internal print preview, it is not needed for printing, since GTK itself creates a suitable cairo context in that case.

Parameters
crThe cairo context.
dpi_xThe horizontal resolution to use with cr.
dpi_yThe vertical resolution to use with cr.

Friends And Related Function Documentation

Glib::RefPtr< Gtk::PrintContext > wrap ( GtkPrintContext *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.