shell32: Fix the Ukrainian translation.
[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 CHMInfo
69 {
70     IITStorage *pITStorage;
71     IStorage *pStorage;
72     LPCWSTR szFile;
73
74     IStream *strings_stream;
75     char **strings;
76     DWORD strings_size;
77
78     WCHAR *defTopic;
79     WCHAR *defTitle;
80     WCHAR *defToc;
81 } CHMInfo;
82
83 #define TAB_CONTENTS   0
84 #define TAB_INDEX      1
85 #define TAB_SEARCH     2
86 #define TAB_FAVORITES  3
87
88 typedef struct {
89     HWND hwnd;
90     DWORD id;
91 } HHTab;
92
93 typedef struct {
94     IOleClientSite *client_site;
95     IWebBrowser2 *web_browser;
96     IOleObject *wb_object;
97
98     HH_WINTYPEW WinType;
99
100     LPWSTR pszType;
101     LPWSTR pszCaption;
102     LPWSTR pszToc;
103     LPWSTR pszIndex;
104     LPWSTR pszFile;
105     LPWSTR pszHome;
106     LPWSTR pszJump1;
107     LPWSTR pszJump2;
108     LPWSTR pszUrlJump1;
109     LPWSTR pszUrlJump2;
110     LPWSTR pszCustomTabs;
111
112     CHMInfo *pCHMInfo;
113     ContentItem *content;
114     HWND hwndTabCtrl;
115     HWND hwndSizeBar;
116     HFONT hFont;
117
118     HHTab tabs[TAB_FAVORITES+1];
119     DWORD current_tab;
120 } HHInfo;
121
122 BOOL InitWebBrowser(HHInfo*,HWND);
123 void ReleaseWebBrowser(HHInfo*);
124 void ResizeWebBrowser(HHInfo*,DWORD,DWORD);
125 void DoPageAction(HHInfo*,DWORD);
126
127 void InitContent(HHInfo*);
128 void ReleaseContent(HHInfo*);
129
130 CHMInfo *OpenCHM(LPCWSTR szFile);
131 BOOL LoadWinTypeFromCHM(HHInfo *info);
132 CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
133 void SetChmPath(ChmPath*,LPCWSTR,LPCWSTR);
134 IStream *GetChmStream(CHMInfo*,LPCWSTR,ChmPath*);
135 LPWSTR FindContextAlias(CHMInfo*,DWORD);
136
137 HHInfo *CreateHelpViewer(LPCWSTR);
138 void ReleaseHelpViewer(HHInfo*);
139 BOOL NavigateToUrl(HHInfo*,LPCWSTR);
140 BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR);
141
142 /* memory allocation functions */
143
144 static inline void *heap_alloc(size_t len)
145 {
146     return HeapAlloc(GetProcessHeap(), 0, len);
147 }
148
149 static inline void *heap_alloc_zero(size_t len)
150 {
151     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
152 }
153
154 static inline void *heap_realloc(void *mem, size_t len)
155 {
156     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
157 }
158
159 static inline void *heap_realloc_zero(void *mem, size_t len)
160 {
161     return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
162 }
163
164 static inline BOOL heap_free(void *mem)
165 {
166     return HeapFree(GetProcessHeap(), 0, mem);
167 }
168
169 static inline LPWSTR strdupW(LPCWSTR str)
170 {
171     LPWSTR ret;
172     int size;
173
174     if(!str)
175         return NULL;
176
177     size = (strlenW(str)+1)*sizeof(WCHAR);
178     ret = heap_alloc(size);
179     memcpy(ret, str, size);
180
181     return ret;
182 }
183
184 static inline LPWSTR strdupnAtoW(LPCSTR str, LONG lenA)
185 {
186     LPWSTR ret;
187     DWORD len;
188
189     if(!str)
190         return NULL;
191
192     if (lenA > 0)
193     {
194         /* find length of string */
195         LPCSTR eos = memchr(str, 0, lenA);
196         if (eos) lenA = eos - str;
197     }
198
199     len = MultiByteToWideChar(CP_ACP, 0, str, lenA, NULL, 0)+1; /* +1 for null pad */
200     ret = heap_alloc(len*sizeof(WCHAR));
201     MultiByteToWideChar(CP_ACP, 0, str, lenA, ret, len);
202     ret[len-1] = 0;
203
204     return ret;
205 }
206
207 static inline LPWSTR strdupAtoW(LPCSTR str)
208 {
209     return strdupnAtoW(str, -1);
210 }
211
212
213
214 extern HINSTANCE hhctrl_hinstance;
215 extern BOOL hh_process;
216
217 #endif