Example #1
0
 protected override int measureRawSize(LayoutingType lt)
 {
     if (Children.Count > 0)
     {
         if (lt == LayoutingType.Width)
         {
             if (largestChild == null)
             {
                 searchLargestChild();
             }
             if (largestChild == null)
             {
                 //if still null, not possible to determine a width
                 //because all children are stretched, force first one to fit
                 Children [0].Width = Measure.Fit;
                 return(-1);                       //cancel actual sizing to let child computation take place
             }
         }
         else
         {
             if (tallestChild == null)
             {
                 searchTallestChild();
             }
             if (tallestChild == null)
             {
                 Children [0].Height = Measure.Fit;
                 return(-1);
             }
         }
     }
     return(base.measureRawSize(lt));
 }
Example #2
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges(layoutType);

            if (layoutType == LayoutingType.Height)
            {
                using (ImageSurface img = new ImageSurface(Format.Argb32, 10, 10)) {
                    using (Context gr = new Context(img)) {
                        //Cairo.FontFace cf = gr.GetContextFontFace ();

                        gr.SelectFontFace(Font.Name, Font.Slant, Font.Wheight);
                        gr.SetFontSize(Font.Size);

                        fe = gr.FontExtents;
                    }
                }

                lineHeight   = fe.Height;
                visibleLines = (int)Math.Floor((double)ClientRectangle.Height / fe.Height);
                System.Diagnostics.Debug.WriteLine("Visible lines: {0})", visibleLines);
                if (Scroll + visibleLines > Datas?.Count)
                {
                    Scroll = Datas.Count - visibleLines;
                }
            }
        }
Example #3
0
        void updateMaxScroll(LayoutingType lt)
        {
            if (Child == null)
            {
                MaxScrollX = 0;
                MaxScrollY = 0;
                return;
            }

            Rectangle cb = ClientRectangle;

            if (lt == LayoutingType.Height)
            {
                MaxScrollY = child.Slot.Height - cb.Height;
                if (child.Slot.Height > 0)
                {
                    NotifyValueChanged("ChildHeightRatio", Slot.Height * Slot.Height / child.Slot.Height);
                }
            }
            else if (lt == LayoutingType.Width)
            {
                MaxScrollX = child.Slot.Width - cb.Width;
                if (child.Slot.Width > 0)
                {
                    NotifyValueChanged("ChildWidthRatio", Slot.Width * Slot.Width / child.Slot.Width);
                }
            }
        }
Example #4
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges (layoutType);

            if (layoutType == LayoutingType.Width)
                MinimumPopupSize = new Size (this.Slot.Width, minimumPopupSize.Height);
        }
Example #5
0
        protected override int measureRawSize(LayoutingType lt)
        {
            int totSpace = 0;

            for (int i = 0; i < Children.Count; i++)
            {
                if (Children [i].Visible)
                {
                    totSpace += Spacing;
                }
            }
            if (totSpace > 0)
            {
                totSpace -= Spacing;
            }
            if (lt == LayoutingType.Width)
            {
                if (Orientation == Orientation.Horizontal)
                {
                    return(contentSize.Width + totSpace + 2 * Margin);
                }
            }
            else if (Orientation == Orientation.Vertical)
            {
                return(contentSize.Height + totSpace + 2 * Margin);
            }

            return(base.measureRawSize(lt));
        }
Example #6
0
        public override bool UpdateLayout(LayoutingType layoutType)
        {
            GenericStack gs = Parent as GenericStack;

            if (layoutType == LayoutingType.Width)
            {
                if (gs.Orientation == Orientation.Horizontal)
                {
                    Width = thickness;
                }
                else
                {
                    Width = Measure.Stretched;
                }
            }
            else if (layoutType == LayoutingType.Height)
            {
                if (gs.Orientation == Orientation.Vertical)
                {
                    Height = thickness;
                }
                else
                {
                    Height = Measure.Stretched;
                }
            }
            return(base.UpdateLayout(layoutType));
        }
Example #7
0
        public void EnqueueAfterThisAndParentSizing(LayoutingType _lt, ILayoutable _object)
        {
            LayoutingQueueItem lqi    = new LayoutingQueueItem(_lt, _object);
            LayoutingType      sizing = LayoutingType.Width;

            if (_lt == LayoutingType.Y)
            {
                sizing = LayoutingType.Height;
            }

            LinkedListNode <LayoutingQueueItem> parentLqi = searchLqi(_object.Parent, sizing);
            LinkedListNode <LayoutingQueueItem> thisLqi   = searchLqi(_object, sizing);

            if (parentLqi == null)
            {
                if (thisLqi != null)
                {
                    _object.RegisteredLQINodes.Add(this.AddAfter(thisLqi, lqi));
                }
                else
                {
                    _object.RegisteredLQINodes.Add(this.AddLast(lqi));
                }
            }
            else
            {
                if (thisLqi == null)
                {
                    _object.RegisteredLQINodes.Add(this.AddAfter(parentLqi, lqi));
                }
                else
                {
                    switch (sizing)
                    {
                    case LayoutingType.Width:
                        if (_object.Parent.getBounds().Width < 0)
                        {
                            _object.RegisteredLQINodes.Add(this.AddAfter(parentLqi, lqi));
                        }
                        else
                        {
                            _object.RegisteredLQINodes.Add(this.AddAfter(thisLqi, lqi));
                        }
                        break;

                    case LayoutingType.Height:
                        if (_object.Parent.getBounds().Height < 0)
                        {
                            _object.RegisteredLQINodes.Add(this.AddAfter(parentLqi, lqi));
                        }
                        else
                        {
                            _object.RegisteredLQINodes.Add(this.AddAfter(thisLqi, lqi));
                        }
                        break;
                    }
                }
            }
        }
