1492e1cfeSmrg/*
2492e1cfeSmrg
3492e1cfeSmrgCopyright 1993, 1998  The Open Group
4492e1cfeSmrg
5492e1cfeSmrgPermission to use, copy, modify, distribute, and sell this software and its
6492e1cfeSmrgdocumentation for any purpose is hereby granted without fee, provided that
7492e1cfeSmrgthe above copyright notice appear in all copies and that both that
8492e1cfeSmrgcopyright notice and this permission notice appear in supporting
9492e1cfeSmrgdocumentation.
10492e1cfeSmrg
11492e1cfeSmrgThe above copyright notice and this permission notice shall be included
12492e1cfeSmrgin all copies or substantial portions of the Software.
13492e1cfeSmrg
14492e1cfeSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15492e1cfeSmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16492e1cfeSmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17492e1cfeSmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18492e1cfeSmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19492e1cfeSmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20492e1cfeSmrgOTHER DEALINGS IN THE SOFTWARE.
21492e1cfeSmrg
22492e1cfeSmrgExcept as contained in this notice, the name of The Open Group shall
23492e1cfeSmrgnot be used in advertising or otherwise to promote the sale, use or
24492e1cfeSmrgother dealings in this Software without prior written authorization
25492e1cfeSmrgfrom The Open Group.
26492e1cfeSmrg
27492e1cfeSmrg*/
28492e1cfeSmrg
29492e1cfeSmrg#ifndef _FontGridP_h_
30492e1cfeSmrg#define _FontGridP_h_
31492e1cfeSmrg
32492e1cfeSmrg#include "grid.h"
33492e1cfeSmrg
34492e1cfeSmrgtypedef struct _FontGridClassPart { int dummy; } FontGridClassPart;
35492e1cfeSmrg
36492e1cfeSmrgtypedef struct _FontGridClassRec {
37492e1cfeSmrg    CoreClassPart	core_class;
38492e1cfeSmrg    SimpleClassPart	simple_class;
39492e1cfeSmrg    FontGridClassPart	grid_class;
40492e1cfeSmrg} FontGridClassRec;
41492e1cfeSmrgextern FontGridClassRec fontgridClassRec;
42492e1cfeSmrg
43492e1cfeSmrgtypedef struct _FontGridPart {
44492e1cfeSmrg    XFontStruct *	text_font;		/* font to display */
45492e1cfeSmrg    int			cell_cols, cell_rows;  /* number of cells */
46492e1cfeSmrg    int			cell_width, cell_height;  /* size of cell */
47492e1cfeSmrg#ifndef XRENDER
48492e1cfeSmrg    Pixel		foreground_pixel;	/* color of text */
49492e1cfeSmrg#endif
50492e1cfeSmrg    Pixel		box_pixel;	/* for box_chars */
51492e1cfeSmrg    Boolean		center_chars;	/* center characters in grid */
52492e1cfeSmrg    Boolean		box_chars;	/* put box around logical width */
53492e1cfeSmrg    XtCallbackList	callbacks;	/* for notifying caller */
54492e1cfeSmrg    int			internal_pad;	/* extra padding inside grid */
55492e1cfeSmrg    long		start_char;	/* first character of grid */
56492e1cfeSmrg    int			grid_width;	/* width of grid lines */
57492e1cfeSmrg    /* private data */
58492e1cfeSmrg    GC			text_gc;	/* printing text */
59492e1cfeSmrg    GC			box_gc;		/* for box_chars */
60492e1cfeSmrg    int			xoff, yoff;	/* extra offsets within grid */
61492e1cfeSmrg#ifdef XRENDER
62492e1cfeSmrg    XftDraw		*draw;
63492e1cfeSmrg    XftColor		fg_color;
64492e1cfeSmrg    XftFont		*text_face;
65492e1cfeSmrg#endif
66492e1cfeSmrg} FontGridPart;
67492e1cfeSmrg
68492e1cfeSmrgtypedef struct _FontGridRec {
69492e1cfeSmrg    CorePart		core;
70492e1cfeSmrg    SimplePart		simple;
71492e1cfeSmrg    FontGridPart	fontgrid;
72492e1cfeSmrg} FontGridRec;
73492e1cfeSmrg
74492e1cfeSmrg#ifdef XRENDER
75492e1cfeSmrg
76492e1cfeSmrg#define GridFontHeight(g)   ((g)->fontgrid.text_face ? \
77492e1cfeSmrg			     (g)->fontgrid.text_face->height : \
78492e1cfeSmrg			     (g)->fontgrid.text_font ? \
79492e1cfeSmrg			     (g)->fontgrid.text_font->ascent + \
80492e1cfeSmrg			     (g)->fontgrid.text_font->descent : 1)
81492e1cfeSmrg#define GridFontAscent(g)   ((g)->fontgrid.text_face ? \
82492e1cfeSmrg			     (g)->fontgrid.text_face->ascent : \
83492e1cfeSmrg			     (g)->fontgrid.text_font ? \
84492e1cfeSmrg			     (g)->fontgrid.text_font->ascent: 1)
85492e1cfeSmrg#define GridFontWidth(g)    ((g)->fontgrid.text_face ? \
86492e1cfeSmrg			     (g)->fontgrid.text_face->max_advance_width : \
87492e1cfeSmrg			     (g)->fontgrid.text_font ? \
88492e1cfeSmrg			     (g)->fontgrid.text_font->max_bounds.width : 1)
89492e1cfeSmrg#define GridForeground(g)   ((g)->fontgrid.fg_color.pixel)
903538fbe3Smrg
91492e1cfeSmrg#else /* XRENDER */
923538fbe3Smrg
93492e1cfeSmrg#define GridFontHeight(g)   ((g)->fontgrid.text_font->ascent + \
94492e1cfeSmrg			     (g)->fontgrid.text_font->descent)
95492e1cfeSmrg#define GridFontAscent(g)   ((g)->fontgrid.text_font ? \
96492e1cfeSmrg			     (g)->fontgrid.text_font->ascent: 1)
97492e1cfeSmrg#define GridFontWidth(g)    ((g)->fontgrid.text_font->max_bounds.width)
98492e1cfeSmrg#define GridForeground(g)   ((g)->fontgrid.foreground_pixel)
993538fbe3Smrg
100492e1cfeSmrg#endif /* else XRENDER */
101492e1cfeSmrg
102492e1cfeSmrg#define DefaultCellWidth(fgw) (GridFontWidth(fgw) \
103492e1cfeSmrg			       + ((fgw)->fontgrid.internal_pad * 2))
104492e1cfeSmrg#define DefaultCellHeight(fgw) (GridFontHeight(fgw) + \
105492e1cfeSmrg				((fgw)->fontgrid.internal_pad * 2))
106492e1cfeSmrg
107492e1cfeSmrg#define CellWidth(fgw) (((int)(fgw)->core.width - (fgw)->fontgrid.grid_width) \
108492e1cfeSmrg			/ (fgw)->fontgrid.cell_cols \
109492e1cfeSmrg			- (fgw)->fontgrid.grid_width)
110492e1cfeSmrg#define CellHeight(fgw) (((int)(fgw)->core.height - (fgw)->fontgrid.grid_width)\
111492e1cfeSmrg			 / (fgw)->fontgrid.cell_rows \
112492e1cfeSmrg			 - (fgw)->fontgrid.grid_width)
113492e1cfeSmrg
114492e1cfeSmrg#endif /* !_FontGridP_h_ */
115