gridP.h revision 3538fbe3
1/* $Xorg: gridP.h,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $ */
2/*
3
4Copyright 1993, 1998  The Open Group
5
6Permission to use, copy, modify, distribute, and sell this software and its
7documentation for any purpose is hereby granted without fee, provided that
8the above copyright notice appear in all copies and that both that
9copyright notice and this permission notice appear in supporting
10documentation.
11
12The above copyright notice and this permission notice shall be included
13in all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
19OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of The Open Group shall
24not be used in advertising or otherwise to promote the sale, use or
25other dealings in this Software without prior written authorization
26from The Open Group.
27
28*/
29/* $XFree86$ */
30
31#ifndef _FontGridP_h_
32#define _FontGridP_h_
33
34#include "grid.h"
35
36typedef struct _FontGridClassPart { int dummy; } FontGridClassPart;
37
38typedef struct _FontGridClassRec {
39    CoreClassPart	core_class;
40    SimpleClassPart	simple_class;
41    FontGridClassPart	grid_class;
42} FontGridClassRec;
43extern FontGridClassRec fontgridClassRec;
44
45typedef struct _FontGridPart {
46    XFontStruct *	text_font;		/* font to display */
47    int			cell_cols, cell_rows;  /* number of cells */
48    int			cell_width, cell_height;  /* size of cell */
49#ifndef XRENDER
50    Pixel		foreground_pixel;	/* color of text */
51#endif
52    Pixel		box_pixel;	/* for box_chars */
53    Boolean		center_chars;	/* center characters in grid */
54    Boolean		box_chars;	/* put box around logical width */
55    XtCallbackList	callbacks;	/* for notifying caller */
56    int			internal_pad;	/* extra padding inside grid */
57    long		start_char;	/* first character of grid */
58    int			grid_width;	/* width of grid lines */
59    /* private data */
60    GC			text_gc;	/* printing text */
61    GC			box_gc;		/* for box_chars */
62    int			xoff, yoff;	/* extra offsets within grid */
63#ifdef XRENDER
64    XftDraw		*draw;
65    XftColor		fg_color;
66    XftFont		*text_face;
67#endif
68} FontGridPart;
69
70typedef struct _FontGridRec {
71    CorePart		core;
72    SimplePart		simple;
73    FontGridPart	fontgrid;
74} FontGridRec;
75
76#ifdef XRENDER
77
78#define GridFontHeight(g)   ((g)->fontgrid.text_face ? \
79			     (g)->fontgrid.text_face->height : \
80			     (g)->fontgrid.text_font ? \
81			     (g)->fontgrid.text_font->ascent + \
82			     (g)->fontgrid.text_font->descent : 1)
83#define GridFontAscent(g)   ((g)->fontgrid.text_face ? \
84			     (g)->fontgrid.text_face->ascent : \
85			     (g)->fontgrid.text_font ? \
86			     (g)->fontgrid.text_font->ascent: 1)
87#define GridFontWidth(g)    ((g)->fontgrid.text_face ? \
88			     (g)->fontgrid.text_face->max_advance_width : \
89			     (g)->fontgrid.text_font ? \
90			     (g)->fontgrid.text_font->max_bounds.width : 1)
91#define GridForeground(g)   ((g)->fontgrid.fg_color.pixel)
92
93#else /* XRENDER */
94
95#define GridFontHeight(g)   ((g)->fontgrid.text_font->ascent + \
96			     (g)->fontgrid.text_font->descent)
97#define GridFontAscent(g)   ((g)->fontgrid.text_font ? \
98			     (g)->fontgrid.text_font->ascent: 1)
99#define GridFontWidth(g)    ((g)->fontgrid.text_font->max_bounds.width)
100#define GridForeground(g)   ((g)->fontgrid.foreground_pixel)
101
102#endif /* else XRENDER */
103
104#define DefaultCellWidth(fgw) (GridFontWidth(fgw) \
105			       + ((fgw)->fontgrid.internal_pad * 2))
106#define DefaultCellHeight(fgw) (GridFontHeight(fgw) + \
107				((fgw)->fontgrid.internal_pad * 2))
108
109#define CellWidth(fgw) (((int)(fgw)->core.width - (fgw)->fontgrid.grid_width) \
110			/ (fgw)->fontgrid.cell_cols \
111			- (fgw)->fontgrid.grid_width)
112#define CellHeight(fgw) (((int)(fgw)->core.height - (fgw)->fontgrid.grid_width)\
113			 / (fgw)->fontgrid.cell_rows \
114			 - (fgw)->fontgrid.grid_width)
115
116#endif /* !_FontGridP_h_ */
117