Example #8
0
 public override void ChildrenLayoutingConstraints(ref LayoutingType layoutType)
 {
     //Prevent child repositionning in the direction of stacking
     if (Orientation == Orientation.Horizontal)
         layoutType &= (~LayoutingType.X);
     else
         layoutType &= (~LayoutingType.Y);
 }
Example #9
0
 public override void OnLayoutChanges(LayoutingType layoutType)
 {
     base.OnLayoutChanges(layoutType);
     if ((layoutType | LayoutingType.Sizing) > 0)
     {
         updateMaxScrolls();
     }
 }
Example #10
0
        public override int measureRawSize(LayoutingType lt)
        {
            if (lt == LayoutingType.Height)
            {
                return((int)Math.Ceiling((fe.Ascent + fe.Descent) * buffer.LineCount) + Margin * 2);
            }

            return(0);           // (int)(fe.MaxXAdvance * buffer.GetLineLength(buffer.longestLineIdx)) + Margin * 2;
        }
Example #11
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges(layoutType);

            if (layoutType == LayoutingType.Width)
            {
                MinimumPopupSize = new Size(this.Slot.Width, minimumPopupSize.Height);
            }
        }
Example #12
0
        protected override int measureRawSize(LayoutingType lt)
        {
            if (lt == LayoutingType.Height)
            {
                return((int)Math.Ceiling(fe.Height * buffer.LineCount) + Margin * 2);
            }

            return((int)(fe.MaxXAdvance * buffer.longestLineCharCount) + Margin * 2 + leftMargin);
        }
Example #13
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges (layoutType);

            if (Orientation == Orientation.Horizontal) {
                if (layoutType == LayoutingType.Width)
                    updateMousePosFromHue ();
            } else if (layoutType == LayoutingType.Height)
                updateMousePosFromHue ();
        }
Example #14
0
 LinkedListNode <LayoutingQueueItem> searchLqi(ILayoutable go, LayoutingType lt)
 {
     for (int i = 0; i < go.RegisteredLQINodes.Count; i++)
     {
         if (go.RegisteredLQINodes [i].Value.LayoutType == lt)
         {
             return(go.RegisteredLQINodes [i]);
         }
     }
     return(null);
 }
Example #15
0
 public override void OnLayoutChanges(LayoutingType layoutType)
 {
     base.OnLayoutChanges(layoutType);
     switch (layoutType)
     {
     case LayoutingType.Width:
     case LayoutingType.Height:
         imlVE.ProcessResize(this.ClientRectangle.Size);
         break;
     }
 }
Example #16
0
 public override void OnLayoutChanges(LayoutingType layoutType)
 {
     base.OnLayoutChanges(layoutType);
     switch (layoutType)
     {
     case LayoutingType.Width:
     case LayoutingType.Height:
         imlVE.ProcessResize(new Size(designWidth, designHeight));
         break;
     }
 }
Example #17
0
 public override void OnLayoutChanges(LayoutingType layoutType)
 {
     base.OnLayoutChanges (layoutType);
     switch (layoutType) {
     case LayoutingType.Width:
         mousePos.X = (int)Math.Floor(s * (double)ClientRectangle.Width);
         break;
     case LayoutingType.Height:
         mousePos.Y = (int)Math.Floor((1.0-v) * (double)ClientRectangle.Height);
         break;
     }
 }
Example #18
0
 public override void ChildrenLayoutingConstraints(ref LayoutingType layoutType)
 {
     //Prevent child repositionning in the direction of stacking
     if (Orientation == Orientation.Horizontal)
     {
         layoutType &= (~LayoutingType.X);
     }
     else
     {
         layoutType &= (~LayoutingType.Y);
     }
 }
Example #19
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges(layoutType);

            if (layoutType == LayoutingType.Height)
            {
                updateVisibleLines();
            }
            else if (layoutType == LayoutingType.Width)
            {
                updateVisibleColumns();
            }
        }
Example #20
0
 void adjustStretchedGo(LayoutingType lt)
 {
     if (stretchedGO == null)
     {
         return;
     }
     if (lt == LayoutingType.Width)
     {
         int newW = Math.Max(
             this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1),
             stretchedGO.MinimumSize.Width);
         if (stretchedGO.MaximumSize.Width > 0)
         {
             newW = Math.Min(newW, stretchedGO.MaximumSize.Width);
         }
         if (newW != stretchedGO.Slot.Width)
         {
             stretchedGO.Slot.Width = newW;
             stretchedGO.IsDirty    = true;
                                 #if DEBUG_LAYOUTING
             Debug.WriteLine("\tAdjusting Width of " + stretchedGO.ToString());
                                 #endif
             stretchedGO.LayoutChanged -= OnChildLayoutChanges;
             stretchedGO.OnLayoutChanges(LayoutingType.Width);
             stretchedGO.LayoutChanged  += OnChildLayoutChanges;
             stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
         }
     }
     else
     {
         int newH = Math.Max(
             this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1),
             stretchedGO.MinimumSize.Height);
         if (stretchedGO.MaximumSize.Height > 0)
         {
             newH = Math.Min(newH, stretchedGO.MaximumSize.Height);
         }
         if (newH != stretchedGO.Slot.Height)
         {
             stretchedGO.Slot.Height = newH;
             stretchedGO.IsDirty     = true;
                                 #if DEBUG_LAYOUTING
             Debug.WriteLine("\tAdjusting Height of " + stretchedGO.ToString());
                                 #endif
             stretchedGO.LayoutChanged -= OnChildLayoutChanges;
             stretchedGO.OnLayoutChanges(LayoutingType.Height);
             stretchedGO.LayoutChanged   += OnChildLayoutChanges;
             stretchedGO.LastSlots.Height = stretchedGO.Slot.Height;
         }
     }
 }
Example #21
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges(layoutType);

            if (_content == null)
            {
                return;
            }

            if (layoutType == LayoutingType.Width)
            {
                _content.MinimumSize = new Size(this.Slot.Width, _content.MinimumSize.Height);
            }
        }
Example #22
0
 public LayoutingQueueItem(LayoutingType _layoutType, ILayoutable _graphicObject)
 {
     LayoutType = _layoutType;
     Layoutable = _graphicObject;
     Layoutable.RegisteredLayoutings |= LayoutType;
     LayoutingTries = 0;
     DiscardCount   = 0;
                 #if DEBUG_LAYOUTING
     LQITime = new Stopwatch();
     Slot    = Rectangle.Empty;
     NewSlot = Rectangle.Empty;
     Debug.WriteLine("\tRegister => " + this.ToString());
                 #endif
 }
Example #23
0
        public void EnqueueBeforeParentSizing(LayoutingType _lt, ILayoutable _object)
        {
            LayoutingQueueItem lqi = new LayoutingQueueItem(_lt, _object);
            LinkedListNode <LayoutingQueueItem> parentLqi = searchLqi(_object.Parent, _lt);

            if (parentLqi == null)
            {
                _object.RegisteredLQINodes.Add(this.AddLast(lqi));
            }
            else
            {
                _object.RegisteredLQINodes.Add(this.AddBefore(parentLqi, lqi));
            }
        }
Example #24
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges(layoutType);
            switch (layoutType)
            {
            case LayoutingType.Width:
                mousePos.X = (int)Math.Floor(s * (double)ClientRectangle.Width);
                break;

            case LayoutingType.Height:
                mousePos.Y = (int)Math.Floor((1.0 - v) * (double)ClientRectangle.Height);
                break;
            }
        }
Example #25
0
File: Shape.cs Project: masums/Crow
 protected override int measureRawSize(LayoutingType lt)
 {
     if ((lt == LayoutingType.Width && contentSize.Width == 0) || (lt == LayoutingType.Height && contentSize.Height == 0))
     {
         using (Surface drawing = new ImageSurface(Format.A1, 1, 1)) {
             using (Context ctx = new Context(drawing)) {
                 executePath(ctx);
                 Rectangle r = ctx.StrokeExtents();
                 contentSize = new Size(r.Right, r.Bottom);
             }
         }
     }
     return(lt == LayoutingType.Width ?
            contentSize.Width + 2 * Margin: contentSize.Height + 2 * Margin);
 }
Example #26
0
        protected override int measureRawSize(LayoutingType lt)
        {
            if (lines == null)
            {
                lines = getLines;
            }

            using (ImageSurface img = new ImageSurface(Format.Argb32, 10, 10)) {
                using (Context gr = new Context(img)) {
                    //Cairo.FontFace cf = gr.GetContextFontFace ();

                    gr.SelectFontFace(Font.Name, Font.Slant, Font.Wheight);
                    gr.SetFontSize(Font.Size);


                    fe = gr.FontExtents;
                    te = new TextExtents();

                    if (lt == LayoutingType.Height)
                    {
                        int lc = lines.Count;
                        //ensure minimal height = text line height
                        if (lc == 0)
                        {
                            lc = 1;
                        }

                        return((int)Math.Ceiling(fe.Height * lc) + Margin * 2);
                    }
                    try {
                        foreach (string s in lines)
                        {
                            string l = s.Replace("\t", new String(' ', Interface.TabSize));

                            TextExtents tmp = gr.TextExtents(l);

                            if (tmp.XAdvance > te.XAdvance)
                            {
                                te = tmp;
                            }
                        }
                    } catch (Exception ex) {
                        return(-1);
                    }
                    return((int)Math.Ceiling(te.XAdvance) + Margin * 2);
                }
            }
        }
