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,
/***********************************************************************
*
* HLPFILE_HlpFilePageByHash
* HLPFILE_PageByHash
*/
HLPFILE_PAGE *HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash, ULONG* relative)
{
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);
......
......@@ -506,10 +506,7 @@ void CALLBACK MACRO_FileOpen(void)
if (WINHELP_GetOpenFileName(szFile, MAX_PATH))
{
HLPFILE* hlpfile = WINHELP_LookupHelpFile(szFile);
WINHELP_CreateHelpWindowByHash(hlpfile, 0,
WINHELP_GetWindowInfo(hlpfile, "main"), SW_SHOWNORMAL);
MACRO_JumpContents(szFile, "main");
}
}
......@@ -628,10 +625,10 @@ void CALLBACK MACRO_JumpContents(LPCSTR lpszPath, LPCSTR lpszWindow)
HLPFILE* hlpfile;
WINE_TRACE("(\"%s\", \"%s\")\n", lpszPath, lpszWindow);
hlpfile = WINHELP_LookupHelpFile(lpszPath);
WINHELP_CreateHelpWindowByHash(hlpfile, 0,
WINHELP_GetWindowInfo(hlpfile, lpszWindow),
SW_NORMAL);
if ((hlpfile = WINHELP_LookupHelpFile(lpszPath)))
WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, 0,
WINHELP_GetWindowInfo(hlpfile, lpszWindow),
SW_NORMAL);
}
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);
hlpfile = WINHELP_LookupHelpFile(lpszPath);
/* Some madness: what user calls 'context', hlpfile calls 'map' */
WINHELP_CreateHelpWindowByMap(hlpfile, context,
WINHELP_GetWindowInfo(hlpfile, lpszWindow),
SW_NORMAL);
WINHELP_OpenHelpWindow(HLPFILE_PageByMap, hlpfile, context,
WINHELP_GetWindowInfo(hlpfile, lpszWindow),
SW_NORMAL);
}
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);
hlpfile = WINHELP_LookupHelpFile(lpszPath);
WINHELP_CreateHelpWindowByHash(hlpfile, lHash,
WINHELP_GetWindowInfo(hlpfile, lpszWindow),
SW_NORMAL);
WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, lHash,
WINHELP_GetWindowInfo(hlpfile, lpszWindow),
SW_NORMAL);
}
void CALLBACK MACRO_JumpHelpOn(void)
......
......@@ -304,8 +304,8 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
if (!hlpfile) return 0;
}
else hlpfile = NULL;
WINHELP_CreateHelpWindowByHash(hlpfile, lHash,
WINHELP_GetWindowInfo(hlpfile, wndname), show);
WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, lHash,
WINHELP_GetWindowInfo(hlpfile, wndname), show);
/* Message loop */
while (GetMessage(&msg, 0, 0, 0))
......@@ -657,49 +657,17 @@ BOOL WINHELP_CreateHelpWindow(WINHELP_WNDPAGE* wpage, int nCmdShow, BOOL remembe
return TRUE;
}
/***********************************************************************
*
* WINHELP_CreateHelpWindowByHash
*/
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
/******************************************************************
* WINHELP_OpenHelpWindow
* Main function to search for a page and display it in a window
*/
BOOL WINHELP_CreateHelpWindowByOffset(HLPFILE* hlpfile, LONG lOffset,
HLPFILE_WINDOWINFO* wi, int nCmdShow)
BOOL WINHELP_OpenHelpWindow(HLPFILE_PAGE* (*lookup)(HLPFILE*, LONG, ULONG*),
HLPFILE* hlpfile, LONG val, HLPFILE_WINDOWINFO* wi,
int nCmdShow)
{
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++;
wpage.wininfo = wi;
return WINHELP_CreateHelpWindow(&wpage, nCmdShow, TRUE);
......@@ -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);
break;
}
WINHELP_CreateHelpWindowByHash(hlpfile, part->link->lHash, wi,
SW_NORMAL);
WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, part->link->lHash,
wi, SW_NORMAL);
break;
case hlp_link_popup:
hlpfile = WINHELP_LookupHelpFile(part->link->lpszString);
if (hlpfile) WINHELP_CreateHelpWindowByHash(hlpfile, part->link->lHash,
WINHELP_GetPopupWindowInfo(hlpfile, hWnd, &mouse),
SW_NORMAL);
if (hlpfile) WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, part->link->lHash,
WINHELP_GetPopupWindowInfo(hlpfile, hWnd, &mouse),
SW_NORMAL);
break;
case hlp_link_macro:
MACRO_ExecuteMacro(part->link->lpszString);
......@@ -2074,7 +2042,8 @@ BOOL WINHELP_CreateIndexWindow(void)
{
ret -= 2;
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;
}
......@@ -178,10 +178,9 @@ typedef struct
extern WINHELP_GLOBALS Globals;
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_OpenHelpWindow(HLPFILE_PAGE* (*)(HLPFILE*, LONG, ULONG*),
HLPFILE*, LONG, HLPFILE_WINDOWINFO*, int);
BOOL WINHELP_GetOpenFileName(LPSTR, int);
BOOL WINHELP_CreateIndexWindow(void);
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