Exemplo n.º 1
0
        public Dock(Dock original, bool floating, int x, int y, int width, int height)
        {
            floatX = x;
            floatY = y;
            this.width = width;
            this.height = height;
            this.floating = floating;

            SetFlag (WidgetFlags.NoWindow);
            if (original != null)
                Bind (original.Master);

            /* create a master for the dock if none was provided */
            if (Master == null) {
                DockObjectFlags &= ~(DockObjectFlags.Automatic);
                Bind (new DockMaster ());
            }

            if (floating) {
                /* create floating window for this dock */
                window = new Window (WindowType.Toplevel);
                Window wnd = window as Window;

                /* set position and default size */
                wnd.WindowPosition = WindowPosition.Mouse;
                wnd.SetDefaultSize (width, height);
                wnd.TypeHint = Gdk.WindowTypeHint.Normal;

                /* metacity ignores this */
                wnd.Move (floatX, floatY);

                /* connect to the configure event so we can track down window geometry */
                wnd.ConfigureEvent += new ConfigureEventHandler (OnFloatingConfigure);

                /* set the title */
                SetWindowTitle ();

                /* set transient for the first dock if that is a non-floating dock */
                DockObject controller = Master.Controller;
                if (controller != null && controller is Dock) {
                    if (!((Dock)controller).Floating) {
                        if (controller.Toplevel != null && controller.Toplevel is Window) {
                            wnd.TransientFor = (Window)controller.Toplevel;
                        }
                    }
                }

                wnd.Add (this);
                wnd.DeleteEvent += new DeleteEventHandler (OnFloatingDelete);
            }

            DockObjectFlags |= DockObjectFlags.Attached;
        }
        public void Attach(IWorkbench wb)
        {
            DefaultWorkbench workbench = (DefaultWorkbench) wb;

            this.workbench = workbench;
            wbWindow = (Window) workbench;

            Gtk.VBox vbox = new VBox (false, 0);
            rootWidget = vbox;

            vbox.PackStart (workbench.TopMenu, false, false, 0);

            toolbarFrame = new CommandFrame (Runtime.Gui.CommandService.CommandManager);
            vbox.PackStart (toolbarFrame, true, true, 0);

            if (workbench.ToolBars != null) {
                for (int i = 0; i < workbench.ToolBars.Length; i++) {
                    toolbarFrame.AddBar ((DockToolbar)workbench.ToolBars[i]);
                }
            }

            // Create the docking widget and add it to the window.
            dock = new Dock ();
            DockBar dockBar = new DockBar (dock);
            Gtk.HBox dockBox = new HBox (false, 5);
            dockBox.PackStart (dockBar, false, true, 0);
            dockBox.PackStart (dock, true, true, 0);
            toolbarFrame.AddContent (dockBox);

            // Create the notebook for the various documents.
            tabControl = new DragNotebook ();
            tabControl.Scrollable = true;
            tabControl.SwitchPage += new SwitchPageHandler (ActiveMdiChanged);
            tabControl.TabsReordered += new TabsReorderedHandler (OnTabsReordered);
            DockItem item = new DockItem ("Documents", "Documents",
                              DockItemBehavior.Locked | DockItemBehavior.NoGrip);
            item.PreferredWidth = -2;
            item.PreferredHeight = -2;
            item.Add (tabControl);
            item.Show ();
            dock.AddItem (item, DockPlacement.Center);

            workbench.Add (vbox);

            vbox.PackEnd (Runtime.Gui.StatusBar.Control, false, true, 0);
            workbench.ShowAll ();

            foreach (IViewContent content in workbench.ViewContentCollection)
                ShowView (content);

            // by default, the active pad collection is the full set
            // will be overriden in CreateDefaultLayout() below
            activePadCollection = workbench.PadContentCollection;

            // create DockItems for all the pads
            foreach (IPadContent content in workbench.PadContentCollection)
            {
                AddPad (content, content.DefaultPlacement);
            }

            CreateDefaultLayout();
            //RedrawAllComponents();
            wbWindow.Show ();

            workbench.ContextChanged += contextChangedHandler;
        }
Exemplo n.º 3
0
 public DockBar(Dock dock)
 {
     items  = new ArrayList();
     Master = dock.Master;
 }
Exemplo n.º 4
0
        public void Bind(Dock dock)
        {
            if (dock == null)
                return;

            Bind (dock.Master);
        }
