Example #1
0
 void TreeView_Layout(object sender, LayoutEventArgs e)
 {
 }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="mapData"></param>
        internal void handleEvent(EventType type, Control sender, EventArgs e, MapData mapData)
        {
            MapData          orgMapData       = mapData;
            ContainerManager containerManager = GuiUtils.getContainerManager(sender);

            switch (type)
            {
#if !PocketPC
            case EventType.DRAG_OVER:
            case EventType.DRAG_DROP:
                // Need to get current Control, Hence needed
                Point pt     = new Point(((DragEventArgs)e).X, ((DragEventArgs)e).Y);
                Point screen = sender.PointToClient(pt);
                mapData = containerManager.HitTest(screen, true, false);
                break;
#endif
            case EventType.MOUSE_MOVE:
                // the mouse move will handle the tooltip
                mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), true, false);
                break;

            case EventType.NCMOUSE_DOWN:
                MapData containerMapData = ControlsMap.getInstance().getMapData(sender);
                Events.OnMouseDown(containerMapData.getForm(), containerMapData.getControl(), null, true, 0, true, true);
                break;

            case EventType.MOUSE_DOWN:
                // check if a point on some table child
                // fixed bug #986057 (same in online)
                // * when pressing Rclick(button != 1) on Table or on the divider the Table's Context Menu will be
                // display( if press on other row no focus will move to the new row)
                // * when pressing Rclick exactly edit the context menu of the edit will be display and the focus
                // will move to the control
                bool LeftClickWasPressed = ((MouseEventArgs)e).Button == MouseButtons.Left;
                bool findExact           = (sender is TableControl && LeftClickWasPressed ? false : true);
                mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), findExact, true);
                if (mapData != null)
                {
                    // Defect# 130085: When we click on a control (say checkbox) placed on table header, mouseDown is not needed to be processed.
                    // Actually, this is received from WM_PARENTNOTIFY from TableControl. This will avoid multiple ACT_CTRL_HIT on table header child
                    // control and Table control. Another option was to set WS_EX_NOPARENTNOTIFY style to table header child.
                    GuiMgControl mgControl = mapData.getControl();
                    if (mgControl.IsTableHeaderChild)
                    {
                        return;
                    }
                    // mark that we need to focus on the control
                    GuiUtils.saveFocusingControl(GuiUtils.FindForm(sender), mapData);
                }
                else if (sender is TableControl)
                {
                    GuiUtils.restoreFocus(GuiUtils.FindForm(sender));
                }
                break;

            case EventType.MOUSE_UP:
                // for mouse up we need control the has been clicked and not nearest control
                mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), true, true);
                break;

            case EventType.MOUSE_DBLCLICK:
                if (!(sender is TableControl)) //TODO
                {
                    mapData = containerManager.HitTest(new Point(((MouseEventArgs)e).X, ((MouseEventArgs)e).Y), true, true);
                }
                break;

            case EventType.PRESS:
                findExact = !(sender is TableControl);
                // Mobile clients for which this event type is applicable must
                // pass actual press co-ords
                Point point = new Point(0, 0);
                mapData = containerManager.HitTest(point, findExact, true);
                if (mapData != null)
                {
                    GuiUtils.saveFocusingControl(GuiUtils.FindForm(sender), mapData);
                }
                break;

            case EventType.PAINT:
                if (containerManager is BasicControlsManager)
                {
                    ((BasicControlsManager)containerManager).Paint(((PaintEventArgs)e).Graphics);
                }
                break;

#if PocketPC
            case EventType.RESIZE:
                EditorSupportingPlacementLayout placementLayout1 = ((TagData)sender.Tag).PlacementLayout;
                if (placementLayout1 != null)
                {
                    LayoutEventArgs le = new LayoutEventArgs();
                    placementLayout1.layout(sender, le);
                }
                break;
#endif
            case EventType.LAYOUT:
                EditorSupportingPlacementLayout placementLayout = ((TagData)sender.Tag).PlacementLayout;
                if (placementLayout != null)
                {
                    placementLayout.layout(sender, (LayoutEventArgs)e);
                }
                break;

            case EventType.DISPOSED:
                containerManager.Dispose();
                break;
            }

            if (mapData == null)
            {
                mapData = orgMapData;
            }
            DefaultHandler.getInstance().handleEvent(type, sender, e, mapData);
        }
Example #3
0
 internal void OnLayout(LayoutEventArgs levent)
 {
     LayoutEngine.Layout(this, levent);
 }
