[ros-diffs] [fireball] 22991: Sync with Wine: Update EDIT_EM_SetMargins in EDIT control.

fireball at svn.reactos.org fireball at svn.reactos.org
Mon Jul 10 10:56:03 CEST 2006


Author: fireball
Date: Mon Jul 10 12:56:02 2006
New Revision: 22991

URL: http://svn.reactos.org/svn/reactos?rev=22991&view=rev
Log:
Sync with Wine: Update EDIT_EM_SetMargins in EDIT control.

Modified:
    trunk/reactos/dll/win32/user32/controls/edit.c
    trunk/reactos/media/doc/README.WINE

Modified: trunk/reactos/dll/win32/user32/controls/edit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/edit.c?rev=22991&r1=22990&r2=22991&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/controls/edit.c (original)
+++ trunk/reactos/dll/win32/user32/controls/edit.c Mon Jul 10 12:56:02 2006
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * 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
  *
@@ -239,7 +239,7 @@
 static void	EDIT_EM_SetHandle16(EDITSTATE *es, HLOCAL16 hloc);
 #endif
 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_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap);
 static BOOL	EDIT_EM_SetTabStops(EDITSTATE *es, INT count, LPINT tabs);
@@ -802,7 +802,7 @@
 	/* The following EM_xxx are new to win95 and don't exist for 16 bit */
 
 	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;
 
 	case EM_GETMARGINS:
@@ -3715,9 +3715,24 @@
  * 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.
  *
- */
+ * 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,
-			       INT left, INT right, BOOL repaint)
+			       WORD left, WORD right, BOOL repaint)
 {
 	TEXTMETRICW tm;
 	INT default_left_margin  = 0; /* in pixels */
@@ -3730,9 +3745,17 @@
             GetTextMetricsW(dc, &tm);
             /* The default margins are only non zero for TrueType or Vector fonts */
             if (tm.tmPitchAndFamily & ( TMPF_VECTOR | TMPF_TRUETYPE )) {
+                int min_size;
+                RECT rc;
                 /* This must be calculated more exactly! But how? */
-                default_left_margin = tm.tmAveCharWidth / 3;
-                default_right_margin = tm.tmAveCharWidth / 3;
+                default_left_margin = tm.tmAveCharWidth / 2;
+                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);
             ReleaseDC(es->hwndSelf, dc);

Modified: trunk/reactos/media/doc/README.WINE
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=22991&r1=22990&r2=22991&view=diff
==============================================================================
--- trunk/reactos/media/doc/README.WINE (original)
+++ trunk/reactos/media/doc/README.WINE Mon Jul 10 12:56:02 2006
@@ -117,7 +117,7 @@
 User32 -
   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/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/listbox.c   # Synced at 20060616
   reactos/dll/win32/user32/controls/scrollbar.c # Forked




More information about the Ros-diffs mailing list