Example #27
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges(layoutType);
            switch (layoutType)
            {
            case LayoutingType.Width:
                DesignWidth = Slot.Width * 100 / zoom;
                imlVE.ProcessResize(new Size(designWidth, designHeight));
                break;

            case LayoutingType.Height:
                DesignHeight = Slot.Height * 100 / zoom;
                imlVE.ProcessResize(new Size(designWidth, designHeight));
                break;
            }
        }
Example #28
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            if (_orientation == Orientation.Horizontal)
            {
                if (layoutType == LayoutingType.Width)
                {
                    RegisterForLayouting(LayoutingType.ArrangeChildren);
                }
            }
            else if (layoutType == LayoutingType.Height)
            {
                RegisterForLayouting(LayoutingType.ArrangeChildren);
            }

            base.OnLayoutChanges(layoutType);
        }
Example #29
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges(layoutType);

            if (Orientation == Orientation.Horizontal)
            {
                if (layoutType == LayoutingType.Width)
                {
                    updateMousePosFromHue();
                }
            }
            else if (layoutType == LayoutingType.Height)
            {
                updateMousePosFromHue();
            }
        }
Example #30
0
 protected override int measureRawSize(LayoutingType lt)
 {
     if (_pic == null)
     {
         _pic = "#Crow.Images.Icons.IconAlerte.svg";
     }
     //TODO:take scalling in account
     if (lt == LayoutingType.Width)
     {
         return(_pic.Dimensions.Width + 2 * Margin);
     }
     else
     {
         return(_pic.Dimensions.Height + 2 * Margin);
     }
 }
Example #31
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges(layoutType);

            if (child == null)
            {
                return;
            }

            LayoutingType ltChild = LayoutingType.None;

            if (layoutType == LayoutingType.Width)
            {
                if (child.Width.Units == Unit.Percent)
                {
                    ltChild |= LayoutingType.Width;
                    if (child.Width.Value < 100 && child.Left == 0)
                    {
                        ltChild |= LayoutingType.X;
                    }
                }
                else if (child.Left == 0)
                {
                    ltChild |= LayoutingType.X;
                }
            }
            else if (layoutType == LayoutingType.Height)
            {
                if (child.Height.Units == Unit.Percent)
                {
                    ltChild |= LayoutingType.Height;
                    if (child.Height.Value < 100 && child.Top == 0)
                    {
                        ltChild |= LayoutingType.Y;
                    }
                }
                else if (child.Top == 0)
                {
                    ltChild |= LayoutingType.Y;
                }
            }
            if (ltChild == LayoutingType.None)
            {
                return;
            }
            child.RegisterForLayouting(ltChild);
        }
Example #32
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
                        #if DEBUG_LAYOUTING
            LayoutingQueueItem.currentLQI.Slot = LastSlots;
            LayoutingQueueItem.currentLQI.Slot = Slot;
                        #endif

            switch (layoutType)
            {
            case LayoutingType.Width:
                foreach (GraphicObject c in Children)
                {
                    if (c.Width.Units == Unit.Percent)
                    {
                        c.RegisterForLayouting(LayoutingType.Width);
                    }
                }
                if (Height == Measure.Fit)
                {
                    RegisterForLayouting(LayoutingType.Height);
                }
                RegisterForLayouting(LayoutingType.X);
                break;

            case LayoutingType.Height:
                foreach (GraphicObject c in Children)
                {
                    if (c.Height.Units == Unit.Percent)
                    {
                        c.RegisterForLayouting(LayoutingType.Height);
                    }
                }
                if (Width == Measure.Fit)
                {
                    RegisterForLayouting(LayoutingType.Width);
                }
                RegisterForLayouting(LayoutingType.Y);
                break;

            default:
                return;
            }
            RegisterForLayouting(LayoutingType.ArrangeChildren);
            //LayoutChanged.Raise (this, new LayoutingEventArgs (layoutType));
        }
Example #33
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges(layoutType);

            if (layoutType == LayoutingType.Height)
            {
                NotifyValueChanged("PageHeight", Slot.Height);
            }
            else if (layoutType == LayoutingType.Width)
            {
                NotifyValueChanged("PageWidth", Slot.Width);
            }
            else
            {
                return;
            }
            updateMaxScroll(layoutType);
        }
