using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
-#if NET_2_0
using System.Collections.Generic;
using System.Runtime.InteropServices;
-#endif
namespace System.Windows.Forms {
-#if NET_2_0
[ComVisible(true)]
[ClassInterface (ClassInterfaceType.AutoDispatch)]
[Designer ("System.Windows.Forms.Design.TextBoxDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
-#endif
public class TextBox : TextBoxBase {
#region Variables
private ContextMenu menu;
private MenuItem delete;
private MenuItem select_all;
-#if NET_2_0
private bool use_system_password_char;
private AutoCompleteStringCollection auto_complete_custom_source;
private AutoCompleteMode auto_complete_mode = AutoCompleteMode.None;
private int auto_complete_selected_index = -1;
private List<string> auto_complete_matches;
private ComboBox auto_complete_cb_source;
-#endif
#endregion // Variables
#region Public Constructors
alignment = HorizontalAlignment.Left;
this.LostFocus +=new EventHandler(TextBox_LostFocus);
this.RightToLeftChanged += new EventHandler (TextBox_RightToLeftChanged);
-#if NET_2_0
MouseWheel += new MouseEventHandler (TextBox_MouseWheel);
-#endif
BackColor = SystemColors.Window;
ForeColor = SystemColors.WindowText;
private void TextBox_LostFocus (object sender, EventArgs e) {
if (hide_selection)
document.InvalidateSelectionArea ();
-#if NET_2_0
if (auto_complete_listbox != null && auto_complete_listbox.Visible)
auto_complete_listbox.HideListBox (false);
-#endif
}
-#if NET_2_0
private void TextBox_MouseWheel (object o, MouseEventArgs args)
{
if (auto_complete_listbox == null || !auto_complete_listbox.Visible)
// We only support CustomSource by now
//
- IList source;
- if (auto_complete_cb_source == null)
- source = auto_complete_custom_source;
- else
- source = auto_complete_cb_source.Items;
-
- if (source == null || source.Count == 0)
- return;
+ IList source = auto_complete_cb_source == null ? auto_complete_custom_source : (IList)auto_complete_cb_source.Items;
bool append = auto_complete_mode == AutoCompleteMode.Append || auto_complete_mode == AutoCompleteMode.SuggestAppend;
bool suggest = auto_complete_mode == AutoCompleteMode.Suggest || auto_complete_mode == AutoCompleteMode.SuggestAppend;
auto_complete_listbox.HideListBox (false);
}
- bool IsAutoCompleteAvailable {
+ internal bool IsAutoCompleteAvailable {
get {
if (auto_complete_source == AutoCompleteSource.None || auto_complete_mode == AutoCompleteMode.None)
return false;
- // We only support CustomSource by now
- if (auto_complete_source != AutoCompleteSource.CustomSource || auto_complete_custom_source == null ||
- auto_complete_custom_source.Count == 0)
+ // We only support CustomSource by now, as well as an internal custom source used by ComboBox
+ if (auto_complete_source != AutoCompleteSource.CustomSource)
+ return false;
+ IList custom_source = auto_complete_cb_source == null ? auto_complete_custom_source : (IList)auto_complete_cb_source.Items;
+ if (custom_source == null || custom_source.Count == 0)
return false;
return true;
SelectionLength = auto_complete_matches [index].Length - auto_complete_original_text.Length;
}
-#endif
+ // this is called when the user selects a value from the autocomplete list
+ // *with* the mouse
+ internal virtual void OnAutoCompleteValueSelected (EventArgs args)
+ {
+ }
private void UpdateAlignment ()
{
internal override Color ChangeBackColor (Color backColor)
{
if (backColor == Color.Empty) {
-#if NET_2_0
if (!ReadOnly)
backColor = SystemColors.Window;
-#else
- backColor = SystemColors.Window;
-#endif
+
backcolor_set = false;
}
+
return backColor;
}
-#if NET_2_0
void OnAutoCompleteCustomSourceChanged(object sender, CollectionChangeEventArgs e) {
if(auto_complete_source == AutoCompleteSource.CustomSource) {
//FIXME: handle add, remove and refresh events in AutoComplete algorithm.
}
}
-#endif
#endregion // Private & Internal Methods
#region Public Instance Properties
-#if NET_2_0
[MonoTODO("AutoCompletion algorithm is currently not implemented.")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
[Browsable (true)]
}
}
}
-#endif
[DefaultValue(false)]
[MWFCategory("Behavior")]
[Localizable(true)]
[DefaultValue('\0')]
[MWFCategory("Behavior")]
-#if NET_2_0
[RefreshProperties (RefreshProperties.Repaint)]
-#endif
public char PasswordChar {
get {
-#if NET_2_0
if (use_system_password_char) {
return '*';
}
-#endif
return password_char;
}
}
}
-#if ONLY_1_1
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override int SelectionLength {
- get {
- return base.SelectionLength;
- }
- set {
- base.SelectionLength = value;
- }
- }
-#endif
-
public override string Text {
get {
return base.Text;
}
#endregion // Public Instance Properties
-#if NET_2_0
public void Paste (string text)
{
document.ReplaceSelection (CaseAdjust (text), false);
ScrollToCaret();
OnTextChanged(EventArgs.Empty);
}
-#endif
#region Protected Instance Methods
protected override CreateParams CreateParams {
get {
}
}
-#if ONLY_1_1
- protected override ImeMode DefaultImeMode {
- get {
- return base.DefaultImeMode;
- }
- }
-#endif
-#if NET_2_0
protected override void Dispose (bool disposing)
{
base.Dispose (disposing);
}
-#endif
protected override bool IsInputKey (Keys keyData)
{
base.OnHandleCreated (e);
}
-#if ONLY_1_1
- protected override void OnMouseUp(MouseEventArgs mevent)
- {
- base.OnMouseUp (mevent);
- }
-#endif
-
protected virtual void OnTextAlignChanged (EventArgs e)
{
EventHandler eh = (EventHandler)(Events [TextAlignChangedEvent]);
protected override void WndProc (ref Message m)
{
switch ((Msg)m.Msg) {
-#if NET_2_0
case Msg.WM_KEYDOWN:
if (!IsAutoCompleteAvailable)
break;
ProcessAutoCompleteInput (ref m, char_value == 8);
return;
-#endif
case Msg.WM_LBUTTONDOWN:
// When the textbox gets focus by LBUTTON (but not by middle or right)
// it does not do the select all / scroll thing.
}
#endregion // Private Methods
-#if NET_2_0
public override bool Multiline {
get {
return base.Multiline;
HighlightedIndex = -1;
Show ();
+ // make sure we are on top - call the raw routine, since we are parentless
+ XplatUI.SetZOrder (Handle, IntPtr.Zero, true, false);
Invalidate ();
}
if (item_idx != -1 && !resizing)
HideListBox (true);
+ owner.OnAutoCompleteValueSelected (EventArgs.Empty); // internal
resizing = false;
Capture = false;
}
ThemeEngine.Current.CPDrawSizeGrip (g, SystemColors.Control, resizer_bounds);
}
}
-#endif
}
-#if NET_2_0
internal class TextBoxAutoCompleteSourceConverter : EnumConverter
{
public TextBoxAutoCompleteSourceConverter(Type type)
return new StandardValuesCollection(arr2);
}
}
-#endif
}