Exemple #1
0
 /// <summary>
 /// Draw the component.
 /// </summary>
 /// <param name="drawEvent"></param>
 public override void OnDraw(DrawEvent drawEvent)
 {
     base.OnDraw(drawEvent);
     if( myImagePart != null
         && myImagePart.SourceTexture != null )
         drawEvent.Painter.DrawImage( myImagePart.SourceTexture, LocalSpaceBoundingRectangle, myImagePart.SourceRectangle );
     base.EndDraw(drawEvent);
 }
Exemple #2
0
        public override void OnDraw(DrawEvent drawEvent)
        {
            base.OnDraw(drawEvent);

            Text myTextStr = new Text(myText, myFont.Font, myTextSize);
            myTextStr.Position = Position;

            Text.Styles st = Text.Styles.Regular;
            if ((myStyle & TextStyle.Bold) != 0)
                st |= Text.Styles.Bold;
            if ((myStyle & TextStyle.Italic) != 0)
                st |= Text.Styles.Italic;
            myTextStr.Style = st;

            // Ne tient pas compte du débordement...
            drawEvent.Painter.DrawString(myTextStr, myTextColor);

            base.EndDraw(drawEvent);
        }
Exemple #3
0
 public override void OnDraw(DrawEvent drawEvent)
 {
     base.OnDraw(drawEvent);
     foreach( BasicLabel label in myBasicLabels )
     {
         // Not any chance that a basic label refuse to be drawn.
         if (Widget.Contains(LocalSpaceBoundingRectangle, label.BoundingRectangle))
             label.OnDraw(drawEvent);
     }
 }
 public override void OnDraw(DrawEvent drawEvent)
 {
     base.OnDraw(drawEvent);
     base.EndDraw(drawEvent);
 }
Exemple #5
0
        /// <summary>
        /// Render all the widgets and cursors.
        /// </summary>
        public void Render( bool debug )
        {
            myPainter.Begin();
            foreach (Widget widget in myManagedWidgets)
            {
                if (widget.Visible)
                {
                    DrawEvent drawEvent = new DrawEvent(myPainter, debug);
                    widget.OnEvent(drawEvent);

                    if (drawEvent.Accepted)
                    {
                        Vector2f pos = widget.Position;
                        drawEvent.Painter.Translate(pos);
                        widget.OnDraw(drawEvent);
                        drawEvent.Painter.TranslateBack(pos);
                    }
                }
            }

            if (myCursor != null)
            {
                if( myCursor.Visible )
                    if( myCursor.Image != null )
                    {
                        FloatRect destRect = new FloatRect(
                            myCursor.Position.X,
                            myCursor.Position.Y,
                            myCursor.Image.SourceRectangle.Width,
                            myCursor.Image.SourceRectangle.Height);
                        myPainter.DrawImage(myCursor.Image.SourceTexture, destRect, myCursor.Image.SourceRectangle);
                    }
                    else
                    {
                        FloatRect destRect = new FloatRect(
                            myCursor.Position.X,
                            myCursor.Position.Y,
                            5,
                            5);
                        myPainter.DrawRectangle(destRect, Color.White);
                    }
            }
            myPainter.End();
        }
Exemple #6
0
        /// <summary>
        /// Draws the widgets in the layout.
        /// </summary>
        /// <param name="drawEvent">Draw event.</param>
        public override void OnDraw(DrawEvent drawEvent)
        {
            base.OnDraw(drawEvent);

            foreach (Widget widget in Widgets)
            {
                drawEvent.Accepted = true;
                if (widget.Visible
                    && Widget.Contains( LocalSpaceBoundingRectangle, widget.BoundingRectangle) )
                {
                    widget.OnEvent(drawEvent);
                    if (drawEvent.Accepted)
                    {
                        drawEvent.Painter.Translate(widget.Position);
                        widget.OnDraw(drawEvent);
                        drawEvent.Painter.TranslateBack(widget.Position);
                    }
                }
            }

            base.EndDraw(drawEvent);
        }
Exemple #7
0
        /// <summary>
        /// Raised when drawing the widgets.
        /// Each widget must draw itself and know
        /// that a new basis is build for it: it starts at the upper left corner of the widget.
        /// DON'T consider widget's position while drawing. It's done by it's parent/manager.
        /// </summary>
        /// <param name="drawEvent">raised event</param>
        public virtual void OnDraw(DrawEvent drawEvent)
        {
            oldPainterTint = drawEvent.Painter.Tint;

            Color interpolatedTint = Tint;
            if (Parent != null)
            {
                interpolatedTint.R = (byte)((interpolatedTint.R * drawEvent.Painter.Tint.R) / 255);
                interpolatedTint.G = (byte)((interpolatedTint.G * drawEvent.Painter.Tint.G) / 255);
                interpolatedTint.B = (byte)((interpolatedTint.B * drawEvent.Painter.Tint.B) / 255);
                interpolatedTint.A = (byte)((interpolatedTint.A * drawEvent.Painter.Tint.A) / 255);
            }

            drawEvent.Painter.Tint = interpolatedTint;
        }
