Kirill K. Smirnov : winhelp: Display keywords index dialog box.
Alexandre Julliard
julliard at winehq.org
Thu Dec 13 08:23:11 CST 2007
Module: wine
Branch: master
Commit: d72cfb73424ffbb21cd72c4e56e3336e7048419c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d72cfb73424ffbb21cd72c4e56e3336e7048419c
Author: Kirill K. Smirnov <lich at math.spbu.ru>
Date: Thu Dec 13 00:56:18 2007 +0300
winhelp: Display keywords index dialog box.
---
programs/winhelp/En.rc | 10 +++
programs/winhelp/Ru.rc | 10 +++
programs/winhelp/macro.c | 2 +-
programs/winhelp/rsrc.rc | 1 +
programs/winhelp/winhelp.c | 146 ++++++++++++++++++++++++++++++++++++++++
programs/winhelp/winhelp.h | 2 +
programs/winhelp/winhelp_res.h | 3 +
7 files changed, 173 insertions(+), 1 deletions(-)
diff --git a/programs/winhelp/En.rc b/programs/winhelp/En.rc
index 8c4bac2..464b185 100644
--- a/programs/winhelp/En.rc
+++ b/programs/winhelp/En.rc
@@ -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
{
diff --git a/programs/winhelp/Ru.rc b/programs/winhelp/Ru.rc
index c07a743..4767d06 100644
--- a/programs/winhelp/Ru.rc
+++ b/programs/winhelp/Ru.rc
@@ -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
{
diff --git a/programs/winhelp/macro.c b/programs/winhelp/macro.c
index c658bf6..68863bf 100644
--- a/programs/winhelp/macro.c
+++ b/programs/winhelp/macro.c
@@ -523,7 +523,7 @@ void CALLBACK MACRO_Find(void)
void CALLBACK MACRO_Finder(void)
{
- WINE_FIXME("()\n");
+ WINHELP_CreateIndexWindow();
}
void CALLBACK MACRO_FloatingMenu(void)
diff --git a/programs/winhelp/rsrc.rc b/programs/winhelp/rsrc.rc
index 3670d48..8109916 100644
--- a/programs/winhelp/rsrc.rc
+++ b/programs/winhelp/rsrc.rc
@@ -20,6 +20,7 @@
*/
#include <windef.h>
+#include <winuser.h>
#include "winhelp.h"
#include "winhelp_res.h"
diff --git a/programs/winhelp/winhelp.c b/programs/winhelp/winhelp.c
index 83c6517..f769153 100644
--- a/programs/winhelp/winhelp.c
+++ b/programs/winhelp/winhelp.c
@@ -672,6 +672,20 @@ BOOL WINHELP_CreateHelpWindowByMap(HLPFILE* hlpfile, LONG lMap,
/***********************************************************************
*
+ * 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
*/
static LRESULT CALLBACK WINHELP_MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -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;
+}
diff --git a/programs/winhelp/winhelp.h b/programs/winhelp/winhelp.h
index 24eb10f..abe68ea 100644
--- a/programs/winhelp/winhelp.h
+++ b/programs/winhelp/winhelp.h
@@ -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);
diff --git a/programs/winhelp/winhelp_res.h b/programs/winhelp/winhelp_res.h
index a6e46f1..14ec13f 100644
--- a/programs/winhelp/winhelp_res.h
+++ b/programs/winhelp/winhelp_res.h
@@ -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
More information about the wine-cvs
mailing list