]> O.S.I.I.S - jp/crow.git/commitdiff
get iface through parenting to prevent queuing out of tree widgets
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 21 Mar 2018 23:47:55 +0000 (00:47 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 21 Mar 2018 23:47:55 +0000 (00:47 +0100)
24 files changed:
CrowIDE/src/Editors/ImlVisualEditor.cs
CrowIDE/src/GraphicObjectDesignContainer.cs
CrowIDE/ui/editors/IMLEdit.itemp
Tests/BasicTests.cs
Tests/Interfaces/Divers/welcome.crow
src/BmpPicture.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/ILayoutable.cs
src/GraphicObjects/IMLContainer.cs
src/GraphicObjects/Image.cs
src/GraphicObjects/MessageBox.cs
src/GraphicObjects/Popper.cs
src/GraphicObjects/ProgressBar.cs
src/GraphicObjects/Slider.cs
src/GraphicObjects/TabItem.cs
src/GraphicObjects/TemplatedContainer.cs
src/GraphicObjects/TemplatedControl.cs
src/GraphicObjects/TemplatedGroup.cs
src/GraphicObjects/Window.cs
src/IML/IMLContext.cs
src/Instantiator.cs
src/Interface.cs
src/Picture.cs
src/SvgPicture.cs

index 11f94c173cfbf0472625e69a2e1f4856898cef98..3c5ecc671e2878fa3159b1d07c866ca252cc2576 100644 (file)
@@ -72,8 +72,8 @@ namespace Crow.Coding
                }
 
                void initIcons () {
-                       icoMove = new SvgPicture ();
-                       icoMove.Load (IFace, "#Crow.Coding.icons.move-arrows.svg");
+                       icoMove = new SvgPicture ("#Crow.Coding.icons.move-arrows.svg");
+                       icoMove.Load (IFace);
 //                     icoStyle = new SvgPicture ();
 //                     icoStyle.Load (IFace, "#Crow.Coding.icons.palette.svg");
                }
