hhctrl.ocx: Added HH_HELP_CONTEXT implementation.
[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
36 #ifdef INIT_GUID
37 #include "initguid.h"
38 #endif
39
40 #include "wine/itss.h"
41 #include "wine/unicode.h"
42
43 #define WB_GOBACK     0
44 #define WB_GOFORWARD  1
45 #define WB_GOHOME     2
46 #define WB_SEARCH     3
47 #define WB_REFRESH    4
48 #define WB_STOP       5
49
50 typedef struct CHMInfo
51 {
52     IITStorage *pITStorage;
53     IStorage *pStorage;
54     LPCWSTR szFile;
55
56     IStream *strings_stream;
57     char **strings;
58     DWORD strings_size;
59 } CHMInfo;
60
61
62 typedef struct {
63     IOleClientSite *client_site;
64     IWebBrowser2 *web_browser;
65     IOleObject *wb_object;
66
67     HH_WINTYPEW WinType;
68     CHMInfo *pCHMInfo;
69     HWND hwndTabCtrl;
70     HWND hwndSizeBar;
71     HFONT hFont;
72 } HHInfo;
73
74 BOOL InitWebBrowser(HHInfo*,HWND);
75 void ReleaseWebBrowser(HHInfo*);
76 void ResizeWebBrowser(HHInfo*,DWORD,DWORD);
77 void DoPageAction(HHInfo*,DWORD);
78
79 CHMInfo *OpenCHM(LPCWSTR szFile);
80 BOOL LoadWinTypeFromCHM(CHMInfo *pCHMInfo, HH_WINTYPEW *pHHWinType);
81 CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
82 LPWSTR FindContextAlias(CHMInfo*,DWORD);
83
84 HHInfo *CreateHelpViewer(LPCWSTR);
85 void ReleaseHelpViewer(HHInfo*);
86 BOOL NavigateToUrl(HHInfo*,LPCWSTR);
87 BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR);
88
89 /* memory allocation functions */
90
91 static inline void *hhctrl_alloc(size_t len)
92 {
93     return HeapAlloc(GetProcessHeap(), 0, len);
94 }
95
96 static inline void *hhctrl_alloc_zero(size_t len)
97 {
98     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
99 }
100
101 static inline void *hhctrl_realloc(void *mem, size_t len)
102 {
103     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
104 }
105
106 static inline void *hhctrl_realloc_zero(void *mem, size_t len)
107 {
108     return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
109 }
110
111 static inline BOOL hhctrl_free(void *mem)
112 {
113     return HeapFree(GetProcessHeap(), 0, mem);
114 }
115
116 static inline LPWSTR strdupW(LPCWSTR str)
117 {
118     LPWSTR ret;
119     int size;
120
121     if(!str)
122         return NULL;
123
124     size = (strlenW(str)+1)*sizeof(WCHAR);
125     ret = hhctrl_alloc(size);
126     memcpy(ret, str, size);
127
128     return ret;
129 }
130
131 static inline LPWSTR strdupAtoW(LPCSTR str)
132 {
133     LPWSTR ret;
134     DWORD len;
135
136     if(!str)
137         return NULL;
138
139     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
140     ret = hhctrl_alloc(len*sizeof(WCHAR));
141     MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
142
143     return ret;
144 }
145
146 extern HINSTANCE hhctrl_hinstance;
147 extern BOOL hh_process;
148
149 #endif