aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/AnalogMeter.cs2
-rw-r--r--src/GraphicObjects/Border.cs8
-rw-r--r--src/GraphicObjects/GraduatedSlider.cs2
-rw-r--r--src/GraphicObjects/GraphicObject.cs49
-rw-r--r--src/GraphicObjects/Group.cs10
-rw-r--r--src/GraphicObjects/Label.cs24
-rw-r--r--src/GraphicObjects/ProgressBar.cs6
-rw-r--r--src/GraphicObjects/Slider.cs40
-rw-r--r--src/GraphicObjects/TextBox.cs4
-rw-r--r--src/GraphicObjects/TextRun.cs2
10 files changed, 89 insertions, 58 deletions
diff --git a/src/GraphicObjects/AnalogMeter.cs b/src/GraphicObjects/AnalogMeter.cs
index 39e012dd..80e0e850 100644
--- a/src/GraphicObjects/AnalogMeter.cs
+++ b/src/GraphicObjects/AnalogMeter.cs
@@ -34,7 +34,7 @@ namespace Crow
gr.Translate (-m.X, -m.Y);
gr.LineWidth = 2;
- gr.Color = Foreground;
+ Foreground.SetAsSource (gr);
gr.MoveTo (m.X,0.0);
gr.LineTo (m.X, -m.Y*0.5);
gr.Stroke ();
diff --git a/src/GraphicObjects/Border.cs b/src/GraphicObjects/Border.cs
index c04a135e..58ccff33 100644
--- a/src/GraphicObjects/Border.cs
+++ b/src/GraphicObjects/Border.cs
@@ -25,7 +25,7 @@ namespace Crow
}
}
[XmlAttributeAttribute()][DefaultValue("White")]
- public override Color Foreground {
+ public override Fill Foreground {
get { return base.Foreground;}
set {base.Foreground = value;}
}
@@ -52,13 +52,13 @@ namespace Crow
if (BorderWidth > 0)
rBack.Inflate (-BorderWidth / 2);
- gr.SetSourceColor(Background);
- CairoHelpers.CairoRectangle(gr,rBack,CornerRadius);
+ Background.SetAsSource (gr, rBack);
+ CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
gr.Fill ();
if (BorderWidth > 0) {
gr.LineWidth = BorderWidth;
- gr.SetSourceColor(Foreground);
+ Foreground.SetAsSource (gr, rBack);
CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
gr.Stroke ();
}
diff --git a/src/GraphicObjects/GraduatedSlider.cs b/src/GraphicObjects/GraduatedSlider.cs
index 3d916a8c..b7a181e0 100644
--- a/src/GraphicObjects/GraduatedSlider.cs
+++ b/src/GraphicObjects/GraduatedSlider.cs
@@ -25,7 +25,7 @@ namespace Crow
protected override void DrawGraduations(Context gr, PointD pStart, PointD pEnd)
{
Rectangle r = ClientRectangle;
- gr.SetSourceColor(Foreground);
+ Foreground.SetAsSource (gr);
gr.LineWidth = 2;
gr.MoveTo(pStart);
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 5613c0c9..7fd0e1ca 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -66,8 +66,8 @@ namespace Crow
#region private fields
ILayoutable _parent;
string _name = "unamed";
- Color _background = Color.Transparent;
- Color _foreground = Color.White;
+ Fill _background = Color.Transparent;
+ Fill _foreground = Color.White;
Font _font = "droid, 10";
double _cornerRadius = 0;
int _margin = 0;
@@ -79,9 +79,6 @@ namespace Crow
HorizontalAlignment _horizontalAlignment = HorizontalAlignment.Center;
Size _maximumSize = "0;0";
Size _minimumSize = "0;0";
-
- Picture _backgroundImage;
- string _backgroundImagePath;
#endregion
#region public fields
@@ -278,7 +275,7 @@ namespace Crow
}
}
[XmlAttributeAttribute()][DefaultValue("Transparent")]
- public virtual Color Background {
+ public virtual Fill Background {
get { return _background; }
set {
if (_background == value)
@@ -289,7 +286,7 @@ namespace Crow
}
}
[XmlAttributeAttribute()][DefaultValue("White")]
- public virtual Color Foreground {
+ public virtual Fill Foreground {
get { return _foreground; }
set {
if (_foreground == value)
@@ -415,7 +412,6 @@ namespace Crow
name = xaa.AttributeName;
continue;
}
-
XmlIgnoreAttribute xia = o as XmlIgnoreAttribute;
if (xia != null)
continue;
@@ -707,7 +703,7 @@ namespace Crow
{
Rectangle rBack = new Rectangle (Slot.Size);
- Background.SetAsSource (gr);
+ Background.SetAsSource (gr, rBack);
CairoHelpers.CairoRectangle(gr,rBack,_cornerRadius);
gr.Fill ();
}
@@ -747,12 +743,15 @@ namespace Crow
Rectangle rb = Parent.ContextCoordinates(Slot);
using (ImageSurface source = new ImageSurface(bmp, Format.Argb32, Slot.Width, Slot.Height, 4 * Slot.Width)) {
- if (this.Background == Color.Clear) {
- ctx.Save ();
- ctx.Operator = Operator.Clear;
- ctx.Rectangle(rb);
- ctx.Fill ();
- ctx.Restore ();
+ //TODO:improve equality test for basic color and Fill
+ if (this.Background is SolidColor) {
+ if ((this.Background as SolidColor).Equals(Color.Clear)) {
+ ctx.Save ();
+ ctx.Operator = Operator.Clear;
+ ctx.Rectangle (rb);
+ ctx.Fill ();
+ ctx.Restore ();
+ }
}
ctx.SetSourceSurface (source, rb.X, rb.Y);
ctx.Paint ();
@@ -1146,16 +1145,16 @@ namespace Crow
il.Emit(OpCodes.Ldstr,strcst);
}else{
- //search for a static field in left operand type named 'rop name'
- FieldInfo ropFi = lopT.GetField (rop, BindingFlags.Static|BindingFlags.Public);
- if (ropFi != null)
- {
- il.Emit (OpCodes.Ldsfld, ropFi);
- }else{
- //search if parsing methods are present
- MethodInfo lopTryParseMi = lopT.GetMethod("TryParse");
- //TODO
- }
+ if (lopT.IsEnum)
+ throw new NotImplementedException();
+
+ MethodInfo lopParseMi = lopT.GetMethod("Parse");
+ if (lopParseMi == null)
+ throw new Exception (string.Format
+ ("GOML:no parse method found in: {0}", lopT.Name));
+ il.Emit(OpCodes.Ldstr, rop);
+ il.Emit(OpCodes.Callvirt, lopParseMi);
+ il.Emit(OpCodes.Unbox_Any, lopT);
}
#endregion
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index e03399e9..087cd38d 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -188,8 +188,9 @@ namespace Crow
protected override void onDraw (Context gr)
{
Rectangle rBack = new Rectangle (Slot.Size);
- gr.SetSourceColor(Background);
- CairoHelpers.CairoRectangle(gr,rBack,CornerRadius);
+
+ Background.SetAsSource (gr, rBack);
+ CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
gr.Fill ();
foreach (GraphicObject g in Children) {
@@ -225,9 +226,10 @@ namespace Crow
clip.clearAndClip (gr);
Rectangle rBack = Slot.Size;
- gr.SetSourceColor(Background);
- CairoHelpers.CairoRectangle(gr,rBack,CornerRadius);
+ Background.SetAsSource (gr, rBack);
+ CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
gr.Fill ();
+
#if DEBUG_CLIP_RECTANGLE
clip.stroke (gr, Color.Amaranth.AdjustAlpha (0.8));
#endif
diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs
index 0b93924a..ee7dd045 100644
--- a/src/GraphicObjects/Label.cs
+++ b/src/GraphicObjects/Label.cs
@@ -106,7 +106,7 @@ namespace Crow
this.registerForGraphicUpdate ();
this.RegisterForLayouting ((int)LayoutingType.Sizing);
- NotifyValueChanged ("Text", Text);
+ NotifyValueChanged ("Text", _text);
}
}
[XmlAttributeAttribute()][DefaultValue(false)]
@@ -122,7 +122,8 @@ namespace Crow
registerForGraphicUpdate();
}
}
- [XmlIgnore]public int CurrentColumn{
+ [XmlAttributeAttribute()][DefaultValue(0)]
+ public int CurrentColumn{
get { return _currentCol; }
set {
if (value == _currentCol)
@@ -136,7 +137,8 @@ namespace Crow
NotifyValueChanged ("CurrentColumn", _currentCol);
}
}
- [XmlIgnore]public int CurrentLine{
+ [XmlAttributeAttribute()][DefaultValue(0)]
+ public int CurrentLine{
get { return _currentLine; }
set {
if (value == _currentLine)
@@ -150,7 +152,9 @@ namespace Crow
NotifyValueChanged ("CurrentLine", _currentLine);
}
}
- [XmlIgnore]public Point SelBegin {
+ //TODO:using HasFocus for drawing selection cause SelBegin and Release binding not to work
+ [XmlAttributeAttribute()][DefaultValue("-1")]
+ public Point SelBegin {
get {
return _selBegin;
}
@@ -158,10 +162,12 @@ namespace Crow
if (value == _selBegin)
return;
_selBegin = value;
+ NotifyValueChanged ("SelBegin", _selBegin);
NotifyValueChanged ("SelectedText", SelectedText);
}
}
- [XmlIgnore]public Point SelRelease {
+ [XmlAttributeAttribute()][DefaultValue("-1")]
+ public Point SelRelease {
get {
return _selRelease;
}
@@ -169,6 +175,7 @@ namespace Crow
if (value == _selRelease)
return;
_selRelease = value;
+ NotifyValueChanged ("SelRelease", _selRelease);
NotifyValueChanged ("SelectedText", SelectedText);
}
}
@@ -228,6 +235,7 @@ namespace Crow
CurrentColumn = lines [CurrentLine].Count ();
lines [CurrentLine] += lines [CurrentLine + 1];
lines.RemoveAt (CurrentLine + 1);
+ NotifyValueChanged ("Text", Text);
return;
}
CurrentColumn--;
@@ -251,6 +259,7 @@ namespace Crow
SelBegin = -1;
SelRelease = -1;
}
+ NotifyValueChanged ("Text", Text);
}
/// <summary>
/// Insert new string at caret position, should be sure no line break is inside.
@@ -260,6 +269,7 @@ namespace Crow
{
lines [CurrentLine] = lines [CurrentLine].Insert (CurrentColumn, str);
CurrentColumn += str.Length;
+ NotifyValueChanged ("Text", Text);
}
#region GraphicObject overrides
@@ -483,7 +493,7 @@ namespace Crow
if (HasFocus )
{
- gr.SetSourceColor(Foreground);
+ Foreground.SetAsSource (gr);
gr.LineWidth = 1.5;
gr.MoveTo(new PointD(textCursorPos + rText.X, rText.Y + CurrentLine * fe.Height));
gr.LineTo(new PointD(textCursorPos + rText.X, rText.Y + (CurrentLine + 1) * fe.Height));
@@ -535,7 +545,7 @@ namespace Crow
if (string.IsNullOrWhiteSpace (l))
continue;
- gr.SetSourceColor(Foreground);
+ Foreground.SetAsSource (gr);
gr.MoveTo (lineRect.X, rText.Y + fe.Ascent + fe.Height * i);
#if _WIN32 || _WIN64
diff --git a/src/GraphicObjects/ProgressBar.cs b/src/GraphicObjects/ProgressBar.cs
index c8dcbb77..c8165353 100644
--- a/src/GraphicObjects/ProgressBar.cs
+++ b/src/GraphicObjects/ProgressBar.cs
@@ -68,7 +68,7 @@ namespace Crow
#region GraphicObject overrides
[XmlAttributeAttribute()][DefaultValue("Gray")]
- public override Color Background {
+ public override Fill Background {
get { return base.Background; }
set { base.Background = value; }
}
@@ -78,7 +78,7 @@ namespace Crow
set { base.BorderWidth = value; }
}
[XmlAttributeAttribute()][DefaultValue("BlueCrayola")]
- public override Color Foreground {
+ public override Fill Foreground {
get { return base.Foreground; }
set { base.Foreground = value; }
}
@@ -94,7 +94,7 @@ namespace Crow
rBack.Width = (int)((double)rBack.Width / Maximum * Value);
- gr.SetSourceColor(Foreground);
+ Foreground.SetAsSource (gr, rBack);
CairoHelpers.CairoRectangle(gr,rBack,CornerRadius);
gr.Fill();
diff --git a/src/GraphicObjects/Slider.cs b/src/GraphicObjects/Slider.cs
index a931934a..f21202a8 100644
--- a/src/GraphicObjects/Slider.cs
+++ b/src/GraphicObjects/Slider.cs
@@ -32,7 +32,7 @@ namespace Crow
#region private fields
Rectangle cursor;
int _cursorSize;
- Color _cursorColor;
+ Fill _cursorColor;
Orientation _orientation;
bool holdCursor = false;
#endregion
@@ -40,33 +40,47 @@ namespace Crow
protected double unity;
#region Public properties
- [XmlAttributeAttribute()][DefaultValue("BlueGray")]
- public virtual Color CursorColor {
+ [XmlAttributeAttribute()][DefaultValue("vgradient|0:White|0,1:SteelBlue|0,9:SteelBlue|1:DimGray")]
+ public virtual Fill CursorColor {
get { return _cursorColor; }
set {
+ if (_cursorColor == value)
+ return;
_cursorColor = value;
registerForGraphicUpdate ();
+ NotifyValueChanged ("CursorColor", _cursorColor);
}
}
[XmlAttributeAttribute()][DefaultValue(20)]
public virtual int CursorSize {
get { return _cursorSize; }
set {
+ if (_cursorSize == value)
+ return;
_cursorSize = value;
+ RegisterForLayouting ((int)LayoutingType.Sizing);
registerForGraphicUpdate ();
+ NotifyValueChanged ("CursorSize", _cursorSize);
}
}
[XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)]
public virtual Orientation Orientation
{
get { return _orientation; }
- set { _orientation = value; }
+ set {
+ if (_orientation == value)
+ return;
+ _orientation = value;
+
+ RegisterForLayouting ((int)LayoutingType.All);
+ NotifyValueChanged ("Orientation", _orientation);
+ }
}
#endregion
[XmlAttributeAttribute()][DefaultValue(10.0)]
public override double Maximum {
get { return base.Maximum; }
- set {
+ set {
if (value == base.Maximum)
return;
base.Maximum = value;
@@ -75,12 +89,18 @@ namespace Crow
}
}
+
#region GraphicObject Overrides
- [XmlAttributeAttribute()][DefaultValue("Gray")]
- public override Color Background {
+ [XmlAttributeAttribute()][DefaultValue("vgradient|0:Black|0,1:Gray|0,9:Gray|1:LightGray")]
+ public override Fill Background {
get { return base.Background; }
set { base.Background = value; }
}
+ [XmlAttributeAttribute()][DefaultValue("Gray")]
+ public override Fill Foreground {
+ get { return base.Foreground; }
+ set { base.Foreground = value; }
+ }
[XmlAttributeAttribute()][DefaultValue(true)]
public override bool Focusable
{
@@ -120,7 +140,7 @@ namespace Crow
protected virtual void DrawGraduations(Context gr, PointD pStart, PointD pEnd)
{
- gr.SetSourceColor(Foreground);
+ Foreground.SetAsSource (gr);
gr.LineWidth = 1;
gr.MoveTo(pStart);
@@ -131,9 +151,9 @@ namespace Crow
}
protected virtual void DrawCursor(Context gr, Rectangle _cursor)
{
- gr.SetSourceColor(CursorColor);
+ CursorColor.SetAsSource (gr, _cursor);
CairoHelpers.CairoRectangle (gr, _cursor, CornerRadius);
- gr.FillPreserve();
+ gr.Fill();
}
void computeCursorPosition()
diff --git a/src/GraphicObjects/TextBox.cs b/src/GraphicObjects/TextBox.cs
index 6af75f1e..d9003b61 100644
--- a/src/GraphicObjects/TextBox.cs
+++ b/src/GraphicObjects/TextBox.cs
@@ -45,12 +45,12 @@ namespace Crow
set { base.Focusable = value; }
}
[XmlAttributeAttribute()][DefaultValue("White")]
- public override Color Background {
+ public override Fill Background {
get { return base.Background; }
set { base.Background = value; }
}
[XmlAttributeAttribute()][DefaultValue("Black")]
- public override Color Foreground {
+ public override Fill Foreground {
get { return base.Foreground; }
set { base.Foreground = value; }
}
diff --git a/src/GraphicObjects/TextRun.cs b/src/GraphicObjects/TextRun.cs
index 1c539c67..bee580b3 100644
--- a/src/GraphicObjects/TextRun.cs
+++ b/src/GraphicObjects/TextRun.cs
@@ -313,7 +313,7 @@ namespace Crow
continue;
}
- gr.SetSourceColor (Foreground);
+ Foreground.SetAsSource (gr);
gr.MoveTo (rText.X, rText.Y + fe.Ascent + fe.Height * curLineCount);
#if _WIN32 || _WIN64