source: trunk/kitgen/8.x/blt/generic/bltText.h@ 175

Last change on this file since 175 was 175, checked in by demin, 12 years ago

initial commit

File size: 7.3 KB
RevLine 
[175]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 */
34typedef 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
50typedef 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
66extern int TkMeasureChars _ANSI_ARGS_((Tk_Font font, char *source,
67 int maxChars, int startX, int maxX, int tabOrigin, int flags,
68 int *nextXPtr));
69extern 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 */
95typedef 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 */
120typedef 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} TextLayout;
125
126typedef struct {
127 XColor *color;
128 int offset;
129} Shadow;
130
131/*
132 * ----------------------------------------------------------------------
133 *
134 * TextStyle --
135 *
136 * Represents a convenient structure to hold text attributes
137 * which determine how a text string is to be displayed on the
138 * window, or drawn with PostScript commands. The alternative
139 * is to pass lots of parameters to the drawing and printing
140 * routines. This seems like a more efficient and less cumbersome
141 * way of passing parameters.
142 *
143 * ----------------------------------------------------------------------
144 */
145typedef struct {
146 unsigned int state; /* If non-zero, indicates to draw text
147 * in the active color */
148 short int width, height; /* Extents of text */
149
150 XColor *color; /* Normal color */
151 XColor *activeColor; /* Active color */
152 Tk_Font font; /* Font to use to draw text */
153 Tk_3DBorder border; /* Background color of text. This is also
154 * used for drawing disabled text. */
155 Shadow shadow; /* Drop shadow color and offset */
156 Tk_Justify justify; /* Justification of the text string. This
157 * only matters if the text is composed
158 * of multiple lines. */
159 GC gc; /* GC used to draw the text */
160 double theta; /* Rotation of text in degrees. */
161 Tk_Anchor anchor; /* Indicates how the text is anchored around
162 * its x and y coordinates. */
163 Blt_Pad padX, padY; /* # pixels padding of around text region */
164 short int leader; /* # pixels spacing between lines of text */
165
166} TextStyle;
167
168
169extern TextLayout *Blt_GetTextLayout _ANSI_ARGS_((char *string,
170 TextStyle *stylePtr));
171
172extern void Blt_GetTextExtents _ANSI_ARGS_((TextStyle *stylePtr,
173 char *text, int *widthPtr, int *heightPtr));
174
175extern void Blt_InitTextStyle _ANSI_ARGS_((TextStyle *stylePtr));
176
177extern void Blt_ResetTextStyle _ANSI_ARGS_((Tk_Window tkwin,
178 TextStyle *stylePtr));
179
180extern void Blt_FreeTextStyle _ANSI_ARGS_((Display *display,
181 TextStyle *stylePtr));
182
183extern void Blt_SetDrawTextStyle _ANSI_ARGS_((TextStyle *stylePtr,
184 Tk_Font font, GC gc, XColor *normalColor, XColor *activeColor,
185 XColor *shadowColor, double theta, Tk_Anchor anchor, Tk_Justify justify,
186 int leader, int shadowOffset));
187
188extern void Blt_SetPrintTextStyle _ANSI_ARGS_((TextStyle *stylePtr,
189 Tk_Font font, XColor *fgColor, XColor *bgColor, XColor *shadowColor,
190 double theta, Tk_Anchor anchor, Tk_Justify justify, int leader,
191 int shadowOffset));
192
193extern void Blt_DrawText _ANSI_ARGS_((Tk_Window tkwin, Drawable drawable,
194 char *string, TextStyle *stylePtr, int x, int y));
195
196extern void Blt_DrawTextLayout _ANSI_ARGS_((Tk_Window tkwin,
197 Drawable drawable, TextLayout *textPtr, TextStyle *stylePtr,
198 int x, int y));
199
200extern void Blt_DrawText2 _ANSI_ARGS_((Tk_Window tkwin, Drawable drawable,
201 char *string, TextStyle *stylePtr, int x, int y,
202 Dim2D * dimPtr));
203
204extern Pixmap Blt_CreateTextBitmap _ANSI_ARGS_((Tk_Window tkwin,
205 TextLayout *textPtr, TextStyle *stylePtr, int *widthPtr,
206 int *heightPtr));
207
208extern int Blt_DrawRotatedText _ANSI_ARGS_((Display *display,
209 Drawable drawable, int x, int y, double theta,
210 TextStyle *stylePtr, TextLayout *textPtr));
211
212#endif /* _BLT_TEXT_H */
Note: See TracBrowser for help on using the repository browser.