include/mscvpdb.h: Use flexible array members for the rest of structures.
[wine.git] / dlls / hhctrl.ocx / hhctrl.h
blobebec0eebf30411348ddefb10c73bcfdf84b71be6
1 /*
2 * Copyright 2005 James Hawkins
3 * Copyright 2007 Jacek Caban for CodeWeavers
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.
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.
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
20 #ifndef HHCTRL_H
21 #define HHCTRL_H
23 #include <stdarg.h>
25 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winternl.h"
30 #include "winuser.h"
31 #include "winnls.h"
32 #include "htmlhelp.h"
33 #include "ole2.h"
34 #include "exdisp.h"
35 #include "mshtmhst.h"
36 #include "commctrl.h"
38 #ifdef INIT_GUID
39 #include "initguid.h"
40 #endif
42 #include "wine/itss.h"
43 #include "wine/list.h"
45 #define WB_GOBACK 0
46 #define WB_GOFORWARD 1
47 #define WB_GOHOME 2
48 #define WB_SEARCH 3
49 #define WB_REFRESH 4
50 #define WB_STOP 5
51 #define WB_PRINT 6
53 typedef struct {
54 LPWSTR chm_file;
55 LPWSTR chm_index;
56 } ChmPath;
58 typedef struct ContentItem {
59 struct ContentItem *parent;
60 struct ContentItem *child;
61 struct ContentItem *next;
63 HTREEITEM id;
65 LPWSTR name;
66 LPWSTR local;
67 ChmPath merge;
68 } ContentItem;
70 typedef struct IndexSubItem {
71 LPWSTR name;
72 LPWSTR local;
73 } IndexSubItem;
75 typedef struct IndexItem {
76 struct IndexItem *next;
78 HTREEITEM id;
79 LPWSTR keyword;
80 ChmPath merge;
82 int nItems;
83 int itemFlags;
84 int indentLevel;
85 IndexSubItem *items;
86 } IndexItem;
88 typedef struct SearchItem {
89 struct SearchItem *next;
91 HTREEITEM id;
92 LPWSTR title;
93 LPWSTR filename;
94 } SearchItem;
96 typedef struct CHMInfo
98 IITStorage *pITStorage;
99 IStorage *pStorage;
100 WCHAR *szFile;
102 IStream *strings_stream;
103 char **strings;
104 DWORD strings_size;
106 WCHAR *compiledFile;
107 WCHAR *defWindow;
108 WCHAR *defTopic;
109 WCHAR *defTitle;
110 WCHAR *defToc;
112 UINT codePage;
113 } CHMInfo;
115 #define TAB_CONTENTS 0
116 #define TAB_INDEX 1
117 #define TAB_SEARCH 2
118 #define TAB_FAVORITES 3
119 #define TAB_NUMTABS TAB_FAVORITES
121 typedef struct {
122 HWND hwnd;
123 DWORD id;
124 } HHTab;
126 typedef struct {
127 HWND hwndList;
128 HWND hwndPopup;
129 HWND hwndCallback;
130 } IndexPopup;
132 typedef struct {
133 SearchItem *root;
134 HWND hwndEdit;
135 HWND hwndList;
136 HWND hwndContainer;
137 } SearchTab;
139 typedef struct {
140 HIMAGELIST hImageList;
141 } ContentsTab;
143 struct wintype_stringsW {
144 WCHAR *pszType;
145 WCHAR *pszCaption;
146 WCHAR *pszToc;
147 WCHAR *pszIndex;
148 WCHAR *pszFile;
149 WCHAR *pszHome;
150 WCHAR *pszJump1;
151 WCHAR *pszJump2;
152 WCHAR *pszUrlJump1;
153 WCHAR *pszUrlJump2;
154 WCHAR *pszCustomTabs;
157 struct wintype_stringsA {
158 char *pszType;
159 char *pszCaption;
160 char *pszToc;
161 char *pszIndex;
162 char *pszFile;
163 char *pszHome;
164 char *pszJump1;
165 char *pszJump2;
166 char *pszUrlJump1;
167 char *pszUrlJump2;
168 char *pszCustomTabs;
171 typedef struct {
172 IOleClientSite IOleClientSite_iface;
173 IOleInPlaceSite IOleInPlaceSite_iface;
174 IOleInPlaceFrame IOleInPlaceFrame_iface;
175 IDocHostUIHandler IDocHostUIHandler_iface;
177 LONG ref;
179 IOleObject *ole_obj;
180 IWebBrowser2 *web_browser;
181 HWND hwndWindow;
182 } WebBrowserContainer;
184 typedef struct {
185 WebBrowserContainer *web_browser;
187 HH_WINTYPEW WinType;
189 struct wintype_stringsA stringsA;
190 struct wintype_stringsW stringsW;
192 struct list entry;
193 CHMInfo *pCHMInfo;
194 ContentItem *content;
195 IndexItem *index;
196 IndexPopup popup;
197 SearchTab search;
198 ContentsTab contents;
199 HWND hwndTabCtrl;
200 HWND hwndSizeBar;
201 HFONT hFont;
203 HHTab tabs[TAB_FAVORITES+1];
204 int viewer_initialized;
205 DWORD current_tab;
206 } HHInfo;
208 BOOL InitWebBrowser(HHInfo*,HWND);
209 void ReleaseWebBrowser(HHInfo*);
210 void ResizeWebBrowser(HHInfo*,DWORD,DWORD);
211 void DoPageAction(WebBrowserContainer*,DWORD);
213 void InitContent(HHInfo*);
214 void ReleaseContent(HHInfo*);
215 void ActivateContentTopic(HWND,LPCWSTR,ContentItem *);
217 void InitIndex(HHInfo*);
218 void ReleaseIndex(HHInfo*);
220 CHMInfo *OpenCHM(LPCWSTR szFile);
221 BOOL LoadWinTypeFromCHM(HHInfo *info);
222 CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
223 void SetChmPath(ChmPath*,LPCWSTR,LPCWSTR);
224 IStream *GetChmStream(CHMInfo*,LPCWSTR,ChmPath*);
225 LPWSTR FindContextAlias(CHMInfo*,DWORD);
226 WCHAR *GetDocumentTitle(CHMInfo*,LPCWSTR);
228 extern struct list window_list;
229 HHInfo *CreateHelpViewer(HHInfo*,LPCWSTR,HWND);
230 void ReleaseHelpViewer(HHInfo*);
231 BOOL NavigateToUrl(HHInfo*,LPCWSTR);
232 BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR);
233 void MergeChmProperties(HH_WINTYPEW*,HHInfo*,BOOL);
234 void UpdateHelpWindow(HHInfo *info);
236 void InitSearch(HHInfo *info, const char *needle);
237 void ReleaseSearch(HHInfo *info);
239 LPCWSTR skip_schema(LPCWSTR url);
240 void wintype_stringsA_free(struct wintype_stringsA *stringsA);
241 void wintype_stringsW_free(struct wintype_stringsW *stringsW);
242 WCHAR *decode_html(const char *html_fragment, int html_fragment_len, UINT code_page);
243 HHInfo *find_window(const WCHAR *window);
245 /* memory allocation functions */
247 static inline LPWSTR strdupnAtoW(LPCSTR str, LONG lenA)
249 LPWSTR ret;
250 DWORD len;
252 if(!str)
253 return NULL;
255 if (lenA > 0)
257 /* find length of string */
258 LPCSTR eos = memchr(str, 0, lenA);
259 if (eos) lenA = eos - str;
262 len = MultiByteToWideChar(CP_ACP, 0, str, lenA, NULL, 0)+1; /* +1 for null pad */
263 ret = malloc(len * sizeof(WCHAR));
264 MultiByteToWideChar(CP_ACP, 0, str, lenA, ret, len);
265 ret[len-1] = 0;
267 return ret;
270 static inline LPWSTR strdupAtoW(LPCSTR str)
272 return strdupnAtoW(str, -1);
275 static inline LPSTR strdupWtoA(LPCWSTR str)
277 LPSTR ret;
278 DWORD len;
280 if(!str)
281 return NULL;
283 len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
284 ret = malloc(len);
285 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, len, NULL, NULL);
286 return ret;
290 extern HINSTANCE hhctrl_hinstance;
291 extern BOOL hh_process;
293 #endif