1 /* $Xorg: gridP.h,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $ */
4 Copyright 1993, 1998 The Open Group
6 Permission to use, copy, modify, distribute, and sell this software and its
7 documentation for any purpose is hereby granted without fee, provided that
8 the above copyright notice appear in all copies and that both that
9 copyright notice and this permission notice appear in supporting
12 The above copyright notice and this permission notice shall be included
13 in all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 OTHER DEALINGS IN THE SOFTWARE.
23 Except as contained in this notice, the name of The Open Group shall
24 not be used in advertising or otherwise to promote the sale, use or
25 other dealings in this Software without prior written authorization
36 typedef struct _FontGridClassPart { int dummy; } FontGridClassPart;
38 typedef struct _FontGridClassRec {
39 CoreClassPart core_class;
40 SimpleClassPart simple_class;
41 FontGridClassPart grid_class;
43 extern FontGridClassRec fontgridClassRec;
45 typedef 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 */
50 Pixel foreground_pixel; /* color of text */
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 */
60 GC text_gc; /* printing text */
61 GC box_gc; /* for box_chars */
62 int xoff, yoff; /* extra offsets within grid */
70 typedef struct _FontGridRec {
73 FontGridPart fontgrid;
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)
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)
102 #endif /* else XRENDER */
104 #define DefaultCellWidth(fgw) (GridFontWidth(fgw) \
105 + ((fgw)->fontgrid.internal_pad * 2))
106 #define DefaultCellHeight(fgw) (GridFontHeight(fgw) + \
107 ((fgw)->fontgrid.internal_pad * 2))
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)
116 #endif /* !_FontGridP_h_ */