Commit 3f1b62f2 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winhelp: Simplify most of the helpers dealing with window creation.

parent 857d0e06
...@@ -148,13 +148,14 @@ static int comp_PageByHash(void *p, const void *key, ...@@ -148,13 +148,14 @@ static int comp_PageByHash(void *p, const void *key,
/*********************************************************************** /***********************************************************************
* *
* HLPFILE_HlpFilePageByHash * HLPFILE_PageByHash
*/ */
HLPFILE_PAGE *HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash, ULONG* relative) HLPFILE_PAGE *HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash, ULONG* relative)
{ {
BYTE *ptr; BYTE *ptr;
if (!hlpfile) return 0; if (!hlpfile) return NULL;
if (!lHash) return HLPFILE_Contents(hlpfile, relative);
WINE_TRACE("<%s>[%x]\n", hlpfile->lpszPath, lHash); WINE_TRACE("<%s>[%x]\n", hlpfile->lpszPath, lHash);
......
...@@ -506,10 +506,7 @@ void CALLBACK MACRO_FileOpen(void) ...@@ -506,10 +506,7 @@ void CALLBACK MACRO_FileOpen(void)
if (WINHELP_GetOpenFileName(szFile, MAX_PATH)) if (WINHELP_GetOpenFileName(szFile, MAX_PATH))
{ {
HLPFILE* hlpfile = WINHELP_LookupHelpFile(szFile); MACRO_JumpContents(szFile, "main");
WINHELP_CreateHelpWindowByHash(hlpfile, 0,
WINHELP_GetWindowInfo(hlpfile, "main"), SW_SHOWNORMAL);
} }
} }
...@@ -628,10 +625,10 @@ void CALLBACK MACRO_JumpContents(LPCSTR lpszPath, LPCSTR lpszWindow) ...@@ -628,10 +625,10 @@ void CALLBACK MACRO_JumpContents(LPCSTR lpszPath, LPCSTR lpszWindow)
HLPFILE* hlpfile; HLPFILE* hlpfile;
WINE_TRACE("(\"%s\", \"%s\")\n", lpszPath, lpszWindow); WINE_TRACE("(\"%s\", \"%s\")\n", lpszPath, lpszWindow);
hlpfile = WINHELP_LookupHelpFile(lpszPath); if ((hlpfile = WINHELP_LookupHelpFile(lpszPath)))
WINHELP_CreateHelpWindowByHash(hlpfile, 0, WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, 0,
WINHELP_GetWindowInfo(hlpfile, lpszWindow), WINHELP_GetWindowInfo(hlpfile, lpszWindow),
SW_NORMAL); SW_NORMAL);
} }
void CALLBACK MACRO_JumpContext(LPCSTR lpszPath, LPCSTR lpszWindow, LONG context) void CALLBACK MACRO_JumpContext(LPCSTR lpszPath, LPCSTR lpszWindow, LONG context)
...@@ -641,9 +638,9 @@ void CALLBACK MACRO_JumpContext(LPCSTR lpszPath, LPCSTR lpszWindow, LONG context ...@@ -641,9 +638,9 @@ void CALLBACK MACRO_JumpContext(LPCSTR lpszPath, LPCSTR lpszWindow, LONG context
WINE_TRACE("(\"%s\", \"%s\", %d)\n", lpszPath, lpszWindow, context); WINE_TRACE("(\"%s\", \"%s\", %d)\n", lpszPath, lpszWindow, context);
hlpfile = WINHELP_LookupHelpFile(lpszPath); hlpfile = WINHELP_LookupHelpFile(lpszPath);
/* Some madness: what user calls 'context', hlpfile calls 'map' */ /* Some madness: what user calls 'context', hlpfile calls 'map' */
WINHELP_CreateHelpWindowByMap(hlpfile, context, WINHELP_OpenHelpWindow(HLPFILE_PageByMap, hlpfile, context,
WINHELP_GetWindowInfo(hlpfile, lpszWindow), WINHELP_GetWindowInfo(hlpfile, lpszWindow),
SW_NORMAL); SW_NORMAL);
} }
void CALLBACK MACRO_JumpHash(LPCSTR lpszPath, LPCSTR lpszWindow, LONG lHash) void CALLBACK MACRO_JumpHash(LPCSTR lpszPath, LPCSTR lpszWindow, LONG lHash)
...@@ -652,9 +649,9 @@ void CALLBACK MACRO_JumpHash(LPCSTR lpszPath, LPCSTR lpszWindow, LONG lHash) ...@@ -652,9 +649,9 @@ void CALLBACK MACRO_JumpHash(LPCSTR lpszPath, LPCSTR lpszWindow, LONG lHash)
WINE_TRACE("(\"%s\", \"%s\", %u)\n", lpszPath, lpszWindow, lHash); WINE_TRACE("(\"%s\", \"%s\", %u)\n", lpszPath, lpszWindow, lHash);
hlpfile = WINHELP_LookupHelpFile(lpszPath); hlpfile = WINHELP_LookupHelpFile(lpszPath);
WINHELP_CreateHelpWindowByHash(hlpfile, lHash, WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, lHash,
WINHELP_GetWindowInfo(hlpfile, lpszWindow), WINHELP_GetWindowInfo(hlpfile, lpszWindow),
SW_NORMAL); SW_NORMAL);
} }
void CALLBACK MACRO_JumpHelpOn(void) void CALLBACK MACRO_JumpHelpOn(void)
......
...@@ -304,8 +304,8 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show) ...@@ -304,8 +304,8 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
if (!hlpfile) return 0; if (!hlpfile) return 0;
} }
else hlpfile = NULL; else hlpfile = NULL;
WINHELP_CreateHelpWindowByHash(hlpfile, lHash, WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, lHash,
WINHELP_GetWindowInfo(hlpfile, wndname), show); WINHELP_GetWindowInfo(hlpfile, wndname), show);
/* Message loop */ /* Message loop */
while (GetMessage(&msg, 0, 0, 0)) while (GetMessage(&msg, 0, 0, 0))
...@@ -657,49 +657,17 @@ BOOL WINHELP_CreateHelpWindow(WINHELP_WNDPAGE* wpage, int nCmdShow, BOOL remembe ...@@ -657,49 +657,17 @@ BOOL WINHELP_CreateHelpWindow(WINHELP_WNDPAGE* wpage, int nCmdShow, BOOL remembe
return TRUE; return TRUE;
} }
/*********************************************************************** /******************************************************************
* * WINHELP_OpenHelpWindow
* WINHELP_CreateHelpWindowByHash * Main function to search for a page and display it in a window
*/
BOOL WINHELP_CreateHelpWindowByHash(HLPFILE* hlpfile, LONG lHash,
HLPFILE_WINDOWINFO* wi, int nCmdShow)
{
WINHELP_WNDPAGE wpage;
wpage.page = NULL;
if (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);
}
/***********************************************************************
*
* WINHELP_CreateHelpWindowByMap
*/
BOOL WINHELP_CreateHelpWindowByMap(HLPFILE* hlpfile, LONG lMap,
HLPFILE_WINDOWINFO* wi, int nCmdShow)
{
WINHELP_WNDPAGE wpage;
wpage.page = HLPFILE_PageByMap(hlpfile, lMap, &wpage.relative);
if (wpage.page) wpage.page->file->wRefCount++;
wpage.wininfo = wi;
return WINHELP_CreateHelpWindow(&wpage, nCmdShow, TRUE);
}
/***********************************************************************
*
* WINHELP_CreateHelpWindowByOffset
*/ */
BOOL WINHELP_CreateHelpWindowByOffset(HLPFILE* hlpfile, LONG lOffset, BOOL WINHELP_OpenHelpWindow(HLPFILE_PAGE* (*lookup)(HLPFILE*, LONG, ULONG*),
HLPFILE_WINDOWINFO* wi, int nCmdShow) HLPFILE* hlpfile, LONG val, HLPFILE_WINDOWINFO* wi,
int nCmdShow)
{ {
WINHELP_WNDPAGE wpage; WINHELP_WNDPAGE wpage;
wpage.page = HLPFILE_PageByOffset(hlpfile, lOffset, &wpage.relative); wpage.page = lookup(hlpfile, val, &wpage.relative);
if (wpage.page) wpage.page->file->wRefCount++; if (wpage.page) wpage.page->file->wRefCount++;
wpage.wininfo = wi; wpage.wininfo = wi;
return WINHELP_CreateHelpWindow(&wpage, nCmdShow, TRUE); return WINHELP_CreateHelpWindow(&wpage, nCmdShow, TRUE);
...@@ -1229,14 +1197,14 @@ static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam, ...@@ -1229,14 +1197,14 @@ static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam,
WINE_WARN("link to window %d/%d\n", part->link->window, hlpfile->numWindows); WINE_WARN("link to window %d/%d\n", part->link->window, hlpfile->numWindows);
break; break;
} }
WINHELP_CreateHelpWindowByHash(hlpfile, part->link->lHash, wi, WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, part->link->lHash,
SW_NORMAL); wi, SW_NORMAL);
break; break;
case hlp_link_popup: case hlp_link_popup:
hlpfile = WINHELP_LookupHelpFile(part->link->lpszString); hlpfile = WINHELP_LookupHelpFile(part->link->lpszString);
if (hlpfile) WINHELP_CreateHelpWindowByHash(hlpfile, part->link->lHash, if (hlpfile) WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, part->link->lHash,
WINHELP_GetPopupWindowInfo(hlpfile, hWnd, &mouse), WINHELP_GetPopupWindowInfo(hlpfile, hWnd, &mouse),
SW_NORMAL); SW_NORMAL);
break; break;
case hlp_link_macro: case hlp_link_macro:
MACRO_ExecuteMacro(part->link->lpszString); MACRO_ExecuteMacro(part->link->lpszString);
...@@ -2074,7 +2042,8 @@ BOOL WINHELP_CreateIndexWindow(void) ...@@ -2074,7 +2042,8 @@ BOOL WINHELP_CreateIndexWindow(void)
{ {
ret -= 2; ret -= 2;
WINE_TRACE("got %d as an offset\n", ret); WINE_TRACE("got %d as an offset\n", ret);
WINHELP_CreateHelpWindowByOffset(hlpfile, ret, Globals.active_win->info, SW_NORMAL); WINHELP_OpenHelpWindow(HLPFILE_PageByOffset, hlpfile, ret,
Globals.active_win->info, SW_NORMAL);
} }
return TRUE; return TRUE;
} }
...@@ -178,10 +178,9 @@ typedef struct ...@@ -178,10 +178,9 @@ typedef struct
extern WINHELP_GLOBALS Globals; extern WINHELP_GLOBALS Globals;
extern FARPROC Callbacks[]; 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(WINHELP_WNDPAGE*, int, BOOL); BOOL WINHELP_CreateHelpWindow(WINHELP_WNDPAGE*, int, BOOL);
BOOL WINHELP_OpenHelpWindow(HLPFILE_PAGE* (*)(HLPFILE*, LONG, ULONG*),
HLPFILE*, LONG, HLPFILE_WINDOWINFO*, int);
BOOL WINHELP_GetOpenFileName(LPSTR, int); BOOL WINHELP_GetOpenFileName(LPSTR, int);
BOOL WINHELP_CreateIndexWindow(void); BOOL WINHELP_CreateIndexWindow(void);
void WINHELP_DeleteBackSet(WINHELP_WINDOW*); void WINHELP_DeleteBackSet(WINHELP_WINDOW*);
......
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