1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
Description: c05c5df1358bf5427dd2fcec0e392a132cd69422
Date: Mon, 17 Nov 2014 10:17:02 +0100
Subject: [PATCH] Pretend that native methods for caret manipulation are
available on Linux
---
.../Be.Windows.Forms.HexBox.csproj | 1 +
Be.Windows.Forms.HexBox/Caret.cs | 71 ++++++++++++++++++++++
Be.Windows.Forms.HexBox/HexBox.cs | 8 +--
3 files changed, 76 insertions(+), 4 deletions(-)
create mode 100644 Be.Windows.Forms.HexBox/Caret.cs
Author: Jaroslav Imrich <jaroslav.imrich@gmail.com>
Bug-Debian: https://bugs.debian.org/767355
Forwarded: no
Reviewed-By: Mathieu Malaterre <malat@debian.org>
@@ -122,6 +122,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="BytePositionInfo.cs" />
+ <Compile Include="Caret.cs" />
<Compile Include="DataBlock.cs">
<SubType>Code</SubType>
</Compile>
@@ -0,0 +1,71 @@
+using System;
+
+namespace Be.Windows.Forms
+{
+ internal static class Caret
+ {
+ public static bool Create(IntPtr hWnd, IntPtr hBitmap, int nWidth, int nHeight)
+ {
+ try
+ {
+ return NativeMethods.CreateCaret(hWnd, hBitmap, nWidth, nHeight);
+ }
+ catch (Exception ex)
+ {
+ // Let's pretend CreateCaret() is available on Linux
+ if ((ex is DllNotFoundException) || (ex is EntryPointNotFoundException))
+ return true;
+
+ throw;
+ }
+ }
+
+ public static bool Show(IntPtr hWnd)
+ {
+ try
+ {
+ return NativeMethods.ShowCaret(hWnd);
+ }
+ catch (Exception ex)
+ {
+ // Let's pretend ShowCaret() is available on Linux
+ if ((ex is DllNotFoundException) || (ex is EntryPointNotFoundException))
+ return true;
+
+ throw;
+ }
+ }
+
+ public static bool Destroy()
+ {
+ try
+ {
+ return NativeMethods.DestroyCaret();
+ }
+ catch (Exception ex)
+ {
+ // Let's pretend DestroyCaret() is available on Linux
+ if ((ex is DllNotFoundException) || (ex is EntryPointNotFoundException))
+ return true;
+
+ throw;
+ }
+ }
+
+ public static bool SetPos(int X, int Y)
+ {
+ try
+ {
+ return NativeMethods.SetCaretPos(X, Y);
+ }
+ catch (Exception ex)
+ {
+ // Let's pretend SetCaretPos() is available on Linux
+ if ((ex is DllNotFoundException) || (ex is EntryPointNotFoundException))
+ return true;
+
+ throw;
+ }
+ }
+ }
+}
@@ -1787,11 +1787,11 @@ namespace Be.Windows.Forms
// define the caret width depending on InsertActive mode
int caretWidth = (this.InsertActive) ? 1 : (int)_charSize.Width;
int caretHeight = (int)_charSize.Height;
- NativeMethods.CreateCaret(Handle, IntPtr.Zero, caretWidth, caretHeight);
+ Caret.Create(Handle, IntPtr.Zero, caretWidth, caretHeight);
UpdateCaret();
- NativeMethods.ShowCaret(Handle);
+ Caret.Show(Handle);
_caretVisible = true;
}
@@ -1806,7 +1806,7 @@ namespace Be.Windows.Forms
long byteIndex = _bytePos - _startByte;
PointF p = _keyInterpreter.GetCaretPointF(byteIndex);
p.X += _byteCharacterPos * _charSize.Width;
- NativeMethods.SetCaretPos((int)p.X, (int)p.Y);
+ Caret.SetPos((int)p.X, (int)p.Y);
}
void DestroyCaret()
@@ -1816,7 +1816,7 @@ namespace Be.Windows.Forms
System.Diagnostics.Debug.WriteLine("DestroyCaret()", "HexBox");
- NativeMethods.DestroyCaret();
+ Caret.Destroy();
_caretVisible = false;
}
|