comctl32/syslink: Wrap the link text on \n characters.
This commit is contained in:
parent
37a0f7ad65
commit
11c2150dd9
|
@ -609,35 +609,26 @@ static PDOC_ITEM SYSLINK_GetPrevLink (const SYSLINK_INFO *infoPtr, PDOC_ITEM Cur
|
||||||
static BOOL SYSLINK_WrapLine (LPWSTR Text, WCHAR BreakChar, int *LineLen,
|
static BOOL SYSLINK_WrapLine (LPWSTR Text, WCHAR BreakChar, int *LineLen,
|
||||||
int nFit, LPSIZE Extent)
|
int nFit, LPSIZE Extent)
|
||||||
{
|
{
|
||||||
WCHAR *Current;
|
int i;
|
||||||
|
|
||||||
if(nFit == *LineLen)
|
for (i = 0; i < nFit; i++) if (Text[i] == '\n') break;
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*LineLen = nFit;
|
if (i == *LineLen) return FALSE;
|
||||||
|
|
||||||
Current = Text + nFit;
|
|
||||||
|
|
||||||
/* check if we're in the middle of a word */
|
/* check if we're in the middle of a word */
|
||||||
if((*Current) != BreakChar)
|
if (Text[i] != '\n' && Text[i] != BreakChar)
|
||||||
{
|
{
|
||||||
/* search for the beginning of the word */
|
/* search for the beginning of the word */
|
||||||
while(Current > Text && (*(Current - 1)) != BreakChar)
|
while (i && Text[i - 1] != BreakChar) i--;
|
||||||
{
|
|
||||||
Current--;
|
|
||||||
(*LineLen)--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if((*LineLen) == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
Extent->cx = 0;
|
Extent->cx = 0;
|
||||||
Extent->cy = 0;
|
Extent->cy = 0;
|
||||||
|
i = max( nFit, 1 );
|
||||||
}
|
}
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
*LineLen = i;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,6 +643,7 @@ static VOID SYSLINK_Render (const SYSLINK_INFO *infoPtr, HDC hdc, PRECT pRect)
|
||||||
HGDIOBJ hOldFont;
|
HGDIOBJ hOldFont;
|
||||||
int x, y, LineHeight;
|
int x, y, LineHeight;
|
||||||
SIZE szDoc;
|
SIZE szDoc;
|
||||||
|
TEXTMETRICW tm;
|
||||||
|
|
||||||
szDoc.cx = szDoc.cy = 0;
|
szDoc.cx = szDoc.cy = 0;
|
||||||
|
|
||||||
|
@ -668,7 +660,8 @@ static VOID SYSLINK_Render (const SYSLINK_INFO *infoPtr, HDC hdc, PRECT pRect)
|
||||||
|
|
||||||
x = SL_LEFTMARGIN;
|
x = SL_LEFTMARGIN;
|
||||||
y = SL_TOPMARGIN;
|
y = SL_TOPMARGIN;
|
||||||
LineHeight = 0;
|
GetTextMetricsW( hdc, &tm );
|
||||||
|
LineHeight = tm.tmHeight + tm.tmExternalLeading;
|
||||||
|
|
||||||
for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
|
for(Current = infoPtr->Items; Current != NULL; Current = Current->Next)
|
||||||
{
|
{
|
||||||
|
@ -677,6 +670,7 @@ static VOID SYSLINK_Render (const SYSLINK_INFO *infoPtr, HDC hdc, PRECT pRect)
|
||||||
PDOC_TEXTBLOCK bl, cbl;
|
PDOC_TEXTBLOCK bl, cbl;
|
||||||
INT nFit;
|
INT nFit;
|
||||||
SIZE szDim;
|
SIZE szDim;
|
||||||
|
int SkipChars = 0;
|
||||||
|
|
||||||
if(Current->nText == 0)
|
if(Current->nText == 0)
|
||||||
{
|
{
|
||||||
|
@ -702,11 +696,15 @@ static VOID SYSLINK_Render (const SYSLINK_INFO *infoPtr, HDC hdc, PRECT pRect)
|
||||||
|
|
||||||
while(n > 0)
|
while(n > 0)
|
||||||
{
|
{
|
||||||
int SkipChars = 0;
|
|
||||||
|
|
||||||
/* skip break characters unless they're the first of the doc item */
|
/* skip break characters unless they're the first of the doc item */
|
||||||
if(tx != Current->Text || x == SL_LEFTMARGIN)
|
if(tx != Current->Text || x == SL_LEFTMARGIN)
|
||||||
{
|
{
|
||||||
|
if (n && *tx == '\n')
|
||||||
|
{
|
||||||
|
tx++;
|
||||||
|
SkipChars++;
|
||||||
|
n--;
|
||||||
|
}
|
||||||
while(n > 0 && (*tx) == infoPtr->BreakChar)
|
while(n > 0 && (*tx) == infoPtr->BreakChar)
|
||||||
{
|
{
|
||||||
tx++;
|
tx++;
|
||||||
|
@ -727,22 +725,12 @@ static VOID SYSLINK_Render (const SYSLINK_INFO *infoPtr, HDC hdc, PRECT pRect)
|
||||||
Wrap = SYSLINK_WrapLine(tx, infoPtr->BreakChar, &LineLen, nFit, &szDim);
|
Wrap = SYSLINK_WrapLine(tx, infoPtr->BreakChar, &LineLen, nFit, &szDim);
|
||||||
|
|
||||||
if(LineLen == 0)
|
if(LineLen == 0)
|
||||||
{
|
|
||||||
if(x > SL_LEFTMARGIN)
|
|
||||||
{
|
{
|
||||||
/* move one line down, the word didn't fit into the line */
|
/* move one line down, the word didn't fit into the line */
|
||||||
x = SL_LEFTMARGIN;
|
x = SL_LEFTMARGIN;
|
||||||
y += LineHeight;
|
y += LineHeight;
|
||||||
LineHeight = 0;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* the word starts at the beginning of the line and doesn't
|
|
||||||
fit into the line, so break it at the last character that fits */
|
|
||||||
LineLen = max(nFit, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(LineLen != n)
|
if(LineLen != n)
|
||||||
{
|
{
|
||||||
|
@ -782,13 +770,10 @@ static VOID SYSLINK_Render (const SYSLINK_INFO *infoPtr, HDC hdc, PRECT pRect)
|
||||||
if(LineLen != 0)
|
if(LineLen != 0)
|
||||||
{
|
{
|
||||||
x += szDim.cx;
|
x += szDim.cx;
|
||||||
LineHeight = max(LineHeight, szDim.cy);
|
|
||||||
|
|
||||||
if(Wrap)
|
if(Wrap)
|
||||||
{
|
{
|
||||||
x = SL_LEFTMARGIN;
|
x = SL_LEFTMARGIN;
|
||||||
y += LineHeight;
|
y += LineHeight;
|
||||||
LineHeight = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -803,6 +788,7 @@ static VOID SYSLINK_Render (const SYSLINK_INFO *infoPtr, HDC hdc, PRECT pRect)
|
||||||
}
|
}
|
||||||
n -= LineLen;
|
n -= LineLen;
|
||||||
tx += LineLen;
|
tx += LineLen;
|
||||||
|
SkipChars = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue