IFaceInit = IFace | 0x06,
CreateITor = IFace | 0x07,
- HoverWidget = Focus | 0x01,
- FocusedWidget = Focus | 0x02,
- ActiveWidget = Focus | 0x03,
+ HoverWidget = IFace | Focus | Widget | 0x01,
+ FocusedWidget = IFace | Focus | Widget | 0x02,
+ ActiveWidget = IFace | Focus | Widget | 0x03,
+ UnfocusedWidget = IFace | Focus | Widget | 0x04,
//10 nth bit set for graphic obj
TemplatedGroup = 0x1000,
GOAddChild = Widget | 0x08,
GOSearchLargestChild = Widget | 0x09,
- GOSearchTallestChild = Widget | 0x10,
- GORegisterForRedraw = Widget | 0x11,
+ GOSearchTallestChild = Widget | 0x0A,
+ GORegisterForRedraw = Widget | 0x0B,
AlreadyDisposed = Dispose | Widget | Error | 0x01,
DisposedByGC = Dispose | Widget | Error | 0x02,
-//
-// LayoutingEventArgs.cs
+// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
-// Author:
-// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
namespace Crow
/// </summary>
public Widget DropTarget;
- //public DragDropEventArgs (GraphicObject source, GraphicObject target = null) : base()
+ /// <summary>
+ /// Create a new instance of DragDropEventArgs.
+ /// </summary>
+ /// <param name="source">the widget instance source of the event</param>
+ /// <param name="target">the target widget of the event</param>
public DragDropEventArgs (Widget source = null, Widget target = null) : base()
{
DragSource = source;
-//
-// LayoutingEventArgs.cs
+// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
-// Author:
-// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
namespace Crow
{
+ /// <summary>
+ /// Event argument for layouting events.
+ /// </summary>
public class LayoutingEventArgs: EventArgs
{
+ /// <summary>
+ /// The layout type that has changed.
+ /// </summary>
public LayoutingType LayoutType;
-
+ /// <summary>
+ /// Create a new instance of LayoutingEventArgs.
+ /// </summary>
+ /// <param name="_layoutType">The layout type that trigger the event.</param>
public LayoutingEventArgs (LayoutingType _layoutType) : base()
{
LayoutType = _layoutType;
-// Copyright (c) 2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
-//
-// MouseCursorChangedEventArgs.cs
+// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
-// Author:
-// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
namespace Crow
{
+ /// <summary>
+ /// Occurs when the mouse cursor changes.
+ /// </summary>
public class MouseCursorChangedEventArgs : EventArgs
{
public MouseCursor NewCursor;
-//
-// ScrollingEventArgs.cs
+// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
-// Author:
-// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
namespace Crow
-//
-// TextChangeEventArgs.cs
+// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
-// Author:
-// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using Crow.Text;
using System;
namespace Crow
{
+ /// <summary>
+ /// Occurs in the TextBox widget when the text has changed.
+ /// </summary>
public class TextChangeEventArgs: EventArgs
{
+ /// <summary>
+ /// The TextChange structure representing the change.
+ /// </summary>
public TextChange Change;
public TextChangeEventArgs (TextChange _newValue) : base()
--- /dev/null
+// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System;
+
+namespace Crow
+{
+ /// <summary>
+ /// Occurs in the TextBox widget when the text has changed. Contains the
+ /// validated text.
+ /// </summary>
+ public class ValidateEventArgs : EventArgs
+ {
+ /// <summary>
+ /// The validated text.
+ /// </summary>
+ public string ValidatedText;
+ public ValidateEventArgs (string _text) : base () {
+ ValidatedText = _text;
+ }
+ }
+}
#region CTOR
static Interface ()
{
- /*if (Type.GetType ("Mono.Runtime") == null) {
- throw new Exception (@"C.R.O.W. run only on Mono, download latest version at: http://www.mono-project.com/download/stable/");
- }*/
-
CROW_CONFIG_ROOT =
System.IO.Path.Combine (
Environment.GetFolderPath (Environment.SpecialFolder.UserProfile),
_focusedWidget.HasFocus = false;
_focusedWidget = value;
- NotifyValueChanged ("FocusedWidget", _focusedWidget);
- DbgLogger.AddEvent (DbgEvtType.FocusedWidget, _focusedWidget);
+ NotifyValueChanged ("FocusedWidget", _focusedWidget);
if (_focusedWidget != null)
_focusedWidget.HasFocus = true;
}
OnTextChanged (this, new TextChangeEventArgs (Text));
}
*/
- bool textMeasureIsUpToDate = false;
+ protected bool textMeasureIsUpToDate = false;
Size cachedTextSize = default(Size);
protected LineCollection lines;
protected void getLines () {
namespace Crow
{
- public class TextBox : Label
+ public class TextBox : Label
{
- #region CTOR
- protected TextBox() {}
- public TextBox(Interface iface, string style = null) : base (iface, style) { }
- #endregion
+ #region CTOR
+ protected TextBox () { }
+ public TextBox (Interface iface, string style = null) : base (iface, style) { }
+ #endregion
+
+ /// <summary>
+ /// Validate content of the text box. Occurs in non multiline TextBox when 'Enter' key
+ /// is pressed.
+ /// </summary>
+ public event EventHandler<ValidateEventArgs> Validate;
+ public virtual void OnValidate (Object sender, ValidateEventArgs e) {
+ Validate.Raise (this, e);
+ }
+
-
#region Keyboard handling
- public override void onKeyDown (object sender, KeyEventArgs e)
- {
- Key key = e.Key;
- TextSpan selection = Selection;
- switch (key)
- {
- case Key.Backspace:
- if (selection.Length == 0) {
- if (selection.Start == 0)
- return;
- update (new TextChange (selection.Start - 1, 1, ""));
- } else
- update (new TextChange (selection.Start, selection.Length, ""));
- break;
- case Key.Delete:
- if (selection.Length == 0) {
- if (selection.Start == Text.Length)
- return;
- update (new TextChange (selection.Start, 1, ""));
- } else {
- if (IFace.Shift)
- IFace.Clipboard = Text.AsSpan(selection.Start, selection.End).ToString();
- update (new TextChange (selection.Start, selection.Length, ""));
- }
- break;
- case Key.Insert:
- if (IFace.Shift)
- update (new TextChange (selection.Start, selection.Length, IFace.Clipboard));
- else if (IFace.Ctrl && !selection.IsEmpty)
- IFace.Clipboard = Text.AsSpan (selection.Start, selection.End).ToString ();
- break;
- case Key.KeypadEnter:
- case Key.Enter:
- if (Multiline)
- update (new TextChange (selection.Start, selection.Length, "\n"));
- else
- OnTextChanged(this,new TextChangeEventArgs(default));
- break;
- case Key.Escape:
- selectionStart = null;
- currentLoc = lines.GetLocation (selection.Start);
- RegisterForRedraw ();
- break;
- case Key.Tab:
- update (new TextChange (selection.Start, selection.Length, "\t"));
- break;
- default:
- base.onKeyDown (sender, e);
- break;
- }
- e.Handled = true;
- }
- public override void onKeyPress (object sender, KeyPressEventArgs e)
- {
- base.onKeyPress (sender, e);
+ public override void onKeyDown (object sender, KeyEventArgs e) {
+ Key key = e.Key;
+ TextSpan selection = Selection;
+ switch (key) {
+ case Key.Backspace:
+ if (selection.Length == 0) {
+ if (selection.Start == 0)
+ return;
+ update (new TextChange (selection.Start - 1, 1, ""));
+ } else
+ update (new TextChange (selection.Start, selection.Length, ""));
+ break;
+ case Key.Delete:
+ if (selection.Length == 0) {
+ if (selection.Start == Text.Length)
+ return;
+ update (new TextChange (selection.Start, 1, ""));
+ } else {
+ if (IFace.Shift)
+ IFace.Clipboard = Text.AsSpan (selection.Start, selection.End).ToString ();
+ update (new TextChange (selection.Start, selection.Length, ""));
+ }
+ break;
+ case Key.Insert:
+ if (IFace.Shift)
+ update (new TextChange (selection.Start, selection.Length, IFace.Clipboard));
+ else if (IFace.Ctrl && !selection.IsEmpty)
+ IFace.Clipboard = Text.AsSpan (selection.Start, selection.End).ToString ();
+ break;
+ case Key.KeypadEnter:
+ case Key.Enter:
+ if (Multiline)
+ update (new TextChange (selection.Start, selection.Length, "\n"));
+ else
+ OnValidate (this, new ValidateEventArgs(_text));
+ break;
+ case Key.Escape:
+ selectionStart = null;
+ currentLoc = lines.GetLocation (selection.Start);
+ RegisterForRedraw ();
+ break;
+ case Key.Tab:
+ update (new TextChange (selection.Start, selection.Length, "\t"));
+ break;
+ default:
+ base.onKeyDown (sender, e);
+ break;
+ }
+ e.Handled = true;
+ }
+ public override void onKeyPress (object sender, KeyPressEventArgs e) {
+ base.onKeyPress (sender, e);
- TextSpan selection = Selection;
- update (new TextChange (selection.Start, selection.Length, e.KeyChar.ToString ()));
-
- /*Insert (e.KeyChar.ToString());
+ TextSpan selection = Selection;
+ update (new TextChange (selection.Start, selection.Length, e.KeyChar.ToString ()));
+
+ /*Insert (e.KeyChar.ToString());
SelRelease = -1;
SelBegin = new Point(CurrentColumn, SelBegin.Y);
RegisterForGraphicUpdate();*/
- }
+ }
#endregion
- void update(TextChange change) {
- Span<char> tmp = stackalloc char[Text.Length + (change.ChangedText.Length - change.Length)];
- ReadOnlySpan<char> src = Text.AsSpan ();
- src.Slice (0, change.Start).CopyTo (tmp);
- change.ChangedText.AsSpan ().CopyTo (tmp.Slice (change.Start));
- src.Slice (change.End).CopyTo (tmp.Slice (change.Start + change.ChangedText.Length));
- Text = tmp.ToString ();
-
- selectionStart = null;
- currentLoc = lines.GetLocation (change.Start + change.ChangedText.Length);
- }
- }
+ void update (TextChange change) {
+ Span<char> tmp = stackalloc char[Text.Length + (change.ChangedText.Length - change.Length)];
+ ReadOnlySpan<char> src = Text.AsSpan ();
+ src.Slice (0, change.Start).CopyTo (tmp);
+ change.ChangedText.AsSpan ().CopyTo (tmp.Slice (change.Start));
+ src.Slice (change.End).CopyTo (tmp.Slice (change.Start + change.ChangedText.Length));
+
+ _text = tmp.ToString ();
+
+ getLines ();
+
+ textMeasureIsUpToDate = false;
+ NotifyValueChanged ("Text", Text);
+ OnTextChanged (this, new TextChangeEventArgs (change));
+
+ selectionStart = null;
+ currentLoc = lines.GetLocation (change.Start + change.ChangedText.Length);
+
+ RegisterForGraphicUpdate ();
+ }
+ }
}
#endregion
protected virtual void onFocused(object sender, EventArgs e){
- #if DEBUG_FOCUS
- Debug.WriteLine("Focused => " + this.ToString());
- #endif
+ DbgLogger.AddEvent (DbgEvtType.FocusedWidget, this);
Focused.Raise (this, e);
}
protected virtual void onUnfocused(object sender, EventArgs e){
- #if DEBUG_FOCUS
- Debug.WriteLine("UnFocused => " + this.ToString());
- #endif
+ DbgLogger.AddEvent (DbgEvtType.UnfocusedWidget, this);
Unfocused.Raise (this, e);
}
<Authors>Jean-Philippe Bruyère</Authors>
<LangVersion>7.2</LangVersion>
- <CrowVersion>0.9.2</CrowVersion>
+ <CrowVersion>0.9.3</CrowVersion>
<CrowPackageVersion>$(CrowVersion)-beta</CrowPackageVersion>
<CrowStbSharp>true</CrowStbSharp>
</PropertyGroup>