Example #4
0
            /// <summary>
            /// </summary>
            /// <param name = "container"></param>
            /// <param name = "layoutEventArgs"></param>
            /// <returns></returns>
            public override bool Layout(object container, LayoutEventArgs layoutEventArgs)
            {
                Control parent = container as Control;

                if (parent.Controls.Count == 0)
                {
                    return(false);
                }
                Size          clientRect         = ((Panel)container).Size;
                int           radioLineSeperator = 0;
                int           radioColSeperator  = 0;
                MgRadioButton radioButton        = (MgRadioButton)parent.Controls[0];
                Boolean       isAppearanceButton = (radioButton.Appearance == Appearance.Button);
                int           radionInColumn     = getCountOfButtonsInColumn(parent.Controls.Count, isAppearanceButton);

                Rectangle radioRect = new Rectangle(0, 0, 0, 0);

                if (parent.Controls.Count == 1)
                {
                    radioButton.SetBounds(0, 0, clientRect.Width, clientRect.Height);
                }
                else
                {
                    int i      = 0;
                    int width  = 0;
                    int height = 0;

                    int numColumns = _numColumns;

                    if (isAppearanceButton)
                    {
                        numColumns = Math.Min(numColumns, parent.Controls.Count);
                        width      = radioRect.Width = clientRect.Width / numColumns;
                        height     = radioRect.Height = clientRect.Height / radionInColumn;
                        // Fixed defect #:137271: radioColSeperator & radioLineSeperator will be 0 for button
                        radioColSeperator  = 0;
                        radioLineSeperator = 0;
                        radioRect.X        = radioLineSeperator;
                        radioRect.Y        = radioColSeperator;
                    }
                    else
                    {
                        MgRadioPanel mgRadioPanel = container as MgRadioPanel;
                        if (radioButton.Image != null)
                        {
                            // Measure the radio button image size.
                            width  = radioButton.Image.Width;
                            height = radioButton.Image.Height;
                        }
                        else
                        {
                            //find the maximun string size in the composite
                            foreach (Control c in parent.Controls)
                            {
                                MgRadioButton mgRadioButton = (MgRadioButton)c;
                                Size          textExt       = Utils.GetTextExt(mgRadioPanel.Font, mgRadioButton.TextToDisplay, c);
                                width  = Math.Max(width, textExt.Width);
                                height = Math.Max(height, textExt.Height);
                            }
                        }
                        // add extras
                        width  = (int)((float)(RADIO_RECT_DX + RADIO_TEXT_SPACE + width + 1) * Utils.GetDpiScaleRatioX(parent));
                        height = (int)((float)(Math.Max(RADIO_RECT_DY, height + 2) * Utils.GetDpiScaleRatioY(parent)));

                        PointF fm = Utils.GetFontMetricsByFont(mgRadioPanel, (mgRadioPanel).Font);

                        radioLineSeperator = (int)fm.Y / 2;
                        height             = Math.Max(height, (clientRect.Height - (radionInColumn * radioLineSeperator)) / radionInColumn);
                        radioColSeperator  = (int)Math.Max((clientRect.Width - (numColumns * width)) / (numColumns + 1), fm.X / 2);

                        // Use DisplayRectangle so that parent.Padding is honored.
#if !PocketPC
                        Rectangle parentDisplayRectangle = parent.DisplayRectangle;
#else
                        Rectangle parentDisplayRectangle = parent.Bounds;
                        parentDisplayRectangle.X = parentDisplayRectangle.Y = 0;
#endif
                        Point nextControlLocation = parentDisplayRectangle.Location;

                        // calculate the bounds of the first button in the first column
                        radioRect.Y      = radioLineSeperator;
                        radioRect.Height = height;
                        // TODO: Hebrew

                        if (mgRadioPanel.RightToLeft == RightToLeft.Yes)
                        {
                            radioRect.X = mgRadioPanel.Width - radioColSeperator - width;
                        }
                        else
                        {
                            radioRect.X = radioColSeperator;
                        }
                        radioRect.Width = width;
                    }

                    foreach (Control c in parent.Controls)
                    {
                        radioButton = (MgRadioButton)c;
                        {
                            // checks if skip to another column is needed
                            if (numColumns > 1 && i > 0 && (i % radionInColumn) == 0)
                            {
                                // TODO: Hebrew
                                MgRadioPanel mgRadioPanel = container as MgRadioPanel;
                                if (mgRadioPanel.RightToLeft == RightToLeft.Yes)
                                {
                                    radioRect.X -= width + radioColSeperator;
                                }
                                else
                                {
                                    radioRect.X += width + radioColSeperator;
                                }
                                radioRect.Y = radioLineSeperator;
                            }
                        }

                        if (radioRect.X + radioRect.Width > clientRect.Width)
                        {
                            radioRect.Width = clientRect.Width - radioRect.X;
                        }
                        if (radioRect.Y + radioRect.Height > clientRect.Height)
                        {
                            radioRect.Height = clientRect.Height - radioRect.Y;
                        }
                        // set the radio bounds
                        radioButton.SetBounds(radioRect.X, radioRect.Y, radioRect.Width, radioRect.Height);

                        // sets the next radio location
                        radioRect.Y += radioLineSeperator + height;
                        i++;
                    }
                }
                return(false);
            }
Example #5
0
        /// <summary> implement placement</summary>
        public void layout(Control containerControl, LayoutEventArgs ea)
        {
            if (!CanPerformLayout(containerControl))
            {
                return;
            }

            containerControl.SuspendLayout();

            Rectangle rectangleToSave, newRect = rectangleToSave = GetBounds(_mainComposite);

            FixRuntimeDesignerPlacement(ref newRect);

            Point     actualPlacement = new Point(0, 0);
            int       deltaX = 0, deltaY = 0;
            ArrayList controlsList;

            bool compositeMoved = newRect.Width - _prevRect.Width != 0 || newRect.Height - _prevRect.Height != 0;

            if (compositeMoved)
            {
                deltaX = newRect.Width - _prevRect.Width;
                deltaY = newRect.Height - _prevRect.Height;

                // we have horizontal scrollbar and it will remain after placement
                if ((_prevRect.Width < _prevLogicalSize.X && newRect.Width < _prevLogicalSize.X) || _prevLogicalSize.X < 0)
                {
                    if (containerControl is ScrollableControl && ((ScrollableControl)containerControl).AutoScroll)
                    {
                        deltaX = 0;
                    }
                }

                if ((_prevRect.Height < _prevLogicalSize.Y && newRect.Height < _prevLogicalSize.Y) || _prevLogicalSize.Y < 0)
                {
                    // we have vertical scrollbar and it will remain after placement
                    deltaY = 0;
                }

                if (deltaX != 0 || deltaY != 0)
                {
                    actualPlacement = limitPlacement(containerControl, deltaX, deltaY, newRect);
                }
                Debug.Assert(!(IsTabControl(containerControl)));

                if (!(containerControl is TableControl))
                {
                    controlsList = GetControlsList(containerControl);

                    // execute placement
                    LogicalControlsContainer logicalControlsContainer = GetLogicalControlsContainer(containerControl);
                    if (logicalControlsContainer != null)
                    {
                        logicalControlsContainer.addChange(actualPlacement);
                    }
                    foreach (Object obj in controlsList)
                    {
#if PocketPC
                        // No placement for dummy control
                        if (containerControl is Panel && obj == ((Panel)containerControl).dummy)
                        {
                            continue;
                        }
#endif
                        ControlPlacement(obj, actualPlacement);
                    }

                    if (logicalControlsContainer.LogicalControls != null)
                    {
                        containerControl.Invalidate();
                    }
                }
            }

            _prevRect = rectangleToSave;
            if (isRTL(containerControl))
            {
                gui_upd_win_scroll_bars_hebrew(containerControl);
            }
            computeAndUpdateLogicalSize(containerControl);
            containerControl.ResumeLayout();
        }
