Ejemplo n.º 1
0
    T(string[] args)
    {
        Application.Init ();
        Window app = new Window ("test");
        app.SetDefaultSize (400, 400);
        app.WindowPosition = WindowPosition.Center;
        app.DeleteEvent += new DeleteEventHandler (OnAppDelete);

        Box table = new VBox (false, 5);
        table.BorderWidth = 10;
        app.Add (table);

        Dock dock = new Dock ();
        layout = new DockLayout (dock);
        layout.LoadFromFile ("layout.xml");
        DockBar dockbar = new DockBar (dock);

        Box box = new HBox (false, 5);
        box.PackStart (dockbar, false, false, 0);
        box.PackEnd (dock, true, true, 0);
        table.PackStart (box, true, true, 0);

        DockItem di = new DockItem ("item1", "Item #1", DockItemBehavior.Locked);
        di.Add (CreateTextView ());
        dock.AddItem (di, DockPlacement.Top);

        DockItem di2 = new DockItem ("item2", "Item #2 has some large title",
                         Gtk.Stock.Execute, DockItemBehavior.Normal);
        di2.Add (new Button ("Button 2"));
        dock.AddItem (di2, DockPlacement.Right);

        DockItem di3 = new DockItem ("item3", "Item #3 has accented characters (áéíóúñ)",
                         Gtk.Stock.Convert, DockItemBehavior.Normal | DockItemBehavior.CantClose);
        di3.Add (new Button ("Button 3"));
        dock.AddItem (di3, DockPlacement.Bottom);

        DockItem[] items = new DockItem[4];
        items[0] = new DockItem ("item4", "Item #4", Gtk.Stock.JustifyFill,
                     DockItemBehavior.Normal | DockItemBehavior.CantIconify);
        items[0].Add (CreateTextView ());
        dock.AddItem (items[0], DockPlacement.Bottom);

        for (int i = 1; i < 3; i++) {
            string name = "Item #" + (i + 4);
            items[i] = new DockItem (name, name, Gtk.Stock.New,
                         DockItemBehavior.Normal);
            items[i].Add (CreateTextView ());
            items[i].Show ();

                items[0].Dock (items[i], DockPlacement.Center, null);
        }

        di3.DockTo (di, DockPlacement.Top);
        di2.DockTo (di3, DockPlacement.Right);
        di2.DockTo (di3, DockPlacement.Left);
        di2.DockTo (null, DockPlacement.Floating);

        box = new HBox (true, 5);
        table.PackEnd (box, false, false, 0);

        Button button = new Button (Gtk.Stock.Save);
        button.Clicked += new EventHandler (OnSaveLayout);
        box.PackEnd (button, false, true, 0);

        button = new Button ("Layout Manager");
        button.Clicked += new EventHandler (OnRunLayoutManager);
        box.PackEnd (button, false, true, 0);

        button = new Button ("Dump XML");
        button.Clicked += new EventHandler (OnDumpXML);
        box.PackEnd (button, false, true, 0);

        app.ShowAll ();

        // placeholders
        DockPlaceholder ph1 = new DockPlaceholder ("ph1", dock, DockPlacement.Top, false);
        DockPlaceholder ph2 = new DockPlaceholder ("ph2", dock, DockPlacement.Bottom, false);
        DockPlaceholder ph3 = new DockPlaceholder ("ph3", dock, DockPlacement.Left, false);
        DockPlaceholder ph4 = new DockPlaceholder ("ph4", dock, DockPlacement.Right, false);

        Application.Run ();
    }
        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;
        }