예제 #1
0
        private bool processFloating(MDIWindow source, float mouseX, float mouseY)
        {
            if ((source.AllowedDockLocations & DockLocation.Left) != 0)
            {
                MDIWindow window = left.findWindowAtPosition(mouseX, mouseY);
                if (window != null)
                {
                    dragTargetContainer = null;
                    dragTargetWindow    = window;
                    findWindowLanding(source, dragTargetWindow, mouseX, mouseY);
                    return(true);
                }
            }

            if ((source.AllowedDockLocations & DockLocation.Right) != 0)
            {
                MDIWindow window = right.findWindowAtPosition(mouseX, mouseY);
                if (window != null)
                {
                    dragTargetContainer = null;
                    dragTargetWindow    = window;
                    findWindowLanding(source, dragTargetWindow, mouseX, mouseY);
                    return(true);
                }
            }

            if ((source.AllowedDockLocations & DockLocation.Top) != 0)
            {
                MDIWindow window = top.findWindowAtPosition(mouseX, mouseY);
                if (window != null)
                {
                    dragTargetContainer = null;
                    dragTargetWindow    = window;
                    findWindowLanding(source, dragTargetWindow, mouseX, mouseY);
                    return(true);
                }
            }

            if ((source.AllowedDockLocations & DockLocation.Bottom) != 0)
            {
                MDIWindow window = bottom.findWindowAtPosition(mouseX, mouseY);
                if (window != null)
                {
                    dragTargetContainer = null;
                    dragTargetWindow    = window;
                    findWindowLanding(source, dragTargetWindow, mouseX, mouseY);
                    return(true);
                }
            }

            if ((source.AllowedDockLocations & DockLocation.Floating) != 0)
            {
                windowTargetWidget.Visible = false;
                dragTargetContainer        = floating;
                dragTargetWindow           = null;
                return(true);
            }
            return(false);
        }
예제 #2
0
 private bool processCenter(MDIWindow source, float mouseX, float mouseY)
 {
     dragTargetContainer = null;
     if ((source.AllowedDockLocations & DockLocation.Center) == 0)
     {
         dragTargetWindow = null;
         return(false);
     }
     dragTargetWindow = documentArea.findWindowAtPosition(mouseX, mouseY);
     findWindowLanding(source, dragTargetWindow, mouseX, mouseY);
     return(true);
 }
예제 #3
0
        private bool checkContainerWidget(Widget widget, MDIChildContainerBase targetContainer, MDIWindow window, DockLocation dockLocation, float x, float y)
        {
            if (widget.Visible)
            {
                float left   = widget.AbsoluteLeft;
                float top    = widget.AbsoluteTop;
                float right  = left + widget.Width;
                float bottom = top + widget.Height;
                if (x > left && x < right && y > top && y < bottom)
                {
                    dragTargetContainer = targetContainer;
                    dragTargetWindow    = null;

                    windowTargetWidget.Visible = true;
                    switch (dockLocation)
                    {
                    case DockLocation.Left:
                        windowTargetWidget.setCoord((int)Location.x, (int)Location.y, (int)window.DesiredSize.Width, (int)WorkingSize.Height);
                        break;

                    case DockLocation.Right:
                        float width = window.DesiredSize.Width;
                        windowTargetWidget.setCoord((int)(WorkingSize.Width - width + Location.x), (int)Location.y, (int)width, (int)WorkingSize.Height);
                        break;

                    case DockLocation.Top:
                        windowTargetWidget.setCoord((int)Location.x, (int)Location.y, (int)WorkingSize.Width, (int)window.DesiredSize.Height);
                        break;

                    case DockLocation.Bottom:
                        float height = window.DesiredSize.Height;
                        windowTargetWidget.setCoord((int)Location.x, (int)(WorkingSize.Height - height + Location.y), (int)WorkingSize.Width, (int)height);
                        break;
                    }

                    return(true);
                }
            }
            return(false);
        }
