예제 #1
0
        /// <summary> Set the assigned position and size, calculated by the geometry management. </summary>
        /// <param name="rectObj"> The rectangle object to set the assigned position and size for. <see cref="XrwRectObj"/> </param>
        /// <param name="position"> The assigned position to set. <see cref="TPoint"/> </param>
        /// <param name="size"> The assigned position to set. <see cref="TSize"/> </param>
        public static void SetAssignedGeometry(XrwRectObj rectObj, TPoint position, TSize size)
        {
            if (rectObj == null)
            {
                Console.WriteLine("GeometryManagerAccess::SetAssignedGeometry () ERROR: Argument null: rectObj");
                return;
            }

            // Fixed size always has priority!
            if (rectObj.IsFixedWidth == true)
            {
                size.Width = rectObj.FixedSize.Width;
            }
            if (rectObj.IsFixedWidth == true)
            {
                size.Height = rectObj.FixedSize.Height;
            }
            rectObj._assignedSize = size;

            if (rectObj.HasOwnWindow && (rectObj is XrwVisibleRectObj))
            {
                // Transfer the geometry to the underlaying window.
                XrwVisibleRectObj visibleRect = rectObj as XrwVisibleRectObj;
                if (visibleRect.Display != IntPtr.Zero && visibleRect.Window != IntPtr.Zero)
                {
                    // This call causes a ConfigureNotify event.
                    X11lib.XMoveResizeWindow(visibleRect.Display, visibleRect.Window, (TInt)position.X, (TInt)position.Y, (TUint)size.Width, (TUint)size.Height);
                    visibleRect._assignedPosition = new TPoint(0, 0);
                }
                else
                {
                    throw new AccessViolationException("XrwVisibleRectObj or inherited widget without display or window.");
                }
            }
            else
            {
                rectObj._assignedPosition = position;
            }

            // Child should be prevented from overwriting parent's border.
            size.Width  -= 2 * rectObj.BorderWidth;
            size.Height -= 2 * rectObj.BorderWidth;

            rectObj.CalculateChildLayout(position, size);
        }
예제 #2
0
        /// <summary> Initializing constructor. </summary>
        /// <param name="visibleRectObj">The rect object to initialize the lines for. <see cref="XrwVisibleRectObj"/> </param>
        /// <param name="text"> The label text. A <see cref="System.String"/> </param>
        public Multiline(XrwVisibleRectObj visibleRectObj, string text)
        {
            if (visibleRectObj == null)
            {
                throw new ArgumentNullException("labelWidget");
            }

            text = text.Replace("\r\n", "\n");
            if (string.IsNullOrEmpty(text))
            {
                TChar[] lineText = {};
                this.Add(new Line(lineText, 0, 0));
                return;
            }

            string [] lines = text.Split('\n');
            for (int countLines = 0; countLines < lines.Length; countLines++)
            {
                TChar[] lineText    = X11Utils.StringToSByteArray(lines[countLines]);
                TSize   textMeasure = visibleRectObj.MeasureTextLine(visibleRectObj.Display, visibleRectObj.GC, lineText);
                this.Add(new Line(lineText, textMeasure.Width, textMeasure.Height));
            }
        }