dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/System.Windows.Forms/Themes IThemePa


From: Richard Baumann <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System.Windows.Forms/Themes IThemePainter.cs,1.1,1.2 DefaultThemePainter.cs,1.1,1.2
Date: Tue, 08 Jul 2003 06:45:02 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/Themes
In directory subversions:/tmp/cvs-serv21033/System.Windows.Forms/Themes

Modified Files:
        IThemePainter.cs DefaultThemePainter.cs 
Log Message:
Change some stuff for the new themes system and add some new drawing code.


Index: IThemePainter.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/Themes/IThemePainter.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** IThemePainter.cs    7 Jul 2003 04:58:50 -0000       1.1
--- IThemePainter.cs    8 Jul 2003 10:45:00 -0000       1.2
***************
*** 115,122 ****
        void DrawReversibleLine(Point start, Point end, Color backColor);
  
        // Draw a scroll button control.
        void DrawScrollButton
                                (Graphics graphics, int x, int y, int width, 
int height,
!                                ScrollButton button, ButtonState state);
  
        // Draw a selection frame.
--- 115,133 ----
        void DrawReversibleLine(Point start, Point end, Color backColor);
  
+       // Draw a scroll bar control.
+       void DrawScrollBar
+                               (Graphics graphics, Rectangle bounds,
+                                Color foreColor, Color backColor,
+                                Brush backgroundBrush,
+                                bool vertical, bool enabled,
+                                Rectangle bar,
+                                Rectangle decrement, bool decDown,
+                                Rectangle increment, bool incDown);
+ 
        // Draw a scroll button control.
        void DrawScrollButton
                                (Graphics graphics, int x, int y, int width, 
int height,
!                                ScrollButton button, ButtonState state,
!                                Color foreColor, Color backColor);
  
        // Draw a selection frame.

Index: DefaultThemePainter.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms/Themes/DefaultThemePainter.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** DefaultThemePainter.cs      7 Jul 2003 04:58:50 -0000       1.1
--- DefaultThemePainter.cs      8 Jul 2003 10:45:00 -0000       1.2
***************
*** 4,7 ****
--- 4,8 ----
   *
   * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
+  * Copyright (C) 2003  Free Software Foundation, Inc.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 911,919 ****
                                        if((i*step) < value)
                                        {
!                                               
ControlPaint.DrawBlock(graphics, x, y+ySpacing, 
!                                                                               
        blockWidth,
!                                                                               
        blockHeight,
!                                                                               
        enabled ? SystemColors.Highlight
!                                                                               
                        : SystemColors.ControlDark);
                                        }
                                        x+=blockWidth+xSpacing;
--- 912,920 ----
                                        if((i*step) < value)
                                        {
!                                               DrawBlock(graphics, x, 
y+ySpacing, 
!                                                         blockWidth,
!                                                         blockHeight,
!                                                         enabled ? 
SystemColors.Highlight
!                                                                 : 
SystemColors.ControlDark);
                                        }
                                        x+=blockWidth+xSpacing;
***************
*** 1131,1141 ****
                        }
  
        // Draw a scroll button control.
        [TODO]
        public virtual void DrawScrollButton
                                (Graphics graphics, int x, int y, int width, 
int height,
!                                ScrollButton button, ButtonState state)
                        {
!                               // TODO
                        }
  
--- 1132,1364 ----
                        }
  