Exemplo n.º 5
0
        private void OnDragMotion(DockItem item, int rootX, int rootY)
        {
            Dock dock = null;
            int winX, winY;
            int x, y;
            bool mayDock = false;
            DockRequest myRequest = new DockRequest (request);

            if (item != request.Applicant)  {
                Console.WriteLine ("Dragged item is not the same as the one we started with");
                return;
            }

            /* first look under the pointer */
            Gdk.Window window = Gdk.Window.AtPointer (out winX, out winY);
            if (window != null && window.UserData != IntPtr.Zero) {
                /* ok, now get the widget who owns that window and see if we can
                   get to a Dock by walking up the hierarchy */
                Widget widget = GLib.Object.GetObject (window.UserData, false) as Widget;
                while (widget != null && (!(widget is Dock) ||
                       (widget is DockObject && ((DockObject)widget).Master != this)))
                        widget = widget.Parent;

                if (widget != null) {
                    int winW, winH, depth;

                    /* verify that the pointer is still in that dock
                       (the user could have moved it) */
                    widget.GdkWindow.GetGeometry (out winX, out winY,
                                      out winW, out winH,
                                      out depth);
                    widget.GdkWindow.GetOrigin (out winX, out winY);
                    if (rootX >= winX && rootX < winX + winW &&
                        rootY >= winY && rootY < winY + winH)
                        dock = widget as Dock;
                }
            }

            if (dock != null) {
                /* translate root coordinates into dock object coordinates
                   (i.e. widget coordinates) */
                dock.GdkWindow.GetOrigin (out winX, out winY);
                x = rootX - winX;
                y = rootY - winY;
                mayDock = dock.OnDockRequest (x, y, ref myRequest);
            } else {
                /* try to dock the item in all the docks in the ring in turn */
                foreach (Dock topDock in toplevelDocks) {
                    if (topDock.GdkWindow == null)
                        Console.WriteLine ("Dock has no GdkWindow: {0}, {1}", topDock.Name, topDock);
                    /* translate root coordinates into dock object
                       coordinates (i.e. widget coordinates) */
                    topDock.GdkWindow.GetOrigin (out winX, out winY);
                    x = rootX - winX;
                    y = rootY - winY;
                    mayDock = topDock.OnDockRequest (x, y, ref myRequest);
                    if (mayDock)
                        break;
                }
            }

            if (!mayDock) {
                dock = null;

                myRequest.Target = Dock.GetTopLevel (item);
                myRequest.Position = DockPlacement.Floating;
                Requisition preferredSize = item.PreferredSize;
                myRequest.Width = preferredSize.Width;
                myRequest.Height = preferredSize.Height;
                myRequest.X = rootX - item.DragOffX;
                myRequest.Y = rootY - item.DragOffY;

                Gdk.Rectangle rect = new Gdk.Rectangle (myRequest.X,
                                    myRequest.Y,
                                    myRequest.Width,
                                    myRequest.Height);

                // setup extra docking information
                myRequest.Extra = rect;
            }

            if (!(myRequest.X == request.X &&
                  myRequest.Y == request.Y &&
                  myRequest.Width == request.Width &&
                  myRequest.Height == request.Height &&
                  dock == rectOwner)) {

                /* erase the previous rectangle */
                if (rectDrawn)
                    XorRect ();
            }

            // set the new values
            request = myRequest;
            rectOwner = dock;

            /* draw the previous rectangle */
            if (!rectDrawn)
                XorRect ();
        }
Exemplo n.º 6
0
        private void OnDragBegin(DockItem item)
        {
            /* Set the target to itself so it won't go floating with just a click. */
            request = new DockRequest ();
            request.Applicant = item;
            request.Target = item;
            request.Position = DockPlacement.Floating;
            request.Extra = IntPtr.Zero;

            rectDrawn = false;
            rectOwner = null;
        }
