1 /*
2  * Motif
3  *
4  * Copyright (c) 1987-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22 */
23 /*
24  * HISTORY
25 */
26 /*   $TOG: XmStringI.h /main/7 1999/09/01 17:15:15 mgreess $ */
27 
28 #ifndef _XmStringI_h
29 #define _XmStringI_h
30 
31 #include <Xm/XmP.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38  * These are the fontlist structures
39  */
40 
41 typedef struct _XmFontListContextRec
42 {
43   Boolean		error;			  /* something bad */
44   unsigned short	index;			  /* next rendition */
45   XmRenderTable		table;			  /* associated table */
46 } XmFontListContextRec;
47 
48 /* useful macros */
49 #define two_byte_font(f)        (( (f)->min_byte1 != 0 || (f)->max_byte1 != 0))
50 
51 #define  FontListType(r)		((_XmRendition)(*(r)))->fontType
52 #define  FontListFont(r)		((_XmRendition)(*(r)))->font
53 #define  FontListTag(r)			((_XmRendition)(*(r)))->tag
54 
55 /* Convenience macros */
56 #define _XmStringCvtNonOpt(str)		(_XmStrOptimized(str) ? \
57 					 _XmStringOptToNonOpt(str) : (str))
58 
59 /*
60  * Macros for string internal context block data structure access
61  */
62 
63 #define _XmStrContString(cont)	  \
64                  ((_XmStringContextRec *)(cont))->string
65 #define _XmStrContCurrLine(cont)  \
66                  ((_XmStringContextRec *)(cont))->current_line
67 #define _XmStrContCurrSeg(cont)   \
68                  ((_XmStringContextRec *)(cont))->current_seg
69 #define _XmStrContOpt(cont)	  \
70                  ((_XmStringContextRec *)(cont))->optimized
71 #define _XmStrContError(cont)	  ((_XmStringContextRec *)(cont))->error
72 #define _XmStrContTabCount(cont)  ((_XmStringContextRec *)(cont))->tab_count
73 #define _XmStrContDir(cont) 	  ((_XmStringContextRec *)(cont))->dir
74 #define _XmStrContTag(cont) 	  ((_XmStringContextRec *)(cont))->tag
75 #define _XmStrContTagType(cont)	  ((_XmStringContextRec *)(cont))->tag_type
76 #define _XmStrContState(cont) 	  ((_XmStringContextRec *)(cont))->state
77 #define _XmStrContRendTags(cont)  ((_XmStringContextRec *)(cont))->rend_tags
78 #define _XmStrContRendCount(cont) ((_XmStringContextRec *)(cont))->rend_count
79 #define _XmStrContRendIndex(cont) ((_XmStringContextRec *)(cont))->rend_index
80 #define _XmStrContTmpStrDir(cont) ((_XmStringContextRec *)(cont))->tmp_str_dir
81 #define _XmStrContTmpDir(cont)	  ((_XmStringContextRec *)(cont))->tmp_dir
82 
83 /*
84  * internal context data block, for read-out
85  */
86 enum
87 {
88   PUSH_STATE, BEGIN_REND_STATE, TAG_STATE, TAB_STATE, DIR_STATE,
89   TEXT_STATE, END_REND_STATE, POP_STATE, SEP_STATE
90 };
91 
92 typedef struct __XmStringContextRec
93 {
94     _XmString   	string;		/* pointer to internal string	*/
95     short       	current_line;	/* index of current line	*/
96     unsigned short      current_seg;	/* index of current segment	*/
97     Boolean     	optimized;      /* is string optimized		*/
98     Boolean     	error;          /* something wrong		*/
99     short		tab_count;	/* tabs processed		*/
100     XmStringDirection	dir;		/* last direction		*/
101     XmStringTag		tag;		/* last tag seen		*/
102     XmTextType		tag_type;	/* type of last tag seen	*/
103     char		state;		/* current state of output	*/
104     XmStringTag        *rend_tags;	/* active renditions.		*/
105     short               rend_count;	/* number of rend_tags.		*/
106     short		rend_index;	/* renditions processed		*/
107     XmDirection		tmp_dir;	/* temporary storage            */
108     XmStringDirection	tmp_str_dir;	/* temporary storage            */
109 } _XmStringContextRec;
110 
111 /*
112  * Internal representation of an XmParseMapping.
113  */
114 typedef struct __XmParseMappingRec {
115   XtPointer		pattern;
116   XmTextType		pattern_type;
117   XmString		substitute;
118   XmParseProc		parse_proc;
119   XtPointer		client_data;
120   XmIncludeStatus	include_status;
121   unsigned char		internal_flags;	/* reserved for unparse data */
122 } _XmParseMappingRec, *_XmParseMapping;
123 
124 /****************************************************************
125  * Symbolic values
126  ****************************************************************/
127 
128 #define XmSTRING_OPTIMIZED			0x0
129 #define XmSTRING_OTHER				0x1
130 #define XmSTRING_MULTIPLE_ENTRY	 		0x2
131 
132 #define TAG_INDEX_BITS  	3
133 #define REND_INDEX_BITS		4
134 #define BYTE_COUNT_BITS		8
135 #define TEXT_BYTES_IN_STRUCT	1
136 
137 #define TAG_INDEX_UNSET		((1 << TAG_INDEX_BITS) - 1)
138 #define TAG_INDEX_MAX		TAG_INDEX_UNSET
139 #define REND_INDEX_UNSET	((1 << REND_INDEX_BITS) - 1)
140 #define REND_INDEX_MAX		REND_INDEX_UNSET
141 
142 /****************************************************************
143 
144   XmStringOpt is an optimized string containing text of less than
145   256 bytes with an associated string direction and up to three
146   implicit tabs.
147 
148   The text is stored immediately after the header within the string.
149 
150  ****************************************************************/
151 
152 typedef struct __XmStringOptHeader {
153   unsigned int type        : 2;	     /* XmSTRING_OPTIMIZED */
154   unsigned int text_type   : 2;	     /* MB, WC, locale or charset text.*/
155   unsigned int tag_index   : TAG_INDEX_BITS;	/* index into charset cache */
156   unsigned int rend_begin  : 1;	     /* flag for RENDITION_BEGIN */
157   unsigned char byte_count;	     /* size of text in this seg.*/
158   unsigned int rend_end    : 1;	     /* flag for RENDITION_END */
159   unsigned int rend_index  : REND_INDEX_BITS;	/* index in tag cache */
160   unsigned int str_dir     : 2;      /* string direction set by app */
161   unsigned int flipped     : 1;      /* whether the text has been flipped */
162   unsigned int tabs	   : 2;	     /* number of tabs preceding the text */
163   unsigned int refcount    : 6;      /* reference count */
164 } _XmStringOptHeader;
165 
166 typedef struct __XmStringOpt {
167   _XmStringOptHeader header;
168   char               text[TEXT_BYTES_IN_STRUCT];
169 } _XmStringOptRec, *_XmStringOpt;
170 
171 /****************************************************************
172 
173   XmStringMulti specifies a string consisting of multiple entries.
174   Each entry is a segment, either an optimized single segment, an
175   unoptimized segment, or an array of segments.
176 
177   If implicit_line is 1, each entry is treated as a single line for
178   display and other purposes.
179 
180   If implicit_line is 0, the string is a sequence of entries, treated as
181   being on one line.
182 
183  ****************************************************************/
184 
185 /* Forward definitions */
186 typedef union __XmStringEntryRec *_XmStringEntry;
187 typedef union __XmStringNREntryRec *_XmStringNREntry;
188 
189 typedef struct __XmStringMultiHeader {
190   unsigned int	type          : 2;	/* XmSTRING_MULTIPLE_ENTRY */
191   unsigned int	implicit_line : 1;	/* 1 => linefeed at end */
192   unsigned int	entry_count   : 21;
193   unsigned char	refcount;
194 } _XmStringMultiHeader;
195 
196 typedef struct __XmStringMulti{
197   _XmStringMultiHeader	header;
198   _XmStringEntry      * entry;	/* pointer to array of pointers to entries */
199 } _XmStringMultiRec, *_XmStringMulti;
200 
201 typedef struct __XmStringEmptyHeader {
202   unsigned int	type          : 2;
203 } _XmStringEmptyHeader;
204 
205 typedef union __XmStringRec {
206   _XmStringEmptyHeader  empty;
207   _XmStringOptHeader	opt_str;	/* XmSTRING_OPTIMIZED */
208   XtPointer		component;	/* unused */
209   _XmStringMultiHeader	multi_str;      /* XmSTRING_MULTIPLE_ENTRY */
210 } _XmStringRec;
211 
212 
213 
214 /****************************************************************
215 
216   Cache data structures
217 
218  ****************************************************************/
219 #define _XmSCANNING_CACHE  0
220 #define _XmRENDERING_CACHE 1
221 /* #define _XmHIGHLIGHT_CACHE 2 */
222 /* #define _XmCSTEXT_CACHE    3 */
223 
224 /*
225  * Header
226  */
227 typedef struct __XmStringCacheRec {
228   struct __XmStringCacheRec * next;
229   unsigned char               cache_type;/* only 255 cache types supported */
230   Boolean		      dirty;	 /* 1 => recompute this cache */
231 }  _XmStringCacheHeader, *_XmStringCache;
232 
233 /*
234  * Scanning cache
235  */
236 typedef struct __XmStringScanning {
237   _XmStringCacheHeader header;           /* cache_type == _XmSCANNING_CACHE */
238   /* Matching fields */
239   XmDirection          prim_dir;         /* primary layout direction */
240 
241   /* Cached data */
242   _XmStringEntry       left;	         /* leftward segment in string */
243   _XmStringEntry       right;	         /* rightward segment in string */
244   XmDirection          layout_direction; /* current segment layout direction */
245   unsigned short       depth;		 /* depth of layout push */
246 } _XmStringScanningRec, *_XmStringScanningCache;
247 
248 /*
249  * Rendering cache
250  */
251 typedef struct __XmStringRendering {
252   _XmStringCacheHeader header;           /* cache_type == _XmRENDERING_CACHE */
253   /* Matching fields */
254   XmRenderTable        rt;
255 
256   /* Cached data */
257   int  	               x;	         /* x pos of segment */
258   int                  y;	         /* y pos of segment */
259   int  	               width;	         /* width of segment */
260   int                  height;	         /* height of segment */
261   int		       ascent;		 /* ascent of segment */
262   int		       descent;		 /* descent of segment */
263   int                  baseline;	 /* baseline of segment */
264   XmRendition          rendition;        /* Rendition used for this segment */
265   char                 prev_tabs;        /* accumulates tabs on line */
266 } _XmStringRenderingRec, *_XmStringRenderingCache;
267 
268 
269 /****************************************************************
270 
271   Optimized segment definition.
272 
273  ****************************************************************/
274 
275 typedef struct __XmStringOptSegHdrRec {
276   unsigned int type            : 2;  /* XmSTRING_ENTRY_OPTIMIZED */
277   unsigned int text_type       : 2;  /* MB, WC, locale or charset */
278   unsigned int tag_index       : TAG_INDEX_BITS; /* index into charset cache */
279   unsigned int rend_begin      : 1;  /* flag for RENDITION_BEGIN */
280   unsigned char byte_count;
281   unsigned int rend_end        : 1;  /* flag for RENDITION_END */
282   unsigned int rend_index : REND_INDEX_BITS; /* index in rendition tag cache */
283   unsigned int str_dir         : 2;  /* Direction of text in segment */
284   unsigned int flipped         : 1;  /* 1 => data is character-flipped */
285   unsigned int tabs_before     : 3;  /* number of preceding tabs */
286   unsigned int permanent       : 1;  /* 0 => Pointer data can be freed */
287   unsigned int soft_line_break : 1;  /* linebreak before is soft */
288   unsigned int immediate       : 1;  /* 0 => data is immediate */
289   unsigned int pad             : 2;
290 } _XmStringOptSegHdrRec;
291 
292 typedef struct __XmStringOptSegRec {
293   _XmStringOptSegHdrRec header;
294   union {
295     wchar_t		wchars[1];
296     unsigned char	chars[1];
297     XtPointer	        text;
298   } data;
299 } _XmStringOptSegRec, *_XmStringOptSeg;
300 
301 /****************************************************************
302 
303   Array 'segment' definition.
304 
305  ****************************************************************/
306 
307 typedef struct __XmStringArraySegHdrRec {
308   unsigned int type            : 2;  /* XmSTRING_ENTRY_ARRAY */
309   unsigned int soft_line_break : 1;  /* linebreak before is soft */
310   unsigned int pad             : 5;
311   unsigned int segment_count   : 8;  /* 256 segments per line */
312   unsigned char pad2byte[2];
313 } _XmStringArraySegHdrRec;
314 
315 typedef struct __XmStringArraySegRec {
316   _XmStringArraySegHdrRec header;
317   _XmStringNREntry	* seg;	      /* array of pointers to segments */
318 } _XmStringArraySegRec, *_XmStringArraySeg;
319 
320 
321 /****************************************************************
322 
323   Unoptimized segment definition.
324 
325  ****************************************************************/
326 
327 typedef struct __XmStringUnoptSegHdrRec {
328   unsigned int	type            : 2;  /* XmSTRING_ENTRY_UNOPTIMIZED */
329   unsigned int  soft_line_break : 1;  /* linebreak before is soft */
330   unsigned int	permanent       : 1;  /* 0 => Pointer data can be freed */
331   unsigned int	pop_after       : 1;  /* whether a pop follows the text */
332   unsigned int	str_dir         : 2;  /* Direction of text in segment */
333   unsigned int  flipped         : 1;  /* 1 => data is character-flipped */
334   XmDirection	push_before;	      /* if NULL => no push */
335   unsigned char	tabs_before;	      /* Number of tabs preceding segment */
336   XmTextType	text_type;	      /* determines type of text and tag */
337 }  _XmStringUnoptSegHdrRec;
338 
339 typedef struct __XmStringUnoptSegRec {
340   _XmStringUnoptSegHdrRec header;
341   union {
342     wchar_t		* wchars;
343     unsigned char	* chars;
344     XtPointer             text;		   /* pointer to text. */
345   } data;			           /* To conform to opt. segment */
346   unsigned char           begin_count;	   /* count of rendition tag begins */
347   unsigned char	          end_count;	   /* count of rendition tag ends */
348   XmStringTag	        * rend_begin_tags; /* list of rendition tag begins */
349   XmStringTag	        * rend_end_tags;   /* list of rendition tag ends */
350   XmStringTag	          tag;		   /* locale or charset tag */
351   unsigned int	          byte_count;	   /* byte count for this segment */
352   unsigned int	          char_count;	   /* character count */
353   _XmStringCache          cache;
354 }  _XmStringUnoptSegRec, *_XmStringUnoptSeg;
355 
356 /****************************************************************
357 
358   XmStringEntry specifies the different 'segments' that can be part
359   of a multiple-entry XmString.
360 
361   These entries can be an optimized segment, an segment with cache,
362   also optimized, an unoptimized segment or an array of segments.
363 
364   The array entry type can contain any of the three other entry types,
365   but not an array entry. This is because we do not want to handle
366   recursive XmStrings.
367 
368  ****************************************************************/
369 
370 #define XmSTRING_ENTRY_OPTIMIZED		0x0
371 #define XmSTRING_ENTRY_UNOPTIMIZED		0x1
372 /* #define XmSTRING_ENTRY_OPTIMIZED_CACHE  	0x2 */
373 #define XmSTRING_ENTRY_ARRAY			0x3
374 
375 typedef union __XmStringEntryRec {
376   _XmStringEmptyHeader         empty;
377   _XmStringOptSegHdrRec	       single;	       /* XmSTRING_ENTRY_OPTIMIZED */
378   _XmStringUnoptSegHdrRec      unopt_single;   /* XmSTRING_ENTRY_UNOPTIMIZED */
379   _XmStringArraySegHdrRec      multiple;       /* XmSTRING_ENTRY_ARRAY */
380 } _XmStringEntryRec;
381 
382 /***************************************************************
383 
384   _XmStringNREntry:
385   Used in the XmStringArraySeg, to prevent recursive
386   definitions of XmStrings.
387 
388  ****************************************************************/
389 
390 typedef union __XmStringNREntryRec {
391   _XmStringEmptyHeader         empty;
392   _XmStringOptSegHdrRec	       single;		/* XmSTRING_ENTRY_OPTIMIZED */
393   _XmStringUnoptSegHdrRec      unopt_single; 	/* XmSTRING_ENTRY_UNOPTIMIZED */
394 } _XmStringNREntryRec;
395 
396 /****************************************************************
397  *
398  * Typedefs for old structures
399  *
400  ****************************************************************/
401 
402 typedef struct __XmStringUnoptSegRec _XmStringSegmentRec;
403 typedef struct __XmStringUnoptSegRec *_XmStringSegment;
404 
405 typedef struct __XmStringArraySegRec _XmStringLineRec;
406 typedef struct __XmStringArraySegRec *_XmStringLine;
407 
408 /****************************************************************
409  *
410  * Macros
411  *
412  ****************************************************************/
413 
414 /* General */
415 #define _XmStrType(str)	      ((str)->empty.type)
416 #define _XmStrOptimized(str)  ((str)->empty.type == XmSTRING_OPTIMIZED)
417 #define _XmStrMultiple(str)   ((str)->empty.type ==  XmSTRING_MULTIPLE_ENTRY)
418 #define _XmStrRefCountGet(str)	(_XmStrMultiple(str)  ? 		   \
419 			       (str)->multi_str.refcount : 		   \
420 			       (_XmStrOptimized(str) ?		   	   \
421 			        (str)->opt_str.refcount : 		   \
422 			        1))
423 #define _XmStrRefCountSet(str, val)					   \
424   (_XmStrMultiple(str)  ? 		   				   \
425    ((str)->multi_str.refcount = (val)) : 	  			   \
426    (_XmStrOptimized(str) ?		   	  			   \
427     ((str)->opt_str.refcount = (val)) : 0))
428 
429 #define _XmStrRefCountInc(str)						   \
430   (_XmStrMultiple(str)  ? 		   				   \
431    ++((str)->multi_str.refcount) :	 	  			   \
432    (_XmStrOptimized(str) ?		   	  			   \
433     ++((str)->opt_str.refcount) : 0))
434 
435 #define _XmStrRefCountDec(str)						   \
436   (_XmStrMultiple(str)  ? 		   				   \
437    --((str)->multi_str.refcount) :	 	  			   \
438    (_XmStrOptimized(str) ?		   	  			   \
439     --((str)->opt_str.refcount) : 0))
440 
441 /* Optimized, one-segment XmStrings */
442 #define _XmStrTextType(str)   ((str)->opt_str.text_type)
443 #define _XmStrTagIndex(str)   ((str)->opt_str.tag_index)
444 #define _XmStrTagGet(str)     (_XmStrTagIndex(str) == TAG_INDEX_UNSET ?    \
445 			       NULL :                                      \
446 			       _XmStringIndexGetTag(_XmStrTagIndex(str)))
447 #define _XmStrByteCount(str)  ((str)->opt_str.byte_count)
448 #define _XmStrCharCount(str)  _XmStringCharacterCount((str)->opt_str.text, \
449 						      _XmStrTextType(str), \
450 						      _XmStrByteCount(str),\
451 						      NULL)
452 #define _XmStrRendBegin(str)  ((str)->opt_str.rend_begin)
453 #define _XmStrRendIndex(str)  ((str)->opt_str.rend_index)
454 #define _XmStrRendTagGet(str) (_XmStrRendIndex(str) == REND_INDEX_UNSET ?  \
455 			       NULL :                                      \
456 			       _XmStringIndexGetTag(_XmStrRendIndex(str)))
457 #define _XmStrRendEnd(str)    ((str)->opt_str.rend_end)
458 #define _XmStrDirection(str)  ((str)->opt_str.str_dir)
459 #define _XmStrFlipped(str)    ((str)->opt_str.flipped)
460 #define _XmStrTabs(str)	      ((str)->opt_str.tabs)
461 #define _XmStrText(str)       (((_XmStringOpt)(str))->text)
462 
463 /* Multi-segment XmStrings */
464 #define _XmStrImplicitLine(str) (str)->multi_str.implicit_line
465 #define _XmStrAddNewline(str)   (_XmStrMultiple(str) ? 		           \
466 			         _XmStrImplicitLine(str) : False)
467 #define _XmStrEntryCount(str)	(str)->multi_str.entry_count
468 #define _XmStrEntryCountGet(str) (_XmStrMultiple(str) ? 		   \
469 				  _XmStrEntryCount(str) : 1)
470 #define _XmStrLineCountGet(str) (_XmStrMultiple(str)&&_XmStrAddNewline(str) ? \
471 				 _XmStrEntryCount(str) : 	   	   \
472 				  1)
473 #define _XmStrEntry(str)	((_XmStringMulti)(str))->entry
474 #define _XmStrEntryGet(str)     (_XmStrMultiple(str) ? 		   	   \
475 				 _XmStrEntry(str) :			   \
476 				 (_XmStringEntry*)NULL)
477 
478 #define _XmStrInit(str, type)						   \
479 {									   \
480   switch (type) { 							   \
481   case XmSTRING_OPTIMIZED : 						   \
482     bzero((char*)str, sizeof(_XmStringOptRec));				   \
483     _XmStrType(str) = type; 						   \
484     _XmStrTextType(str) = XmNO_TEXT;                                       \
485     _XmStrDirection(str) = XmSTRING_DIRECTION_UNSET;			   \
486     _XmStrTagIndex(str) = TAG_INDEX_UNSET;			 	   \
487     _XmStrRendIndex(str) = REND_INDEX_UNSET;			 	   \
488     _XmStrRefCountSet(str, 1);			 	 	 	   \
489     break; 								   \
490   case XmSTRING_MULTIPLE_ENTRY : 					   \
491     bzero((char*)str, sizeof(_XmStringMultiRec));			   \
492     _XmStrType(str) = type; 						   \
493     _XmStrRefCountSet(str, 1);			 	 	 	   \
494     break; 								   \
495   } 									   \
496 }
497 
498 #ifdef _XmDEBUG_XMSTRING_MEM
499 #define STR_OFFSET		sizeof(double)
500 #define _XmStrMalloc(size)	(XtMalloc((size) + STR_OFFSET) + STR_OFFSET)
501 #define _XmStrFree(ptr)		(XtFree(((char*)(ptr)) - STR_OFFSET))
502 #else
503 #define _XmStrMalloc(size)	(XtMalloc(size))
504 #define _XmStrFree(ptr)		(XtFree((char*)(ptr)))
505 #endif /* _XmDEBUG_XMSTRING_MEM */
506 
507 #define _XmStrCreate(str, type, text_len)				   \
508 {									   \
509   switch (type) { 							   \
510   case XmSTRING_OPTIMIZED : 						   \
511     (str) = (_XmString)							   \
512       _XmStrMalloc(sizeof(_XmStringOptRec) +                               \
513 		   (text_len ? (text_len - TEXT_BYTES_IN_STRUCT) : 0));    \
514     bzero((char*)str, sizeof(_XmStringOptRec)); 			   \
515     _XmStrType(str) = type; 						   \
516     _XmStrTextType(str) = XmNO_TEXT;                                       \
517     _XmStrDirection(str) = XmSTRING_DIRECTION_UNSET;			   \
518     _XmStrTagIndex(str) = TAG_INDEX_UNSET;			 	   \
519     _XmStrRendIndex(str) = REND_INDEX_UNSET;			 	   \
520     _XmStrRefCountSet(str, 1);			 	 	 	   \
521     _XmStrByteCount(str) = text_len;                                       \
522     break; 								   \
523   case XmSTRING_MULTIPLE_ENTRY : 					   \
524     (str) = (_XmString)_XmStrMalloc(sizeof(_XmStringMultiRec));		   \
525     bzero((char*)str, sizeof(_XmStringMultiRec));			   \
526     _XmStrType(str) = type; 						   \
527     _XmStrRefCountSet(str, 1);			 	 	 	   \
528     break; 								   \
529   } 									   \
530 }
531 
532 /* General XmString Entry macros */
533 #define _XmEntryType(entry)	(((_XmStringEntry)(entry))->empty.type)
534 #define _XmEntryOptimized(entry) 					   \
535         (_XmEntryType(entry) == XmSTRING_ENTRY_OPTIMIZED)
536 #define _XmEntryMultiple(entry) 					   \
537         (_XmEntryType(entry) == XmSTRING_ENTRY_ARRAY)
538 #define _XmEntryUnoptimized(entry) 					   \
539 	(_XmEntryType(entry) == XmSTRING_ENTRY_UNOPTIMIZED)
540 
541 /* Non-array entry macros */
542 #define _XmEntryTextTypeSet(entry, val)					   \
543 	(_XmEntryOptimized(entry) ? 					   \
544 	 (((_XmStringEntry)(entry))->single.text_type = (val)) :	   \
545 	 (((_XmStringEntry)(entry))->unopt_single.text_type = (val)))
546 #define _XmEntryTagIndex(entry) 					   \
547 	(((_XmStringEntry)(entry))->single.tag_index)
548 #define _XmUnoptSegTag(entry) 						   \
549         ((_XmStringUnoptSeg)(entry))->tag
550 #define _XmUnoptSegByteCount(entry)                                        \
551         ((_XmStringUnoptSeg)(entry))->byte_count
552 #define _XmEntryByteCountSet(entry, val)				   \
553 	(_XmEntryOptimized(entry) ? 					   \
554 	 (((_XmStringEntry)(entry))->single.byte_count = (val)) : 	   \
555 	 (_XmUnoptSegByteCount(entry) = (val)))
556 #define _XmEntryCharCountSet(entry, val)			           \
557 	(_XmEntryUnoptimized(entry) ? 					   \
558 	 (((_XmStringUnoptSeg)(entry))->char_count = (val)) :	 	   \
559 	 0)
560 #define _XmEntryRendIndex(entry) 					   \
561         (((_XmStringEntry)(entry))->single.rend_index)
562 #define _XmUnoptSegRendBeginCount(entry)				   \
563  	((_XmStringUnoptSeg)(entry))->begin_count
564 #define _XmEntryRendBeginCountSet(entry, val) 				   \
565 	(_XmEntryOptimized(entry) ? 					   \
566 	 (((_XmStringEntry)(entry))->single.rend_begin = (val)) : 	   \
567 	 (_XmUnoptSegRendBeginCount(entry) = (val)))
568 #define _XmUnoptSegRendBegins(entry)					   \
569   	((_XmStringUnoptSeg)(entry))->rend_begin_tags
570 #define _XmUnoptSegRendEndCount(entry)					   \
571   	((_XmStringUnoptSeg)(entry))->end_count
572 #define _XmEntryRendEndCountSet(entry, val) 				   \
573 	(_XmEntryOptimized(entry) ? 					   \
574 	 (((_XmStringEntry)(entry))->single.rend_end = (val)) : 	   \
575 	 (_XmUnoptSegRendEndCount(entry) = (val)))
576 #define _XmUnoptSegRendEnds(entry)					   \
577   	((_XmStringUnoptSeg)(entry))->rend_end_tags
578 #define _XmEntryTabsSet(entry, val) 					   \
579 	(_XmEntryOptimized(entry) ? 					   \
580 	 (((_XmStringEntry)(entry))->single.tabs_before = (val)) :	   \
581 	 (((_XmStringEntry)(entry))->unopt_single.tabs_before = (val)))
582 #define _XmEntryFlippedGet(entry) 					   \
583 	(_XmEntryOptimized(entry) ? 					   \
584 	 ((_XmStringEntry)(entry))->single.flipped : 			   \
585 	 ((_XmStringEntry)(entry))->unopt_single.flipped)
586 #define _XmEntryFlippedSet(entry, val) 					   \
587 	(_XmEntryOptimized(entry) ? 					   \
588 	 (((_XmStringEntry)(entry))->single.flipped = (val)) : 		   \
589 	 (((_XmStringEntry)(entry))->unopt_single.flipped = (val)))
590 #define _XmEntryPermGet(entry) 						   \
591 	(_XmEntryOptimized(entry) ? 					   \
592 	 ((_XmStringEntry)(entry))->single.permanent : 			   \
593 	 ((_XmStringEntry)(entry))->unopt_single.permanent)
594 #define _XmEntryPermSet(entry, val) 					   \
595 	(_XmEntryOptimized(entry) ? 					   \
596 	 (((_XmStringEntry)(entry))->single.permanent = (val)) : 	   \
597 	 (((_XmStringEntry)(entry))->unopt_single.permanent = (val)))
598 #define _XmEntrySoftNewlineGet(entry) 					   \
599 	(_XmEntryOptimized(entry) ? 					   \
600 	 ((_XmStringEntry)(entry))->single.soft_line_break : 		   \
601 	 (_XmEntryUnoptimized(entry) ? 					   \
602 	  ((_XmStringEntry)(entry))->unopt_single.soft_line_break : 	   \
603 	  ((_XmStringEntry)(entry))->multiple.soft_line_break))
604 #define _XmEntrySoftNewlineSet(entry, val) 				   \
605 	(_XmEntryOptimized(entry) ? 					   \
606 	 (((_XmStringEntry)(entry))->single.soft_line_break = (val)) : 	   \
607 	 (_XmEntryUnoptimized(entry) ? 					   \
608 	  (((_XmStringEntry)(entry))->unopt_single.soft_line_break = (val)):\
609 	  (((_XmStringEntry)(entry))->multiple.soft_line_break = (val))))
610 #define _XmEntryImm(entry) 						   \
611 	(((_XmStringEntry)(entry))->single.immediate)
612 #define _XmEntryPushSet(entry, val) 					   \
613 	(_XmEntryUnoptimized(entry) ? 					   \
614 	 (((_XmStringEntry)(entry))->unopt_single.push_before = (val)) :  \
615 	 0)
616 #define _XmEntryPopSet(entry, val) 					   \
617 	(_XmEntryUnoptimized(entry) ? 					   \
618 	 (((_XmStringEntry)(entry))->unopt_single.pop_after = (val)) :    \
619 	 0)
620 #define _XmEntryMBText(entry) 						   \
621 	(((_XmStringOptSeg)(entry))->data.chars)
622 #define _XmEntryWCText(entry) 						   \
623 	(((_XmStringOptSeg)(entry))->data.wchars)
624 #define _XmEntryCacheSet(entry, val) 					   \
625 	(_XmEntryUnoptimized(entry) ? 					   \
626 	 (((_XmStringUnoptSeg)(entry))->cache = (val)) :		   \
627 	 NULL)
628 
629 
630 /* Array entry specific macros */
631 #define _XmEntrySegmentCount(entry) 					   \
632   (((_XmStringEntry)(entry))->multiple.segment_count)
633 #define _XmEntrySegmentCountGet(entry) 					   \
634         (_XmEntryMultiple(entry) ? 					   \
635 	 _XmEntrySegmentCount(entry) :			 		   \
636 	 1)
637 #define _XmEntrySegment(entry) 						   \
638   (((_XmStringArraySeg)(entry))->seg)
639 
640 #define _XmEntrySegmentGet(entry) 					   \
641         (_XmEntryMultiple(entry) ? 					   \
642 	 _XmEntrySegment(entry) : 					   \
643 	 (_XmStringNREntry *)&(entry))
644 
645 /* Creation macros */
646 
647 #define _XmEntryInit(entry, type)                               	   \
648 {									   \
649   switch (type) { 							   \
650   case XmSTRING_ENTRY_OPTIMIZED : 					   \
651     bzero((char*)entry, sizeof(_XmStringOptSegRec));			   \
652     _XmEntryTagIndex(entry) = TAG_INDEX_UNSET;			 	   \
653     _XmEntryRendIndex(entry) = REND_INDEX_UNSET;		 	   \
654     break; 								   \
655   case XmSTRING_ENTRY_ARRAY : 						   \
656     bzero((char*)entry, sizeof(_XmStringArraySegRec));			   \
657     break; 								   \
658   case XmSTRING_ENTRY_UNOPTIMIZED :					   \
659     bzero((char*)entry, sizeof(_XmStringUnoptSegRec));		   \
660     break; 								   \
661   } 									   \
662   _XmEntryType(entry) = type; 						   \
663   _XmEntryTextTypeSet(entry, XmNO_TEXT);                                   \
664   if (type != XmSTRING_ENTRY_ARRAY)                                        \
665     _XmEntryDirectionSet(entry, XmSTRING_DIRECTION_UNSET);		   \
666 }
667 
668 #define _XmEntryCreate(entry, type)					   \
669 {									   \
670   switch (type) { 							   \
671   case XmSTRING_ENTRY_OPTIMIZED : 					   \
672     (entry) = (_XmStringEntry)XtMalloc(sizeof(_XmStringOptSegRec));	   \
673     bzero((char*)entry, sizeof(_XmStringOptSegRec));			   \
674     _XmEntryTagIndex(entry) = TAG_INDEX_UNSET;			 	   \
675     _XmEntryRendIndex(entry) = REND_INDEX_UNSET;		 	   \
676     break; 								   \
677   case XmSTRING_ENTRY_ARRAY : 						   \
678     (entry) = (_XmStringEntry)XtMalloc(sizeof(_XmStringArraySegRec));	   \
679     bzero((char*)entry, sizeof(_XmStringArraySegRec));			   \
680     break; 								   \
681   case XmSTRING_ENTRY_UNOPTIMIZED :					   \
682     (entry) = (_XmStringEntry)XtMalloc(sizeof(_XmStringUnoptSegRec));  \
683     bzero((char*)entry, sizeof(_XmStringUnoptSegRec));		   \
684     break; 								   \
685   } 									   \
686   if (entry) {                                                             \
687     _XmEntryType(entry) = type; 					   \
688     _XmEntryTextTypeSet(entry, XmNO_TEXT);                                 \
689     if (type != XmSTRING_ENTRY_ARRAY)                                      \
690       _XmEntryDirectionSet(entry, XmSTRING_DIRECTION_UNSET);		   \
691   } 									   \
692 }
693 
694 #define _XmCACHE_DIRTY        0
695 #define _XmCacheDirty(cache)    (((_XmStringCache)(cache))->dirty)
696 #define _XmCacheNext(cache)     (((_XmStringCache)(cache))->next)
697 
698 #define _XmEntryDirtyGet(entry, type, data) \
699      (((type) == _XmSCANNING_CACHE) ? \
700       (Boolean)(long)_XmScanningCacheGet((_XmStringNREntry)entry, \
701 					 (XmDirection)(long)data, \
702 					 _XmCACHE_DIRTY) : \
703       (((type) == _XmRENDERING_CACHE) ? \
704        (Boolean)(long)_XmRenderCacheGet((_XmStringEntry)entry, \
705 					(XmRenderTable)(long)data, \
706 				        _XmCACHE_DIRTY) : \
707        True))
708 
709 
710 #define _XmEntryDirtySet(entry, type, data, val) \
711      (((type) == _XmSCANNING_CACHE) ? \
712       _XmScanningCacheSet((_XmStringNREntry)entry, \
713 			  (XmDirection)(long)data, \
714 			  _XmCACHE_DIRTY, (XtPointer)(long)val) : \
715       (((type) == _XmRENDERING_CACHE) ? \
716        _XmRenderCacheSet((_XmStringEntry)entry, \
717 			 (XmRenderTable)(long)data, \
718 			 _XmCACHE_DIRTY, (XtPointer)(long)val) : \
719        (void)NULL))
720 
721 /* Scanning cache */
722 #define _XmCACHE_SCAN_LEFT    1
723 #define _XmCACHE_SCAN_RIGHT   2
724 #define _XmCACHE_SCAN_LAYOUT  3
725 #define _XmCACHE_SCAN_DEPTH   4
726 #define _XmEntryLeftGet(entry, d) 					   \
727       (_XmStringEntry)_XmScanningCacheGet(entry, d, _XmCACHE_SCAN_LEFT)
728 #define _XmEntryRightGet(entry, d) 				   \
729       (_XmStringEntry)_XmScanningCacheGet(entry, d, _XmCACHE_SCAN_RIGHT)
730 #define _XmEntryLayoutGet(entry, d) 				   \
731       (XmDirection)(long)_XmScanningCacheGet(entry, d, _XmCACHE_SCAN_LAYOUT)
732 #define _XmEntryLayoutDepthGet(entry, d) 				   \
733       (unsigned short)(long)_XmScanningCacheGet(entry, d, _XmCACHE_SCAN_DEPTH)
734 #define _XmEntryLeftSet(entry, d, val) 				   \
735       _XmScanningCacheSet(entry, d, _XmCACHE_SCAN_LEFT, (XtPointer)(long)val)
736 #define _XmEntryRightSet(entry, d, val) 				   \
737       _XmScanningCacheSet(entry, d, _XmCACHE_SCAN_RIGHT, (XtPointer)(long)val)
738 #define _XmEntryLayoutSet(entry, d, val) 				   \
739       _XmScanningCacheSet(entry, d, _XmCACHE_SCAN_LAYOUT, (XtPointer)(long)val)
740 #define _XmEntryLayoutDepthSet(entry, d, val) 			   \
741       _XmScanningCacheSet(entry, d, _XmCACHE_SCAN_DEPTH, (XtPointer)(long)val)
742 
743 /* Rendering cache */
744 #define _XmCACHE_RENDER_WIDTH     1
745 #define _XmCACHE_RENDER_HEIGHT    2
746 #define _XmCACHE_RENDER_RENDITION 3
747 #define _XmCACHE_RENDER_X         4
748 #define _XmCACHE_RENDER_Y         5
749 #define _XmCACHE_RENDER_BASELINE  6
750 #define _XmCACHE_RENDER_ASCENT	  7
751 #define _XmCACHE_RENDER_DESCENT	  8
752 #define _XmCACHE_RENDER_PREV_TABS 9
753 #define _XmEntryXGet(entry, rt) 					   \
754         (long)_XmRenderCacheGet(entry, rt, _XmCACHE_RENDER_X)
755 #define _XmEntryYGet(entry, rt) 					   \
756         (long)_XmRenderCacheGet(entry, rt, _XmCACHE_RENDER_Y)
757 #define _XmEntryWidthGet(entry, rt) 					   \
758         (long)_XmRenderCacheGet(entry, rt, _XmCACHE_RENDER_WIDTH)
759 #define _XmEntryHeightGet(entry, rt) 					   \
760         (long)_XmRenderCacheGet(entry, rt, _XmCACHE_RENDER_HEIGHT)
761 #define _XmEntryBaselineGet(entry, rt) 				 	   \
762         (long)_XmRenderCacheGet(entry, rt, _XmCACHE_RENDER_BASELINE)
763 #define _XmEntryAscentGet(entry, rt) 				 	   \
764         (long)_XmRenderCacheGet(entry, rt, _XmCACHE_RENDER_ASCENT)
765 #define _XmEntryDescentGet(entry, rt) 				 	   \
766         (long)_XmRenderCacheGet(entry, rt, _XmCACHE_RENDER_DESCENT)
767 #define _XmEntryRenditionGet(entry, rt) 				   \
768         (XmRendition)_XmRenderCacheGet(entry, rt, _XmCACHE_RENDER_RENDITION)
769 #define _XmEntryPrevTabsGet(entry, rt)					   \
770         (char)(long)_XmRenderCacheGet(entry, rt, _XmCACHE_RENDER_PREV_TABS)
771 #define _XmEntryXSet(entry, rt, val) 					   \
772         _XmRenderCacheSet(entry, rt, _XmCACHE_RENDER_X, (XtPointer)(long)val)
773 #define _XmEntryYSet(entry, rt, val) 					   \
774         _XmRenderCacheSet(entry, rt, _XmCACHE_RENDER_Y, (XtPointer)(long)val)
775 #define _XmEntryWidthSet(entry, rt, val) 				   \
776         _XmRenderCacheSet(entry, rt, _XmCACHE_RENDER_WIDTH, (XtPointer)(long)val)
777 #define _XmEntryHeightSet(entry, rt, val) 				   \
778         _XmRenderCacheSet(entry, rt, _XmCACHE_RENDER_HEIGHT, (XtPointer)(long)val)
779 #define _XmEntryBaselineSet(entry, rt, val) 			 	   \
780         _XmRenderCacheSet(entry, rt, _XmCACHE_RENDER_BASELINE, (XtPointer)(long)val)
781 #define _XmEntryAscentSet(entry, rt, val) 				 	   \
782         _XmRenderCacheSet(entry, rt, _XmCACHE_RENDER_ASCENT, (XtPointer)(long)val)
783 #define _XmEntryDescentSet(entry, rt, val) 				 	   \
784         _XmRenderCacheSet(entry, rt, _XmCACHE_RENDER_DESCENT, (XtPointer)(long)val)
785 #define _XmEntryRenditionSet(entry, rt, val) 				   \
786         _XmRenderCacheSet(entry, rt, _XmCACHE_RENDER_RENDITION, (XtPointer)(long)val)
787 #define _XmEntryPrevTabsSet(entry, rt, val)				   \
788         _XmRenderCacheSet(entry, rt, _XmCACHE_RENDER_PREV_TABS, (XtPointer)(long)val)
789 
790 /*
791  * Macros for old non-optimized segment data structure access
792  */
793 
794 #define _XmSegTag(seg)			_XmUnoptSegTag(seg)
795 #define _XmSegCharCount(seg)		_XmUnoptSegByteCount(seg)
796 #define _XmSegText(seg)			((_XmStringUnoptSeg)(seg))->data.text
797 #define _XmSegDirection(seg)		_XmEntryDirectionGet(seg)
798 #define _XmSegLayoutDirection(seg)      _XmEntryPushGet(seg)
799 #define _XmSegLayout(seg)               _XmEntryPopGet(seg)
800 
801 #define _XmSegType(seg)			_XmEntryTextTypeGet(seg)
802 #define _XmSegTextGet(seg)		(unsigned char *)_XmSegText(seg)
803 #define _XmSegTextSet(seg,val)		_XmEntryTextSet(seg, (XtPointer)(val))
804 #define _XmSegMBTextGet(seg)		_XmEntryMBText(seg)
805 #define _XmSegWCTextGet(seg)		_XmEntryWCText(seg)
806 #define _XmSegTab(seg)			_XmEntryTabsGet(seg)
807 #define _XmSegLeft(seg)			((_XmStringUnoptSeg)seg)->cache
808 #define _XmSegRight(seg)		((_XmStringUnoptSeg)seg)->cache
809 #define _XmSegRendBegins(seg)		_XmUnoptSegRendBegins(seg)
810 #define _XmSegRendBeginGet(seg,n)	_XmEntryRendBeginGet(seg,n)
811 #define _XmSegRendBeginCount(seg)	_XmUnoptSegRendBeginCount(seg)
812 #define _XmSegRendEnds(seg)		_XmUnoptSegRendEnds(seg)
813 #define _XmSegRendEndGet(seg,n)		_XmEntryRendEndGet(seg,n)
814 #define _XmSegRendEndCount(seg)		_XmUnoptSegRendEndCount(seg)
815 
816 /*
817  * Macros for line data structure access
818  */
819 
820 #define _XmStrLineSegCount(line)        _XmEntrySegmentCount(line)
821 #define _XmStrLineSegment(line)						\
822   ((_XmStringSegment *)_XmEntrySegment(line))
823 #define _XmStrLineSegmentSet(line, val)	_XmEntrySegment(line) = 	\
824   (_XmStringNREntry *)(val)
825 
826 /*
827  * Macros for internal string data structure access
828  */
829 
830 #define _XmStrLineCnt(str)		_XmStrEntryCount(str)
831 #define _XmStrLineLine(str)		((_XmStringLine *)_XmStrEntry(str))
832 #define _XmStrLineLineSet(str, val)	_XmStrEntry(str) = 		\
833   (_XmStringEntry *)(val)
834 
835 
836 /****************************************************************
837  *
838  * Function headers
839  *
840  ****************************************************************/
841 
842 /**** Private Defines, Typedefs, and Function Declarations for XmString.c ****/
843 
844 extern XFontStruct * _XmGetFirstFont(
845                         XmFontListEntry entry) ;
846 extern Boolean _XmFontListSearch(
847                         XmFontList fontlist,
848                         XmStringCharSet charset,
849                         short *indx,
850                         XFontStruct **font_struct) ;
851 
852 extern int _XmStringIndexCacheTag(
853                         XmStringTag tag,
854                         int length) ;
855 extern XmStringTag _XmStringCacheTag(
856                         XmStringTag tag,
857                         int length) ;
858 
859 
860 extern Boolean _XmStringInitContext(
861                         _XmStringContext *context,
862                         _XmString string) ;
863 extern Boolean _XmStringGetNextSegment(
864                         _XmStringContext context,
865                         XmStringCharSet *charset,
866                         XmStringDirection *direction,
867                         char **text,
868                         short *char_count,
869                         Boolean *separator) ;
870 extern void _XmStringFreeContext(
871                         _XmStringContext context) ;
872 extern Dimension _XmStringWidth(
873                         XmFontList fontlist,
874                         _XmString string) ;
875 extern Dimension _XmStringHeight(
876                         XmFontList fontlist,
877                         _XmString string) ;
878 extern void _XmStringExtent(
879                         XmFontList fontlist,
880                         _XmString string,
881                         Dimension *width,
882                         Dimension *height) ;
883 extern Boolean _XmStringEmpty(
884                         _XmString string) ;
885 extern void _XmStringDraw(
886                         Display *d,
887                         Window w,
888                         XmFontList fontlist,
889                         _XmString string,
890                         GC gc,
891 #if NeedWidePrototypes
892                         int x,
893                         int y,
894                         int width,
895                         unsigned int align,
896                         unsigned int lay_dir,
897 #else
898                         Position x,
899                         Position y,
900                         Dimension width,
901                         unsigned char align,
902                         unsigned char lay_dir,
903 #endif /* NeedWidePrototypes */
904                         XRectangle *clip) ;
905 extern void _XmStringDrawImage(
906                         Display *d,
907                         Window w,
908                         XmFontList fontlist,
909                         _XmString string,
910                         GC gc,
911 #if NeedWidePrototypes
912                         int x,
913                         int y,
914                         int width,
915                         unsigned int align,
916                         unsigned int lay_dir,
917 #else
918                         Position x,
919                         Position y,
920                         Dimension width,
921                         unsigned char align,
922                         unsigned char lay_dir,
923 #endif /* NeedWidePrototypes */
924                         XRectangle *clip) ;
925 extern void _XmStringDrawUnderline(
926                         Display *d,
927                         Window w,
928                         XmFontList f,
929                         _XmString s,
930                         GC gc,
931 #if NeedWidePrototypes
932                         int x,
933                         int y,
934                         int width,
935                         unsigned int align,
936                         unsigned int lay_dir,
937 #else
938                         Position x,
939                         Position y,
940                         Dimension width,
941                         unsigned char align,
942                         unsigned char lay_dir,
943 #endif /* NeedWidePrototypes */
944                         XRectangle *clip,
945                         _XmString u) ;
946 extern void _XmStringDrawMnemonic(
947                         Display *d,
948                         Window w,
949                         XmFontList fontlist,
950                         _XmString string,
951                         GC gc,
952 #if NeedWidePrototypes
953                         int x,
954                         int y,
955                         int width,
956                         unsigned int align,
957                         unsigned int lay_dir,
958 #else
959                         Position x,
960                         Position y,
961                         Dimension width,
962                         unsigned char align,
963                         unsigned char lay_dir,
964 #endif /* NeedWidePrototypes */
965                         XRectangle *clip,
966                         String mnemonic,
967                         XmStringCharSet charset) ;
968 extern void _XmStringRender(Display *d,
969                             Drawable w,
970                             XmRenderTable rendertable,
971                             XmRendition rend,
972                             _XmString string,
973 #if NeedWidePrototypes
974                             int x,
975                             int y,
976                             int width,
977                             unsigned int align,
978                             unsigned int lay_dir
979 #else
980                             Position x,
981                             Position y,
982                             Dimension width,
983                             unsigned char align,
984                             unsigned char lay_dir
985 #endif	/* NeedWidePrototypes */
986                             ) ;
987 extern _XmString _XmStringCreate(
988                         XmString cs) ;
989 extern void _XmStringFree(
990                         _XmString string) ;
991 extern char * _XmStringGetCurrentCharset( void ) ;
992 extern char * _XmCharsetCanonicalize(
993                         String charset) ;
994 extern _XmString _XmStringCopy(
995                         _XmString string) ;
996 extern Boolean _XmStringByteCompare(
997                         _XmString a,
998                         _XmString b) ;
999 extern Boolean _XmStringHasSubstring(
1000                         _XmString string,
1001                         _XmString substring) ;
1002 extern XmString _XmStringCreateExternal(
1003                         XmFontList fontlist,
1004                         _XmString cs) ;
1005 extern Dimension _XmStringBaseline(
1006                         XmFontList fontlist,
1007                         _XmString string) ;
1008 extern void _XmStringGetBaselines(XmRenderTable rendertable,
1009                                   _XmString string,
1010                                   Dimension **baselines,
1011                                   Cardinal *line_count);
1012 extern int _XmStringLineCount(
1013                         _XmString string) ;
1014 extern char * _XmStringGetTextConcat(
1015                         XmString string) ;
1016 extern Boolean _XmStringIsCurrentCharset(
1017 			XmStringCharSet c) ;
1018 extern Boolean _XmStringSingleSegment(
1019 			XmString str,
1020 			char **pTextOut,
1021 			XmStringCharSet *pCharsetOut ) ;
1022 extern NextTabResult _XmStringGetNextTabWidth(XmStringContext ctx,
1023 				Widget widget,
1024                                 unsigned char units,
1025                                 XmRenderTable rt,
1026 				float *width,
1027 				XmRendition *rend);
1028 extern XtPointer _XmStringUngenerate (XmString string,
1029 			XmStringTag tag,
1030 			XmTextType tag_type,
1031 			XmTextType output_type);
1032 
1033 extern void _XmStringDrawSegment(Display *d,
1034 				 Drawable w,
1035 #if NeedWidePrototypes
1036 				 int x,
1037 				 int y,
1038 				 int width,
1039 				 int height,
1040 #else
1041 				 Position x,
1042 				 Position y,
1043 				 Dimension width,
1044 				 Dimension height,
1045 #endif /* NeedWidePrototypes */
1046 				 _XmStringNREntry seg,
1047 				 XmRendition rend,
1048 				 XmRenderTable rendertable,
1049 #if NeedWidePrototypes
1050 				 int image,
1051 #else
1052 				 Boolean image,
1053 #endif /* NeedWidePrototypes */
1054 				 XmString *underline,
1055 #if NeedWidePrototypes
1056 				 unsigned int descender
1057 #else
1058 				 Dimension descender
1059 #endif /* NeedWidePrototypes */
1060 				 );
1061 extern void _XmStringDrawLining(Display *d,
1062 				Drawable w,
1063 				Position x,
1064 				Position y,
1065 				Dimension width,
1066 				Dimension height,
1067 				Dimension descender,
1068 				XmRendition rend,
1069 				Pixel select_color,
1070 				XmHighlightMode mode,
1071 				Boolean colors_set);
1072 
1073 extern Boolean _XmStringSegmentExtents(_XmStringEntry entry,
1074 				       XmRenderTable rendertable,
1075 				       XmRendition *rend_in_out,
1076 				       XmRendition base,
1077 				       Dimension *width,
1078 				       Dimension *height,
1079 				       Dimension *ascent,
1080 				       Dimension *descent);
1081 
1082 extern void _XmStringLayout(_XmString string,
1083 #if NeedWidePrototypes
1084 			    int direction
1085 #else
1086                             XmDirection direction
1087 #endif /* NeedWidePrototypes */
1088 			    );
1089 extern _XmString _XmStringOptToNonOpt(_XmStringOpt string);
1090 extern XmString _XmStringCvtOptToMulti(XmString str);
1091 extern XmString _XmStringOptimize(XmString str);
1092 extern XmString _XmStringMakeXmString(_XmStringEntry **entries,
1093 				      int count);
1094 extern void _XmStringEntryFree(_XmStringEntry entry);
1095 extern _XmStringEntry _XmStringEntryCopy(_XmStringEntry entry);
1096 extern unsigned char _XmStringCharacterCount(XtPointer text,
1097 					     XmTextType text_type,
1098 					     int byte_count,
1099 					     XFontStruct *font);
1100 extern unsigned char _XmEntryCharCountGet(_XmStringEntry entry,
1101 					  XmRenderTable rt);
1102 extern _XmStringCache _XmStringCacheGet(_XmStringCache caches,
1103 					int type);
1104 extern void _XmStringCacheFree(_XmStringCache caches);
1105 extern XtPointer _XmScanningCacheGet(_XmStringNREntry entry,
1106 #if NeedWidePrototypes
1107 				     int d,
1108 #else
1109 				     XmDirection d,
1110 #endif /* NeedWidePrototypes */
1111 				     int field);
1112 extern void      _XmScanningCacheSet(_XmStringNREntry entry,
1113 #if NeedWidePrototypes
1114 				     int d,
1115 #else
1116 				     XmDirection d,
1117 #endif /* NeedWidePrototypes */
1118 				     int field,
1119 				     XtPointer value);
1120 /* Rendering cache */
1121 extern XtPointer _XmRenderCacheGet(_XmStringEntry entry,
1122 				   XmRenderTable rt,
1123 				   int field);
1124 extern void      _XmRenderCacheSet(_XmStringEntry entry,
1125 				   XmRenderTable rt,
1126 				   int field,
1127 				   XtPointer value);
1128 
1129 extern XmStringTag _XmStringIndexGetTag(int index);
1130 
1131 extern Boolean _XmStringGetSegment(_XmStringContext   context,
1132 				   Boolean	      update_context,
1133 				   Boolean	      copy_data,
1134 				   XtPointer         *text,
1135 				   XmStringTag       *tag,
1136 				   XmTextType        *type,
1137 				   XmStringTag      **rendition_tags,
1138 				   unsigned int      *tag_count,
1139 				   XmStringDirection *direction,
1140 				   Boolean           *separator,
1141 				   unsigned char     *tabs,
1142 				   short             *char_count,
1143 				   XmDirection       *push_before,
1144 				   Boolean	     *pop_after);
1145 
1146 /* Declarations for macro to function switchover. */
1147 extern _XmStringCache _XmEntryCacheGet(_XmStringEntry entry);
1148 extern XmStringTag _XmEntryTag(_XmStringEntry entry);
1149 extern void _XmEntryTagSet(_XmStringEntry entry, XmStringTag tag);
1150 extern XtPointer _XmEntryTextGet(_XmStringEntry entry);
1151 extern XmDirection _XmEntryPushGet(_XmStringEntry entry);
1152 extern Boolean _XmEntryPopGet(_XmStringEntry entry);
1153 extern unsigned int _XmEntryByteCountGet(_XmStringEntry entry);
1154 extern unsigned int _XmEntryDirectionGet(_XmStringEntry entry);
1155 extern void _XmEntryDirectionSet(_XmStringEntry entry, XmDirection val);
1156 extern unsigned char _XmEntryRendEndCountGet(_XmStringEntry entry);
1157 extern unsigned char _XmEntryRendBeginCountGet(_XmStringEntry entry);
1158 extern XmStringTag _XmEntryRendEndGet(_XmStringEntry entry,
1159 				      int n);
1160 extern XmStringTag _XmEntryRendBeginGet(_XmStringEntry entry,
1161 					int n);
1162 extern void _XmEntryRendEndSet(_XmStringEntry entry,
1163 			       XmStringTag tag,
1164 			       int n);
1165 extern void _XmEntryRendBeginSet(_XmStringEntry entry,
1166 				 XmStringTag tag,
1167 				 int n);
1168 extern unsigned char _XmEntryTabsGet(_XmStringEntry entry);
1169 extern unsigned int _XmEntryTextTypeGet(_XmStringEntry entry);
1170 extern void _XmEntryTextSet(_XmStringEntry entry, XtPointer val);
1171 
1172 extern unsigned char *_XmStringTruncateASN1(unsigned char *str, int n);
1173 extern void _XmStringContextCopy(_XmStringContext target,
1174 				 _XmStringContext source);
1175 extern void _XmStringContextFree(_XmStringContext target);
1176 extern XmString _XmStringNCreate(char *text, XmStringTag tag, int len);
1177 extern void _XmStringSegmentNew(_XmString string,
1178 				int line_index,
1179 				_XmStringEntry value,
1180 				int copy) ;
1181 extern void _XmStringContextReInit(_XmStringContext context,
1182 			 _XmString	  string);
1183 extern int _XmConvertFactor(unsigned char units,
1184 			    float *factor);
1185 
1186 
1187 
1188 #ifdef _XmDEBUG_XMSTRING
1189 extern void _Xm_dump_fontlist(XmFontList f) ;
1190 extern void _Xm_dump_fontlist_cache( void ) ;
1191 extern void _Xm_dump_stream( unsigned char *cs) ;
1192 extern void _Xm_dump_internal(_XmString string) ;
1193 #endif /* _XmDEBUG_XMSTRING */
1194 /********    End Private Function Declarations    ********/
1195 
1196 #ifdef __cplusplus
1197 }  /* Close scope of 'extern "C"' declaration which encloses file. */
1198 #endif
1199 
1200 #endif /* _XmStringI_h */
1201 /* DON'T ADD ANYTHING AFTER THIS #endif */
1202