index 4540898baf3518063cc109ef074c793bc4cc4e26..e2e1ac8d032c6718e62f7dc9aed4d7e2598d5047 100644 (file)
@@ -53,8 +53,8 @@ namespace Crow.Coding
                        lock (go.IFace.UpdateMutex) {                           
                                go.IFace.DragImageHeight = dragIconSize;
                                go.IFace.DragImageWidth = dragIconSize;
-                               SvgPicture pic = new SvgPicture ();
-                               pic.Load (go.IFace, IconPath);
+                               SvgPicture pic = new SvgPicture (IconPath);
+                               pic.Load (go.IFace);
                                ImageSurface img = new ImageSurface (Format.Argb32, dragIconSize, dragIconSize);
                                using (Context ctx = new Context (img)) {
                                        Rectangle r = new Rectangle (0, 0, dragIconSize, dragIconSize);
index 84f391cfce1a1613c0cb87f5edfee314a6ac8f83..6ea1391f76549a4e1c5e3aeac3ce6ec17e7b0fac 100644 (file)
@@ -44,9 +44,5 @@
                </VerticalStack>
                <Splitter/>
                <IMLContainer Path="#Crow.Coding.ui.SourceEditor.crow"/>
-<!--           <Label DataSource="{../editor.Error}" Text="{}"
-                       Visible="{../editor.HasError}"
-                       Height="Fit" Width="Stretched" Background="DarkRed" Foreground="White"
-                       TextAlignment="TopLeft" Multiline="true"/>-->
        </VerticalStack>
 </TabItem>
index af624ee500fe2b33510981251e1e1cfd68aea5a0..6883360d90a07941006d3fe74bcc299330e58c38 100644 (file)
@@ -194,8 +194,10 @@ namespace Tests
                        this.KeyDown += KeyboardKeyDown1;
 
                        //testFiles = new string [] { @"Interfaces/Experimental/testDock.crow" };
-                       testFiles = new string [] { @"Interfaces/Divers/welcome.crow" };
+                       //testFiles = new string [] { @"Interfaces/Divers/welcome.crow" };
                        //testFiles = new string [] { @"Interfaces/Divers/0.crow" };
+                       //testFiles = new string [] { @"Interfaces/Divers/testIMLContainer.crow" };
+                       testFiles = new string [] { @"Interfaces/TemplatedContainer/testTabView.crow" };
                        //testFiles = new string [] { @"Interfaces/TemplatedContainer/testTreeView.crow" };
                        //testFiles = new string [] { @"Interfaces/Divers/colorPicker.crow" };
 //                     testFiles = new string[] { @"Interfaces/TemplatedControl/testItemTemplateTag.crow" };
index b65a4553ab071ef2540ec5d7a7a768d26049230e..8db6dc655fc390a71091d1e5228ded44ece4af00 100644 (file)
@@ -4,4 +4,6 @@
        <Slider Orientation="Vertical" Height="Stretched" Width="20" Background="DimGray"/>
        <Label Name="ShowTarget" Background="DarkBlue"/>
 </VerticalStack>-->
-<Slider Orientation="Horizontal" Height="10" Width="100" Background="DimGray"/>
\ No newline at end of file
+<Popper >
+       <Label/>
+</Popper>
\ No newline at end of file
index 42ab2a0861cbf7d7440081d65185951c87b2f6cb..d132ba89a13cb7a54e44a9036b7cfd975df75bea 100644 (file)
@@ -55,18 +55,21 @@ namespace Crow
                /// load the image for rendering from the path given as argument
                /// </summary>
                /// <param name="path">image path, may be embedded</param>
-               public override void Load (Interface iface, string path)
+               public override void Load (Interface iface)
                {
-                       Path = path;
-                       if (sharedResources.ContainsKey (path)) {
-                               sharedPicture sp = sharedResources [path];
+                       Loaded = false;
+                       if (iface == null)
+                               return;
+                       
+                       if (sharedResources.ContainsKey (Path)) {
+                               sharedPicture sp = sharedResources [Path];
                                image = (byte[])sp.Data;
                                Dimensions = sp.Dims;
                        } else {
-                               using (Stream stream = iface.GetStreamFromPath (path)) {                                
+                               using (Stream stream = iface.GetStreamFromPath (Path)) {                                
                                        loadBitmap (new System.Drawing.Bitmap (stream));        
                                }
-                               sharedResources [path] = new sharedPicture (image, Dimensions);
+                               sharedResources [Path] = new sharedPicture (image, Dimensions);
                        }
                        Loaded = true;
                }
index d1ae13c9d633afe4ed5f431c943cc8212d8dfdfb..60f1bf066ed9d206ab92b02ecfaadae75b37be2a 100644 (file)
@@ -171,24 +171,24 @@ namespace Crow
                                throw new Exception("Trying to dispose an object queued for Redraw: " + this.ToString());
                                #endif
 
-                               if (IFace.HoverWidget != null) {
-                                       if (IFace.HoverWidget.IsOrIsInside(this))
-                                               IFace.HoverWidget = null;
-                               }
-                               if (IFace.ActiveWidget != null) {
-                                       if (IFace.ActiveWidget.IsOrIsInside (this))
-                                               IFace.ActiveWidget = null;
-                               }
-                               if (IFace.FocusedWidget != null) {
-                                       if (IFace.FocusedWidget.IsOrIsInside (this))
-                                               IFace.FocusedWidget = null;
-                               }
-                               if (!localDataSourceIsNull)
-                                       DataSource = null;
-
-                               parentRWLock.EnterWriteLock();
-                               parent = null;
-                               parentRWLock.ExitWriteLock();
+//                             if (IFace.HoverWidget != null) {
+//                                     if (IFace.HoverWidget.IsOrIsInside(this))
+//                                             IFace.HoverWidget = null;
+//                             }
+//                             if (IFace.ActiveWidget != null) {
+//                                     if (IFace.ActiveWidget.IsOrIsInside (this))
+//                                             IFace.ActiveWidget = null;
+//                             }
+//                             if (IFace.FocusedWidget != null) {
+//                                     if (IFace.FocusedWidget.IsOrIsInside (this))
+//                                             IFace.FocusedWidget = null;
+//                             }
+//                             if (!localDataSourceIsNull)
+//                                     DataSource = null;
+
+                               //parentRWLock.EnterWriteLock();
+                               Parent = null;
+                               //parentRWLock.ExitWriteLock();
                        } else
                                Debug.WriteLine ("!!! Finalized by GC: {0}", this.ToString ());
                        Clipping?.Dispose ();
@@ -208,8 +208,7 @@ namespace Crow
                /// <summary>
                /// interface this widget is bound to, this should not be changed once the instance is created
                /// </summary>
-               public Interface IFace = null;
-
+               public Interface IFace { get { return parent?.IFace; }}
                /// <summary>
                /// contains the dirty rectangles in the coordinate system of the cache. those dirty zones
                /// are repeated at each cached levels of the tree with correspondig coordinate system. This is done
@@ -260,16 +259,16 @@ namespace Crow
                /// <param name="iface">Iface.</param>
                public GraphicObject (Interface iface) : this()
                {
-                       IFace = iface;
-                       Initialize ();
+                       //IFace = iface;
+                       Initialize (iface);
                }
                #endregion
                //internal bool initialized = false;
                /// <summary>
                /// Initialize this Graphic object instance by setting style and default values and loading template if required
                /// </summary>
-               public virtual void Initialize(){
-                       loadDefaultValues ();
+               public virtual void Initialize(Interface iFace){
+                       loadDefaultValues (iFace);
                        //initialized = true;
                }
                #region private fields
@@ -1030,7 +1029,7 @@ namespace Crow
 
                #region Default and Style Values loading
                /// <summary> Loads the default values from XML attributes default </summary>
-               public void loadDefaultValues()
+               public void loadDefaultValues(Interface iFace)
                {
 //                     #if DEBUG_LOAD
 //                     Debug.WriteLine ("LoadDefValues for " + this.ToString ());
@@ -1039,17 +1038,17 @@ namespace Crow
                        Type thisType = this.GetType ();
 
                        if (!string.IsNullOrEmpty (Style)) {
-                               if (IFace.DefaultValuesLoader.ContainsKey (Style)) {
-                                       IFace.DefaultValuesLoader [Style] (this);
+                               if (iFace.DefaultValuesLoader.ContainsKey (Style)) {
+                                       iFace.DefaultValuesLoader [Style] (this);
                                        onInitialized (this, null);
                                        return;
                                }
-                       } else if (IFace.DefaultValuesLoader.ContainsKey (thisType.FullName)) {
-                               IFace.DefaultValuesLoader [thisType.FullName] (this);
+                       } else if (iFace.DefaultValuesLoader.ContainsKey (thisType.FullName)) {
+                               iFace.DefaultValuesLoader [thisType.FullName] (this);
                                onInitialized (this, null);
                                return;
-                       } else  if (IFace.DefaultValuesLoader.ContainsKey (thisType.Name)) {
-                               IFace.DefaultValuesLoader [thisType.Name] (this);
+                       } else  if (iFace.DefaultValuesLoader.ContainsKey (thisType.Name)) {
+                               iFace.DefaultValuesLoader [thisType.Name] (this);
                                onInitialized (this, null);
                                return;
                        }
@@ -1063,17 +1062,17 @@ namespace Crow
                        //   those files being placed in a Styles folder
                        string styleKey = Style;
                        if (!string.IsNullOrEmpty (Style)) {
-                               if (IFace.Styling.ContainsKey (Style)) {
-                                       styling.Add (IFace.Styling [Style]);
+                               if (iFace.Styling.ContainsKey (Style)) {
+                                       styling.Add (iFace.Styling [Style]);
                                }
                        }
-                       if (IFace.Styling.ContainsKey (thisType.FullName)) {
-                               styling.Add (IFace.Styling [thisType.FullName]);
+                       if (iFace.Styling.ContainsKey (thisType.FullName)) {
+                               styling.Add (iFace.Styling [thisType.FullName]);
                                if (string.IsNullOrEmpty (styleKey))
                                        styleKey = thisType.FullName;
                        }
-                       if (IFace.Styling.ContainsKey (thisType.Name)) {
-                               styling.Add (IFace.Styling [thisType.Name]);
+                       if (iFace.Styling.ContainsKey (thisType.Name)) {
+                               styling.Add (iFace.Styling [thisType.Name]);
                                if (string.IsNullOrEmpty (styleKey))
                                        styleKey = thisType.Name;
                        }
@@ -1193,8 +1192,8 @@ namespace Crow
                        #endregion
 
                        try {
-                               IFace.DefaultValuesLoader[styleKey] = (Interface.LoaderInvoker)dm.CreateDelegate(typeof(Interface.LoaderInvoker));
-                               IFace.DefaultValuesLoader[styleKey] (this);
+                               iFace.DefaultValuesLoader[styleKey] = (Interface.LoaderInvoker)dm.CreateDelegate(typeof(Interface.LoaderInvoker));
+                               iFace.DefaultValuesLoader[styleKey] (this);
                        } catch (Exception ex) {
                                throw new Exception ("Error applying style <" + styleKey + ">:", ex);
                        }
@@ -1385,12 +1384,15 @@ namespace Crow
                        IsDirty = true;
                        EnqueueForRepaint ();
                }
-               protected void EnqueueForRepaint (){
+               protected virtual void EnqueueForRepaint (){
                        //if no layouting remains in queue for item, registre for redraw
                        if (requestedLayoutings != LayoutingType.None)
                                RegisterForLayouting ();
-                       else if (RegisteredLayoutings == LayoutingType.None && IsDirty)
-                               IFace.EnqueueForRepaint (this);                 
+                       else if (RegisteredLayoutings == LayoutingType.None && IsDirty) {
+                               Interface iface = IFace;
+                               if (iface != null)
+                                       IFace.EnqueueForRepaint (this);
+                       }
                }
                #endregion
 
@@ -1405,11 +1407,11 @@ namespace Crow
                public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){
                }
                public virtual bool ArrangeChildren { get { return false; } }
+
                public virtual void RegisterForLayouting(LayoutingType layoutType = LayoutingType.None){
-                       if (Parent == null || !Monitor.TryEnter(IFace.LayoutMutex)) {
+                       Interface iface = IFace;
+                       if (iface == null || !Monitor.TryEnter(IFace.LayoutMutex)) {
                                requestedLayoutings |= layoutType;
-//                             if (registeredLayoutings != LayoutingType.None)
-//                                     Debugger.Break ();
                                return;
                        }
                        layoutType |= requestedLayoutings;
@@ -1433,9 +1435,6 @@ namespace Crow
                        if (Parent is GraphicObject)
                                (Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType);
 
-//                             //prevent queueing same LayoutingType for this
-//                             layoutType &= (~RegisteredLayoutings);
-
                        if (layoutType == LayoutingType.None) {
                                Monitor.Exit (IFace.LayoutMutex);
                                return;
@@ -1443,15 +1442,15 @@ namespace Crow
 
                        //enqueue LQI LayoutingTypes separately
                        if (layoutType.HasFlag (LayoutingType.Width))
-                               IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
+                               iface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
                        if (layoutType.HasFlag (LayoutingType.Height))
-                               IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
+                               iface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
                        if (layoutType.HasFlag (LayoutingType.X))
-                               IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
+                               iface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
                        if (layoutType.HasFlag (LayoutingType.Y))
-                               IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
+                               iface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
                        if (layoutType.HasFlag (LayoutingType.ArrangeChildren))
-                               IFace.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
+                               iface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
                        
                        Monitor.Exit (IFace.LayoutMutex);
                }
index c8aa38fbf1d88730755d2d56d843b79d70f5f00a..138e800dacbd648b55312dedd5c56683d9828db7 100644 (file)
@@ -37,6 +37,8 @@ namespace Crow
                ///  to the parent in the graphic tree </summary>
                ILayoutable LogicalParent { get; set; }
 
+               Interface IFace { get; }
+
                Rectangle ClientRectangle { get; }
                Rectangle getSlot();
 
index 84692284f2ce3d7468f10d76fb0b3dc77bb52b61..f6126b95f14b080b7ade5099ea59ba4d60f8ec6a 100644 (file)
@@ -34,6 +34,7 @@ namespace Crow
                }
 
                string path;
+               bool loaded = true;
 
                public string Path {
                        get { return path; }
@@ -41,10 +42,39 @@ namespace Crow
                                if (path == value)
                                        return;
                                path = value;
-                               this.SetChild (IFace.Load (path));
+
+                               if (path == null)
+                                       this.SetChild (null);
+                               else
+                                       loaded = false;
+                               
                                NotifyValueChanged ("Path", path);
                        }
                }
+               protected override void EnqueueForRepaint ()
+               {
+                       if (!loaded) {
+                               Interface iface = IFace;
+                               if (iface != null) {
+                                       this.SetChild (iface.Load (path));
+                                       loaded = true;
+                                       RegisterForGraphicUpdate ();
+                                       return;
+                               }
+                       }
+                       base.EnqueueForRepaint ();
+               }
+               protected override void SetChild (GraphicObject _child)
+               {
+                       base.SetChild (_child);
+                       if (_child != null) {
+                               if (_child.localDataSourceIsNull) {
+                                       object ds = DataSource;
+                                       if (ds != null)
+                                               OnDataSourceChanged (this, new DataSourceChangeEventArgs (null, ds));
+                               }
+                       }
+               }
        }
 }
 
index faa13ec455d4b12a1528a0e241c9fa7ebde30963..9deb2e389e8bfbc1694e131e8c457f2096cea26c 100644 (file)
@@ -89,19 +89,18 @@ namespace Crow
                        set {
                                if (value == Path)
                                        return;
-                               try {
-                                       if (string.IsNullOrEmpty(value))
-                                               Picture = null;
-                                       else {
-                                               //lock(IFace.LayoutMutex){
-                                                       LoadImage (value);
-                                               //}
-                                       }
-                               } catch (Exception ex) {
-                                       Debug.WriteLine (ex.Message);
+                               if (string.IsNullOrEmpty (value))
                                        _pic = null;
+                               else {
+                                       if (value.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture))
+                                               _pic = new SvgPicture (value);
+                                       else
+                                               _pic = new BmpPicture (value);
+                                       _pic.Scaled = scaled;
+                                       _pic.KeepProportions = keepProps;
                                }
                                NotifyValueChanged ("Path", Path);
+                               RegisterForGraphicUpdate ();
                        }
                }
                /// <summary>
@@ -131,7 +130,7 @@ namespace Crow
                                _pic = value;
                                if (_pic!=null){
                                        if (!_pic.Loaded)
-                                               _pic.Load (IFace, _pic.Path);
+                                               _pic.Load (IFace);
                                        Scaled = _pic.Scaled;
                                        KeepProportions = _pic.KeepProportions;
                                }
@@ -170,29 +169,31 @@ namespace Crow
                }
                #endregion
 
-               #region Image Loading
-               public void LoadImage (string path)
-               {
-                       Picture pic;
-                       if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture))
-                               pic = new SvgPicture (path);
-                       else
-                               pic = new BmpPicture (path);
-
-                       pic.Load (IFace, path);
-                       pic.Scaled = scaled;
-                       pic.KeepProportions = keepProps;
-
-                       Picture = pic;
-               }
-               #endregion
 
                #region GraphicObject overrides
+               protected override void EnqueueForRepaint ()
+               {
+                       if (_pic != null) {
+                               if (!_pic.Loaded) {
+                                       Interface iface = IFace;
+                                       if (iface != null) {
+                                               _pic.Load (iface);
+                                               RegisterForGraphicUpdate ();
+                                       }
+                                       return;
+                               }
+                       }
+                       base.EnqueueForRepaint ();
+               }
                public override int measureRawSize (LayoutingType lt)
                {
                        if (_pic == null)
                                return 2 * Margin;
                                //_pic = "#Crow.Images.Icons.IconAlerte.svg";
+
+                       if (!_pic.Loaded)
+                               _pic.Load (IFace);
+                       
                        //TODO:take scalling in account
                        if (lt == LayoutingType.Width)
                                return _pic.Dimensions.Width + 2 * Margin;
@@ -204,7 +205,7 @@ namespace Crow
                        base.onDraw (gr);
 
                        if (_pic == null)
-                               return;
+                               return;                 
 
                        _pic.Paint (gr, ClientRectangle, _svgSub);
 
index 45ef1e009ce3bf85824663018e2471d6d1db07ca..78c4f90fd4736f3b9cdcc023acd8d30a1e4d9b4e 100644 (file)
@@ -47,9 +47,9 @@ namespace Crow
 
                }
 
-               protected override void loadTemplate (GraphicObject template)
+               protected override void loadTemplate(Interface iFace, GraphicObject template = null)
                {
-                       base.loadTemplate (template);
+                       base.loadTemplate (iFace, template);
                        NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.Informations.svg");
                }
                string message, okMessage, cancelMessage, noMessage;
index 1186e8e727ba1de76a9eb54ede1fca49bef52333..e39b90906a951920fd22c8c49b803aae792372f5 100644 (file)
@@ -232,9 +232,9 @@ namespace Crow
                }
                public virtual void onUnpop(object sender, EventArgs e)
                {
-                       if (Content != null) {
+                       if (Content != null)
                                Content.Visible = false;
-                       }
+                       
                        Unpoped.Raise (this, e);
                }
 
index e8165fd2e19f239400529df671a9164a2615e5d4..dc989b19e150232a860a0c20f511eaabe7e89b36 100644 (file)
@@ -43,10 +43,7 @@ namespace Crow
                public ProgressBar(Interface iface) : base(iface){}
                #endregion
 
-               protected override void loadTemplate (GraphicObject template)
-               {
-                       
-               }
+               protected override void loadTemplate(Interface iFace, GraphicObject template = null){}
 
                #region GraphicObject overrides
                protected override void onDraw (Context gr)
index 2bdd5b8ab0c2c8e5693ea39f30384152e19464e8..43e6e2e6f492a9bdaebc256939b24b57ffef3b3b 100644 (file)
@@ -50,11 +50,7 @@ namespace Crow
 
                #region implemented abstract members of TemplatedControl
 
-               protected override void loadTemplate (GraphicObject template = null)
-               {
-                       
-               }
-
+               protected override void loadTemplate(Interface iFace, GraphicObject template = null){}
                #endregion
 
                #region private fields
index 473fc313e4c11dd59c0fb37313a914e7745ca218..aa7954d55a430a3c31b84dc7ae75d6257638537c 100644 (file)
@@ -66,9 +66,9 @@ namespace Crow
                                        value.LogicalParent = this;
                        }
                }
