mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 23:42:57 +00:00
Sync with Wine: Update EDIT_EM_SetMargins in EDIT control.
svn path=/trunk/; revision=22991
This commit is contained in:
parent
e11e4547e1
commit
645a3280f5
2 changed files with 30 additions and 7 deletions
|
@ -18,7 +18,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
*
|
*
|
||||||
|
@ -239,7 +239,7 @@ static void EDIT_EM_SetHandle(EDITSTATE *es, HLOCAL hloc);
|
||||||
static void EDIT_EM_SetHandle16(EDITSTATE *es, HLOCAL16 hloc);
|
static void EDIT_EM_SetHandle16(EDITSTATE *es, HLOCAL16 hloc);
|
||||||
#endif
|
#endif
|
||||||
static void EDIT_EM_SetLimitText(EDITSTATE *es, INT limit);
|
static void EDIT_EM_SetLimitText(EDITSTATE *es, INT limit);
|
||||||
static void EDIT_EM_SetMargins(EDITSTATE *es, INT action, INT left, INT right, BOOL repaint);
|
static void EDIT_EM_SetMargins(EDITSTATE *es, INT action, WORD left, WORD right, BOOL repaint);
|
||||||
static void EDIT_EM_SetPasswordChar(EDITSTATE *es, WCHAR c);
|
static void EDIT_EM_SetPasswordChar(EDITSTATE *es, WCHAR c);
|
||||||
static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap);
|
static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap);
|
||||||
static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, LPINT tabs);
|
static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, LPINT tabs);
|
||||||
|
@ -802,7 +802,7 @@ static LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
|
||||||
/* The following EM_xxx are new to win95 and don't exist for 16 bit */
|
/* The following EM_xxx are new to win95 and don't exist for 16 bit */
|
||||||
|
|
||||||
case EM_SETMARGINS:
|
case EM_SETMARGINS:
|
||||||
EDIT_EM_SetMargins(es, (INT)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam), TRUE);
|
EDIT_EM_SetMargins(es, (INT)wParam, LOWORD(lParam), HIWORD(lParam), TRUE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EM_GETMARGINS:
|
case EM_GETMARGINS:
|
||||||
|
@ -3715,9 +3715,24 @@ static void EDIT_EM_SetLimitText(EDITSTATE *es, INT limit)
|
||||||
* of the char's width as the margin, but this is not how Windows handles this.
|
* of the char's width as the margin, but this is not how Windows handles this.
|
||||||
* For all other fonts Windows sets the margins to zero.
|
* For all other fonts Windows sets the margins to zero.
|
||||||
*
|
*
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
WCHAR magic_string[] = {'\'','*','*','\'', 0};
|
||||||
|
SIZE sz;
|
||||||
|
|
||||||
|
GetTextExtentPointW(dc, magic_string, sizeof(magic_string)/sizeof(WCHAR) - 1, &sz);
|
||||||
|
return sz.cx + left + right;
|
||||||
|
}
|
||||||
|
|
||||||
static void EDIT_EM_SetMargins(EDITSTATE *es, INT action,
|
static void EDIT_EM_SetMargins(EDITSTATE *es, INT action,
|
||||||
INT left, INT right, BOOL repaint)
|
WORD left, WORD right, BOOL repaint)
|
||||||
{
|
{
|
||||||
TEXTMETRICW tm;
|
TEXTMETRICW tm;
|
||||||
INT default_left_margin = 0; /* in pixels */
|
INT default_left_margin = 0; /* in pixels */
|
||||||
|
@ -3730,9 +3745,17 @@ static void EDIT_EM_SetMargins(EDITSTATE *es, INT action,
|
||||||
GetTextMetricsW(dc, &tm);
|
GetTextMetricsW(dc, &tm);
|
||||||
/* 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;
|
||||||
|
RECT rc;
|
||||||
/* This must be calculated more exactly! But how? */
|
/* This must be calculated more exactly! But how? */
|
||||||
default_left_margin = tm.tmAveCharWidth / 3;
|
default_left_margin = tm.tmAveCharWidth / 2;
|
||||||
default_right_margin = tm.tmAveCharWidth / 3;
|
default_right_margin = tm.tmAveCharWidth / 2;
|
||||||
|
min_size = calc_min_set_margin_size(dc, default_left_margin, default_right_margin);
|
||||||
|
GetClientRect(es->hwndSelf, &rc);
|
||||||
|
if(rc.right - rc.left < min_size) {
|
||||||
|
default_left_margin = es->left_margin;
|
||||||
|
default_right_margin = es->right_margin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SelectObject(dc, old_font);
|
SelectObject(dc, old_font);
|
||||||
ReleaseDC(es->hwndSelf, dc);
|
ReleaseDC(es->hwndSelf, dc);
|
||||||
|
|
|
@ -117,7 +117,7 @@ msvcrt -
|
||||||
User32 -
|
User32 -
|
||||||
reactos/dll/win32/user32/controls/button.c # Synced at 20060621
|
reactos/dll/win32/user32/controls/button.c # Synced at 20060621
|
||||||
reactos/dll/win32/user32/controls/combo.c # Synced at 20060617
|
reactos/dll/win32/user32/controls/combo.c # Synced at 20060617
|
||||||
reactos/dll/win32/user32/controls/edit.c # Synced at 20060623
|
reactos/dll/win32/user32/controls/edit.c # Synced at 20060710
|
||||||
reactos/dll/win32/user32/controls/icontitle.c # Synced at 20060617
|
reactos/dll/win32/user32/controls/icontitle.c # Synced at 20060617
|
||||||
reactos/dll/win32/user32/controls/listbox.c # Synced at 20060616
|
reactos/dll/win32/user32/controls/listbox.c # Synced at 20060616
|
||||||
reactos/dll/win32/user32/controls/scrollbar.c # Forked
|
reactos/dll/win32/user32/controls/scrollbar.c # Forked
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue