// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Copyright (c) 2004 Novell, Inc.
+// Copyright (c) 2004-2005 Novell, Inc.
//
// Authors:
// Jordi Mas i Hernandez, jordi@ximian.com
// John BouAntoun, jba-mono@optusnet.com.au
//
//
-//
-// $Revision: 1.48 $
-// $Modtime: $
-// $Log: ThemeWin32Classic.cs,v $
-// Revision 1.48 2004/10/15 15:08:49 ravindra
-// Added ColumnHeaderHeight property in Theme for ListView.
-//
-// Revision 1.47 2004/10/13 15:06:37 pbartok
-// - Path from John BouAntoun:
-// * Fix check rendering (centre correctly for normal style, offset
-// correctly for FlatStyle).
-// * Fix border color usage (use backcolor) for FlatStyle.Popup
-// * Use checkbox.Capture instead of checkbox.is_pressed when rendering
-// flatstyle states.
-//
-// Revision 1.46 2004/10/13 03:48:15 pbartok
-// - Removed all occurences of SystemColors and replaced them with the
-// matching theme color
-//
-// Revision 1.45 2004/10/13 03:41:45 pbartok
-// - From John BouAntoun: Added an overload to CPDrawBorder3D to allow him
-// using the function for flatstyle drawing
-// - Changed functions to use the new version of CPDrawBorder3D
-//
-// Revision 1.44 2004/10/13 02:45:21 pbartok
-// - Fixes from John BouAntoun: now handles forecolors and backcolors for
-// flatstyle rendered controls much better; It also fixes normal checkbox
-// rendering when pushed or disabled.
-//
-// Revision 1.43 2004/10/07 14:56:51 jordi
-// Removes deletion of cached brushes
-//
-// Revision 1.42 2004/10/06 09:59:05 jordi
-// removes warnings from compilation
-//
-// Revision 1.41 2004/10/05 16:15:30 jackson
-// Improve rendering of the radio button patch by John BouAntoun
-//
-// Revision 1.40 2004/10/05 09:04:31 ravindra
-// - Added DrawListView method and ListViewDefaultSize property.
-// - Changed ControlPaint method calls to CPDrawXXX wherever possible.
-// - Changed DOS style CRLF to Unix format (dos2unix).
-//
-// Revision 1.39 2004/10/04 07:09:37 jordi
-// fixes right button position causing right button not showing on horizontal scrollbars
-//
-// Revision 1.38 2004/09/28 18:44:25 pbartok
-// - Streamlined Theme interfaces:
-// * Each DrawXXX method for a control now is passed the object for the
-// control to be drawn in order to allow accessing any state the theme
-// might require
-//
-// * ControlPaint methods for the theme now have a CP prefix to avoid
-// name clashes with the Draw methods for controls
-//
-// * Every control now retrieves it's DefaultSize from the current theme
-//
-// Revision 1.37 2004/09/09 08:28:11 pbartok
-// - Improve disabled string look
-//
-// Revision 1.36 2004/09/09 03:03:49 ravindra
-// PictureBox would not draw a null image to avoid crash.
-//
-// Revision 1.35 2004/09/07 17:12:26 jordi
-// GroupBox control
-//
-// Revision 1.34 2004/09/07 09:40:15 jordi
-// LinkLabel fixes, methods, multiple links
-//
-// Revision 1.33 2004/09/05 08:03:51 jordi
-// fixes bugs, adds flashing on certain situations
-//
-// Revision 1.32 2004/09/02 16:32:54 jordi
-// implements resource pool for pens, brushes, and hatchbruses
-//
-// Revision 1.31 2004/08/25 20:04:40 ravindra
-// Added the missing divider code and grip for ToolBar Control.
-//
-// Revision 1.30 2004/08/25 18:29:14 jordi
-// new methods, properties, and fixes for progressbar
-//
-// Revision 1.29 2004/08/25 00:43:13 ravindra
-// Fixed wrapping related issues in ToolBar control.
-//
-// Revision 1.28 2004/08/24 18:37:02 jordi
-// fixes formmating, methods signature, and adds missing events
-//
-// Revision 1.27 2004/08/24 16:16:46 jackson
-// Handle drawing picture boxes in the theme now. Draw picture box borders and obey sizing modes
-//
-// Revision 1.26 2004/08/21 01:52:08 ravindra
-// Improvments in mouse event handling in the ToolBar control.
-//
-// Revision 1.25 2004/08/20 00:12:51 jordi
-// fixes methods signature
-//
-// Revision 1.24 2004/08/19 22:25:31 jordi
-// theme enhancaments
-//
-// Revision 1.23 2004/08/18 19:16:53 jordi
-// Move colors to a table
-//
-// Revision 1.22 2004/08/17 19:29:11 jackson
-// Don't use KnownColor to create colours. It has a large startup time.
-//
-// Revision 1.21 2004/08/15 23:20:54 ravindra
-// Changes to Theme for ToolBar control and also dos2unix format.
-//
-// Revision 1.20 2004/08/13 21:22:18 jordi
-// removes redundant code and fixes issues with tickposition
-//
-// Revision 1.19 2004/08/12 20:29:01 jordi
-// Trackbar enhancement, fix mouse problems, highli thumb, etc
-//
-// Revision 1.18 2004/08/12 18:54:37 jackson
-// Handle owner draw status bars
-//
-// Revision 1.17 2004/08/11 01:31:35 jackson
-// Create Brushes as little as possible
-//
-// Revision 1.16 2004/08/10 19:21:27 jordi
-// scrollbar enhancements and standarize on win colors defaults
-//
-// Revision 1.15 2004/08/10 18:52:30 jackson
-// Implement DrawItem functionality
-//
-// Revision 1.14 2004/08/09 21:34:54 jackson
-// Add support for drawing status bar and get status bar item sizes
-//
-// Revision 1.13 2004/08/09 21:21:49 jackson
-// Use known colors for default control colours
-//
-// Revision 1.12 2004/08/09 21:12:15 jackson
-// Make the default font static, it is static in control so this doesn't change functionality and creating fonts is sloooooow.
-//
-// Revision 1.11 2004/08/09 17:31:13 jackson
-// New names for control properties
-//
-// Revision 1.10 2004/08/09 17:00:00 jackson
-// Add default window color properties
-//
-// Revision 1.9 2004/08/09 16:17:19 jackson
-// Use correct default back color
-//
-// Revision 1.8 2004/08/09 15:53:12 jackson
-// Themes now handle default control properties so coloring will be consistent
-//
-// Revision 1.7 2004/08/08 22:54:21 jordi
-// Label BorderStyles
-//
-// Revision 1.6 2004/08/08 18:09:53 jackson
-// Add pen_buttonface
-//
-// Revision 1.5 2004/08/08 17:34:28 jordi
-// Use Windows Standard Colours
-//
-// Revision 1.4 2004/08/07 23:31:15 jordi
-// fixes label bug and draw method name
-//
-// Revision 1.3 2004/08/07 19:05:44 jordi
-// Theme colour support and GetSysColor defines
-//
-// Revision 1.2 2004/08/07 00:01:39 pbartok
-// - Fixed some rounding issues with float/int
-//
-// Revision 1.1 2004/07/26 17:42:03 jordi
-// Theme support
-//
-//
+
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
+using System.Drawing.Text;
namespace System.Windows.Forms
{
internal class ThemeWin32Classic : Theme
{
+ public override Version Version {\r
+ get {\r
+ return new Version(0, 1, 0, 0);\r
+ }\r
+ }\r
+
/* Default colors for Win32 classic theme */
uint [] theme_colors = { /* AARRGGBB */
(uint) XplatUIWin32.GetSysColorIndex.COLOR_INFOBK, 0xffffffff,
};
-
- static protected Pen pen_ticks;
- static protected SolidBrush br_arrow;
- static protected SolidBrush br_progressbarblock;
- static protected Pen pen_arrow;
-
- /* Cache */
- protected SolidBrush label_br_fore_color;
- protected SolidBrush label_br_back_color;
+ /* Hardcoded colour values not exposed in the API constants in all configurations */
+ static readonly Color arrow_color = Color.Black;
+ static readonly Color pen_ticks_color = Color.Black;
+ static readonly Color progressbarblock_color = Color.FromArgb (255, 0, 0, 128);
+ static StringFormat string_format_menu_text;
+ static StringFormat string_format_menu_shortcut;
+ static StringFormat string_format_menu_menubar_text;
+ static readonly Rectangle checkbox_rect = new Rectangle (2, 2, 11,11); // Position of the checkbox relative to the item
+ static ImageAttributes imagedisabled_attributes = null;
+ const int SEPARATOR_HEIGHT = 5;
+ const int SM_CXBORDER = 1;
+ const int SM_CYBORDER = 1;
+ const int MENU_TAB_SPACE = 8; // Pixels added to the width of an item because of a tab
+ const int MENU_BAR_ITEMS_SPACE = 8; // Space between menu bar items
#region Principal Theme Methods
public ThemeWin32Classic ()
- {
- label_br_fore_color = null;
- label_br_back_color = null;
-
+ {
/* Init Default colour array*/
syscolors = Array.CreateInstance (typeof (Color), (uint) XplatUIWin32.GetSysColorIndex.COLOR_MAXVALUE+1);
for (int i = 0; i < theme_colors.Length; i +=2)
- syscolors.SetValue (Color.FromArgb ((int)theme_colors[i+1]), (int) theme_colors[i]);
-
- pen_ticks = new Pen (Color.Black);
- br_arrow = new SolidBrush (Color.Black);
- pen_arrow = new Pen (Color.Black);
- br_progressbarblock = new SolidBrush (Color.FromArgb (255, 0, 0, 128));
+ syscolors.SetValue (Color.FromArgb ((int)theme_colors[i+1]), (int) theme_colors[i]);
- defaultWindowBackColor = Color.FromArgb (255, 10, 10, 10);
+ defaultWindowBackColor = SystemColors.Window;
defaultWindowForeColor = ColorButtonText;
default_font = new Font (FontFamily.GenericSansSerif, 8.25f);
+
+ /* Menu string formats */
+ string_format_menu_text = new StringFormat ();
+ string_format_menu_text.LineAlignment = StringAlignment.Center;
+ string_format_menu_text.Alignment = StringAlignment.Near;
+ string_format_menu_text.HotkeyPrefix = HotkeyPrefix.Show;
+
+ string_format_menu_shortcut = new StringFormat ();
+ string_format_menu_shortcut.LineAlignment = StringAlignment.Center;
+ string_format_menu_shortcut.Alignment = StringAlignment.Far;
+
+ string_format_menu_menubar_text = new StringFormat ();
+ string_format_menu_menubar_text.LineAlignment = StringAlignment.Center;
+ string_format_menu_menubar_text.Alignment = StringAlignment.Center;
+ string_format_menu_menubar_text.HotkeyPrefix = HotkeyPrefix.Show;
}
+ public override void ResetDefaults() {
+ throw new NotImplementedException("Need to implement ResetDefaults() for Win32 theme");
+ }
+
public override bool DoubleBufferingSupported {
get {return true; }
}
public override void DrawButtonBase(Graphics dc, Rectangle clip_area, ButtonBase button) {
int width;
int height;
+ Rectangle buttonRectangle;
+ Rectangle borderRectangle;
width = button.ClientSize.Width;
height = button.ClientSize.Height;
-
- SolidBrush sb = new SolidBrush(button.BackColor);
- dc.FillRectangle(sb, button.ClientRectangle);
- sb.Dispose();
-
- CPDrawButton(dc, button.ClientRectangle, button.ButtonState);
-
+
+ dc.FillRectangle(ResPool.GetSolidBrush (button.BackColor), button.ClientRectangle);
+
+ // set up the button rectangle
+ buttonRectangle = button.ClientRectangle;
if (button.has_focus) {
- CPDrawFocusRectangle(dc, button.ClientRectangle, ColorButtonText, ColorButtonFace);
+ // shrink the rectangle for the normal button drawing inside the focus rectangle
+ borderRectangle = Rectangle.Inflate(buttonRectangle, -1, -1);
+ } else {
+ borderRectangle = buttonRectangle;
}
+ if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
+ DrawFlatStyleButton (dc, borderRectangle, button);
+ } else {
+ CPDrawButton(dc, borderRectangle, button.ButtonState);
+ }
+
// First, draw the image
if ((button.image != null) || (button.image_list != null)) {
// Need to draw a picture
}
if (button.is_pressed) {
- image_x+=2;
- image_y+=2;
+ image_x+=1;
+ image_y+=1;
}
if (button.is_enabled) {
CPDrawImageDisabled(dc, i, image_x, image_y, ColorButtonFace);
}
}
-
+
+ // Draw the focus rectangle
+ if (button.has_focus) {
+ if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
+ DrawFlatStyleFocusRectangle (dc, button.ClientRectangle, button, button.ForeColor, button.BackColor);
+ } else {
+ CPDrawFocusRectangle(dc, button.ClientRectangle, button.ForeColor, button.BackColor);
+ }
+ }
+
// Now the text
if (button.text != null && button.text != String.Empty) {
- Rectangle text_rect = new Rectangle(3, 3, button.ClientSize.Width-6, button.ClientSize.Height-6); // FIXME; calculate rect properly
+ Rectangle text_rect = Rectangle.Inflate(buttonRectangle, -4, -4);
if (button.is_pressed) {
text_rect.X++;
text_rect.Y++;
}
- if (button.is_enabled) {
- SolidBrush b = new SolidBrush(button.ForeColor);
- dc.DrawString(button.text, button.Font, b, text_rect, button.text_format);
- b.Dispose();
+ if (button.is_enabled) {
+ dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (button.ForeColor), text_rect, button.text_format);
+
+ } else {
+ if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
+ dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), text_rect, button.text_format);
+ } else {
+ CPDrawStringDisabled(dc, button.text, button.Font, ColorButtonText, text_rect, button.text_format);
+ }
+ }
+ }
+ }
+
+ // draw the flat style part of the rectangle
+ public void DrawFlatStyleButton (Graphics graphics, Rectangle rectangle, ButtonBase button) {
+ Color rect_back_color = button.BackColor;
+ Color rect_fore_color = button.ForeColor;
+ Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
+
+ if (button.Enabled) {
+ if (button.Capture || button.is_entered) {
+ if (button.FlatStyle == FlatStyle.Flat) {
+ // fill the rectangle
+ graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
+
+ // now draw the outer border
+ if (button.Capture && button.is_entered) {
+ rect_back_color = ControlPaint.LightLight (rect_back_color);
+ } else {
+ rect_back_color = ControlPaint.Light (rect_back_color);
+ }
+
+ // draw rectangle and fill it
+ graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
+ graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
+ } else {
+ // else it must be a popup button
+
+ if (button.Capture && button.is_entered) {
+ graphics.DrawRectangle(ResPool.GetPen (this.ColorButtonText), trace_rectangle);
+ } else {
+ // draw a 3d border
+ CPDrawBorder3D (graphics, rectangle, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, button.BackColor);
+ graphics.DrawLine ( ResPool.GetPen (this.ColorButtonText), trace_rectangle.X, trace_rectangle.Bottom, trace_rectangle.Right, trace_rectangle.Bottom);
+ graphics.DrawLine ( ResPool.GetPen (this.ColorButtonText), trace_rectangle.Right, trace_rectangle.Y, trace_rectangle.Right, trace_rectangle.Bottom);
+ }
+ }
+
+ // TODO: draw inner focus rectangle
+
} else {
- CPDrawStringDisabled(dc, button.text, button.Font, ColorButtonText, text_rect, button.text_format);
+ // popup has a ButtonColorText forecolor, not a button.ForeCOlor
+ if (button.FlatStyle == FlatStyle.Popup) {
+ rect_fore_color = this.ColorButtonText;
+ }
+
+ // fill then draw outer rect
+ graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
+ graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
+ }
+
+ // finally some small tweaks to render radiobutton and checkbox
+ CheckBox checkbox = button as CheckBox;
+ RadioButton radiobutton = button as RadioButton;
+ if ((checkbox != null && checkbox.Checked) ||
+ (radiobutton != null && radiobutton.Checked)) {
+ if (button.FlatStyle == FlatStyle.Flat && button.is_entered && !button.Capture) {
+ // render the hover for flat flatstyle and cheked
+ graphics.DrawRectangle(ResPool.GetPen (this.ColorButtonText), trace_rectangle);
+ } else if (!button.is_entered && !button.Capture) {
+ // render the checked state for popup when unhovered
+ CPDrawBorder3D (graphics, rectangle, Border3DStyle.SunkenInner, Border3DSide.Right | Border3DSide.Bottom, button.BackColor);
+ }
+ }
+ } else {
+ // rendering checkbox or radio button style buttons
+ CheckBox checkbox = button as CheckBox;
+ RadioButton radiobutton = button as RadioButton;
+ bool draw_popup_checked = false;
+
+ if (button.FlatStyle == FlatStyle.Popup) {
+ rect_fore_color = this.ColorButtonText;
+
+ // see if we should draw a disabled checked popup button
+ draw_popup_checked = ((checkbox != null && checkbox.Checked) ||
+ (radiobutton != null && radiobutton.Checked));
+ }
+
+ graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
+ graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
+
+ // finally draw the flatstyle checked effect if need
+ if (draw_popup_checked) {
+ // render the checked state for popup when unhovered
+ CPDrawBorder3D (graphics, rectangle, Border3DStyle.SunkenInner, Border3DSide.Right | Border3DSide.Bottom, button.BackColor);
}
}
}
Rectangle checkbox_rectangle;
SolidBrush sb;
int checkmark_size=13;
+ int checkmark_space = 4;
client_rectangle = checkbox.ClientRectangle;
text_rectangle = client_rectangle;
text_format = new StringFormat();
text_format.Alignment=StringAlignment.Near;
text_format.LineAlignment=StringAlignment.Center;
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
/* Calculate the position of text and checkbox rectangle */
if (checkbox.appearance!=Appearance.Button) {
checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
text_rectangle.X=client_rectangle.X;
text_rectangle.Width=client_rectangle.Width;
+ text_rectangle.Height=client_rectangle.Height-checkbox_rectangle.Y-checkmark_space;
break;
}
case ContentAlignment.BottomLeft: {
checkbox_rectangle.X=client_rectangle.Left;
checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
- text_rectangle.X=client_rectangle.X+checkmark_size;
- text_rectangle.Width=client_rectangle.Width-checkmark_size;
+ text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
+ text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
break;
}
checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
text_rectangle.X=client_rectangle.X;
- text_rectangle.Width=client_rectangle.Width-checkmark_size;
+ text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
break;
}
case ContentAlignment.MiddleLeft: {
checkbox_rectangle.X=client_rectangle.Left;
checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
- text_rectangle.X=client_rectangle.X+checkmark_size;
- text_rectangle.Width=client_rectangle.Width-checkmark_size;
+ text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
+ text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
break;
}
checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
text_rectangle.X=client_rectangle.X;
- text_rectangle.Width=client_rectangle.Width-checkmark_size;
+ text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
break;
}
checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
checkbox_rectangle.Y=client_rectangle.Top;
text_rectangle.X=client_rectangle.X;
- text_rectangle.Y=checkmark_size;
text_rectangle.Width=client_rectangle.Width;
- text_rectangle.Height=client_rectangle.Height-checkmark_size;
+ text_rectangle.Y=checkmark_size+checkmark_space;
+ text_rectangle.Height=client_rectangle.Height-checkmark_size-checkmark_space;
break;
}
case ContentAlignment.TopLeft: {
checkbox_rectangle.X=client_rectangle.Left;
- checkbox_rectangle.Y=client_rectangle.Top;
- text_rectangle.X=client_rectangle.X+checkmark_size;
- text_rectangle.Width=client_rectangle.Width-checkmark_size;
+ text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
+ text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
break;
}
case ContentAlignment.TopRight: {
checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
- checkbox_rectangle.Y=client_rectangle.Top;
text_rectangle.X=client_rectangle.X;
- text_rectangle.Width=client_rectangle.Width-checkmark_size;
+ text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
break;
}
}
text_rectangle.X=client_rectangle.X;
text_rectangle.Width=client_rectangle.Width;
}
-
+
/* Set the horizontal alignment of our text */
switch(checkbox.text_alignment) {
case ContentAlignment.BottomLeft:
// Start drawing
-
- sb=new SolidBrush(checkbox.BackColor);
- dc.FillRectangle(sb, checkbox.ClientRectangle);
- sb.Dispose();
-
- // establish if we are rendering a flat style of some sort
- if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
- DrawFlatStyleCheckBox (dc, checkbox_rectangle, checkbox);
+
+ dc.FillRectangle (ResPool.GetSolidBrush (checkbox.BackColor), checkbox.ClientRectangle);
+ // render as per normal button
+ if (checkbox.appearance==Appearance.Button) {
+ if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
+ DrawFlatStyleButton(dc, checkbox.ClientRectangle, checkbox);
+ } else {
+ CPDrawButton(dc, checkbox.ClientRectangle, state);
+ }
} else {
- // render as per normal
- if (checkbox.appearance!=Appearance.Button) {
- ControlPaint.DrawCheckBox(dc, checkbox_rectangle, state);
+ // establish if we are rendering a flat style of some sort
+ if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
+ DrawFlatStyleCheckBox (dc, checkbox_rectangle, checkbox);
} else {
- ControlPaint.DrawButton(dc, text_rectangle, state);
+ ControlPaint.DrawCheckBox(dc, checkbox_rectangle, state);
}
}
- // win32 compat - win32 seems to give the text a slight (3px) offset when rendering
- Rectangle inner_text_rectangle = new Rectangle (text_rectangle.X + 3, text_rectangle.Y, Math.Max (text_rectangle.Width - 3, 0), text_rectangle.Height);
-
+ // offset the text if it's pressed and a button
+ if (checkbox.Appearance == Appearance.Button) {
+ if (checkbox.Checked || (checkbox.Capture && checkbox.FlatStyle != FlatStyle.Flat)) {
+ text_rectangle.X ++;
+ text_rectangle.Y ++;
+ }
+
+ text_rectangle.Inflate(-4, -4);
+ }
+
/* Place the text; to be compatible with Windows place it after the checkbox has been drawn */
if (checkbox.Enabled) {
sb = ResPool.GetSolidBrush(checkbox.ForeColor);
- dc.DrawString(checkbox.Text, checkbox.Font, sb, inner_text_rectangle, text_format);
+ dc.DrawString(checkbox.Text, checkbox.Font, sb, text_rectangle, text_format);
} else if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
- dc.DrawString(checkbox.Text, checkbox.Font, SystemBrushes.ControlDark, inner_text_rectangle, text_format);
+ dc.DrawString(checkbox.Text, checkbox.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), text_rectangle, text_format);
} else {
- CPDrawStringDisabled(dc, checkbox.Text, checkbox.Font, ColorButtonText, inner_text_rectangle, text_format);
+ CPDrawStringDisabled(dc, checkbox.Text, checkbox.Font, ColorButtonText, text_rectangle, text_format);
}
if (checkbox.Focused) {
- ControlPaint.DrawFocusRectangle(dc, text_rectangle);
+ if (checkbox.FlatStyle != FlatStyle.Flat) {
+ DrawInnerFocusRectangle (dc, Rectangle.Inflate (text_rectangle, -1, -1), checkbox.BackColor);
+ } else {
+ dc.DrawRectangle (ResPool.GetPen (checkbox.ForeColor), Rectangle.Inflate (text_rectangle, -1, -1));
+ }
}
}
ControlPaint.DrawBorder(graphics, checkbox_rectangle, checkbox.ForeColor, ButtonBorderStyle.Solid);
} else {
// draw sunken effect
- CPDrawBorder3D (graphics, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.Bottom | Border3DSide.Right, checkbox.BackColor);
- // draw top left
- graphics.DrawLine(ResPool.GetPen (ControlPaint.DarkDark (checkbox.BackColor)), checkbox_rectangle.X, checkbox_rectangle.Y, checkbox_rectangle.X, checkbox_rectangle.Y+checkbox_rectangle.Height);
- graphics.DrawLine(ResPool.GetPen (ControlPaint.DarkDark (checkbox.BackColor)), checkbox_rectangle.X, checkbox_rectangle.Y, Math.Max(checkbox_rectangle.X + checkbox_rectangle.Width - 1, 0), checkbox_rectangle.Y);
+ CPDrawBorder3D (graphics, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.All, checkbox.BackColor);
}
} else {
graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);
#endregion // CheckBox
+
+ #region CheckedListBox
+
+ public override Rectangle CheckedListBoxCheckRectangle ()
+ {
+ return checkbox_rect;
+ }
+
+ public override void DrawCheckedListBoxItem (CheckedListBox ctrl, DrawItemEventArgs e)
+ {
+ Color back_color, fore_color;
+ Rectangle item_rect = e.Bounds;
+ ButtonState state;
+ StringFormat string_format = ctrl.GetFormatString ();
+
+ /* Draw checkbox */
+
+ if ((ctrl.Items.GetListBoxItem (e.Index)).State == CheckState.Checked)
+ state = ButtonState.Checked;
+ else
+ state = ButtonState.Normal;
+
+ if (ctrl.ThreeDCheckBoxes == false)
+ state |= ButtonState.Flat;
+
+ ControlPaint.DrawCheckBox (e.Graphics,
+ item_rect.X + checkbox_rect.X, item_rect.Y + checkbox_rect.Y,
+ checkbox_rect.Width, checkbox_rect.Height,
+ state);
+
+ item_rect.X += checkbox_rect.Width + checkbox_rect.X * 2;
+ item_rect.Width -= checkbox_rect.Width + checkbox_rect.X * 2;
+
+ /* Draw text*/
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ back_color = ThemeEngine.Current.ColorHilight;
+ fore_color = ThemeEngine.Current.ColorHilightText;
+ }
+ else {
+ back_color = e.BackColor;
+ fore_color = e.ForeColor;
+ }
+
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
+ (back_color), item_rect);
+
+ e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
+ ThemeEngine.Current.ResPool.GetSolidBrush (fore_color),
+ item_rect, string_format);
+
+ if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
+ ThemeEngine.Current.CPDrawFocusRectangle (e.Graphics, item_rect,
+ fore_color, back_color);
+ }
+ }
+
+ #endregion // CheckedListBox
+
+ #region ComboBox
+
+ // Drawing
+
+ public override void DrawComboBoxEditDecorations (Graphics dc, ComboBox ctrl, Rectangle cl)
+ {
+ dc.DrawLine (ResPool.GetPen (ColorButtonShadow), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top
+ dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
+ dc.DrawLine (ResPool.GetPen (ColorButtonFace), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
+ dc.DrawLine (ResPool.GetPen (ColorButtonHilight), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
+ dc.DrawLine (ResPool.GetPen (ColorButtonShadow), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
+ dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2);
+ dc.DrawLine (ResPool.GetPen (ColorButtonFace), cl.X + cl.Width - 2, cl.Y, cl.X + cl.Width - 2, cl.Y + cl.Height); //right
+ dc.DrawLine (ResPool.GetPen (ColorButtonHilight), cl.X + cl.Width - 1, cl.Y + 1 , cl.X + cl.Width - 1, cl.Y + cl.Height - 1);
+ }
+
+ // Sizing
+ public override int DrawComboBoxEditDecorationTop () { return 2;}
+ public override int DrawComboBoxEditDecorationBottom () { return 2;}
+ public override int DrawComboBoxEditDecorationRight () { return 2;}
+ public override int DrawComboBoxEditDecorationLeft () { return 2;}
+
+ private int DrawComboListBoxDecoration (ComboBoxStyle style)
+ {
+ if (style == ComboBoxStyle.Simple)
+ return 2;
+ else
+ return 1;
+ }
+
+ public override int DrawComboListBoxDecorationTop (ComboBoxStyle style)
+ {
+ return DrawComboListBoxDecoration (style);
+ }
+
+ public override int DrawComboListBoxDecorationBottom (ComboBoxStyle style)
+ {
+ return DrawComboListBoxDecoration (style);
+ }
+
+ public override int DrawComboListBoxDecorationRight (ComboBoxStyle style)
+ {
+ return DrawComboListBoxDecoration (style);
+ }
+
+ public override int DrawComboListBoxDecorationLeft (ComboBoxStyle style)
+ {
+ return DrawComboListBoxDecoration (style);
+ }
+
+ public override void DrawComboListBoxDecorations (Graphics dc, ComboBox ctrl, Rectangle cl)
+ {
+ if (ctrl.DropDownStyle == ComboBoxStyle.Simple) {
+ DrawComboBoxEditDecorations (dc, ctrl, cl);
+ }
+ else {
+ dc.DrawRectangle (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorWindowFrame),
+ cl.X, cl.Y, cl.Width - 1, cl.Height - 1);
+ }
+ }
+
+ public override void DrawComboBoxItem (ComboBox ctrl, DrawItemEventArgs e)
+ {
+ Color back_color, fore_color;
+ Rectangle text_draw = e.Bounds;
+ StringFormat string_format = new StringFormat ();
+ string_format.FormatFlags = StringFormatFlags.LineLimit;
+
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ back_color = ThemeEngine.Current.ColorHilight;
+ fore_color = ThemeEngine.Current.ColorHilightText;
+ }
+ else {
+ back_color = e.BackColor;
+ fore_color = e.ForeColor;
+ }
+
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (back_color), e.Bounds);
+
+ if (e.Index != -1) {
+ e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
+ ThemeEngine.Current.ResPool.GetSolidBrush (fore_color),
+ text_draw, string_format);
+ }
+
+ if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
+ ThemeEngine.Current.CPDrawFocusRectangle (e.Graphics, e.Bounds, fore_color, back_color);
+ }
+ }
+
+ #endregion ComboBox
+
+ #region Datagrid
+ public override int DataGridPreferredColumnWidth { get { return 75;} }
+ public override int DataGridMinimumColumnCheckBoxHeight { get { return 16;} }
+ public override int DataGridMinimumColumnCheckBoxWidth { get { return 16;} }
+ public override Color DataGridAlternatingBackColor { get { return ColorWindow;} }
+ public override Color DataGridBackgroundColor { get { return ColorWindow;} }
+ public override Color DataGridCaptionBackColor { get { return ColorActiveTitle;} }
+ public override Color DataGridCaptionForeColor { get { return SystemColors.ActiveCaptionText;} }
+ public override Color DataGridGridLineColor { get { return SystemColors.Control;} }
+ public override Color DataGridHeaderBackColor { get { return SystemColors.Control;} }
+ public override Color DataGridHeaderForeColor { get { return SystemColors.ControlText;} }
+ public override Color DataGridLinkColor { get { return SystemColors.HotTrack;} }
+ public override Color DataGridLinkHoverColor { get { return SystemColors.HotTrack;} }
+ public override Color DataGridParentRowsBackColor { get { return SystemColors.Control;} }
+ public override Color DataGridParentRowsForeColor { get { return SystemColors.WindowText;} }
+ public override Color DataGridSelectionBackColor { get { return ColorActiveTitle;} }
+ public override Color DataGridSelectionForeColor { get { return ColorTitleText;} }
+ #endregion // Datagrid
+
+ #region DateTimePicker
+
+ public override void DrawDateTimePicker (Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp) {
+ // if not showing the numeric updown control then render border
+ if (!dtp.ShowUpDown && clip_rectangle.IntersectsWith (dtp.ClientRectangle)) {
+ // draw the outer border
+ Rectangle button_bounds = dtp.ClientRectangle;
+ this.CPDrawBorder3D (dc, button_bounds, Border3DStyle.Sunken, Border3DSide.All, dtp.BackColor);
+
+ // deflate by the border width
+ if (clip_rectangle.IntersectsWith (dtp.drop_down_arrow_rect)) {
+ button_bounds.Inflate (-2,-2);
+ ButtonState state = dtp.is_drop_down_visible ? ButtonState.Pushed : ButtonState.Normal;
+ this.CPDrawComboButton (
+ dc,
+ dtp.drop_down_arrow_rect,
+ state);
+ }
+ }
+
+ // render the date part
+ if (clip_rectangle.IntersectsWith (dtp.date_area_rect)) {
+ // fill the background
+ dc.FillRectangle (ResPool.GetSolidBrush (ThemeEngine.Current.ColorWindow), dtp.date_area_rect);
+
+ // fill the currently highlighted area
+ if (dtp.hilight_date_area != Rectangle.Empty) {
+ dc.FillRectangle (ResPool.GetSolidBrush (ThemeEngine.Current.ColorHilight), dtp.hilight_date_area);
+ }
+
+ // draw the text part
+ // TODO: if date format is CUstom then we need to draw the dates as separate parts
+ StringFormat text_format = new StringFormat();
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.Alignment = StringAlignment.Near;
+ dc.DrawString (dtp.Text, dtp.Font, ResPool.GetSolidBrush (dtp.ForeColor), Rectangle.Inflate(dtp.date_area_rect, -1, -1), text_format);
+ }
+ }
+
+ #endregion // DateTimePicker
#region GroupBox
public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box) {
- SizeF size;
- int width, y;
- Rectangle rect = box.ClientRectangle;
- Color disabled = ColorGrayText;
+ StringFormat text_format;
+ SizeF size;
+ int width;
+ int y;
+ Rectangle rect;
+
+ rect = box.ClientRectangle;
+
+ // Needed once the Dark/Light code below is enabled again
+ //Color disabled = ColorGrayText;
Pen pen_light = ResPool.GetPen (Color.FromArgb (255,255,255,255));
Pen pen_dark = ResPool.GetPen (Color.FromArgb (255, 128, 128,128));
dc.FillRectangle (ResPool.GetSolidBrush (box.BackColor), rect);
+ text_format = new StringFormat();
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
+
size = dc.MeasureString (box.Text, box.Font);
width = (int) size.Width;
/* Text */
- if (box.Enabled)
- dc.DrawString (box.Text, box.Font, new SolidBrush (box.ForeColor), 10, 0);
- else
+ if (box.Enabled) {
+ dc.DrawString (box.Text, box.Font, new SolidBrush (box.ForeColor), 10, 0, text_format);
+ } else {
CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor,
- new RectangleF (10, 0, width, box.Font.Height), new StringFormat ());
+ new RectangleF (10, 0, width, box.Font.Height), text_format);
+ }
}
#region HScrollBar
public override Size HScrollBarDefaultSize {
get {
- return new Size (80,13);
+ return new Size (80, this.ScrollBarButtonSize);
}
}
#endregion // HScrollBar
#region Label
- public override void DrawLabel (Graphics dc, Rectangle clip_rectangle, Label label) {
- if (label_br_fore_color == null || label_br_fore_color.Color != label.ForeColor) {
- label_br_fore_color = GetControlForeBrush (label.ForeColor);
- }
-
- if (label_br_back_color == null || label_br_back_color.Color != label.BackColor) {
- label_br_back_color = GetControlBackBrush (label.BackColor);
- }
-
- dc.FillRectangle (label_br_back_color, clip_rectangle);
+ public override void DrawLabel (Graphics dc, Rectangle clip_rectangle, Label label)
+ {
+ dc.FillRectangle (ResPool.GetSolidBrush (label.BackColor), clip_rectangle);
- CPDrawBorderStyle (dc, clip_rectangle, label.BorderStyle);
+ CPDrawBorderStyle (dc, label.ClientRectangle, label.BorderStyle);
if (label.Enabled) {
- dc.DrawString (label.Text, label.Font, label_br_fore_color, clip_rectangle, label.string_format);
+ dc.DrawString (label.Text, label.Font, ResPool.GetSolidBrush (label.ForeColor), clip_rectangle, label.string_format);
} else {
ControlPaint.DrawStringDisabled (dc, label.Text, label.Font, label.ForeColor, clip_rectangle, label.string_format);
}
return new Size (100, 23);
}
}
- #endregion // Label
+ #endregion // Label\r
+\r
+ #region LinkLabel\r
+ public override void DrawLinkLabel (Graphics dc, Rectangle clip_rectangle, LinkLabel label)\r
+ {\r
+ Color color;\r
+\r
+ dc.FillRectangle (ResPool.GetSolidBrush (label.BackColor), clip_rectangle);\r
+ CPDrawBorderStyle (dc, label.ClientRectangle, label.BorderStyle);
+\r
+ for (int i = 0; i < label.num_pieces; i++) {
+
+ if (clip_rectangle.IntersectsWith (label.pieces[i].rect) == false) {
+ continue;
+ }
+ \r
+ color = label.GetLinkColor (label.pieces[i], i);\r
+\r
+ if (label.pieces[i].link == null)\r
+ dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (Color.Black),\r
+ label.pieces[i].rect.X, label.pieces[i].rect.Y);\r
+ else\r
+ dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (color),\r
+ label.pieces[i].rect.X, label.pieces[i].rect.Y);
+
+ if (label.pieces[i].focused) {
+ CPDrawFocusRectangle (dc, label.pieces[i].rect, label.ForeColor, label.BackColor);
+ }\r
+ }
+ \r
+ }\r
+ #endregion // LinkLabel\r
+ #region ListBox
+
+ // Drawing
+ public override void DrawListBoxDecorations (Graphics dc, ListBox ctrl)
+ {
+ Rectangle cl = ctrl.LBoxInfo.client_rect;
+
+ // Draw decorations
+ switch (ctrl.BorderStyle) {
+ case BorderStyle.Fixed3D: {
+ dc.DrawLine (ResPool.GetPen (ColorButtonShadow), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top
+ dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
+ dc.DrawLine (ResPool.GetPen (ColorButtonFace), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
+ dc.DrawLine (ResPool.GetPen (ColorButtonHilight), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
+ dc.DrawLine (ResPool.GetPen (ColorButtonShadow), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
+ dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2);
+ dc.DrawLine (ResPool.GetPen (ColorButtonFace), cl.X + cl.Width - 2, cl.Y, cl.X + cl.Width - 2, cl.Y + cl.Height); //right
+ dc.DrawLine (ResPool.GetPen (ColorButtonHilight), cl.X + cl.Width - 1, cl.Y + 1 , cl.X + cl.Width - 1, cl.Y + cl.Height - 1);
+ break;
+ }
+ case BorderStyle.FixedSingle:
+ dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame), cl.X, cl.Y, cl.Width - 1, cl.Height - 1);
+ break;
+ case BorderStyle.None:
+ default:
+ break;
+ }
+ }
+
+ private int DrawListBoxDecorationSize (BorderStyle border_style)
+ {
+ switch (border_style) {
+ case BorderStyle.Fixed3D:
+ return 2;
+ case BorderStyle.FixedSingle:
+ return 1;
+ case BorderStyle.None:
+ default:
+ break;
+ }
+
+ return 0;
+ }
+
+ // Sizing
+ public override int DrawListBoxDecorationTop (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
+ public override int DrawListBoxDecorationBottom (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
+ public override int DrawListBoxDecorationRight (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
+ public override int DrawListBoxDecorationLeft (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
+
+ public override void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e)
+ {
+ Color back_color, fore_color;
+ StringFormat string_format = ctrl.GetFormatString ();
+
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ back_color = ThemeEngine.Current.ColorHilight;
+ fore_color = ThemeEngine.Current.ColorHilightText;
+ }
+ else {
+ back_color = e.BackColor;
+ fore_color = e.ForeColor;
+ }
+
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
+ (back_color), e.Bounds);
+
+ e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
+ ThemeEngine.Current.ResPool.GetSolidBrush (fore_color),
+ e.Bounds, string_format);
+
+ if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
+ ThemeEngine.Current.CPDrawFocusRectangle (e.Graphics, e.Bounds,
+ fore_color, back_color);
+ }
+ }
+
+ #endregion ListBox
#region ListView
// Drawing
- public override void DrawListView (Graphics dc, Rectangle clip_rectangle, ListView control)
+ public override void DrawListView (Graphics dc, Rectangle clip, ListView control)
{
- Rectangle control_area = control.ClientRectangle;
+ bool details = (control.View == View.Details);
- // Draw the border of the list view with a background
- dc.FillRectangle (ResPool.GetSolidBrush (control.BackColor), control_area);
- this.CPDrawBorderStyle (dc, control_area, control.BorderStyle);
- if (control.View == View.Details)
- dc.FillRectangle (ResPool.GetSolidBrush (SystemColors.Control),
- 0, 0, control_area.Width, this.ColumnHeaderHeight);
- }
+ dc.FillRectangle (ResPool.GetSolidBrush (control.BackColor), clip);
- // Sizing
- public override Size ListViewDefaultSize {
- get {
- return new Size (121, 97);
- }
- }
+ // border is drawn directly in the Paint method
+ if (details && control.HeaderStyle != ColumnHeaderStyle.None) {
+ dc.FillRectangle (ResPool.GetSolidBrush (SystemColors.Control),
+ 0, 0, control.TotalWidth, control.Font.Height + 5);
+ if (control.Columns.Count > 0) {
+ if (control.HeaderStyle == ColumnHeaderStyle.Clickable) {
+ foreach (ColumnHeader col in control.Columns) {
+ this.CPDrawButton (dc, col.Rect,
+ (col.Pressed ?
+ ButtonState.Pushed :
+ ButtonState.Normal));
+ dc.DrawString (col.Text, ThemeEngine.Current.DefaultFont,
+ ResPool.GetSolidBrush
+ (this.ColorButtonText),
+ //col.Rect,
+ col.Rect.X + 3,
+ col.Rect.Y + col.Rect.Height/2 + 1,
+ col.Format);
+ }
+ }
+ // Non-clickable columns
+ else {
+ foreach (ColumnHeader col in control.Columns) {
+ this.CPDrawButton (dc, col.Rect, ButtonState.Flat);
+ dc.DrawString (col.Text, ThemeEngine.Current.DefaultFont,
+ ResPool.GetSolidBrush
+ (this.ColorButtonText),
+ //col.Rect,
+ col.Rect.X + 3,
+ col.Rect.Y + col.Rect.Height/2 + 1,
+ col.Format);
+ }
+ }
+ }
+ }
- public override int ColumnHeaderHeight {
- get {
- return 16;
+ // In case of details view draw the items only if
+ // columns are non-zero
+ if (!details || control.Columns.Count > 0)
+ foreach (ListViewItem item in control.Items) {
+ if (clip.IntersectsWith (item.EntireRect))
+ DrawListViewItem (dc, control, item);
+ }
+
+ // draw the gridlines
+ if (details && control.GridLines) {
+ int top = (control.HeaderStyle == ColumnHeaderStyle.None) ?
+ 2 : control.Font.Height + 2;
+
+ // draw vertical gridlines
+ foreach (ColumnHeader col in control.Columns)
+ dc.DrawLine (this.ResPool.GetPen (this.ColorButtonFace),
+ col.Rect.Right, top,
+ col.Rect.Right, control.TotalHeight);
+ // draw horizontal gridlines
+ ListViewItem last_item = null;
+ foreach (ListViewItem item in control.Items) {
+ dc.DrawLine (this.ResPool.GetPen (this.ColorButtonFace),
+ item.EntireRect.Left, item.EntireRect.Top,
+ control.TotalWidth, item.EntireRect.Top);
+ last_item = item;
+ }
+
+ // draw a line after at the bottom of the last item
+ if (last_item != null) {
+ dc.DrawLine (this.ResPool.GetPen (this.ColorButtonFace),
+ last_item.EntireRect.Left,
+ last_item.EntireRect.Bottom,
+ control.TotalWidth,
+ last_item.EntireRect.Bottom);
+ }
+ }
+ }
+
+ // draws the ListViewItem of the given index
+ private void DrawListViewItem (Graphics dc, ListView control, ListViewItem item)
+ {
+ if (control.CheckBoxes) {
+ if (control.StateImageList == null) {
+ // Make sure we've got at least a line width of 1
+ int check_wd = Math.Max (3, item.CheckRect.Width / 6);
+ int scale = Math.Max (1, item.CheckRect.Width / 12);
+
+ // set the checkbox background
+ dc.FillRectangle (this.ResPool.GetSolidBrush (this.ColorWindow),
+ item.CheckRect);
+ // define a rectangle inside the border area
+ Rectangle rect = new Rectangle (item.CheckRect.X + 2,
+ item.CheckRect.Y + 2,
+ item.CheckRect.Width - 4,
+ item.CheckRect.Height - 4);
+ Pen pen = new Pen (this.ColorWindowText, 2);
+ dc.DrawRectangle (pen, rect);
+
+ // Need to draw a check-mark
+ if (item.Checked) {
+ pen.Width = 1;
+ // adjustments to get the check-mark at the right place
+ rect.X ++; rect.Y ++;
+ // following logic is taken from DrawFrameControl method
+ for (int i = 0; i < check_wd; i++) {
+ dc.DrawLine (pen, rect.Left + check_wd / 2,
+ rect.Top + check_wd + i,
+ rect.Left + check_wd / 2 + 2 * scale,
+ rect.Top + check_wd + 2 * scale + i);
+ dc.DrawLine (pen,
+ rect.Left + check_wd / 2 + 2 * scale,
+ rect.Top + check_wd + 2 * scale + i,
+ rect.Left + check_wd / 2 + 6 * scale,
+ rect.Top + check_wd - 2 * scale + i);
+ }
+ }
+ }
+ else {
+ if (item.Checked && control.StateImageList.Images.Count > 1)
+ control.StateImageList.Draw (dc,
+ item.CheckRect.Location, 1);
+ else if (! item.Checked && control.StateImageList.Images.Count > 0)
+ control.StateImageList.Draw (dc,
+ item.CheckRect.Location, 0);
+ }
+ }
+
+ // Item is drawn as a special case, as it is not just text
+ if (control.View == View.LargeIcon) {
+ if (item.ImageIndex > -1 &&
+ control.LargeImageList != null &&
+ item.ImageIndex < control.LargeImageList.Images.Count)
+ control.LargeImageList.Draw (dc, item.IconRect.Location,
+ item.ImageIndex);
+ }
+ else {
+ if (item.ImageIndex > -1 &&
+ control.SmallImageList != null &&
+ item.ImageIndex < control.SmallImageList.Images.Count)
+ control.SmallImageList.Draw (dc, item.IconRect.Location,
+ item.ImageIndex);
+ }
+
+ // draw the item text
+ Rectangle text_rect = item.LabelRect;
+ // format for the item text
+ StringFormat format = new StringFormat ();
+ format.LineAlignment = StringAlignment.Center;
+ if (control.View == View.LargeIcon)
+ format.Alignment = StringAlignment.Center;
+ else
+ format.Alignment = StringAlignment.Near;
+
+ if (!control.LabelWrap)
+ format.FormatFlags = StringFormatFlags.NoWrap;
+
+ if (item.Selected) {
+ if (control.View == View.Details) {
+ if (control.FullRowSelect) {
+ // fill the entire rect excluding the checkbox
+ Rectangle full_rect = item.EntireRect;
+ full_rect.Location = item.LabelRect.Location;
+ dc.FillRectangle (this.ResPool.GetSolidBrush
+ (this.ColorHilight), full_rect);
+ }
+ else {
+ Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
+ item.Font));
+ text_rect.Width = text_size.Width;
+ dc.FillRectangle (this.ResPool.GetSolidBrush
+ (this.ColorHilight), text_rect);
+ }
+ }
+ else {
+ /*Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
+ item.Font));
+ Point loc = text_rect.Location;
+ loc.X += (text_rect.Width - text_size.Width) / 2;
+ text_rect.Width = text_size.Width;*/
+ dc.FillRectangle (this.ResPool.GetSolidBrush (this.ColorHilight),
+ text_rect);
+ }
}
+ else
+ dc.FillRectangle (ResPool.GetSolidBrush (item.BackColor), text_rect);
+
+ if (item.Text != null && item.Text.Length > 0) {
+ if (item.Selected)
+ dc.DrawString (item.Text, item.Font, this.ResPool.GetSolidBrush
+ (this.ColorHilightText), text_rect, format);
+ else
+ dc.DrawString (item.Text, item.Font, this.ResPool.GetSolidBrush
+ (item.ForeColor), text_rect, format);
+ }
+
+ if (control.View == View.Details && control.Columns.Count > 0) {
+ // draw subitems for details view
+ ListViewItem.ListViewSubItemCollection subItems = item.SubItems;
+ int count = (control.Columns.Count < subItems.Count ?
+ control.Columns.Count : subItems.Count);
+
+ if (count > 0) {
+ ColumnHeader col;
+ ListViewItem.ListViewSubItem subItem;
+ Rectangle sub_item_rect = item.LabelRect;
+
+ // set the format for subitems
+ format.FormatFlags = StringFormatFlags.NoWrap;
+ format.Alignment = StringAlignment.Near;
+
+ // 0th subitem is the item already drawn
+ for (int index = 1; index < count; index++) {
+ subItem = subItems [index];
+ col = control.Columns [index];
+ sub_item_rect.X = col.Rect.Left;
+ sub_item_rect.Width = col.Wd;
+
+ SolidBrush sub_item_back_br = null;
+ SolidBrush sub_item_fore_br = null;
+ Font sub_item_font = null;
+
+ if (item.UseItemStyleForSubItems) {
+ sub_item_back_br = this.ResPool.GetSolidBrush
+ (item.BackColor);
+ sub_item_fore_br = this.ResPool.GetSolidBrush
+ (item.ForeColor);
+ sub_item_font = item.Font;
+ }
+ else {
+ sub_item_back_br = this.ResPool.GetSolidBrush
+ (subItem.BackColor);
+ sub_item_fore_br = this.ResPool.GetSolidBrush
+ (subItem.ForeColor);
+ sub_item_font = subItem.Font;
+ }
+
+ // In case of fullrowselect, background is filled
+ // for the entire rect above
+ if (item.Selected && control.FullRowSelect) {
+ if (subItem.Text != null && subItem.Text.Length > 0)
+ dc.DrawString (subItem.Text, sub_item_font,
+ this.ResPool.GetSolidBrush
+ (this.ColorHilightText),
+ sub_item_rect, format);
+ }
+ else {
+ dc.FillRectangle (sub_item_back_br, sub_item_rect);
+ if (subItem.Text != null && subItem.Text.Length > 0)
+ dc.DrawString (subItem.Text, sub_item_font,
+ sub_item_fore_br,
+ sub_item_rect, format);
+ }
+ sub_item_rect.X += col.Wd;
+ }
+ }
+ }
+ }
+
+ // Sizing
+ public override Size ListViewCheckBoxSize {
+ get { return new Size (16, 16); }
+ }
+
+ public override int ListViewColumnHeaderHeight {
+ get { return 16; }
+ }
+
+ public override int ListViewDefaultColumnWidth {
+ get { return 60; }
+ }
+
+ public override int ListViewVerticalSpacing {
+ get { return 22; }
+ }
+
+ public override int ListViewEmptyColumnWidth {
+ get { return 10; }
+ }
+
+ public override int ListViewHorizontalSpacing {
+ get { return 10; }
+ }
+
+ public override Size ListViewDefaultSize {
+ get { return new Size (121, 97); }
}
#endregion // ListView
+
+ #region Menus
+ public override void CalcItemSize (Graphics dc, MenuAPI.MENUITEM item, int y, int x, bool menuBar)
+ {
+ item.rect.Y = y;
+ item.rect.X = x;
+
+ if (item.item.Visible == false)
+ return;
+
+ if (item.item.Separator == true) {
+ item.rect.Height = SEPARATOR_HEIGHT / 2;
+ item.rect.Width = -1;
+ return;
+ }
+
+ if (item.item.MeasureEventDefined) {
+ MeasureItemEventArgs mi = new MeasureItemEventArgs (dc, item.pos);
+ item.item.PerformMeasureItem (mi);
+ item.rect.Height = mi.ItemHeight;
+ item.rect.Width = mi.ItemWidth;
+ return;
+ } else {
+
+ SizeF size;
+ size = dc.MeasureString (item.item.Text, ThemeEngine.Current.MenuFont);
+ item.rect.Width = (int) size.Width;
+ item.rect.Height = (int) size.Height;
+
+ if (!menuBar) {
+
+ if (item.item.Shortcut != Shortcut.None && item.item.ShowShortcut) {
+ item.item.XTab = ThemeEngine.Current.MenuCheckSize.Width + MENU_TAB_SPACE + (int) size.Width;
+ size = dc.MeasureString (" " + item.item.GetShortCutText (), ThemeEngine.Current.MenuFont);
+ item.rect.Width += MENU_TAB_SPACE + (int) size.Width;
+ }
+
+ item.rect.Width += 4 + (ThemeEngine.Current.MenuCheckSize.Width * 2);
+ }
+ else {
+ item.rect.Width += MENU_BAR_ITEMS_SPACE;
+ x += item.rect.Width;
+ }
+
+ if (item.rect.Height < ThemeEngine.Current.MenuHeight)
+ item.rect.Height = ThemeEngine.Current.MenuHeight;
+ }
+ }
+
+ // Updates the menu rect and returns the height
+ public override int CalcMenuBarSize (Graphics dc, IntPtr hMenu, int width)
+ {
+ int x = 0;
+ int i = 0;
+ int y = 0;
+ MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);
+ menu.Height = 0;
+ MenuAPI.MENUITEM item;
+
+ while (i < menu.items.Count) {
+
+ item = (MenuAPI.MENUITEM) menu.items[i];
+ CalcItemSize (dc, item, y, x, true);
+ i = i + 1;
+
+ if (x + item.rect.Width > width) {
+ item.rect.X = 0;
+ y += item.rect.Height;
+ item.rect.Y = y;
+ x = 0;
+ }
+
+ x += item.rect.Width;
+ item.item.MenuBar = true;
+
+ if (y + item.rect.Height > menu.Height)
+ menu.Height = item.rect.Height + y;
+ }
+
+ menu.Width = width;
+ return menu.Height;
+ }
+
+
+ public override void CalcPopupMenuSize (Graphics dc, IntPtr hMenu)
+ {
+ int x = 3;
+ int start = 0;
+ int i, n, y, max;
+
+ MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);
+ menu.Height = 0;
+
+ while (start < menu.items.Count) {
+ y = 2;
+ max = 0;
+ for (i = start; i < menu.items.Count; i++) {
+ MenuAPI.MENUITEM item = (MenuAPI.MENUITEM) menu.items[i];
+
+ if ((i != start) && (item.item.Break || item.item.BarBreak))
+ break;
+
+ CalcItemSize (dc, item, y, x, false);
+ y += item.rect.Height;
+
+ if (item.rect.Width > max)
+ max = item.rect.Width;
+ }
+
+ // Reemplace the -1 by the menu width (separators)
+ for (n = start; n < i; n++, start++) {
+ MenuAPI.MENUITEM item = (MenuAPI.MENUITEM) menu.items[n];
+ item.rect.Width = max;
+ }
+
+ if (y > menu.Height)
+ menu.Height = y;
+
+ x+= max;
+ }
+
+ menu.Width = x;
+
+ //space for border
+ menu.Width += 2;
+ menu.Height += 2;
+
+ menu.Width += SM_CXBORDER;
+ menu.Height += SM_CYBORDER;
+ }
+
+ // Draws a menu bar in a window
+ public override void DrawMenuBar (Graphics dc, IntPtr hMenu, Rectangle rect)
+ {
+ MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);
+ Rectangle item_rect;
+
+ if (menu.Height == 0)
+ ThemeEngine.Current.CalcMenuBarSize (dc, hMenu, rect.Width);
+
+ rect.Height = menu.Height;
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (menu.Wnd.BackColor), rect);
+
+ for (int i = 0; i < menu.items.Count; i++) {
+ MenuAPI.MENUITEM it = (MenuAPI.MENUITEM) menu.items[i];
+ item_rect = it.rect;
+ item_rect.X += rect.X;
+ item_rect.Y += rect.Y;
+ it.item.MenuHeight = menu.Height;
+ it.item.PerformDrawItem (new DrawItemEventArgs (dc, ThemeEngine.Current.MenuFont,
+ item_rect, i, it.item.Status));
+
+ }
+ }
+
+ public override void DrawMenuItem (MenuItem item, DrawItemEventArgs e)
+ {
+ StringFormat string_format;
+ Rectangle rect_text = e.Bounds;
+
+ if (item.Visible == false)
+ return;
+
+ if (item.MenuBar) {
+ string_format = string_format_menu_menubar_text;
+ }
+ else {
+ string_format = string_format_menu_text;
+ }
+
+ if (item.Separator == true) {
+ e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+ e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y);
+
+ e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonHilight),
+ e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + 1);
+
+ return;
+ }
+
+ if (!item.MenuBar)
+ rect_text.X += ThemeEngine.Current.MenuCheckSize.Width;
+
+ if (item.BarBreak) { /* Draw vertical break bar*/
+ Rectangle rect = e.Bounds;
+ rect.Y++;
+ rect.Width = 3;
+ rect.Height = item.MenuHeight - 6;
+
+ e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+ rect.X, rect.Y , rect.X, rect.Y + rect.Height);
+
+ e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonHilight),
+ rect.X + 1, rect.Y , rect.X +1, rect.Y + rect.Height);
+ }
+
+ Color color_text;
+ Color color_back;
+
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ color_text = ThemeEngine.Current.ColorHilightText;
+ color_back = ThemeEngine.Current.ColorHilight;
+ }
+ else {
+ color_text = ThemeEngine.Current.ColorMenuText;
+ color_back = ThemeEngine.Current.ColorMenu;
+ }
+
+ /* Draw background */
+ Rectangle rect_back = e.Bounds;
+ rect_back.X++;
+ rect_back.Width -=2;
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (color_back), rect_back);
+
+ if (item.Enabled) {
+ e.Graphics.DrawString (item.Text, e.Font,
+ ThemeEngine.Current.ResPool.GetSolidBrush (color_text),
+ rect_text, string_format);
+
+ if (!item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut) {
+ string str = item.GetShortCutText ();
+ Rectangle rect = rect_text;
+ rect.X = item.XTab;
+ rect.Width -= item.XTab;
+
+ e.Graphics.DrawString (str, e.Font, ThemeEngine.Current.ResPool.GetSolidBrush (color_text),
+ rect, string_format_menu_shortcut);
+ }
+ }
+ else {
+ ControlPaint.DrawStringDisabled (e.Graphics, item.Text, e.Font,
+ Color.Black, rect_text, string_format);
+ }
+
+ /* Draw arrow */
+ if (item.MenuBar == false && item.IsPopup) {
+
+ int cx = ThemeEngine.Current.MenuCheckSize.Width;
+ int cy = ThemeEngine.Current.MenuCheckSize.Height;
+ Bitmap bmp = new Bitmap (cx, cy);
+ Graphics gr = Graphics.FromImage (bmp);
+ Rectangle rect_arrow = new Rectangle (0, 0, cx, cy);
+ ControlPaint.DrawMenuGlyph (gr, rect_arrow, MenuGlyph.Arrow);
+ bmp.MakeTransparent ();
+
+ if (item.Enabled) {
+ e.Graphics.DrawImage (bmp, e.Bounds.X + e.Bounds.Width - cx,
+ e.Bounds.Y + ((e.Bounds.Height - cy) /2));
+ } else {
+ ControlPaint.DrawImageDisabled (e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
+ e.Bounds.Y + ((e.Bounds.Height - cy) /2), color_back);
+ }
+
+ gr.Dispose ();
+ bmp.Dispose ();
+ }
+
+ /* Draw checked or radio */
+ if (item.MenuBar == false && item.Checked) {
+
+ Rectangle area = e.Bounds;
+ int cx = ThemeEngine.Current.MenuCheckSize.Width;
+ int cy = ThemeEngine.Current.MenuCheckSize.Height;
+ Bitmap bmp = new Bitmap (cx, cy);
+ Graphics gr = Graphics.FromImage (bmp);
+ Rectangle rect_arrow = new Rectangle (0, 0, cx, cy);
+
+ if (item.RadioCheck)
+ ControlPaint.DrawMenuGlyph (gr, rect_arrow, MenuGlyph.Bullet);
+ else
+ ControlPaint.DrawMenuGlyph (gr, rect_arrow, MenuGlyph.Checkmark);
+
+ bmp.MakeTransparent ();
+ e.Graphics.DrawImage (bmp, area.X, e.Bounds.Y + ((e.Bounds.Height - cy) / 2));
+
+ gr.Dispose ();
+ bmp.Dispose ();
+ }
+ }
+
+ public override void DrawPopupMenu (Graphics dc, IntPtr hMenu, Rectangle cliparea, Rectangle rect)
+ {
+ MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);
+
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
+ (ThemeEngine.Current.ColorMenu), cliparea);
+
+ /* Draw menu borders */
+ dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorHilightText),
+ rect.X, rect.Y, rect.X + rect.Width, rect.Y);
+
+ dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorHilightText),
+ rect.X, rect.Y, rect.X, rect.Y + rect.Height);
+
+ dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+ rect.X + rect.Width - 1 , rect.Y , rect.X + rect.Width - 1, rect.Y + rect.Height);
+
+ dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonDkShadow),
+ rect.X + rect.Width, rect.Y , rect.X + rect.Width, rect.Y + rect.Height);
+
+ dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+ rect.X , rect.Y + rect.Height - 1 , rect.X + rect.Width - 1, rect.Y + rect.Height -1);
+
+ dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonDkShadow),
+ rect.X , rect.Y + rect.Height, rect.X + rect.Width - 1, rect.Y + rect.Height);
+
+ for (int i = 0; i < menu.items.Count; i++)
+ if (cliparea.IntersectsWith (((MenuAPI.MENUITEM) menu.items[i]).rect)) {
+ MenuAPI.MENUITEM it = (MenuAPI.MENUITEM) menu.items[i];
+ it.item.MenuHeight = menu.Height;
+ it.item.PerformDrawItem (new DrawItemEventArgs (dc, ThemeEngine.Current.MenuFont,
+ it.rect, i, it.item.Status));
+ }
+ }
+
+ #endregion // Menus
+
+ #region MonthCalendar
+
+ // draw the month calendar
+ public override void DrawMonthCalendar(Graphics dc, Rectangle clip_rectangle, MonthCalendar mc) \r
+ {
+ Rectangle client_rectangle = mc.ClientRectangle;
+ Size month_size = mc.SingleMonthSize;
+ // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
+ Size calendar_spacing = (Size)((object)mc.calendar_spacing);
+ Size date_cell_size = (Size)((object)mc.date_cell_size);
+
+ // draw the singlecalendars
+ int x_offset = 1;
+ int y_offset = 1;
+ // adjust for the position of the specific month
+ for (int i=0; i < mc.CalendarDimensions.Height; i++) \r
+ {
+ if (i > 0) \r
+ {
+ y_offset += month_size.Height + calendar_spacing.Height;
+ }
+ // now adjust for x position
+ for (int j=0; j < mc.CalendarDimensions.Width; j++) \r
+ {
+ if (j > 0) \r
+ {
+ x_offset += month_size.Width + calendar_spacing.Width;
+ } \r
+ else \r
+ {
+ x_offset = 1;
+ }
+
+ Rectangle month_rect = new Rectangle (x_offset, y_offset, month_size.Width, month_size.Height);
+ if (month_rect.IntersectsWith (clip_rectangle)) {
+ DrawSingleMonth (
+ dc,
+ clip_rectangle,
+ month_rect,
+ mc,
+ i,
+ j);
+ }
+ }
+ }
+
+ Rectangle bottom_rect = new Rectangle (
+ client_rectangle.X,
+ Math.Max(client_rectangle.Bottom - date_cell_size.Height - 3, 0),
+ client_rectangle.Width,
+ date_cell_size.Height + 2);
+ // draw the today date if it's set
+ if (mc.ShowToday && bottom_rect.IntersectsWith (clip_rectangle)) \r
+ {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), bottom_rect);
+ if (mc.ShowToday) {
+ int today_offset = 5;
+ if (mc.ShowTodayCircle) \r
+ {
+ Rectangle today_circle_rect = new Rectangle (
+ client_rectangle.X + 5,
+ Math.Max(client_rectangle.Bottom - date_cell_size.Height - 2, 0),
+ date_cell_size.Width,
+ date_cell_size.Height);
+ DrawTodayCircle (dc, today_circle_rect);
+ today_offset += date_cell_size.Width + 5;
+ }
+ // draw today's date
+ StringFormat text_format = new StringFormat();
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.Alignment = StringAlignment.Near;
+ Font bold_font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
+ Rectangle today_rect = new Rectangle (
+ today_offset + client_rectangle.X,
+ Math.Max(client_rectangle.Bottom - date_cell_size.Height, 0),
+ Math.Max(client_rectangle.Width - today_offset, 0),
+ date_cell_size.Height);
+ dc.DrawString ("Today: " + DateTime.Now.ToShortDateString(), bold_font, ResPool.GetSolidBrush (mc.ForeColor), today_rect, text_format);
+ }
+ }
+
+ // finally paint the borders of the calendars as required
+ for (int i = 0; i <= mc.CalendarDimensions.Width; i++) {
+ if (i == 0 && clip_rectangle.X == client_rectangle.X) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, 1, client_rectangle.Height));
+ } else if (i == mc.CalendarDimensions.Width && clip_rectangle.Right == client_rectangle.Right) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.Right-1, client_rectangle.Y, 1, client_rectangle.Height));
+ } else {
+ Rectangle rect = new Rectangle (
+ client_rectangle.X + (month_size.Width*i) + (calendar_spacing.Width * (i-1)) + 1,
+ client_rectangle.Y,
+ calendar_spacing.Width,
+ client_rectangle.Height);
+ if (i < mc.CalendarDimensions.Width && i > 0 && clip_rectangle.IntersectsWith (rect)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
+ }
+ }
+ }
+ for (int i = 0; i <= mc.CalendarDimensions.Height; i++) {
+ if (i == 0 && clip_rectangle.Y == client_rectangle.Y) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, client_rectangle.Width, 1));
+ } else if (i == mc.CalendarDimensions.Height && clip_rectangle.Bottom == client_rectangle.Bottom) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Bottom-1, client_rectangle.Width, 1));
+ } else {
+ Rectangle rect = new Rectangle (
+ client_rectangle.X,
+ client_rectangle.Y + (month_size.Height*i) + (calendar_spacing.Height*(i-1)) + 1,
+ client_rectangle.Width,
+ calendar_spacing.Height);
+ if (i < mc.CalendarDimensions.Height && i > 0 && clip_rectangle.IntersectsWith (rect)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
+ }
+ }
+ }
+
+ // draw the drop down border if need
+ if (mc.owner != null) {
+ Rectangle bounds = mc.ClientRectangle;
+ if (clip_rectangle.Contains (mc.Location)) {
+ // find out if top or left line to draw
+ if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
+
+ dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.X, bounds.Bottom-1);
+ }
+ if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
+ dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.Right-1, bounds.Y);
+ }
+ }
+ if (clip_rectangle.Contains (new Point(bounds.Right, bounds.Bottom))) {
+ // find out if bottom or right line to draw
+ if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
+ dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1);
+ }
+ if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
+ dc.DrawLine (SystemPens.ControlText, bounds.Right-1, bounds.Y, bounds.Right-1, bounds.Bottom-1);
+ }
+ }
+ }
+ }
+
+ // darws a single part of the month calendar (with one month)
+ private void DrawSingleMonth(Graphics dc, Rectangle clip_rectangle, Rectangle rectangle, MonthCalendar mc, int row, int col) \r
+ {
+ // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
+ Size title_size = (Size)((object)mc.title_size);
+ Size date_cell_size = (Size)((object)mc.date_cell_size);
+ DateTime current_month = (DateTime)((object)mc.current_month);
+
+ // set up some standard string formating variables
+ StringFormat text_format = new StringFormat();
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.Alignment = StringAlignment.Center;
+
+
+ // draw the title back ground
+ DateTime this_month = current_month.AddMonths (row*mc.CalendarDimensions.Width+col);
+ Rectangle title_rect = new Rectangle(rectangle.X, rectangle.Y, title_size.Width, title_size.Height);
+ if (title_rect.IntersectsWith (clip_rectangle)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), title_rect);
+ // draw the title
+ string title_text = this_month.ToString ("MMMM yyyy");
+ dc.DrawString (title_text, mc.Font, ResPool.GetSolidBrush (mc.TitleForeColor), title_rect, text_format);
+
+ // draw previous and next buttons if it's time
+ if (row == 0 && col == 0) \r
+ {
+ // draw previous button
+ DrawMonthCalendarButton (
+ dc,
+ rectangle,
+ mc,
+ title_size,
+ mc.button_x_offset,
+ (System.Drawing.Size)((object)mc.button_size),
+ true);
+ }
+ if (row == 0 && col == mc.CalendarDimensions.Width-1) \r
+ {
+ // draw next button
+ DrawMonthCalendarButton (
+ dc,
+ rectangle,
+ mc,
+ title_size,
+ mc.button_x_offset,
+ (System.Drawing.Size)((object)mc.button_size),
+ false);
+ }
+ }
+
+ // set the week offset and draw week nums if needed
+ int col_offset = (mc.ShowWeekNumbers) ? 1 : 0;
+ Rectangle day_name_rect = new Rectangle(
+ rectangle.X,
+ rectangle.Y + title_size.Height,
+ (7 + col_offset) * date_cell_size.Width,
+ date_cell_size.Height);
+ if (day_name_rect.IntersectsWith (clip_rectangle)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), day_name_rect);
+ // draw the day names
+ DayOfWeek first_day_of_week = mc.GetDayOfWeek(mc.FirstDayOfWeek);
+ for (int i=0; i < 7; i++) \r
+ {
+ int position = i - (int) first_day_of_week;
+ if (position < 0) \r
+ {
+ position = 7 + position;
+ }
+ // draw it
+ Rectangle day_rect = new Rectangle(
+ day_name_rect.X + ((i + col_offset)* date_cell_size.Width),
+ day_name_rect.Y,
+ date_cell_size.Width,
+ date_cell_size.Height);
+ dc.DrawString (((DayOfWeek)i).ToString().Substring(0, 3), mc.Font, ResPool.GetSolidBrush (mc.TitleBackColor), day_rect, text_format);
+ }
+
+ // draw the vertical divider
+ int vert_divider_y = Math.Max(title_size.Height+ date_cell_size.Height-1, 0);
+ dc.DrawLine (
+ ResPool.GetPen (mc.ForeColor),
+ rectangle.X + (col_offset * date_cell_size.Width) + mc.divider_line_offset,
+ rectangle.Y + vert_divider_y,
+ rectangle.Right - mc.divider_line_offset,
+ rectangle.Y + vert_divider_y);
+ }
+
+
+ // draw the actual date items in the grid (including the week numbers)
+ Rectangle date_rect = new Rectangle (
+ rectangle.X,
+ rectangle.Y + title_size.Height + date_cell_size.Height,
+ date_cell_size.Width,
+ date_cell_size.Height);
+ int month_row_count = 0;
+ bool draw_week_num_divider = false;
+ DateTime current_date = mc.GetFirstDateInMonthGrid ( new DateTime (this_month.Year, this_month.Month, 1));
+ for (int i=0; i < 6; i++) \r
+ {
+ // establish if this row is in our clip_area
+ Rectangle row_rect = new Rectangle (
+ rectangle.X,
+ rectangle.Y + title_size.Height + (date_cell_size.Height * (i+1)),
+ date_cell_size.Width * 7,
+ date_cell_size.Height);
+ if (mc.ShowWeekNumbers) {
+ row_rect.Width += date_cell_size.Width;
+ }
+
+ bool draw_row = row_rect.IntersectsWith (clip_rectangle);
+ if (draw_row) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), row_rect);
+ }
+ // establish if this is a valid week to draw
+ if (mc.IsValidWeekToDraw (this_month, current_date, row, col)) {
+ month_row_count = i;
+ }
+
+ // draw the week number if required
+ if (mc.ShowWeekNumbers && month_row_count == i) {
+ if (!draw_week_num_divider) {
+ draw_week_num_divider = draw_row;
+ }
+ // get the week for this row
+ int week = mc.GetWeekOfYear (current_date);
+
+ if (draw_row) {
+ dc.DrawString (
+ week.ToString(),
+ mc.Font,
+ ResPool.GetSolidBrush (mc.TitleBackColor),
+ date_rect,
+ text_format);
+ }
+ date_rect.Offset(date_cell_size.Width, 0);
+ }
+
+ // only draw the days if we have to
+ if(month_row_count == i) {
+ for (int j=0; j < 7; j++) \r
+ {
+ if (draw_row) {
+ DrawMonthCalendarDate (
+ dc,
+ date_rect,
+ mc,
+ current_date,
+ this_month,
+ row,
+ col);
+ }
+
+ // move the day on
+ current_date = current_date.AddDays(1);
+ date_rect.Offset(date_cell_size.Width, 0);
+ }
+
+ // shift the rectangle down one row
+ int offset = (mc.ShowWeekNumbers) ? -8 : -7;
+ date_rect.Offset(offset*date_cell_size.Width, date_cell_size.Height);
+ }
+ }
+
+ // month_row_count is zero based, so add one
+ month_row_count++;
+
+ // draw week numbers if required
+ if (draw_week_num_divider) {
+ col_offset = 1;
+ dc.DrawLine (
+ ResPool.GetPen (mc.ForeColor),
+ rectangle.X + date_cell_size.Width - 1,
+ rectangle.Y + title_size.Height + date_cell_size.Height + mc.divider_line_offset,
+ rectangle.X + date_cell_size.Width - 1,
+ rectangle.Y + title_size.Height + date_cell_size.Height + (month_row_count * date_cell_size.Height) - mc.divider_line_offset);
+ }
+ }
+
+ // draws the pervious or next button
+ private void DrawMonthCalendarButton (Graphics dc, Rectangle rectangle, MonthCalendar mc, Size title_size, int x_offset, Size button_size, bool is_previous) \r
+ {
+ bool is_clicked = false;
+ Rectangle button_rect;
+ Rectangle arrow_rect = new Rectangle (rectangle.X, rectangle.Y, 4, 7);
+ Point[] arrow_path = new Point[3];
+ // prepare the button
+ if (is_previous) \r
+ {
+ is_clicked = mc.is_previous_clicked;
+ button_rect = new Rectangle (
+ rectangle.X + 1 + x_offset,
+ rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
+ Math.Max(button_size.Width - 1, 0),
+ Math.Max(button_size.Height - 1, 0));
+ arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
+ arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
+ if (is_clicked) {
+ arrow_rect.Offset(1,1);
+ }
+ arrow_path[0] = new Point (arrow_rect.Right, arrow_rect.Y);
+ arrow_path[1] = new Point (arrow_rect.X, arrow_rect.Y + arrow_rect.Height/2);
+ arrow_path[2] = new Point (arrow_rect.Right, arrow_rect.Bottom);
+ }
+ else
+ {
+ is_clicked = mc.is_next_clicked;
+ button_rect = new Rectangle (
+ rectangle.Right - 1 - x_offset - button_size.Width,
+ rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
+ Math.Max(button_size.Width - 1, 0),
+ Math.Max(button_size.Height - 1, 0));
+ arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
+ arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
+ if (is_clicked) {
+ arrow_rect.Offset(1,1);
+ }
+ arrow_path[0] = new Point (arrow_rect.X, arrow_rect.Y);
+ arrow_path[1] = new Point (arrow_rect.Right, arrow_rect.Y + arrow_rect.Height/2);
+ arrow_path[2] = new Point (arrow_rect.X, arrow_rect.Bottom);
+ }
+
+ // fill the background
+ dc.FillRectangle (SystemBrushes.Control, button_rect);
+ // draw the border
+ if (is_clicked) {
+ dc.DrawRectangle (SystemPens.ControlDark, button_rect);
+ }
+ else {
+ CPDrawBorder3D (dc, button_rect, Border3DStyle.Raised, Border3DSide.All);
+ }
+ // draw the arrow
+ dc.FillPolygon (SystemBrushes.ControlText, arrow_path);
+ }
+
+
+ // draws one day in the calendar grid
+ private void DrawMonthCalendarDate (Graphics dc, Rectangle rectangle, MonthCalendar mc, DateTime date, DateTime month, int row, int col) {
+ Color date_color = mc.ForeColor;
+ Rectangle interior = new Rectangle (rectangle.X, rectangle.Y, Math.Max(rectangle.Width - 1, 0), Math.Max(rectangle.Height - 1, 0));
+
+ // find out if we are the lead of the first calendar or the trail of the last calendar
+ if (date.Year != month.Year || date.Month != month.Month) {
+ DateTime check_date = month.AddMonths (-1);
+ // check if it's the month before
+ if (check_date.Year == date.Year && check_date.Month == date.Month && row == 0 && col == 0) {
+ date_color = mc.TrailingForeColor;
+ } else {
+ // check if it's the month after
+ check_date = month.AddMonths (1);
+ if (check_date.Year == date.Year && check_date.Month == date.Month && row == mc.CalendarDimensions.Height-1 && col == mc.CalendarDimensions.Width-1) {
+ date_color = mc.TrailingForeColor;
+ } else {
+ return;
+ }
+ }
+ } else {
+ date_color = mc.ForeColor;
+ }
+
+
+ if (date == mc.SelectionStart && date == mc.SelectionEnd) {
+ // see if the date is in the start of selection
+ date_color = mc.BackColor;
+ // draw the left hand of the back ground
+ Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
+ dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 0, 359);
+ } else if (date == mc.SelectionStart) {
+ // see if the date is in the start of selection
+ date_color = mc.BackColor;
+ // draw the left hand of the back ground
+ Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
+ dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 90, 180);
+ // fill the other side as a straight rect
+ if (date < mc.SelectionEnd) \r
+ {
+ // use rectangle instead of rectangle to go all the way to edge of rect
+ selection_rect.X = (int) Math.Floor((double)(rectangle.X + rectangle.Width / 2));
+ selection_rect.Width = Math.Max(rectangle.Right - selection_rect.X, 0);
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
+ }
+ } else if (date == mc.SelectionEnd) {
+ // see if it is the end of selection
+ date_color = mc.BackColor;
+ // draw the left hand of the back ground
+ Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
+ dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 270, 180);
+ // fill the other side as a straight rect
+ if (date > mc.SelectionStart) {
+ selection_rect.X = rectangle.X;
+ selection_rect.Width = rectangle.Width - (rectangle.Width / 2);
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
+ }
+ } else if (date > mc.SelectionStart && date < mc.SelectionEnd) {
+ // now see if it's in the middle
+ date_color = mc.BackColor;
+ // draw the left hand of the back ground
+ Rectangle selection_rect = Rectangle.Inflate(rectangle, 0, -3);
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
+ }
+
+ // set up some standard string formating variables
+ StringFormat text_format = new StringFormat();
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.Alignment = StringAlignment.Center;
+
+
+ // establish if it's a bolded font
+ Font font;
+ if (mc.IsBoldedDate (date)) {
+ font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
+ } else {
+ font = mc.Font;
+ }
+
+ // just draw the date now
+ dc.DrawString (date.Day.ToString(), font, ResPool.GetSolidBrush (date_color), rectangle, text_format);
+
+ // today circle if needed
+ if (mc.ShowTodayCircle && date == DateTime.Now.Date) {
+ DrawTodayCircle (dc, interior);
+ }
+
+ // draw the selection grid
+ if (mc.is_date_clicked && mc.clicked_date == date) {
+ using (Pen pen = new Pen (Color.Black, 1) ) {
+ pen.DashStyle = DashStyle.Dot;
+ dc.DrawRectangle (pen, interior);
+ }
+ }
+ }
+
+ private void DrawTodayCircle (Graphics dc, Rectangle rectangle) {
+ Color circle_color = Color.FromArgb (248, 0, 0);
+ // draw the left hand of the circle
+ Rectangle lhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 4, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 5, 0));
+ Rectangle rhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 1, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 2, 0));
+ Point [] curve_points = new Point [3];
+ curve_points [0] = new Point (lhs_circle_rect.X, rhs_circle_rect.Y + rhs_circle_rect.Height/12);
+ curve_points [1] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/9, rhs_circle_rect.Y);
+ curve_points [2] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/2 + 1, rhs_circle_rect.Y);
+
+ using (Pen pen = new Pen (circle_color, 2)) {
+ dc.DrawArc (pen, lhs_circle_rect, 90, 180);
+ dc.DrawArc (pen, rhs_circle_rect, 270, 180);
+ dc.DrawCurve (pen, curve_points);
+ dc.DrawLine (ResPool.GetPen (circle_color), curve_points [2], new Point (curve_points [2].X, lhs_circle_rect.Y));
+ }
+ }
+
+ #endregion // MonthCalendar
#region Panel
public override Size PanelDefaultSize {
#endregion // Panel
#region PictureBox
- public override void DrawPictureBox (Graphics dc, PictureBox pb) {
+ public override void DrawPictureBox (Graphics dc, Rectangle clip, PictureBox pb) {
Rectangle client = pb.ClientRectangle;
- int x, y, width, height;
-
- dc.FillRectangle (new SolidBrush (pb.BackColor), client);
- x = y = 0;
if (pb.Image != null) {
switch (pb.SizeMode) {
case PictureBoxSizeMode.StretchImage:
- width = client.Width;
- height = client.Height;
+ dc.DrawImage (pb.Image, 0, 0, client.Width, client.Height);
break;
+
case PictureBoxSizeMode.CenterImage:
- width = client.Width;
- height = client.Height;
- x = width / 2;
- y = (height - pb.Image.Height) / 2;
+ dc.DrawImage (pb.Image, (client.Width / 2) - (pb.Image.Width / 2), (client.Height / 2) - (pb.Image.Height / 2));
break;
default:
// Normal, AutoSize
- width = client.Width;
- height = client.Height;
+ dc.DrawImage(pb.Image, 0, 0);
break;
}
- dc.DrawImage (pb.Image, x, y, width, height);
}
CPDrawBorderStyle (dc, client, pb.BorderStyle);
}
#endregion // PictureBox
#region ProgressBar
- public override void DrawProgressBar (Graphics dc, Rectangle clip_rectangle, ProgressBar progress_bar) {
- Rectangle client_area = progress_bar.client_area;
- Rectangle paint_area = progress_bar.paint_area;
- int steps = (progress_bar.Maximum - progress_bar.Minimum) / progress_bar.step;
- int space_betweenblocks = 2;
- int x;
+ public override void DrawProgressBar (Graphics dc, Rectangle clip_rect, ProgressBar ctrl)
+ {
+ Rectangle block_rect;
+ Rectangle client_area = ctrl.client_area;
+ int space_betweenblocks = 2;
int block_width;
int increment;
int barpos_pixels;
-
- x = client_area.X;
+
block_width = ((client_area.Height) * 2 ) / 3;
- barpos_pixels = ((progress_bar.Value - progress_bar.Minimum) * client_area.Width) / (progress_bar.Maximum - progress_bar.Minimum);
+ barpos_pixels = ((ctrl.Value - ctrl.Minimum) * client_area.Width) / (ctrl.Maximum - ctrl.Minimum);
increment = block_width + space_betweenblocks;
/* Draw border */
- CPDrawBorder3D (dc, progress_bar.paint_area, Border3DStyle.SunkenInner, Border3DSide.All, ColorButtonFace);
+ CPDrawBorder3D (dc, ctrl.ClientRectangle, Border3DStyle.SunkenInner, Border3DSide.All & ~Border3DSide.Middle, ColorButtonFace);
/* Draw Blocks */
- while ((x - client_area.X) < barpos_pixels) {
- dc.FillRectangle (br_progressbarblock, x, client_area.Y, block_width, client_area.Height);
- x = x + increment;
+ block_rect = new Rectangle (client_area.X, client_area.Y, block_width, client_area.Height);
+ while ((block_rect.X - client_area.X) < barpos_pixels) {
+
+ if (clip_rect.IntersectsWith (block_rect) == true) {
+ dc.FillRectangle (ResPool.GetSolidBrush (progressbarblock_color), block_rect);
+ }
+
+ block_rect.X += increment;
}
}
Rectangle radiobutton_rectangle;
SolidBrush sb;
int radiobutton_size = 12;
+ int radiobutton_space = 4;
client_rectangle = radio_button.ClientRectangle;
text_rectangle = client_rectangle;
text_format = new StringFormat();
text_format.Alignment = StringAlignment.Near;
text_format.LineAlignment = StringAlignment.Center;
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
/* Calculate the position of text and checkbox rectangle */
if (radio_button.appearance!=Appearance.Button) {
radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
text_rectangle.X=client_rectangle.X;
text_rectangle.Width=client_rectangle.Width;
+ text_rectangle.Height=client_rectangle.Height-radiobutton_size-radiobutton_space;
break;
}
case ContentAlignment.BottomLeft: {
radiobutton_rectangle.X=client_rectangle.Left;
radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
- text_rectangle.X=client_rectangle.X+radiobutton_size;
- text_rectangle.Width=client_rectangle.Width-radiobutton_size;
+ text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
+ text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
break;
}
radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
text_rectangle.X=client_rectangle.X;
- text_rectangle.Width=client_rectangle.Width-radiobutton_size;
+ text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
break;
}
case ContentAlignment.MiddleLeft: {
radiobutton_rectangle.X=client_rectangle.Left;
radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
- text_rectangle.X=client_rectangle.X+radiobutton_size;
- text_rectangle.Width=client_rectangle.Width-radiobutton_size;
+ text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
+ text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
break;
}
radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
text_rectangle.X=client_rectangle.X;
- text_rectangle.Width=client_rectangle.Width-radiobutton_size;
+ text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
break;
}
radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
radiobutton_rectangle.Y=client_rectangle.Top;
text_rectangle.X=client_rectangle.X;
- text_rectangle.Y=radiobutton_size;
+ text_rectangle.Y=radiobutton_size+radiobutton_space;
text_rectangle.Width=client_rectangle.Width;
- text_rectangle.Height=client_rectangle.Height-radiobutton_size;
+ text_rectangle.Height=client_rectangle.Height-radiobutton_size-radiobutton_space;
break;
}
case ContentAlignment.TopLeft: {
radiobutton_rectangle.X=client_rectangle.Left;
radiobutton_rectangle.Y=client_rectangle.Top;
- text_rectangle.X=client_rectangle.X+radiobutton_size;
- text_rectangle.Width=client_rectangle.Width-radiobutton_size;
+ text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
+ text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
break;
}
radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
radiobutton_rectangle.Y=client_rectangle.Top;
text_rectangle.X=client_rectangle.X;
- text_rectangle.Width=client_rectangle.Width-radiobutton_size;
+ text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
break;
}
}
text_rectangle.X=client_rectangle.X;
text_rectangle.Width=client_rectangle.Width;
}
-
+
/* Set the horizontal alignment of our text */
switch(radio_button.text_alignment) {
case ContentAlignment.BottomLeft:
dc.FillRectangle(sb, radio_button.ClientRectangle);
sb.Dispose();
- // establish if we are rendering a flat style of some sort
- if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
- DrawFlatStyleRadioButton (dc, radiobutton_rectangle, radio_button);
+
+
+ if (radio_button.appearance==Appearance.Button) {
+ if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
+ DrawFlatStyleButton(dc, radio_button.ClientRectangle, radio_button);
+ } else {
+ CPDrawButton(dc, radio_button.ClientRectangle, state);
+ }
} else {
- // render as per normal
- if (radio_button.appearance!=Appearance.Button) {
- ControlPaint.DrawRadioButton (dc, radiobutton_rectangle, state);
+ // establish if we are rendering a flat style of some sort
+ if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
+ DrawFlatStyleRadioButton (dc, radiobutton_rectangle, radio_button);
} else {
- ControlPaint.DrawButton (dc, text_rectangle, state);
+ ControlPaint.DrawRadioButton (dc, radiobutton_rectangle, state);
}
}
- // wind32 compat - win32 seems to give the text a slight (3px) offset when rendering
- Rectangle inner_text_rectangle = new Rectangle (text_rectangle.X + 3, text_rectangle.Y, Math.Max (text_rectangle.Width - 3, 0), text_rectangle.Height);
-
- /* Place the text; to be compatible with Windows place it after the radiobutton has been drawn */
- sb=new SolidBrush(radio_button.ForeColor);
- dc.DrawString (radio_button.Text, radio_button.Font, sb, inner_text_rectangle, text_format);
- sb.Dispose();
+ // offset the text if it's pressed and a button
+ if (radio_button.Appearance == Appearance.Button) {
+ if (radio_button.Checked || (radio_button.Capture && radio_button.FlatStyle != FlatStyle.Flat)) {
+ text_rectangle.X ++;
+ text_rectangle.Y ++;
+ }
+
+ text_rectangle.Inflate(-4,-4);
+ }
+
+ /* Place the text; to be compatible with Windows place it after the radiobutton has been drawn */
+ dc.DrawString (radio_button.Text, radio_button.Font, ThemeEngine.Current.ResPool.GetSolidBrush (radio_button.ForeColor), text_rectangle, text_format);
+
+ if (radio_button.Enabled) {
+ sb = ResPool.GetSolidBrush(radio_button.ForeColor);
+ dc.DrawString(radio_button.Text, radio_button.Font, sb, text_rectangle, text_format);
+ } else if (radio_button.FlatStyle == FlatStyle.Flat) {
+ dc.DrawString(radio_button.Text, radio_button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), text_rectangle, text_format);
+ } else {
+ CPDrawStringDisabled(dc, radio_button.Text, radio_button.Font, this.ColorButtonText, text_rectangle, text_format);
+ }
if (radio_button.Focused) {
- ControlPaint.DrawFocusRectangle(dc, text_rectangle);
- }
+ if (radio_button.FlatStyle != FlatStyle.Flat) {
+ DrawInnerFocusRectangle (dc, text_rectangle, radio_button.BackColor);
+ } else {
+ dc.DrawRectangle (ResPool.GetPen (radio_button.ForeColor), text_rectangle);
+ }
+ }
}
// renders a radio button with the Flat and Popup FlatStyle
private void DrawFlatStyleRadioButton (Graphics graphics, Rectangle rectangle, RadioButton radio_button)
{
int lineWidth;
-
- // win32 compat fill in the background of the knob
- graphics.FillPie (ResPool.GetSolidBrush (this.ColorWindow), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
-
- // draw the outer flatstyle arcs
- if (radio_button.FlatStyle == FlatStyle.Flat) {
- graphics.DrawArc (ResPool.GetPen (ColorButtonText), rectangle, 0, 359);
- } else {
- // must be a popup radio button
- if (radio_button.is_entered) {
- // draw the popup 3d button knob
- graphics.DrawArc (SystemPens.ControlLight, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 0, 359);
-
- graphics.DrawArc (SystemPens.ControlDark, rectangle, 135, 180);
- graphics.DrawArc (SystemPens.ControlLightLight, rectangle, 315, 180);
+
+ if (radio_button.Enabled) {
+ // draw the outer flatstyle arcs
+ if (radio_button.FlatStyle == FlatStyle.Flat) {
+ graphics.DrawArc (ResPool.GetPen (radio_button.ForeColor), rectangle, 0, 359);
+
+ // fill in the area depending on whether or not the mouse is hovering
+ if (radio_button.is_entered && radio_button.Capture) {
+ graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.Light (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+ } else {
+ graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+ }
} else {
- // just draw lighter flatstyle outer circle
- graphics.DrawArc (SystemPens.ControlDark, rectangle, 0, 359);
+ // must be a popup radio button
+ // fill the control
+ graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 0, 359);
+
+ if (radio_button.is_entered || radio_button.Capture) {
+ // draw the popup 3d button knob
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.Light (radio_button.BackColor)), rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 0, 359);
+
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (radio_button.BackColor)), rectangle, 135, 180);
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 315, 180);
+
+ } else {
+ // just draw lighter flatstyle outer circle
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (this.ColorButtonFace)), rectangle, 0, 359);
+ }
}
+ } else {
+ // disabled
+ // fill control background color regardless of actual backcolor
+ graphics.FillPie (ResPool.GetSolidBrush (this.ColorButtonFace), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
+ // draw the ark as control dark
+ graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark(this.ColorButtonFace)), rectangle, 0, 359);
}
// draw the check
SolidBrush buttonBrush;
if (!radio_button.Enabled) {
- buttonBrush = (SolidBrush) SystemBrushes.ControlDark;
+ buttonBrush = ResPool.GetSolidBrush (ControlPaint.Dark (this.ColorButtonFace));
+ } else if (radio_button.FlatStyle == FlatStyle.Popup && radio_button.is_entered && radio_button.Capture) {
+ buttonBrush = ResPool.GetSolidBrush (this.ColorButtonText);
} else {
- buttonBrush = (SolidBrush) SystemBrushes.ControlText;
+ buttonBrush = ResPool.GetSolidBrush (radio_button.ForeColor);
}
graphics.FillPie (buttonBrush, rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2, 0, 359);
- }
+ }
}
public override Size RadioButtonDefaultSize {
#endregion // RadioButton
#region ScrollBar
- public override void DrawScrollBar(Graphics dc, Rectangle clip_rectangle, ScrollBar bar) {
+ public override void DrawScrollBar (Graphics dc, Rectangle clip, ScrollBar bar)
+ {
int scrollbutton_width = bar.scrollbutton_width;
int scrollbutton_height = bar.scrollbutton_height;
Rectangle first_arrow_area;
- Rectangle second_arrow_area;
- Rectangle area;
+ Rectangle second_arrow_area;
Rectangle thumb_pos;
-
- area = bar.paint_area;
+
thumb_pos = bar.ThumbPos;
if (bar.vert) {
first_arrow_area = new Rectangle(0, 0, bar.Width, scrollbutton_height);
bar.FirstArrowArea = first_arrow_area;
- second_arrow_area = new Rectangle(0, area.Height - scrollbutton_height, bar.Width, scrollbutton_height);
+ second_arrow_area = new Rectangle(0, bar.ClientRectangle.Height - scrollbutton_height, bar.Width, scrollbutton_height);
bar.SecondArrowArea = second_arrow_area;
thumb_pos.Width = bar.Width;
bar.ThumbPos = thumb_pos;
/* Buttons */
- CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state);
- CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state);
+ if (clip.IntersectsWith (first_arrow_area))
+ CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state);
+ if (clip.IntersectsWith (second_arrow_area))
+ CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state);
/* Background */
switch (bar.thumb_moving) {
case ScrollBar.ThumbMoving.None: {
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), 0,
- scrollbutton_height, area.Width, area.Height - (scrollbutton_height * 2));
-
+ Rectangle r = new Rectangle (0,
+ scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - (scrollbutton_height * 2));
+ Rectangle intersect = Rectangle.Intersect (clip, r);
+
+ if (intersect != Rectangle.Empty) {
+ Brush h = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace);
+ dc.FillRectangle (h, intersect);
+ }
break;
}
case ScrollBar.ThumbMoving.Forward: {
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
- 0, scrollbutton_height,
- area.Width, thumb_pos.Y - scrollbutton_height);
-
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
- 0, thumb_pos.Y + thumb_pos.Height,
- area.Width, area.Height - (thumb_pos.Y + thumb_pos.Height) - scrollbutton_height);
-
+ Rectangle r = new Rectangle (0, scrollbutton_height,
+ bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height);
+ Rectangle intersect = Rectangle.Intersect (clip, r);
+
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), intersect);
+
+ r.X = 0;
+ r.Y = thumb_pos.Y + thumb_pos.Height;
+ r.Width = bar.ClientRectangle.Width;
+ r.Height = bar.ClientRectangle.Height - (thumb_pos.Y + thumb_pos.Height) - scrollbutton_height;
+
+ intersect = Rectangle.Intersect (clip, r);
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black), intersect);
break;
}
case ScrollBar.ThumbMoving.Backwards: {
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
- 0, scrollbutton_height,
- area.Width, thumb_pos.Y - scrollbutton_height);
-
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
- 0, thumb_pos.Y + thumb_pos.Height,
- area.Width, area.Height - (thumb_pos.Y + thumb_pos.Height) - scrollbutton_height);
-
+ Rectangle r = new Rectangle (0, scrollbutton_height,
+ bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height);
+ Rectangle intersect = Rectangle.Intersect (clip, r);
+
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black), intersect);
+
+ r.X = 0;
+ r.Y = thumb_pos.Y + thumb_pos.Height;
+ r.Width = bar.ClientRectangle.Width;
+ r.Height = bar.ClientRectangle.Height - (thumb_pos.Y + thumb_pos.Height) - scrollbutton_height;
+
+ intersect = Rectangle.Intersect (clip, r);
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), intersect);
break;
}
default:
break;
}
-
- }
- else {
+ } else {
first_arrow_area = new Rectangle(0, 0, scrollbutton_width, bar.Height);
bar.FirstArrowArea = first_arrow_area;
- second_arrow_area = new Rectangle(area.Width - scrollbutton_width, 0, scrollbutton_width, bar.Height);
+ second_arrow_area = new Rectangle (bar.ClientRectangle.Width - scrollbutton_width, 0, scrollbutton_width, bar.Height);
bar.SecondArrowArea = second_arrow_area;
thumb_pos.Height = bar.Height;
bar.ThumbPos = thumb_pos;
/* Buttons */
- CPDrawScrollButton (dc, bar.FirstArrowArea, ScrollButton.Left, bar.firstbutton_state);
- CPDrawScrollButton (dc, bar.SecondArrowArea, ScrollButton.Right, bar.secondbutton_state);
+ if (clip.IntersectsWith (first_arrow_area))
+ CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Left, bar.firstbutton_state);
+ if (clip.IntersectsWith (second_arrow_area))
+ CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Right, bar.secondbutton_state);
- /* Background */
- //dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), scrollbutton_width,
- // 0, area.Width - (scrollbutton_width * 2), area.Height);
-
+ /* Background */
switch (bar.thumb_moving) {
case ScrollBar.ThumbMoving.None: {
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), scrollbutton_width,
- 0, area.Width - (scrollbutton_width * 2), area.Height);
-
+ Rectangle r = new Rectangle (scrollbutton_width,
+ 0, bar.ClientRectangle.Width - (scrollbutton_width * 2), bar.ClientRectangle.Height);
+ Rectangle intersect = Rectangle.Intersect (clip, r);
+
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), intersect);
break;
}
case ScrollBar.ThumbMoving.Forward: {
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
- scrollbutton_width, 0,
- thumb_pos.X - scrollbutton_width, area.Height);
-
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
- thumb_pos.X + thumb_pos.Width, 0,
- area.Width - (thumb_pos.X + thumb_pos.Width) - scrollbutton_width, area.Height);
-
+ Rectangle r = new Rectangle (scrollbutton_width, 0,
+ thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height);
+ Rectangle intersect = Rectangle.Intersect (clip, r);
+
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), intersect);
+
+ r.X = thumb_pos.X + thumb_pos.Width;
+ r.Y = 0;
+ r.Width = bar.ClientRectangle.Width - (thumb_pos.X + thumb_pos.Width) - scrollbutton_width;
+ r.Height = bar.ClientRectangle.Height;
+
+ intersect = Rectangle.Intersect (clip, r);
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black), intersect);
break;
}
case ScrollBar.ThumbMoving.Backwards: {
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
- scrollbutton_width, 0,
- thumb_pos.X - scrollbutton_width, area.Height);
-
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
- thumb_pos.X + thumb_pos.Width, 0,
- area.Width - (thumb_pos.X + thumb_pos.Width) - scrollbutton_width, area.Height);
+ Rectangle r = new Rectangle (scrollbutton_width, 0,
+ thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height);
+ Rectangle intersect = Rectangle.Intersect (clip, r);
-
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black), intersect);
+
+ r.X = thumb_pos.X + thumb_pos.Width;
+ r.Y = 0;
+ r.Width = bar.ClientRectangle.Width - (thumb_pos.X + thumb_pos.Width) - scrollbutton_width;
+ r.Height = bar.ClientRectangle.Height;
+
+ intersect = Rectangle.Intersect (clip, r);
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), intersect);
break;
}
-
- default:
- break;
}
}
/* Thumb */
- if (bar.Enabled)
- DrawScrollButtonPrimitive (dc, thumb_pos, ButtonState.Normal);
+ if (bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith (thumb_pos))
+ DrawScrollButtonPrimitive (dc, thumb_pos, ButtonState.Normal);
}
public override int ScrollBarButtonSize {
#endregion // ScrollBar
#region StatusBar
- public override void DrawStatusBar (Graphics dc, Rectangle clip_rectangle, StatusBar sb) {
- Rectangle area = sb.paint_area;
- int horz_border = 2;
- int vert_border = 2;
+ public override void DrawStatusBar (Graphics dc, Rectangle clip, StatusBar sb) {
+ Rectangle area = sb.ClientRectangle;
+ int horz_border = 2;
+ int vert_border = 2;
- dc.FillRectangle (GetControlBackBrush (sb.BackColor), area);
+ dc.FillRectangle (GetControlBackBrush (sb.BackColor), clip);
- if (sb.ShowPanels && sb.Panels.Count == 0) {
- // Create a default panel.
- SolidBrush br_forecolor = GetControlForeBrush (sb.ForeColor);
-
- StatusBarPanel panel = new StatusBarPanel ();
- Rectangle new_area = new Rectangle (area.X + horz_border,
- area.Y + horz_border,
- area.Width - StatusBarSizeGripWidth - horz_border,
- area.Height - horz_border);
- DrawStatusBarPanel (dc, new_area, -1, br_forecolor, panel);
+ if (sb.Panels.Count == 0 && sb.Text != String.Empty) {
+ string text = sb.Text;
+ StringFormat string_format = new StringFormat ();
+ string_format.Trimming = StringTrimming.Character;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+
+ if (text [0] == '\t') {
+ string_format.Alignment = StringAlignment.Center;
+ text = text.Substring (1);
+ if (text [0] == '\t') {
+ string_format.Alignment = StringAlignment.Far;
+ text = text.Substring (1);
+ }
+ }
+
+ dc.DrawString (text, sb.Font, ResPool.GetSolidBrush (sb.ForeColor),
+ new Rectangle(area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4), string_format);
} else if (sb.ShowPanels) {
SolidBrush br_forecolor = GetControlForeBrush (sb.ForeColor);
int prev_x = area.X + horz_border;
Rectangle pr = new Rectangle (prev_x, y,
sb.Panels [i].Width, area.Height);
prev_x += pr.Width + StatusBarHorzGapWidth;
- DrawStatusBarPanel (dc, pr, i, br_forecolor, sb.Panels [i]);
+ if (pr.IntersectsWith (clip))
+ DrawStatusBarPanel (dc, pr, i, br_forecolor, sb.Panels [i]);
}
}
int left = area.Left;
if (panel.Icon != null) {
left += 2;
- int size = area.Height - border_size;
- Rectangle ia = new Rectangle (left, border_size, size, size);
dc.DrawIcon (panel.Icon, left, area.Top);
left += panel.Icon.Width;
}
string text = panel.Text;
StringFormat string_format = new StringFormat ();
- string_format.LineAlignment = StringAlignment.Center;
- string_format.Alignment = StringAlignment.Near;
+ string_format.Trimming = StringTrimming.Character;
string_format.FormatFlags = StringFormatFlags.NoWrap;
if (text [0] == '\t') {
}
}
- float x = left + border_size;
- float y = ((area.Bottom - area.Top) / 2.0F) + border_size;
-
- dc.DrawString (text, panel.Parent.Font, br_forecolor, x, y, string_format);
+ int x = left + border_size;
+ int y = border_size + 2;
+ Rectangle r = new Rectangle (x, y,
+ area.Right - x - border_size,
+ area.Bottom - y - border_size);
+
+ dc.DrawString (text, panel.Parent.Font, br_forecolor, r, string_format);
}
public override int StatusBarSizeGripWidth {
}
#endregion // StatusBar
+ public override void DrawTabControl (Graphics dc, Rectangle area, TabControl tab)
+ {
+ // Do we need to fill the back color? It can't be changed...
+ dc.FillRectangle (GetControlBackBrush (tab.BackColor), area);
+ Rectangle panel_rect = GetTabPanelRectExt (tab);
+
+ if (tab.Appearance == TabAppearance.Normal) {
+ CPDrawBorder3D (dc, panel_rect, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, ColorButtonFace);
+ CPDrawBorder3D (dc, panel_rect, Border3DStyle.Raised, Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+ }
+
+ if (tab.Alignment == TabAlignment.Top) {
+ for (int r = tab.TabPages.Count; r > 0; r--) {
+ for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
+ if (i == tab.SelectedIndex)
+ continue;
+ if (r != tab.TabPages [i].Row)
+ continue;
+ Rectangle rect = tab.GetTabRect (i);
+ if (!rect.IntersectsWith (area))
+ continue;
+ DrawTab (dc, tab.TabPages [i], tab, rect, false);
+ }
+ }
+ } else {
+ for (int r = 0; r < tab.TabPages.Count; r++) {
+ for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
+ if (i == tab.SelectedIndex)
+ continue;
+ if (r != tab.TabPages [i].Row)
+ continue;
+ Rectangle rect = tab.GetTabRect (i);
+ if (!rect.IntersectsWith (area))
+ continue;
+ DrawTab (dc, tab.TabPages [i], tab, rect, false);
+ }
+ }
+ }
+
+ if (tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos) {
+ Rectangle rect = tab.GetTabRect (tab.SelectedIndex);
+ if (rect.IntersectsWith (area))
+ DrawTab (dc, tab.TabPages [tab.SelectedIndex], tab, rect, true);
+ }
+
+ if (tab.ShowSlider) {
+ Rectangle right = GetTabControlRightScrollRect (tab);
+ Rectangle left = GetTabControlLeftScrollRect (tab);
+ CPDrawScrollButton (dc, right, ScrollButton.Right, tab.RightSliderState);
+ CPDrawScrollButton (dc, left, ScrollButton.Left, tab.LeftSliderState);
+ }
+ }
+
+ public override Rectangle GetTabControlLeftScrollRect (TabControl tab)
+ {
+ switch (tab.Alignment) {
+ case TabAlignment.Top:
+ return new Rectangle (tab.ClientRectangle.Right - 34, tab.ClientRectangle.Top + 1, 17, 17);
+ default:
+ Rectangle panel_rect = GetTabPanelRectExt (tab);
+ return new Rectangle (tab.ClientRectangle.Right - 34, panel_rect.Bottom + 2, 17, 17);
+ }
+ }
+
+ public override Rectangle GetTabControlRightScrollRect (TabControl tab)
+ {
+ switch (tab.Alignment) {
+ case TabAlignment.Top:
+ return new Rectangle (tab.ClientRectangle.Right - 17, tab.ClientRectangle.Top + 1, 17, 17);
+ default:
+ Rectangle panel_rect = GetTabPanelRectExt (tab);
+ return new Rectangle (tab.ClientRectangle.Right - 17, panel_rect.Bottom + 2, 17, 17);
+ }
+ }
+
+ public override Size TabControlDefaultItemSize {
+ get { return new Size (42, 21); }
+ }
+
+ public override Point TabControlDefaultPadding {
+ get { return new Point (6, 3); }
+ }
+
+ public override int TabControlMinimumTabWidth {
+ get { return 42; }
+ }
+
+ public override Rectangle GetTabControlDisplayRectangle (TabControl tab)
+ {
+ Rectangle ext = GetTabPanelRectExt (tab);
+ // Account for border size
+ return new Rectangle (ext.Left + 2, ext.Top + 1, ext.Width - 6, ext.Height - 4);
+ }
+
+ public override Size TabControlGetSpacing (TabControl tab) {
+ switch (tab.Appearance) {
+ case TabAppearance.Normal:
+ return new Size (1, -2);
+ case TabAppearance.Buttons:
+ return new Size (3, 3);
+ case TabAppearance.FlatButtons:
+ return new Size (9, 3);
+ default:
+ throw new Exception ("Invalid Appearance value: " + tab.Appearance);
+ }
+ }
+
+ private Rectangle GetTabPanelRectExt (TabControl tab)
+ {
+ // Offset the tab from the top corner
+ Rectangle res = new Rectangle (tab.ClientRectangle.X + 2,
+ tab.ClientRectangle.Y,
+ tab.ClientRectangle.Width - 2,
+ tab.ClientRectangle.Height - 1);
+
+ if (tab.TabCount == 0)
+ return res;
+
+ int spacing = TabControlGetSpacing (tab).Height;
+ int offset = (tab.ItemSize.Height + spacing) * tab.RowCount + 3;
+
+ switch (tab.Alignment) {
+ case TabAlignment.Left:
+ res.X += offset;
+ res.Width -= offset;
+ break;
+ case TabAlignment.Right:
+ res.Width -= offset;
+ break;
+ case TabAlignment.Top:
+ res.Y += offset;
+ res.Height -= offset;
+ break;
+ case TabAlignment.Bottom:
+ res.Height -= offset;
+ break;
+ }
+
+ return res;
+ }
+
+ private int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
+ {
+ int FlatButtonSpacing = 8;
+ Rectangle interior;
+ int res = bounds.Width;
+
+ // we can't fill the background right away because the bounds might be adjusted if the tab is selected
+
+ if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) {
+
+ dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
+
+ // Separators
+ if (tab.Appearance == TabAppearance.FlatButtons) {
+ int width = bounds.Width;
+ bounds.Width += (FlatButtonSpacing - 2);
+ res = bounds.Width;
+ CPDrawBorder3D (dc, bounds, Border3DStyle.Etched, Border3DSide.Right);
+ bounds.Width = width;
+ }
+
+ if (is_selected) {
+ CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.All);
+ } else if (tab.Appearance != TabAppearance.FlatButtons) {
+ CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.All);
+ }
+
+ interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4);
+
+
+ StringFormat string_format = new StringFormat ();
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+
+ interior.Y++;
+ dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
+ interior.Y--;
+ } else {
+ Pen light = ResPool.GetPen (ControlPaint.LightLight (tab.BackColor));
+
+ switch (tab.Alignment) {
+
+ case TabAlignment.Top:
+
+
+ dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
+
+ dc.DrawLine (light, bounds.Left, bounds.Bottom, bounds.Left, bounds.Top + 3);
+ dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
+ dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right - 3, bounds.Top);
+
+ dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom);
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 1, bounds.Top + 2, bounds.Right, bounds.Top + 3);
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom);
+
+ interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
+
+ if (page.Text != String.Empty) {
+ StringFormat string_format = new StringFormat ();
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ interior.Y++;
+ dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
+ interior.Y--;
+ }
+
+ break;
+
+ case TabAlignment.Bottom:
+
+ dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
+
+ dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 3);
+ dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left + 2, bounds.Bottom - 1);
+
+ dc.DrawLine (SystemPens.ControlDark, bounds.Left + 3, bounds.Bottom - 1, bounds.Right - 3, bounds.Bottom - 1);
+ dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Bottom - 3, bounds.Right - 1, bounds.Top);
+
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 3, bounds.Bottom, bounds.Right, bounds.Bottom - 3);
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom - 3, bounds.Right, bounds.Top);
+
+ interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
+
+ if (page.Text != String.Empty) {
+ StringFormat string_format = new StringFormat ();
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ interior.Y++;
+ dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
+ interior.Y--;
+ }
+
+ break;
+
+ case TabAlignment.Left:
+
+ dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
+
+ dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left, bounds.Top + 3);
+ dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
+ dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right, bounds.Top);
+
+ dc.DrawLine (SystemPens.ControlDark, bounds.Right, bounds.Bottom - 1, bounds.Left + 2, bounds.Bottom - 1);
+
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom, bounds.Left + 2, bounds.Bottom);
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 2, bounds.Bottom, bounds.Left, bounds.Bottom - 3);
+
+ interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
+
+ if (page.Text != String.Empty) {
+ StringFormat string_format = new StringFormat ();
+ // Flip the text around
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ string_format.FormatFlags = StringFormatFlags.DirectionVertical;
+ int wo = interior.Width / 2;
+ int ho = interior.Height / 2;
+ dc.TranslateTransform (interior.X + wo, interior.Y + ho);
+ dc.RotateTransform (180);
+ dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
+ dc.ResetTransform ();
+ }
+
+ break;
+
+ default:
+ // TabAlignment.Right
+
+ dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
+
+ dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Right - 3, bounds.Top);
+ dc.DrawLine (light, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3);
+
+ dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom - 1);
+ dc.DrawLine (SystemPens.ControlDark, bounds.Left, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1);
+
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom - 3);
+ dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
+
+ interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
+
+ if (page.Text != String.Empty) {
+ StringFormat string_format = new StringFormat ();
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ string_format.FormatFlags = StringFormatFlags.DirectionVertical;
+ interior.X++;
+ dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
+ interior.X--;
+ }
+
+ break;
+ }
+ }
+
+ if (page.Focused) {
+ CPDrawFocusRectangle (dc, interior, tab.ForeColor, tab.BackColor);
+ }
+
+ return res;
+ }
+
#region ToolBar
public override void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control) {
StringFormat format = new StringFormat ();
-
+ format.Trimming = StringTrimming.EllipsisWord;
if (control.textAlignment == ToolBarTextAlign.Underneath) {
format.LineAlignment = StringAlignment.Center;
format.Alignment = StringAlignment.Center;
button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
imgRect.Height, button.ImageIndex);
else {
- dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
ControlPaint.DrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
Border3DSide.Right | Border3DSide.Bottom);
}
button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
imgRect.Height, button.ImageIndex);
else {
- dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
ControlPaint.DrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
Border3DSide.Right | Border3DSide.Bottom);
}
button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
imgRect.Height, button.ImageIndex);
else {
- dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
}
button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
imgRect.Height, button.ImageIndex);
else {
- dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
}
button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width, imgRect.Height,
button.ImageIndex);
else {
- dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
}
}
#endregion // ToolBar
+ #region ToolTip
+ public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control) {
+ dc.FillRectangle(ResPool.GetSolidBrush(this.ColorInfoWindow), control.client_rect);
+ dc.DrawRectangle(ResPool.GetPen(this.ColorWindowFrame), 0, 0, control.Width-1, control.Height-1);
+ dc.DrawString(control.text, control.Font, ResPool.GetSolidBrush(this.ColorInfoText), control.client_rect, control.string_format);
+ }
+
+ public override Size ToolTipSize(ToolTip.ToolTipWindow tt, string text) {
+ SizeF sizef;
+
+ sizef = tt.DeviceContext.MeasureString(text, tt.Font);
+ return new Size((int)sizef.Width+2, (int)sizef.Height+3); // Need space for the border
+ }
+ #endregion // ToolTip
+
#region TrackBar
- private void DrawTrackBar_Vertical (Graphics dc, Rectangle area, TrackBar tb,
+ private void DrawTrackBar_Vertical (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
float ticks, int value_pos, bool mouse_value) {
float pixel_len;
float pixels_betweenticks;
const int space_from_right = 8;
- const int space_from_left = 8;
+ const int space_from_left = 8;
+ Rectangle area = tb.ClientRectangle;
switch (tb.TickStyle) {
case TickStyle.BottomRight:
}
pixel_len = thumb_area.Height - 11;
- pixels_betweenticks = pixel_len / ticks;
+ pixels_betweenticks = pixel_len / ticks;
+
+ thumb_area.X = thumb_pos.X;
+ thumb_area.Y = channel_startpoint.Y;
+ thumb_area.Width = thumb_pos.Height;
/* Draw ticks*/
- if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
- ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-
- for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
- if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
- dc.DrawLine (pen_ticks, area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
- area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc);
- else
- dc.DrawLine (pen_ticks, area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
- area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc);
+ Region outside = new Region (area);
+ outside.Exclude (thumb_area);
+
+ if (outside.IsVisible (clip_rectangle)) {
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
+ area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
+ area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc);
+ }
+ }
+
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ pixel_len = thumb_area.Height - 11;
+ pixels_betweenticks = pixel_len / ticks;
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
+ area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
+ area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
+ }
}
}
-
- if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
- ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-
- pixel_len = thumb_area.Height - 11;
- pixels_betweenticks = pixel_len / ticks;
-
- for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
- //Console.WriteLine ("{0} {1} {2}", pixel_len, inc, pixels_betweenticks );
- if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
- dc.DrawLine (pen_ticks, area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
- area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
- else
- dc.DrawLine (pen_ticks, area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
- area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
- }
- }
+
+ outside.Dispose ();
+
}
/*
- Ticks are draw at (channel.Witdh - 10) / (Maximum - Minimum)
*/
- private void DrawTrackBar_Horizontal (Graphics dc, Rectangle area, TrackBar tb,
+ private void DrawTrackBar_Horizontal (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
float ticks, int value_pos, bool mouse_value) {
Point toptick_startpoint = new Point ();
float pixel_len;
float pixels_betweenticks;
const int space_from_right = 8;
- const int space_from_left = 8;
+ const int space_from_left = 8;
+ Rectangle area = tb.ClientRectangle;
switch (tb.TickStyle) {
case TickStyle.BottomRight:
pixels_betweenticks = pixel_len / ticks;
/* Draw ticks*/
- if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
- ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-
- for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
- if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
- dc.DrawLine (pen_ticks, area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
- area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3);
- else
- dc.DrawLine (pen_ticks, area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
- area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2);
+ thumb_area.Y = thumb_pos.Y;
+ thumb_area.X = channel_startpoint.X;
+ thumb_area.Height = thumb_pos.Height;
+ Region outside = new Region (area);
+ outside.Exclude (thumb_area);
+
+ if (outside.IsVisible (clip_rectangle)) {
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
+ area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
+ area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2);
+ }
+ }
+
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
+ area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
+ area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
+ }
}
}
-
- if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
- ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-
- for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
- if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
- dc.DrawLine (pen_ticks, area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
- area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y);
- else
- dc.DrawLine (pen_ticks, area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
- area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
- }
- }
+
+ outside.Dispose ();
}
- public override void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb) {
-//public override void DrawTrackBar (Graphics dc,
-//Rectangle area,
-//TrackBar tb,
-//ref Rectangle thumb_pos,
-//ref Rectangle thumb_area,
+ public override void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb)
+ {
Brush br_thumb;
int value_pos;
bool mouse_value;
Rectangle area;
Rectangle thumb_pos = tb.ThumbPos;
Rectangle thumb_area = tb.ThumbArea;
-
+
if (tb.thumb_pressed) {
value_pos = tb.thumb_mouseclick;
mouse_value = true;
mouse_value = false;
}
- area = tb.paint_area;
+ area = tb.ClientRectangle;
if (tb.thumb_pressed == true) {
br_thumb = (Brush) ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace);
/* Control Background */
if (tb.BackColor == DefaultControlBackColor) {
- dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), clip_rectangle);
} else {
- dc.FillRectangle (ResPool.GetSolidBrush (tb.BackColor), area);
+ dc.FillRectangle (ResPool.GetSolidBrush (tb.BackColor), clip_rectangle);
}
}
if (tb.Orientation == Orientation.Vertical) {
- DrawTrackBar_Vertical (dc, area, tb, ref thumb_pos, ref thumb_area,
+ DrawTrackBar_Vertical (dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
br_thumb, ticks, value_pos, mouse_value);
} else {
- DrawTrackBar_Horizontal (dc, area, tb, ref thumb_pos, ref thumb_area,
+ DrawTrackBar_Horizontal (dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
br_thumb, ticks, value_pos, mouse_value);
}
#region VScrollBar
public override Size VScrollBarDefaultSize {
get {
- return new Size (13,80);
+ return new Size (this.ScrollBarButtonSize, 80);
}
}
#endregion // VScrollBar
+ #region TreeView
+ public override Size TreeViewDefaultSize {\r
+ get {\r
+ return new Size (121, 97);\r
+ }\r
+ }\r
+
+ #endregion
+
#region ControlPaint
private enum DrawFrameControlStates {
ButtonCheck = 0x0000,
if ((style & Border3DStyle.RaisedInner)!=0) {
if (doInner) {
- penTopLeftInner=ResPool.GetPen(ControlPaint.Light(control_color));
+ penTopLeftInner=ResPool.GetPen(control_color);
penBottomRightInner=ResPool.GetPen(ControlPaint.Dark(control_color));
} else {
penTopLeft=ResPool.GetPen(ControlPaint.LightLight(control_color));
} else if ((style & Border3DStyle.SunkenInner)!=0) {
if (doInner) {
penTopLeftInner=ResPool.GetPen(ControlPaint.Dark(control_color));
- penBottomRightInner=ResPool.GetPen(ControlPaint.Light(control_color));
+ penBottomRightInner=ResPool.GetPen(control_color);
} else {
penTopLeft=ResPool.GetPen(ControlPaint.DarkDark(control_color));
penBottomRight=ResPool.GetPen(ControlPaint.LightLight(control_color));
}
if ((sides & Border3DSide.Left)!=0) {
- graphics.DrawLine(penTopLeft, rect.Left, rect.Bottom-1, rect.Left, rect.Top);
+ graphics.DrawLine(penTopLeft, rect.Left, rect.Bottom-2, rect.Left, rect.Top);
if (doInner) {
- graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Bottom-1, rect.Left+1, rect.Top);
+ graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Bottom-2, rect.Left+1, rect.Top);
}
}
if ((sides & Border3DSide.Top)!=0) {
- graphics.DrawLine(penTopLeft, rect.Left, rect.Top, rect.Right-1, rect.Top);
+ graphics.DrawLine(penTopLeft, rect.Left, rect.Top, rect.Right-2, rect.Top);
if (doInner) {
if ((sides & Border3DSide.Left)!=0) {
- graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Top+1, rect.Right-1, rect.Top+1);
+ graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Top+1, rect.Right-3, rect.Top+1);
} else {
- graphics.DrawLine(penTopLeftInner, rect.Left, rect.Top+1, rect.Right-1, rect.Top+1);
+ graphics.DrawLine(penTopLeftInner, rect.Left, rect.Top+1, rect.Right-3, rect.Top+1);
}
}
}
if (doInner) {
if ((sides & Border3DSide.Top)!=0) {
- graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top+1, rect.Right-2, rect.Bottom-1);
+ graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top+1, rect.Right-2, rect.Bottom-2);
} else {
- graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top, rect.Right-2, rect.Bottom-1);
+ graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top, rect.Right-2, rect.Bottom-2);
}
}
}
if ((sides & Border3DSide.Right)!=0) {
graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-2, rect.Bottom-2);
} else {
- graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-1, rect.Bottom-2);
+ graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-2, rect.Bottom-2);
}
}
}
ControlPaint.DrawBorder(graphics, rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
} else {
if ((state & (ButtonState.Pushed | ButtonState.Checked))!=0) {
- CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+ // this needs to render like a pushed button - jba
+ // CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+ Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
+ graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorButtonFace)), trace_rectangle);
} else {
CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
}
}
-
- public override void CPDrawFocusRectangle (Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor) {
- //Color colorForeInverted;
- Color colorBackInverted;
- Pen pen;
-
- //colorForeInverted=Color.FromArgb(Math.Abs(foreColor.R-255), Math.Abs(foreColor.G-255), Math.Abs(foreColor.B-255));
- //pen=new Pen(colorForeInverted, 1);
- // MS seems to always use black
- pen=new Pen(Color.Black, 1);
- graphics.DrawRectangle(pen, rectangle);
- pen.Dispose();
-
- colorBackInverted=Color.FromArgb(Math.Abs(backColor.R-255), Math.Abs(backColor.G-255), Math.Abs(backColor.B-255));
- pen=new Pen(colorBackInverted, 1);
- pen.DashStyle=DashStyle.Dot;
- graphics.DrawRectangle(pen, rectangle);
- pen.Dispose();
+ public virtual void DrawFlatStyleFocusRectangle (Graphics graphics, Rectangle rectangle, ButtonBase button, Color foreColor, Color backColor) {
+ // make a rectange to trace around border of the button
+ Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
+
+ Color outerColor = foreColor;
+ // adjust focus color according to the flatstyle
+ if (button.FlatStyle == FlatStyle.Popup && !button.is_pressed) {
+ outerColor = (backColor == ColorButtonFace) ? ControlPaint.Dark(ColorButtonFace) : ColorButtonText;
+ }
+
+ // draw the outer rectangle
+ graphics.DrawRectangle (ResPool.GetPen (outerColor), trace_rectangle);
+
+ // draw the inner rectangle
+ if (button.FlatStyle == FlatStyle.Popup) {
+ DrawInnerFocusRectangle (graphics, Rectangle.Inflate (rectangle, -4, -4), backColor);
+ } else {
+ // draw a flat inner rectangle
+ Pen pen = ResPool.GetPen (ControlPaint.LightLight (backColor));
+ graphics.DrawRectangle(pen, Rectangle.Inflate (trace_rectangle, -4, -4));
+ }
}
+
+ public virtual void DrawInnerFocusRectangle(Graphics graphics, Rectangle rectangle, Color backColor)
+ {
+ // make a rectange to trace around border of the button
+ Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
+
+ Color colorBackInverted = Color.FromArgb (Math.Abs (backColor.R-255), Math.Abs (backColor.G-255), Math.Abs (backColor.B-255));
+ DashStyle oldStyle; // used for caching old penstyle
+ Pen pen = ResPool.GetPen (colorBackInverted);
+
+ oldStyle = pen.DashStyle;
+ pen.DashStyle = DashStyle.Dot;
+ graphics.DrawRectangle (pen, trace_rectangle);
+ pen.DashStyle = oldStyle;
+ }
+
-
+ public override void CPDrawFocusRectangle (Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor)
+ {
+ Rectangle rect = rectangle;
+ Pen pen;
+ HatchBrush brush;
+
+ if (backColor.GetBrightness () >= 0.5) {
+ foreColor = Color.Transparent;
+ backColor = Color.Black;
+
+ } else {
+ backColor = Color.FromArgb (Math.Abs (backColor.R-255), Math.Abs (backColor.G-255), Math.Abs (backColor.B-255));
+ foreColor = Color.Black;
+ }
+
+ brush = ResPool.GetHatchBrush (HatchStyle.Percent50, backColor, foreColor);
+ pen = new Pen (brush, 1);
+
+ rect.Width--;
+ rect.Height--;
+
+ graphics.DrawRectangle (pen, rect);
+ pen.Dispose ();
+ }
+
public override void CPDrawGrabHandle (Graphics graphics, Rectangle rectangle, bool primary, bool enabled) {
SolidBrush sb;
Pen pen;
} else {
pen=new Pen(Color.White, 1);
if (enabled==true) {
- sb=new SolidBrush(Color.Black);
+ sb=ThemeEngine.Current.ResPool.GetSolidBrush (Color.Black);
} else {
sb=ResPool.GetSolidBrush (ColorButtonFace);
}
the image grayscale. At least when having > 256 colors on
the display.
*/
-
- ImageAttributes imageAttributes=new ImageAttributes();
- ColorMatrix colorMatrix=new ColorMatrix(new float[][] {
- // This table would create a perfect grayscale image, based on luminance
- // new float[]{0.3f,0.3f,0.3f,0,0},
- // new float[]{0.59f,0.59f,0.59f,0,0},
- // new float[]{0.11f,0.11f,0.11f,0,0},
- // new float[]{0,0,0,1,0,0},
- // new float[]{0,0,0,0,1,0},
- // new float[]{0,0,0,0,0,1}
-
- // This table generates a image that is grayscaled and then
- // brightened up. Seems to match MS close enough.
- new float[]{0.2f,0.2f,0.2f,0,0},
- new float[]{0.41f,0.41f,0.41f,0,0},
- new float[]{0.11f,0.11f,0.11f,0,0},
- new float[]{0.15f,0.15f,0.15f,1,0,0},
- new float[]{0.15f,0.15f,0.15f,0,1,0},
- new float[]{0.15f,0.15f,0.15f,0,0,1}
- });
-
- imageAttributes.SetColorMatrix(colorMatrix);
- graphics.DrawImage(image, new Rectangle(x, y, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
- imageAttributes.Dispose();
+
+ if (imagedisabled_attributes == null) {
+ imagedisabled_attributes = new ImageAttributes ();
+ ColorMatrix colorMatrix=new ColorMatrix(new float[][] {
+ // This table would create a perfect grayscale image, based on luminance
+ // new float[]{0.3f,0.3f,0.3f,0,0},
+ // new float[]{0.59f,0.59f,0.59f,0,0},
+ // new float[]{0.11f,0.11f,0.11f,0,0},
+ // new float[]{0,0,0,1,0,0},
+ // new float[]{0,0,0,0,1,0},
+ // new float[]{0,0,0,0,0,1}
+
+ // This table generates a image that is grayscaled and then
+ // brightened up. Seems to match MS close enough.
+ new float[]{0.2f,0.2f,0.2f,0,0},
+ new float[]{0.41f,0.41f,0.41f,0,0},
+ new float[]{0.11f,0.11f,0.11f,0,0},
+ new float[]{0.15f,0.15f,0.15f,1,0,0},
+ new float[]{0.15f,0.15f,0.15f,0,1,0},
+ new float[]{0.15f,0.15f,0.15f,0,0,1}
+ });
+
+ imagedisabled_attributes.SetColorMatrix (colorMatrix);
+ }
+
+ graphics.DrawImage(image, new Rectangle(x, y, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imagedisabled_attributes);
+
}
int centerX;
int centerY;
int shiftX;
- int shiftY;
rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
centerX=rect.Left+rect.Width/2;
centerY=rect.Top+rect.Height/2;
shiftX=Math.Max(1, rect.Width/8);
- shiftY=Math.Max(1, rect.Height/8);
rect.X-=shiftX;
centerX-=shiftX;
bool enabled = (state == ButtonState.Inactive) ? false: true;
DrawScrollButtonPrimitive (dc, area, state);
+
+ if (area.Width < 12 || area.Height < 12) /* Cannot see a thing at smaller sizes */
+ return;
/* Paint arrows */
switch (type) {
for (int i = 0; i < 3; i++)
if (enabled)
- dc.DrawLine (pen_arrow, x + i, y - i, x + i + 6 - 2*i, y - i);
+ dc.DrawLine (ResPool.GetPen (arrow_color), x + i, y - i, x + i + 6 - 2*i, y - i);
else
dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y - i, x + i + 6 - 2*i, y - i);
- dc.FillRectangle (br_arrow, x + 3, area.Y + 6, 1, 1);
+ dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
+ x + 3, area.Y + 6, 1, 1);
+
break;
}
case ScrollButton.Down: {
- int x = area.X + (area.Width / 2) - 4;
+ int x = area.X + (area.Width / 2) - 5;
int y = area.Y + 5;
for (int i = 4; i != 0; i--)
if (enabled)
- dc.DrawLine (pen_arrow, x + i, y + i, x + i + 8 - 2*i, y + i);
+ dc.DrawLine (ResPool.GetPen (arrow_color), x + i, y + i, x + i + 8 - 2*i, y + i);
else
dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y + i, x + i + 8 - 2*i, y + i);
- dc.FillRectangle (br_arrow, x + 4, y + 4, 1, 1);
+ dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
+ x + 4, y + 4, 1, 1);
break;
}
for (int i = 0; i < 3; i++)
if (enabled)
- dc.DrawLine (pen_arrow, x - i, y + i, x - i, y + i + 6 - 2*i);
+ dc.DrawLine (ResPool.GetPen (arrow_color), x - i, y + i, x - i, y + i + 6 - 2*i);
else
dc.DrawLine (ResPool.GetPen (ColorGrayText), x - i, y + i, x - i, y + i + 6 - 2*i);
- dc.FillRectangle (br_arrow, x - 3, y + 3, 1, 1);
+ dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
+ x - 3, y + 3, 1, 1);
break;
}
case ScrollButton.Right: {
- int y = area.Y + (area.Height / 2) - 4;
+ int y = area.Y + (area.Height / 2) - 5;
int x = area.X + 5;
for (int i = 4; i != 0; i--)
if (enabled)
- dc.DrawLine (pen_arrow, x + i, y + i, x + i, y + i + 8 - 2*i);
+ dc.DrawLine (ResPool.GetPen (arrow_color), x + i, y + i, x + i, y + i + 8 - 2*i);
else
dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y + i, x + i, y + i + 8 - 2*i);
- dc.FillRectangle (br_arrow, x + 4, y + 4, 1, 1);
+ dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
+ x + 4, y + 4, 1, 1);
break;
}
public override void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
- StringFormat format) {
- SolidBrush brush;
-
- brush=new SolidBrush(ControlPaint.Light(color, 95));
+ StringFormat format) {
layoutRectangle.Offset(1.0f, 1.0f);
- graphics.DrawString(s, font, brush, layoutRectangle, format);
-
- brush.Color=ControlPaint.Light(color, 50);
+ graphics.DrawString(s, font, ResPool.GetSolidBrush (ControlPaint.Light(color, 95)), layoutRectangle, format);
layoutRectangle.Offset(-1.0f, -1.0f);
- graphics.DrawString(s, font, brush, layoutRectangle, format);
-
- brush.Dispose();
+ graphics.DrawString(s, font, ResPool.GetSolidBrush (ControlPaint.Light(color, 50)), layoutRectangle, format);
+
}
private static void DrawBorderInternal(Graphics graphics, int startX, int startY, int endX, int endY,
}
case CaptionButton.Help: {
- StringFormat sf = new StringFormat();
- SolidBrush sb = new SolidBrush(color);
+ StringFormat sf = new StringFormat();
Font font = new Font("Microsoft Sans Serif", captionRect.Height, FontStyle.Bold, GraphicsUnit.Pixel);
sf.Alignment=StringAlignment.Center;
sf.LineAlignment=StringAlignment.Center;
- graphics.DrawString("?", font, sb, captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
+ graphics.DrawString("?", font, ThemeEngine.Current.ResPool.GetSolidBrush (color), captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
- sf.Dispose();
- sb.Dispose();
+ sf.Dispose();
font.Dispose();
return;
[MonoTODO("Finish drawing code for Caption, Menu and Scroll")]
private void DrawFrameControl(Graphics graphics, Rectangle rectangle, DrawFrameControlTypes Type, DrawFrameControlStates State) {
+ // make a rectange to trace around border of the button
+ Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
switch(Type) {
case DrawFrameControlTypes.Button: {
- if ((State & DrawFrameControlStates.ButtonPush)!=0) {
- /* Goes first, affects the background */
- if ((State & DrawFrameControlStates.Checked)!=0) {
- HatchBrush hatchBrush=new HatchBrush(HatchStyle.Percent50, ColorButtonLight, ColorButtonHilight);
- graphics.FillRectangle(hatchBrush,rectangle);
- hatchBrush.Dispose();
- }
- if ((State & DrawFrameControlStates.Pushed)!=0) {
- CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+ if ((State & DrawFrameControlStates.ButtonPush)!=0) {
+// JBA 31 oct 2004 - I don't think that button style should be rendered like this
+// /* Goes first, affects the background */
+// if ((State & DrawFrameControlStates.Checked)!=0) {
+// HatchBrush hatchBrush=new HatchBrush(HatchStyle.Percent50, ColorButtonLight, ColorButtonHilight);
+// graphics.FillRectangle(hatchBrush,rectangle);
+// hatchBrush.Dispose();
+// }
+
+ // Clear the background
+ graphics.FillRectangle (SystemBrushes.Control, rectangle);
+
+ if ((State & DrawFrameControlStates.Pushed)!=0 || (State & DrawFrameControlStates.Checked)!=0) {
+ graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorButtonFace)), trace_rectangle);
} else if ((State & DrawFrameControlStates.Flat)!=0) {
ControlPaint.DrawBorder(graphics, rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
} else if ((State & DrawFrameControlStates.Inactive)!=0) {
return;
}
-
- dc.FillRectangle (new SolidBrush (Color.Blue), area);
-
+
dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X, area.Y, area.Width, 1);
dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X, area.Y, 1, area.Height);
public override void CPDrawBorderStyle (Graphics dc, Rectangle area, BorderStyle border_style) {
switch (border_style){
- case BorderStyle.Fixed3D:
+ case BorderStyle.Fixed3D:
dc.DrawLine (ResPool.GetPen (ColorButtonShadow), area.X, area.Y, area.X +area.Width, area.Y);
dc.DrawLine (ResPool.GetPen (ColorButtonShadow), area.X, area.Y, area.X, area.Y + area.Height);
dc.DrawLine (ResPool.GetPen (ColorButtonHilight), area.X , area.Y + area.Height - 1, area.X + area.Width ,
area.Y + area.Height - 1);
dc.DrawLine (ResPool.GetPen (ColorButtonHilight), area.X + area.Width -1 , area.Y, area.X + area.Width -1,
area.Y + area.Height);
+
+ // FIXME: These colors are not correct. Microsoft uses different ones but I didn't find them.
+ dc.DrawLine (ResPool.GetPen (ColorButtonLight), area.X + 1, area.Bottom - 2, area.Right - 2, area.Bottom - 2);
+ dc.DrawLine (ResPool.GetPen (ColorButtonLight), area.Right - 2, area.Top + 1, area.Right - 2, area.Bottom - 2);
+ dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), area.X + 1, area.Top + 1, area.X + 1, area.Bottom - 3);
+ dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), area.X + 1, area.Top + 1, area.Right - 3, area.Top + 1);
break;
case BorderStyle.FixedSingle:
dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame), area.X, area.Y, area.Width - 1, area.Height - 1);