1 /*
2  * Copyright (C) 2003 Red Hat, Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 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  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18 
19 /* The interfaces in this file are subject to change at any time. */
20 
21 #ifndef vte_vtedraw_h_included
22 #define vte_vtedraw_h_included
23 
24 
25 #include <glib.h>
26 #include <gtk/gtk.h>
27 #include <cairo.h>
28 #include "vte.h"
29 #include "vteunistr.h"
30 
31 G_BEGIN_DECLS
32 
33 #define VTE_DRAW_SINGLE_WIDE_CHARACTERS	\
34 					" !\"#$%&'()*+,-./" \
35 					"0123456789" \
36 					":;<=>?@" \
37 					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
38 					"[\\]^_`" \
39 					"abcdefghijklmnopqrstuvwxyz" \
40 					"{|}~" \
41 					""
42 #define VTE_DRAW_DOUBLE_WIDE_CHARACTERS 0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x4e94,\
43 					0xac00, 0xac01, 0xac04, 0xac08, 0xac10
44 /* For Pango, we have to use CJK Ideographs alone. Otherwise, 'width'
45    returned by pango_layout would be screwed up for Chinese and Japanese
46    fonts without Hangul */
47 #define VTE_DRAW_DOUBLE_WIDE_IDEOGRAPHS 0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x4e94
48 #define VTE_DRAW_OPAQUE 0xff
49 #define VTE_DRAW_MAX_LENGTH 1024
50 
51 #define VTE_DRAW_NORMAL 0
52 #define VTE_DRAW_BOLD   1
53 #define VTE_DRAW_ITALIC 2
54 
55 struct _vte_draw;
56 
57 /* A request to draw a particular character spanning a given number of columns
58    at the given location.  Unlike most APIs, (x,y) specifies the top-left
59    corner of the cell into which the character will be drawn instead of the
60    left end of the baseline. */
61 struct _vte_draw_text_request {
62 	vteunistr c;
63 	gshort x, y, columns;
64 };
65 
66 guint _vte_draw_get_style(gboolean bold, gboolean italic);
67 
68 /* Create and destroy a draw structure. */
69 struct _vte_draw *_vte_draw_new(void);
70 void _vte_draw_free(struct _vte_draw *draw);
71 
72 cairo_t *_vte_draw_get_context (struct _vte_draw *draw);
73 
74 void _vte_draw_set_cairo(struct _vte_draw *draw,
75                          cairo_t *cr);
76 
77 void _vte_draw_set_background_solid(struct _vte_draw *draw,
78                                     const GdkRGBA *color);
79 
80 void _vte_draw_clear(struct _vte_draw *draw,
81 		     gint x, gint y, gint width, gint height);
82 
83 void _vte_draw_set_text_font(struct _vte_draw *draw,
84                              GtkWidget *widget,
85 			     const PangoFontDescription *fontdesc);
86 void _vte_draw_get_text_metrics(struct _vte_draw *draw,
87 				gint *width, gint *height, gint *ascent);
88 int _vte_draw_get_char_width(struct _vte_draw *draw, vteunistr c, int columns,
89 			     guint style);
90 gboolean _vte_draw_has_bold (struct _vte_draw *draw, guint style);
91 
92 void _vte_draw_text(struct _vte_draw *draw,
93 		    struct _vte_draw_text_request *requests, gsize n_requests,
94 		    const PangoColor *color, guchar alpha, guint style);
95 gboolean _vte_draw_char(struct _vte_draw *draw,
96 			struct _vte_draw_text_request *request,
97 			const PangoColor *color, guchar alpha, guint style);
98 gboolean _vte_draw_has_char(struct _vte_draw *draw, vteunistr c, guint style);
99 
100 void _vte_draw_fill_rectangle(struct _vte_draw *draw,
101 			      gint x, gint y, gint width, gint height,
102 			      const PangoColor *color, guchar alpha);
103 void _vte_draw_draw_rectangle(struct _vte_draw *draw,
104 			      gint x, gint y, gint width, gint height,
105 			      const PangoColor *color, guchar alpha);
106 void _vte_draw_set_source_color_alpha (struct _vte_draw *draw,
107                                        const PangoColor *color,
108                                        guchar            alpha);
109 
110 G_END_DECLS
111 
112 #endif
113