Sophie

Sophie

distrib > PLD > ac > amd64 > media > dist > by-pkgid > fd2761970a77896f276e13daf3a9620f > files > 119

bonobo-devel-1.0.22-7.amd64.rpm

<HTML
><HEAD
><TITLE
>BonoboPrint</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
"><LINK
REL="HOME"
TITLE="Bonobo API Reference Manual"
HREF="book1.html"><LINK
REL="UP"
TITLE="Printing"
HREF="bonobo-print.html"><LINK
REL="PREVIOUS"
TITLE="Printing"
HREF="bonobo-print.html"><LINK
REL="NEXT"
TITLE="BonoboPrintClient"
HREF="bonobo-bonobo-print-client.html"></HEAD
><BODY
CLASS="REFENTRY"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
BGCOLOR="#000000"
CELLPADDING="1"
CELLSPACING="0"
><TR
><TH
COLSPAN="4"
ALIGN="center"
><FONT
COLOR="#FFFFFF"
SIZE="5"
>Bonobo API Reference Manual</FONT
></TH
></TR
><TR
><TD
WIDTH="25%"
BGCOLOR="#C00000"
ALIGN="left"
><A
HREF="bonobo-print.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>&#60;&#60;&#60; Previous Page</B
></FONT
></A
></TD
><TD
WIDTH="25%"
BGCOLOR="#0000C0"
ALIGN="center"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
><A
HREF="book1.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Home</B
></FONT
></A
></B
></FONT
></TD
><TD
WIDTH="25%"
BGCOLOR="#00C000"
ALIGN="center"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
><A
HREF="bonobo-print.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Up</B
></FONT
></A
></B
></FONT
></TD
><TD
WIDTH="25%"
BGCOLOR="#C00000"
ALIGN="right"
><A
HREF="bonobo-bonobo-print-client.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Next Page &#62;&#62;&#62;</B
></FONT
></A
></TD
></TR
></TABLE
></DIV
><H1
><A
NAME="BONOBO-BONOBO-PRINT"
>BonoboPrint</A
></H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN11192"
></A
><H2
>Name</H2
>BonoboPrint&nbsp;--&nbsp;A print interface all embeddables should implement</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN11195"
></A
><H2
>Synopsis</H2
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="SYNOPSIS"
>&#13;

typedef     <A
HREF="bonobo-bonobo-print.html#BONOBOPRINT"
>BonoboPrint</A
>;
typedef     <A
HREF="bonobo-bonobo-print.html#BONOBOPRINTCLASS"
>BonoboPrintClass</A
>;
<GTKDOCLINK
HREF="GTKTYPE"
>GtkType</GTKDOCLINK
>     <A
HREF="bonobo-bonobo-print.html#BONOBO-PRINT-GET-TYPE"
>bonobo_print_get_type</A
>           (void);
<A
HREF="bonobo-bonobo-print.html#BONOBOPRINT"
>BonoboPrint</A
>* <A
HREF="bonobo-bonobo-print.html#BONOBO-PRINT-CONSTRUCT"
>bonobo_print_construct</A
>         (<A
HREF="bonobo-bonobo-print.html#BONOBOPRINT"
>BonoboPrint</A
> *p,
                                             <GTKDOCLINK
HREF="BONOBOPRINTRENDERFN"
>BonoboPrintRenderFn</GTKDOCLINK
> *render,
                                             <GTKDOCLINK
HREF="GPOINTER"
>gpointer</GTKDOCLINK
> user_data);
<A
HREF="bonobo-bonobo-print.html#BONOBOPRINT"
>BonoboPrint</A
>* <A
HREF="bonobo-bonobo-print.html#BONOBO-PRINT-NEW"
>bonobo_print_new</A
>               (<GTKDOCLINK
HREF="BONOBOPRINTRENDERFN"
>BonoboPrintRenderFn</GTKDOCLINK
> *render,
                                             <GTKDOCLINK
HREF="GPOINTER"
>gpointer</GTKDOCLINK
> user_data);&#13;</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN11211"
></A
><H2
>Object Hierarchy</H2
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="SYNOPSIS"
>&#13;  <GTKDOCLINK
HREF="GTKOBJECT"
>GtkObject</GTKDOCLINK
>
   +----<A
