1 /* gtkplotpc - gtkplot print context - a renderer for printing functions 2 * Copyright 1999-2001 Adrian E. Feiguin <feiguin@ifir.edu.ar> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public 15 * License along with this library; if not, write to the 16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 * Boston, MA 02111-1307, USA. 18 */ 19 20 #ifndef __GTK_PLOT_PC_H__ 21 #define __GTK_PLOT_PC_H__ 22 23 #include <stdio.h> 24 #include "gtkpsfont.h" 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif /* __cplusplus */ 29 30 31 #define GTK_PLOT_PC(obj) GTK_CHECK_CAST (obj, gtk_plot_pc_get_type (), GtkPlotPC) 32 #define GTK_TYPE_PLOT_PC (gtk_plot_pc_get_type ()) 33 34 #define GTK_PLOT_PC_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_plot_pc_get_type(), GtkPlotPCClass) 35 #define GTK_IS_PLOT_PC(obj) GTK_CHECK_TYPE (obj, gtk_plot_pc_get_type ()) 36 37 38 /* Page size */ 39 40 typedef enum{ 41 GTK_PLOT_LETTER , 42 GTK_PLOT_LEGAL , 43 GTK_PLOT_A4 , 44 GTK_PLOT_EXECUTIVE , 45 GTK_PLOT_CUSTOM 46 } GtkPlotPageSize; 47 48 #define GTK_PLOT_LETTER_W 612 /* Width and Height in ps points */ 49 #define GTK_PLOT_LETTER_H 792 50 51 #define GTK_PLOT_LEGAL_W 612 52 #define GTK_PLOT_LEGAL_H 1008 53 54 #define GTK_PLOT_A4_W 595 55 #define GTK_PLOT_A4_H 842 56 57 #define GTK_PLOT_EXECUTIVE_W 540 58 #define GTK_PLOT_EXECUTIVE_H 720 59 60 61 /* Page orientation */ 62 typedef enum{ 63 GTK_PLOT_PORTRAIT , 64 GTK_PLOT_LANDSCAPE 65 } GtkPlotPageOrientation; 66 67 /* Size units */ 68 typedef enum{ 69 GTK_PLOT_PSPOINTS , 70 GTK_PLOT_MM , 71 GTK_PLOT_CM , 72 GTK_PLOT_INCHES 73 } GtkPlotUnits; 74 75 76 typedef struct _GtkPlotPC GtkPlotPC; 77 typedef struct _GtkPlotPCClass GtkPlotPCClass; 78 typedef struct _GtkPlotPoint GtkPlotPoint; 79 80 struct _GtkPlotPoint 81 { 82 gdouble x, y; 83 }; 84 85 struct _GtkPlotPC 86 { 87 GtkObject object; 88 89 gdouble width, height; /* viewport */ 90 GdkColor color; 91 92 gint init_count; 93 gboolean use_pixmap; 94 }; 95 96 97 struct _GtkPlotPCClass 98 { 99 GtkObjectClass parent_class; 100 101 gboolean (* init) (GtkPlotPC *pc); 102 103 void (* leave) (GtkPlotPC *pc); 104 105 void (* set_viewport) (GtkPlotPC *pc, 106 gdouble w, gdouble h); 107 108 void (* gsave) (GtkPlotPC *pc); 109 110 void (* grestore) (GtkPlotPC *pc); 111 112 void (* clip) (GtkPlotPC *pc, 113 const GdkRectangle *area); 114 void (* clip_mask) (GtkPlotPC *pc, 115 gdouble x, 116 gdouble y, 117 const GdkBitmap *mask); 118 119 void (* set_color) (GtkPlotPC *pc, 120 const GdkColor *color); 121 122 void (* set_lineattr) (GtkPlotPC *pc, 123 gfloat line_width, 124 GdkLineStyle line_style, 125 GdkCapStyle cap_style, 126 GdkJoinStyle join_style); 127 128 void (* set_dash) (GtkPlotPC *pc, 129 gdouble offset_, 130 gdouble *values, 131 gint num_values); 132 133 void (* draw_point) (GtkPlotPC *pc, 134 gdouble x, gdouble y); 135 136 void (* draw_line) (GtkPlotPC *pc, 137 gdouble x1, gdouble y1, 138 gdouble x2, gdouble y2); 139 140 void (* draw_lines) (GtkPlotPC *pc, 141 GtkPlotPoint *points, 142 gint numpoints); 143 144 void (* draw_rectangle) (GtkPlotPC *pc, 145 gboolean filled, 146 gdouble x, gdouble y, 147 gdouble width, 148 gdouble height); 149 150 void (* draw_polygon) (GtkPlotPC *pc, 151 gboolean filled, 152 GtkPlotPoint *points, 153 gint numpoints); 154 155 void (* draw_circle) (GtkPlotPC *pc, 156 gboolean filled, 157 gdouble x, gdouble y, 158 gdouble size); 159 160 void (* draw_ellipse) (GtkPlotPC *pc, 161 gboolean filled, 162 gdouble x, gdouble y, 163 gdouble width, 164 gdouble height); 165 166 void (* set_font) (GtkPlotPC *pc, 167 GtkPSFont *psfont, 168 gint height); 169 170 void (* draw_string) (GtkPlotPC *pc, 171 gint x, gint y, 172 gint angle, 173 const GdkColor *fg, 174 const GdkColor *bg, 175 gboolean transparent, 176 gint border, 177 gint border_space, 178 gint border_width, 179 gint shadow_width, 180 const gchar *font, 181 gint height, 182 GtkJustification just, 183 const gchar *text); 184 185 void (* draw_pixmap) (GtkPlotPC *pc, 186 GdkPixmap *pixmap, 187 GdkBitmap *mask, 188 gint xsrc, gint ysrc, 189 gint xdest, gint ydest, 190 gint width, 191 gint height, 192 gdouble scale_x, 193 gdouble scale_y); 194 }; 195 196 GtkType gtk_plot_pc_get_type (void); 197 GtkObject *gtk_plot_pc_new (void); 198 199 gboolean gtk_plot_pc_init (GtkPlotPC *pc); 200 201 void gtk_plot_pc_leave (GtkPlotPC *pc); 202 void gtk_plot_pc_set_viewport (GtkPlotPC *pc, 203 gdouble w, gdouble h); 204 205 void gtk_plot_pc_gsave (GtkPlotPC *pc); 206 207 void gtk_plot_pc_grestore (GtkPlotPC *pc); 208 209 void gtk_plot_pc_clip (GtkPlotPC *pc, 210 GdkRectangle *area); 211 void gtk_plot_pc_clip_mask (GtkPlotPC *pc, 212 gdouble x, 213 gdouble y, 214 GdkBitmap *mask); 215 216 void gtk_plot_pc_set_color (GtkPlotPC *pc, 217 GdkColor *color); 218 219 void gtk_plot_pc_set_lineattr (GtkPlotPC *pc, 220 gfloat line_width, 221 GdkLineStyle line_style, 222 GdkCapStyle cap_style, 223 GdkJoinStyle join_style); 224 225 void gtk_plot_pc_set_dash (GtkPlotPC *pc, 226 gdouble offset_, 227 gdouble *values, 228 gint num_values); 229 230 void gtk_plot_pc_draw_point (GtkPlotPC *pc, 231 gdouble x, gdouble y); 232 233 void gtk_plot_pc_draw_line (GtkPlotPC *pc, 234 gdouble x1, gdouble y1, 235 gdouble x2, gdouble y2); 236 237 void gtk_plot_pc_draw_lines (GtkPlotPC *pc, 238 GtkPlotPoint *points, 239 gint numpoints); 240 241 void gtk_plot_pc_draw_rectangle (GtkPlotPC *pc, 242 gboolean filled, 243 gdouble x, gdouble y, 244 gdouble width, 245 gdouble height); 246 247 void gtk_plot_pc_draw_polygon (GtkPlotPC *pc, 248 gint filled, 249 GtkPlotPoint *points, 250 gint numpoints); 251 252 void gtk_plot_pc_draw_ellipse (GtkPlotPC *pc, 253 gboolean filled, 254 gdouble x, gdouble y, 255 gdouble width, 256 gdouble height); 257 258 void gtk_plot_pc_draw_circle (GtkPlotPC *pc, 259 gint filled, 260 gdouble x, gdouble y, 261 gdouble size); 262 263 void gtk_plot_pc_set_font (GtkPlotPC *pc, 264 GtkPSFont *psfont, 265 gint height); 266 267 void gtk_plot_pc_draw_string (GtkPlotPC *pc, 268 gint x, gint y, 269 gint angle, 270 const GdkColor *fg, 271 const GdkColor *bg, 272 gboolean transparent, 273 gint border, 274 gint border_space, 275 gint border_width, 276 gint shadow_width, 277 const gchar *font, 278 gint height, 279 GtkJustification just, 280 const gchar *text); 281 282 void gtk_plot_pc_draw_pixmap (GtkPlotPC *pc, 283 GdkPixmap *pixmap, 284 GdkBitmap *mask, 285 gint xsrc, gint ysrc, 286 gint xdest, gint ydest, 287 gint width, 288 gint height, 289 gdouble scale_x, 290 gdouble scale_y); 291 292 #ifdef __cplusplus 293 } 294 #endif /* __cplusplus */ 295 296 297 #endif /* __GTK_PLOT_PC_H__ */ 298 299