OSDN Git Service

高dpiディスプレイを使用しているケースで予測候補の位置がずれるバグを修正した
authorgdkhd812 <jbh03215@htmil.co.jp>
Tue, 10 Dec 2013 15:13:09 +0000 (00:13 +0900)
committergdkhd812 <jbh03215@htmil.co.jp>
Tue, 10 Dec 2013 15:13:09 +0000 (00:13 +0900)
Common/DotNetTextStore/TextStoreBase.cs
Metro/FooEditEngine/FooTextBox.cs
WPF/FooEditEngine/Direct2D/D2DRender.cs
WPF/FooEditEngine/FooTextBox.cs

index 9db9152..951ff3a 100644 (file)
@@ -94,6 +94,9 @@ namespace DotNetTextStore
 \r
     public abstract class TextStoreBase\r
     {\r
+        public delegate double GetDpiHandeler();\r
+        public event GetDpiHandeler GetDpi;\r
+\r
         public delegate bool IsReadOnlyHandler();\r
         public event IsReadOnlyHandler IsReadOnly;\r
 \r
@@ -1240,10 +1243,15 @@ namespace DotNetTextStore
                 var pointBotttomRight = new POINT();\r
                 GetStringExtent(i_startIndex, i_endIndex, out pointTopLeft, out pointBotttomRight);\r
 \r
-                o_rect.left = (int)pointTopLeft.x;\r
-                o_rect.top = (int)pointTopLeft.y;\r
-                o_rect.bottom = (int)pointBotttomRight.y;//startFormattedText.Height);\r
-                o_rect.right = (int)pointBotttomRight.x;\r
+                if(this.GetDpi == null)\r
+                    throw new NotImplementedException();\r
+\r
+                double dpi = this.GetDpi();\r
+\r
+                o_rect.left = (int)(pointTopLeft.x * dpi / 96.0);\r
+                o_rect.top = (int)(pointTopLeft.y * dpi / 96.0);\r
+                o_rect.bottom = (int)(pointBotttomRight.y * dpi / 96.0);\r
+                o_rect.right = (int)(pointBotttomRight.x * dpi / 96.0);\r
                 o_isClipped = false;\r
 #if TSF_DEBUG_OUTPUT\r
                 DebugOut.Print("rect left:{0} top:{1} bottom:{2} right:{3}", o_rect.left, o_rect.top, o_rect.bottom, o_rect.right);\r
@@ -1264,10 +1272,15 @@ namespace DotNetTextStore
 \r
                 GetScreenExtent(out pointTopLeft, out pointBottomRight);\r
 \r
-                o_rect.left = (int)pointTopLeft.x;\r
-                o_rect.top = (int)pointTopLeft.y;\r
-                o_rect.right = (int)pointBottomRight.x;\r
-                o_rect.bottom = (int)pointBottomRight.y;\r
+                if (this.GetDpi == null)\r
+                    throw new NotImplementedException();\r
+\r
+                double dpi = this.GetDpi();\r
+\r
+                o_rect.left = (int)(pointTopLeft.x * dpi / 96.0);\r
+                o_rect.top = (int)(pointTopLeft.y * dpi / 96.0);\r
+                o_rect.bottom = (int)(pointBottomRight.y * dpi / 96.0);\r
+                o_rect.right = (int)(pointBottomRight.x * dpi / 96.0);\r
 #if TSF_DEBUG_OUTPUT\r
                 DebugOut.Print("rect left:{0} top:{1} bottom:{2} right:{3}", o_rect.left, o_rect.top, o_rect.bottom, o_rect.right);\r
 #endif\r
index ba24940..f269cb9 100644 (file)
@@ -59,6 +59,7 @@ namespace FooEditEngine.Metro
             this.textStore = new TextStore2();\r
             this.textStore.IsLoading += textStore_IsLoading;\r
             this.textStore.IsReadOnly += textStore_IsReadOnly;\r
+            this.textStore.GetDpi += textStore_GetDpi;\r
             this.textStore.GetStringLength += () => this.Document.Length;\r
             this.textStore.GetString += _textStore_GetString;\r
             this.textStore.GetSelectionIndex += _textStore_GetSelectionIndex;\r
@@ -627,6 +628,13 @@ namespace FooEditEngine.Metro
             this.Refresh();\r
         }\r
 \r
+        double textStore_GetDpi()\r
+        {\r
+            float dpi;\r
+            this.Render.GetDpi(out dpi, out dpi);\r
+            return dpi;\r
+        }\r
+\r
         bool textStore_IsReadOnly()\r
         {\r
             return false;\r
index 28e6fd6..ebd7f3d 100644 (file)
@@ -85,7 +85,7 @@ namespace FooEditEngine.WPF
             image.Source = this.imageSource;
         }
 
-        private void GetDpi(out float dpix, out float dpiy)
+        public void GetDpi(out float dpix, out float dpiy)
         {
             IntPtr hDc = NativeMethods.GetDC(IntPtr.Zero);
             dpix = NativeMethods.GetDeviceCaps(hDc, NativeMethods.LOGPIXELSX);
index 077a43a..b16b087 100644 (file)
@@ -71,6 +71,7 @@ namespace FooEditEngine.WPF
             this.textStore = new TextStore();\r
             this.textStore.IsLoading += textStore_IsLoading;\r
             this.textStore.IsReadOnly += textStore_IsReadOnly;\r
+            this.textStore.GetDpi += textStore_GetDpi;\r
             this.textStore.GetStringLength += () => this.Document.Length;\r
             this.textStore.GetString += _textStore_GetString;\r
             this.textStore.GetSelectionIndex += _textStore_GetSelectionIndex;\r
@@ -479,6 +480,13 @@ namespace FooEditEngine.WPF
             get { return this.textStore; }\r
         }\r
 \r
+        double textStore_GetDpi()\r
+        {\r
+            float dpi;\r
+            this.Render.GetDpi(out dpi, out dpi);\r
+            return dpi;\r
+        }\r
+\r
         bool textStore_IsReadOnly()\r
         {\r
             return false;\r