public override void Paint(CellExposeEventArgs aArgs)
        {
            if (Area.IsInsideArea(aArgs.ClippingArea) == false)
            {
                return;
            }
            Style  style = Rc.GetStyle(ChameleonTemplates.Button);
            Widget wdg   = (Widget)Master;

            Gdk.Rectangle rect = aArgs.CellArea.CopyToGdkRectangle();
            rect.Height += 2;
            if (this.ResolveState() == StateType.Insensitive)
            {
                Style.PaintBox(style, aArgs.Drawable, StateType.Insensitive, ShadowType.Out, rect,
                               wdg, "button", rect.X, rect.Y, rect.Width, rect.Height);
                rect.Width = rect.Width - System.Convert.ToInt32(rect.Width * Progress);
                Style.PaintBox(style, aArgs.Drawable, StateType.Insensitive, ShadowType.Out, rect,
                               wdg, "button", rect.X, rect.Y, rect.Width, rect.Height);
            }
            else
            {
                Style.PaintBox(style, aArgs.Drawable, StateType.Normal, ShadowType.Out, rect,
                               wdg, "box", rect.X, rect.Y, rect.Width, rect.Height);
                rect.Width = rect.Width - System.Convert.ToInt32(rect.Width * Progress);
                Style.PaintBox(style, aArgs.Drawable, StateType.Selected, ShadowType.Out, rect,
                               wdg, "bar", rect.X, rect.Y, rect.Width, rect.Height);
            }
            style.Dispose();
        }
        /// <summary>
        /// Paints cell on cairo context
        /// </summary>
        /// <param name="aArgs">
        /// A <see cref="CellExposeEventArgs"/>
        /// </param>
        public override void Paint(CellExposeEventArgs aArgs)
        {
            if (Area.IsInsideArea(aArgs.ClippingArea) == false)
            {
                return;
            }
            Style  style = Rc.GetStyle(ChameleonTemplates.VSeparator);
            Widget wdg   = (Widget)Master;

            Style.PaintVline(style, aArgs.Drawable, StateType.Normal, aArgs.CellArea.CopyToGdkRectangle(),
                             wdg, "hseparator", System.Convert.ToInt32(aArgs.CellArea.Y),
                             System.Convert.ToInt32(aArgs.CellArea.Y + aArgs.CellArea.Height),
                             System.Convert.ToInt32(aArgs.CellArea.X) + 1);
            style.Dispose();
        }
Example #3
0
        /// <summary>
        /// Paints cell on cairo context
        /// </summary>
        /// <param name="aArgs">
        /// A <see cref="CellExposeEventArgs"/>
        /// </param>
        public override void Paint(CellExposeEventArgs aArgs)
        {
            if (Area.IsInsideArea(aArgs.ClippingArea) == false)
            {
                return;
            }

/*			System.Console.WriteLine("Master: {0}", ((Gtk.Widget) Master).Allocation);
 *                      System.Console.WriteLine("Owner: {0}", ((IDrawingCell) Owner).Area);
 *                      System.Console.WriteLine("Arrow area: {0}", Area);
 *                      System.Console.WriteLine("Cell area: {0}", aArgs.CellArea);*/
            object wdg = Master;

            if (wdg is Gtk.Widget)
            {
                Style  style = Rc.GetStyle(ChameleonTemplates.Arrow);
                double x, y;
                MaxArrowSize(out x, out y);
                CellRectangle r = aArgs.CellArea.Copy();
                if (r.Height > r.Width)
                {
                    while (x < r.Width)
                    {
                        r.Shrink(1);
                    }
                }
                else
                {
                    while (y < r.Height)
                    {
                        r.Shrink(1);
                    }
                }
//				Gdk.Rectangle rect = aArgs.CellArea.CopyToGdkRectangle();
                Gdk.Rectangle rect = r.CopyToGdkRectangle();
//				System.Console.WriteLine(rect);
                Style.PaintArrow(style, aArgs.Drawable, this.ResolveState(), ShadowType.In, rect,
                                 (wdg is Gtk.Widget) ? (Gtk.Widget)wdg : null, "arrow", ArrowType, true, rect.X, rect.Y, rect.Width, rect.Height);
                style.Dispose();
                r = null;
            }
            else
            {
//				System.Console.WriteLine("Arrow master={0}", Master.GetType());
            }
        }
