winhelp: Display keywords index dialog box.

This commit is contained in:
Kirill K. Smirnov 2007-12-13 00:56:18 +03:00 committed by Alexandre Julliard
parent 6a2ad1b479
commit d72cfb7342
7 changed files with 173 additions and 1 deletions

View File

@ -50,6 +50,16 @@ MAIN_MENU MENU LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
}
}
IDD_INDEX DIALOG DISCARDABLE 0, 0, 200, 190 LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Shell Dlg"
CAPTION "Index"
{
LISTBOX IDC_INDEXLIST, 10, 10, 180, 150, LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_BORDER
PUSHBUTTON "&OK", IDOK, 40, 170, 50, 12
PUSHBUTTON "&Cancel", IDCANCEL, 120, 170, 50, 12
}
/* Strings */
STRINGTABLE DISCARDABLE LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
{

View File

@ -49,6 +49,16 @@ MAIN_MENU MENU LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
}
}
IDD_INDEX DIALOG DISCARDABLE 0, 0, 200, 190 LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Shell Dlg"
CAPTION "Óêàçàòåëü"
{
LISTBOX IDC_INDEXLIST, 10, 10, 180, 150, LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_BORDER
PUSHBUTTON "&OK", IDOK, 40, 170, 50, 12
PUSHBUTTON "&Îòìåíà", IDCANCEL, 120, 170, 50, 12
}
/* Strings */
STRINGTABLE DISCARDABLE LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
{

View File

@ -523,7 +523,7 @@ void CALLBACK MACRO_Find(void)
void CALLBACK MACRO_Finder(void)
{
WINE_FIXME("()\n");
WINHELP_CreateIndexWindow();
}
void CALLBACK MACRO_FloatingMenu(void)

View File

@ -20,6 +20,7 @@
*/
#include <windef.h>
#include <winuser.h>
#include "winhelp.h"
#include "winhelp_res.h"

View File

@ -670,6 +670,20 @@ BOOL WINHELP_CreateHelpWindowByMap(HLPFILE* hlpfile, LONG lMap,
return WINHELP_CreateHelpWindow(page, wi, nCmdShow);
}
/***********************************************************************
*
* WINHELP_CreateHelpWindowByOffset
*/
BOOL WINHELP_CreateHelpWindowByOffset(HLPFILE* hlpfile, LONG lOffset,
HLPFILE_WINDOWINFO* wi, int nCmdShow)
{
HLPFILE_PAGE* page = NULL;
page = HLPFILE_PageByOffset(hlpfile, lOffset);
if (page) page->file->wRefCount++;
return WINHELP_CreateHelpWindow(page, wi, nCmdShow);
}
/***********************************************************************
*
* WINHELP_MainWndProc
@ -1933,3 +1947,135 @@ WINHELP_LINE_PART* WINHELP_IsOverLink(WINHELP_WINDOW* win, WPARAM wParam, LPARAM
return NULL;
}
/**************************************************************************
* cb_KWBTree
*
* HLPFILE_BPTreeCallback enumeration function for '|KWBTREE' internal file.
*
*/
static void cb_KWBTree(void *p, void **next, void *cookie)
{
HWND hListWnd = (HWND)cookie;
WINE_TRACE("Adding '%s' to search list\n", (char *)p);
SendMessage(hListWnd, LB_INSERTSTRING, -1, (LPARAM)p);
*next = (char*)p + strlen((char*)p) + 7;
}
/**************************************************************************
* comp_KWBTREE
*
* HLPFILE_BPTreeCompare function for '|KWBTREE' internal file.
*
*/
static int comp_KWBTree(void *p, const void *key,
int leaf, void** next)
{
WINE_TRACE("comparing key '%s' with '%s'\n", (char *)p, (char *)key);
*next = (char*)p+strlen(p)+1+(leaf?6:2);
/* unlike directory, index is case insensitive */
return lstrcmpi(p, key);
}
/**************************************************************************
* WINHELP_IndexDlgProc
*
* Index dialog callback function.
*
*/
INT_PTR CALLBACK WINHELP_SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HLPFILE *file;
int sel;
ULONG offset = 1;
switch (msg)
{
case WM_INITDIALOG:
file = (HLPFILE *)lParam;
HLPFILE_BPTreeEnum(file->kwbtree, cb_KWBTree,
GetDlgItem(hWnd, IDC_INDEXLIST));
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
sel = SendDlgItemMessage(hWnd, IDC_INDEXLIST, LB_GETCURSEL, 0, 0);
if (sel != LB_ERR)
{
char buf[500]; /* enough */
BYTE *p;
int count;
SendDlgItemMessage(hWnd, IDC_INDEXLIST, LB_GETTEXT,
sel, (LPARAM)buf);
p = HLPFILE_BPTreeSearch(file->kwbtree, buf, comp_KWBTree);
if (p == NULL)
{
/*
* TODO:
* This may happen if help file uses other locale than
* system. We should honour charset provided in help file
* and use UNICODE, but for now current implementation is
* acceptable (almost all help files use ANSI).
*/
WINE_FIXME("item '%s' not found, locale mismatch???\n", buf);
return TRUE;
}
count = *(short*)((char *)p + strlen((char *)p) + 1);
if (count > 1)
{
MessageBox(hWnd, "count > 1 not supported yet", "Error", MB_OK | MB_ICONSTOP);
return TRUE;
}
offset = *(ULONG*)((char *)p + strlen((char *)p) + 3);
offset = *(long*)(file->kwdata + offset + 9);
if (offset == 0xFFFFFFFF)
{
MessageBox(hWnd, "macro keywords not supported yet", "Error", MB_OK | MB_ICONSTOP);
return TRUE;
}
}
/* Fall through */
case IDCANCEL:
EndDialog(hWnd, offset);
return TRUE;
default:
break;
}
default:
break;
}
return FALSE;
}
/**************************************************************************
* WINHELP_CreateIndexWindow
*
* Displays a dialog with keywords of current help file.
*
*/
BOOL WINHELP_CreateIndexWindow(void)
{
int ret;
HLPFILE *hlpfile;
if (Globals.active_win && Globals.active_win->page && Globals.active_win->page->file)
hlpfile = Globals.active_win->page->file;
else
return FALSE;
if (hlpfile->kwbtree == NULL)
{
WINE_TRACE("No index provided\n");
return FALSE;
}
ret = DialogBoxParam(Globals.hInstance, MAKEINTRESOURCE(IDD_INDEX),
Globals.active_win->hMainWnd, WINHELP_SearchDlgProc,
(LPARAM)hlpfile);
if (ret > 1)
WINHELP_CreateHelpWindowByOffset(hlpfile, ret, Globals.active_win->info, SW_NORMAL);
return TRUE;
}