+       // Draw a scroll bar control.
+       public virtual void DrawScrollBar
+                               (Graphics graphics, Rectangle bounds,
+                                Color foreColor, Color backColor,
+                                Brush backgroundBrush,
+                                bool vertical, bool enabled,
+                                Rectangle bar,
+                                Rectangle decrement, bool decDown,
+                                Rectangle increment, bool incDown)
+                       {
+                               int x = bounds.X;
+                               int y = bounds.Y;
+                               int width = bounds.Width;
+                               int height = bounds.Height;
+ 
+                               // fill in the background
+                               graphics.FillRectangle(backgroundBrush,
+                                                      x, y, width, height);
+ 
+                               // add the border
+                               DrawBorder3D(graphics,
+                                            x, y, width, height,
+                                            foreColor, backColor,
+                                            Border3DStyle.SunkenInner,
+                                            Border3DSide.Left | 
Border3DSide.Top |
+                                            Border3DSide.Right | 
Border3DSide.Bottom);
+ 
+                               // setup the arrow directions for the scroll 
buttons
+                               ScrollButton decButton;
+                               ScrollButton incButton;
+                               if (vertical)
+                               {
+                                       decButton = ScrollButton.Up;
+                                       incButton = ScrollButton.Down;
+                               }
+                               else
+                               {
+                                       decButton = ScrollButton.Left;
+                                       incButton = ScrollButton.Right;
+                               }
+ 
+                               // setup the states for the scroll buttons
+                               ButtonState decState;
+                               ButtonState incState;
+                               if (!enabled)
+                               {
+                                       decState = ButtonState.Inactive;
+                                       incState = ButtonState.Inactive;
+                               }
+                               else
+                               {
+                                       decState = decDown ?
+                                                  ButtonState.Pushed :
+                                                  ButtonState.Normal;
+                                       incState = incDown ?
+                                                  ButtonState.Pushed :
+                                                  ButtonState.Normal;
+                               }
+ 
+                               // draw the scroll buttons
+                               DrawScrollButton(graphics,
+                                                decrement.X, decrement.Y,
+                                                decrement.Width, 
decrement.Height,
+                                                decButton, decState,
+                                                foreColor, backColor);
+                               DrawScrollButton(graphics,
+                                                increment.X, increment.Y,
+                                                increment.Width, 
increment.Height,
+                                                incButton, incState,
+                                                foreColor, backColor);
+ 
+                               // calculate the state for the scroll bar
+                               ButtonState barState = enabled ?
+                                                      ButtonState.Normal :
+                                                      ButtonState.Inactive;
+ 
+                               // draw the scroll bar
+                               DrawButton(graphics,
+                                          bar.X, bar.Y,
+                                          bar.Width, bar.Height,
+                                          barState,
+                                          foreColor, backColor,
+                                          false);
+                       }
+ 
        // Draw a scroll button control.
        [TODO]
        public virtual void DrawScrollButton
                                (Graphics graphics, int x, int y, int width, 
int height,
!                                ScrollButton button, ButtonState state,
!                                Color foreColor, Color backColor)
                        {
!                               // draw the button border
!                               DrawButton(graphics,
!                                          x, y, width, height,
!                                          state,
!                                          foreColor, backColor,
!                                          false);
!                               x += 2; // skip border
!                               y += 2; // skip border
!                               width -= 4; // skip border
!                               height -= 4; // skip border
!                               if ((state & ButtonState.Pushed) != 0)
!                               {
!                                       x += 1;
!                                       y += 1;
!                               }
! 
!                               // setup the glyph shape
!                               PointF[] glyph = null;
!                               float gBounds = width < height ?
!                                               width : height;
!                               gBounds *= 0.8f;
!                               float gX = x+((width-gBounds)/2.0f);
!                               float gY = y+((height-gBounds)/2.0f);
!                               float gWidth = 0;//back_compat
!                               float gHeight = 0;//back_compat
!                               switch (button)
!                               {
!                                       case ScrollButton.Up:
!                                       {
!                                               float scale = gBounds/7.0f;
!                                               float pX = gX;
!                                               float pY = 
gY+((gBounds-4)/2.0f);
!                                               float scale3 = (3*scale);
!                                               float scale6 = (6*scale);
!                                               glyph = new PointF[4];
!                                               glyph[0] = new PointF(gX+scale3,
!                                                                     gY);
!                                               glyph[1] = new PointF(gX+scale6,
!                                                                     
gY+scale3);
!                                               glyph[2] = new PointF(gX,
!                                                                     
gY+scale3);
!                                               glyph[3] = glyph[0];
!                                       }
!                                       break;
! 
!                                       case ScrollButton.Down:
!                                       {
!                                       #if false
!                                               // this is the XP style arrow...
!                                               // the shape is wider than it is
!                                               // tall so scale it based on the
!                                               // width and then offset the y
!                                               float scale = gBounds/9.0f;
!                                               float pX = gX;
!                                               float pY = 
gY+((gBounds-6)/2.0f);
!                                               glyph = new PointF[7];
!                                               glyph[0] = new PointF(gX,
!                                                                     
gY+(scale));
!                                               glyph[1] = new 
PointF(gX+(scale),
!                                                                     gY);
!                                               glyph[2] = new 
PointF(gX+(4*scale),
!                                                                     
gY+(3*scale));
!                                               glyph[3] = new 
PointF(gX+(7*scale),
!                                                                     gY);
!                                               glyph[4] = new 
PointF(gX+(8*scale),
!                                                                     
gY+(1*scale));
!                                               glyph[5] = new 
PointF(gX+(4*scale),
!                                                                     
gY+(5*scale));
!                                               glyph[6] = glyph[0];
!                                       #endif
!                                               float scale = gBounds/7.0f;
!                                               float pX = gX;
!                                               float pY = 
gY+((gBounds-4)/2.0f);
!                                               float scale3 = (3*scale);
!                                               float scale6 = (6*scale);
!                                               glyph = new PointF[4];
!                                               glyph[0] = new PointF(gX,
!                                                                     gY);
!                                               glyph[1] = new PointF(gX+scale6,
!                                                                     gY);
!                                               glyph[2] = new PointF(gX+scale3,
!                                                                     
gY+scale3);
!                                               glyph[3] = glyph[0];
!                                       }
!                                       break;
! 
!                                       case ScrollButton.Left:
!                                       {
!                                               float scale = gBounds/7.0f;
!                                               float pX = 
gX+((gBounds-4)/2.0f);
!                                               float pY = gY;
!                                               float scale3 = (3*scale);
!                                               float scale6 = (6*scale);
!                                               glyph = new PointF[4];
!                                               glyph[0] = new PointF(gX,
!                                                                     
gY+scale3);
!                                               glyph[1] = new PointF(gX+scale3,
!                                                                     gY);
!                                               glyph[2] = new PointF(gX+scale3,
!                                                                     
gY+scale6);
!                                               glyph[3] = glyph[0];
!                                       }
!                                       break;
! 
!                                       default: // ScrollButton.Right
!                                       {
!                                               float scale = gBounds/7.0f;
!                                               float pX = 
gX+((gBounds-4)/2.0f);
!                                               float pY = gY;
!                                               float scale3 = (3*scale);
!                                               float scale6 = (6*scale);
!                                               glyph = new PointF[4];
!                                               glyph[0] = new PointF(gX,
!                                                                     
gY+scale3);
!                                               glyph[1] = new PointF(gX+scale3,
!                                                                     gY);
!                                               glyph[2] = new PointF(gX+scale3,
!                                                                     
gY+scale6);
!                                               glyph[3] = glyph[0];
!                                       }
!                                       break;
!                               }
! 
!                               // draw the glyph
!                               Color color = foreColor;
!                               if ((state & ButtonState.Inactive) != 0)
!                               {
!                                       color = ControlPaint.Light(foreColor);
!                               }
!                               using (Brush brush = new SolidBrush(Color.Blue))
!                               {
!                                       graphics.FillPolygon(brush,glyph);
!                               }
!                               using (Pen pen = new Pen(Color.Green))
!                               {
!                                       graphics.DrawPolygon(pen,glyph);
!                               }
                        }
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]