riched20/tests: Remove the todo_wine logic where appropriate.
[wine] / programs / winhlp32 / 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     unsigned    window;         /* window number for displaying the link (-1 is current) */
45     DWORD       cpMin;
46     DWORD       cpMax;
47     struct tagHlpFileLink* next;
48 } HLPFILE_LINK;
49
50 typedef struct tagHlpFileMacro
51 {
52     LPCSTR                      lpszMacro;
53     struct tagHlpFileMacro*     next;
54 } HLPFILE_MACRO;
55
56 typedef struct tagHlpFilePage
57 {
58     LPSTR                       lpszTitle;
59     HLPFILE_MACRO*              first_macro;
60
61     HLPFILE_LINK*               first_link;
62
63     unsigned                    wNumber;
64     unsigned                    offset;
65     DWORD                       reference;
66     struct tagHlpFilePage*      next;
67     struct tagHlpFilePage*      prev;
68
69     DWORD                       browse_bwd;
70     DWORD                       browse_fwd;
71
72     struct tagHlpFileFile*      file;
73 } HLPFILE_PAGE;
74
75 typedef struct
76 {
77     LONG                        lMap;
78     unsigned long               offset;
79 } HLPFILE_MAP;
80
81 typedef struct
82 {
83     LOGFONT                     LogFont;
84     HFONT                       hFont;
85     COLORREF                    color;
86 } HLPFILE_FONT;
87
88 typedef struct tagHlpFileFile
89 {
90     BYTE*                       file_buffer;
91     UINT                        file_buffer_size;
92     LPSTR                       lpszPath;
93     LPSTR                       lpszTitle;
94     LPSTR                       lpszCopyright;
95     HLPFILE_PAGE*               first_page;
96     HLPFILE_PAGE*               last_page;
97     HLPFILE_MACRO*              first_macro;
98     BYTE*                       Context;
99     BYTE*                       kwbtree;
100     BYTE*                       kwdata;
101     unsigned                    wMapLen;
102     HLPFILE_MAP*                Map;
103     unsigned                    wTOMapLen;
104     unsigned*                   TOMap;
105     unsigned long               contents_start;
106
107     struct tagHlpFileFile*      prev;
108     struct tagHlpFileFile*      next;
109
110     unsigned                    wRefCount;
111
112     unsigned short              version;
113     unsigned short              flags;
114     unsigned short              charset;
115     unsigned short              tbsize;     /* topic block size */
116     unsigned short              dsize;      /* decompress size */
117     unsigned short              compressed;
118     unsigned                    hasPhrases;   /* file has |Phrases */
119     unsigned                    hasPhrases40; /* file has |PhrIndex/|PhrImage */
120     UINT                        num_phrases;
121     unsigned*                   phrases_offsets;
122     char*                       phrases_buffer;
123
124     BYTE**                      topic_map;
125     BYTE*                       topic_end;
126     UINT                        topic_maplen;
127
128     unsigned                    numBmps;
129     HBITMAP*                    bmps;
130
131     unsigned                    numFonts;
132     HLPFILE_FONT*               fonts;
133
134     unsigned                    numWindows;
135     HLPFILE_WINDOWINFO*         windows;
136     HICON                       hIcon;
137
138     BOOL                        has_popup_color;
139     COLORREF                    popup_color;
140
141     LPSTR                       help_on_file;
142 } HLPFILE;
143
144 /*
145  * Compare function type for HLPFILE_BPTreeSearch function.
146  *
147  * PARAMS
148  *     p       [I] pointer to testing block (key + data)
149  *     key     [I] pointer to key value to look for
150  *     leaf    [I] whether this function called for index of leaf page
151  *     next    [O] pointer to pointer to next block
152  */
153 typedef int (*HLPFILE_BPTreeCompare)(void *p, const void *key,
154                                      int leaf, void **next);
155
156 /*
157  * Callback function type for HLPFILE_BPTreeEnum function.
158  *
159  * PARAMS
160  *     p       [I]  pointer to data block
161  *     next    [O]  pointer to pointer to next block
162  *     cookie  [IO] cookie data
163  */
164 typedef void (*HLPFILE_BPTreeCallback)(void *p, void **next, void *cookie);
165
166 HLPFILE*      HLPFILE_ReadHlpFile(LPCSTR lpszPath);
167 HLPFILE_PAGE* HLPFILE_Contents(HLPFILE* hlpfile, ULONG* relative);
168 HLPFILE_PAGE* HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash, ULONG* relative);
169 HLPFILE_PAGE* HLPFILE_PageByMap(HLPFILE* hlpfile, LONG lMap, ULONG* relative);
170 HLPFILE_PAGE* HLPFILE_PageByOffset(HLPFILE* hlpfile, LONG offset, ULONG* relative);
171 LONG          HLPFILE_Hash(LPCSTR lpszContext);
172 void          HLPFILE_FreeHlpFile(HLPFILE*);
173 unsigned      HLPFILE_HalfPointsToTwips(unsigned pts);
174
175 static inline unsigned HLPFILE_PointsToTwips(unsigned pts)
176 {
177     return HLPFILE_HalfPointsToTwips(2 * pts);
178 }
179
180 void* HLPFILE_BPTreeSearch(BYTE*, const void*, HLPFILE_BPTreeCompare);
181 void  HLPFILE_BPTreeEnum(BYTE*, HLPFILE_BPTreeCallback cb, void *cookie);
182
183 struct RtfData {
184     BOOL        in_text;
185     char*       data;           /* RTF stream start */
186     char*       ptr;            /* current position in stream */
187     unsigned    allocated;      /* overall allocated size */
188     unsigned    char_pos;       /* current char position (in richedit) */
189     char*       where;          /* pointer to feed back richedit */
190     unsigned    font_scale;     /* how to scale fonts */
191     HLPFILE_LINK*first_link;
192     HLPFILE_LINK*current_link;
193     BOOL        force_color;
194     unsigned    relative;       /* offset within page to lookup for */
195     unsigned    char_pos_rel;   /* char_pos correspondinf to relative */
196 };
197
198 BOOL          HLPFILE_BrowsePage(HLPFILE_PAGE*, struct RtfData* rd,
199                                  unsigned font_scale, unsigned relative);