Debian Codegraph @

generic/bltText.h

raw symbols SCIP
1 /*
2 * bltText.h --
3 *
4 * Copyright 1993-1998 Lucent Technologies, Inc.
5 *
6 * Permission to use, copy, modify, and distribute this software and
7 * its documentation for any purpose and without fee is hereby
8 * granted, provided that the above copyright notice appear in all
9 * copies and that both that the copyright notice and warranty
10 * disclaimer appear in supporting documentation, and that the names
11 * of Lucent Technologies any of their entities not be used in
12 * advertising or publicity pertaining to distribution of the software
13 * without specific, written prior permission.
14 *
15 * Lucent Technologies disclaims all warranties with regard to this
16 * software, including all implied warranties of merchantability and
17 * fitness. In no event shall Lucent Technologies be liable for any
18 * special, indirect or consequential damages or any damages
19 * whatsoever resulting from loss of use, data or profits, whether in
20 * an action of contract, negligence or other tortuous action, arising
21 * out of or in connection with the use or performance of this
22 * software.
23 */
24
25 #ifndef _BLT_TEXT_H
26 #define _BLT_TEXT_H
27
28 #if (TK_MAJOR_VERSION == 4)
29
30 /*
31 * The following structure is used by Tk_GetFontMetrics() to return
32 * information about the properties of a Tk_Font.
33 */
34 typedef struct {
35 int ascent; /* The amount in pixels that the tallest
36 * letter sticks up above the baseline, plus
37 * any extra blank space added by the designer
38 * of the font. */
39 int descent; /* The largest amount in pixels that any
40 * letter sticks below the baseline, plus any
41 * extra blank space added by the designer of
42 * the font. */
43 int linespace; /* The sum of the ascent and descent. How
44 * far apart two lines of text in the same
45 * font should be placed so that none of the
46 * characters in one line overlap any of the
47 * characters in the other line. */
48 } Tk_FontMetrics;
49
50 typedef XFontStruct *Tk_Font;
51
52 #define Tk_FontId(font) ((font)->fid)
53 #define Tk_TextWidth(font, str, len) (XTextWidth((font),(str),(len)))
54 #define Tk_GetFontMetrics(font, fmPtr) \
55 ((fmPtr)->ascent = (font)->ascent, \
56 (fmPtr)->descent = (font)->descent, \
57 (fmPtr)->linespace = (font)->ascent + (font)->descent)
58
59 #define Tk_NameOfFont(font) (Tk_NameOfFontStruct(font))
60 #define Tk_DrawChars(dpy, draw, gc, font, str, len, x, y) \
61 TkDisplayChars((dpy),(draw),(gc),(font),(str),(len),(x),(y), 0, DEF_TEXT_FLAGS)
62
63 #define Tk_MeasureChars(font, text, len, maxPixels, flags, lenPtr) \
64 TkMeasureChars((font),(text), (len), 0, maxPixels, 0,(flags), (lenPtr))
65
66 extern int TkMeasureChars _ANSI_ARGS_((Tk_Font font, char *source,
67 int maxChars, int startX, int maxX, int tabOrigin, int flags,
68 int *nextXPtr));
69 extern void TkDisplayChars _ANSI_ARGS_((Display *display, Drawable drawable,
70 GC gc, Tk_Font font, char *string, int length, int x, int y,
71 int tabOrigin, int flags));
72 /*
73 * FLAGS passed to TkMeasureChars:
74 */
75 #define TK_WHOLE_WORDS (1<<0)
76 #define TK_AT_LEAST_ONE (1<<1)
77 #define TK_PARTIAL_OK (1<<2)
78 #define TK_IGNORE_NEWLINES (1<<3)
79 #define TK_IGNORE_TABS (1<<4)
80 #define NO_FLAGS 0
81
82 #endif /* TK_MAJOR_VERSION == 4 */
83
84 #define DEF_TEXT_FLAGS (TK_PARTIAL_OK | TK_IGNORE_NEWLINES)
85
86
87
88 /*
89 * ----------------------------------------------------------------------
90 *
91 * TextFragment --
92 *
93 * ----------------------------------------------------------------------
94 */
95 typedef struct {
96 char *text; /* Text to be displayed */
97
98 short int x, y; /* X-Y offset of the baseline from the
99 * upper-left corner of the bbox. */
100
101 short int sx, sy; /* See bltWinUtil.c */
102
103 short int count; /* Number of bytes in text. The actual
104 * character count may differ because of
105 * multi-byte UTF encodings. */
106
107 short int width; /* Width of segment in pixels. This
108 * information is used to draw
109 * PostScript strings the same width
110 * as X. */
111 } TextFragment;
112
113 /*
114 * ----------------------------------------------------------------------
115 *
116 * TextLayout --
117 *
118 * ----------------------------------------------------------------------
119 */
120 typedef struct {
121 int nFrags; /* # fragments of text */
122 short int width, height; /* Dimensions of text bounding box */
123 TextFragment fragArr[1]; /* Information about each fragment of text */
124 int rotated;
125 } TextLayout;
126
127 typedef struct {
128 XColor *color;
129 int offset;
130 } Shadow;
131
132 /*
133 * ----------------------------------------------------------------------
134 *
135 * TextStyle --
136 *
137 * Represents a convenient structure to hold text attributes
138 * which determine how a text string is to be displayed on the
139 * window, or drawn with PostScript commands. The alternative
140 * is to pass lots of parameters to the drawing and printing
141 * routines. This seems like a more efficient and less cumbersome
142 * way of passing parameters.
143 *
144 * ----------------------------------------------------------------------
145 */
146 typedef struct {
147 unsigned int state; /* If non-zero, indicates to draw text
148 * in the active color */
149 short int width, height; /* Extents of text */
150
151 XColor *color; /* Normal color */
152 XColor *activeColor; /* Active color */
153 Tk_Font font; /* Font to use to draw text */
154 Tk_3DBorder border; /* Background color of text. This is also
155 * used for drawing disabled text. */
156 Shadow shadow; /* Drop shadow color and offset */
157 Tk_Justify justify; /* Justification of the text string. This
158 * only matters if the text is composed
159 * of multiple lines. */
160 GC gc; /* GC used to draw the text */
161 double theta; /* Rotation of text in degrees. */
162 Tk_Anchor anchor; /* Indicates how the text is anchored around
163 * its x and y coordinates. */
164 Blt_Pad padX, padY; /* # pixels padding of around text region */
165 short int leader; /* # pixels spacing between lines of text */
166 int underline; /* Character to underline. */
167
168 } TextStyle;
169
170
171 typedef struct {
172 XColor *color;
173 XColor *color2;
174 int width;
175 XColor **grads; /* Generated list of colors. */
176 XColor *origColor; /* Saved copy to detect if changed.*/
177 XColor *origColor2;
178 int origWidth;
179 } Gradient;
180
181
182 extern TextLayout *Blt_GetTextLayout _ANSI_ARGS_((char *string,
183 TextStyle *stylePtr));
184 extern TextLayout *Blt_GetTextLayoutStr _ANSI_ARGS_((char *string,
185 TextStyle *stylePtr));
186
187 extern void Blt_GetTextExtents _ANSI_ARGS_((TextStyle *stylePtr,
188 char *text, int *widthPtr, int *heightPtr));
189
190 extern void Blt_InitTextStyle _ANSI_ARGS_((TextStyle *stylePtr));
191
192 extern void Blt_ResetTextStyle _ANSI_ARGS_((Tk_Window tkwin,
193 TextStyle *stylePtr));
194
195 extern void Blt_FreeTextStyle _ANSI_ARGS_((Display *display,
196 TextStyle *stylePtr));
197
198 extern void Blt_SetDrawTextStyle _ANSI_ARGS_((TextStyle *stylePtr,
199 Tk_Font font, GC gc, XColor *normalColor, XColor *activeColor,
200 XColor *shadowColor, double theta, Tk_Anchor anchor, Tk_Justify justify,
201 int leader, int shadowOffset));
202
203 extern void Blt_SetPrintTextStyle _ANSI_ARGS_((TextStyle *stylePtr,
204 Tk_Font font, XColor *fgColor, XColor *bgColor, XColor *shadowColor,
205 double theta, Tk_Anchor anchor, Tk_Justify justify, int leader,
206 int shadowOffset));
207
208 extern void Blt_DrawText _ANSI_ARGS_((Tk_Window tkwin, Drawable drawable,
209 char *string, TextStyle *stylePtr, int x, int y));
210
211 extern void Blt_DrawTextLayout _ANSI_ARGS_((Tk_Window tkwin,
212 Drawable drawable, TextLayout *textPtr, TextStyle *stylePtr,
213 int x, int y));
214
215 extern int Blt_TextLayoutValue _ANSI_ARGS_(( TextLayout *textPtr, Tcl_DString *dStr));
216
217 extern void Blt_DrawText2 _ANSI_ARGS_((Tk_Window tkwin, Drawable drawable,
218 char *string, TextStyle *stylePtr, int x, int y,
219 Dim2D * dimPtr));
220
221 extern Pixmap Blt_CreateTextBitmap _ANSI_ARGS_((Tk_Window tkwin,
222 TextLayout *textPtr, TextStyle *stylePtr, int *widthPtr,
223 int *heightPtr));
224
225 extern int Blt_DrawRotatedText _ANSI_ARGS_((Display *display,
226 Drawable drawable, int x, int y, double theta,
227 TextStyle *stylePtr, TextLayout *textPtr));
228
229 extern void Blt_DeleteAxisLabelsGC _ANSI_ARGS_((Tk_Window tkwin));
230
231 extern int Blt_GetGradient(Tcl_Interp *interp, Tk_Window tkwin, Gradient *gradPtr);
232
233 extern int Blt_FreeGradient(Gradient *gradPtr);
234
235
236 #endif /* _BLT_TEXT_H */