File: test-common.c

package info (click to toggle)
libgnomeprintui 2.18.3-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,352 kB
  • ctags: 1,907
  • sloc: ansic: 14,837; sh: 11,426; xml: 1,776; makefile: 281
file content (156 lines) | stat: -rw-r--r-- 6,000 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include "test-common.h"

void
test_print_page (GnomePrintContext *pc, guint page)
{
	gint i, j;
        gint max_i = 10;
        gint max_j = 10;
        gint size, spacing, x, y;
        GnomeFont *font;
        gchar *txt;
 
				txt = g_strdup_printf ("Test page %i", page);
        gnome_print_beginpage (pc, (const guchar *) txt);
				g_free (txt);
         
        font = gnome_font_find_closest ((const guchar *) "Times New Roman", 44);
        gnome_print_setfont (pc, font);
 
        gnome_print_moveto (pc, 50, 50);
        gnome_print_show (pc, (const guchar *) "Print Preview test");
 
        txt = g_strdup_printf ("Page %i", page);
        gnome_print_moveto (pc, 50, 800);
        gnome_print_show (pc, (const guchar *) txt);
        g_free (txt);
 
        gnome_print_moveto (pc, 50, 100);
        gnome_print_lineto (pc, 450, 100);
        gnome_print_lineto (pc, 450, 150);
        gnome_print_lineto (pc, 50, 150);
        gnome_print_closepath (pc);
        gnome_print_fill (pc);

        gnome_print_setrgbcolor (pc, 1, 1, 1);
        gnome_print_moveto (pc, 55, 105);
        gnome_print_show (pc, (const guchar *) "Inverted text");
 
        gnome_print_setrgbcolor (pc, 1, 0, 0);
        gnome_print_moveto (pc, 55, 160);
        gnome_print_show (pc, (const guchar *) "Red");
 
        gnome_print_setrgbcolor (pc, 0, 1, 0);
        gnome_print_moveto (pc, 155, 160);
        gnome_print_show (pc, (const guchar *) "Green");
 
        gnome_print_setrgbcolor (pc, 0, 0, 1);
        gnome_print_moveto (pc, 305, 160);
        gnome_print_show (pc, (const guchar *) "Blue");
         
        for (i = 0; i < max_i; i++) {
                for (j = 0; j < max_j; j++) {
                        gdouble r;
                        gdouble g;
                        gdouble b;
 
                        r = ((gdouble) i) / ((gdouble) max_i);
                        g = ((gdouble) j) / ((gdouble) max_j);
                        b = 1 - r;
 
                        size = 15;
                        spacing = size + 2;
                        x = 100;
                        y = 250;
 
                        gnome_print_setrgbcolor (pc, r, g, b);
                        gnome_print_moveto (pc, x + (i * spacing), y + (j * spacing));
                        gnome_print_lineto (pc, x + (i * spacing), y + (j * spacing) + size);
                        gnome_print_lineto (pc, x + (i * spacing) + size, y + (j * spacing) + size);
                        gnome_print_lineto (pc, x + (i * spacing) + size, y + (j * spacing));
                        gnome_print_closepath (pc);
                        gnome_print_fill (pc);
                }
        }
 
        for (i = 0; i < max_i; i++) {
                for (j = 0; j < max_j; j++) {
                        gdouble r;
                        gdouble g;
                        gdouble b;
 
                        r = ((gdouble) i) / ((gdouble) max_i);
                        g = ((gdouble) j) / ((gdouble) max_j);
                        b = 1 - r;
 
                        size = 15;
                        spacing = size + 2;
                        x = 300;
                        y = y;
 
                        gnome_print_setrgbcolor (pc, r, g, b);
                        gnome_print_moveto (pc, x + (i * spacing), y + (j * spacing));
                        gnome_print_lineto (pc, x + (i * spacing), y + (j * spacing) + size);
                        gnome_print_lineto (pc, x + (i * spacing) + size, y + (j * spacing) + size);
                        gnome_print_lineto (pc, x + (i * spacing) + size, y + (j * spacing));
                        gnome_print_closepath (pc);
                        gnome_print_stroke (pc);
                }
        }
 
 
        for (i = 0; i < max_i; i++) {
                for (j = 0; j < max_j; j++) {
                        gdouble r;
                        gdouble g;
                        gdouble b;
 
                        r = ((gdouble) i) / ((gdouble) max_i);
                        g = r;
                        b = r;
 
                        size = 15;
                        spacing = size + 2;
                        x = 100;
                        y = 450;
 
                        gnome_print_setrgbcolor (pc, r, g, b);
                        gnome_print_moveto (pc, x + (i * spacing), y + (j * spacing));
                        gnome_print_lineto (pc, x + (i * spacing), y + (j * spacing) + size);
                        gnome_print_lineto (pc, x + (i * spacing) + size, y + (j * spacing) + size);
                        gnome_print_lineto (pc, x + (i * spacing) + size, y + (j * spacing));
                        gnome_print_closepath (pc);
                        gnome_print_stroke (pc);
                }
        }
 
        for (i = 0; i < max_i; i++) {
                for (j = 0; j < max_j; j++) {
                        gdouble r;
                        gdouble g;
                        gdouble b;
 
                        r = ((gdouble) i) / ((gdouble) max_i);
                        g = r;
                        b = r;
 
                        size = 15;
                        spacing = size + 2;
                        x = 300;
                        y = 450;
 
                        gnome_print_setrgbcolor (pc, r, g, b);
                        gnome_print_moveto (pc, x + (i * spacing), y + (j * spacing));
                        gnome_print_lineto (pc, x + (i * spacing), y + (j * spacing) + size);
                        gnome_print_lineto (pc, x + (i * spacing) + size, y + (j * spacing) + size);
                        gnome_print_lineto (pc, x + (i * spacing) + size, y + (j * spacing));
                        gnome_print_closepath (pc);
                        gnome_print_fill (pc);
                }
        }

				gnome_print_setopacity (pc, 0.3);
				gnome_print_setrgbcolor (pc, 255., 0., 0.);
				gnome_print_rect_filled (pc, 240., 50., 100., 450.);
        gnome_print_showpage (pc);
}