-               protected override void loadTemplate(GraphicObject template = null)
+               protected override void loadTemplate(Interface iFace, GraphicObject template = null)
                {
-                       base.loadTemplate (template);
+                       base.loadTemplate (iFace, template);
 
                        titleWidget = this.child.FindByName ("TabTitle");
                }
@@ -191,7 +191,7 @@ namespace Crow
                        set {
                                base.Parent = value;
                                if (value != null) {
-                                       dragStartPoint = IFace.Mouse.Position;
+                                       //dragStartPoint = IFace.Mouse.Position;
                                        savedParent = value as TabView;
                                }
                        }
index a779595d9b30d002a28c005940ad68c7aa79f52c..5d18ea5021023e23ef4b24d91d4512720e6fa704 100644 (file)
@@ -73,9 +73,9 @@ namespace Crow
                        get { return _contentContainer?.Child != null; }
                }
                //TODO: move loadTemplate and ResolveBinding in TemplatedContainer
-               protected override void loadTemplate(GraphicObject template = null)
+               protected override void loadTemplate(Interface iFace, GraphicObject template = null)
                {
-                       base.loadTemplate (template);
+                       base.loadTemplate (iFace, template);
                        _contentContainer = this.child.FindByName ("Content") as Container;
                }
 
index 037cae32a45e3832b5e2ea30fda94e4a326127be..08413709af9e0a3ce348a8923792b453541e7707 100644 (file)
@@ -62,7 +62,7 @@ namespace Crow
                public TemplatedControl (Interface iface) : base(iface){}
                #endregion
 
-               string _template;
+               string templatePath;
                string caption;
 
                /// <summary>
@@ -71,16 +71,16 @@ namespace Crow
                //TODO: this property should be renamed 'TemplatePath'
                [XmlAttributeAttribute][DefaultValue(null)]
                public string Template {
-                       get { return _template; }
+                       get { return templatePath; }
                        set {
                                if (Template == value)
                                        return;
-                               _template = value;
+                               templatePath = value;
 
-                               if (string.IsNullOrEmpty(_template))
-                                       loadTemplate ();
-                               else
-                                       loadTemplate (IFace.Load (_template));
+//                             if (string.IsNullOrEmpty(templatePath))
+//                                     loadTemplate ();
+//                             else
+//                                     loadTemplate (IFace.Load (templatePath));
                        }
                }
                /// <summary>
@@ -99,10 +99,10 @@ namespace Crow
 
                #region GraphicObject overrides
 
-               public override void Initialize ()
+               public override void Initialize (Interface iFace)
                {
-                       loadTemplate ();
-                       base.Initialize ();
+                       loadTemplate (iFace);
+                       base.Initialize (iFace);
                }
                /// <summary>
                /// override search method from GraphicObject to prevent
@@ -149,15 +149,15 @@ namespace Crow
                /// Loads the template.
                /// </summary>
                /// <param name="template">Optional template instance</param>