Exemple #8
0
        /// <summary>
        /// Restore the old painter tint
        /// </summary>
        public void EndDraw(DrawEvent drawEvent)
        {
            if( drawEvent.DebugDraw )
                drawEvent.Painter.DebugDrawRectangle(LocalSpaceBoundingRectangle, Color.Red);

            drawEvent.Painter.Tint = oldPainterTint;
        }
Exemple #9
0
        public override void OnDraw(DrawEvent drawEvent)
        {
            base.OnDraw(drawEvent);

            FloatRect geometryRegion = GeometryRegion;

            // Check if we can draw the borders.
            if( Widget.Contains(LocalSpaceBoundingRectangle,BordersRectangle) )
            {
                drawEvent.Painter.DrawRectangle(geometryRegion, BackgroundColor);

                if (myFrameImages[0] != null)
                    drawEvent.Painter.DrawImage(myFrameImages[0].SourceTexture,
                                                new FloatRect(geometryRegion.Left - myFrameImages[0].Size.X,
                                                              geometryRegion.Top - myFrameImages[0].Size.Y,
                                                              myFrameImages[0].Size.X,
                                                              myFrameImages[0].Size.Y),
                                                myFrameImages[0].SourceRectangle);

                if (myFrameImages[1] != null)
                    drawEvent.Painter.DrawImage(myFrameImages[1].SourceTexture,
                                                new FloatRect(geometryRegion.Left,
                                                              geometryRegion.Top - myFrameImages[1].Size.Y,
                                                              geometryRegion.Width,
                                                              myFrameImages[1].Size.Y),
                                                myFrameImages[1].SourceRectangle);

                if (myFrameImages[2] != null)
                    drawEvent.Painter.DrawImage(myFrameImages[2].SourceTexture,
                                                new FloatRect(geometryRegion.Left + geometryRegion.Width,
                                                              geometryRegion.Top - myFrameImages[2].Size.Y,
                                                              myFrameImages[2].Size.X,
                                                              myFrameImages[2].Size.Y),
                                                myFrameImages[2].SourceRectangle);

                if (myFrameImages[3] != null)
                    drawEvent.Painter.DrawImage(myFrameImages[3].SourceTexture,
                                                new FloatRect(geometryRegion.Left - myFrameImages[3].Size.X,
                                                              geometryRegion.Top,
                                                              myFrameImages[3].Size.X,
                                                              geometryRegion.Height),
                                                myFrameImages[3].SourceRectangle);

                if (myFrameImages[4] != null)
                    drawEvent.Painter.DrawImage(myFrameImages[4].SourceTexture,
                                                geometryRegion,
                                                myFrameImages[4].SourceRectangle);

                if (myFrameImages[5] != null)
                    drawEvent.Painter.DrawImage(myFrameImages[5].SourceTexture,
                                                new FloatRect(geometryRegion.Left + geometryRegion.Width,
                                                              geometryRegion.Top,
                                                              myFrameImages[5].Size.X,
                                                              geometryRegion.Height),
                                                myFrameImages[5].SourceRectangle);

                if (myFrameImages[6] != null)
                    drawEvent.Painter.DrawImage(myFrameImages[6].SourceTexture,
                                                new FloatRect(geometryRegion.Left - myFrameImages[6].Size.X,
                                                              geometryRegion.Top + geometryRegion.Height,
                                                              myFrameImages[6].Size.X,
                                                              myFrameImages[6].Size.Y),
                                                myFrameImages[6].SourceRectangle);
                if (myFrameImages[7] != null)
                    drawEvent.Painter.DrawImage(myFrameImages[7].SourceTexture,
                                                new FloatRect(geometryRegion.Left,
                                                              geometryRegion.Top + geometryRegion.Height,
                                                              geometryRegion.Width,
                                                              myFrameImages[7].Size.Y),
                                                myFrameImages[7].SourceRectangle);

                if (myFrameImages[8] != null)
                    drawEvent.Painter.DrawImage(myFrameImages[8].SourceTexture,
                                                new FloatRect(geometryRegion.Left + geometryRegion.Width,
                                                              geometryRegion.Top + geometryRegion.Height,
                                                              myFrameImages[8].Size.X,
                                                              myFrameImages[8].Size.Y),
                                                myFrameImages[8].SourceRectangle);
            }

            // We also check if we can draw the inner widget.
            if (myContainedWidget != null
                && myContainedWidget.Visible
                && Widget.Contains(InnerLocalSpaceGeometryRegion,myContainedWidget.BoundingRectangle) )
            {
                myContainedWidget.OnEvent(drawEvent);
                if (drawEvent.Accepted)
                {
                    Vector2f vec = new Vector2f(
                        geometryRegion.Left + myContainedWidget.Position.X,
                        geometryRegion.Top + myContainedWidget.Position.Y );
                    drawEvent.Painter.Translate(vec);
                    myContainedWidget.OnDraw(drawEvent);
                    drawEvent.Painter.TranslateBack(vec);
                }
            }

            base.EndDraw(drawEvent);
        }