Inheritance: Gtk.NodeStore
Example #1
0
        public Toolbox(ServiceContainer parentServices)
        {
            this.parentServices = parentServices;

            //we need this service, so create it if not present
            toolboxService = parentServices.GetService (typeof (IToolboxService)) as ToolboxService;
            if (toolboxService == null) {
                toolboxService = new ToolboxService ();
                parentServices.AddService (typeof (IToolboxService), toolboxService);
            }

            #region Toolbar
            toolbar = new Toolbar ();
            toolbar.ToolbarStyle = ToolbarStyle.Icons;
            toolbar.IconSize = IconSize.SmallToolbar;
            base.PackStart (toolbar, false, false, 0);

            filterToggleButton = new ToggleToolButton ();
            filterToggleButton.IconWidget = new Image (Stock.MissingImage, IconSize.SmallToolbar);
            filterToggleButton.Toggled += new EventHandler (toggleFiltering);
            toolbar.Insert (filterToggleButton, 0);

            catToggleButton = new ToggleToolButton ();
            catToggleButton.IconWidget = new Image (Stock.MissingImage, IconSize.SmallToolbar);
            catToggleButton.Toggled += new EventHandler (toggleCategorisation);
            toolbar.Insert (catToggleButton, 1);

            SeparatorToolItem sep = new SeparatorToolItem();
            toolbar.Insert (sep, 2);

            filterEntry = new Entry();
            filterEntry.WidthRequest = 150;
            filterEntry.Changed += new EventHandler (filterTextChanged);

            #endregion

            scrolledWindow = new ScrolledWindow ();
            base.PackEnd (scrolledWindow, true, true, 0);

            //Initialise model

            store = new ToolboxStore ();

            //initialise view
            nodeView = new NodeView (store);
            nodeView.Selection.Mode = SelectionMode.Single;
            nodeView.HeadersVisible = false;

            //cell renderers
            CellRendererPixbuf pixbufRenderer = new CellRendererPixbuf ();
            CellRendererText textRenderer = new CellRendererText ();
            textRenderer.Ellipsize = Pango.EllipsizeMode.End;

            //Main column with text, icons
            TreeViewColumn col = new TreeViewColumn ();

            col.PackStart (pixbufRenderer, false);
            col.SetAttributes (pixbufRenderer,
                                  "pixbuf", ToolboxStore.Columns.Icon,
                                  "visible", ToolboxStore.Columns.IconVisible,
                                  "cell-background-gdk", ToolboxStore.Columns.BackgroundColour);

            col.PackEnd (textRenderer, true);
            col.SetAttributes (textRenderer,
                                  "text", ToolboxStore.Columns.Label,
                                  "weight", ToolboxStore.Columns.FontWeight,
                                  "cell-background-gdk", ToolboxStore.Columns.BackgroundColour);

            nodeView.AppendColumn (col);

            //Initialise self
            scrolledWindow.VscrollbarPolicy = PolicyType.Automatic;
            scrolledWindow.HscrollbarPolicy = PolicyType.Never;
            scrolledWindow.WidthRequest = 150;
            scrolledWindow.AddWithViewport (nodeView);

            //selection events
            nodeView.NodeSelection.Changed += OnSelectionChanged;
            nodeView.RowActivated  += OnRowActivated;

            //update view when toolbox service updated
            toolboxService.ToolboxChanged += new EventHandler (tbsChanged);
            Refresh ();

            //track expanded state of nodes
            nodeView.RowCollapsed += new RowCollapsedHandler (whenRowCollapsed);
            nodeView.RowExpanded += new RowExpandedHandler (whenRowExpanded);

            //set initial state
            filterToggleButton.Active = false;
            catToggleButton.Active = true;
        }
Example #2
0
        public Toolbox(ServiceContainer parentServices)
        {
            this.parentServices = parentServices;

            //we need this service, so create it if not present
            toolboxService = parentServices.GetService(typeof(IToolboxService)) as ToolboxService;
            if (toolboxService == null)
            {
                toolboxService = new ToolboxService();
                parentServices.AddService(typeof(IToolboxService), toolboxService);
            }

            #region Toolbar
            toolbar = new Toolbar();
            toolbar.ToolbarStyle = ToolbarStyle.Icons;
            toolbar.IconSize     = IconSize.SmallToolbar;
            base.PackStart(toolbar, false, false, 0);

            filterToggleButton            = new ToggleToolButton();
            filterToggleButton.IconWidget = new Image(Stock.MissingImage, IconSize.SmallToolbar);
            filterToggleButton.Toggled   += new EventHandler(toggleFiltering);
            toolbar.Insert(filterToggleButton, 0);

            catToggleButton            = new ToggleToolButton();
            catToggleButton.IconWidget = new Image(Stock.MissingImage, IconSize.SmallToolbar);
            catToggleButton.Toggled   += new EventHandler(toggleCategorisation);
            toolbar.Insert(catToggleButton, 1);

            SeparatorToolItem sep = new SeparatorToolItem();
            toolbar.Insert(sep, 2);

            filterEntry = new Entry();
            filterEntry.WidthRequest = 150;
            filterEntry.Changed     += new EventHandler(filterTextChanged);

            #endregion

            scrolledWindow = new ScrolledWindow();
            base.PackEnd(scrolledWindow, true, true, 0);


            //Initialise model

            store = new ToolboxStore();

            //initialise view
            nodeView = new NodeView(store);
            nodeView.Selection.Mode = SelectionMode.Single;
            nodeView.HeadersVisible = false;

            //cell renderers
            CellRendererPixbuf pixbufRenderer = new CellRendererPixbuf();
            CellRendererText   textRenderer   = new CellRendererText();
            textRenderer.Ellipsize = Pango.EllipsizeMode.End;

            //Main column with text, icons
            TreeViewColumn col = new TreeViewColumn();

            col.PackStart(pixbufRenderer, false);
            col.SetAttributes(pixbufRenderer,
                              "pixbuf", ToolboxStore.Columns.Icon,
                              "visible", ToolboxStore.Columns.IconVisible,
                              "cell-background-gdk", ToolboxStore.Columns.BackgroundColour);

            col.PackEnd(textRenderer, true);
            col.SetAttributes(textRenderer,
                              "text", ToolboxStore.Columns.Label,
                              "weight", ToolboxStore.Columns.FontWeight,
                              "cell-background-gdk", ToolboxStore.Columns.BackgroundColour);

            nodeView.AppendColumn(col);

            //Initialise self
            scrolledWindow.VscrollbarPolicy = PolicyType.Automatic;
            scrolledWindow.HscrollbarPolicy = PolicyType.Never;
            scrolledWindow.WidthRequest     = 150;
            scrolledWindow.AddWithViewport(nodeView);

            //selection events
            nodeView.NodeSelection.Changed += OnSelectionChanged;
            nodeView.RowActivated          += OnRowActivated;

            //update view when toolbox service updated
            toolboxService.ToolboxChanged += new EventHandler(tbsChanged);
            Refresh();

            //track expanded state of nodes
            nodeView.RowCollapsed += new RowCollapsedHandler(whenRowCollapsed);
            nodeView.RowExpanded  += new RowExpandedHandler(whenRowExpanded);

            //set initial state
            filterToggleButton.Active = false;
            catToggleButton.Active    = true;
        }