mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 18:35:41 +00:00
[USER32] - Sync with Wine Staging 1.9.18.
svn path=/trunk/; revision=72651
This commit is contained in:
parent
cf98f01e86
commit
3e15c24d4c
1 changed files with 38 additions and 32 deletions
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* Edit control
|
* Edit control
|
||||||
*
|
*
|
||||||
* Copyright David W. Metcalfe, 1994
|
* Copyright David W. Metcalfe, 1994
|
||||||
* Copyright William Magro, 1995, 1996
|
* Copyright William Magro, 1995, 1996
|
||||||
* Copyright Frans van Dorsselaer, 1996, 1997
|
* Copyright Frans van Dorsselaer, 1996, 1997
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
|
@ -2904,30 +2904,30 @@ static void EDIT_EM_SetLimitText(EDITSTATE *es, UINT limit)
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
*
|
*
|
||||||
* EM_SETMARGINS
|
* EM_SETMARGINS
|
||||||
*
|
*
|
||||||
* EC_USEFONTINFO is used as a left or right value i.e. lParam and not as an
|
* EC_USEFONTINFO is used as a left or right value i.e. lParam and not as an
|
||||||
* action wParam despite what the docs say. EC_USEFONTINFO calculates the
|
* action wParam despite what the docs say. EC_USEFONTINFO calculates the
|
||||||
* margin according to the textmetrics of the current font.
|
* margin according to the textmetrics of the current font.
|
||||||
*
|
*
|
||||||
* FIXME - With TrueType or vector fonts EC_USEFONTINFO currently sets one third
|
* When EC_USEFONTINFO is used in the non_cjk case the margins only
|
||||||
* of the char's width as the margin, but this is not how Windows handles this.
|
* change if the edit control is equal to or larger than a certain
|
||||||
* For all other fonts Windows sets the margins to zero.
|
* size. Though there is an exception for the empty client rect case
|
||||||
*
|
* with small font sizes.
|
||||||
* FIXME - When EC_USEFONTINFO is used the margins only change if the
|
|
||||||
* edit control is equal to or larger than a certain size.
|
|
||||||
* Interestingly if one subtracts both the left and right margins from
|
|
||||||
* this size one always seems to get an even number. The extents of
|
|
||||||
* the (four character) string "'**'" match this quite closely, so
|
|
||||||
* we'll use this until we come up with a better idea.
|
|
||||||
*/
|
*/
|
||||||
static int calc_min_set_margin_size(HDC dc, INT left, INT right)
|
static BOOL is_cjk(UINT charset)
|
||||||
{
|
{
|
||||||
static const WCHAR magic_string[] = {'\'','*','*','\'', 0};
|
switch(charset)
|
||||||
SIZE sz;
|
{
|
||||||
|
case SHIFTJIS_CHARSET:
|
||||||
GetTextExtentPointW(dc, magic_string, sizeof(magic_string)/sizeof(WCHAR) - 1, &sz);
|
case HANGUL_CHARSET:
|
||||||
return sz.cx + left + right;
|
case GB2312_CHARSET:
|
||||||
|
case CHINESEBIG5_CHARSET:
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
/* HANGUL_CHARSET is strange, though treated as CJK by Win 8, it is
|
||||||
|
* not by other versions including Win 10. */
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EDIT_EM_SetMargins(EDITSTATE *es, INT action,
|
static void EDIT_EM_SetMargins(EDITSTATE *es, INT action,
|
||||||
|
@ -2941,19 +2941,25 @@ static void EDIT_EM_SetMargins(EDITSTATE *es, INT action,
|
||||||
if (es->font && (left == EC_USEFONTINFO || right == EC_USEFONTINFO)) {
|
if (es->font && (left == EC_USEFONTINFO || right == EC_USEFONTINFO)) {
|
||||||
HDC dc = GetDC(es->hwndSelf);
|
HDC dc = GetDC(es->hwndSelf);
|
||||||
HFONT old_font = SelectObject(dc, es->font);
|
HFONT old_font = SelectObject(dc, es->font);
|
||||||
GetTextMetricsW(dc, &tm);
|
LONG width = GdiGetCharDimensions(dc, &tm, NULL);
|
||||||
|
RECT rc;
|
||||||
|
|
||||||
/* The default margins are only non zero for TrueType or Vector fonts */
|
/* The default margins are only non zero for TrueType or Vector fonts */
|
||||||
if (tm.tmPitchAndFamily & ( TMPF_VECTOR | TMPF_TRUETYPE )) {
|
if (tm.tmPitchAndFamily & ( TMPF_VECTOR | TMPF_TRUETYPE )) {
|
||||||
int min_size;
|
if (!is_cjk(tm.tmCharSet)) {
|
||||||
RECT rc;
|
default_left_margin = width / 2;
|
||||||
/* This must be calculated more exactly! But how? */
|
default_right_margin = width / 2;
|
||||||
default_left_margin = tm.tmAveCharWidth / 2;
|
|
||||||
default_right_margin = tm.tmAveCharWidth / 2;
|
GetClientRect(es->hwndSelf, &rc);
|
||||||
min_size = calc_min_set_margin_size(dc, default_left_margin, default_right_margin);
|
if (rc.right - rc.left < (width / 2 + width) * 2 &&
|
||||||
GetClientRect(es->hwndSelf, &rc);
|
(width >= 28 || !IsRectEmpty(&rc)) ) {
|
||||||
if (!IsRectEmpty(&rc) && (rc.right - rc.left < min_size)) {
|
default_left_margin = es->left_margin;
|
||||||
default_left_margin = es->left_margin;
|
default_right_margin = es->right_margin;
|
||||||
default_right_margin = es->right_margin;
|
}
|
||||||
|
} else {
|
||||||
|
/* FIXME: figure out the CJK values. They are not affected by the client rect. */
|
||||||
|
default_left_margin = width / 2;
|
||||||
|
default_right_margin = width / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SelectObject(dc, old_font);
|
SelectObject(dc, old_font);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue