Ejemplo n.º 1
0
        /// <summary>
        /// Hides the notebook and switches to paned mode
        /// </summary>
        /// <param name='newalign'>
        /// Newalign.
        /// </param>
        public void hideNotebook(ItemAlignment newalign)
        {
            List <Widget> widgets = new List <Widget>(20);

            for (int i = (notebook.NPages - 1); i > -1; i--)
            {
                Widget w = notebook.GetNthPage(i);
                notebook.RemovePage(i);
                w.Parent = null;
                widgets.Add(w);
            }


            notebook.Visible = false;
            PanedBox.removeItem(notebook);

            foreach (Widget w in widgets)
            {
                DockItemContainer dc = w as DockItemContainer;
                if (dc != null)
                {
                    dc.CurrentContainer = null;
                    addItem(dc, newalign);
                }
            }

            Mode = ViewMode.PanedBox;
        }
Ejemplo n.º 2
0
        public void addPage(DockItemContainer itemcontainer, ItemAlignment align)
        {
            if ((itemcontainer.CurrentContainer != null) && (itemcontainer.CurrentContainer == this))
            {
                if (align != ItemAlignment.Center)
                {
                    if (notebook.Visible)
                    {
                        hideNotebook(align);
                        //setAlign(align);
                        return;
                    }
                }

//				if (align == ItemAlignment.Center)
//				{
//					addPages();
//					return;
//				}
            }
            else
            {
                itemcontainer.CurrentContainer = this;

                String title = itemcontainer.Name;
                if (itemcontainer.CurrentWidget != null)
                {
                    if (itemcontainer.CurrentWidget is DockableWidget)
                    {
                        if (!String.IsNullOrEmpty(((DockableWidget)itemcontainer.CurrentWidget).Title))
                        {
                            title = ((DockableWidget)itemcontainer.CurrentWidget).Title;
                        }
                    }
                }

                Gtk.Label lbl = new Gtk.Label(title);
                notebook.InsertPage(itemcontainer, lbl, notebook.NPages + 1);
            }

            if (OnItemAdded != null)
            {
                OnItemAdded(itemcontainer.CurrentWidget, new EventArgs());
            }
        }