예제 #4
0
        public void windowDragStarted(MDIWindow source, float mouseX, float mouseY)
        {
            dragSourceWindow    = source;
            dragTargetWindow    = null;
            dragTargetContainer = null;

            if ((source.AllowedDockLocations & DockLocation.Left) != 0)
            {
                int x = (int)(left.DesiredSize.Width / 2 + Location.x);
                int y = (int)WorkingSize.Height / 2;
                leftContainerWidget.setPosition(x, y);
                leftContainerWidget.Visible = true;
            }

            if ((source.AllowedDockLocations & DockLocation.Right) != 0)
            {
                int x = (int)(right.DesiredSize.Width / 2 + right.Location.x - rightContainerWidget.Width);
                int y = (int)WorkingSize.Height / 2;
                rightContainerWidget.setPosition(x, y);
                rightContainerWidget.Visible = true;
            }

            if ((source.AllowedDockLocations & DockLocation.Top) != 0)
            {
                int x = (int)WorkingSize.Width / 2;
                int y = (int)(top.DesiredSize.Height / 2 + Location.y);
                topContainerWidget.setPosition(x, y);
                topContainerWidget.Visible = true;
            }

            if ((source.AllowedDockLocations & DockLocation.Bottom) != 0)
            {
                int x = (int)WorkingSize.Width / 2;
                int y = (int)(bottom.DesiredSize.Width / 2 + bottom.Location.y - bottomContainerWidget.Width);
                bottomContainerWidget.setPosition(x, y);
                bottomContainerWidget.Visible = true;
            }
        }
예제 #5
0
        /// <summary>
        /// Add a child to a specific place with a specific alignment to the
        /// container. This method will create subcontainers as needed to get
        /// the layout desired.
        /// </summary>
        /// <param name="child">The child to add.</param>
        /// <param name="previous">The window to add the child relative to.</param>
        /// <param name="alignment">The alignment of child to previous.</param>
        public override void addChild(MDIWindow child, MDIWindow previous, WindowAlignment alignment)
        {
            switch (alignment)
            {
            case WindowAlignment.Left:
                if (previous._ParentContainer.Layout == MDILayoutContainer.LayoutType.Horizontal)
                {
                    //The child can simply be appended.
                    previous._ParentContainer.insertChild(child, previous, false);
                }
                else
                {
                    //The child needs a new subcontainer created.
                    MDILayoutContainer    newContainer    = new MDILayoutContainerScale(MDILayoutContainer.LayoutType.Horizontal, Padding, CurrentDockLocation);
                    MDIChildContainerBase parentContainer = previous._ParentContainer;
                    parentContainer.swapAndRemove(newContainer, previous);
                    newContainer.addChild(child);
                    newContainer.addChild(previous);
                }
                break;

            case WindowAlignment.Right:
                if (previous._ParentContainer.Layout == MDILayoutContainer.LayoutType.Horizontal)
                {
                    //The child can simply be appended.
                    previous._ParentContainer.insertChild(child, previous, true);
                }
                else
                {
                    //The child needs a new subcontainer created.
                    MDILayoutContainer    newContainer    = new MDILayoutContainerScale(MDILayoutContainer.LayoutType.Horizontal, Padding, CurrentDockLocation);
                    MDIChildContainerBase parentContainer = previous._ParentContainer;
                    parentContainer.swapAndRemove(newContainer, previous);
                    newContainer.addChild(previous);
                    newContainer.addChild(child);
                }
                break;

            case WindowAlignment.Top:
                if (previous._ParentContainer.Layout == MDILayoutContainer.LayoutType.Vertical)
                {
                    //The child can simply be appended.
                    previous._ParentContainer.insertChild(child, previous, false);
                }
                else
                {
                    //The child needs a new subcontainer created.
                    MDILayoutContainer    newContainer    = new MDILayoutContainerScale(MDILayoutContainer.LayoutType.Vertical, Padding, CurrentDockLocation);
                    MDIChildContainerBase parentContainer = previous._ParentContainer;
                    parentContainer.swapAndRemove(newContainer, previous);
                    newContainer.addChild(child);
                    newContainer.addChild(previous);
                }
                break;

            case WindowAlignment.Bottom:
                if (previous._ParentContainer.Layout == MDILayoutContainer.LayoutType.Vertical)
                {
                    //The child can simply be appended.
                    previous._ParentContainer.insertChild(child, previous, true);
                }
                else
                {
                    //The child needs a new subcontainer created.
                    MDILayoutContainer    newContainer    = new MDILayoutContainerScale(MDILayoutContainer.LayoutType.Vertical, Padding, CurrentDockLocation);
                    MDIChildContainerBase parentContainer = previous._ParentContainer;
                    parentContainer.swapAndRemove(newContainer, previous);
                    newContainer.addChild(previous);
                    newContainer.addChild(child);
                }
                break;
            }
        }