<LogicalName>Crow.Window.template</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="Images\Icons\Cursors\ibeam" />
+ <EmbeddedResource Include="Templates\treeList.crow" />
</ItemGroup>
<ItemGroup>
<None Include="README.md" />
<HorizontalStack Height="Fit" Width="{./WidthPolicy}">
<GraphicObject Width="12" Height="10"/>
<TreeView Name="List" Height="Fit" Width="{./WidthPolicy}"
- Template="#Tests.Interfaces.treeList.crow" />
+ Template="#Crow.Templates.treeList.crow" />
</HorizontalStack>
</Expandable>
</ItemTemplate>
<?xml version="1.0"?>
-<Border BorderWidth="1" Foreground="White" CornerRadius="20" Height="{./HeightPolicy}" Width="{./WidthPolicy}"
+<Border BorderWidth="1" Foreground="White" CornerRadius="{./CornerRadius}" Height="{./HeightPolicy}" Width="{./WidthPolicy}"
MouseEnter="./onBorderMouseEnter"
MouseLeave="./onBorderMouseLeave">
- <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}">
+ <VerticalStack Height="{./HeightPolicy}" Width="{./WidthPolicy}" Spacing="0">
<!-- <Border Name="TitleBar" BorderWidth="1" Foreground="White" Width="{./WidthPolicy}" Height="Fit"
Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9">-->
<HorizontalStack Background="vgradient|0:0.4,0.6,0.0,0.5|1:0.0,0.8,0.8,0.9"
--- /dev/null
+<?xml version="1.0"?>
+<VerticalStack
+ Height="Fit" Width="{../WidthPolicy}" Name="List"/>
\ No newline at end of file
Instantiator i = new Instantiator(fi.FullName);
lock (CrowInterface.UpdateMutex) {
(CrowInterface.FindByName ("crowContainer") as Container).SetChild
- (i.CreateInstance());
+ (i.CreateInstance(CrowInterface));
CurSources = i.GetImlSourcesCode();
}
}
}
lock (CrowInterface.UpdateMutex) {
(CrowInterface.FindByName ("crowContainer") as Container).SetChild
- (i.CreateInstance());
+ (i.CreateInstance(CrowInterface));
}
}
void onButClick(object send, MouseButtonEventArgs e)
<?xml version="1.0"?>
-<Group Background="SeaGreen" Fit="true" Margin="1">
-<Border Foreground="White" Margin="10" Width="Fit" Height="Fit" Background="DarkRed" BorderWidth="1">
+<CheckBox/>
+<!--<Group Background="SeaGreen" Fit="true" Margin="1">
+<Border Foreground="White" Margin="2" CornerRadius="20" Width="Fit" Height="Fit" Background="DarkRed" BorderWidth="1">
<TextBox Multiline="true" Font="mono, 12" Margin="0"
Text="this is a test of double click\n and here a second line of text\n and again a third one"/>
</Border>
-</Group>
\ No newline at end of file
+</Group>-->
\ No newline at end of file
public static class CompilerServices
{
static MethodInfo miAddBinding = typeof(GraphicObject).GetMethod ("BindMember");
+ static FieldInfo miSetCurIface = typeof(GraphicObject).
+ GetField ("CurrentInterface", BindingFlags.NonPublic | BindingFlags.Instance);
-
+ public static void emitSetCurInterface(ILGenerator il){
+ il.Emit (OpCodes.Ldloc_0);
+ il.Emit (OpCodes.Ldarg_1);
+ il.Emit (OpCodes.Stfld, miSetCurIface);
+ }
public static void emitBindingCreation(ILGenerator il, string memberName, string expression){
il.Emit (OpCodes.Ldloc_0);
il.Emit (OpCodes.Ldstr, memberName);
gr.Save ();
if (ClipToClientRect) {
//clip to client zone
- CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+ CairoHelpers.CairoRectangle (gr, ClientRectangle,Math.Max(0.0, CornerRadius-Margin));
gr.Clip ();
}
public FileDialog ()
{
currentDir = new DirectoryInfo (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
- window = Interface.Load("#Crow.Templates.FileDialog.goml") as Window;
+ //window = Interface..Load("#Crow.Templates.FileDialog.goml") as Window;
window.DataSource = this;
}
#endregion
//if no layouting remains in queue for item, registre for redraw
if (RegisteredLayoutings == LayoutingType.None && bmp == null)
- Interface.CurrentInterface.EnqueueForRepaint (this);
+ CurrentInterface.EnqueueForRepaint (this);
return true;
}
uid = currentUid;
currentUid++;
- if (Interface.CurrentInterface.XmlLoading)
- return;
- loadDefaultValues ();
+// if (CurrentInterface.XmlLoading)
+// return;
+// loadDefaultValues ();
}
public GraphicObject (Rectangle _bounds)
{
- if (!Interface.CurrentInterface.XmlLoading)
- loadDefaultValues ();
+// if (!CurrentInterface.XmlLoading)
+// loadDefaultValues ();
Left = _bounds.Left;
Top = _bounds.Top;
isVisible = value;
- if (Interface.CurrentInterface == null)
- return;
-
//ensure main win doesn't keep hidden childrens ref
- if (!isVisible && this.Contains (Interface.CurrentInterface.HoverWidget))
- Interface.CurrentInterface.HoverWidget = null;
+ if (!isVisible && this.Contains (CurrentInterface.HoverWidget))
+ CurrentInterface.HoverWidget = null;
if (Parent is GraphicObject)
(Parent as GraphicObject).RegisterForLayouting (LayoutingType.Sizing);
if (isVisible)
RegisterForLayouting (LayoutingType.Sizing);
- Interface.CurrentInterface.EnqueueForRepaint (this);
+ CurrentInterface.EnqueueForRepaint (this);
NotifyValueChanged ("Visible", isVisible);
}
if (Width == Measure.Fit || Height == Measure.Fit)
RegisterForLayouting (LayoutingType.Sizing);
else if (RegisteredLayoutings == LayoutingType.None)
- Interface.CurrentInterface.EnqueueForRepaint (this);
+ CurrentInterface.EnqueueForRepaint (this);
}
/// <summary> query an update of the content, a redraw </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
{
bmp = null;
if (RegisteredLayoutings == LayoutingType.None)
- Interface.CurrentInterface.EnqueueForRepaint (this);
- }
- // public Interface CurrentInterface {
- // get {
- // ILayoutable tmp = this.Parent;
- // while (tmp != null) {
- // if (tmp is Interface)
- // return tmp as Interface;
- // tmp = tmp.Parent;
- // }
- // return null;
- // }
- // }
+ CurrentInterface.EnqueueForRepaint (this);
+ }
+ internal Interface CurrentInterface = null;
#endregion
#region Layouting
public virtual void RegisterForLayouting(LayoutingType layoutType){
if (Parent == null)
return;
- lock (Interface.CurrentInterface.LayoutMutex) {
+ lock (CurrentInterface.LayoutMutex) {
//dont set position for stretched item
if (Width == Measure.Stretched)
layoutType &= (~LayoutingType.X);
//enqueue LQI LayoutingTypes separately
if (layoutType.HasFlag (LayoutingType.Width))
- Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
+ CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
if (layoutType.HasFlag (LayoutingType.Height))
- Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
+ CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
if (layoutType.HasFlag (LayoutingType.X))
- Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
+ CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
if (layoutType.HasFlag (LayoutingType.Y))
- Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
+ CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
if (layoutType.HasFlag (LayoutingType.ArrangeChildren))
- Interface.CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
+ CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
}
}
//if no layouting remains in queue for item, registre for redraw
if (this.registeredLayoutings == LayoutingType.None && bmp == null)
- Interface.CurrentInterface.EnqueueForRepaint (this);
+ CurrentInterface.EnqueueForRepaint (this);
return true;
}
}
public virtual void checkHoverWidget(MouseMoveEventArgs e)
{
- if (Interface.CurrentInterface.HoverWidget != this) {
- Interface.CurrentInterface.HoverWidget = this;
+ if (CurrentInterface.HoverWidget != this) {
+ CurrentInterface.HoverWidget = this;
onMouseEnter (this, e);
}
MouseMove.Raise (sender, e);
}
public virtual void onMouseDown(object sender, MouseButtonEventArgs e){
- if (Interface.CurrentInterface.activeWidget == null)
- Interface.CurrentInterface.activeWidget = this;
+ if (CurrentInterface.activeWidget == null)
+ CurrentInterface.activeWidget = this;
if (this.Focusable && !Interface.FocusOnHover) {
BubblingMouseButtonEventArg be = e as BubblingMouseButtonEventArg;
if (be.Focused == null) {
be.Focused = this;
- Interface.CurrentInterface.FocusedWidget = this;
+ CurrentInterface.FocusedWidget = this;
}
}
//bubble event to the top
{
Type type = this.GetType ();
GraphicObject result = (GraphicObject)Activator.CreateInstance (type);
+ result.CurrentInterface = CurrentInterface;
foreach (PropertyInfo pi in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
if (pi.GetSetMethod () == null)
//if no layouting remains in queue for item, registre for redraw
if (RegisteredLayoutings == LayoutingType.None && bmp == null)
- Interface.CurrentInterface.EnqueueForRepaint (this);
+ CurrentInterface.EnqueueForRepaint (this);
return true;
}
#region Mouse handling
public override void checkHoverWidget (MouseMoveEventArgs e)
{
- if (Interface.CurrentInterface.HoverWidget != this) {
- Interface.CurrentInterface.HoverWidget = this;
+ if (CurrentInterface.HoverWidget != this) {
+ CurrentInterface.HoverWidget = this;
onMouseEnter (this, e);
}
for (int i = Children.Count - 1; i >= 0; i--) {
{
base.onMouseEnter (sender, e);
if (Selectable)
- Interface.CurrentInterface.MouseCursor = XCursor.Text;
+ CurrentInterface.MouseCursor = XCursor.Text;
}
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
base.onMouseLeave (sender, e);
- Interface.CurrentInterface.MouseCursor = XCursor.Default;
+ CurrentInterface.MouseCursor = XCursor.Default;
}
public override void onFocused (object sender, EventArgs e)
{
NotifyValueChanged ("Data", data);
- lock (Interface.CurrentInterface.UpdateMutex)
+ lock (CurrentInterface.UpdateMutex)
_list.ClearChildren ();
if (_gsList.Orientation == Orientation.Horizontal)
_gsList.Width = -1;
//g.LogicalParent = this;
}
- lock (Interface.CurrentInterface.LayoutMutex)
+ lock (CurrentInterface.LayoutMutex)
_list.AddChild (page);
#if DEBUG_LOAD
else
iTemp = ItemTemplates ["default"];
- lock (Interface.CurrentInterface.LayoutMutex) {
- g = iTemp.CreateInstance();
+ lock (CurrentInterface.LayoutMutex) {
+ g = iTemp.CreateInstance(CurrentInterface);
page.AddChild (g);
g.DataSource = data [i];
}
//ensure popped window is cleared
if (Content != null) {
if (Content.Parent != null)
- Interface.CurrentInterface.DeleteWidget (Content);
+ CurrentInterface.DeleteWidget (Content);
}
base.ClearBinding ();
}
public virtual void onPop(object sender, EventArgs e)
{
- if (Interface.CurrentInterface == null)
- return;
if (Content != null) {
Content.Visible = true;
if (Content.Parent == null)
- Interface.CurrentInterface.AddWidget (Content);
- Interface.CurrentInterface.PutOnTop (Content);
+ CurrentInterface.AddWidget (Content);
+ CurrentInterface.PutOnTop (Content);
_content_LayoutChanged (this, new LayoutingEventArgs (LayoutingType.Sizing));
}
Pop.Raise (this, e);
}
public virtual void onUnpop(object sender, EventArgs e)
{
- if (Interface.CurrentInterface == null)
- return;
if (Content != null)
Content.Visible = false;
Unpop.Raise (this, e);
{
base.onMouseEnter (sender, e);
if ((Parent as GenericStack).Orientation == Orientation.Horizontal)
- Interface.CurrentInterface.MouseCursor = XCursor.H;
+ CurrentInterface.MouseCursor = XCursor.H;
else
- Interface.CurrentInterface.MouseCursor = XCursor.V;
+ CurrentInterface.MouseCursor = XCursor.V;
}
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
base.onMouseLeave (sender, e);
- Interface.CurrentInterface.MouseCursor = XCursor.Default;
+ CurrentInterface.MouseCursor = XCursor.Default;
}
public override void onMouseMove (object sender, MouseMoveEventArgs e)
{
//if no layouting remains in queue for item, registre for redraw
if (RegisteredLayoutings == LayoutingType.None && bmp == null)
- Interface.CurrentInterface.EnqueueForRepaint (this);
+ CurrentInterface.EnqueueForRepaint (this);
return true;
}
#region Mouse handling
public override void checkHoverWidget (MouseMoveEventArgs e)
{
- if (Interface.CurrentInterface.HoverWidget != this) {
- Interface.CurrentInterface.HoverWidget = this;
+ if (CurrentInterface.HoverWidget != this) {
+ CurrentInterface.HoverWidget = this;
onMouseEnter (this, e);
}
#region CTOR
public TemplatedControl () : base()
{
- if (Interface.CurrentInterface.XmlLoading)
- return;
- loadTemplate ();
+// if (CurrentInterface.XmlLoading)
+// return;
+ //loadTemplate ();
}
#endregion
if (string.IsNullOrEmpty(_template))
loadTemplate ();
else
- loadTemplate (Interface.Load (_template));
+ loadTemplate (CurrentInterface.Load (_template));
}
}
[XmlAttributeAttribute][DefaultValue("#Crow.Templates.ItemTemplate.goml")]
if (template == null) {
if (!Interface.DefaultTemplates.ContainsKey (this.GetType ().FullName))
throw new Exception (string.Format ("No default template found for '{0}'", this.GetType ().FullName));
- this.SetChild (Interface.Load (Interface.DefaultTemplates[this.GetType ().FullName]));
+ this.SetChild (CurrentInterface.Load (Interface.DefaultTemplates[this.GetType ().FullName]));
}else
this.SetChild (template);
}
}
} else
- loadTemplate (Interface.Load (template));
+ loadTemplate (CurrentInterface.Load (template));
//if no template found, load default one
if (this.child == null)
if (!MoveRight ())
return;
}else if (e.Shift)
- Interface.CurrentInterface.Clipboard = this.SelectedText;
+ CurrentInterface.Clipboard = this.SelectedText;
this.DeleteChar ();
break;
case Key.Enter:
break;
case Key.Insert:
if (e.Shift)
- this.Insert (Interface.CurrentInterface.Clipboard);
+ this.Insert (CurrentInterface.Clipboard);
else if (e.Control && !selectionIsEmpty)
- Interface.CurrentInterface.Clipboard = this.SelectedText;
+ CurrentInterface.Clipboard = this.SelectedText;
break;
case Key.Left:
if (e.Shift) {
{
base.onMouseMove (sender, e);
- Interface otkgw = Interface.CurrentInterface;
+ Interface otkgw = CurrentInterface;
if (!hoverBorder) {
currentDirection = Direction.None;
- Interface.CurrentInterface.MouseCursor = XCursor.Default;
+ CurrentInterface.MouseCursor = XCursor.Default;
return;
}
{
hoverBorder = false;
currentDirection = Direction.None;
- Interface.CurrentInterface.MouseCursor = XCursor.Default;
+ CurrentInterface.MouseCursor = XCursor.Default;
}
protected void onBorderMouseEnter (object sender, MouseMoveEventArgs e)
{
}
protected void butQuitPress (object sender, MouseButtonEventArgs e)
{
- Interface.CurrentInterface.MouseCursor = XCursor.Default;
+ CurrentInterface.MouseCursor = XCursor.Default;
close ();
}
void close(){
Closing.Raise (this, null);
- Interface.CurrentInterface.DeleteWidget (this);
+ CurrentInterface.DeleteWidget (this);
}
}
}
//if no layouting remains in queue for item, registre for redraw
if (RegisteredLayoutings == LayoutingType.None && bmp == null)
- Interface.CurrentInterface.EnqueueForRepaint (this);
+ CurrentInterface.EnqueueForRepaint (this);
return true;
}
{
public class IMLReader : XmlTextReader
{
- Interface.LoaderInvoker loader = null;
+ InstanciatorInvoker loader = null;
string ImlPath;
Stream ImlStream;
/// <summary>
/// Finalize instatiator MSIL and return LoaderInvoker delegate
/// </summary>
- public Interface.LoaderInvoker GetLoader(){
+ public InstanciatorInvoker GetLoader(){
if (loader != null)
return loader;
il.Emit(OpCodes.Ret);
- loader = (Interface.LoaderInvoker)dm.CreateDelegate (typeof(Interface.LoaderInvoker));
+ loader = (InstanciatorInvoker)dm.CreateDelegate (typeof(InstanciatorInvoker));
return loader;
}
dm = new DynamicMethod("dyn_instantiator",
MethodAttributes.Family | MethodAttributes.FamANDAssem | MethodAttributes.NewSlot,
CallingConventions.Standard,
- typeof(void),new Type[] {typeof(object)}, RootType, true);
+ typeof(void),new Type[] {typeof(object), typeof(Interface)}, RootType, true);
il = dm.GetILGenerator(256);
il.DeclareLocal(typeof(GraphicObject));
//set local GraphicObject to root object passed as 1st argument
il.Emit (OpCodes.Ldarg_0);
il.Emit (OpCodes.Stloc_0);
+ CompilerServices.emitSetCurInterface (il);
}
void emitLoader(Type crowType){
string tmpXml = ReadOuterXml ();
if (string.IsNullOrEmpty (templatePath)) {
reader.il.Emit (OpCodes.Ldnull);//default template loading
}else{
+ reader.il.Emit (OpCodes.Ldarg_1);//load currentInterface
reader.il.Emit (OpCodes.Ldstr, templatePath); //Load template path string
reader.il.Emit (OpCodes.Callvirt,//call Interface.Load(path)
- typeof(Interface).GetMethod ("Load", BindingFlags.Static | BindingFlags.Public));
+ typeof(Interface).GetMethod ("Load", BindingFlags.Instance | BindingFlags.Public));
}
reader.il.Emit (OpCodes.Callvirt,//load template
crowType.GetMethod ("loadTemplate", BindingFlags.Instance | BindingFlags.NonPublic));
reader.il.Emit(OpCodes.Newobj, t.GetConstructors () [0]);//TODO:search parameterless ctor
reader.il.Emit (OpCodes.Stloc_0);//child is now loc_0
+ CompilerServices.emitSetCurInterface (il);
reader.emitLoader(t);
namespace Crow
{
+ public delegate void InstanciatorInvoker(object instance, Interface iface);
+
public class Instantiator
{
public Type RootType;
- Interface.LoaderInvoker loader;
+ InstanciatorInvoker loader;
string imlPath;
loadingTime.ElapsedTicks, loadingTime.ElapsedMilliseconds, imlPath);
#endif
}
- public Instantiator (Type _root, Interface.LoaderInvoker _loader)
+ public Instantiator (Type _root, InstanciatorInvoker _loader)
{
RootType = _root;
loader = _loader;
}
#endregion
- public GraphicObject CreateInstance(){
+ public GraphicObject CreateInstance(Interface iface){
GraphicObject tmp = (GraphicObject)Activator.CreateInstance(RootType);
- loader (tmp);
+ loader (tmp, iface);
return tmp;
}
public string GetImlSourcesCode(){
FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb;
}
public Interface(){
- Interface.CurrentInterface = this;
CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
}
#endregion
xs.Serialize (s, graphicObject, xn);
}
}
- public static GraphicObject Load (string path)
+ public GraphicObject Load (string path)
{
try {
- return GetInstantiator (path).CreateInstance ();
+ return GetInstantiator (path).CreateInstance (this);
} catch (Exception ex) {
throw new Exception ("Error loading <" + path + ">:", ex);
}
public GraphicObject LoadInterface (string path)
{
lock (UpdateMutex) {
- GraphicObject tmp = Interface.Load (path);
+ GraphicObject tmp = Load (path);
AddWidget (tmp);
return tmp;
public List<GraphicObject> GraphicTree = new List<GraphicObject>();
- public static Interface CurrentInterface;
-
Rectangles _redrawClip = new Rectangles();
Context ctx;
public void Update(){
- CurrentInterface = this;
-
if (mouseRepeatCount > 0) {
int mc = mouseRepeatCount;
mouseRepeatCount -= mc;
#if MEASURE_TIME
clippingTime.Restart ();
#endif
- lock (CurrentInterface.DrawingQueue) {
- while (CurrentInterface.DrawingQueue.Count > 0) {
- GraphicObject g = CurrentInterface.DrawingQueue.Dequeue ();
+ lock (DrawingQueue) {
+ while (DrawingQueue.Count > 0) {
+ GraphicObject g = DrawingQueue.Dequeue ();
g.IsQueueForRedraw = false;
try {
if (g.Parent == null)
#if DEBUG_CLIP_RECTANGLE
clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5));
#endif
- lock (Interface.CurrentInterface.RenderMutex) {
+ lock (RenderMutex) {
if (IsDirty)
DirtyRect += clipping.Bounds;
else
public ItemTemplate(string path)
: base(path) {
}
- public ItemTemplate (Type _root, Interface.LoaderInvoker _loader,string _dataType, string _fetchDataMethod)
+ public ItemTemplate (Type _root, InstanciatorInvoker _loader,string _dataType, string _fetchDataMethod)
:base(_root, _loader)
{
strDataType = _dataType;
if (LayoutingTries < Interface.MaxLayoutingTries) {
LayoutingTries++;
Layoutable.RegisteredLayoutings |= LayoutType;
- Interface.CurrentInterface.LayoutingQueue.Enqueue (this);
+ (Layoutable as GraphicObject).CurrentInterface.LayoutingQueue.Enqueue (this);
} else if (DiscardCount < Interface.MaxDiscardCount) {
LayoutingTries = 0;
DiscardCount++;
Layoutable.RegisteredLayoutings |= LayoutType;
- Interface.CurrentInterface.DiscardQueue.Enqueue (this);
+ (Layoutable as GraphicObject).CurrentInterface.DiscardQueue.Enqueue (this);
}
#if DEBUG_LAYOUTING
else