hhctrl.ocx: Support HTML Help having indented Index tab items.
[wine/multimedia.git] / dlls / hhctrl.ocx / hhctrl.h
blobadff42df23148b3b1f43f2dfdc64c29b81af4261
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 "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"
37 #ifdef INIT_GUID
38 #include "initguid.h"
39 #endif
41 #include "wine/itss.h"
42 #include "wine/unicode.h"
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
51 typedef struct {
52 LPWSTR chm_file;
53 LPWSTR chm_index;
54 } ChmPath;
56 typedef struct ContentItem {
57 struct ContentItem *parent;
58 struct ContentItem *child;
59 struct ContentItem *next;
61 HTREEITEM id;
63 LPWSTR name;
64 LPWSTR local;
65 ChmPath merge;
66 } ContentItem;
68 typedef struct IndexSubItem {
69 LPWSTR name;
70 LPWSTR local;
71 } IndexSubItem;
73 typedef struct IndexItem {
74 struct IndexItem *next;
76 HTREEITEM id;
77 LPWSTR keyword;
78 ChmPath merge;
80 int nItems;
81 int itemFlags;
82 int indentLevel;
83 IndexSubItem *items;
84 } IndexItem;
86 typedef struct CHMInfo
88 IITStorage *pITStorage;
89 IStorage *pStorage;
90 WCHAR *szFile;
92 IStream *strings_stream;
93 char **strings;
94 DWORD strings_size;
96 WCHAR *defTopic;
97 WCHAR *defTitle;
98 WCHAR *defToc;
99 } CHMInfo;
101 #define TAB_CONTENTS 0
102 #define TAB_INDEX 1
103 #define TAB_SEARCH 2
104 #define TAB_FAVORITES 3
106 typedef struct {
107 HWND hwnd;
108 DWORD id;
109 } HHTab;
111 typedef struct {
112 HWND hwndList;
113 HWND hwndPopup;
114 HWND hwndCallback;
115 } IndexPopup;
117 typedef struct {
118 IOleClientSite *client_site;
119 IWebBrowser2 *web_browser;
120 IOleObject *wb_object;
122 HH_WINTYPEW WinType;
124 LPWSTR pszType;
125 LPWSTR pszCaption;
126 LPWSTR pszToc;
127 LPWSTR pszIndex;
128 LPWSTR pszFile;
129 LPWSTR pszHome;
130 LPWSTR pszJump1;
131 LPWSTR pszJump2;
132 LPWSTR pszUrlJump1;
133 LPWSTR pszUrlJump2;
134 LPWSTR pszCustomTabs;
136 CHMInfo *pCHMInfo;
137 ContentItem *content;
138 IndexItem *index;
139 IndexPopup popup;
140 HWND hwndTabCtrl;
141 HWND hwndSizeBar;
142 HFONT hFont;
144 HHTab tabs[TAB_FAVORITES+1];
145 DWORD current_tab;
146 } HHInfo;
148 BOOL InitWebBrowser(HHInfo*,HWND);
149 void ReleaseWebBrowser(HHInfo*);
150 void ResizeWebBrowser(HHInfo*,DWORD,DWORD);
151 void DoPageAction(HHInfo*,DWORD);
153 void InitContent(HHInfo*);
154 void ReleaseContent(HHInfo*);
156 void InitIndex(HHInfo*);
157 void ReleaseIndex(HHInfo*);
159 CHMInfo *OpenCHM(LPCWSTR szFile);
160 BOOL LoadWinTypeFromCHM(HHInfo *info);
161 CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
162 void SetChmPath(ChmPath*,LPCWSTR,LPCWSTR);
163 IStream *GetChmStream(CHMInfo*,LPCWSTR,ChmPath*);
164 LPWSTR FindContextAlias(CHMInfo*,DWORD);
166 HHInfo *CreateHelpViewer(LPCWSTR);
167 void ReleaseHelpViewer(HHInfo*);
168 BOOL NavigateToUrl(HHInfo*,LPCWSTR);
169 BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR);
171 /* memory allocation functions */
173 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
175 return HeapAlloc(GetProcessHeap(), 0, len);
178 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
180 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
183 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
185 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
188 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
190 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
193 static inline BOOL heap_free(void *mem)
195 return HeapFree(GetProcessHeap(), 0, mem);
198 static inline LPWSTR strdupW(LPCWSTR str)
200 LPWSTR ret;
201 int size;
203 if(!str)
204 return NULL;
206 size = (strlenW(str)+1)*sizeof(WCHAR);
207 ret = heap_alloc(size);
208 memcpy(ret, str, size);
210 return ret;
213 static inline LPWSTR strdupnAtoW(LPCSTR str, LONG lenA)
215 LPWSTR ret;
216 DWORD len;
218 if(!str)
219 return NULL;
221 if (lenA > 0)
223 /* find length of string */
224 LPCSTR eos = memchr(str, 0, lenA);
225 if (eos) lenA = eos - str;
228 len = MultiByteToWideChar(CP_ACP, 0, str, lenA, NULL, 0)+1; /* +1 for null pad */
229 ret = heap_alloc(len*sizeof(WCHAR));
230 MultiByteToWideChar(CP_ACP, 0, str, lenA, ret, len);
231 ret[len-1] = 0;
233 return ret;
236 static inline LPWSTR strdupAtoW(LPCSTR str)
238 return strdupnAtoW(str, -1);
243 extern HINSTANCE hhctrl_hinstance;
244 extern BOOL hh_process;
246 #endif