📄 winhelp.c
字号:
DeleteObject(hBitmap); } break; } } } EndPaint(hWnd, &ps); break; case WM_MOUSEMOVE: win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0); if (WINHELP_IsOverLink(win, wParam, lParam)) SetCursor(win->hHandCur); /* set to hand pointer cursor to indicate a link */ else SetCursor(win->hArrowCur); /* set to hand pointer cursor to indicate a link */ break; case WM_LBUTTONDOWN: win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0); hPopupWnd = Globals.hPopupWnd; Globals.hPopupWnd = 0; part = WINHELP_IsOverLink(win, wParam, lParam); if (part) { HLPFILE* hlpfile; HLPFILE_WINDOWINFO* wi; mouse.x = (short)LOWORD(lParam); mouse.y = (short)HIWORD(lParam); if (part->link) switch (part->link->cookie) { case hlp_link_link: hlpfile = WINHELP_LookupHelpFile(part->link->lpszString); if (part->link->window == -1) wi = win->info; else if ((part->link->window >= 0) && (part->link->window < hlpfile->numWindows)) wi = &hlpfile->windows[part->link->window]; else { WINE_WARN("link to window %d/%d\n", part->link->window, hlpfile->numWindows); break; } WINHELP_CreateHelpWindowByHash(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); break; case hlp_link_macro: MACRO_ExecuteMacro(part->link->lpszString); break; default: WINE_FIXME("Unknown link cookie %d\n", part->link->cookie); } } if (hPopupWnd) DestroyWindow(hPopupWnd); break; case WM_NCDESTROY: win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0); if (hWnd == Globals.hPopupWnd) Globals.hPopupWnd = 0; bExit = (Globals.wVersion >= 4 && !lstrcmpi(win->lpszName, "main")); DeleteObject(win->hBrush); WINHELP_DeleteWindow(win); if (bExit) MACRO_Exit(); if (!Globals.win_list) PostQuitMessage(0); break; } return DefWindowProc(hWnd, msg, wParam, lParam);}/****************************************************************** * WINHELP_HistoryWndProc * * */static LRESULT CALLBACK WINHELP_HistoryWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){ WINHELP_WINDOW* win; PAINTSTRUCT ps; HDC hDc; TEXTMETRIC tm; unsigned int i; RECT r; switch (msg) { case WM_NCCREATE: win = (WINHELP_WINDOW*)((LPCREATESTRUCT)lParam)->lpCreateParams; SetWindowLong(hWnd, 0, (LONG)win); win->hHistoryWnd = hWnd; break; case WM_CREATE: win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0); hDc = GetDC(hWnd); GetTextMetrics(hDc, &tm); GetWindowRect(hWnd, &r); r.right = r.left + 30 * tm.tmAveCharWidth; r.bottom = r.top + (sizeof(win->history) / sizeof(win->history[0])) * tm.tmHeight; AdjustWindowRect(&r, GetWindowLong(hWnd, GWL_STYLE), FALSE); if (r.left < 0) {r.right -= r.left; r.left = 0;} if (r.top < 0) {r.bottom -= r.top; r.top = 0;} MoveWindow(hWnd, r.left, r.top, r.right, r.bottom, TRUE); ReleaseDC(hWnd, hDc); break; case WM_LBUTTONDOWN: win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0); hDc = GetDC(hWnd); GetTextMetrics(hDc, &tm); i = HIWORD(lParam) / tm.tmHeight; if (i < win->histIndex) WINHELP_CreateHelpWindow(win->history[i], win->info, SW_SHOW); ReleaseDC(hWnd, hDc); break; case WM_PAINT: hDc = BeginPaint(hWnd, &ps); win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0); GetTextMetrics(hDc, &tm); for (i = 0; i < win->histIndex; i++) { TextOut(hDc, 0, i * tm.tmHeight, win->history[i]->lpszTitle, strlen(win->history[i]->lpszTitle)); } EndPaint(hWnd, &ps); break; case WM_DESTROY: win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0); if (hWnd == win->hHistoryWnd) win->hHistoryWnd = 0; break; } return DefWindowProc(hWnd, msg, wParam, lParam);}/*********************************************************************** * * WINHELP_ShadowWndProc */static LRESULT CALLBACK WINHELP_ShadowWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){ WINHELP_CheckPopup(msg); return DefWindowProc(hWnd, msg, wParam, lParam);}/*********************************************************************** * * SetupText */static void WINHELP_SetupText(HWND hWnd){ HDC hDc = GetDC(hWnd); RECT rect; SIZE newsize; ShowScrollBar(hWnd, SB_VERT, FALSE); if (!WINHELP_SplitLines(hWnd, NULL)) { ShowScrollBar(hWnd, SB_VERT, TRUE); GetClientRect(hWnd, &rect); WINHELP_SplitLines(hWnd, &newsize); SetScrollRange(hWnd, SB_VERT, 0, rect.top + newsize.cy - rect.bottom, TRUE); } else { SetScrollPos(hWnd, SB_VERT, 0, FALSE); SetScrollRange(hWnd, SB_VERT, 0, 0, FALSE); } ReleaseDC(hWnd, hDc);}/*********************************************************************** * * WINHELP_AppendText */static BOOL WINHELP_AppendText(WINHELP_LINE ***linep, WINHELP_LINE_PART ***partp, LPSIZE space, LPSIZE textsize, INT *line_ascent, INT ascent, LPCSTR text, UINT textlen, HFONT font, COLORREF color, HLPFILE_LINK *link, unsigned underline){ WINHELP_LINE *line; WINHELP_LINE_PART *part; LPSTR ptr; if (!*partp) /* New line */ { *line_ascent = ascent; line = HeapAlloc(GetProcessHeap(), 0, sizeof(WINHELP_LINE) + textlen); if (!line) return FALSE; line->next = 0; part = &line->first_part; ptr = (char*)line + sizeof(WINHELP_LINE); line->rect.top = (**linep ? (**linep)->rect.bottom : 0) + space->cy; line->rect.bottom = line->rect.top; line->rect.left = space->cx; line->rect.right = space->cx; if (**linep) *linep = &(**linep)->next; **linep = line; space->cy = 0; } else /* Same line */ { line = **linep; if (*line_ascent < ascent) { WINHELP_LINE_PART *p; for (p = &line->first_part; p; p = p->next) { p->rect.top += ascent - *line_ascent; p->rect.bottom += ascent - *line_ascent; } line->rect.bottom += ascent - *line_ascent; *line_ascent = ascent; } part = HeapAlloc(GetProcessHeap(), 0, sizeof(WINHELP_LINE_PART) + textlen); if (!part) return FALSE; **partp = part; ptr = (char*)part + sizeof(WINHELP_LINE_PART); } memcpy(ptr, text, textlen); part->cookie = hlp_line_part_text; part->rect.left = line->rect.right + (*partp ? space->cx : 0); part->rect.right = part->rect.left + textsize->cx; line->rect.right = part->rect.right; part->rect.top = ((*partp) ? line->rect.top : line->rect.bottom) + *line_ascent - ascent; part->rect.bottom = part->rect.top + textsize->cy; line->rect.bottom = max(line->rect.bottom, part->rect.bottom); part->u.text.lpsText = ptr; part->u.text.wTextLen = textlen; part->u.text.hFont = font; part->u.text.color = color; part->u.text.wUnderline = underline; WINE_TRACE("Appended text '%*.*s'[%d] @ (%d,%d-%d,%d)\n", part->u.text.wTextLen, part->u.text.wTextLen, part->u.text.lpsText, part->u.text.wTextLen, part->rect.left, part->rect.top, part->rect.right, part->rect.bottom); part->link = link; if (link) link->wRefCount++; part->next = 0; *partp = &part->next; space->cx = 0; return TRUE;}/*********************************************************************** * * WINHELP_AppendGfxObject */static WINHELP_LINE_PART* WINHELP_AppendGfxObject(WINHELP_LINE ***linep, WINHELP_LINE_PART ***partp, LPSIZE space, LPSIZE gfxSize, HLPFILE_LINK *link, unsigned pos){ WINHELP_LINE *line; WINHELP_LINE_PART *part; LPSTR ptr; if (!*partp || pos == 1) /* New line */ { line = HeapAlloc(GetProcessHeap(), 0, sizeof(WINHELP_LINE)); if (!line) return NULL; line->next = NULL; part = &line->first_part; line->rect.top = (**linep ? (**linep)->rect.bottom : 0) + space->cy; line->rect.bottom = line->rect.top; line->rect.left = space->cx; line->rect.right = space->cx; if (**linep) *linep = &(**linep)->next; **linep = line; space->cy = 0; ptr = (char*)line + sizeof(WINHELP_LINE); } else /* Same line */ { if (pos == 2) WINE_FIXME("Left alignment not handled\n"); line = **linep; part = HeapAlloc(GetProcessHeap(), 0, sizeof(WINHELP_LINE_PART)); if (!part) return NULL; **partp = part; ptr = (char*)part + sizeof(WINHELP_LINE_PART); } /* part->cookie should be set by caller (image or metafile) */ part->rect.left = line->rect.right + (*partp ? space->cx : 0); part->rect.right = part->rect.left + gfxSize->cx; line->rect.right = part->rect.right; part->rect.top = (*partp) ? line->rect.top : line->rect.bottom; part->rect.bottom = part->rect.top + gfxSize->cy; line->rect.bottom = max(line->rect.bottom, part->rect.bottom); WINE_TRACE("Appended gfx @ (%d,%d-%d,%d)\n", part->rect.left, part->rect.top, part->rect.right, part->rect.bottom); part->link = link; if (link) link->wRefCount++; part->next = NULL; *partp = &part->next; space->cx = 0; return part;}/*********************************************************************** * * WINHELP_SplitLines */static BOOL WINHELP_SplitLines(HWND hWnd, LPSIZE newsize){ WINHELP_WINDOW *win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0); HLPFILE_PARAGRAPH *p; WINHELP_LINE **line = &win->first_line; WINHELP_LINE_PART **part = 0; INT line_ascent = 0; SIZE space; RECT rect; HDC hDc; if (newsize) newsize->cx = newsize->cy = 0; if (!win->page) return TRUE; WINHELP_DeleteLines(win); GetClientRect(hWnd, &rect); rect.top += INTERNAL_BORDER_WIDTH; rect.left += INTERNAL_BORDER_WIDTH; rect.right -= INTERNAL_BORDER_WIDTH; rect.bottom -= INTERNAL_BORDER_WIDTH; space.cy = rect.top; space.cx = rect.left; hDc = GetDC(hWnd); for (p = win->page->first_paragraph; p; p = p->next) { switch (p->cookie) { case para_normal_text:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -