Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtHelp / GraphicsP.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 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 /* $XConsortium: GraphicsP.h /main/4 1996/05/09 03:43:09 drk $ */
24 #ifndef _DtGraphicsP_h
25 #define _DtGraphicsP_h
26
27 #include <stdio.h>
28 #include <X11/Intrinsic.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 /* 
34  * Input stream data structures
35  */
36
37 /* Stream source types */ 
38 enum _DtGrStreamType { _DtGrNONE, _DtGrBUFFER, _DtGrFILE };
39
40 /* Stream file data */
41 typedef struct
42 {
43     FILE *fileptr;
44     char *filename;
45     char *uncompressed_filename;
46 } _DtGrFile;
47
48 /* Stream buffer data */
49 typedef struct
50 {
51     const char *base;
52     long       size;
53     char       *current;
54     char       *end;
55 } _DtGrBuffer;
56
57 /* Stream data */
58 typedef struct
59 {
60     enum _DtGrStreamType  type;
61     union
62     {
63         _DtGrFile    file;
64         _DtGrBuffer  buffer;
65     } source;
66 } _DtGrStream;
67
68 /*
69  * Input stream function prototypes
70  */
71
72 /* Open a file stream */
73 int _DtGrOpenFile(
74     _DtGrStream *stream,
75     const char  *path
76 );
77
78 /* Open a buffer stream */
79 int _DtGrOpenBuffer(
80     _DtGrStream *stream,
81     const char  *buffer,
82     int         buffer_size
83 );
84
85 /* Close a stream */
86 int _DtGrCloseStream(
87     _DtGrStream *stream
88 );
89
90 /* Reads data from a stream into a buffer */
91 size_t _DtGrRead(
92     void        *buffer,
93     size_t      size,
94     size_t      num_items,
95     _DtGrStream *stream
96 );
97
98 /* Sets the position of the next input operation on a stream */
99 int _DtGrSeek(
100     _DtGrStream *stream,
101     long        offset,
102     int         whence
103 );
104
105 /* Reads a character from a stream and advances the stream position */
106 int _DtGrGetChar(
107     _DtGrStream *stream
108 );
109
110 /* Reads a string from a stream and advances the stream position */
111 char *_DtGrGetString(
112     char        *buffer,
113     int         num_bytes,
114     _DtGrStream *stream
115 );
116
117 /*
118  * Inline graphics data structures
119  */
120
121 enum _DtGrColorModel { _DtGrCOLOR, _DtGrGRAY_SCALE, _DtGrBITONAL };
122 enum _DtGrLoadStatus { _DtGrSUCCESS, _DtGrCOLOR_REDUCE,_DtGrCONVERT_FAILURE, 
123                        _DtGrOPEN_FAILED, _DtGrFILE_INVALID, _DtGrNO_MEMORY, 
124                        _DtGrCOLOR_FAILED };
125
126 /* Context structure used by image type converters */
127 typedef struct {
128     char *image_type;
129     XPointer context;
130 } _DtGrContext;
131
132 typedef enum _DtGrLoadStatus (*_DtGrLoadProc)(
133     _DtGrStream           *stream,
134     Screen                *screen,
135     int                   depth,
136     Colormap              colormap,
137     Visual                *visual,
138     Pixel                 foreground,
139     Pixel                 background,
140     GC                    gc,
141     enum _DtGrColorModel  color_model,
142     Boolean               allow_reduced_colors,
143     Dimension             *in_out_width,
144     Dimension             *in_out_height,
145     unsigned short        media_resolution,
146     Pixmap                *ret_pixmap,
147     Pixmap                *ret_mask,
148     Pixel                 **ret_colors,
149     int                   *ret_num_colors,
150     _DtGrContext          *context);
151
152 typedef void (*_DtGrDestroyContextProc)(
153     _DtGrContext *context);
154
155 /*
156  * Inline graphics function prototypes
157  */
158
159 /* Loads an image into a pixmap */
160 enum _DtGrLoadStatus _DtGrLoad(
161     _DtGrStream           *stream,
162     char                  **image_type,
163     Screen                *screen,
164     int                   depth,
165     Colormap              colormap,
166     Visual                *visual,
167     Pixel                 foreground,
168     Pixel                 background,
169     GC                    gc,
170     enum _DtGrColorModel  color_model,
171     Boolean               allow_reduced_colors,
172     Dimension             *in_out_width,
173     Dimension             *in_out_height,
174     unsigned short        media_resolution,
175     Pixmap                *ret_pixmap,
176     Pixmap                *ret_mask,
177     Pixel                 **ret_colors,
178     int                   *ret_num_colors,
179     _DtGrContext          *context);
180
181 /* Destroys a context */
182 void _DtGrDestroyContext(
183     _DtGrContext *context);
184
185 /* Registers a converter for a graphic type */
186 void _DtGrRegisterConverter(
187     char                    *image_type,
188     _DtGrLoadProc           convert_proc,
189     _DtGrDestroyContextProc destroy_context_proc,
190     _DtGrLoadProc           *current_convert_proc,
191     _DtGrDestroyContextProc *current_destroy_proc);
192
193 #ifdef __cplusplus
194 }
195 #endif
196 #endif /* _DtGraphicsP_h */
197 /* DON'T ADD ANYTHING AFTER THIS #endif */