// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gtk import ( "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/cairo" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" "github.com/bnema/puregotk/v4/pango" ) // Encapsulates context information that is required when // drawing pages for printing. // // This includes the cairo context and important parameters like page size // and resolution. It also lets you easily create [class@Pango.Layout] and // [class@Pango.Context] objects that match the font metrics of the cairo surface. // // `GtkPrintContext` objects get passed to the // [signal@Gtk.PrintOperation::begin-print], // [signal@Gtk.PrintOperation::end-print], // [signal@Gtk.PrintOperation::request-page-setup] and // [signal@Gtk.PrintOperation::draw-page] signals on the // [class@Gtk.PrintOperation] object. // // ## Using GtkPrintContext in a ::draw-page callback // // ```c // static void // draw_page (GtkPrintOperation *operation, // // GtkPrintContext *context, // int page_nr) // // { // cairo_t *cr; // PangoLayout *layout; // PangoFontDescription *desc; // // cr = gtk_print_context_get_cairo_context (context); // // // Draw a red rectangle, as wide as the paper (inside the margins) // cairo_set_source_rgb (cr, 1.0, 0, 0); // cairo_rectangle (cr, 0, 0, gtk_print_context_get_width (context), 50); // // cairo_fill (cr); // // // Draw some lines // cairo_move_to (cr, 20, 10); // cairo_line_to (cr, 40, 20); // cairo_arc (cr, 60, 60, 20, 0, M_PI); // cairo_line_to (cr, 80, 20); // // cairo_set_source_rgb (cr, 0, 0, 0); // cairo_set_line_width (cr, 5); // cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); // cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); // // cairo_stroke (cr); // // // Draw some text // layout = gtk_print_context_create_pango_layout (context); // pango_layout_set_text (layout, "Hello World! Printing is easy", -1); // desc = pango_font_description_from_string ("sans 28"); // pango_layout_set_font_description (layout, desc); // pango_font_description_free (desc); // // cairo_move_to (cr, 30, 20); // pango_cairo_layout_path (cr, layout); // // // Font Outline // cairo_set_source_rgb (cr, 0.93, 1.0, 0.47); // cairo_set_line_width (cr, 0.5); // cairo_stroke_preserve (cr); // // // Font Fill // cairo_set_source_rgb (cr, 0, 0.0, 1.0); // cairo_fill (cr); // // g_object_unref (layout); // } // // ``` type PrintContext struct { gobject.Object } var xPrintContextGLibType func() types.GType func PrintContextGLibType() types.GType { return xPrintContextGLibType() } func PrintContextNewFromInternalPtr(ptr uintptr) *PrintContext { cls := &PrintContext{} cls.Ptr = ptr return cls } var xPrintContextCreatePangoContext func(uintptr) uintptr // Creates a new `PangoContext` that can be used with the // `GtkPrintContext`. func (x *PrintContext) CreatePangoContext() *pango.Context { var cls *pango.Context cret := xPrintContextCreatePangoContext(x.GoPointer()) if cret == 0 { return nil } cls = &pango.Context{} cls.Ptr = cret return cls } var xPrintContextCreatePangoLayout func(uintptr) uintptr // Creates a new `PangoLayout` that is suitable for use // with the `GtkPrintContext`. func (x *PrintContext) CreatePangoLayout() *pango.Layout { var cls *pango.Layout cret := xPrintContextCreatePangoLayout(x.GoPointer()) if cret == 0 { return nil } cls = &pango.Layout{} cls.Ptr = cret return cls } var xPrintContextGetCairoContext func(uintptr) *cairo.Context // Obtains the cairo context that is associated with the // `GtkPrintContext`. func (x *PrintContext) GetCairoContext() *cairo.Context { cret := xPrintContextGetCairoContext(x.GoPointer()) return cret } var xPrintContextGetDpiX func(uintptr) float64 // Obtains the horizontal resolution of the `GtkPrintContext`, // in dots per inch. func (x *PrintContext) GetDpiX() float64 { cret := xPrintContextGetDpiX(x.GoPointer()) return cret } var xPrintContextGetDpiY func(uintptr) float64 // Obtains the vertical resolution of the `GtkPrintContext`, // in dots per inch. func (x *PrintContext) GetDpiY() float64 { cret := xPrintContextGetDpiY(x.GoPointer()) return cret } var xPrintContextGetHardMargins func(uintptr, *float64, *float64, *float64, *float64) bool // Obtains the hardware printer margins of the `GtkPrintContext`, // in units. func (x *PrintContext) GetHardMargins(TopVar *float64, BottomVar *float64, LeftVar *float64, RightVar *float64) bool { cret := xPrintContextGetHardMargins(x.GoPointer(), TopVar, BottomVar, LeftVar, RightVar) return cret } var xPrintContextGetHeight func(uintptr) float64 // Obtains the height of the `GtkPrintContext`, in pixels. func (x *PrintContext) GetHeight() float64 { cret := xPrintContextGetHeight(x.GoPointer()) return cret } var xPrintContextGetPageSetup func(uintptr) uintptr // Obtains the `GtkPageSetup` that determines the page // dimensions of the `GtkPrintContext`. func (x *PrintContext) GetPageSetup() *PageSetup { var cls *PageSetup cret := xPrintContextGetPageSetup(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &PageSetup{} cls.Ptr = cret return cls } var xPrintContextGetPangoFontmap func(uintptr) uintptr // Returns a `PangoFontMap` that is suitable for use // with the `GtkPrintContext`. func (x *PrintContext) GetPangoFontmap() *pango.FontMap { var cls *pango.FontMap cret := xPrintContextGetPangoFontmap(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &pango.FontMap{} cls.Ptr = cret return cls } var xPrintContextGetWidth func(uintptr) float64 // Obtains the width of the `GtkPrintContext`, in pixels. func (x *PrintContext) GetWidth() float64 { cret := xPrintContextGetWidth(x.GoPointer()) return cret } var xPrintContextSetCairoContext func(uintptr, *cairo.Context, float64, float64) // 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. func (x *PrintContext) SetCairoContext(CrVar *cairo.Context, DpiXVar float64, DpiYVar float64) { xPrintContextSetCairoContext(x.GoPointer(), CrVar, DpiXVar, DpiYVar) } func (c *PrintContext) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *PrintContext) SetGoPointer(ptr uintptr) { c.Ptr = ptr } func init() { core.SetPackageName("GTK", "gtk4") core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"}) var libs []uintptr for _, libPath := range core.GetPaths("GTK") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xPrintContextGLibType, libs, "gtk_print_context_get_type") core.PuregoSafeRegister(&xPrintContextCreatePangoContext, libs, "gtk_print_context_create_pango_context") core.PuregoSafeRegister(&xPrintContextCreatePangoLayout, libs, "gtk_print_context_create_pango_layout") core.PuregoSafeRegister(&xPrintContextGetCairoContext, libs, "gtk_print_context_get_cairo_context") core.PuregoSafeRegister(&xPrintContextGetDpiX, libs, "gtk_print_context_get_dpi_x") core.PuregoSafeRegister(&xPrintContextGetDpiY, libs, "gtk_print_context_get_dpi_y") core.PuregoSafeRegister(&xPrintContextGetHardMargins, libs, "gtk_print_context_get_hard_margins") core.PuregoSafeRegister(&xPrintContextGetHeight, libs, "gtk_print_context_get_height") core.PuregoSafeRegister(&xPrintContextGetPageSetup, libs, "gtk_print_context_get_page_setup") core.PuregoSafeRegister(&xPrintContextGetPangoFontmap, libs, "gtk_print_context_get_pango_fontmap") core.PuregoSafeRegister(&xPrintContextGetWidth, libs, "gtk_print_context_get_width") core.PuregoSafeRegister(&xPrintContextSetCairoContext, libs, "gtk_print_context_set_cairo_context") }