1 /* Lasem 2 * 3 * Copyright © 2009 Emmanuel Pacaud 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General 16 * Public License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 18 * Boston, MA 02111-1307, USA. 19 * 20 * Author: 21 * Emmanuel Pacaud <emmanuel@gnome.org> 22 */ 23 24 #ifndef LSM_DOM_VIEW_H 25 #define LSM_DOM_VIEW_H 26 27 #include <lsmdomtypes.h> 28 #include <lsmutils.h> 29 #include <cairo.h> 30 #include <pango/pangocairo.h> 31 32 G_BEGIN_DECLS 33 34 #define LSM_DOM_VIEW_DEFAULT_RESOLUTION 72.0 35 #define LSM_DOM_VIEW_DEFAULT_VIEWBOX_WIDTH 320.0 36 #define LSM_DOM_VIEW_DEFAULT_VIEWBOX_HEIGHT 200.0 37 38 #define LSM_TYPE_DOM_VIEW (lsm_dom_view_get_type ()) 39 #define LSM_DOM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LSM_TYPE_DOM_VIEW, LsmDomView)) 40 #define LSM_DOM_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LSM_TYPE_DOM_VIEW, LsmDomViewClass)) 41 #define LSM_IS_DOM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LSM_TYPE_DOM_VIEW)) 42 #define LSM_IS_DOM_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LSM_TYPE_DOM_VIEW)) 43 #define LSM_DOM_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), LSM_TYPE_DOM_VIEW, LsmDomViewClass)) 44 45 typedef struct _LsmDomViewClass LsmDomViewClass; 46 47 struct _LsmDomView { 48 GObject object; 49 50 LsmDomDocument * document; 51 52 PangoFontDescription * font_description; 53 PangoLayout * pango_layout; 54 PangoLayout * measure_pango_layout; 55 cairo_t * cairo; 56 gboolean is_vector; 57 58 double resolution_ppi; 59 LsmBox viewport_pt; 60 }; 61 62 struct _LsmDomViewClass { 63 GObjectClass parent_class; 64 65 GType document_type; 66 67 void (*measure) (LsmDomView *view, double *width, double *height, double *baseline); 68 void (*render) (LsmDomView *view); 69 void (*set_debug) (LsmDomView *view, const char *feature, gboolean enable); 70 }; 71 72 GType lsm_dom_view_get_type (void); 73 74 double lsm_dom_view_get_resolution (LsmDomView *self); 75 void lsm_dom_view_set_resolution (LsmDomView *self, double ppi); 76 77 void lsm_dom_view_set_viewport (LsmDomView *self, const LsmBox *viewport_pt); 78 void lsm_dom_view_set_viewport_pixels(LsmDomView *self, const LsmBox *viewport); 79 LsmBox lsm_dom_view_get_viewport (LsmDomView *self); 80 LsmBox lsm_dom_view_get_viewport_pixels(LsmDomView *self); 81 82 void lsm_dom_view_render (LsmDomView *view, cairo_t *cairo, double x, double y); 83 84 void lsm_dom_view_get_size (LsmDomView *view, double *width, double *height, double *baseline); 85 void lsm_dom_view_get_size_pixels (LsmDomView *view, unsigned int *width, unsigned int *height, 86 unsigned int *baseline); 87 88 void lsm_dom_view_set_debug (LsmDomView *view, const char *feature, gboolean enable); 89 90 void lsm_dom_view_set_document (LsmDomView *view, LsmDomDocument *document); 91 92 G_END_DECLS 93 94 #endif 95