wintrust: Fix copy-paste error.
[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
51 typedef struct {
52     LPWSTR chm_file;
53     LPWSTR chm_index;
54 } ChmPath;
55
56 typedef struct ContentItem {
57     struct ContentItem *parent;
58     struct ContentItem *child;
59     struct ContentItem *next;
60
61     HTREEITEM id;
62
63     LPWSTR name;
64     LPWSTR local;
65     ChmPath merge;
66 } ContentItem;
67
68 typedef struct IndexSubItem {
69     LPWSTR name;
70     LPWSTR local;
71 } IndexSubItem;
72
73 typedef struct IndexItem {
74     struct IndexItem *next;
75
76     HTREEITEM id;
77     LPWSTR keyword;
78     ChmPath merge;
79
80     int nItems;
81     int itemFlags;
82     IndexSubItem *items;
83 } IndexItem;
84
85 typedef struct CHMInfo
86 {
87     IITStorage *pITStorage;
88     IStorage *pStorage;
89     WCHAR *szFile;
90
91     IStream *strings_stream;
92     char **strings;
93     DWORD strings_size;
94
95     WCHAR *defTopic;
96     WCHAR *defTitle;
97     WCHAR *defToc;
98 } CHMInfo;
99
100 #define TAB_CONTENTS   0
101 #define TAB_INDEX      1
102 #define TAB_SEARCH     2
103 #define TAB_FAVORITES  3
104
105 typedef struct {
106     HWND hwnd;
107     DWORD id;
108 } HHTab;
109
110 typedef struct {
111     HWND hwndList;
112     HWND hwndPopup;
113     HWND hwndCallback;
114 } IndexPopup;
115
116 typedef struct {
117     IOleClientSite *client_site;
118     IWebBrowser2 *web_browser;
119     IOleObject *wb_object;
120
121     HH_WINTYPEW WinType;
122
123     LPWSTR pszType;
124     LPWSTR pszCaption;
125     LPWSTR pszToc;
126     LPWSTR pszIndex;
127     LPWSTR pszFile;
128     LPWSTR pszHome;
129     LPWSTR pszJump1;
130     LPWSTR pszJump2;
131     LPWSTR pszUrlJump1;
132     LPWSTR pszUrlJump2;
133     LPWSTR pszCustomTabs;
134
135     CHMInfo *pCHMInfo;
136     ContentItem *content;
137     IndexItem *index;
138     IndexPopup popup;
139     HWND hwndTabCtrl;
140     HWND hwndSizeBar;
141     HFONT hFont;
142
143     HHTab tabs[TAB_FAVORITES+1];
144     DWORD current_tab;
145 } HHInfo;
146
147 BOOL InitWebBrowser(HHInfo*,HWND);
148 void ReleaseWebBrowser(HHInfo*);
149 void ResizeWebBrowser(HHInfo*,DWORD,DWORD);
150 void DoPageAction(HHInfo*,DWORD);
151
152 void InitContent(HHInfo*);
153 void ReleaseContent(HHInfo*);
154
155 void InitIndex(HHInfo*);
156 void ReleaseIndex(HHInfo*);
157
158 CHMInfo *OpenCHM(LPCWSTR szFile);
159 BOOL LoadWinTypeFromCHM(HHInfo *info);
160 CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
161 void SetChmPath(ChmPath*,LPCWSTR,LPCWSTR);
162 IStream *GetChmStream(CHMInfo*,LPCWSTR,ChmPath*);
163 LPWSTR FindContextAlias(CHMInfo*,DWORD);
164
165 HHInfo *CreateHelpViewer(LPCWSTR);
166 void ReleaseHelpViewer(HHInfo*);
167 BOOL NavigateToUrl(HHInfo*,LPCWSTR);
168 BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR);
169
170 /* memory allocation functions */
171
172 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
173 {
174     return HeapAlloc(GetProcessHeap(), 0, len);
175 }
176
177 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
178 {
179     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
180 }
181
182 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
183 {
184     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
185 }
186
187 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
188 {
189     return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
190 }
191
192 static inline BOOL heap_free(void *mem)
193 {
194     return HeapFree(GetProcessHeap(), 0, mem);
195 }
196
197 static inline LPWSTR strdupW(LPCWSTR str)
198 {
199     LPWSTR ret;
200     int size;
201
202     if(!str)
203         return NULL;
204
205     size = (strlenW(str)+1)*sizeof(WCHAR);
206     ret = heap_alloc(size);
207     memcpy(ret, str, size);
208
209     return ret;
210 }
211
212 static inline LPWSTR strdupnAtoW(LPCSTR str, LONG lenA)
213 {
214     LPWSTR ret;
215     DWORD len;
216
217     if(!str)
218         return NULL;
219
220     if (lenA > 0)
221     {
222         /* find length of string */
223         LPCSTR eos = memchr(str, 0, lenA);
224         if (eos) lenA = eos - str;
225     }
226
227     len = MultiByteToWideChar(CP_ACP, 0, str, lenA, NULL, 0)+1; /* +1 for null pad */
228     ret = heap_alloc(len*sizeof(WCHAR));
229     MultiByteToWideChar(CP_ACP, 0, str, lenA, ret, len);
230     ret[len-1] = 0;
231
232     return ret;
233 }
234
235 static inline LPWSTR strdupAtoW(LPCSTR str)
236 {
237     return strdupnAtoW(str, -1);
238 }
239
240
241
242 extern HINSTANCE hhctrl_hinstance;
243 extern BOOL hh_process;
244
245 #endif