Exemplo n.º 7
0
        private void OnDragMotion(DockItem item, int rootX, int rootY)
        {
            Dock        dock = null;
            int         winX, winY;
            int         x, y;
            bool        mayDock   = false;
            DockRequest myRequest = new DockRequest(request);

            if (item != request.Applicant)
            {
                Console.WriteLine("Dragged item is not the same as the one we started with");
                return;
            }

            /* first look under the pointer */
            Gdk.Window window = Gdk.Window.AtPointer(out winX, out winY);
            if (window != null && window.UserData != IntPtr.Zero)
            {
                /* ok, now get the widget who owns that window and see if we can
                 * get to a Dock by walking up the hierarchy */
                Widget widget = GLib.Object.GetObject(window.UserData, false) as Widget;
                while (widget != null && (!(widget is Dock) ||
                                          (widget is DockObject && ((DockObject)widget).Master != this)))
                {
                    widget = widget.Parent;
                }

                if (widget != null)
                {
                    int winW, winH, depth;

                    /* verify that the pointer is still in that dock
                     * (the user could have moved it) */
                    widget.GdkWindow.GetGeometry(out winX, out winY,
                                                 out winW, out winH,
                                                 out depth);
                    widget.GdkWindow.GetOrigin(out winX, out winY);
                    if (rootX >= winX && rootX < winX + winW &&
                        rootY >= winY && rootY < winY + winH)
                    {
                        dock = widget as Dock;
                    }
                }
            }

            if (dock != null)
            {
                /* translate root coordinates into dock object coordinates
                 * (i.e. widget coordinates) */
                dock.GdkWindow.GetOrigin(out winX, out winY);
                x       = rootX - winX;
                y       = rootY - winY;
                mayDock = dock.OnDockRequest(x, y, ref myRequest);
            }
            else
            {
                /* try to dock the item in all the docks in the ring in turn */
                foreach (Dock topDock in toplevelDocks)
                {
                    if (topDock.GdkWindow == null)
                    {
                        Console.WriteLine("Dock has no GdkWindow: {0}, {1}", topDock.Name, topDock);
                    }

                    /* translate root coordinates into dock object
                     * coordinates (i.e. widget coordinates) */
                    topDock.GdkWindow.GetOrigin(out winX, out winY);
                    x       = rootX - winX;
                    y       = rootY - winY;
                    mayDock = topDock.OnDockRequest(x, y, ref myRequest);
                    if (mayDock)
                    {
                        break;
                    }
                }
            }

            if (!mayDock)
            {
                dock = null;

                myRequest.Target   = Dock.GetTopLevel(item);
                myRequest.Position = DockPlacement.Floating;
                Requisition preferredSize = item.PreferredSize;
                myRequest.Width  = preferredSize.Width;
                myRequest.Height = preferredSize.Height;
                myRequest.X      = rootX - item.DragOffX;
                myRequest.Y      = rootY - item.DragOffY;

                Gdk.Rectangle rect = new Gdk.Rectangle(myRequest.X,
                                                       myRequest.Y,
                                                       myRequest.Width,
                                                       myRequest.Height);

                // setup extra docking information
                myRequest.Extra = rect;
            }

            if (!(myRequest.X == request.X &&
                  myRequest.Y == request.Y &&
                  myRequest.Width == request.Width &&
                  myRequest.Height == request.Height &&
                  dock == rectOwner))
            {
                /* erase the previous rectangle */
                if (rectDrawn)
                {
                    XorRect();
                }
            }

            // set the new values
            request   = myRequest;
            rectOwner = dock;

            /* draw the previous rectangle */
            if (!rectDrawn)
            {
                XorRect();
            }
        }
Exemplo n.º 8
0
 public DockLayout(Dock dock)
 {
     layouts = new ArrayList ();
     this.Attach (dock.Master);
     BuildModels ();
 }
Exemplo n.º 9
0
        public void AddFloatingItem(DockItem item, int x, int y, int width, int height)
        {
            Dock dock = new Dock (this, true, x, y, width, height);

            if (Visible) {
                dock.Show ();
                if (IsMapped)
                    dock.Map ();
                dock.QueueResize ();
            }

            dock.AddItem (item, DockPlacement.Top);
        }
Exemplo n.º 10
0
 public Dock(Dock original, bool floating)
     : this(original, floating, 0, 0, -1, -1)
 {
 }
Exemplo n.º 11
0
 public Dock(Dock original, bool floating)
     : this(original, floating, 0, 0, -1, -1)
 {
 }
Exemplo n.º 12
0
 public DockLayout(Dock dock)
 {
     layouts = new ArrayList();
     this.Attach(dock.Master);
     BuildModels();
 }
Exemplo n.º 13
0
 public DockBar(Dock dock)
 {
     items    = new ArrayList();
     tooltips = new Tooltips();
     Master   = dock.Master;
 }
Exemplo n.º 14
0
 public DockBar(Dock dock)
 {
     items = new ArrayList ();
     tooltips = new Tooltips ();
     Master = dock.Master;
 }
Exemplo n.º 15
0
 public DockBar(Dock dock)
 {
     items = new ArrayList ();
     Master = dock.Master;
 }