Example #4
0
        /// <summary>
        /// Renders cell on provided space
        /// </summary>
        /// <param name="window">
        /// Drawable <see cref="Gdk.Drawable"/>
        /// </param>
        /// <param name="widget">
        /// Widget <see cref="Widget"/>
        /// </param>
        /// <param name="background_area">
        /// Area for background <see cref="Gdk.Rectangle"/>
        /// </param>
        /// <param name="cell_area">
        /// Cell area <see cref="Gdk.Rectangle"/>
        /// </param>
        /// <param name="expose_area">
        /// Expose area <see cref="Gdk.Rectangle"/>
        /// </param>
        /// <param name="aFlags">
        /// State flags <see cref="CellRendererState"/>
        /// </param>
        protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area,
                                       Gdk.Rectangle cell_area, Gdk.Rectangle expose_area,
                                       CellRendererState aFlags)
        {
            masterWidget = widget;

            CellRectangle r = new CellRectangle(cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height);

            Gdk.Drawable  buffer  = null;
            Cairo.Context context = null;
            if (DoubleBuffered == true)
            {
                buffer  = new Gdk.Pixmap(window, cell_area.Width, cell_area.Height);
                context = Gdk.CairoHelper.Create(buffer);
            }
            else
            {
                context = Gdk.CairoHelper.Create(window);
            }

            Style style = Rc.GetStyle(widget);

            r.Set(expose_area.X, expose_area.Y, expose_area.Width, expose_area.Height);
            CalculateCellAreas(r);
            if (DoubleBuffered == true)
            {
                PaintCells(buffer, context, r, aFlags);
                widget.GdkWindow.DrawDrawable(style.BlackGC, buffer, cell_area.X, cell_area.Y, cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height);
                buffer.Dispose();
            }
            else
            {
                PaintCells(window, context, r, aFlags);
            }

            style.Dispose();
            ((IDisposable)context.Target).Dispose();
            ((IDisposable)context).Dispose();
            context      = null;
            masterWidget = null;
        }
Example #5
0
        /// <summary>
        /// Draws widget
        /// </summary>
        /// <param name="evnt">
        /// Parameters <see cref="Gdk.EventExpose"/>
        /// </param>
        /// <returns>
        /// returns true <see cref="System.Boolean"/>
        /// </returns>
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            buttonStyle = Rc.GetStyle(ChameleonTemplates.Button);

            if (widgets.Count > 0)
            {
                Gtk.Requisition req;
                Gdk.Rectangle   rect = evnt.Area;
                int             x, y, w, h = 0;
                evnt.Window.BeginPaintRect(evnt.Area);
                ExposeWidget(false, false, rect, evnt);
                if (Homogeneous == true)
                {
                    int cellWidth = Allocation.Width / Count;
                    if (Hovered > -1)
                    {
                        rect = new Rectangle(Hovered * cellWidth, 0, cellWidth, Allocation.Height);
                        ExposeWidget(false, true, rect, evnt);
                    }
                    if (Selected > -1)
                    {
                        rect = new Rectangle(Selected * cellWidth, 0, cellWidth, Allocation.Height);
                        ExposeWidget(true, false, rect, evnt);
                    }
                }
                else
                {
                    if (Hovered > -1)
                    {
                        if (widgets[Hovered].TranslateCoordinates(this, 0, 0, out x, out y) == true)
                        {
                            req = widgets[Hovered].SizeRequest();
                            widgets[Hovered].TranslateCoordinates(this, req.Width, req.Height, out w, out h);
                            rect = new Rectangle(x, 0, w - x, Allocation.Height);
                            ChameleonTemplates.Button.State = StateType.Prelight;
                            ExposeWidget(false, true, rect, evnt);
                            ChameleonTemplates.Button.State = StateType.Normal;
                        }
                    }
                    if (Selected > -1)
                    {
                        if (widgets[Selected].TranslateCoordinates(this, 0, 0, out x, out y) == true)
                        {
                            req = widgets[Selected].SizeRequest();
                            widgets[Selected].TranslateCoordinates(this, req.Width, req.Height, out w, out h);
                            rect = new Rectangle(x, 0, w - x, Allocation.Height);
                            ExposeWidget(true, false, rect, evnt);
                        }
                    }
                }
                // Draw children
                if (Child != null)
                {
                    PropagateExpose(Child, evnt);
                }

                buttonStyle.Dispose();
                return(true);
            }
            base.OnExposeEvent(evnt);
            return(true);
        }
