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