Merge branch 'master' into cde-next
[oweals/cde.git] / cde / lib / DtHelp / CanvasI.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-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 libraries 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 /* $XConsortium: CanvasI.h /main/18 1996/10/21 13:59:51 cde-hp $ */
24 /*************************************<+>*************************************
25  *****************************************************************************
26  **
27  **  File:   CanvasI.h
28  **
29  **  Project:
30  **
31  **  Description:  Public Header file for Canvas.c
32  **
33  **  (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
34  **
35  **  (c) Copyright 1993, 1994 Hewlett-Packard Company
36  **  (c) Copyright 1993, 1994 International Business Machines Corp.
37  **  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
38  **  (c) Copyright 1993, 1994 Novell, Inc.
39  *******************************************************************
40  *************************************<+>*************************************/
41 #ifndef _DtCanvasI_h
42 #define _DtCanvasI_h
43
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 #include <stdlib.h>
50
51 /********    Internal Defines Declarations    ********/
52 #define _DtCvLINE_HORZ  0
53 #define _DtCvLINE_VERT  1
54
55 /********    Internal Enum Declarations    ********/
56 enum    _dtCvTraversalType
57   {
58         _DtCvTraversalNone,
59         _DtCvTraversalLink,
60         _DtCvTraversalMark
61   };
62
63 /********    Internal Typedef Declarations    ********/
64
65 #if !defined(_DtCvLinkMgrP_h) && !defined(_DtCvLinkMgrI_h)
66 typedef struct  _dtCvLinkDb*    _DtCvLinkDb;
67 #endif
68
69 typedef enum    _dtCvTraversalType      _DtCvTraversalType;
70
71 /* adding this typedef so that debugging can access the structure */
72 typedef struct  _dtCvSegment            _DtCvSegmentI;
73 typedef struct  _dtCvSegPts             _DtCvSegPtsI;
74
75 /********    Internal Structures Declarations    ********/
76
77 typedef struct _dtCvDspLine {
78         _DtCvValue       processed;
79         _DtCvUnit        text_x;
80         _DtCvUnit        max_x;
81         _DtCvUnit        baseline;
82         _DtCvUnit        descent;
83         _DtCvUnit        ascent;
84         int              byte_index;
85         int              length;
86         _DtCvSegmentI   *seg_ptr;
87 } _DtCvDspLine;
88
89 typedef struct  _dtCvLineSeg {
90         _DtCvValue       processed;
91         short           dir;
92         _DtCvUnit       pos_x;
93         _DtCvUnit       max_x;
94         _DtCvUnit       pos_y;
95         _DtCvUnit       max_y;
96         _DtCvUnit       width;
97         _DtCvPointer    data;
98 } _DtCvLineSeg;
99
100 typedef struct _dtCvPointData {
101         _DtCvUnit       x;
102         _DtCvUnit       y;              /* baseline of the line */
103         int             line_idx;
104         int             char_idx;
105 } _DtCvPointData;
106
107 typedef struct  _dtCvMarkData {
108         _DtCvValue      on;
109         _DtCvPointer    client_data;
110         _DtCvPointData  beg;
111         _DtCvPointData  end;
112 } _DtCvMarkData;
113
114 typedef struct  _dtCvTraversalInfo {
115         _DtCvValue               active;
116         _DtCvTraversalType       type;  /* the type of the traversal */
117         int                      idx;   /* the index into the approp. struct */
118                                         /* either the txt_lst or marks  */
119         _DtCvUnit                x_pos; /* x pos on the line.              */
120         _DtCvUnit                y_pos; /* top y pos of bounding box       */
121         _DtCvUnit                width; /* width of link on 1st line only  */
122         _DtCvUnit                height; /* height of 1st line bounding box */
123         _DtCvSegmentI           *seg_ptr; /* ptr to first seg of link        */
124 } _DtCvTraversalInfo;
125
126 typedef struct  _dtCvSearchData {
127         int             idx;    /* the line index of the search hit */
128         _DtCvDspLine    *lst;   /* pointer to the text line list    */
129 } _DtCvSearchData;
130
131 typedef struct _dtCanvasStruct {
132         int             error;
133         long            txt_cnt;        /* maximum used in txt_list     */
134         int             txt_max;        /* maximum in txt_list          */
135
136         int             line_cnt;       /* maximum used in line_lst     */
137         int             line_max;       /* maximum in line_lst          */
138         int             mark_cnt;       /* mark counter                 */
139         int             mark_max;       /* maximum in mark_lst          */
140
141         int             trav_cnt;       /* maximum used in trav_lst     */
142         int             trav_max;       /* maximum in trav_lst          */
143         int             cur_trav;       /* traversal indicator          */
144
145         int             search_cnt;
146         int             search_max;
147
148         int             brk_cnt;        /* the number of page breaks    */
149         int             brk_max;        /* the maxium entries           */
150
151         short           mb_length;      /* The maximum length of a char */
152
153         _DtCvUnit               max_x;          /* The maximum x position */
154         _DtCvUnit               max_y;          /* The maximum y position */
155         _DtCvValue              constraint;     /* Indicates if the right
156                                                    boundary can be breached */
157         _DtCvValue              trav_on;        /* Indicates if the traversal
158                                                    is on or off.            */
159         _DtCvPointer            client_data;
160         _DtCvMetrics            metrics;
161         _DtCvSpaceMetrics       link_info;
162         _DtCvSpaceMetrics       traversal_info;
163         _DtCvLocale             locale;
164
165         _DtCvSegmentI           *element_lst;
166         _DtCvDspLine            *txt_lst;
167         _DtCvLineSeg            *line_lst;
168         _DtCvTraversalInfo      *trav_lst;
169         _DtCvLinkDb              link_data;
170         _DtCvPointData           select_start;
171         _DtCvPointData           select_end;
172         _DtCvMarkData           *marks;
173         _DtCvSearchData         *searchs;
174         _DtCvUnit               *pg_breaks;
175         _DtCvVirtualInfo         virt_functions;
176
177 } _DtCanvasStruct;
178
179 /********    Internal Structure Typedef Declarations    ********/
180 typedef struct _dtCvPointData   _DtCvSelectData;
181
182 /********    Internal Macros Declarations    ********/
183
184 #define _DtCvHasTraversal(x)    ((x) & _DtCvTRAVERSAL_FLAG)
185
186 /*
187  * segment type access
188  */
189 #define _DtCvIsTypeNoop(x) \
190                 ((((x) & _DtCvPRIMARY_MASK) == _DtCvNOOP) ? 1 : 0)
191
192 /*
193  * Is a flag set
194  */
195 #define _DtCvIsSegVisibleLink(x)        _DtCvIsSegHyperText(x)
196 #define _DtCvIsSegALink(x) \
197                         (_DtCvIsSegHyperText(x) || _DtCvIsSegGhostLink(x))
198
199 #define _DtCvIsMarkMaskOn(x) \
200                         (((x) & _DtCvACTIVATE_MARK_ON) ? _DtCvTRUE : _DtCvFALSE)
201
202 /*
203  * remove masks
204  */
205 #define _DtCvRemoveBeginFlags(x)        x &= ~(_DtCvTRAVERSAL_BEGIN | \
206                                                _DtCvLINK_BEGIN      | \
207                                                _DtCvMARK_BEGIN      | \
208                                                _DtCvSEARCH_BEGIN)
209 #define _DtCvSetSearchEnd(x,seg)        x |= ((seg)->type & _DtCvSEARCH_END)
210 #define _DtCvSetSearchBegin(x,seg)      x |= ((seg)->type & _DtCvSEARCH_BEGIN)
211 #define _DtCvClearSearchFlags(x)        x &= ~(_DtCvSEARCH_FLAG  | \
212                                                _DtCvSEARCH_BEGIN | \
213                                                _DtCvSEARCH_END)
214
215 #define _DtCvClearLinkFlags(x)          x &= ~(_DtCvLINK_FLAG   | \
216                                                _DtCvLINK_BEGIN  | \
217                                                _DtCvLINK_END    | \
218                                                _DtCvLINK_POP_UP | \
219                                                _DtCvLINK_NEW_WINDOW)
220
221 #define _DtCvClearProcessed(x)  (x).processed = False
222 #define _DtCvSetProcessed(x)    (x).processed = True
223 #define _DtCvIsProcessed(x)     (x).processed
224 #define _DtCvIsNotProcessed(x)  ((False == (x).processed) ? True : False)
225 #define _DtCvStraddlesPt(pt,min,max)    ((min) <= (pt)  && (pt)  <= (max))
226
227 /********    Internal Function Declarations    ********/
228 extern  _DtCvUnit       _DtCvAdjustForSuperSub(
229                                 _DtCanvasStruct   *canvas,
230                                 _DtCvSegmentI     *p_seg,
231                                 _DtCvUnit         start_x,
232                                 _DtCvUnit        *script_x,
233                                 _DtCvUnit        *super_width,
234                                 _DtCvUnit        *super_y,
235                                 _DtCvUnit        *sub_width,
236                                 _DtCvUnit        *sub_y,
237                                 _DtCvValue       *super_flag,
238                                 _DtCvValue       *sub_flag);
239 extern  _DtCvUnit       _DtCvAdvanceXOfLine (
240                                 _DtCanvasStruct   *canvas,
241                                 _DtCvSegmentI     *p_seg,
242                                 _DtCvUnit         x_pos,
243                                 int              *link_idx,
244                                 _DtCvValue       *link_flag);
245 extern  _DtCvStatus     _DtCvCheckInfringement (
246                                 _DtCvUnit          tst_top,
247                                 _DtCvUnit          tst_bot,
248                                 _DtCvUnit          obj_top,
249                                 _DtCvUnit          obj_bot);
250 extern  void            _DtCvCheckLineMarks (
251                                 _DtCanvasStruct   *canvas,
252                                 int                line_idx,
253                                 int                char_idx,
254                                 int                length,
255                                 _DtCvUnit          dst_x,
256                                 _DtCvFlags         check_flags,
257                                 int               *ret_len,
258                                 _DtCvFlags        *ret_old,
259                                 _DtCvFlags        *ret_new);
260 extern  void            _DtCvClearInternalUse (
261                                 _DtCvSegmentI    *list,
262                                 _DtCvStatus       flag);
263 extern  _DtCvUnit       _DtCvDrawSegments(
264                                 _DtCanvasStruct  *canvas,
265                                 _DtCvDspLine      line,
266                                 _DtCvSegmentI    *p_seg,
267                                 int               start_char,
268                                 int               count,
269                                 int              *prev_lnk,
270                                 _DtCvUnit         txt_x,
271                                 _DtCvUnit         sel_x,
272                                 _DtCvUnit        *scriptX,
273                                 _DtCvUnit        *super_width,
274                                 _DtCvUnit        *super_y,
275                                 _DtCvUnit        *sub_width,
276                                 _DtCvUnit        *sub_y,
277                                 _DtCvValue       *last_was_sub,
278                                 _DtCvValue       *last_was_super,
279                                 _DtCvValue       *last_link_vis,
280                                 _DtCvFlags        old_flag,
281                                 _DtCvFlags        new_flag,
282                                 _DtCvElemType     trav_flag,
283                                 _DtCvPointer      trav_data);
284 extern  int             _DtCvGetCharIdx(
285                                 _DtCanvasStruct  *canvas,
286                                 _DtCvDspLine      line,
287                                 _DtCvUnit         find_x);
288 extern  _DtCvUnit       _DtCvGetStartXOfLine(
289                                 _DtCvDspLine     *line,
290                                 _DtCvSegmentI   **pSeg);
291 extern  void            _DtCvGetWidthOfSegment(
292                                 _DtCanvasStruct  *canvas,
293                                 _DtCvSegmentI    *p_seg,
294                                 int               start,
295                                 int               max_cnt,
296                                 int              *ret_cnt,
297                                 _DtCvUnit        *ret_w,
298                                 _DtCvValue       *ret_trimmed);
299 extern  _DtCvValue      _DtCvModifyXpos(
300                                 _DtCvSpaceMetrics info,
301                                 _DtCvSegmentI   *seg,
302                                 _DtCvValue       tst_result,
303                                 _DtCvValue       old_result,
304                                 int              idx,
305                                 _DtCvUnit       *x_pos);
306 extern  void            _DtCvSkipLineChars(
307                                 _DtCanvasStruct  *canvas,
308                                 _DtCvSegmentI    *p_seg,
309                                 int               start,
310                                 int               max_cnt,
311                                 int               use_len,
312                                 int              *ret_start,
313                                 _DtCvSegmentI    **ret_seg);
314
315 #ifdef __cplusplus
316 }  /* Close scope of 'extern "C"' declaration which encloses file. */
317 #endif
318
319 #endif /* _DtCanvasI_h */
320 /* DON'T ADD ANYTHING AFTER THIS #endif */