View File

@ -172,8 +172,10 @@ extern FARPROC Callbacks[];
BOOL WINHELP_CreateHelpWindowByHash(HLPFILE*, LONG, HLPFILE_WINDOWINFO*, int);
BOOL WINHELP_CreateHelpWindowByMap(HLPFILE*, LONG, HLPFILE_WINDOWINFO*, int);
BOOL WINHELP_CreateHelpWindowByOffset(HLPFILE*, LONG, HLPFILE_WINDOWINFO*, int);
BOOL WINHELP_CreateHelpWindow(HLPFILE_PAGE*, HLPFILE_WINDOWINFO*, int);
BOOL WINHELP_GetOpenFileName(LPSTR, int);
BOOL WINHELP_CreateIndexWindow(void);
INT WINHELP_MessageBoxIDS(UINT, UINT, WORD);
INT WINHELP_MessageBoxIDS_s(UINT, LPCSTR, UINT, WORD);
HLPFILE* WINHELP_LookupHelpFile(LPCSTR lpszFile);

View File

@ -30,3 +30,6 @@
#define STID_HELP_FILES_HLP 0x12C
#define STID_DIALOG_TEST 0x12D
#define STID_FILE_NOT_FOUND_s 0x12E
#define IDD_INDEX 0x150
#define IDC_INDEXLIST 0x151