Commit a4480365 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winhelp: Added ability to locate information within a page (and to store it inside WNDPAGE).

parent 61cc5106
......@@ -96,21 +96,12 @@ static HLPFILE_PAGE *HLPFILE_PageByNumber(HLPFILE* hlpfile, UINT wNum)
return page;
}
/* FIXME:
* this finds the page containing the offset. The offset can either
* refer to the top of the page (offset == page->offset), or
* to some paragraph inside the page...
* As of today, we only return the page... we should also return
* a paragraph, and then, while opening a new page, compute the
* y-offset of the paragraph to be shown and scroll the window
* accordingly
*/
/******************************************************************
* HLPFILE_PageByOffset
*
*
*/
HLPFILE_PAGE *HLPFILE_PageByOffset(HLPFILE* hlpfile, LONG offset)
HLPFILE_PAGE *HLPFILE_PageByOffset(HLPFILE* hlpfile, LONG offset, ULONG* relative)
{
HLPFILE_PAGE* page;
HLPFILE_PAGE* found;
......@@ -125,7 +116,10 @@ HLPFILE_PAGE *HLPFILE_PageByOffset(HLPFILE* hlpfile, LONG offset)
for (found = NULL, page = hlpfile->first_page; page; page = page->next)
{
if (page->offset <= offset && (!found || found->offset < page->offset))
{
*relative = offset - page->offset;
found = page;
}
}
if (!found)
WINE_ERR("Page of offset %u not found in file %s\n",
......@@ -156,7 +150,7 @@ static int comp_PageByHash(void *p, const void *key,
*
* HLPFILE_HlpFilePageByHash
*/
HLPFILE_PAGE *HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash)
HLPFILE_PAGE *HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash, ULONG* relative)
{
BYTE *ptr;
......@@ -166,7 +160,10 @@ HLPFILE_PAGE *HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash)
/* For win 3.0 files hash values are really page numbers */
if (hlpfile->version <= 16)
{
*relative = 0;
return HLPFILE_PageByNumber(hlpfile, lHash);
}
ptr = HLPFILE_BPTreeSearch(hlpfile->Context, LongToPtr(lHash), comp_PageByHash);
if (!ptr)
......@@ -175,14 +172,14 @@ HLPFILE_PAGE *HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash)
return NULL;
}
return HLPFILE_PageByOffset(hlpfile, GET_UINT(ptr, 4));
return HLPFILE_PageByOffset(hlpfile, GET_UINT(ptr, 4), relative);
}
/***********************************************************************
*
* HLPFILE_PageByMap
*/
HLPFILE_PAGE *HLPFILE_PageByMap(HLPFILE* hlpfile, LONG lMap)
HLPFILE_PAGE *HLPFILE_PageByMap(HLPFILE* hlpfile, LONG lMap, ULONG* relative)
{
unsigned int i;
......@@ -193,7 +190,7 @@ HLPFILE_PAGE *HLPFILE_PageByMap(HLPFILE* hlpfile, LONG lMap)
for (i = 0; i < hlpfile->wMapLen; i++)
{
if (hlpfile->Map[i].lMap == lMap)
return HLPFILE_PageByOffset(hlpfile, hlpfile->Map[i].offset);
return HLPFILE_PageByOffset(hlpfile, hlpfile->Map[i].offset, relative);
}
WINE_ERR("Page of Map %x not found in file %s\n", lMap, hlpfile->lpszPath);
......@@ -204,14 +201,18 @@ HLPFILE_PAGE *HLPFILE_PageByMap(HLPFILE* hlpfile, LONG lMap)
*
* HLPFILE_Contents
*/
HLPFILE_PAGE* HLPFILE_Contents(HLPFILE *hlpfile)
HLPFILE_PAGE* HLPFILE_Contents(HLPFILE *hlpfile, ULONG* relative)
{
HLPFILE_PAGE* page = NULL;
if (!hlpfile) return NULL;
page = HLPFILE_PageByOffset(hlpfile, hlpfile->contents_start);
if (!page) page = hlpfile->first_page;
page = HLPFILE_PageByOffset(hlpfile, hlpfile->contents_start, relative);
if (!page)
{
page = hlpfile->first_page;
*relative = 0;
}
return page;
}
......
......@@ -188,10 +188,10 @@ typedef int (*HLPFILE_BPTreeCompare)(void *p, const void *key,
typedef void (*HLPFILE_BPTreeCallback)(void *p, void **next, void *cookie);
HLPFILE* HLPFILE_ReadHlpFile(LPCSTR lpszPath);
HLPFILE_PAGE* HLPFILE_Contents(HLPFILE* hlpfile);
HLPFILE_PAGE* HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash);
HLPFILE_PAGE* HLPFILE_PageByMap(HLPFILE* hlpfile, LONG lMap);
HLPFILE_PAGE* HLPFILE_PageByOffset(HLPFILE* hlpfile, LONG offset);
HLPFILE_PAGE* HLPFILE_Contents(HLPFILE* hlpfile, ULONG* relative);
HLPFILE_PAGE* HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash, ULONG* relative);
HLPFILE_PAGE* HLPFILE_PageByMap(HLPFILE* hlpfile, LONG lMap, ULONG* relative);
HLPFILE_PAGE* HLPFILE_PageByOffset(HLPFILE* hlpfile, LONG offset, ULONG* relative);
LONG HLPFILE_Hash(LPCSTR lpszContext);
void HLPFILE_FreeLink(HLPFILE_LINK* link);
void HLPFILE_FreeHlpFile(HLPFILE*);
......
......@@ -246,15 +246,16 @@ void CALLBACK MACRO_BookmarkMore(void)
void CALLBACK MACRO_BrowseButtons(void)
{
HLPFILE_PAGE* page = Globals.active_win->page;
ULONG relative;
WINE_TRACE("()\n");
MACRO_CreateButton("BTN_PREV", "&<<", "Prev()");
MACRO_CreateButton("BTN_NEXT", "&>>", "Next()");
if (!HLPFILE_PageByOffset(page->file, page->browse_bwd))
if (!HLPFILE_PageByOffset(page->file, page->browse_bwd, &relative))
MACRO_DisableButton("BTN_PREV");
if (!HLPFILE_PageByOffset(page->file, page->browse_fwd))
if (!HLPFILE_PageByOffset(page->file, page->browse_fwd, &relative))
MACRO_DisableButton("BTN_NEXT");
}
......@@ -718,7 +719,7 @@ void CALLBACK MACRO_Next(void)
WINE_TRACE("()\n");
wp.page = Globals.active_win->page;
wp.page = HLPFILE_PageByOffset(wp.page->file, wp.page->browse_fwd);
wp.page = HLPFILE_PageByOffset(wp.page->file, wp.page->browse_fwd, &wp.relative);
if (wp.page)
{
wp.page->file->wRefCount++;
......@@ -758,7 +759,7 @@ void CALLBACK MACRO_Prev(void)
WINE_TRACE("()\n");
wp.page = Globals.active_win->page;
wp.page = HLPFILE_PageByOffset(wp.page->file, wp.page->browse_bwd);
wp.page = HLPFILE_PageByOffset(wp.page->file, wp.page->browse_bwd, &wp.relative);
if (wp.page)
{
wp.page->file->wRefCount++;
......
......@@ -53,7 +53,7 @@ static void WINHELP_InitFonts(HWND hWnd);
static void WINHELP_DeleteLines(WINHELP_WINDOW*);
static void WINHELP_DeleteWindow(WINHELP_WINDOW*);
static void WINHELP_DeleteButtons(WINHELP_WINDOW*);
static void WINHELP_SetupText(HWND hWnd);
static void WINHELP_SetupText(HWND hWnd, ULONG relative);
static WINHELP_LINE_PART* WINHELP_IsOverLink(WINHELP_WINDOW*, WPARAM, LPARAM);
WINHELP_GLOBALS Globals = {3, NULL, NULL, TRUE, NULL, NULL, NULL, NULL, {{{NULL,NULL}},0}};
......@@ -560,7 +560,8 @@ BOOL WINHELP_CreateHelpWindow(WINHELP_WNDPAGE* wpage, int nCmdShow, BOOL remembe
win->page = wpage->page;
win->info = wpage->wininfo;
WINHELP_SetupText(GetDlgItem(win->hMainWnd, CTL_ID_TEXT));
WINHELP_SetupText(GetDlgItem(win->hMainWnd, CTL_ID_TEXT), wpage->relative);
InvalidateRect(win->hMainWnd, NULL, TRUE);
if (win->hHistoryWnd) InvalidateRect(win->hHistoryWnd, NULL, TRUE);
break;
......@@ -669,8 +670,8 @@ BOOL WINHELP_CreateHelpWindowByHash(HLPFILE* hlpfile, LONG lHash,
wpage.page = NULL;
if (hlpfile)
wpage.page = lHash ? HLPFILE_PageByHash(hlpfile, lHash) :
HLPFILE_Contents(hlpfile);
wpage.page = lHash ? HLPFILE_PageByHash(hlpfile, lHash, &wpage.relative) :
HLPFILE_Contents(hlpfile, &wpage.relative);
if (wpage.page) wpage.page->file->wRefCount++;
wpage.wininfo = wi;
return WINHELP_CreateHelpWindow(&wpage, nCmdShow, TRUE);
......@@ -685,7 +686,7 @@ BOOL WINHELP_CreateHelpWindowByMap(HLPFILE* hlpfile, LONG lMap,
{
WINHELP_WNDPAGE wpage;
wpage.page = HLPFILE_PageByMap(hlpfile, lMap);
wpage.page = HLPFILE_PageByMap(hlpfile, lMap, &wpage.relative);
if (wpage.page) wpage.page->file->wRefCount++;
wpage.wininfo = wi;
return WINHELP_CreateHelpWindow(&wpage, nCmdShow, TRUE);
......@@ -700,7 +701,7 @@ BOOL WINHELP_CreateHelpWindowByOffset(HLPFILE* hlpfile, LONG lOffset,
{
WINHELP_WNDPAGE wpage;
wpage.page = HLPFILE_PageByOffset(hlpfile, lOffset);
wpage.page = HLPFILE_PageByOffset(hlpfile, lOffset, &wpage.relative);
if (wpage.page) wpage.page->file->wRefCount++;
wpage.wininfo = wi;
return WINHELP_CreateHelpWindow(&wpage, nCmdShow, TRUE);
......@@ -1022,7 +1023,7 @@ static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam,
case WM_WINDOWPOSCHANGED:
winpos = (WINDOWPOS*) lParam;
if (!(winpos->flags & SWP_NOSIZE)) WINHELP_SetupText(hWnd);
if (!(winpos->flags & SWP_NOSIZE)) WINHELP_SetupText(hWnd, 0);
break;
case WM_MOUSEWHEEL:
......@@ -1359,7 +1360,7 @@ static LRESULT CALLBACK WINHELP_ShadowWndProc(HWND hWnd, UINT msg, WPARAM wParam
*
* SetupText
*/
static void WINHELP_SetupText(HWND hWnd)
static void WINHELP_SetupText(HWND hWnd, ULONG relative)
{
HDC hDc = GetDC(hWnd);
RECT rect;
......
......@@ -95,6 +95,7 @@ typedef struct
{
HLPFILE_PAGE* page;
HLPFILE_WINDOWINFO* wininfo;
ULONG relative;
} WINHELP_WNDPAGE;
typedef struct tagPageSet
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment