1c2c66affSColin Finck /*
2c2c66affSColin Finck  * Help Viewer
3c2c66affSColin Finck  *
4c2c66affSColin Finck  * Copyright    1996 Ulrich Schmid
5c2c66affSColin Finck  * Copyright    2002 Sylvain Petreolle <spetreolle@yahoo.fr>
6c2c66affSColin Finck  *              2002 Eric Pouech
7c2c66affSColin Finck  *
8c2c66affSColin Finck  * This library is free software; you can redistribute it and/or
9c2c66affSColin Finck  * modify it under the terms of the GNU Lesser General Public
10c2c66affSColin Finck  * License as published by the Free Software Foundation; either
11c2c66affSColin Finck  * version 2.1 of the License, or (at your option) any later version.
12c2c66affSColin Finck  *
13c2c66affSColin Finck  * This library is distributed in the hope that it will be useful,
14c2c66affSColin Finck  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15c2c66affSColin Finck  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16c2c66affSColin Finck  * Lesser General Public License for more details.
17c2c66affSColin Finck  *
18c2c66affSColin Finck  * You should have received a copy of the GNU Lesser General Public
19c2c66affSColin Finck  * License along with this library; if not, write to the Free Software
20c2c66affSColin Finck  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21c2c66affSColin Finck  */
22c2c66affSColin Finck 
23*e289916aSAmine Khaldi #pragma once
24c2c66affSColin Finck 
25c2c66affSColin Finck #define MAX_LANGUAGE_NUMBER     255
26c2c66affSColin Finck #define MAX_STRING_LEN          255
27c2c66affSColin Finck 
28c2c66affSColin Finck #define INTERNAL_BORDER_WIDTH   5
29c2c66affSColin Finck #define POPUP_YDISTANCE         20
30c2c66affSColin Finck #define SHADOW_DX               10
31c2c66affSColin Finck #define SHADOW_DY               10
32c2c66affSColin Finck #define BUTTON_CX               6
33c2c66affSColin Finck #define BUTTON_CY               6
34c2c66affSColin Finck 
35c2c66affSColin Finck #ifndef RC_INVOKED
36c2c66affSColin Finck 
37c2c66affSColin Finck #include <stdarg.h>
38c2c66affSColin Finck 
39c2c66affSColin Finck #include "hlpfile.h"
40*e289916aSAmine Khaldi #include "windef.h"
41*e289916aSAmine Khaldi #include "winbase.h"
42c2c66affSColin Finck #include "macro.h"
43c2c66affSColin Finck #include "winhelp_res.h"
44c2c66affSColin Finck 
45c2c66affSColin Finck typedef struct tagHelpButton
46c2c66affSColin Finck {
47c2c66affSColin Finck     HWND                hWnd;
48c2c66affSColin Finck 
49c2c66affSColin Finck     LPCSTR              lpszID;
50c2c66affSColin Finck     LPCSTR              lpszName;
51c2c66affSColin Finck     LPCSTR              lpszMacro;
52c2c66affSColin Finck 
53c2c66affSColin Finck     WPARAM              wParam;
54c2c66affSColin Finck 
55c2c66affSColin Finck     RECT                rect;
56c2c66affSColin Finck 
57c2c66affSColin Finck     struct tagHelpButton*next;
58c2c66affSColin Finck } WINHELP_BUTTON;
59c2c66affSColin Finck 
60c2c66affSColin Finck typedef struct
61c2c66affSColin Finck {
62c2c66affSColin Finck     HLPFILE_PAGE*       page;
63c2c66affSColin Finck     HLPFILE_WINDOWINFO* wininfo;
64c2c66affSColin Finck     ULONG               relative;
65c2c66affSColin Finck } WINHELP_WNDPAGE;
66c2c66affSColin Finck 
67c2c66affSColin Finck typedef struct tagPageSet
68c2c66affSColin Finck {
69c2c66affSColin Finck     /* FIXME: for now it's a fixed size */
70c2c66affSColin Finck     WINHELP_WNDPAGE     set[40];
71c2c66affSColin Finck     unsigned            index;
72c2c66affSColin Finck } WINHELP_PAGESET;
73c2c66affSColin Finck 
74c2c66affSColin Finck typedef struct tagWinHelp
75c2c66affSColin Finck {
76c2c66affSColin Finck     unsigned            ref_count;
77c2c66affSColin Finck     WINHELP_BUTTON*     first_button;
78c2c66affSColin Finck     HLPFILE_PAGE*       page;
79c2c66affSColin Finck 
80c2c66affSColin Finck     HWND                hMainWnd;
81c2c66affSColin Finck     HWND                hHistoryWnd;
82c2c66affSColin Finck 
83c2c66affSColin Finck     WNDPROC             origRicheditWndProc;
84c2c66affSColin Finck 
85c2c66affSColin Finck     HFONT*              fonts;
86c2c66affSColin Finck     UINT                fonts_len;
87c2c66affSColin Finck 
88c2c66affSColin Finck     HCURSOR             hHandCur;
89c2c66affSColin Finck 
90c2c66affSColin Finck     HBRUSH              hBrush;
91c2c66affSColin Finck 
92c2c66affSColin Finck     HLPFILE_WINDOWINFO* info;
93c2c66affSColin Finck 
94c2c66affSColin Finck     WINHELP_PAGESET     back;
95c2c66affSColin Finck     unsigned            font_scale; /* 0 = small, 1 = normal, 2 = large */
96c2c66affSColin Finck 
97c2c66affSColin Finck     struct tagWinHelp*  next;
98c2c66affSColin Finck } WINHELP_WINDOW;
99c2c66affSColin Finck 
100c2c66affSColin Finck #define DC_NOMSG     0x00000000
101c2c66affSColin Finck #define DC_MINMAX    0x00000001
102c2c66affSColin Finck #define DC_INITTERM  0x00000002
103c2c66affSColin Finck #define DC_JUMP      0x00000004
104c2c66affSColin Finck #define DC_ACTIVATE  0x00000008
105c2c66affSColin Finck #define DC_CALLBACKS 0x00000010
106c2c66affSColin Finck 
107c2c66affSColin Finck #define DW_NOTUSED    0
108c2c66affSColin Finck #define DW_WHATMSG    1
109c2c66affSColin Finck #define DW_MINMAX     2
110c2c66affSColin Finck #define DW_SIZE       3
111c2c66affSColin Finck #define DW_INIT       4
112c2c66affSColin Finck #define DW_TERM       5
113c2c66affSColin Finck #define DW_STARTJUMP  6
114c2c66affSColin Finck #define DW_ENDJUMP    7
115c2c66affSColin Finck #define DW_CHGFILE    8
116c2c66affSColin Finck #define DW_ACTIVATE   9
117c2c66affSColin Finck #define	DW_CALLBACKS 10
118c2c66affSColin Finck 
119c2c66affSColin Finck typedef LONG (CALLBACK *WINHELP_LDLLHandler)(WORD, LONG_PTR, LONG_PTR);
120c2c66affSColin Finck 
121c2c66affSColin Finck typedef struct tagDll
122c2c66affSColin Finck {
123c2c66affSColin Finck     HANDLE              hLib;
124c2c66affSColin Finck     const char*         name;
125c2c66affSColin Finck     WINHELP_LDLLHandler handler;
126c2c66affSColin Finck     DWORD               class;
127c2c66affSColin Finck     struct tagDll*      next;
128c2c66affSColin Finck } WINHELP_DLL;
129c2c66affSColin Finck 
130c2c66affSColin Finck typedef struct
131c2c66affSColin Finck {
132c2c66affSColin Finck     UINT                wVersion;
133c2c66affSColin Finck     HANDLE              hInstance;
134c2c66affSColin Finck     BOOL                isBook;
135c2c66affSColin Finck     WINHELP_WINDOW*     active_win;
136c2c66affSColin Finck     WINHELP_WINDOW*     active_popup;
137c2c66affSColin Finck     WINHELP_WINDOW*     win_list;
138c2c66affSColin Finck     WNDPROC             button_proc;
139c2c66affSColin Finck     WINHELP_DLL*        dlls;
140c2c66affSColin Finck     WINHELP_PAGESET     history;
141c2c66affSColin Finck     HFONT               hButtonFont;
142c2c66affSColin Finck } WINHELP_GLOBALS;
143c2c66affSColin Finck 
144c2c66affSColin Finck extern const struct winhelp_callbacks
145c2c66affSColin Finck {
146c2c66affSColin Finck     WORD      (WINAPI *GetFSError)(void);
147c2c66affSColin Finck     HANDLE    (WINAPI *HfsOpenSz)(LPSTR,BYTE);
148c2c66affSColin Finck     WORD      (WINAPI *RcCloseHfs)(HANDLE);
149c2c66affSColin Finck     HANDLE    (WINAPI *HfOpenHfs)(HANDLE,LPSTR,BYTE);
150c2c66affSColin Finck     HANDLE    (WINAPI *RcCloseHf)(HANDLE);
151c2c66affSColin Finck     LONG      (WINAPI *LcbReadHf)(HANDLE,BYTE*,LONG);
152c2c66affSColin Finck     LONG      (WINAPI *LTellHf)(HANDLE);
153c2c66affSColin Finck     LONG      (WINAPI *LSeekHf)(HANDLE,LONG,WORD);
154c2c66affSColin Finck     BOOL      (WINAPI *FEofHf)(HANDLE);
155c2c66affSColin Finck     LONG      (WINAPI *LcbSizeHf)(HANDLE);
156c2c66affSColin Finck     BOOL      (WINAPI *FAccessHfs)(HANDLE,LPSTR,BYTE);
157c2c66affSColin Finck     WORD      (WINAPI *RcLLInfoFromHf)(HANDLE,WORD,LPWORD,LPLONG,LPLONG);
158c2c66affSColin Finck     WORD      (WINAPI *RcLLInfoFromHfs)(HANDLE,LPSTR,WORD,LPWORD,LPLONG,LPLONG);
159c2c66affSColin Finck     void      (WINAPI *ErrorW)(int);
160c2c66affSColin Finck     void      (WINAPI *ErrorSz)(LPSTR);
161c2c66affSColin Finck     ULONG_PTR (WINAPI *GetInfo)(WORD,HWND);
162c2c66affSColin Finck     LONG      (WINAPI *API)(LPSTR,WORD,DWORD);
163c2c66affSColin Finck } Callbacks;
164c2c66affSColin Finck 
165c2c66affSColin Finck extern WINHELP_GLOBALS Globals;
166c2c66affSColin Finck 
167c2c66affSColin Finck BOOL WINHELP_CreateHelpWindow(WINHELP_WNDPAGE*, int, BOOL);
168c2c66affSColin Finck BOOL WINHELP_OpenHelpWindow(HLPFILE_PAGE* (*)(HLPFILE*, LONG, ULONG*),
169c2c66affSColin Finck                             HLPFILE*, LONG, HLPFILE_WINDOWINFO*, int);
170c2c66affSColin Finck BOOL WINHELP_GetOpenFileName(LPSTR, int);
171c2c66affSColin Finck BOOL WINHELP_CreateIndexWindow(BOOL);
172c2c66affSColin Finck void WINHELP_DeleteBackSet(WINHELP_WINDOW*);
173c2c66affSColin Finck HLPFILE* WINHELP_LookupHelpFile(LPCSTR lpszFile);
174c2c66affSColin Finck HLPFILE_WINDOWINFO* WINHELP_GetWindowInfo(HLPFILE* hlpfile, LPCSTR name);
175c2c66affSColin Finck void WINHELP_LayoutMainWindow(WINHELP_WINDOW* win);
176c2c66affSColin Finck WINHELP_WINDOW* WINHELP_GrabWindow(WINHELP_WINDOW*);
177c2c66affSColin Finck BOOL WINHELP_ReleaseWindow(WINHELP_WINDOW*);
178c2c66affSColin Finck 
179c2c66affSColin Finck extern const char MAIN_WIN_CLASS_NAME[];
180c2c66affSColin Finck extern const char BUTTON_BOX_WIN_CLASS_NAME[];
181c2c66affSColin Finck extern const char TEXT_WIN_CLASS_NAME[];
182c2c66affSColin Finck extern const char SHADOW_WIN_CLASS_NAME[];
183c2c66affSColin Finck extern const char HISTORY_WIN_CLASS_NAME[];
184c2c66affSColin Finck extern const char STRING_BUTTON[];
185c2c66affSColin Finck extern const char STRING_MENU_Xx[];
186c2c66affSColin Finck extern const char STRING_DIALOG_TEST[];
187c2c66affSColin Finck #endif
188c2c66affSColin Finck 
189c2c66affSColin Finck /* Buttons */
190c2c66affSColin Finck #define WH_FIRST_BUTTON     500
191