comctl32: Implement LM_GETIDEALSIZE for the syslink control.
This commit is contained in:
parent
8c5d169a20
commit
254b97732b
|
@ -643,18 +643,24 @@ static BOOL SYSLINK_WrapLine (HDC hdc, LPWSTR Text, WCHAR BreakChar, int *LineLe
|
|||
* SYSLINK_Render
|
||||
* Renders the document in memory
|
||||
*/
|
||||
static VOID SYSLINK_Render (SYSLINK_INFO *infoPtr, HDC hdc)
|
||||
static VOID SYSLINK_Render (SYSLINK_INFO *infoPtr, HDC hdc, PRECT pRect)
|
||||
{
|
||||
RECT rc;
|
||||
PDOC_ITEM Current;
|
||||
HGDIOBJ hOldFont;
|
||||
int x, y, LineHeight;
|
||||
SIZE szDoc;
|
||||
|
||||
GetClientRect(infoPtr->Self, &rc);
|
||||
szDoc.cx = szDoc.cy = 0;
|
||||
|
||||
rc = *pRect;
|
||||
rc.right -= SL_RIGHTMARGIN;
|
||||
rc.bottom -= SL_BOTTOMMARGIN;
|
||||
|
||||
if(rc.right - SL_LEFTMARGIN < 0 || rc.bottom - SL_TOPMARGIN < 0) return;
|
||||
if(rc.right - SL_LEFTMARGIN < 0)
|
||||
rc.right = MAXLONG;
|
||||
if (rc.bottom - SL_TOPMARGIN < 0)
|
||||
rc.bottom = MAXLONG;
|
||||
|
||||
hOldFont = SelectObject(hdc, infoPtr->Font);
|
||||
|
||||
|
@ -715,6 +721,7 @@ static VOID SYSLINK_Render (SYSLINK_INFO *infoPtr, HDC hdc)
|
|||
{
|
||||
int LineLen = n;
|
||||
BOOL Wrap = FALSE;
|
||||
PDOC_TEXTBLOCK nbl;
|
||||
|
||||
if(n != 0)
|
||||
{
|
||||
|
@ -753,30 +760,12 @@ static VOID SYSLINK_Render (SYSLINK_INFO *infoPtr, HDC hdc)
|
|||
}
|
||||
}
|
||||
|
||||
if(bl != NULL)
|
||||
{
|
||||
PDOC_TEXTBLOCK nbl = ReAlloc(bl, (nBlocks + 1) * sizeof(DOC_TEXTBLOCK));
|
||||
nbl = ReAlloc(bl, (nBlocks + 1) * sizeof(DOC_TEXTBLOCK));
|
||||
if (nbl != NULL)
|
||||
{
|
||||
bl = nbl;
|
||||
nBlocks++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Free(bl);
|
||||
bl = NULL;
|
||||
nBlocks = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bl = Alloc(sizeof(DOC_TEXTBLOCK));
|
||||
if (bl != NULL)
|
||||
nBlocks++;
|
||||
}
|
||||
|
||||
if(bl != NULL)
|
||||
{
|
||||
cbl = bl + nBlocks - 1;
|
||||
|
||||
cbl->nChars = LineLen;
|
||||
|
@ -786,6 +775,11 @@ static VOID SYSLINK_Render (SYSLINK_INFO *infoPtr, HDC hdc)
|
|||
cbl->rc.right = x + szDim.cx;
|
||||
cbl->rc.bottom = y + szDim.cy;
|
||||
|
||||
if (cbl->rc.right > szDoc.cx)
|
||||
szDoc.cx = cbl->rc.right;
|
||||
if (cbl->rc.bottom > szDoc.cy)
|
||||
szDoc.cy = cbl->rc.bottom;
|
||||
|
||||
if(LineLen != 0)
|
||||
{
|
||||
x += szDim.cx;
|
||||
|
@ -801,6 +795,10 @@ static VOID SYSLINK_Render (SYSLINK_INFO *infoPtr, HDC hdc)
|
|||
}
|
||||
else
|
||||
{
|
||||
Free(bl);
|
||||
bl = NULL;
|
||||
nBlocks = 0;
|
||||
|
||||
ERR("Failed to alloc DOC_TEXTBLOCK structure!\n");
|
||||
break;
|
||||
}
|
||||
|
@ -820,6 +818,9 @@ static VOID SYSLINK_Render (SYSLINK_INFO *infoPtr, HDC hdc)
|
|||
}
|
||||
|
||||
SelectObject(hdc, hOldFont);
|
||||
|
||||
pRect->right = pRect->left + szDoc.cx;
|
||||
pRect->bottom = pRect->top + szDoc.cy;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -920,6 +921,7 @@ static HFONT SYSLINK_SetFont (SYSLINK_INFO *infoPtr, HFONT hFont, BOOL bRedraw)
|
|||
HDC hdc;
|
||||
LOGFONTW lf;
|
||||
TEXTMETRICW tm;
|
||||
RECT rcClient;
|
||||
HFONT hOldFont = infoPtr->Font;
|
||||
infoPtr->Font = hFont;
|
||||
|
||||
|
@ -931,6 +933,8 @@ static HFONT SYSLINK_SetFont (SYSLINK_INFO *infoPtr, HFONT hFont, BOOL bRedraw)
|
|||
}
|
||||
|
||||
/* Render text position and word wrapping in memory */
|
||||
if (GetClientRect(infoPtr->Self, &rcClient))
|
||||
{
|
||||
hdc = GetDC(infoPtr->Self);
|
||||
if(hdc != NULL)
|
||||
{
|
||||
|
@ -947,9 +951,10 @@ static HFONT SYSLINK_SetFont (SYSLINK_INFO *infoPtr, HFONT hFont, BOOL bRedraw)
|
|||
ERR("Failed to create link font!\n");
|
||||
}
|
||||
|
||||
SYSLINK_Render(infoPtr, hdc);
|
||||
SYSLINK_Render(infoPtr, hdc, &rcClient);
|
||||
ReleaseDC(infoPtr->Self, hdc);
|
||||
}
|
||||
}
|
||||
|
||||
if(bRedraw)
|
||||
{
|
||||
|
@ -978,16 +983,21 @@ static LRESULT SYSLINK_SetText (SYSLINK_INFO *infoPtr, LPCWSTR Text)
|
|||
/* let's parse the string and create a document */
|
||||
if(SYSLINK_ParseText(infoPtr, Text) > 0)
|
||||
{
|
||||
RECT rcClient;
|
||||
|
||||
/* Render text position and word wrapping in memory */
|
||||
if (GetClientRect(infoPtr->Self, &rcClient))
|
||||
{
|
||||
HDC hdc = GetDC(infoPtr->Self);
|
||||
if (hdc != NULL)
|
||||
{
|
||||
SYSLINK_Render(infoPtr, hdc);
|
||||
SYSLINK_Render(infoPtr, hdc, &rcClient);
|
||||
ReleaseDC(infoPtr->Self, hdc);
|
||||
|
||||
InvalidateRect(infoPtr->Self, NULL, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1076,6 +1086,7 @@ static LRESULT SYSLINK_SetItem (SYSLINK_INFO *infoPtr, PLITEM Item)
|
|||
else
|
||||
{
|
||||
Free(szId);
|
||||
|
||||
ERR("Unable to allocate memory for link url\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1502,6 +1513,33 @@ static BOOL SYSLINK_NoNextLink (SYSLINK_INFO *infoPtr, BOOL Prev)
|
|||
return NewFocus == NULL;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SYSLINK_GetIdealSize
|
||||
* Calculates the ideal size of a link control at a given maximum width.
|
||||
*/
|
||||
static VOID SYSLINK_GetIdealSize (SYSLINK_INFO *infoPtr, int cxMaxWidth, LPSIZE lpSize)
|
||||
{
|
||||
RECT rc;
|
||||
HDC hdc;
|
||||
|
||||
rc.left = rc.top = rc.bottom = 0;
|
||||
rc.right = cxMaxWidth;
|
||||
|
||||
hdc = GetDC(infoPtr->Self);
|
||||
if (hdc != NULL)
|
||||
{
|
||||
HGDIOBJ hOldFont = SelectObject(hdc, infoPtr->Font);
|
||||
|
||||
SYSLINK_Render(infoPtr, hdc, &rc);
|
||||
|
||||
SelectObject(hdc, hOldFont);
|
||||
ReleaseDC(infoPtr->Self, hdc);
|
||||
|
||||
lpSize->cx = rc.right;
|
||||
lpSize->cy = rc.bottom;
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SysLinkWindowProc
|
||||
*/
|
||||
|
@ -1541,13 +1579,17 @@ static LRESULT WINAPI SysLinkWindowProc(HWND hwnd, UINT message,
|
|||
}
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
RECT rcClient;
|
||||
if (GetClientRect(infoPtr->Self, &rcClient))
|
||||
{
|
||||
HDC hdc = GetDC(infoPtr->Self);
|
||||
if(hdc != NULL)
|
||||
{
|
||||
SYSLINK_Render(infoPtr, hdc);
|
||||
SYSLINK_Render(infoPtr, hdc, &rcClient);
|
||||
ReleaseDC(infoPtr->Self, hdc);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1651,6 +1693,11 @@ static LRESULT WINAPI SysLinkWindowProc(HWND hwnd, UINT message,
|
|||
return SYSLINK_GetItem(infoPtr, (PLITEM)lParam);
|
||||
|
||||
case LM_GETIDEALHEIGHT:
|
||||
if (lParam)
|
||||
{
|
||||
/* LM_GETIDEALSIZE */
|
||||
SYSLINK_GetIdealSize(infoPtr, (int)wParam, (LPSIZE)lParam);
|
||||
}
|
||||
return SYSLINK_GetIdealHeight(infoPtr);
|
||||
|
||||
case WM_SETFOCUS:
|
||||
|
|
|
@ -4889,6 +4889,7 @@ static const WCHAR WC_LINK[] = { 'S','y','s','L','i','n','k',0 };
|
|||
/* SysLink messages */
|
||||
#define LM_HITTEST (WM_USER + 768)
|
||||
#define LM_GETIDEALHEIGHT (WM_USER + 769)
|
||||
#define LM_GETIDEALSIZE (LM_GETIDEALHEIGHT)
|
||||
#define LM_SETITEM (WM_USER + 770)
|
||||
#define LM_GETITEM (WM_USER + 771)
|
||||
|
||||
|
|
Loading…
Reference in New Issue