Module: wine Branch: master Commit: 3f1b62f2f76f0c516f0e9e8c239cc57708711950 URL: http://source.winehq.org/git/wine.git/?a=commit;h=3f1b62f2f76f0c516f0e9e8c23...
Author: Eric Pouech eric.pouech@orange.fr Date: Tue Apr 22 22:01:08 2008 +0200
winhelp: Simplify most of the helpers dealing with window creation.
---
programs/winhelp/hlpfile.c | 5 ++- programs/winhelp/macro.c | 25 +++++++---------- programs/winhelp/winhelp.c | 63 +++++++++++-------------------------------- programs/winhelp/winhelp.h | 5 +-- 4 files changed, 32 insertions(+), 66 deletions(-)
diff --git a/programs/winhelp/hlpfile.c b/programs/winhelp/hlpfile.c index 30c678d..c20bead 100644 --- a/programs/winhelp/hlpfile.c +++ b/programs/winhelp/hlpfile.c @@ -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);
diff --git a/programs/winhelp/macro.c b/programs/winhelp/macro.c index 3681933..66eac0f 100644 --- a/programs/winhelp/macro.c +++ b/programs/winhelp/macro.c @@ -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) diff --git a/programs/winhelp/winhelp.c b/programs/winhelp/winhelp.c index 4981748..797bbae 100644 --- a/programs/winhelp/winhelp.c +++ b/programs/winhelp/winhelp.c @@ -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; } diff --git a/programs/winhelp/winhelp.h b/programs/winhelp/winhelp.h index f8ff0c6..a8f211e 100644 --- a/programs/winhelp/winhelp.h +++ b/programs/winhelp/winhelp.h @@ -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*);