mshtml: Keep reference in node returned from get_node.
[wine] / dlls / hhctrl.ocx / hhctrl.h
1 /*
2  * Copyright 2005 James Hawkins
3  * Copyright 2007 Jacek Caban for CodeWeavers
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19
20 #ifndef HHCTRL_H
21 #define HHCTRL_H
22
23 #include <stdarg.h>
24
25 #define COBJMACROS
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "winnls.h"
31 #include "htmlhelp.h"
32 #include "ole2.h"
33 #include "exdisp.h"
34 #include "mshtmhst.h"
35 #include "commctrl.h"
36
37 #ifdef INIT_GUID
38 #include "initguid.h"
39 #endif
40
41 #include "wine/itss.h"
42 #include "wine/unicode.h"
43
44 #define WB_GOBACK     0
45 #define WB_GOFORWARD  1
46 #define WB_GOHOME     2
47 #define WB_SEARCH     3
48 #define WB_REFRESH    4
49 #define WB_STOP       5
50 #define WB_PRINT      6
51
52 typedef struct {
53     LPWSTR chm_file;
54     LPWSTR chm_index;
55 } ChmPath;
56
57 typedef struct ContentItem {
58     struct ContentItem *parent;
59     struct ContentItem *child;
60     struct ContentItem *next;
61
62     HTREEITEM id;
63
64     LPWSTR name;
65     LPWSTR local;
66     ChmPath merge;
67 } ContentItem;
68
69 typedef struct IndexSubItem {
70     LPWSTR name;
71     LPWSTR local;
72 } IndexSubItem;
73
74 typedef struct IndexItem {
75     struct IndexItem *next;
76
77     HTREEITEM id;
78     LPWSTR keyword;
79     ChmPath merge;
80
81     int nItems;
82     int itemFlags;
83     int indentLevel;
84     IndexSubItem *items;
85 } IndexItem;
86
87 typedef struct SearchItem {
88     struct SearchItem *next;
89
90     HTREEITEM id;
91     LPWSTR title;
92     LPWSTR filename;
93 } SearchItem;
94
95 typedef struct CHMInfo
96 {
97     IITStorage *pITStorage;
98     IStorage *pStorage;
99     WCHAR *szFile;
100
101     IStream *strings_stream;
102     char **strings;
103     DWORD strings_size;
104
105     WCHAR *compiledFile;
106     WCHAR *defTopic;
107     WCHAR *defTitle;
108     WCHAR *defToc;
109
110     UINT codePage;
111 } CHMInfo;
112
113 #define TAB_CONTENTS   0
114 #define TAB_INDEX      1
115 #define TAB_SEARCH     2
116 #define TAB_FAVORITES  3
117 #define TAB_NUMTABS    TAB_FAVORITES
118
119 typedef struct {
120     HWND hwnd;
121     DWORD id;
122 } HHTab;
123
124 typedef struct {
125     HWND hwndList;
126     HWND hwndPopup;
127     HWND hwndCallback;
128 } IndexPopup;
129
130 typedef struct {
131     SearchItem *root;
132     HWND hwndEdit;
133     HWND hwndList;
134     HWND hwndContainer;
135 } SearchTab;
136
137 typedef struct {
138     HIMAGELIST hImageList;
139 } ContentsTab;
140
141 typedef struct {
142     IOleClientSite *client_site;
143     IWebBrowser2 *web_browser;
144     IOleObject *wb_object;
145
146     HH_WINTYPEW WinType;
147
148     LPWSTR pszType;
149     LPWSTR pszCaption;
150     LPWSTR pszToc;
151     LPWSTR pszIndex;
152     LPWSTR pszFile;
153     LPWSTR pszHome;
154     LPWSTR pszJump1;
155     LPWSTR pszJump2;
156     LPWSTR pszUrlJump1;
157     LPWSTR pszUrlJump2;
158     LPWSTR pszCustomTabs;
159
160     CHMInfo *pCHMInfo;
161     ContentItem *content;
162     IndexItem *index;
163     IndexPopup popup;
164     SearchTab search;
165     ContentsTab contents;
166     HWND hwndTabCtrl;
167     HWND hwndSizeBar;
168     HFONT hFont;
169
170     HHTab tabs[TAB_FAVORITES+1];
171     DWORD current_tab;
172 } HHInfo;
173
174 BOOL InitWebBrowser(HHInfo*,HWND) DECLSPEC_HIDDEN;
175 void ReleaseWebBrowser(HHInfo*) DECLSPEC_HIDDEN;
176 void ResizeWebBrowser(HHInfo*,DWORD,DWORD) DECLSPEC_HIDDEN;
177 void DoPageAction(HHInfo*,DWORD) DECLSPEC_HIDDEN;
178
179 void InitContent(HHInfo*) DECLSPEC_HIDDEN;
180 void ReleaseContent(HHInfo*) DECLSPEC_HIDDEN;
181 void ActivateContentTopic(HWND,LPCWSTR,ContentItem *) DECLSPEC_HIDDEN;
182
183 void InitIndex(HHInfo*) DECLSPEC_HIDDEN;
184 void ReleaseIndex(HHInfo*) DECLSPEC_HIDDEN;
185
186 CHMInfo *OpenCHM(LPCWSTR szFile) DECLSPEC_HIDDEN;
187 BOOL LoadWinTypeFromCHM(HHInfo *info) DECLSPEC_HIDDEN;
188 CHMInfo *CloseCHM(CHMInfo *pCHMInfo) DECLSPEC_HIDDEN;
189 void SetChmPath(ChmPath*,LPCWSTR,LPCWSTR) DECLSPEC_HIDDEN;
190 IStream *GetChmStream(CHMInfo*,LPCWSTR,ChmPath*) DECLSPEC_HIDDEN;
191 LPWSTR FindContextAlias(CHMInfo*,DWORD) DECLSPEC_HIDDEN;
192
193 HHInfo *CreateHelpViewer(LPCWSTR) DECLSPEC_HIDDEN;
194 void ReleaseHelpViewer(HHInfo*) DECLSPEC_HIDDEN;
195 BOOL NavigateToUrl(HHInfo*,LPCWSTR) DECLSPEC_HIDDEN;
196 BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR) DECLSPEC_HIDDEN;
197
198 void InitSearch(HHInfo *info, const char *needle) DECLSPEC_HIDDEN;
199 void ReleaseSearch(HHInfo *info) DECLSPEC_HIDDEN;
200
201 LPCWSTR skip_schema(LPCWSTR url) DECLSPEC_HIDDEN;
202
203 WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_page);
204
205 /* memory allocation functions */
206
207 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
208 {
209     return HeapAlloc(GetProcessHeap(), 0, len);
210 }
211
212 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
213 {
214     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
215 }
216
217 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
218 {
219     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
220 }
221
222 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
223 {
224     return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
225 }
226
227 static inline BOOL heap_free(void *mem)
228 {
229     return HeapFree(GetProcessHeap(), 0, mem);
230 }
231
232 static inline LPWSTR strdupW(LPCWSTR str)
233 {
234     LPWSTR ret;
235     int size;
236
237     if(!str)
238         return NULL;
239
240     size = (strlenW(str)+1)*sizeof(WCHAR);
241     ret = heap_alloc(size);
242     memcpy(ret, str, size);
243
244     return ret;
245 }
246
247 static inline LPWSTR strdupnAtoW(LPCSTR str, LONG lenA)
248 {
249     LPWSTR ret;
250     DWORD len;
251
252     if(!str)
253         return NULL;
254
255     if (lenA > 0)
256     {
257         /* find length of string */
258         LPCSTR eos = memchr(str, 0, lenA);
259         if (eos) lenA = eos - str;
260     }
261
262     len = MultiByteToWideChar(CP_ACP, 0, str, lenA, NULL, 0)+1; /* +1 for null pad */
263     ret = heap_alloc(len*sizeof(WCHAR));
264     MultiByteToWideChar(CP_ACP, 0, str, lenA, ret, len);
265     ret[len-1] = 0;
266
267     return ret;
268 }
269
270 static inline LPWSTR strdupAtoW(LPCSTR str)
271 {
272     return strdupnAtoW(str, -1);
273 }
274
275
276
277 extern HINSTANCE hhctrl_hinstance DECLSPEC_HIDDEN;
278 extern BOOL hh_process DECLSPEC_HIDDEN;
279
280 #endif