Example #34
0
 public LayoutingQueueItem(LayoutingType _layoutType, ILayoutable _graphicObject)
 {
     LayoutType = _layoutType;
     Layoutable = _graphicObject;
     Layoutable.RegisteredLayoutings |= LayoutType;
                 #if DEBUG_LAYOUTING
     if (graphicObject.CurrentDrawLQIs == null)
     {
         graphicObject.CurrentDrawLQIs = new List <LayoutingQueueItem>();
     }
     graphicObject.CurrentDrawLQIs.Add(this);
     if (currentLQI != null)
     {
         wasTriggeredBy = currentLQI;
         currentLQI.triggeredLQIs.Add(this);
     }
                 #endif
 }
Example #35
0
 /// <summary> return size of content + margins </summary>
 protected virtual int measureRawSize(LayoutingType lt)
 {
     return lt == LayoutingType.Width ?
         contentSize.Width + 2 * Margin: contentSize.Height + 2 * Margin;
 }
Example #36
0
        /// <summary> Update layout component only one at a time, this is where the computation of alignement
        /// and size take place.
        /// The redrawing will only be triggered if final slot size has changed </summary>
        /// <returns><c>true</c>, if layouting was possible, <c>false</c> if conditions were not
        /// met and LQI has to be re-queued</returns>
        public virtual bool UpdateLayout(LayoutingType layoutType)
        {
            //unset bit, it would be reset if LQI is re-queued
            registeredLayoutings &= (~layoutType);

            switch (layoutType) {
            case LayoutingType.X:
                if (Left == 0) {

                    if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) ||
                        RegisteredLayoutings.HasFlag (LayoutingType.Width))
                        return false;

                    switch (HorizontalAlignment) {
                    case HorizontalAlignment.Left:
                        Slot.X = 0;
                        break;
                    case HorizontalAlignment.Right:
                        Slot.X = Parent.ClientRectangle.Width - Slot.Width;
                        break;
                    case HorizontalAlignment.Center:
                        Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2;
                        break;
                    }
                } else
                    Slot.X = Left;

                if (LastSlots.X == Slot.X)
                    break;

                IsDirty = true;

                OnLayoutChanges (layoutType);

                LastSlots.X = Slot.X;
                break;
            case LayoutingType.Y:
                if (Top == 0) {

                    if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height) ||
                        RegisteredLayoutings.HasFlag (LayoutingType.Height))
                        return false;

                    switch (VerticalAlignment) {
                    case VerticalAlignment.Top://this could be processed even if parent Height is not known
                        Slot.Y = 0;
                        break;
                    case VerticalAlignment.Bottom:
                        Slot.Y = Parent.ClientRectangle.Height - Slot.Height;
                        break;
                    case VerticalAlignment.Center:
                        Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2;
                        break;
                    }
                } else
                    Slot.Y = Top;

                if (LastSlots.Y == Slot.Y)
                    break;

                IsDirty = true;

                OnLayoutChanges (layoutType);

                LastSlots.Y = Slot.Y;
                break;
            case LayoutingType.Width:
                if (Visible) {
                    if (Width.IsFixed)
                        Slot.Width = Width;
                    else if (Width == Measure.Fit) {
                        Slot.Width = measureRawSize (LayoutingType.Width);
                    } else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width))
                        return false;
                    else if (Width == Measure.Stretched)
                        Slot.Width = Parent.ClientRectangle.Width;
                    else
                        Slot.Width = (int)Math.Round ((double)(Parent.ClientRectangle.Width * Width) / 100.0);

                    if (Slot.Width < 0)
                        return false;

                    //size constrain
                    if (Slot.Width < MinimumSize.Width) {
                        Slot.Width = MinimumSize.Width;
                        //NotifyValueChanged ("WidthPolicy", Measure.Stretched);
                    } else if (Slot.Width > MaximumSize.Width && MaximumSize.Width > 0) {
                        Slot.Width = MaximumSize.Width;
                        //NotifyValueChanged ("WidthPolicy", Measure.Stretched);
                    }
                } else
                    Slot.Width = 0;

                if (LastSlots.Width == Slot.Width)
                    break;

                IsDirty = true;

                OnLayoutChanges (layoutType);

                LastSlots.Width = Slot.Width;
                break;
            case LayoutingType.Height:
                if (Visible) {
                    if (Height.IsFixed)
                        Slot.Height = Height;
                    else if (Height == Measure.Fit) {
                        Slot.Height = measureRawSize (LayoutingType.Height);
                    } else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height))
                        return false;
                    else if (Height == Measure.Stretched)
                        Slot.Height = Parent.ClientRectangle.Height;
                    else
                        Slot.Height = (int)Math.Round ((double)(Parent.ClientRectangle.Height * Height) / 100.0);

                    if (Slot.Height < 0)
                        return false;

                    //size constrain
                    if (Slot.Height < MinimumSize.Height) {
                        Slot.Height = MinimumSize.Height;
                        //NotifyValueChanged ("HeightPolicy", Measure.Stretched);
                    } else if (Slot.Height > MaximumSize.Height && MaximumSize.Height > 0) {
                        Slot.Height = MaximumSize.Height;
                        //NotifyValueChanged ("HeightPolicy", Measure.Stretched);
                    }
                } else
                    Slot.Height = 0;

                if (LastSlots.Height == Slot.Height)
                    break;

                IsDirty = true;

                OnLayoutChanges (layoutType);

                LastSlots.Height = Slot.Height;
                break;
            }

            //if no layouting remains in queue for item, registre for redraw
            if (this.registeredLayoutings == LayoutingType.None && IsDirty)
                CurrentInterface.EnqueueForRepaint (this);

            return true;
        }
Example #37
0
        public virtual void RegisterForLayouting(LayoutingType layoutType)
        {
            if (Parent == null)
                return;
            lock (CurrentInterface.LayoutMutex) {
                //prevent queueing same LayoutingType for this
                layoutType &= (~RegisteredLayoutings);

                if (layoutType == LayoutingType.None)
                    return;
                //dont set position for stretched item
                if (Width == Measure.Stretched)
                    layoutType &= (~LayoutingType.X);
                if (Height == Measure.Stretched)
                    layoutType &= (~LayoutingType.Y);

                if (!ArrangeChildren)
                    layoutType &= (~LayoutingType.ArrangeChildren);

                //apply constraints depending on parent type
                if (Parent is GraphicObject)
                    (Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType);

            //				//prevent queueing same LayoutingType for this
            //				layoutType &= (~RegisteredLayoutings);

                if (layoutType == LayoutingType.None)
                    return;

                //enqueue LQI LayoutingTypes separately
                if (layoutType.HasFlag (LayoutingType.Width))
                    CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
                if (layoutType.HasFlag (LayoutingType.Height))
                    CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
                if (layoutType.HasFlag (LayoutingType.X))
                    CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
                if (layoutType.HasFlag (LayoutingType.Y))
                    CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
                if (layoutType.HasFlag (LayoutingType.ArrangeChildren))
                    CurrentInterface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
            }
        }
Example #38
0
        protected override int measureRawSize(LayoutingType lt)
        {
            if (lines == null)
                lines = getLines;

            using (ImageSurface img = new ImageSurface (Format.Argb32, 10, 10)) {
                using (Context gr = new Context (img)) {
                    //Cairo.FontFace cf = gr.GetContextFontFace ();

                    gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
                    gr.SetFontSize (Font.Size);

                    fe = gr.FontExtents;
                    te = new TextExtents();

                    if (lt == LayoutingType.Height){
                        int lc = lines.Count;
                        //ensure minimal height = text line height
                        if (lc == 0)
                            lc = 1;

                        return (int)Math.Ceiling(fe.Height * lc) + Margin * 2;
                    }

                    foreach (string s in lines) {
                        string l = s.Replace("\t", new String (' ', Interface.TabSize));

                        TextExtents tmp = gr.TextExtents (l);

                        if (tmp.XAdvance > te.XAdvance)
                            te = tmp;
                    }
                    return (int)Math.Ceiling (te.XAdvance) + Margin * 2;
                }
            }
        }
Example #39
0
 protected override int measureRawSize(LayoutingType lt)
 {
     if (Children.Count > 0) {
         if (lt == LayoutingType.Width) {
             if (largestChild == null)
                 searchLargestChild ();
             if (largestChild == null) {
                 //if still null, not possible to determine a width
                 //because all children are stretched, force first one to fit
                 Children [0].Width = Measure.Fit;
                 return -1;//cancel actual sizing to let child computation take place
             }
         } else {
             if (tallestChild == null)
                 searchTallestChild ();
             if (tallestChild == null) {
                 Children [0].Height = Measure.Fit;
                 return -1;
             }
         }
     }
     return base.measureRawSize (lt);
 }
Example #40
0
 protected override int measureRawSize(LayoutingType lt)
 {
     if (_pic == null)
         _pic = "#Crow.Images.Icons.IconAlerte.svg";
     //TODO:take scalling in account
     if (lt == LayoutingType.Width)
         return _pic.Dimensions.Width + 2 * Margin;
     else
         return _pic.Dimensions.Height + 2 * Margin;
 }
Example #41
0
        public override bool UpdateLayout(LayoutingType layoutType)
        {
            RegisteredLayoutings &= (~layoutType);

            if (layoutType == LayoutingType.ArrangeChildren) {
                //allow 1 child to have size to 0 if stack has fixed or streched size policy,
                //this child will occupy remaining space
                //if stack size policy is Fit, no child may have stretch enabled
                //in the direction of stacking.
                ComputeChildrenPositions ();

                //if no layouting remains in queue for item, registre for redraw
                if (RegisteredLayoutings == LayoutingType.None && IsDirty)
                    CurrentInterface.EnqueueForRepaint (this);

                return true;
            }

            return base.UpdateLayout(layoutType);
        }