Example #6
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MainView(ViewBase owner = null) : base(owner)
        {
            MasterView      = this;
            numberOfButtons = 0;
            if ((uint)Environment.OSVersion.Platform <= 3)
            {
                Rc.Parse(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                      ".gtkrc"));
            }
            baseFont        = Rc.GetStyle(new Label()).FontDescription.Copy();
            defaultBaseSize = baseFont.Size / Pango.Scale.PangoScale;
            FontSize        = Utility.Configuration.Settings.BaseFontSize;
            Builder builder = BuilderFromResource("ApsimNG.Resources.Glade.MainView.glade");

            window1         = (Window)builder.GetObject("window1");
            progressBar     = (ProgressBar)builder.GetObject("progressBar");
            StatusWindow    = (TextView)builder.GetObject("StatusWindow");
            stopButton      = (Button)builder.GetObject("stopButton");
            notebook1       = (Notebook)builder.GetObject("notebook1");
            notebook2       = (Notebook)builder.GetObject("notebook2");
            vbox1           = (VBox)builder.GetObject("vbox1");
            vbox2           = (VBox)builder.GetObject("vbox2");
            hpaned1         = (HPaned)builder.GetObject("hpaned1");
            hbox1           = (HBox)builder.GetObject("hbox1");
            _mainWidget     = window1;
            window1.Icon    = new Gdk.Pixbuf(null, "ApsimNG.Resources.apsim logo32.png");
            listButtonView1 = new ListButtonView(this);
            listButtonView1.ButtonsAreToolbar = true;

            EventBox labelBox = new EventBox();
            Label    label    = new Label("NOTE: This version of APSIM writes .apsimx files as JSON, not XML. These files cannot be opened with older versions of APSIM.");

            labelBox.Add(label);
            labelBox.ModifyBg(StateType.Normal, new Gdk.Color(0xff, 0xff, 0x00)); // yellow
            vbox1.PackStart(labelBox, false, true, 0);
            vbox1.PackEnd(listButtonView1.MainWidget, true, true, 0);
            listButtonView2 = new ListButtonView(this);
            listButtonView2.ButtonsAreToolbar = true;
            vbox2.PackEnd(listButtonView2.MainWidget, true, true, 0);
            hpaned1.PositionSet = true;
            hpaned1.Child2.Hide();
            hpaned1.Child2.NoShowAll = true;
            notebook1.SetMenuLabel(vbox1, new Label(indexTabText));
            notebook2.SetMenuLabel(vbox2, new Label(indexTabText));
            hbox1.HeightRequest = 20;


            TextTag tag = new TextTag("error");

            tag.Foreground = "red";
            StatusWindow.Buffer.TagTable.Add(tag);
            tag            = new TextTag("warning");
            tag.Foreground = "brown";
            StatusWindow.Buffer.TagTable.Add(tag);
            tag            = new TextTag("normal");
            tag.Foreground = "blue";
            StatusWindow.ModifyBase(StateType.Normal, new Gdk.Color(0xff, 0xff, 0xf0));
            StatusWindow.Visible     = false;
            stopButton.Image         = new Gtk.Image(new Gdk.Pixbuf(null, "ApsimNG.Resources.MenuImages.Delete.png", 12, 12));
            stopButton.ImagePosition = PositionType.Right;
            stopButton.Image.Visible = true;
            stopButton.Clicked      += OnStopClicked;
            window1.DeleteEvent     += OnClosing;
            listButtonView1.ListView.MainWidget.ScrollEvent   += ListView_ScrollEvent;
            listButtonView2.ListView.MainWidget.ScrollEvent   += ListView_ScrollEvent;
            listButtonView1.ListView.MainWidget.KeyPressEvent += ListView_KeyPressEvent;
            listButtonView2.ListView.MainWidget.KeyPressEvent += ListView_KeyPressEvent;
            //window1.ShowAll();
            if (ProcessUtilities.CurrentOS.IsMac)
            {
                InitMac();
            }
        }
 /// <summary>
 /// Resolves style used for drawing this container
 /// </summary>
 /// <returns>
 /// Style <see cref="Style"/>
 /// </returns>
 protected override Style GetStyle()
 {
     return(Rc.GetStyle(ChameleonTemplates.Button));
 }