📄 winhelp.c
字号:
case para_debug_text: { TEXTMETRIC tm; SIZE textsize = {0, 0}; LPCSTR text = p->u.text.lpszText; UINT indent = 0; UINT len = strlen(text); unsigned underline = 0; HFONT hFont = 0; COLORREF color = RGB(0, 0, 0); if (p->u.text.wFont < win->page->file->numFonts) { HLPFILE* hlpfile = win->page->file; if (!hlpfile->fonts[p->u.text.wFont].hFont) hlpfile->fonts[p->u.text.wFont].hFont = CreateFontIndirect(&hlpfile->fonts[p->u.text.wFont].LogFont); hFont = hlpfile->fonts[p->u.text.wFont].hFont; color = hlpfile->fonts[p->u.text.wFont].color; } else { UINT wFont = (p->u.text.wFont < win->fonts_len) ? p->u.text.wFont : 0; hFont = win->fonts[wFont]; } if (p->link && p->link->bClrChange) { underline = (p->link->cookie == hlp_link_popup) ? 3 : 1; color = RGB(0, 0x80, 0); } if (p->cookie == para_debug_text) color = RGB(0xff, 0, 0); SelectObject(hDc, hFont); GetTextMetrics(hDc, &tm); if (p->u.text.wIndent) { indent = p->u.text.wIndent * 5 * tm.tmAveCharWidth; if (!part) space.cx = rect.left + indent - 2 * tm.tmAveCharWidth; } if (p->u.text.wVSpace) { part = 0; space.cx = rect.left + indent; space.cy += (p->u.text.wVSpace - 1) * tm.tmHeight; } if (p->u.text.wHSpace) { space.cx += p->u.text.wHSpace * 2 * tm.tmAveCharWidth; } WINE_TRACE("splitting text %s\n", text); while (len) { INT free_width = rect.right - (part ? (*line)->rect.right : rect.left) - space.cx; UINT low = 0, curr = len, high = len, textlen = 0; if (free_width > 0) { while (1) { GetTextExtentPoint(hDc, text, curr, &textsize); if (textsize.cx <= free_width) low = curr; else high = curr; if (high <= low + 1) break; if (textsize.cx) curr = (curr * free_width) / textsize.cx; if (curr <= low) curr = low + 1; else if (curr >= high) curr = high - 1; } textlen = low; while (textlen && text[textlen] && text[textlen] != ' ') textlen--; } if (!part && !textlen) textlen = max(low, 1); if (free_width <= 0 || !textlen) { part = 0; space.cx = rect.left + indent; space.cx = min(space.cx, rect.right - rect.left - 1); continue; } WINE_TRACE("\t => %d %*s\n", textlen, textlen, text); if (!WINHELP_AppendText(&line, &part, &space, &textsize, &line_ascent, tm.tmAscent, text, textlen, hFont, color, p->link, underline) || (!newsize && (*line)->rect.bottom > rect.bottom)) { ReleaseDC(hWnd, hDc); return FALSE; } if (newsize) newsize->cx = max(newsize->cx, (*line)->rect.right + INTERNAL_BORDER_WIDTH); len -= textlen; text += textlen; if (text[0] == ' ') text++, len--; } } break; case para_bitmap: case para_metafile: { SIZE gfxSize; INT free_width; WINHELP_LINE_PART* ref_part; if (p->u.gfx.pos & 0x8000) { space.cx = rect.left; if (*line) space.cy += (*line)->rect.bottom - (*line)->rect.top; part = 0; } if (p->cookie == para_bitmap) { DIBSECTION dibs; GetObject(p->u.gfx.u.bmp.hBitmap, sizeof(dibs), &dibs); gfxSize.cx = dibs.dsBm.bmWidth; gfxSize.cy = dibs.dsBm.bmHeight; } else { LPMETAFILEPICT lpmfp = &p->u.gfx.u.mfp; if (lpmfp->mm == MM_ANISOTROPIC || lpmfp->mm == MM_ISOTROPIC) { gfxSize.cx = MulDiv(lpmfp->xExt, GetDeviceCaps(hDc, HORZRES), 100*GetDeviceCaps(hDc, HORZSIZE)); gfxSize.cy = MulDiv(lpmfp->yExt, GetDeviceCaps(hDc, VERTRES), 100*GetDeviceCaps(hDc, VERTSIZE)); } else { gfxSize.cx = lpmfp->xExt; gfxSize.cy = lpmfp->yExt; } } free_width = rect.right - ((part && *line) ? (*line)->rect.right : rect.left) - space.cx; if (free_width <= 0) { part = NULL; space.cx = rect.left; space.cx = min(space.cx, rect.right - rect.left - 1); } ref_part = WINHELP_AppendGfxObject(&line, &part, &space, &gfxSize, p->link, p->u.gfx.pos); if (!ref_part || (!newsize && (*line)->rect.bottom > rect.bottom)) { return FALSE; } if (p->cookie == para_bitmap) { ref_part->cookie = hlp_line_part_bitmap; ref_part->u.bitmap.hBitmap = p->u.gfx.u.bmp.hBitmap; } else { ref_part->cookie = hlp_line_part_metafile; ref_part->u.metafile.hMetaFile = p->u.gfx.u.mfp.hMF; ref_part->u.metafile.mm = p->u.gfx.u.mfp.mm; } } break; } } if (newsize) newsize->cy = (*line)->rect.bottom + INTERNAL_BORDER_WIDTH; ReleaseDC(hWnd, hDc); return TRUE;}/*********************************************************************** * * WINHELP_CheckPopup */static void WINHELP_CheckPopup(UINT msg){ if (!Globals.hPopupWnd) return; switch (msg) { case WM_COMMAND: case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: case WM_NCLBUTTONDOWN: case WM_NCMBUTTONDOWN: case WM_NCRBUTTONDOWN: DestroyWindow(Globals.hPopupWnd); Globals.hPopupWnd = 0; }}/*********************************************************************** * * WINHELP_DeleteLines */static void WINHELP_DeleteLines(WINHELP_WINDOW *win){ WINHELP_LINE *line, *next_line; WINHELP_LINE_PART *part, *next_part; for (line = win->first_line; line; line = next_line) { next_line = line->next; for (part = &line->first_part; part; part = next_part) { next_part = part->next; HLPFILE_FreeLink(part->link); HeapFree(GetProcessHeap(), 0, part); } } win->first_line = 0;}/*********************************************************************** * * WINHELP_DeleteWindow */static void WINHELP_DeleteWindow(WINHELP_WINDOW* win){ WINHELP_WINDOW** w; unsigned int i; WINHELP_BUTTON* b; WINHELP_BUTTON* bp; for (w = &Globals.win_list; *w; w = &(*w)->next) { if (*w == win) { *w = win->next; break; } } if (Globals.active_win == win) { Globals.active_win = Globals.win_list; if (Globals.win_list) SetActiveWindow(Globals.win_list->hMainWnd); } for (b = win->first_button; b; b = bp) { DestroyWindow(b->hWnd); bp = b->next; HeapFree(GetProcessHeap(), 0, b); } if (win->hShadowWnd) DestroyWindow(win->hShadowWnd); if (win->hHistoryWnd) DestroyWindow(win->hHistoryWnd); for (i = 0; i < win->histIndex; i++) { HLPFILE_FreeHlpFile(win->history[i]->file); } for (i = 0; i < win->backIndex; i++) HLPFILE_FreeHlpFile(win->back[i]->file); if (win->page) HLPFILE_FreeHlpFile(win->page->file); WINHELP_DeleteLines(win); HeapFree(GetProcessHeap(), 0, win);}/*********************************************************************** * * WINHELP_InitFonts */static void WINHELP_InitFonts(HWND hWnd){ WINHELP_WINDOW *win = (WINHELP_WINDOW*) GetWindowLong(hWnd, 0); LOGFONT logfontlist[] = { {-10, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"}, {-12, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"}, {-12, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"}, {-12, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"}, {-12, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"}, {-10, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"}, { -8, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 32, "Helv"}};#define FONTS_LEN (sizeof(logfontlist)/sizeof(*logfontlist)) static HFONT fonts[FONTS_LEN]; static BOOL init = 0; win->fonts_len = FONTS_LEN; win->fonts = fonts; if (!init) { UINT i; for (i = 0; i < FONTS_LEN; i++) { fonts[i] = CreateFontIndirect(&logfontlist[i]); } init = 1; }}/*********************************************************************** * * WINHELP_MessageBoxIDS */INT WINHELP_MessageBoxIDS(UINT ids_text, UINT ids_title, WORD type){ CHAR text[MAX_STRING_LEN]; CHAR title[MAX_STRING_LEN]; LoadString(Globals.hInstance, ids_text, text, sizeof(text)); LoadString(Globals.hInstance, ids_title, title, sizeof(title)); return MessageBox(0, text, title, type);}/*********************************************************************** * * MAIN_MessageBoxIDS_s */INT WINHELP_MessageBoxIDS_s(UINT ids_text, LPCSTR str, UINT ids_title, WORD type){ CHAR text[MAX_STRING_LEN]; CHAR title[MAX_STRING_LEN]; CHAR newtext[MAX_STRING_LEN + MAX_PATH]; LoadString(Globals.hInstance, ids_text, text, sizeof(text)); LoadString(Globals.hInstance, ids_title, title, sizeof(title)); wsprintf(newtext, text, str); return MessageBox(0, newtext, title, type);}/****************************************************************** * WINHELP_IsOverLink * * */WINHELP_LINE_PART* WINHELP_IsOverLink(WINHELP_WINDOW* win, WPARAM wParam, LPARAM lParam){ POINT mouse; WINHELP_LINE *line; WINHELP_LINE_PART *part; int scroll_pos = GetScrollPos(win->hTextWnd, SB_VERT); mouse.x = LOWORD(lParam); mouse.y = HIWORD(lParam); for (line = win->first_line; line; line = line->next) { for (part = &line->first_part; part; part = part->next) { if (part->link && part->link->lpszString && part->rect.left <= mouse.x && part->rect.right >= mouse.x && part->rect.top <= mouse.y + scroll_pos && part->rect.bottom >= mouse.y + scroll_pos) { return part; } } } return NULL;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -