quartz: Make dwSamplesProcessed a longlong.
[wine] / programs / winhelp / hlpfile.h
1 /*
2  * Help Viewer
3  *
4  * Copyright    1996 Ulrich Schmid
5  *              2002, 2008 Eric Pouech
6  *              2007 Kirill K. Smirnov
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 struct tagHelpFile;
24
25 typedef struct 
26 {
27     char        type[10];
28     char        name[9];
29     char        caption[51];
30     POINT       origin;
31     SIZE        size;
32     int         style;
33     DWORD       win_style;
34     COLORREF    sr_color;       /* color for scrollable region */
35     COLORREF    nsr_color;      /* color for non scrollable region */
36 } HLPFILE_WINDOWINFO;
37
38 typedef struct tagHlpFileLink
39 {
40     enum {hlp_link_link, hlp_link_popup, hlp_link_macro} cookie;
41     LPCSTR      string;         /* name of the file to for the link (NULL if same file) */
42     LONG        hash;           /* topic index */
43     unsigned    bClrChange : 1, /* true if the link is green & underlined */
44                 wRefCount;      /* number of internal references to this object */
45     unsigned    window;         /* window number for displaying the link (-1 is current) */
46     DWORD       cpMin;
47     DWORD       cpMax;
48     struct tagHlpFileLink* next;
49 } HLPFILE_LINK;
50
51 enum para_type {para_normal_text, para_debug_text, para_bitmap, para_metafile};
52
53 typedef struct tagHlpFileParagraph
54 {
55     enum para_type              cookie;
56
57     union
58     {
59         struct
60         {
61             LPSTR                       lpszText;
62             unsigned                    wFont;
63             unsigned                    wIndent;
64             unsigned                    wHSpace;
65             unsigned                    wVSpace;
66         } text;
67         struct
68         {
69             unsigned                    pos;    /* 0: center, 1: left, 2: right */
70             union 
71             {
72                 struct 
73                 {
74                     HBITMAP             hBitmap;
75                 } bmp;
76                 METAFILEPICT            mfp;
77             } u;
78         } gfx; /* for bitmaps and metafiles */
79     } u;
80
81     HLPFILE_LINK*               link;
82
83     struct tagHlpFileParagraph* next;
84 } HLPFILE_PARAGRAPH;
85
86 typedef struct tagHlpFileMacro
87 {
88     LPCSTR                      lpszMacro;
89     struct tagHlpFileMacro*     next;
90 } HLPFILE_MACRO;
91
92 typedef struct tagHlpFilePage
93 {
94     LPSTR                       lpszTitle;
95     HLPFILE_PARAGRAPH*          first_paragraph;
96     HLPFILE_MACRO*              first_macro;
97
98     HLPFILE_LINK*               first_link;
99
100     unsigned                    wNumber;
101     unsigned                    offset;
102     DWORD                       reference;
103     struct tagHlpFilePage*      next;
104     struct tagHlpFilePage*      prev;
105
106     DWORD                       browse_bwd;
107     DWORD                       browse_fwd;
108
109     struct tagHlpFileFile*      file;
110 } HLPFILE_PAGE;
111
112 typedef struct
113 {
114     LONG                        lMap;
115     unsigned long               offset;
116 } HLPFILE_MAP;
117
118 typedef struct
119 {
120     LOGFONT                     LogFont;
121     HFONT                       hFont;
122     COLORREF                    color;
123 } HLPFILE_FONT;
124
125 typedef struct tagHlpFileFile
126 {
127     BYTE*                       file_buffer;
128     UINT                        file_buffer_size;
129     LPSTR                       lpszPath;
130     LPSTR                       lpszTitle;
131     LPSTR                       lpszCopyright;
132     HLPFILE_PAGE*               first_page;
133     HLPFILE_PAGE*               last_page;
134     HLPFILE_MACRO*              first_macro;
135     BYTE*                       Context;
136     BYTE*                       kwbtree;
137     BYTE*                       kwdata;
138     unsigned                    wMapLen;
139     HLPFILE_MAP*                Map;
140     unsigned long               contents_start;
141
142     struct tagHlpFileFile*      prev;
143     struct tagHlpFileFile*      next;
144
145     unsigned                    wRefCount;
146
147     unsigned short              version;
148     unsigned short              flags;
149     unsigned short              charset;
150     unsigned short              tbsize;     /* topic block size */
151     unsigned short              dsize;      /* decompress size */
152     unsigned short              compressed;
153     unsigned                    hasPhrases;   /* file has |Phrases */
154     unsigned                    hasPhrases40; /* file has |PhrIndex/|PhrImage */
155     UINT                        num_phrases;
156     unsigned*                   phrases_offsets;
157     char*                       phrases_buffer;
158
159     BYTE**                      topic_map;
160     BYTE*                       topic_end;
161     UINT                        topic_maplen;
162
163     unsigned                    numBmps;
164     HBITMAP*                    bmps;
165
166     unsigned                    numFonts;
167     HLPFILE_FONT*               fonts;
168
169     unsigned                    numWindows;
170     HLPFILE_WINDOWINFO*         windows;
171     HICON                       hIcon;
172 } HLPFILE;
173
174 /*
175  * Compare function type for HLPFILE_BPTreeSearch function.
176  *
177  * PARAMS
178  *     p       [I] pointer to testing block (key + data)
179  *     key     [I] pointer to key value to look for
180  *     leaf    [I] whether this function called for index of leaf page
181  *     next    [O] pointer to pointer to next block
182  */
183 typedef int (*HLPFILE_BPTreeCompare)(void *p, const void *key,
184                                      int leaf, void **next);
185
186 /*
187  * Callback function type for HLPFILE_BPTreeEnum function.
188  *
189  * PARAMS
190  *     p       [I]  pointer to data block
191  *     next    [O]  pointer to pointer to next block
192  *     cookie  [IO] cookie data
193  */
194 typedef void (*HLPFILE_BPTreeCallback)(void *p, void **next, void *cookie);
195
196 HLPFILE*      HLPFILE_ReadHlpFile(LPCSTR lpszPath);
197 HLPFILE_PAGE* HLPFILE_Contents(HLPFILE* hlpfile, ULONG* relative);
198 HLPFILE_PAGE* HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash, ULONG* relative);
199 HLPFILE_PAGE* HLPFILE_PageByMap(HLPFILE* hlpfile, LONG lMap, ULONG* relative);
200 HLPFILE_PAGE* HLPFILE_PageByOffset(HLPFILE* hlpfile, LONG offset, ULONG* relative);
201 LONG          HLPFILE_Hash(LPCSTR lpszContext);
202 void          HLPFILE_FreeLink(HLPFILE_LINK* link);
203 void          HLPFILE_FreeHlpFile(HLPFILE*);
204 unsigned      HLPFILE_HalfPointsToTwips(unsigned pts);
205
206 static inline unsigned HLPFILE_PointsToTwips(unsigned pts)
207 {
208     return HLPFILE_HalfPointsToTwips(2 * pts);
209 }
210
211 void* HLPFILE_BPTreeSearch(BYTE*, const void*, HLPFILE_BPTreeCompare);
212 void  HLPFILE_BPTreeEnum(BYTE*, HLPFILE_BPTreeCallback cb, void *cookie);
213
214 struct RtfData {
215     BOOL        in_text;
216     char*       data;           /* RTF stream start */
217     char*       ptr;            /* current position in stream */
218     unsigned    allocated;      /* overall allocated size */
219     unsigned    char_pos;       /* current char position (in richedit) */
220     char*       where;          /* pointer to feed back richedit */
221     HLPFILE_LINK*first_link;
222     HLPFILE_LINK*current_link;
223     BOOL        force_color;
224 };
225
226 BOOL          HLPFILE_BrowsePage(HLPFILE_PAGE*, struct RtfData* rd);