Ejemplo n.º 3
0
        public void addItem(DockItemContainer item, ItemAlignment align, bool left = false)
        {
            items.Add(item);

            DockFramePosition pos = DockFramePosition.None;

            if (lastposition.ContainsKey(item.CurrentWidget.GetType().ToString()))
            {
                pos = lastposition[item.CurrentWidget.GetType().ToString()];
            }

            switch (pos)
            {
            case DockFramePosition.Left:
                left = true;
                break;

            case DockFramePosition.Right:
                left = false;
                break;
            }

            if (left)
            {
                if (dock1.Mode == ViewMode.Notebook)
                {
                    dock1.addPage(item, align);
                }
                else
                {
                    dock1.addItem(item, align);
                }
            }
            else
            {
                if (dock2.Mode == ViewMode.Notebook)
                {
                    dock2.addPage(item, align);
                }
                else
                {
                    dock2.addItem(item, align);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// adds a new item to the itemcontainer
        /// </summary>
        /// <param name='itemcontainer'>
        /// Itemcontainer.
        /// </param>
        /// <param name='align'>
        /// Align.
        /// </param>
        public void addItem(DockItemContainer itemcontainer, ItemAlignment align)
        {
            if ((itemcontainer.CurrentWidget != null) && (itemcontainer.CurrentWidget is DockcontainerWidget))
            {
                if (this == (itemcontainer.CurrentWidget as DockcontainerWidget).Dock)
                {
                    return;
                }
            }

            //itemcontainer.ParentWindow
            if ((itemcontainer.CurrentContainer != null) && (itemcontainer.CurrentContainer == this))
            {
                //containing this item
                if (align != ItemAlignment.Center)
                {
                    if (notebook.Visible)
                    {
                        hideNotebook(align);
                        setAlign(align);
                        return;
                    }
                }

                if (align == ItemAlignment.Center)
                {
                    addPages();
                    return;
                }
            }
            else
            {
                //Console.WriteLine("add new item: " + itemcontainer.Name);
                //add a new item
                itemcontainer.CurrentContainer = this;
                AddItem(itemcontainer);
                setAlign(align);
            }

            if (OnItemAdded != null)
            {
                OnItemAdded(itemcontainer.CurrentWidget, new EventArgs());
            }
        }         //addItem
Ejemplo n.º 5
0
        }         //addItem

        /// <summary>
        /// sets the align for all panedboxes
        /// </summary>
        /// <param name='align'>
        /// Align.
        /// </param>
        private void setAlign(ItemAlignment align)
        {
            switch (align)
            {
            case ItemAlignment.Top:
                if (Orientation == Orientation.Horizontal)
                {
                    Orientation = Orientation.Vertical;
                }
                //PackStart(itemcontainer,true,true,0);
                break;

            case ItemAlignment.Left:
                if (Orientation == Orientation.Vertical)
                {
                    Orientation = Orientation.Horizontal;
                }
                //PackStart(itemcontainer,true,true,0);
                break;

            case ItemAlignment.Right:
                if (Orientation == Orientation.Vertical)
                {
                    Orientation = Orientation.Horizontal;
                }
                //PackEnd(itemcontainer,true,true,0);
                break;

            case ItemAlignment.Bottom:
                if (Orientation == Orientation.Horizontal)
                {
                    Orientation = Orientation.Vertical;
                }
                //PackEnd(itemcontainer,true,true,0);
                break;

            case ItemAlignment.Center:
                addPages();
                break;

            default:
                break;
            }
        }
Ejemplo n.º 6
0
 public TextBoxExItem(Image image, ItemAlignment align)
 {
     Image     = image;
     Alignment = align;
 }
Ejemplo n.º 7
0
        protected void setPlaceholderWindowsize(int cX, int cY)
        {
            List<Widget> lst = new List<Widget>(100);
              addChildren(this,lst); //recursiv add all children in the list
              targetContainer = null;
            bool done = false;

            //foreach(Widget w in lst)
            for (int i=lst.Count-1;i>-1;i--)
              {
                    Widget w = lst[i];

                //Console.WriteLine("fe: " + w.Name);
                int rx = 0;
                int ry = 0;

                int sx,sy;
                this.Window.GetOrigin (out sx, out sy);
                if (w.Window != null)
                {
                    //Console.WriteLine("window:" + w.Window.ToString() + " sx: " + sx + " sy: " + sy);
                    w.Window.GetOrigin(out rx,out ry);
                    rx = rx - sx; //x of widget relativ to window
                    ry = ry - sy; //y of widget relative to window

                     if ( (rx <= cX) && (cX <= (rx+w.Allocation.Width)))
                     {
                        if ((ry <= cY) && (cY <= (ry+w.Allocation.Height)))
                        {
                          if (w is DockContainer)
                          {
                            //Console.WriteLine("tc:" + w.Name);
                            targetContainer = (DockContainer)w;
                            if (placeholderwindow != null)
                            {
                              int wd = w.Allocation.Width;
                              int wh = w.Allocation.Height / 2;
                              int wx = rx + sx;
                              int wy = ry + sy;

                              targetAlign = getAlignment(rx,ry,cX,cY,w.Allocation.Width,w.Allocation.Height);

                              //bool alignChanged = placeholderwindow.Alignment != targetAlign;
                              placeholderwindow.Alignment = targetAlign;
                              switch (targetAlign)
                              {
                                        case ItemAlignment.Top:
                                            wh = w.Allocation.Height / 3;
                                            break;
                                        case ItemAlignment.Left:
                                            wh = w.Allocation.Height;
                                            wd = w.Allocation.Width /3;
                                            break;
                                        case ItemAlignment.Right:
                                            wh = w.Allocation.Height;
                                            wd = w.Allocation.Width /3;
                                            wx = wx + (w.Allocation.Width -wd);
                                            break;
                                        case ItemAlignment.Bottom:
                                            wh = w.Allocation.Height / 3;
                                            wy = wy + (w.Allocation.Height - wh);
                                            break;
                                        case ItemAlignment.Center:
                                            wh = w.Allocation.Height / 3;
                                            wd = w.Allocation.Width / 3;
                                            wx = wx + wd;
                                            wy = wy + wh;
                                            break;
                                        default:
                                            break;
                              }

                              //if (alignChanged) {
                              placeholderwindow.Move(wx,wy);
                              placeholderwindow.Resize(wd,wh);
                              done = true;
                            //		}
                            }
                          }
                        }
                     }
                }

                if (done)
                {
                    break;
                }
              } //foreach
        }
Ejemplo n.º 8
0
        public void addItem(DockItemContainer item,ItemAlignment align,bool left=false)
        {
            items.Add(item);

            DockFramePosition pos = DockFramePosition.None;
            if (lastposition.ContainsKey(item.CurrentWidget.GetType().ToString()))
            {
                pos = lastposition[item.CurrentWidget.GetType().ToString()];
            }

            switch (pos) {
                case DockFramePosition.Left:
                    left = true;
                    break;
                case DockFramePosition.Right:
                    left = false;
                    break;
            }

            if (left)
            {
                if (dock1.Mode == ViewMode.Notebook)
                {
                    dock1.addPage(item,align);
                } else {
                  dock1.addItem(item,align);
                }
            } else
            {
                if (dock2.Mode == ViewMode.Notebook)
                {
                    dock2.addPage(item,align);
                } else {
                  dock2.addItem(item,align);
                }
            }
        }
Ejemplo n.º 9
0
        protected void setPlaceholderWindowsize(int cX, int cY)
        {
            List <Widget> lst = new List <Widget>(100);

            addChildren(this, lst);      //recursiv add all children in the list
            targetContainer = null;
            bool done = false;

            //foreach(Widget w in lst)
            for (int i = lst.Count - 1; i > -1; i--)
            {
                Widget w = lst[i];

                //Console.WriteLine("fe: " + w.Name);
                int rx = 0;
                int ry = 0;

                int sx, sy;
                this.Window.GetOrigin(out sx, out sy);
                if (w.Window != null)
                {
                    //Console.WriteLine("window:" + w.Window.ToString() + " sx: " + sx + " sy: " + sy);
                    w.Window.GetOrigin(out rx, out ry);
                    rx = rx - sx;                     //x of widget relativ to window
                    ry = ry - sy;                     //y of widget relative to window

                    if ((rx <= cX) && (cX <= (rx + w.Allocation.Width)))
                    {
                        if ((ry <= cY) && (cY <= (ry + w.Allocation.Height)))
                        {
                            if (w is DockContainer)
                            {
                                //Console.WriteLine("tc:" + w.Name);
                                targetContainer = (DockContainer)w;
                                if (placeholderwindow != null)
                                {
                                    int wd = w.Allocation.Width;
                                    int wh = w.Allocation.Height / 2;
                                    int wx = rx + sx;
                                    int wy = ry + sy;

                                    targetAlign = getAlignment(rx, ry, cX, cY, w.Allocation.Width, w.Allocation.Height);

                                    //bool alignChanged = placeholderwindow.Alignment != targetAlign;
                                    placeholderwindow.Alignment = targetAlign;
                                    switch (targetAlign)
                                    {
                                    case ItemAlignment.Top:
                                        wh = w.Allocation.Height / 3;
                                        break;

                                    case ItemAlignment.Left:
                                        wh = w.Allocation.Height;
                                        wd = w.Allocation.Width / 3;
                                        break;

                                    case ItemAlignment.Right:
                                        wh = w.Allocation.Height;
                                        wd = w.Allocation.Width / 3;
                                        wx = wx + (w.Allocation.Width - wd);
                                        break;

                                    case ItemAlignment.Bottom:
                                        wh = w.Allocation.Height / 3;
                                        wy = wy + (w.Allocation.Height - wh);
                                        break;

                                    case ItemAlignment.Center:
                                        wh = w.Allocation.Height / 3;
                                        wd = w.Allocation.Width / 3;
                                        wx = wx + wd;
                                        wy = wy + wh;
                                        break;

                                    default:
                                        break;
                                    }

                                    //if (alignChanged) {
                                    placeholderwindow.Move(wx, wy);
                                    placeholderwindow.Resize(wd, wh);
                                    done = true;
                                    //		}
                                }
                            }
                        }
                    }
                }

                if (done)
                {
                    break;
                }
            }               //foreach
        }
Ejemplo n.º 10
0
 /// <summary>
 /// sets the align for all panedboxes
 /// </summary>
 /// <param name='align'>
 /// Align.
 /// </param>
 private void setAlign(ItemAlignment align)
 {
     switch (align)
     {
         case ItemAlignment.Top:
             if (Orientation == Orientation.Horizontal)
             {
                 Orientation = Orientation.Vertical;
             }
             //PackStart(itemcontainer,true,true,0);
             break;
         case ItemAlignment.Left:
             if (Orientation == Orientation.Vertical)
             {
                 Orientation = Orientation.Horizontal;
             }
             //PackStart(itemcontainer,true,true,0);
             break;
         case ItemAlignment.Right:
             if (Orientation == Orientation.Vertical)
             {
                 Orientation = Orientation.Horizontal;
             }
             //PackEnd(itemcontainer,true,true,0);
             break;
         case ItemAlignment.Bottom:
             if (Orientation == Orientation.Horizontal)
             {
                 Orientation = Orientation.Vertical;
             }
             //PackEnd(itemcontainer,true,true,0);
             break;
         case ItemAlignment.Center:
             addPages();
             break;
         default:
             break;
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Hides the notebook and switches to paned mode
        /// </summary>
        /// <param name='newalign'>
        /// Newalign.
        /// </param>
        public void hideNotebook(ItemAlignment newalign)
        {
            List<Widget> widgets = new List<Widget>(20);

            for (int i=(notebook.NPages-1);i>-1;i--)
            {
                Widget w = notebook.GetNthPage(i);
                notebook.RemovePage(i);
                w.Parent = null;
                widgets.Add(w);
            }

            notebook.Visible = false;
            PanedBox.removeItem(notebook);

            foreach (Widget w in widgets)
            {
                DockItemContainer dc = w as DockItemContainer;
                if (dc != null)
                {
                    dc.CurrentContainer = null;
                    addItem(dc,newalign);
                }
            }

            Mode = ViewMode.PanedBox;
        }
Ejemplo n.º 12
0
        public void addPage(DockItemContainer itemcontainer, ItemAlignment align)
        {
            if ((itemcontainer.CurrentContainer != null) && (itemcontainer.CurrentContainer == this))
            {
                if (align != ItemAlignment.Center)
                {
                    if (notebook.Visible)
                    {
                        hideNotebook(align);
                        //setAlign(align);
                        return;
                    }
                }

            //				if (align == ItemAlignment.Center)
            //				{
            //					addPages();
            //					return;
            //				}
            } else
            {
                itemcontainer.CurrentContainer = this;

                String title = itemcontainer.Name;
                if (itemcontainer.CurrentWidget != null)
                {
                    if (itemcontainer.CurrentWidget is DockableWidget)
                    {
                        if (!String.IsNullOrEmpty(((DockableWidget)itemcontainer.CurrentWidget).Title))
                        {
                            title = ((DockableWidget)itemcontainer.CurrentWidget).Title;
                        }
                    }
                }

                Gtk.Label lbl = new Gtk.Label(title);
                notebook.InsertPage(itemcontainer,lbl,notebook.NPages+1);
            }

            if (OnItemAdded != null)
            {
                OnItemAdded(itemcontainer.CurrentWidget,new EventArgs());
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// adds a new item to the itemcontainer
        /// </summary>
        /// <param name='itemcontainer'>
        /// Itemcontainer.
        /// </param>
        /// <param name='align'>
        /// Align.
        /// </param>
        public void addItem(DockItemContainer itemcontainer, ItemAlignment align)
        {
            if ((itemcontainer.CurrentWidget != null) && (itemcontainer.CurrentWidget is DockcontainerWidget))
            {
                if (this == (itemcontainer.CurrentWidget as DockcontainerWidget).Dock)
                {
                    return;
                }
            }

            //itemcontainer.ParentWindow
            if ((itemcontainer.CurrentContainer != null) && (itemcontainer.CurrentContainer == this))
            {
                //containing this item
                if (align != ItemAlignment.Center)
                {
                    if (notebook.Visible)
                    {
                        hideNotebook(align);
                        setAlign(align);
                        return;
                    }
                }

                if (align == ItemAlignment.Center)
                {
                    addPages();
                    return;
                }
            } else
            {
                //Console.WriteLine("add new item: " + itemcontainer.Name);
                //add a new item
                itemcontainer.CurrentContainer = this;
                AddItem(itemcontainer);
                setAlign(align);
            }

            if (OnItemAdded != null)
            {
                OnItemAdded(itemcontainer.CurrentWidget,new EventArgs());
            }
        }