Example #42
0
        protected override int measureRawSize(LayoutingType lt)
        {
            int tmp = 0;
            //Wrapper can't fit in the direction of the wrapper
            if (lt == LayoutingType.Width) {
                if (Orientation == Orientation.Vertical) {
                    Width = Measure.Stretched;
                    return -1;
                } else if (RegisteredLayoutings.HasFlag (LayoutingType.Height))
                    return -1;
                else {
                    int dy = 0;
                    int largestChild = 0;
                    lock (Children) {
                        foreach (GraphicObject c in Children) {
                            if (!c.Visible)
                                continue;
                            if (c.Height.Units == Unit.Percent &&
                                c.RegisteredLayoutings.HasFlag (LayoutingType.Height))
                                return -1;
                            if (dy + c.Slot.Height > ClientRectangle.Height) {
                                dy = 0;
                                tmp += largestChild + Spacing;
                                largestChild = c.Slot.Width;
                            } else if (largestChild < c.Slot.Width)
                                largestChild = c.Slot.Width;

                            dy += c.Slot.Height + Spacing;
                        }
                        if (dy == 0)
                            tmp -= Spacing;
                        return tmp + largestChild + 2 * Margin;
                    }
                }
            } else if (Orientation == Orientation.Horizontal) {
                Height = Measure.Stretched;
                return -1;
            } else if (RegisteredLayoutings.HasFlag (LayoutingType.Width))
                return -1;
            else {
                int dx = 0;
                int tallestChild = 0;
                lock (Children) {
                    foreach (GraphicObject c in Children) {
                        if (!c.Visible)
                            continue;
                        if (c.Width.Units == Unit.Percent &&
                            c.RegisteredLayoutings.HasFlag (LayoutingType.Width))
                            return -1;
                        if (dx + c.Slot.Width > ClientRectangle.Width) {
                            dx = 0;
                            tmp += tallestChild + Spacing;
                            tallestChild = c.Slot.Height;
                        } else if (tallestChild < c.Slot.Height)
                            tallestChild = c.Slot.Height;

                        dx += c.Slot.Width + Spacing;
                    }
                    if (dx == 0)
                        tmp -= Spacing;
                    return tmp + tallestChild + 2 * Margin;
                }
            }
        }
Example #43
0
        public override bool UpdateLayout(LayoutingType layoutType)
        {
            RegisteredLayoutings &= (~layoutType);

            if (layoutType == LayoutingType.ArrangeChildren) {
                if ((RegisteredLayoutings & LayoutingType.Sizing) != 0)
                    return false;

                ComputeChildrenPositions ();

                //if no layouting remains in queue for item, registre for redraw
                if (RegisteredLayoutings == LayoutingType.None && IsDirty)
                    CurrentInterface.EnqueueForRepaint (this);

                return true;
            }

            return base.UpdateLayout(layoutType);
        }
Example #44
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            #if DEBUG_LAYOUTING
            CurrentInterface.currentLQI.Slot = LastSlots;
            CurrentInterface.currentLQI.Slot = Slot;
            #endif

            switch (layoutType) {
            case LayoutingType.Width:
                foreach (GraphicObject c in Children) {
                    if (c.Width.Units == Unit.Percent)
                        c.RegisterForLayouting (LayoutingType.Width);
                }
                if (Height == Measure.Fit)
                    RegisterForLayouting (LayoutingType.Height);
                RegisterForLayouting (LayoutingType.X);
                break;
            case LayoutingType.Height:
                foreach (GraphicObject c in Children) {
                    if (c.Height.Units == Unit.Percent)
                        c.RegisterForLayouting (LayoutingType.Height);
                }
                if (Width == Measure.Fit)
                    RegisterForLayouting (LayoutingType.Width);
                RegisterForLayouting (LayoutingType.Y);
                break;
            default:
                return;
            }
            RegisterForLayouting (LayoutingType.ArrangeChildren);
            //LayoutChanged.Raise (this, new LayoutingEventArgs (layoutType));
        }
Example #45
0
		public bool UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); }
Example #46
0
 protected override int measureRawSize(LayoutingType lt)
 {
     int tmp = base.measureRawSize (lt);
     return tmp < 0 ? tmp : tmp + 2 * BorderWidth;
 }
Example #47
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges (layoutType);

            if (child == null)
                return;

            LayoutingType ltChild = LayoutingType.None;

            if (layoutType == LayoutingType.Width) {
                if (child.Width.Units == Unit.Percent) {
                    ltChild |= LayoutingType.Width;
                    if (child.Width.Value < 100 && child.Left == 0)
                        ltChild |= LayoutingType.X;
                } else if (child.Left == 0)
                    ltChild |= LayoutingType.X;
            } else if (layoutType == LayoutingType.Height) {
                if (child.Height.Units == Unit.Percent) {
                    ltChild |= LayoutingType.Height;
                    if (child.Height.Value < 100 && child.Top == 0)
                        ltChild |= LayoutingType.Y;
                } else if (child.Top == 0)
                        ltChild |= LayoutingType.Y;
            }
            if (ltChild == LayoutingType.None)
                return;
            child.RegisterForLayouting (ltChild);
        }