-               protected virtual void loadTemplate(GraphicObject template = null)
+               protected virtual void loadTemplate(Interface iFace, GraphicObject template = null)
                {
                        if (this.child != null)//template change, bindings has to be reset
                                this.ClearTemplateBinding();
                        
                        if (template == null) {
-                               if (!IFace.DefaultTemplates.ContainsKey (this.GetType ().FullName))
+                               if (!iFace.DefaultTemplates.ContainsKey (this.GetType ().FullName))
                                        throw new Exception (string.Format ("No default template found for '{0}'", this.GetType ().FullName));
-                               this.SetChild (IFace.Load (IFace.DefaultTemplates[this.GetType ().FullName]));
+                               this.SetChild (iFace.Load (iFace.DefaultTemplates[this.GetType ().FullName]));
                        }else
                                this.SetChild (template);
                }
index 6067f0ac68204f8886f923dd2aed628d682f4281..afdee4c2e5b75c22bc21d00209aa10ac3d9ae712 100644 (file)
@@ -110,9 +110,9 @@ namespace Crow
                                NotifyValueChanged("ItemTemplate", _itemTemplate);
                        }
                }
-               protected override void loadTemplate(GraphicObject template = null)
+               protected override void loadTemplate(Interface iFace, GraphicObject template = null)
                {
-                       base.loadTemplate (template);
+                       base.loadTemplate (iFace, template);
 
                        items = this.child.FindByName ("ItemsContainer") as Group;
                        if (items == null)
index 56632ff3a8e2fcab5af7c31b4107e1c2d67c5283..fe033cc2168dfc1864622b72f905e4b24ddcad70 100644 (file)
@@ -73,9 +73,9 @@ namespace Crow
                #endregion
 
                #region TemplatedContainer overrides
-               protected override void loadTemplate(GraphicObject template = null)
+               protected override void loadTemplate(Interface iFace, GraphicObject template = null)
                {
-                       base.loadTemplate (template);
+                       base.loadTemplate (iFace, template);
 
                        NotifyValueChanged ("ShowNormal", false);
                        NotifyValueChanged ("ShowMinimize", true);
@@ -433,7 +433,7 @@ namespace Crow
 
                protected void butQuitPress (object sender, MouseButtonEventArgs e)
                {
-                       IFace.MouseCursor = XCursor.Default;
+                       //IFace.MouseCursor = XCursor.Default;
                        close ();
                }
 
index aa4dee2f768f6bdd0b9d9e4590ee715e964fdc0e..9bfd13d0f59ac5fc90bf315824ae3ccebdace849 100644 (file)
@@ -77,7 +77,7 @@ namespace Crow.IML
                                throw new Exception ("No default parameterless constructor found in " + rootType.Name);                 
                        il.Emit (OpCodes.Newobj, ci);
                        il.Emit (OpCodes.Stloc_0);
-                       CompilerServices.emitSetCurInterface (il);
+                       //CompilerServices.emitSetCurInterface (il);
                }
 
                public NodeAddress CurrentNodeAddress {
index 001832b108ca79997f9bb4a970688498657e66ff..388c5d7681c3c4a2346b6a914eb862398f96d5b2 100644 (file)
@@ -314,6 +314,7 @@ namespace Crow.IML
 
                                if (!inlineTemplate) {//load from path or default template
                                        ctx.il.Emit (OpCodes.Ldloc_0);//Load  current templatedControl ref
+                                       ctx.il.Emit (OpCodes.Ldarg_1);//load currentInterface
                                        if (string.IsNullOrEmpty (templatePath)) {
                                                ctx.il.Emit (OpCodes.Ldnull);//default template loading
                                        } else {
@@ -438,6 +439,7 @@ namespace Crow.IML
                                        }
                                }
                                ctx.il.Emit (OpCodes.Ldloc_0);
+                               ctx.il.Emit (OpCodes.Ldarg_1);//load currentInterface
                                ctx.il.Emit (OpCodes.Callvirt, CompilerServices.miLoadDefaultVals);
                                #endregion
 
@@ -519,19 +521,22 @@ namespace Crow.IML
                                                throw new Exception (reader.Name + " type not found");
                                        ConstructorInfo ci = t.GetConstructor (
                                                                     BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public,  
-                                               null, Type.EmptyTypes, null);
+                                                                    null, Type.EmptyTypes, null);
                                        if (ci == null)
                                                throw new Exception ("No default parameterless constructor found in " + t.Name);                                        
                                        ctx.il.Emit (OpCodes.Newobj, ci);
                                        ctx.il.Emit (OpCodes.Stloc_0);//child is now loc_0
-                                       CompilerServices.emitSetCurInterface (ctx.il);
+                                       //CompilerServices.emitSetCurInterface (ctx.il);
 
                                        ctx.nodesStack.Push (new Node (t, nodeIdx));
                                        emitLoader (reader, ctx);
                                        ctx.nodesStack.Pop ();
 
+                                       MethodInfo miAdd = ctx.nodesStack.Peek ().GetAddMethod (nodeIdx);
+                                       if (miAdd == CompilerServices.miLoadTmp)
+                                               ctx.il.Emit (OpCodes.Ldarg_1);//push cur iface if tmp load
                                        ctx.il.Emit (OpCodes.Ldloc_0);//load child on stack for parenting
-                                       ctx.il.Emit (OpCodes.Callvirt, ctx.nodesStack.Peek().GetAddMethod(nodeIdx));
+                                       ctx.il.Emit (OpCodes.Callvirt, miAdd);
                                        ctx.il.Emit (OpCodes.Stloc_0); //reset local to current go
 
                                        nodeIdx++;
index 3b8642886fe8716230d7967bc0b5cbf41bda47c8..66edf3f93317c105674fbcc803f340610d6c4383 100644 (file)
@@ -157,8 +157,8 @@ namespace Crow
                        loadCursors ();
                        loadStyling ();
                        findAvailableTemplates ();
-                       initTooltip ();
-                       initContextMenus ();
+//                     initTooltip ();
+//                     initContextMenus ();
                }
 
                #region Static and constants