HREF="bonobo-bonobo-object.html#BONOBOOBJECT"
>BonoboObject</A
>
         +----<GTKDOCLINK
HREF="BONOBOXOBJECT"
>BonoboXObject</GTKDOCLINK
>
               +----BonoboPrint</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN11217"
></A
><H2
>Description</H2
><P
>This interfaces is implemented by an embeddable ( compound document item ).
It exposes a simple render method that allows its child to print itself.
The component renders itself ( or a sub-window of itself ) with the
specified dimensions to the provided GnomePrintContext.</P
><P
>In addition to proxying the render request, the context also converts the
scribbled on context to a meta file, and returns a stream to the callee
such that the information can be transfered to the caller. A nice wrapper
interface is available in <A
HREF="bonobo-bonobo-print-client.html#BONOBOPRINTCLIENT"
>BonoboPrintClient</A
> that makes this very simple
to use.</P
><P
>First of course, the interface has to be constructed add associated
with the <GTKDOCLINK
HREF="BONOBOEMBEDDABLE"
>BonoboEmbeddable</GTKDOCLINK
> 's <A
HREF="bonobo-bonobo-object.html#BONOBOOBJECT"
>BonoboObject</A
> using the
bonobo_object_add_interface method.
  <DIV
CLASS="EXAMPLE"
><A
NAME="AEN11225"
></A
><P
><B
>Example 1. Aggregating a new BonoboPrint interface</B
></P
><TABLE
BORDER="0"
BGCOLOR="#D8F8D8"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>HelloBonoboEmbeddable *
hello_bonobo_embeddable_construct (HelloBonoboEmbeddable *embeddable)
{
	BonoboPrint         *print;

	g_return_val_if_fail (HELLO_BONOBO_IS_EMBEDDABLE (embeddable), NULL);

	bonobo_embeddable_construct (BONOBO_EMBEDDABLE (embeddable),
				     hello_bonobo_view_factory, NULL);

	/* Register the Bonobo::Print interface */
	print = bonobo_print_new (hello_object_print, embeddable);
	if (!print) {
		bonobo_object_unref (BONOBO_OBJECT (embeddable));
		return NULL;
	}

	bonobo_object_add_interface (BONOBO_OBJECT (embeddable),
				     BONOBO_OBJECT (print));
	return embeddable;
}
    </PRE
></TD
></TR
></TABLE
></DIV
></P
><P
>Having aggregated the print interface to the embeddable, and passed
in the 'embeddable' itself as the user_data, we can then implement
the <GTKDOCLINK
HREF="BONOBOPRINTRENDERFN"
>BonoboPrintRenderFn</GTKDOCLINK
> method and make the interface actually
useful, in this case we extract the text from the embeddable-&#62;text
pointer, and print 'Value:' with the text under it, and some
miscellaneous lines:
  <DIV
CLASS="EXAMPLE"
><A
NAME="AEN11230"
></A
><P
><B
>Example 2. A simple print function</B
></P
><TABLE
BORDER="0"
BGCOLOR="#D8F8D8"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void
hello_object_print (GnomePrintContext         *ctx,
		    double                     width,
		    double                     height,
		    const Bonobo_PrintScissor *scissor,
		    gpointer                   user_data)
{
	HelloBonoboEmbeddable *embeddable = user_data;
	GnomeFont             *font;
	double                 w, w2, h;
	const char            *str, *descr;

	str = embeddable-&#62;text ? embeddable-&#62;text : "No text";
	descr = "Value:";

	gnome_print_setlinewidth (ctx, 2);
	font = gnome_font_new ("Helvetica", 12.0);
	g_return_if_fail (font != NULL);
	gnome_print_setrgbcolor (ctx, 0.0, 0.0, 0.0);
	gnome_print_setfont (ctx, font);

	w  = gnome_font_get_width_string (font, descr);
	w2 = gnome_font_get_width_string (font, str);
	h  = gnome_font_get_ascender (font) +
	     gnome_font_get_descender (font);

	gnome_print_moveto (ctx, (width / 2) - (w / 2), (height / 2) + h * 2);
	gnome_print_show (ctx, descr);
	gnome_print_moveto (ctx, (width / 2) - (w2 / 2), height / 2 - h);
	gnome_print_show (ctx, str);

	gtk_object_unref (GTK_OBJECT (font));
}
    </PRE
