📄 winhelp.c
字号:
{ char* ptr = (wh->ofsFilename) ? (LPSTR)wh + wh->ofsFilename : NULL; WINE_TRACE("Got[%u]: cmd=%u data=%08x fn=%s\n", wh->size, wh->command, wh->data, ptr); switch (wh->command) { case HELP_CONTEXT: if (ptr) { MACRO_JumpContext(ptr, "main", wh->data); } break; case HELP_QUIT: MACRO_Exit(); break; case HELP_CONTENTS: if (ptr) { MACRO_JumpContents(ptr, "main"); } break; case HELP_HELPONHELP: MACRO_HelpOn(); break; /* case HELP_SETINDEX: */ case HELP_SETCONTENTS: if (ptr) { MACRO_SetContents(ptr, wh->data); } break; case HELP_CONTEXTPOPUP: if (ptr) { MACRO_PopupContext(ptr, wh->data); } break; /* case HELP_FORCEFILE:*/ /* case HELP_CONTEXTMENU: */ case HELP_FINDER: /* in fact, should be the topic dialog box */ WINE_FIXME("HELP_FINDER: stub\n"); if (ptr) { MACRO_JumpHash(ptr, "main", 0); } break; /* case HELP_WM_HELP: */ /* case HELP_SETPOPUP_POS: */ /* case HELP_KEY: */ /* case HELP_COMMAND: */ /* case HELP_PARTIALKEY: */ /* case HELP_MULTIKEY: */ /* case HELP_SETWINPOS: */ WINE_FIXME("Unknown command (%x) for remote winhelp control\n", wh->command); break; } } return 0L;}/****************************************************************** * WINHELP_ReuseWindow * * */static BOOL WINHELP_ReuseWindow(WINHELP_WINDOW* win, WINHELP_WINDOW* oldwin, HLPFILE_PAGE* page, int nCmdShow){ unsigned int i; win->hMainWnd = oldwin->hMainWnd; win->hButtonBoxWnd = oldwin->hButtonBoxWnd; win->hTextWnd = oldwin->hTextWnd; win->hHistoryWnd = oldwin->hHistoryWnd; oldwin->hMainWnd = oldwin->hButtonBoxWnd = oldwin->hTextWnd = oldwin->hHistoryWnd = 0; win->hBrush = oldwin->hBrush; SetWindowLong(win->hMainWnd, 0, (LONG)win); SetWindowLong(win->hButtonBoxWnd, 0, (LONG)win); SetWindowLong(win->hTextWnd, 0, (LONG)win); SetWindowLong(win->hHistoryWnd, 0, (LONG)win); WINHELP_InitFonts(win->hMainWnd); if (page) SetWindowText(win->hMainWnd, page->file->lpszTitle); WINHELP_SetupText(win->hTextWnd); InvalidateRect(win->hTextWnd, NULL, TRUE); SendMessage(win->hMainWnd, WM_USER, 0, 0); ShowWindow(win->hMainWnd, nCmdShow); UpdateWindow(win->hTextWnd); if (!(win->info->win_style & WS_POPUP)) { unsigned num; memcpy(win->history, oldwin->history, sizeof(win->history)); win->histIndex = oldwin->histIndex; /* FIXME: when using back, we shouldn't update the history... */ if (page) { for (i = 0; i < win->histIndex; i++) if (win->history[i] == page) break; /* if the new page is already in the history, do nothing */ if (i == win->histIndex) { num = sizeof(win->history) / sizeof(win->history[0]); if (win->histIndex == num) { /* we're full, remove latest entry */ HLPFILE_FreeHlpFile(win->history[0]->file); memmove(&win->history[0], &win->history[1], (num - 1) * sizeof(win->history[0])); win->histIndex--; } win->history[win->histIndex++] = page; page->file->wRefCount++; if (win->hHistoryWnd) InvalidateRect(win->hHistoryWnd, NULL, TRUE); } } memcpy(win->back, oldwin->back, sizeof(win->back)); win->backIndex = oldwin->backIndex; if (page) { num = sizeof(win->back) / sizeof(win->back[0]); if (win->backIndex == num) { /* we're full, remove latest entry */ HLPFILE_FreeHlpFile(win->back[0]->file); memmove(&win->back[0], &win->back[1], (num - 1) * sizeof(win->back[0])); win->backIndex--; } win->back[win->backIndex++] = page; page->file->wRefCount++; } } else win->backIndex = win->histIndex = 0; oldwin->histIndex = oldwin->backIndex = 0; WINHELP_DeleteWindow(oldwin); return TRUE;}/*********************************************************************** * * WINHELP_CreateHelpWindow */BOOL WINHELP_CreateHelpWindow(HLPFILE_PAGE* page, HLPFILE_WINDOWINFO* wi, int nCmdShow){ WINHELP_WINDOW *win, *oldwin; HWND hWnd; BOOL bPrimary; BOOL bPopup; LPSTR name; bPrimary = !lstrcmpi(wi->name, "main"); bPopup = wi->win_style & WS_POPUP; /* Initialize WINHELP_WINDOW struct */ win = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINHELP_WINDOW) + strlen(wi->name) + 1); if (!win) return FALSE; win->next = Globals.win_list; Globals.win_list = win; name = (char*)win + sizeof(WINHELP_WINDOW); lstrcpy(name, wi->name); win->lpszName = name; win->page = page; win->hArrowCur = LoadCursorA(0, (LPSTR)IDC_ARROW); win->hHandCur = LoadCursorA(0, (LPSTR)IDC_HAND); win->info = wi; Globals.active_win = win; /* Initialize default pushbuttons */ if (bPrimary && page) { CHAR buffer[MAX_STRING_LEN]; LoadString(Globals.hInstance, STID_CONTENTS, buffer, sizeof(buffer)); MACRO_CreateButton("BTN_CONTENTS", buffer, "Contents()"); LoadString(Globals.hInstance, STID_SEARCH,buffer, sizeof(buffer)); MACRO_CreateButton("BTN_SEARCH", buffer, "Search()"); LoadString(Globals.hInstance, STID_BACK, buffer, sizeof(buffer)); MACRO_CreateButton("BTN_BACK", buffer, "Back()"); LoadString(Globals.hInstance, STID_HISTORY, buffer, sizeof(buffer)); MACRO_CreateButton("BTN_HISTORY", buffer, "History()"); LoadString(Globals.hInstance, STID_TOPICS, buffer, sizeof(buffer)); MACRO_CreateButton("BTN_TOPICS", buffer, "Finder()"); } /* Initialize file specific pushbuttons */ if (!(wi->win_style & WS_POPUP) && page) { HLPFILE_MACRO *macro; for (macro = page->file->first_macro; macro; macro = macro->next) MACRO_ExecuteMacro(macro->lpszMacro); for (macro = page->first_macro; macro; macro = macro->next) MACRO_ExecuteMacro(macro->lpszMacro); } /* Reuse existing window */ if (!bPopup) { for (oldwin = win->next; oldwin; oldwin = oldwin->next) { if (!lstrcmpi(oldwin->lpszName, wi->name)) { return WINHELP_ReuseWindow(win, oldwin, page, nCmdShow); } } if (page) { win->histIndex = win->backIndex = 1; win->history[0] = win->back[0] = page; page->file->wRefCount += 2; strcpy(wi->caption, page->file->lpszTitle); } } hWnd = CreateWindow(bPopup ? TEXT_WIN_CLASS_NAME : MAIN_WIN_CLASS_NAME, wi->caption, bPrimary ? WS_OVERLAPPEDWINDOW : wi->win_style, wi->origin.x, wi->origin.y, wi->size.cx, wi->size.cy, NULL, bPrimary ? LoadMenu(Globals.hInstance, MAKEINTRESOURCE(MAIN_MENU)) : 0, Globals.hInstance, win); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE;}/*********************************************************************** * * WINHELP_CreateHelpWindowByHash */BOOL WINHELP_CreateHelpWindowByHash(HLPFILE* hlpfile, LONG lHash, HLPFILE_WINDOWINFO* wi, int nCmdShow){ HLPFILE_PAGE* page = NULL; if (hlpfile) page = lHash ? HLPFILE_PageByHash(hlpfile, lHash) : HLPFILE_Contents(hlpfile); if (page) page->file->wRefCount++; return WINHELP_CreateHelpWindow(page, wi, nCmdShow);}/*********************************************************************** * * WINHELP_CreateHelpWindowByMap */BOOL WINHELP_CreateHelpWindowByMap(HLPFILE* hlpfile, LONG lMap, HLPFILE_WINDOWINFO* wi, int nCmdShow){ HLPFILE_PAGE* page = NULL; page = HLPFILE_PageByMap(hlpfile, lMap); 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){ WINHELP_WINDOW *win; WINHELP_BUTTON *button; RECT rect, button_box_rect; INT text_top, curPos, min, max, dy, keyDelta; WINHELP_CheckPopup(msg); switch (msg) { case WM_NCCREATE: win = (WINHELP_WINDOW*) ((LPCREATESTRUCT) lParam)->lpCreateParams; SetWindowLong(hWnd, 0, (LONG) win); win->hMainWnd = hWnd; break; case WM_CREATE: win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0); /* Create button box and text Window */ CreateWindow(BUTTON_BOX_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWnd, 0, Globals.hInstance, win); CreateWindow(TEXT_WIN_CLASS_NAME, "", WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWnd, 0, Globals.hInstance, win); /* Fall through */ case WM_USER: case WM_WINDOWPOSCHANGED: win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0); GetClientRect(hWnd, &rect); /* Update button box and text Window */ SetWindowPos(win->hButtonBoxWnd, HWND_TOP, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0); GetWindowRect(win->hButtonBoxWnd, &button_box_rect); text_top = rect.top + button_box_rect.bottom - button_box_rect.top; SetWindowPos(win->hTextWnd, HWND_TOP, rect.left, text_top, rect.right - rect.left, rect.bottom - text_top, 0); break; case WM_COMMAND: Globals.active_win = win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0); switch (wParam) { /* Menu FILE */ case MNID_FILE_OPEN: MACRO_FileOpen(); break; case MNID_FILE_PRINT: MACRO_Print(); break; case MNID_FILE_SETUP: MACRO_PrinterSetup(); break; case MNID_FILE_EXIT: MACRO_Exit(); break; /* Menu EDIT */ case MNID_EDIT_COPYDLG: MACRO_CopyDialog(); break; case MNID_EDIT_ANNOTATE:MACRO_Annotate(); break; /* Menu Bookmark */ case MNID_BKMK_DEFINE: MACRO_BookmarkDefine(); break; /* Menu Help */ case MNID_HELP_HELPON: MACRO_HelpOn(); break; case MNID_HELP_HELPTOP: MACRO_HelpOnTop(); break; case MNID_HELP_ABOUT: MACRO_About(); break; case MNID_HELP_WINE: ShellAbout(hWnd, "WINE", "Help", 0); break; default: /* Buttons */ for (button = win->first_button; button; button = button->next) if (wParam == button->wParam) break; if (button) MACRO_ExecuteMacro(button->lpszMacro); else WINHELP_MessageBoxIDS(STID_NOT_IMPLEMENTED, 0x121, MB_OK); break; } break; case WM_DESTROY: if (Globals.hPopupWnd) DestroyWindow(Globals.hPopupWnd); break; case WM_COPYDATA: return WINHELP_HandleCommand((HWND)wParam, lParam); case WM_KEYDOWN: keyDelta = 0; switch (wParam) { case VK_UP: case VK_DOWN: keyDelta = GetSystemMetrics(SM_CXVSCROLL); if (wParam == VK_UP) keyDelta = -keyDelta; case VK_PRIOR: case VK_NEXT: win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -