Esempio n. 1
0
        /// <summary> Calcualate layout after a position or size change. </summary>
        /// <param name="assignedPosition"> The position of the top left top corner assigned by the window manager (for shell widgets) or geometry management (by non-shell widgets). <see cref="TPoint"/> </param>
        /// <param name="availableSize"> The available size. <see cref="TIntSize"/> </param>
        /// <remarks> This method is defined at XrwRectObj for compatibility, but must be implemented for composite widgets only. </remarks>
        public override void CalculateChildLayout(TPoint assignedPosition, TSize availableSize)
        {
            int    borderAndFrame = _borderWidth + _frameWidth;
            TPoint childPosition  = new TPoint(assignedPosition.X + borderAndFrame,
                                               assignedPosition.Y + borderAndFrame);

            for (int counter = 0; counter < _children.Count; counter++)
            {
                TSize preferredSize = _children[counter].PreferredSize();

                if (_children[counter].ExpandToAvailableWidth == true)
                {
                    if (preferredSize.Width < availableSize.Width - borderAndFrame - borderAndFrame)
                    {
                        preferredSize.Width = availableSize.Width - borderAndFrame - borderAndFrame;
                    }
                }
                if (_children[counter].ExpandToAvailableHeight == true)
                {
                    if (preferredSize.Height < availableSize.Height - borderAndFrame - borderAndFrame)
                    {
                        preferredSize.Height = availableSize.Height - borderAndFrame - borderAndFrame;
                    }
                }

                GeometryManagerAccess.SetAssignedGeometry(_children[counter], childPosition, preferredSize);
            }
        }
Esempio n. 2
0
        // ###############################################################################
        // ### D E S T R U C T I O N
        // ###############################################################################

        #region Destruction

        #endregion

        // ###############################################################################
        // ### P R O P E R T I E S
        // ###############################################################################

        #region Properties

        #endregion

        // ###############################################################################
        // ### M E T H O D S
        // ###############################################################################

        #region Methods

        #endregion

        #region Event handler

        /// <summary> Handle the ConfigureEvent event. </summary>
        /// <param name="e"> The event data. <see cref="XawClientMessageEvent"/> </param>
        /// <remarks> Set XawClientMessageEvent. Set result to nonzero to stop further event processing. </remarks>
        public virtual void OnConfigure(XrwConfigureEvent e)
        {
            // Prevent useless reconfiguration, if widt / height did not change.
            if (_assignedSize.Width != (int)e.Event.width ||
                _assignedSize.Height != (int)e.Event.height)
            {
                _assignedPosition.X  = (int)e.Event.x;
                _assignedPosition.Y  = (int)e.Event.y;
                _assignedSize.Width  = (int)e.Event.width;
                _assignedSize.Height = (int)e.Event.height;

                for (int cntChildren = 0; cntChildren < _children.Count; cntChildren++)
                {
                    XrwRectObj widget = _children[cntChildren];
                    // Every direct child can occupy the complete size.
                    GeometryManagerAccess.SetAssignedGeometry(widget, new TPoint(0, 0), _assignedSize);
                }
            }
            // Position can change without the nessesarity to calculate a new geometry.
            else
            {
                _assignedPosition.X = (int)e.Event.x;
                _assignedPosition.Y = (int)e.Event.y;
            }
        }
        /// <summary> Calcualate layout after a position or size change. </summary>
        /// <remarks> This method is defined at XrwRectObj for compatibility, but must be implemented for composite widgets only. </remarks>
        public void CalculateChildLayout()
        {
            TPoint           childPosition         = new TPoint(_borderWidth, _borderWidth);
            List <ChildData> childData             = new List <ChildData>();
            TSize            childrenPreferredSize = new TSize(0, 0);

            for (int counter = 0; counter < _children.Count; counter++)
            {
                TSize preferredSize = _children[counter].PreferredSize();
                childData.Add(new ChildData(_children[counter], preferredSize));

                if (childrenPreferredSize.Width < preferredSize.Width)
                {
                    childrenPreferredSize.Width = preferredSize.Width;
                }
                if (childrenPreferredSize.Height < preferredSize.Height)
                {
                    childrenPreferredSize.Height = preferredSize.Height;
                }
            }

            for (int counter = 0; counter < childData.Count; counter++)
            {
                ChildData cd = childData[counter];

                if (cd.Widget.ExpandToAvailableWidth == true)
                {
                    cd.Size.Width = childrenPreferredSize.Width;
                }
                if (cd.Widget.ExpandToAvailableHeight == true)
                {
                    cd.Size.Height = childrenPreferredSize.Height;
                }

                GeometryManagerAccess.SetAssignedGeometry(cd.Widget, childPosition, cd.Size);
            }
        }
