struct Gtk::PrintOperation::DrawPageSignal
- Gtk::PrintOperation::DrawPageSignal
- GObject::Signal
- Struct
- Value
- Object
Overview
Emitted for every page that is printed.
The signal handler must render the @page_nr's page onto the cairo
context obtained from @context using
Gtk::PrintContext#cairo_::context
.
WARNING ⚠️ The following code is in c ⚠️
static void
draw_page (Gtk::PrintOperation *operation,
Gtk::PrintContext *context,
int page_nr,
gpointer user_data)
{
cairo_::t *cr;
Pango::Layout *layout;
double width, text_height;
int layout_height;
Pango::FontDescription *desc;
cr = gtk_print_context_get_cairo_::context (context);
width = gtk_print_context_get_width (context);
cairo_::rectangle (cr, 0, 0, width, HEADER_HEIGHT);
cairo_::set_source_rgb (cr, 0.8, 0.8, 0.8);
cairo_::fill (cr);
layout = gtk_print_context_create_pango_layout (context);
desc = pango_font_description_from_string ("sans 14");
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
pango_layout_set_text (layout, "some text", -1);
pango_layout_set_width (layout, width * PANGO_SCALE);
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
pango_layout_get_size (layout, NULL, &layout_height);
text_height = (double)layout_height / PANGO_SCALE;
cairo_::move_to (cr, width / 2, (HEADER_HEIGHT - text_height) / 2);
pango_cairo_::show_layout (cr, layout);
g_object_unref (layout);
}
Use Gtk::PrintOperation#use_full_page=
and
Gtk::PrintOperation#unit=
before starting the print
operation to set up the transformation of the cairo context
according to your needs.
Defined in:
lib/gi-crystal/src/auto/gtk-4.0/print_operation.crInstance Method Summary
- #connect(*, after : Bool = false, &block : Proc(Gtk::PrintContext, Int32, Nil)) : GObject::SignalConnection
- #connect(handler : Proc(Gtk::PrintContext, Int32, Nil), *, after : Bool = false) : GObject::SignalConnection
- #connect(handler : Proc(Gtk::PrintOperation, Gtk::PrintContext, Int32, Nil), *, after : Bool = false) : GObject::SignalConnection
- #emit(context : Gtk::PrintContext, page_nr : Int32) : Nil
-
#name : String
The signal name
Instance methods inherited from struct GObject::Signal
[](detail : String) : self
[],
name : String
name
Constructor methods inherited from struct GObject::Signal
new(source : GObject::Object, detail : String? = nil)
new
Instance Method Detail
def connect(*, after : Bool = false, &block : Proc(Gtk::PrintContext, Int32, Nil)) : GObject::SignalConnection
#
def connect(handler : Proc(Gtk::PrintContext, Int32, Nil), *, after : Bool = false) : GObject::SignalConnection
#
def connect(handler : Proc(Gtk::PrintOperation, Gtk::PrintContext, Int32, Nil), *, after : Bool = false) : GObject::SignalConnection
#