Improved a bit link handling (a few more link types loaded from file

and support for link to a macro).
This commit is contained in:
Eric Pouech 2002-10-21 18:20:05 +00:00 committed by Alexandre Julliard
parent 2468f06fa5
commit 03587c6f91
4 changed files with 98 additions and 67 deletions

View file

@ -757,28 +757,31 @@ static BOOL HLPFILE_AddParagraph(HLPFILE *hlpfile, BYTE *buf, BYTE *end, unsigne
strcpy(paragraph->u.text.lpszText, text);
}
if (attributes.link.lpszPath)
if (attributes.link.lpszString)
{
/* FIXME: should build a string table for the attributes.link.lpszPath
* they are reallocated for each link
*/
paragraph->link = HeapAlloc(GetProcessHeap(), 0,
sizeof(HLPFILE_LINK) + strlen(attributes.link.lpszPath) + 1);
sizeof(HLPFILE_LINK) + strlen(attributes.link.lpszString) + 1);
if (!paragraph->link) return FALSE;
paragraph->link->lpszPath = (char*)paragraph->link + sizeof(HLPFILE_LINK);
strcpy((char*)paragraph->link->lpszPath, attributes.link.lpszPath);
paragraph->link->lHash = attributes.link.lHash;
paragraph->link->cookie = attributes.link.cookie;
paragraph->link->lpszString = (char*)paragraph->link + sizeof(HLPFILE_LINK);
strcpy((char*)paragraph->link->lpszString, attributes.link.lpszString);
paragraph->link->lHash = attributes.link.lHash;
paragraph->link->bClrChange = attributes.link.bClrChange;
paragraph->link->bPopup = attributes.link.bPopup;
WINE_TRACE("Link to %s/%08lx\n",
paragraph->link->lpszPath, paragraph->link->lHash);
WINE_TRACE("Link[%d] to %s/%08lx\n",
paragraph->link->cookie, paragraph->link->lpszString, paragraph->link->lHash);
}
#if 0
memset(&attributes, 0, sizeof(attributes));
#else
attributes.hBitmap = 0;
attributes.link.lpszPath = NULL;
attributes.link.lpszString = NULL;
attributes.link.bClrChange = FALSE;
attributes.link.lHash = 0;
attributes.wVSpace = 0;
attributes.wHSpace = 0;
attributes.wIndent = 0;
@ -880,53 +883,67 @@ static BOOL HLPFILE_AddParagraph(HLPFILE *hlpfile, BYTE *buf, BYTE *end, unsigne
case 0x8B:
case 0x8C:
WINE_FIXME("NIY\n");
WINE_FIXME("NIY non-break space/hyphen\n");
format += 1;
break;
#if 0
case 0xa9:
case 0xA9:
format += 2;
break;
#endif
case 0xc8:
case 0xcc:
WINE_FIXME("macro NIY %s\n", format + 3);
format += GET_USHORT(format, 1) + 3;
case 0xC8:
case 0xCC:
WINE_TRACE("macro => %s\n", format + 3);
attributes.link.bClrChange = !(*format & 4);
attributes.link.cookie = hlp_link_macro;
attributes.link.lpszString = format + 3;
format += 3 + GET_USHORT(format, 1);
break;
case 0xe0:
case 0xe1:
case 0xE0:
case 0xE1:
WINE_WARN("jump topic 1 => %u\n", GET_UINT(format, 1));
format += 5;
break;
case 0xe2:
case 0xe3:
attributes.link.lpszPath = hlpfile->lpszPath;
attributes.link.lHash = GET_UINT(format, 1);
attributes.link.bPopup = !(*format & 1);
case 0xE2:
case 0xE3:
attributes.link.bClrChange = TRUE;
/* fall thru */
case 0xE6:
case 0xE7:
attributes.link.cookie = (*format & 1) ? hlp_link_link : hlp_link_popup;
attributes.link.lpszString = hlpfile->lpszPath;
attributes.link.lHash = GET_UINT(format, 1);
format += 5;
break;
case 0xe6:
case 0xe7:
WINE_WARN("jump topic 2 => %u\n", GET_UINT(format, 1));
format += 5;
break;
case 0xea:
attributes.link.lpszPath = format + 8;
attributes.link.lHash = GET_UINT(format, 4);
attributes.link.bPopup = !(*format & 1);
format += 3 + GET_USHORT(format, 1);
break;
case 0xee:
case 0xef:
case 0xeb:
WINE_WARN("jump to external file\n");
case 0xEA:
case 0xEB:
case 0xEE:
case 0xEF:
{
char* ptr = format + 8;
BYTE type = format[3];
attributes.link.cookie = hlp_link_link;
attributes.link.lHash = GET_UINT(format, 4);
attributes.link.bClrChange = !(*format & 1);
if (type == 1)
{WINE_FIXME("Unsupported wnd number %d for link\n", *ptr); ptr++;}
if (type == 4 || type == 6)
{
attributes.link.lpszString = ptr;
ptr += strlen(ptr) + 1;
}
else
attributes.link.lpszString = hlpfile->lpszPath;
if (type == 6)
WINE_FIXME("Unsupported wnd name '%s' for link\n", ptr);
}
format += 3 + GET_USHORT(format, 1);
break;

View file

@ -23,9 +23,10 @@ struct tagHelpFile;
typedef struct
{
LPCSTR lpszPath;
LONG lHash;
BOOL bPopup;
enum {hlp_link_none, hlp_link_link, hlp_link_popup, hlp_link_macro} cookie;
LPCSTR lpszString;
LONG lHash;
BOOL bClrChange;
} HLPFILE_LINK;
enum para_type {para_normal_text, para_debug_text, para_image};

View file

@ -701,8 +701,24 @@ static LRESULT CALLBACK WINHELP_TextWndProc(HWND hWnd, UINT msg, WPARAM wParam,
mouse.x = LOWORD(lParam);
mouse.y = HIWORD(lParam);
WINHELP_CreateHelpWindowByHash(part->link.lpszPath, part->link.lHash, NULL,
part->link.bPopup, hWnd, &mouse, SW_NORMAL);
switch (part->link.cookie)
{
case hlp_link_none:
break;
case hlp_link_link:
WINHELP_CreateHelpWindowByHash(part->link.lpszString, part->link.lHash, NULL,
FALSE, hWnd, &mouse, SW_NORMAL);
break;
case hlp_link_popup:
WINHELP_CreateHelpWindowByHash(part->link.lpszString, part->link.lHash, NULL,
TRUE, 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)
@ -773,7 +789,7 @@ static BOOL WINHELP_AppendText(WINHELP_LINE ***linep, WINHELP_LINE_PART ***partp
*line_ascent = ascent;
line = HeapAlloc(GetProcessHeap(), 0,
sizeof(WINHELP_LINE) + textlen + (link ? lstrlen(link->lpszPath) + 1 : 0));
sizeof(WINHELP_LINE) + textlen + (link ? lstrlen(link->lpszString) + 1 : 0));
if (!line) return FALSE;
line->next = 0;
@ -807,7 +823,7 @@ static BOOL WINHELP_AppendText(WINHELP_LINE ***linep, WINHELP_LINE_PART ***partp
part = HeapAlloc(GetProcessHeap(), 0,
sizeof(WINHELP_LINE_PART) + textlen +
(link ? lstrlen(link->lpszPath) + 1 : 0));
(link ? lstrlen(link->lpszString) + 1 : 0));
if (!part) return FALSE;
**partp = part;
ptr = (char*)part + sizeof(WINHELP_LINE_PART);
@ -836,12 +852,13 @@ static BOOL WINHELP_AppendText(WINHELP_LINE ***linep, WINHELP_LINE_PART ***partp
part->rect.left, part->rect.top, part->rect.right, part->rect.bottom);
if (link)
{
strcpy(ptr + textlen, link->lpszPath);
part->link.lpszPath = ptr + textlen;
part->link.lHash = link->lHash;
part->link.bPopup = link->bPopup;
strcpy(ptr + textlen, link->lpszString);
part->link.lpszString = ptr + textlen;
part->link.cookie = link->cookie;
part->link.lHash = link->lHash;
part->link.bClrChange = link->bClrChange;
}
else part->link.lpszPath = 0;
else part->link.cookie = hlp_link_none;
part->next = 0;
*partp = &part->next;
@ -867,7 +884,7 @@ static BOOL WINHELP_AppendBitmap(WINHELP_LINE ***linep, WINHELP_LINE_PART ***par
if (!*partp || pos == 1) /* New line */
{
line = HeapAlloc(GetProcessHeap(), 0,
sizeof(WINHELP_LINE) + (link ? lstrlen(link->lpszPath) + 1 : 0));
sizeof(WINHELP_LINE) + (link ? lstrlen(link->lpszString) + 1 : 0));
if (!line) return FALSE;
line->next = NULL;
@ -890,7 +907,7 @@ static BOOL WINHELP_AppendBitmap(WINHELP_LINE ***linep, WINHELP_LINE_PART ***par
part = HeapAlloc(GetProcessHeap(), 0,
sizeof(WINHELP_LINE_PART) +
(link ? lstrlen(link->lpszPath) + 1 : 0));
(link ? lstrlen(link->lpszString) + 1 : 0));
if (!part) return FALSE;
**partp = part;
ptr = (char*)part + sizeof(WINHELP_LINE_PART);
@ -912,12 +929,13 @@ static BOOL WINHELP_AppendBitmap(WINHELP_LINE ***linep, WINHELP_LINE_PART ***par
if (link)
{
strcpy(ptr, link->lpszPath);
part->link.lpszPath = ptr;
part->link.lHash = link->lHash;
part->link.bPopup = link->bPopup;
strcpy(ptr, link->lpszString);
part->link.lpszString = ptr;
part->link.cookie = link->cookie;
part->link.lHash = link->lHash;
part->link.bClrChange = link->bClrChange;
}
else part->link.lpszPath = 0;
else part->link.cookie = hlp_link_none;
part->next = NULL;
*partp = &part->next;
@ -996,7 +1014,7 @@ static BOOL WINHELP_SplitLines(HWND hWnd, LPSIZE newsize)
if (p->link)
{
underline = (p->link->bPopup) ? 3 : 1;
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);
@ -1274,7 +1292,8 @@ WINHELP_LINE_PART* WINHELP_IsOverLink(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
for (part = &line->first_part; part; part = part->next)
{
if (part->link.lpszPath &&
if (part->link.cookie != hlp_link_none &&
part->link.lpszString &&
part->rect.left <= mouse.x &&
part->rect.right >= mouse.x &&
part->rect.top <= mouse.y + scroll_pos &&

View file

@ -56,13 +56,7 @@ typedef struct tagHelpLinePart
HBITMAP hBitmap;
} image;
} u;
struct
{
LPCSTR lpszPath;
LONG lHash;
BOOL bPopup;
} link;
HLPFILE_LINK link;
struct tagHelpLinePart *next;
} WINHELP_LINE_PART;