@@ -1259,6 +1259,9 @@ namespace Crow
                #endregion
 
                #region ILayoutable implementation
+               /// </summary>
+               public Interface IFace { get { return this; }}
+
                public virtual bool PointIsIn(ref Point m)
                {
                        return true;
index 69ff25748e087e73adef8e2fd61398d889e48cba..0cfe190262b8c90c4228ceefd11aea90a95cd73d 100644 (file)
@@ -98,7 +98,7 @@ namespace Crow
                /// load the image for rendering from the stream given as argument
                /// </summary>
                /// <param name="stream">picture stream</param>
-               public abstract void Load(Interface iface, string path);
+               public abstract void Load(Interface iface);
                #endregion
 
                /// <summary>
index a7362582307480149137f98e0b9a271648520412..253e46d1c4b9174605e4bca1a8f0d84ae75493d3 100644 (file)
@@ -51,23 +51,29 @@ namespace Crow
                {}
                #endregion
 
-               public override void Load (Interface iface, string path)
-               {
-                       Path = path;
-                       if (sharedResources.ContainsKey (path)) {
-                               sharedPicture sp = sharedResources [path];
+               public override void Load (Interface iface)
+               {                       
+                       Loaded = false;
+                       if (iface == null)
+                               return;                 
+                       if (sharedResources.ContainsKey (Path)) {
+                               sharedPicture sp = sharedResources [Path];
                                hSVG = (Rsvg.Handle)sp.Data;
                                Dimensions = sp.Dims;
                        } else {
-                               using (Stream stream = iface.GetStreamFromPath (path)) {
-                                       using (MemoryStream ms = new MemoryStream ()) {
-                                               stream.CopyTo (ms);
-
-                                               hSVG = new Rsvg.Handle (ms.ToArray ());
-                                               Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
+                               try {
+                                       using (Stream stream = iface.GetStreamFromPath (Path)) {
+                                               using (MemoryStream ms = new MemoryStream ()) {
+                                                       stream.CopyTo (ms);
+
+                                                       hSVG = new Rsvg.Handle (ms.ToArray ());
+                                                       Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
+                                               }
                                        }
+                                       sharedResources [Path] = new sharedPicture (hSVG, Dimensions);
+                               } catch (Exception ex) {
+                                       
                                }
-                               sharedResources [path] = new sharedPicture (hSVG, Dimensions);
                        }
                        Loaded = true;
                }