Esempio n. 4
0
        /// <summary> Calcualate layout after a position or size change acting like a VBox. </summary>
        /// <param name="assignedPosition"> The position of the top left top corner assigned by the window manager (for shell widgets) or geometry management (by non-shell widgets). <see cref="TPoint"/> </param>
        /// <param name="availableSize"> The available size. <see cref="TIntSize"/> </param>
        /// <remarks> This method is defined at XrwRectObj for compatibility, but must be implemented for composite widgets only. </remarks>
        private void CalculateChildLayoutVBox(TPoint assignedPosition, TSize availableSize)
        {
            int    borderAndFrame = _borderWidth + _frameWidth;
            TPoint childPosition  = new TPoint(assignedPosition.X + borderAndFrame,
                                               assignedPosition.Y + borderAndFrame);

            List <ChildData> childData      = new List <ChildData>();
            int countMaxSiblingHeightExpand = 0;
            int countAvailableHeightExpand  = 0;
            int childrenPreferredHeight     = 0;
            int maxSiblingHeight            = 0;
            int unexpandedMaxSiblingHeight  = 0;

            for (int counter = 0; counter < _children.Count; counter++)
            {
                TSize preferredSize = _children[counter].PreferredSize();
                childData.Add(new ChildData(_children[counter], preferredSize));

                if (_children[counter].ExpandToMaxSiblingHeight == true)
                {
                    countMaxSiblingHeightExpand++;
                    unexpandedMaxSiblingHeight += preferredSize.Height;
                }
                if (_children[counter].ExpandToAvailableHeight == true)
                {
                    countAvailableHeightExpand++;
                }

                childrenPreferredHeight += preferredSize.Height;
                if (counter > 0)
                {
                    childrenPreferredHeight += _vertSpacing;
                }

                if (maxSiblingHeight < preferredSize.Height)
                {
                    maxSiblingHeight = preferredSize.Height;
                }
            }

            int heightForAvailableHeightExpand = (availableSize.Height > childrenPreferredHeight && countAvailableHeightExpand > 0 ?
                                                  (availableSize.Height - childrenPreferredHeight) / countAvailableHeightExpand - _frameWidth - _frameWidth :
                                                  (availableSize.Height - childrenPreferredHeight) - _frameWidth - _frameWidth);
            int heightForMaxSiblingHeightExpand = Math.Min(heightForAvailableHeightExpand, maxSiblingHeight * countMaxSiblingHeightExpand - unexpandedMaxSiblingHeight);

            heightForAvailableHeightExpand -= heightForMaxSiblingHeightExpand;

            if (countAvailableHeightExpand == 0 && heightForAvailableHeightExpand > 0)
            {
                childPosition.Y = childPosition.Y + (int)(heightForAvailableHeightExpand * _childAlign);
            }

            for (int counter = 0; counter < childData.Count; counter++)
            {
                ChildData cd = childData[counter];

                if (cd.Widget.ExpandToMaxSiblingHeight == true)
                {
                    int expandBy = Math.Min(heightForMaxSiblingHeightExpand, maxSiblingHeight - cd.Size.Height);
                    cd.Size.Height += expandBy;
                    heightForMaxSiblingHeightExpand -= expandBy;
                }
                if (cd.Widget.ExpandToAvailableHeight == true)
                {
                    int expandBy = (int)(heightForAvailableHeightExpand / countAvailableHeightExpand);
                    cd.Size.Height += expandBy;
                    heightForAvailableHeightExpand -= expandBy;
                    countAvailableHeightExpand--;
                }
                if (cd.Widget.ExpandToAvailableWidth == true)
                {
                    if (cd.Size.Width < availableSize.Width - borderAndFrame - borderAndFrame)
                    {
                        cd.Size.Width = availableSize.Width - borderAndFrame - borderAndFrame;
                    }
                }

                GeometryManagerAccess.SetAssignedGeometry(cd.Widget, childPosition, cd.Size);
                childPosition.Y = childPosition.Y + cd.Size.Height + _vertSpacing;
            }
        }