></TD
></TR
></TABLE
></DIV
></P
><P
>In the above example the Scissor context is not used. In many
applications it will not, however the scissor context specifies
how the printed item will be cropped inside the container application,
this allows the component to adjust its printed output to best fit
this situation if neccessary.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN11234"
></A
><H2
>Details</H2
><DIV
CLASS="REFSECT2"
><A
NAME="AEN11236"
></A
><H3
><A
NAME="BONOBOPRINT"
></A
>BonoboPrint</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef struct {
        BonoboXObject        object;

	BonoboPrintRenderFn *render;
	gpointer             user_data;
} BonoboPrint;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN11241"
></A
><H3
><A
NAME="BONOBOPRINTCLASS"
></A
>BonoboPrintClass</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef struct {
	BonoboXObjectClass   parent;

	POA_Bonobo_Print__epv epv;

	BonoboPrintRenderFn *render;
} BonoboPrintClass;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN11246"
></A
><H3
><A
NAME="BONOBO-PRINT-GET-TYPE"
></A
>bonobo_print_get_type ()</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
><GTKDOCLINK
HREF="GTKTYPE"
>GtkType</GTKDOCLINK
>     bonobo_print_get_type           (void);</PRE
></TD
></TR
></TABLE
><P
></P
><P
></P
><P
></P
><TABLE
CLASS="VARIABLELIST"
BORDER="0"
CELLSPACING="0"
CELLPADDING="4"
WIDTH="100%"
BGCOLOR="#FFD0D0"
><TBODY
><TR
><TD
ALIGN="RIGHT"
VALIGN="TOP"
WIDTH="20%"
><A
NAME="AEN11254"><SPAN
STYLE="white-space: nowrap"
><I
CLASS="EMPHASIS"
>Returns</I
> :</SPAN
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="80%"
><P
> the GtkType for a BonoboPrint object.</P
></TD
></TR
></TBODY
></TABLE
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN11259"
></A
><H3
><A
NAME="BONOBO-PRINT-CONSTRUCT"
></A
>bonobo_print_construct ()</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
><A
HREF="bonobo-bonobo-print.html#BONOBOPRINT"
>BonoboPrint</A
>* bonobo_print_construct         (<A
HREF="bonobo-bonobo-print.html#BONOBOPRINT"
>BonoboPrint</A
> *p,
                                             <GTKDOCLINK
HREF="BONOBOPRINTRENDERFN"
>BonoboPrintRenderFn</GTKDOCLINK
> *render,
                                             <GTKDOCLINK
HREF="GPOINTER"
>gpointer</GTKDOCLINK
> user_data);</PRE
></TD
></TR
></TABLE
><P
>Construct <TT
CLASS="PARAMETER"
><I
>p</I
></TT
> setting its <TT
CLASS="PARAMETER"
><I
>render</I
></TT
> and <TT
CLASS="PARAMETER"
><I
>user_data</I
></TT
> pointers</P
><P
></P
><P
></P
><TABLE
CLASS="VARIABLELIST"
BORDER="0"
CELLSPACING="0"
CELLPADDING="4"
WIDTH="100%"
BGCOLOR="#FFD0D0"
><TBODY
><TR
><TD
ALIGN="RIGHT"
VALIGN="TOP"
WIDTH="20%"
><A
NAME="AEN11273"><SPAN
STYLE="white-space: nowrap"
><TT
CLASS="PARAMETER"
><I
>p</I
></TT
>&nbsp;:</SPAN
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="80%"
><P
> the print object</P
></TD
></TR
><TR
><TD
ALIGN="RIGHT"
VALIGN="TOP"
WIDTH="20%"
><A
NAME="AEN11278"><SPAN
STYLE="white-space: nowrap"
><TT
CLASS="PARAMETER"
><I
>render</I
></TT
>&nbsp;:</SPAN
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="80%"
><P
> the render method</P
></TD
></TR
><TR
><TD
ALIGN="RIGHT"
VALIGN="TOP"
WIDTH="20%"
><A
NAME="AEN11283"><SPAN
STYLE="white-space: nowrap"
><TT
CLASS="PARAMETER"
><I
>user_data</I
></TT
>&nbsp;:</SPAN
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="80%"
><P
> the render method's user data</P
></TD
></TR
><TR
><TD
ALIGN="RIGHT"
VALIGN="TOP"
WIDTH="20%"
><A
NAME="AEN11288"><SPAN
STYLE="white-space: nowrap"
><I
CLASS="EMPHASIS"
>Returns</I
> :</SPAN
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="80%"
><P
> a constructed BonoboPrint object</P
></TD
></TR
></TBODY
></TABLE
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN11293"
></A
><H3
><A
NAME="BONOBO-PRINT-NEW"
></A
>bonobo_print_new ()</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
><A
HREF="bonobo-bonobo-print.html#BONOBOPRINT"
>BonoboPrint</A
>* bonobo_print_new               (<GTKDOCLINK
HREF="BONOBOPRINTRENDERFN"
>BonoboPrintRenderFn</GTKDOCLINK
> *render,
                                             <GTKDOCLINK
HREF="GPOINTER"
>gpointer</GTKDOCLINK
> user_data);</PRE
></TD
></TR
></TABLE
><P
>Create a new bonobo-print implementing BonoboObject
interface.</P
><P
>This interface is called to ask a component to
<TT
CLASS="PARAMETER"
><I
>render</I
></TT
> itself to a print context with the specified
width and height, and scissoring data.</P
><P
></P
><P
></P
><TABLE
CLASS="VARIABLELIST"
BORDER="0"
CELLSPACING="0"
CELLPADDING="4"
WIDTH="100%"
BGCOLOR="#FFD0D0"
><TBODY
><TR
><TD
ALIGN="RIGHT"
VALIGN="TOP"
WIDTH="20%"
><A
NAME="AEN11305"><SPAN
STYLE="white-space: nowrap"
><TT
CLASS="PARAMETER"
><I
>render</I
></TT
>&nbsp;:</SPAN
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="80%"
><P
> the render function</P
></TD
></TR
><TR
><TD
ALIGN="RIGHT"
VALIGN="TOP"
WIDTH="20%"
><A
NAME="AEN11310"><SPAN
STYLE="white-space: nowrap"
><TT
CLASS="PARAMETER"
><I
>user_data</I
></TT
>&nbsp;:</SPAN
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="80%"
><P
> the render's user data function</P
></TD
></TR
><TR
><TD
ALIGN="RIGHT"
VALIGN="TOP"
WIDTH="20%"
><A
NAME="AEN11315"><SPAN
STYLE="white-space: nowrap"
><I
CLASS="EMPHASIS"
>Returns</I
> :</SPAN
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="80%"
><P
> a new BonoboPrint interface</P
></TD
></TR
></TBODY
></TABLE
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><BR
CLEAR="all"><BR><TABLE
WIDTH="100%"
BORDER="0"
BGCOLOR="#000000"
CELLPADDING="1"
CELLSPACING="0"
><TR
><TD
WIDTH="25%"
BGCOLOR="#C00000"
ALIGN="left"
><A
HREF="bonobo-print.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>&#60;&#60;&#60; Previous Page</B
></FONT
></A
></TD
><TD
WIDTH="25%"
BGCOLOR="#0000C0"
ALIGN="center"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
><A
HREF="book1.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Home</B
></FONT
></A
></B
></FONT
></TD
><TD
WIDTH="25%"
BGCOLOR="#00C000"
ALIGN="center"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
><A
HREF="bonobo-print.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Up</B
></FONT
></A
></B
></FONT
></TD
><TD
WIDTH="25%"
BGCOLOR="#C00000"
ALIGN="right"
><A
HREF="bonobo-bonobo-print-client.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Next Page &#62;&#62;&#62;</B
></FONT
></A
></TD
></TR
><TR
><TD
COLSPAN="2"
ALIGN="left"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Printing</B
></FONT
></TD
><TD
COLSPAN="2"
ALIGN="right"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>BonoboPrintClient</B
></FONT
></TD
></TR
></TABLE
></DIV
></BODY
></HTML
>