~ubuntu-branches/ubuntu/precise/gtk+2.0/precise-updates

« back to all changes in this revision

Viewing changes to docs/reference/gtk/tmpl/gtkprintcontext.sgml

  • Committer: Package Import Robot
  • Author(s): Ken VanDine
  • Date: 2011-12-01 11:40:06 UTC
  • mfrom: (1.14.11)
  • Revision ID: package-import@ubuntu.com-20111201114006-nrmf6qu3pg512veo
Tags: 2.24.8-0ubuntu1
* New upstream release 
  - gtkfilechooser should be more robust to malformed URIs
    in .gtk-bookmarks (LP: #189494)
* debian/patches/010_make_bg_changes_queue_repaint.patch
  - dropped it introduces performance regressions in some gtk2 
    apps (LP: #889019)
* 101_filechooser.patch, 000git_file_chooser.patch: dropped, upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!-- ##### SECTION Title ##### -->
2
 
GtkPrintContext
3
 
 
4
 
<!-- ##### SECTION Short_Description ##### -->
5
 
Encapsulates context for drawing pages
6
 
 
7
 
<!-- ##### SECTION Long_Description ##### -->
8
 
<para>
9
 
A GtkPrintContext encapsulates context information that is required when
10
 
drawing pages for printing, such as the cairo context and important 
11
 
parameters like page size and resolution. It also lets you easily
12
 
create #PangoLayout and #PangoContext objects that match the font metrics 
13
 
of the cairo surface.
14
 
</para>
15
 
<para>
16
 
GtkPrintContext objects gets passed to the ::begin-print, ::end-print, 
17
 
::request-page-setup and ::draw-page signals on the #GtkPrintOperation.
18
 
</para>
19
 
 
20
 
<example>
21
 
<title>Using GtkPrintContext in a ::draw-page callback</title>
22
 
<programlisting>
23
 
static void
24
 
draw_page (GtkPrintOperation *operation,
25
 
           GtkPrintContext   *context,
26
 
           int                page_nr)
27
 
{
28
 
  cairo_t *cr;
29
 
  PangoLayout *layout;
30
 
  PangoFontDescription *desc;
31
 
  
32
 
  cr = gtk_print_context_get_cairo_context (context);
33
 
 
34
 
  /* Draw a red rectangle, as wide as the paper (inside the margins) */
35
 
  cairo_set_source_rgb (cr, 1.0, 0, 0);
36
 
  cairo_rectangle (cr, 0, 0, gtk_print_context_get_width (context), 50);
37
 
  
38
 
  cairo_fill (cr);
39
 
 
40
 
  /* Draw some lines */
41
 
  cairo_move_to (cr, 20, 10);
42
 
  cairo_line_to (cr, 40, 20);
43
 
  cairo_arc (cr, 60, 60, 20, 0, M_PI);
44
 
  cairo_line_to (cr, 80, 20);
45
 
  
46
 
  cairo_set_source_rgb (cr, 0, 0, 0);
47
 
  cairo_set_line_width (cr, 5);
48
 
  cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
49
 
  cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
50
 
  
51
 
  cairo_stroke (cr);
52
 
 
53
 
  /* Draw some text */ 
54
 
  layout = gtk_print_context_create_layout (context);
55
 
  pango_layout_set_text (layout, "Hello World! Printing is easy", -1);
56
 
  desc = pango_font_description_from_string ("sans 28");
57
 
  pango_layout_set_font_description (layout, desc);
58
 
  pango_font_description_free (desc);
59
 
 
60
 
  cairo_move_to (cr, 30, 20);
61
 
  pango_cairo_layout_path (cr, layout);
62
 
 
63
 
  /* Font Outline */
64
 
  cairo_set_source_rgb (cr, 0.93, 1.0, 0.47);
65
 
  cairo_set_line_width (cr, 0.5);
66
 
  cairo_stroke_preserve (cr);
67
 
 
68
 
  /* Font Fill */
69
 
  cairo_set_source_rgb (cr, 0, 0.0, 1.0);
70
 
  cairo_fill (cr);
71
 
  
72
 
  g_object_unref (layout);
73
 
}
74
 
</programlisting>
75
 
</example>
76
 
 
77
 
<para>
78
 
Printing support was added in GTK+ 2.10.
79
 
</para>
80
 
 
81
 
<!-- ##### SECTION See_Also ##### -->
82
 
<para>
83
 
 
84
 
</para>
85
 
 
86
 
<!-- ##### SECTION Stability_Level ##### -->
87
 
 
88
 
 
89
 
<!-- ##### SECTION Image ##### -->
90
 
 
91
 
 
92
 
<!-- ##### STRUCT GtkPrintContext ##### -->
93
 
<para>
94
 
 
95
 
</para>
96
 
 
97
 
 
98
 
<!-- ##### FUNCTION gtk_print_context_get_cairo_context ##### -->
99
 
<para>
100
 
 
101
 
</para>
102
 
 
103
 
@context: 
104
 
@Returns: 
105
 
 
106
 
 
107
 
<!-- ##### FUNCTION gtk_print_context_set_cairo_context ##### -->
108
 
<para>
109
 
 
110
 
</para>
111
 
 
112
 
@context: 
113
 
@cr: 
114
 
@dpi_x: 
115
 
@dpi_y: 
116
 
 
117
 
 
118
 
<!-- ##### FUNCTION gtk_print_context_get_page_setup ##### -->
119
 
<para>
120
 
 
121
 
</para>
122
 
 
123
 
@context: 
124
 
@Returns: 
125
 
 
126
 
 
127
 
<!-- ##### FUNCTION gtk_print_context_get_width ##### -->
128
 
<para>
129
 
 
130
 
</para>
131
 
 
132
 
@context: 
133
 
@Returns: 
134
 
 
135
 
 
136
 
<!-- ##### FUNCTION gtk_print_context_get_height ##### -->
137
 
<para>
138
 
 
139
 
</para>
140
 
 
141
 
@context: 
142
 
@Returns: 
143
 
 
144
 
 
145
 
<!-- ##### FUNCTION gtk_print_context_get_dpi_x ##### -->
146
 
<para>
147
 
 
148
 
</para>
149
 
 
150
 
@context: 
151
 
@Returns: 
152
 
 
153
 
 
154
 
<!-- ##### FUNCTION gtk_print_context_get_dpi_y ##### -->
155
 
<para>
156
 
 
157
 
</para>
158
 
 
159
 
@context: 
160
 
@Returns: 
161
 
 
162
 
 
163
 
<!-- ##### FUNCTION gtk_print_context_get_pango_fontmap ##### -->
164
 
<para>
165
 
 
166
 
</para>
167
 
 
168
 
@context: 
169
 
@Returns: 
170
 
 
171
 
 
172
 
<!-- ##### FUNCTION gtk_print_context_create_pango_context ##### -->
173
 
<para>
174
 
 
175
 
</para>
176
 
 
177
 
@context: 
178
 
@Returns: 
179
 
 
180
 
 
181
 
<!-- ##### FUNCTION gtk_print_context_create_pango_layout ##### -->
182
 
<para>
183
 
 
184
 
</para>
185
 
 
186
 
@context: 
187
 
@Returns: 
188
 
 
189
 
 
190
 
<!-- ##### FUNCTION gtk_print_context_get_hard_margins ##### -->
191
 
<para>
192
 
 
193
 
</para>
194
 
 
195
 
@context: 
196
 
@top: 
197
 
@bottom: 
198
 
@left: 
199
 
@right: 
200
 
@Returns: 
201
 
 
202