Example #48
0
 /// <summary> By default in groups, LayoutingType.ArrangeChildren is reset </summary>
 public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType)
 {
 }
Example #49
0
        /// <summary> trigger dependant sizing component update </summary>
        public virtual void OnLayoutChanges(LayoutingType  layoutType)
        {
            #if DEBUG_LAYOUTING
            CurrentInterface.currentLQI.Slot = LastSlots;
            CurrentInterface.currentLQI.NewSlot = Slot;
            #endif

            switch (layoutType) {
            case LayoutingType.Width:
                RegisterForLayouting (LayoutingType.X);
                break;
            case LayoutingType.Height:
                RegisterForLayouting (LayoutingType.Y);
                break;
            }
            LayoutChanged.Raise (this, new LayoutingEventArgs (layoutType));
        }
Example #50
0
 public override void ChildrenLayoutingConstraints(ref LayoutingType layoutType)
 {
     layoutType &= (~LayoutingType.Positioning);
 }
Example #51
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges (layoutType);

            if (_content == null)
                return;

            if (layoutType == LayoutingType.Width)
                _content.MinimumSize = new Size (this.Slot.Width, _content.MinimumSize.Height);
        }
Example #52
0
        public override void OnLayoutChanges(LayoutingType layoutType)
        {
            base.OnLayoutChanges (layoutType);

            //position smaller objects in group when group size is fit
            switch (layoutType) {
            case LayoutingType.Width:
                foreach (GraphicObject c in Children){
                    if (c.Width.Units == Unit.Percent)
                        c.RegisterForLayouting (LayoutingType.Width);
                    else
                        c.RegisterForLayouting (LayoutingType.X);
                }
                break;
            case LayoutingType.Height:
                foreach (GraphicObject c in Children) {
                    if (c.Height.Units == Unit.Percent)
                        c.RegisterForLayouting (LayoutingType.Height);
                    else
                        c.RegisterForLayouting (LayoutingType.Y);
                }
                break;
            }
        }
Example #53
0
 public LayoutingEventArgs(LayoutingType  _layoutType)
     : base()
 {
     LayoutType = _layoutType;
 }
Example #54
0
        protected override int measureRawSize(LayoutingType lt)
        {
            int totSpace = 0;
            for (int i = 0; i < Children.Count; i++) {
                if (Children [i].Visible)
                    totSpace += Spacing;
            }
            if (totSpace > 0)
                totSpace -= Spacing;
            if (lt == LayoutingType.Width) {
                if (Orientation == Orientation.Horizontal)
                    return contentSize.Width + totSpace + 2 * Margin;
            }else if (Orientation == Orientation.Vertical)
                return contentSize.Height + totSpace + 2 * Margin;

            return base.measureRawSize (lt);
        }
Example #55
0
		public void EnqueueForLayouting (LayoutingType layoutType)
		{
			throw new NotImplementedException ();
		}			
Example #56
0
 public override bool UpdateLayout(LayoutingType layoutType)
 {
     if (child != null) {
         //force sizing to fit if sizing on children and child has stretched size
         switch (layoutType) {
         case LayoutingType.Width:
             if (Width == Measure.Fit && child.Width.Units == Unit.Percent)
                 child.Width = Measure.Fit;
             break;
         case LayoutingType.Height:
             if (Height == Measure.Fit && child.Height.Units == Unit.Percent)
                 child.Height = Measure.Fit;
             break;
         }
     }
     return base.UpdateLayout (layoutType);
 }
Example #57
0
        public override bool UpdateLayout(LayoutingType layoutType)
        {
            RegisteredLayoutings &= (~layoutType);

            if (layoutType == LayoutingType.ArrangeChildren) {
                int curOffset = Spacing;
                for (int i = 0; i < Children.Count; i++) {
                    if (!Children [i].Visible)
                        continue;
                    TabItem ti = Children [i] as TabItem;
                    ti.TabOffset = curOffset;
                    if (Orientation == Orientation.Horizontal) {
                        if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Width))
                            return false;
                        curOffset += ti.TabTitle.Slot.Width + Spacing;
                    } else {
                        if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Height))
                            return false;
                        curOffset += ti.TabTitle.Slot.Height + Spacing;
                    }
                }

                //if no layouting remains in queue for item, registre for redraw
                if (RegisteredLayoutings == LayoutingType.None && IsDirty)
                    CurrentInterface.EnqueueForRepaint (this);

                return true;
            }

            return base.UpdateLayout(layoutType);
        }
Example #58
0
 public override bool UpdateLayout(LayoutingType layoutType)
 {
     GenericStack gs = Parent as GenericStack;
     if (layoutType == LayoutingType.Width){
         if (gs.Orientation == Orientation.Horizontal)
             Width = thickness;
         else
             Width = Measure.Stretched;
     } else if (layoutType == LayoutingType.Height){
         if (gs.Orientation == Orientation.Vertical)
             Height = thickness;
         else
             Height = Measure.Stretched;
     }
     return base.UpdateLayout (layoutType);
 }