aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/Label.cs
diff options
context:
space:
mode:
authorj-p <jp.bruyere@live.be>2016-08-05 18:48:09 +0200
committerGitHub <noreply@github.com>2016-08-05 18:48:09 +0200
commitbeba8120aa8f1529d79ccf0f52f02069b02aaf4d (patch)
tree8de343d8341be621c4b5daa12899155e0bc2f26a /src/GraphicObjects/Label.cs
parentda0cd66b6af42a3df1f35014617f1e0882ae9e63 (diff)
parentb9e90a3df66f4bd8228c1246af830d7801ea57ba (diff)
Merge pull request #15 from jpbruyere/TemplateImprovments
Template improvments
Diffstat (limited to 'src/GraphicObjects/Label.cs')
-rw-r--r--src/GraphicObjects/Label.cs52
1 files changed, 35 insertions, 17 deletions
diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs
index 2f5798ee..d09542b5 100644
--- a/src/GraphicObjects/Label.cs
+++ b/src/GraphicObjects/Label.cs
@@ -48,12 +48,13 @@ namespace Crow
#region private and protected fields
string _text = "label";
- Alignment _textAlignment = Alignment.Left;
- bool horizontalStretch = false;
- bool verticalStretch = false;
- bool _multiline = false;
- Color selColor;
- Color selFontColor;
+ Alignment _textAlignment;
+ bool horizontalStretch;
+ bool verticalStretch;
+ bool _selectable;
+ bool _multiline;
+ Color selBackground;
+ Color selForeground;
Point mouseLocalPos = -1;//mouse coord in widget space, filled only when clicked
int _currentCol; //0 based cursor position in string
int _currentLine;
@@ -73,23 +74,23 @@ namespace Crow
[XmlAttributeAttribute][DefaultValue("SteelBlue")]
public virtual Color SelectionBackground {
- get { return selColor; }
+ get { return selBackground; }
set {
- if (value == selColor)
+ if (value == selBackground)
return;
- selColor = value;
- NotifyValueChanged ("SelectionBackground", selColor);
+ selBackground = value;
+ NotifyValueChanged ("SelectionBackground", selBackground);
RegisterForRedraw ();
}
}
[XmlAttributeAttribute][DefaultValue("White")]
public virtual Color SelectionForeground {
- get { return selFontColor; }
+ get { return selForeground; }
set {
- if (value == selFontColor)
+ if (value == selForeground)
return;
- selFontColor = value;
- NotifyValueChanged ("SelectionForeground", selFontColor);
+ selForeground = value;
+ NotifyValueChanged ("SelectionForeground", selForeground);
RegisterForRedraw ();
}
}
@@ -151,6 +152,21 @@ namespace Crow
}
}
[XmlAttributeAttribute][DefaultValue(false)]
+ public bool Selectable
+ {
+ get { return _selectable; }
+ set
+ {
+ if (value == _selectable)
+ return;
+ _selectable = value;
+ NotifyValueChanged ("Selectable", _selectable);
+ SelBegin = -1;
+ SelRelease = -1;
+ RegisterForRedraw ();
+ }
+ }
+ [XmlAttributeAttribute][DefaultValue(false)]
public bool Multiline
{
get { return _multiline; }
@@ -548,7 +564,7 @@ namespace Crow
// lineRect.X += (rText.Width - lineLength);
if (SelRelease >= 0 && i >= selectionStart.Y && i <= selectionEnd.Y) {
- gr.SetSourceColor(selColor);
+ gr.SetSourceColor(selBackground);
Rectangle selRect = lineRect ;
@@ -594,6 +610,8 @@ namespace Crow
{
base.onFocused (sender, e);
+ if (!_selectable)
+ return;
SelBegin = new Point(0,0);
SelRelease = new Point (lines.LastOrDefault ().Length, lines.Count-1);
RegisterForRedraw ();
@@ -610,7 +628,7 @@ namespace Crow
{
base.onMouseMove (sender, e);
- if (!(SelectionInProgress && HasFocus))
+ if (!(SelectionInProgress && HasFocus && _selectable))
return;
updatemouseLocalPos (e.Position);
@@ -619,7 +637,7 @@ namespace Crow
}
public override void onMouseDown (object sender, MouseButtonEventArgs e)
{
- if (this.HasFocus){
+ if (this.HasFocus && _selectable){
updatemouseLocalPos (e.Position);
SelBegin = -1;
SelRelease = -1;