*** empty log message ***
[m17n/m17n-lib.git] / src / face.h
1 /* face.h -- header file for the face module.
2    Copyright (C) 2003, 2004
3      National Institute of Advanced Industrial Science and Technology (AIST)
4      Registration Number H15PRO112
5
6    This file is part of the m17n library.
7
8    The m17n library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Lesser General Public License
10    as published by the Free Software Foundation; either version 2.1 of
11    the License, or (at your option) any later version.
12
13    The m17n library is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    Lesser General Public License for more details.
17
18    You should have received a copy of the GNU Lesser General Public
19    License along with the m17n library; if not, write to the Free
20    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21    02111-1307, USA.  */
22
23 #ifndef _M17N_FACE_H_
24 #define _M17N_FACE_H_
25
26 enum MFaceProperty
27   {
28     /** The font related properties.  */
29     /* The order of MFACE_FOUNDRY to MFACE_ADSTYLE must be the same as
30        enum MFontProperty.  */
31     MFACE_FOUNDRY,
32     MFACE_FAMILY,
33     MFACE_WEIGHT,
34     MFACE_STYLE,
35     MFACE_STRETCH,
36     MFACE_ADSTYLE,
37     MFACE_SIZE,
38     MFACE_FONTSET,
39
40     /** The color related properties.   */
41     MFACE_FOREGROUND,
42     MFACE_BACKGROUND,
43
44     /** The other properties.   */
45     MFACE_HLINE,
46     MFACE_BOX,
47     MFACE_VIDEOMODE,
48
49     /** Extention by applications.  */
50     MFACE_HOOK_FUNC,
51     MFACE_HOOK_ARG,
52
53     /* In a realized face, this is already reflected in MFACE_SIZE,
54        thus is ignored.  */
55     MFACE_RATIO,
56
57     MFACE_PROPERTY_MAX
58   };
59
60 struct MFace
61 {
62   M17NObject control;
63   /* Initialized to 0, and incremented by one each the face is
64      modified.  */
65   unsigned tick;
66   void *property[MFACE_PROPERTY_MAX];
67 };
68
69
70 enum face_gc
71   {
72     MFACE_GC_NORMAL,
73     MFACE_GC_INVERSE,
74     MFACE_GC_SCRATCH,
75     MFACE_GC_HLINE,
76     MFACE_GC_BOX_TOP,
77     MFACE_GC_BOX_BOTTOM,
78     MFACE_GC_BOX_LEFT,
79     MFACE_GC_BOX_RIGHT,
80     MFACE_GCS
81   };
82
83 /** A realized face is registered in MFrame->face_list, thus it does
84     not have to be a managed object.  */
85
86 struct MRealizedFace
87 {
88   /** Frame on which this realized face is created.  */
89   MFrame *frame;
90
91   /** Properties of all stacked faces are merged into here.  */
92   MFace face;
93
94   /** From what faces this is realized.  Keys are Mface and values are
95      (MFace *).  */
96   MPlist *base_face_list;
97
98   /* Initialized to the sum of ticks of the above faces.  */
99   unsigned tick;
100
101   /* Realized font, one of <frame>->realized_font_list.  */
102   MRealizedFont *rfont;
103
104   /* Realized fontset, one of <frame>->realized_fontset_list.  */
105   MRealizedFontset *rfontset;
106
107   MSymbol layouter;
108
109   MFaceHLineProp *hline;
110
111   MFaceBoxProp *box;
112
113   /** Realized face for ASCII chars that has the same face
114       properties. */
115   MRealizedFace *ascii_rface;
116
117   /** Realized face for undisplayable chars (no font found) that has
118       the same face properties. */
119   MRealizedFace *nofont_rface;
120
121   int ascent, descent;
122   int space_width;
123
124   /** Pointer to a window system dependent object.  */
125   void *info;
126 };
127
128
129 extern MFace *mface__default;
130
131 extern MRealizedFace *mface__realize (MFrame *frame, MFace **faces, int num,
132                                       MSymbol language, MSymbol charset,
133                                       int limitted_size);
134
135 extern MGlyph *mface__for_chars (MSymbol script, MSymbol language,
136                                  MSymbol charset, MGlyph *from_g, MGlyph *to_g,
137                                  int size);
138
139 extern void mface__free_realized (MRealizedFace *rface);
140
141 #endif /* _M17N_FACE_H_ */