Beispiel #1
0
        //ペインの分割
        public SplitResult SplitPane(IPane target, IPane newpane, Direction direction)
        {
            Debug.Assert(newpane.AsDotNet().Parent == null);

            //分割可能かどうかのチェック1 総数
            if (_count >= _countLimit)
            {
                return(SplitResult.F_TooManyPanes);
            }

            //分割可能かどうかのチェック2 分割対象が最小サイズを満たしているか
            if (SizeToLength(target.Size, direction) < _minimumEdgeLength * 2 + PaneSplitter.SPLITTER_WIDTH)
            {
                return(SplitResult.F_TooSmallToSplit);
            }

            Control parent         = target.AsDotNet().Parent;
            bool    splitting_root = _rootList == null;

            if (splitting_root)   //空の状態からの構築
            {
                _rootList = new DivisionList(this, null, direction, target, newpane, target.Size, target.Dock);
                UIUtil.ReplaceControl(parent, target.AsDotNet(), _rootList.HostingControl);
            }
            else
            {
                DivisionNode node = _rootList.FirstNode.FindNode(target);
                Debug.Assert(node != null);
                if (direction == node.ParentList.Direction)   //同方向分割
                {
                    bool eq = node.ParentList.IsEquallyDivided;
                    node.InsertNext(newpane);
                    if (eq)
                    {
                        node.ParentList.AdjustRatioEqually();
                    }
                }
                else   //異方向分割
                {
                    DivisionList newlist = new DivisionList(this, node, direction, target, newpane, target.Size, target.Dock);
                    node.ReplacePaneByChildList(newlist);
                }
            }

            Rebuild();
            DoLayout();
            FindForm().MinimumSize = _rootList.FirstNode.RequiredMinimumSize; //!!TODO これはコントロールのサイズであり、フォームボーダーとは別の話

            _count++;
            return(SplitResult.Success);
        }
Beispiel #2
0
        public IPane UnifyAll()
        {
            if (_rootList == null)
            {
                return(null);
            }

            IPane   r      = _rootList.FirstPane;
            Control parent = _rootList.HostingControl.Parent;

            UIUtil.ReplaceControl(parent, _rootList.HostingControl, r.AsDotNet());
            _rootList = null;
            _count    = 1;
            return(r);
        }
Beispiel #3
0
        //ペインを閉じて結合する。outの引数は次にフォーカスを与えるべきペイン
        public SplitResult UnifyPane(IPane target, out IPane nextfocus)
        {
            nextfocus = null; //失敗時にはクリアできるように
            Debug.Assert(_rootList != null);

            DivisionNode node          = _rootList.FirstNode.FindNode(target);
            bool         unifying_root = node.ParentList == _rootList && _rootList.NodeCount == 2; //結合の結果RootListが入れ替わる予定のとき
            Control      parent        = _rootList.HostingControl.Parent;

            if (unifying_root && _rootList.FirstNode.IsLast)
            {
                return(SplitResult.F_UnifySingle);
            }

            DivisionList list   = node.ParentList;
            DivisionNode active = list.Remove(node);

            if (list.NodeCount == 1) //こうなったときに面倒が発生
            {
                if (active.IsLeaf)   // (1) ペインであるとき
                {
                    IPane newpane = active.Pane;
                    Debug.Assert(newpane != null);
                    if (list.ParentNode == null)   //1-1
                    {
                        UIUtil.ReplaceControl(parent, list.HostingControl, newpane.AsDotNet());
                        _rootList = null;
                    }
                    else   //1-2
                    {
                        list.ParentNode.ReplaceChildListByPane(newpane);
                    }
                }
                else   // (2) ノードであるとき
                {
                    DivisionList newlist = active.ChildList;
                    if (list.ParentNode == null)   //2-1
                    {
                        _rootList = newlist;
                        newlist.ClearParentNode();
                        UIUtil.ReplaceControl(parent, list.HostingControl, newlist.HostingControl);
                    }
                    else                                              //2-2
                    {
                        DivisionList pp = list.ParentNode.ParentList; //長くなる方のリスト
                        Debug.Assert(pp.Direction == newlist.Direction);
                        pp.ReplaceNodeByList(list.ParentNode, newlist);
                    }
                }
            }

            if (_rootList != null)
            {
                Rebuild();
                DoLayout();
                FindForm().MinimumSize = _rootList.FirstNode.RequiredMinimumSize; //!!TODO Splitterだけで構成されていないフォームでアウト
            }

            _count--;
            nextfocus = active.IsLeaf ? active.Pane : active.ChildList.FirstPane;
            return(SplitResult.Success);
        }
Beispiel #4
0
        //�y�C���̕���
        public SplitResult SplitPane(IPane target, IPane newpane, Direction direction)
        {
            Debug.Assert(newpane.AsDotNet().Parent == null);

            //�����”\���ǂ����̃`�F�b�N1 ����
            if (_count >= _countLimit)
                return SplitResult.F_TooManyPanes;

            //�����”\���ǂ����̃`�F�b�N2 �����Ώۂ��ŏ��T�C�Y�𖞂����Ă��邩
            if (SizeToLength(target.Size, direction) < _minimumEdgeLength * 2 + PaneSplitter.SPLITTER_WIDTH)
                return SplitResult.F_TooSmallToSplit;

            Control parent = target.AsDotNet().Parent;
            bool splitting_root = _rootList == null;

            if (splitting_root) { //��̏�Ԃ���̍\�z
                _rootList = new DivisionList(this, null, direction, target, newpane, target.Size, target.Dock);
                UIUtil.ReplaceControl(parent, target.AsDotNet(), _rootList.HostingControl);
            }
            else {
                DivisionNode node = _rootList.FirstNode.FindNode(target);
                Debug.Assert(node != null);
                if (direction == node.ParentList.Direction) { //����������
                    bool eq = node.ParentList.IsEquallyDivided;
                    node.InsertNext(newpane);
                    if (eq)
                        node.ParentList.AdjustRatioEqually();
                }
                else { //�ٕ�������
                    DivisionList newlist = new DivisionList(this, node, direction, target, newpane, target.Size, target.Dock);
                    node.ReplacePaneByChildList(newlist);
                }
            }

            Rebuild();
            DoLayout();
            FindForm().MinimumSize = _rootList.FirstNode.RequiredMinimumSize; //!!TODO ����̓R���g���[���̃T�C�Y�ł���A�t�H�[���{�[�_�[�Ƃ͕ʂ̘b

            _count++;
            return SplitResult.Success;
        }
Beispiel #5
0
        //ペインの分割
        public SplitResult SplitPane(IPane target, IPane newpane, Direction direction) {
            Debug.Assert(newpane.AsDotNet().Parent == null);

            //分割可能かどうかのチェック1 総数
            if (_count >= _countLimit)
                return SplitResult.F_TooManyPanes;

            //分割可能かどうかのチェック2 分割対象が最小サイズを満たしているか
            if (SizeToLength(target.Size, direction) < _minimumEdgeLength * 2 + PaneSplitter.SPLITTER_WIDTH)
                return SplitResult.F_TooSmallToSplit;

            Control parent = target.AsDotNet().Parent;
            bool splitting_root = _rootList == null;

            if (splitting_root) { //空の状態からの構築
                _rootList = new DivisionList(this, null, direction, target, newpane, target.Size, target.Dock);
                UIUtil.ReplaceControl(parent, target.AsDotNet(), _rootList.HostingControl);
            }
            else {
                DivisionNode node = _rootList.FirstNode.FindNode(target);
                Debug.Assert(node != null);
                if (direction == node.ParentList.Direction) { //同方向分割
                    bool eq = node.ParentList.IsEquallyDivided;
                    node.InsertNext(newpane);
                    if (eq)
                        node.ParentList.AdjustRatioEqually();
                }
                else { //異方向分割
                    DivisionList newlist = new DivisionList(this, node, direction, target, newpane, target.Size, target.Dock);
                    node.ReplacePaneByChildList(newlist);
                }
            }

            Rebuild();
            DoLayout();
            FindForm().MinimumSize = _rootList.FirstNode.RequiredMinimumSize; //!!TODO これはコントロールのサイズであり、フォームボーダーとは別の話

            _count++;
            return SplitResult.Success;
        }