gdi32: Declare some functions static.
[wine] / dlls / hhctrl.ocx / hhctrl.c
1 /*
2  * hhctrl implementation
3  *
4  * Copyright 2004 Krzysztof Foltman
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdarg.h>
22 #include <string.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wingdi.h"
26 #include "winnls.h"
27 #include "winuser.h"
28 #include "wine/debug.h"
29 #include "htmlhelp.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
32
33 int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine);
34
35 static const char *command_to_string(UINT command)
36 {
37 #define X(x) case x: return #x
38     switch (command)
39     {
40         X( HH_DISPLAY_TOPIC );
41         X( HH_DISPLAY_TOC );
42         X( HH_DISPLAY_INDEX );
43         X( HH_DISPLAY_SEARCH );
44         X( HH_SET_WIN_TYPE );
45         X( HH_GET_WIN_TYPE );
46         X( HH_GET_WIN_HANDLE );
47         X( HH_ENUM_INFO_TYPE );
48         X( HH_SET_INFO_TYPE );
49         X( HH_SYNC );
50         X( HH_RESERVED1 );
51         X( HH_RESERVED2 );
52         X( HH_RESERVED3 );
53         X( HH_KEYWORD_LOOKUP );
54         X( HH_DISPLAY_TEXT_POPUP );
55         X( HH_HELP_CONTEXT );
56         X( HH_TP_HELP_CONTEXTMENU );
57         X( HH_TP_HELP_WM_HELP );
58         X( HH_CLOSE_ALL );
59         X( HH_ALINK_LOOKUP );
60         X( HH_GET_LAST_ERROR );
61         X( HH_ENUM_CATEGORY );
62         X( HH_ENUM_CATEGORY_IT );
63         X( HH_RESET_IT_FILTER );
64         X( HH_SET_INCLUSIVE_FILTER );
65         X( HH_SET_EXCLUSIVE_FILTER );
66         X( HH_INITIALIZE );
67         X( HH_UNINITIALIZE );
68         X( HH_PRETRANSLATEMESSAGE );
69         X( HH_SET_GLOBAL_PROPERTY );
70     default: return "???";
71     }
72 #undef X
73 }
74
75 HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
76 {
77     CHAR *file = NULL;
78
79     TRACE("(%p, %s, command=%s, data=%d)\n",
80           caller, debugstr_w( filename ),
81           command_to_string( command ), data);
82
83     if (filename)
84     {
85         DWORD len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL );
86
87         file = HeapAlloc( GetProcessHeap(), 0, len );
88         WideCharToMultiByte( CP_ACP, 0, filename, -1, file, len, NULL, NULL );
89     }
90
91     switch (command)
92     {
93         case HH_DISPLAY_TOPIC:
94         case HH_DISPLAY_TOC:
95         case HH_DISPLAY_SEARCH:
96         case HH_HELP_CONTEXT:
97             FIXME("Not all HH cases handled correctly\n");
98             doWinMain(GetModuleHandleW(NULL), file);
99             break;
100         default:
101             FIXME("HH case %s not handled.\n", command_to_string( command ));
102     }
103     HeapFree(GetProcessHeap(), 0, file);
104     return 0;
105 }
106
107 HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD data)
108 {
109     WCHAR *wfile = NULL;
110     HWND result;
111
112     if (filename)
113     {
114         DWORD len = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
115
116         wfile = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR));
117         MultiByteToWideChar( CP_ACP, 0, filename, -1, wfile, len );
118     }
119
120     result = HtmlHelpW( caller, wfile, command, data );
121
122     HeapFree( GetProcessHeap(), 0, wfile );
123     return result;
124 }