Example #6
0
        /// <summary>
        /// </summary>
        /// <param name="container"></param>
        /// <param name="layoutEventArgs"></param>
        /// <returns></returns>
        public override bool Layout(object composite, LayoutEventArgs layoutEventArgs)
        {
            /// <summary> layout the MgSplitContainer and all his children</summary>
            //protected internal void layout(Composite composite, bool flushCache)
            //{
            MgSplitContainer mgSplitContainer = (MgSplitContainer)composite;

            //Sometime we need to ignore the layout, when we doing move to control
            if (mgSplitContainer.IgnoreLayout)
            {
                return(true);
            }

            double[] ratios       = null;
            int      totalOrgSize = 0;

            Rectangle clientArea = mgSplitContainer.ClientRectangle;

            if (clientArea.Width <= 1 || clientArea.Height <= 1)
            {
                return(false);
            }

            // get the controls on the mgSplitContainer (without the splitter, and only the visible)
            Control[] controls = mgSplitContainer.getControls(false);
            if (controls.Length == 0)
            {
                return(false);
            }
            //      if (allControlsHaveBounds(controls) == false)
            //         return;

            // check the splitter controls
            // checkSplitterControls(MgSplitContainer, controls);

            // check the direction shell was reduce or increased
            bool      parentReduced  = false;
            Rectangle lastClientArea = mgSplitContainer.LastClientArea;

            if (clientArea.Width < lastClientArea.Width || clientArea.Height < lastClientArea.Height)
            {
                parentReduced = true;
            }
            ((TagData)mgSplitContainer.Tag).RepaintRect = lastClientArea;

            // save the last client Area, for the next time
            mgSplitContainer.LastClientArea = GuiUtils.copyRect(clientArea);

            // get the array to the splitter controls
            Splitter[] splitters = new Splitter[mgSplitContainer.Splitters.Count];
            for (int i = 0; i < mgSplitContainer.Splitters.Count; i++)
            {
                Splitter s = mgSplitContainer.Splitters[i];
                splitters[i] = s;
            }

            //MOVE TO mgSplitContainer!!!
            // for the out most MgSplitContainer form we need to change the client rect, not to include the offset
            if (GuiUtils.isOutmostMgSplitContainer(mgSplitContainer))
            {
                clientArea.X      += (MgSplitContainer.SPLITTER_WIDTH / 2);
                clientArea.Y      += (MgSplitContainer.SPLITTER_WIDTH / 2);
                clientArea.Width  -= MgSplitContainer.SPLITTER_WIDTH;
                clientArea.Height -= MgSplitContainer.SPLITTER_WIDTH;
            }

            // check if we need to update the original size at the end of the method?
            bool saveSizeAtTheEnd = ratiosWillChange(parentReduced, mgSplitContainer.getOrientation(), controls);

            bool checkPlacement   = true;
            bool checkMinimumSize = parentReduced;
            bool calcByMinSize    = true;

            // get the dynamic client area by checking the placement & minimum size(only when we decrease)
            int areaS = calcAreaS(mgSplitContainer, clientArea, controls, splitters, checkPlacement, checkMinimumSize, false);

            // get the total minimum size by checking the placement & minimum size(only when we decrease)
            int totalMinimumSize = getTotalSizeOfControls(controls, mgSplitContainer.getOrientation(), true, calcByMinSize, checkPlacement, checkMinimumSize);

            // flag to set if we ignore the minimum size: Minimum size is ignored when
            // 1. increasing the size
            // or
            // 2. reducing the size and the total minimum size is greater than the dynamic client area
            //    and when we not on outmost MgSplitContainer
            bool ignoreMinSize = false;

            if (!GuiUtils.isOutmostMgSplitContainer(mgSplitContainer) && !GuiUtils.isDirectChildOfOutmostMgSplitContainer(mgSplitContainer))
            {
                ignoreMinSize = true;
            }

            checkPlacement   = false;
            checkMinimumSize = false;
            calcByMinSize    = false;
            if (areaS > 0)
            {
                if (!parentReduced)
                {
                    output(mgSplitContainer.getOrientation(), "Area ", "1");
                    // Check the placement property and ignore the minimum size
                    ignoreMinSize    = true;
                    checkPlacement   = true;
                    checkMinimumSize = false;
                }
                else if (areaS < totalMinimumSize)
                // parentReduced is true
                {
                    output(mgSplitContainer.getOrientation(), "Area ", "2");
                    // when reduce and the dynamic client area is > total minimum size we need to ignore also the
                    // placement and the minimum size, all the controls will be in the resize
                    ignoreMinSize    = true;
                    checkPlacement   = false;
                    checkMinimumSize = false;
                }
                else
                {
                    output(mgSplitContainer.getOrientation(), "Area ", "3");
                    // when parentReduced && areaS > totalMinimumSize, check the placement and minimum size
                    checkPlacement   = true;
                    checkMinimumSize = true;
                }
            }
            // If the dynamic client area is little than or equal to zero then
            // if (areaS <= 0)
            else
            {
                output(mgSplitContainer.getOrientation(), "Area ", "<0");
                output(mgSplitContainer.getOrientation(), "areaS < totalMinimumSize? ", " " + (areaS < totalMinimumSize));

                // when we on outmost MgSplitContainer :use the minimum sizes as the weights.
                if (GuiUtils.isOutmostMgSplitContainer(mgSplitContainer))
                {
                    Debug.Assert(false);
                    // output(mgSplitContainer.getOrientation(), "calByMinSize ", " " + calcByMinSize);
                    // checkPlacement = false;
                    // checkMinimumSize = false;
                    // calcByMinSize = true;
                }
                // when we not in outmost MgSplitContainer :save the size in the org size and cal with ignore all the
                // placemetn & min size
                // if (!GuiUtils.isOutmostMgSplitContainer(mgSplitContainer))
                else
                {
                    output(mgSplitContainer.getOrientation(), "calByMinSize ", " " + calcByMinSize);
                    checkPlacement   = false;
                    checkMinimumSize = false;
                    calcByMinSize    = false;
                }
            }

            // get the dynamic client area according to the init members
            areaS = calcAreaS(mgSplitContainer, clientArea, controls, splitters, checkPlacement, checkMinimumSize, calcByMinSize);
            // get the total size according to the init members
            totalOrgSize = getTotalSizeOfControls(controls, mgSplitContainer.getOrientation(), true, calcByMinSize, checkPlacement, checkMinimumSize);
            // get the ratios according to the init members
            ratios = calcRatios(controls, mgSplitContainer.getOrientation(), totalOrgSize, checkPlacement, checkMinimumSize, calcByMinSize, areaS, ref saveSizeAtTheEnd);

            output(mgSplitContainer.getOrientation(), "areaS ", " " + areaS);

            // 6. order the controls and splitters
            //TODOR: border is all the time 0 // int splitterWidth = splitters.Length > 0 ? MgSplitContainer.SPLITTER_WIDTH + splitters[0].getBorderWidth() * 2 : MgSplitContainer.SPLITTER_WIDTH;
            int splitterWidth = MgSplitContainer.SPLITTER_WIDTH;

            if (mgSplitContainer.getOrientation() == MgSplitContainer.SPLITTER_STYLE_HORIZONTAL)
            {
                int width = ratios[0] != -1 ? (int)(areaS * ratios[0]) : getOrgSize(controls[0]).X;
                if (!ignoreMinSize)
                {
                    width = Math.Max(width, getMinimunSize(controls[0]).X);
                }
                int x = clientArea.X;

                // fixed bug #:293109, while the user is do resize we need to save te bound
                GuiUtils.controlSetBounds(controls[0], x, clientArea.Y, (int)width, clientArea.Height);
                SetNewSaveBound(controls[0], x, clientArea.Y, (int)width, clientArea.Height);

                x += width;

                if (controls.Length > 1)
                {
                    ((TagData)splitters[splitters.Length - 1].Tag).RepaintRect = splitters[splitters.Length - 1].Bounds;
                    GuiUtils.controlSetBounds(splitters[splitters.Length - 1], x, clientArea.Y, splitterWidth, clientArea.Height);
                    x    += splitterWidth;
                    width = clientArea.Width - (x - clientArea.X);
                    if (!ignoreMinSize)
                    {
                        width = Math.Max(width, getMinimunSize(controls[controls.Length - 1]).X);
                    }

                    GuiUtils.controlSetBounds(controls[controls.Length - 1], x, clientArea.Y, width, clientArea.Height);
                    SetNewSaveBound(controls[controls.Length - 1], x, clientArea.Y, width, clientArea.Height);
                }
            }
            else if (mgSplitContainer.getOrientation() == MgSplitContainer.SPLITTER_STYLE_VERTICAL)
            {
                int height = ratios[0] != -1 ? (int)(areaS * ratios[0]) : getOrgSize(controls[0]).Y;
                if (!ignoreMinSize)
                {
                    height = Math.Max(height, getMinimunSize(controls[0]).Y);
                }

                int y = clientArea.Y;
                GuiUtils.controlSetBounds(controls[0], clientArea.X, clientArea.Y, clientArea.Width, height);
                SetNewSaveBound(controls[0], clientArea.X, clientArea.Y, clientArea.Width, height);
                y += height;

                if (controls.Length > 1)
                {
                    ((TagData)splitters[splitters.Length - 1].Tag).RepaintRect = splitters[splitters.Length - 1].Bounds;
                    GuiUtils.controlSetBounds(splitters[splitters.Length - 1], clientArea.X, y, clientArea.Width, splitterWidth);
                    SetNewSaveBound(splitters[splitters.Length - 1], clientArea.X, y, clientArea.Width, splitterWidth);

                    y     += splitterWidth;
                    height = clientArea.Height - (y - clientArea.Y);
                    if (!ignoreMinSize)
                    {
                        height = Math.Max(height, getMinimunSize(controls[controls.Length - 1]).Y);
                    }
                    GuiUtils.controlSetBounds(controls[controls.Length - 1], clientArea.X, y, clientArea.Width, height);
                    SetNewSaveBound(controls[controls.Length - 1], clientArea.X, y, clientArea.Width, height);
                }
            }

            if (saveSizeAtTheEnd)
            {
                for (int k = 0; k < controls.Length; k++)
                {
                    Rectangle rect = controls[k].Bounds;
                    setOrgSizeBy(controls[k], rect.Width, rect.Height);
                }
            }

            return(true);
        }
Example #7
0
 internal void LayoutHandler(object sender, LayoutEventArgs e)
 {
     handleEvent(EventType.LAYOUT, sender, e);
 }