gridP.h 4.0 KB

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