OSDN Git Service

UWP版テキストボックスを作った
[fooeditengine/FooEditEngine.git] / Core / TextServiceFramework / TextStoreHelper.cs
index 13cabf5..1f98d9a 100644 (file)
@@ -8,11 +8,14 @@
 
 You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
+#if METRO || WPF || WINDOWS_UWP
+
+ using System.Linq;
 #if METRO || WPF
-using System.Linq;
 using DotNetTextStore.UnmanagedAPI.WinDef;
 using DotNetTextStore.UnmanagedAPI.TSF;
 using DotNetTextStore;
+#endif
 
 namespace FooEditEngine
 {
@@ -29,6 +32,7 @@ namespace FooEditEngine
             document.UndoManager.EndUndoGroup();
         }
 
+#if METRO || WPF
         public static bool ScrollToCompstionUpdated(TextStoreBase textStore,EditView view,int start, int end)
         {
             if (textStore.IsLocked() == false)
@@ -48,6 +52,7 @@ namespace FooEditEngine
             }
             return false;   
         }
+#endif
 
         public static void GetStringExtent(Document document,EditView view,int i_startIndex,int i_endIndex,out Point startPos,out Point endPos)
         {
@@ -57,29 +62,26 @@ namespace FooEditEngine
             startPos = view.GetPostionFromTextPoint(view.LayoutLines.GetTextPointFromIndex(i_startIndex));
             endTextPoint = view.GetLayoutLineFromIndex(endIndex);
             endPos = view.GetPostionFromTextPoint(endTextPoint);
-            //変換候補リストに隙間があるので、ユーザーが見えるように少し移動させる
-            endPos.Y += view.LayoutLines.GetLayout(endTextPoint.row).Height;
+            //アンダーラインを描くことがあるので少しずらす
+            endPos.Y += view.LayoutLines.GetLayout(endTextPoint.row).Height + 5;
         }
 
-        public static void GetSelection(Controller controller, SelectCollection selectons, out DotNetTextStore.TextSelection[] sels)
+        public static void GetSelection(Controller controller, SelectCollection selectons, out TextRange sel)
         {
-            sels = new TextSelection[1];
-            sels[0] = new TextSelection();
             if (controller.RectSelection && selectons.Count > 0)
             {
-                sels[0].start = selectons[0].start;
-                sels[0].end = sels[0].start + selectons[0].length;
+                sel.Index = selectons[0].start;
+                sel.Length = selectons[0].length;
             }
             else
             {
-                sels[0].start = controller.SelectionStart;
-                sels[0].end = sels[0].start + controller.SelectionLength;
+                sel.Index = controller.SelectionStart;
+                sel.Length = controller.SelectionLength;
             }
         }
 
-        public static void SetSelectionIndex(Controller controller,EditView view,DotNetTextStore.TextSelection[] sels)
+        public static void SetSelectionIndex(Controller controller,EditView view,int i_startIndex,int i_endIndex)
         {
-            int i_startIndex = sels[0].start, i_endIndex = sels[0].end;
             if (controller.IsRectInsertMode())
             {
                 TextPoint start = view.LayoutLines.GetTextPointFromIndex(i_startIndex);
@@ -97,11 +99,12 @@ namespace FooEditEngine
             }
         }
 
-        public static void InsertTextAtSelection(Controller controller,string i_value)
+        public static void InsertTextAtSelection(Controller controller,string i_value, bool fromTIP = true)
         {
-            controller.DoInputString(i_value, true);
+            controller.DoInputString(i_value, fromTIP);
         }
 
+#if METRO || WPF
         public static void NotifyTextChanged(TextStoreBase textStore, int startIndex,int removeLength,int insertLength)
         {
 #if METRO
@@ -117,6 +120,7 @@ namespace FooEditEngine
 #endif
             textStore.NotifyTextChanged(startIndex, oldend, newend);
         }
+#endif
     }
 }
 #endif