1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004 Novell, Inc.
23 // Jordi Mas i Hernandez, jordi@ximian.com
24 // Peter Bartok, pbartok@novell.com
25 // John BouAntoun, jba-mono@optusnet.com.au
31 // $Log: ThemeWin32Classic.cs,v $
32 // Revision 1.65 2004/11/10 20:10:38 jackson
33 // * ThemeWin32Classic.cs: Do not draw the selected tab if its not in
36 // Revision 1.64 2004/11/10 19:22:26 jackson
37 // * ThemeWin32Classic.cs: Don't bother drawing tabs outside of the
40 // Revision 1.63 2004/11/10 01:04:28 jackson
41 // * TabControl.cs (CalcXPos): New helper method so we can determine
42 // the proper place to start drawing vertical tabs.
43 // * ThemeWin32Classic.cs (DrawTab): Draw right aligned tabs.
45 // Revision 1.62 2004/11/09 21:44:54 jackson
46 // * TabControl.cs: Calculate sizing and rects for left aligned tabs.
47 // * ThemeWin32Classic.cs (GetTabControl*ScrollRect): Only handle Top
48 // and Bottom, left and right are illegal values for this and
49 // multiline is enabled when the alignment is set to left or right.
50 // (DrawTab): Each alignment block should draw the text itself now
51 // because Left requires special love. Also add rendering for Left
54 // Revision 1.61 2004/11/09 11:06:21 jba
55 // - (DrawButtonBase): Fix verticle text rect clipping in windows
56 // - (DrawCheckBox): Fix CheckAlign.TopCenter and CheckAlign.BottomCenter
57 // rendering and incorrect text rect clipping
58 // - (DrawRadioButton): Fix CheckAlign.TopCenter and CheckAlign.BottomCenter
59 // rendering and incorrect text rect clipping
61 // Revision 1.60 2004/11/09 03:12:00 jackson
62 // * ThemeWin32Classic.cs (DrawTabControl): Render tabs from top to
63 // bottom when they are bottom aligned so the bottoms of the tabs get
65 // * TabControl.cs (DropRow): Move rows up instead of down when the
66 // tab control is bottom aligned.
68 // Revision 1.59 2004/11/08 20:40:08 jackson
69 // Render the little scrolling jimmi in the correct location with bottom aligned tabs
71 // Revision 1.58 2004/11/08 14:15:00 jordi
72 // fixes vertical scrollbar and removes dead code
74 // Revision 1.57 2004/11/05 05:47:34 jba
75 // - Fix Button rendering for FlatStyle = Flat or Popup
76 // - Fix RadioButton and CheckBox rendering when Appearance = Button (normal and
78 // - Correct outer rectangle color when drawing focus rectangle
79 // - Adjust button bounds to be 1 px smaller when focused
80 // - Make button not draw sunken 3d border when pushed (windows compat)
81 // - Fix CPDrawBorder3D to not make bottom right hand corner rounded
82 // - Offset the text in RadioButton and Checkbox when being rendered as a button.
83 // - Hover and Click behaviour for Colored FlatStyle.Flat and Popup radiobuttons
84 // - Fixed disabled rendering for colored flatstyle radiobuttons (both)
85 // - Fixed disabled text rendering for normally rendered radiobuttons
87 // Revision 1.56 2004/11/04 11:26:09 ravindra
88 // - Changed default ListView values signatures (prefixed all with ListView).
89 // - Fixed default size values for VScrollBar and HScrollBar.
90 // - Fixed DrawListViewItem method.
92 // Revision 1.55 2004/11/03 18:52:14 jackson
93 // Initial implementation of the scrolly widgerywoo
95 // Revision 1.54 2004/11/02 20:40:54 jackson
96 // Move the row with the selected tab to the bottom
98 // Revision 1.53 2004/11/02 02:47:55 jackson
99 // New rendering and sizing code for tab controls
101 // Revision 1.52 2004/10/30 10:23:02 ravindra
102 // Drawing ListView and some default values.
104 // Revision 1.51 2004/10/26 09:55:48 ravindra
105 // Some formatting for my last checkins.
107 // Revision 1.50 2004/10/26 09:36:32 ravindra
108 // Implemented DetailView drawing for ListView control and default values.
110 // Revision 1.49 2004/10/18 04:49:25 pbartok
111 // - Added ToolTip drawing code
113 // Revision 1.48 2004/10/15 15:08:49 ravindra
114 // Added ColumnHeaderHeight property in Theme for ListView.
116 // Revision 1.47 2004/10/13 15:06:37 pbartok
117 // - Path from John BouAntoun:
118 // * Fix check rendering (centre correctly for normal style, offset
119 // correctly for FlatStyle).
120 // * Fix border color usage (use backcolor) for FlatStyle.Popup
121 // * Use checkbox.Capture instead of checkbox.is_pressed when rendering
124 // Revision 1.46 2004/10/13 03:48:15 pbartok
125 // - Removed all occurences of SystemColors and replaced them with the
126 // matching theme color
128 // Revision 1.45 2004/10/13 03:41:45 pbartok
129 // - From John BouAntoun: Added an overload to CPDrawBorder3D to allow him
130 // using the function for flatstyle drawing
131 // - Changed functions to use the new version of CPDrawBorder3D
133 // Revision 1.44 2004/10/13 02:45:21 pbartok
134 // - Fixes from John BouAntoun: now handles forecolors and backcolors for
135 // flatstyle rendered controls much better; It also fixes normal checkbox
136 // rendering when pushed or disabled.
138 // Revision 1.43 2004/10/07 14:56:51 jordi
139 // Removes deletion of cached brushes
141 // Revision 1.42 2004/10/06 09:59:05 jordi
142 // removes warnings from compilation
144 // Revision 1.41 2004/10/05 16:15:30 jackson
145 // Improve rendering of the radio button patch by John BouAntoun
147 // Revision 1.40 2004/10/05 09:04:31 ravindra
148 // - Added DrawListView method and ListViewDefaultSize property.
149 // - Changed ControlPaint method calls to CPDrawXXX wherever possible.
150 // - Changed DOS style CRLF to Unix format (dos2unix).
152 // Revision 1.39 2004/10/04 07:09:37 jordi
153 // fixes right button position causing right button not showing on horizontal scrollbars
155 // Revision 1.38 2004/09/28 18:44:25 pbartok
156 // - Streamlined Theme interfaces:
157 // * Each DrawXXX method for a control now is passed the object for the
158 // control to be drawn in order to allow accessing any state the theme
161 // * ControlPaint methods for the theme now have a CP prefix to avoid
162 // name clashes with the Draw methods for controls
164 // * Every control now retrieves it's DefaultSize from the current theme
166 // Revision 1.37 2004/09/09 08:28:11 pbartok
167 // - Improve disabled string look
169 // Revision 1.36 2004/09/09 03:03:49 ravindra
170 // PictureBox would not draw a null image to avoid crash.
172 // Revision 1.35 2004/09/07 17:12:26 jordi
175 // Revision 1.34 2004/09/07 09:40:15 jordi
176 // LinkLabel fixes, methods, multiple links
178 // Revision 1.33 2004/09/05 08:03:51 jordi
179 // fixes bugs, adds flashing on certain situations
181 // Revision 1.32 2004/09/02 16:32:54 jordi
182 // implements resource pool for pens, brushes, and hatchbruses
184 // Revision 1.31 2004/08/25 20:04:40 ravindra
185 // Added the missing divider code and grip for ToolBar Control.
187 // Revision 1.30 2004/08/25 18:29:14 jordi
188 // new methods, properties, and fixes for progressbar
190 // Revision 1.29 2004/08/25 00:43:13 ravindra
191 // Fixed wrapping related issues in ToolBar control.
193 // Revision 1.28 2004/08/24 18:37:02 jordi
194 // fixes formmating, methods signature, and adds missing events
196 // Revision 1.27 2004/08/24 16:16:46 jackson
197 // Handle drawing picture boxes in the theme now. Draw picture box borders and obey sizing modes
199 // Revision 1.26 2004/08/21 01:52:08 ravindra
200 // Improvments in mouse event handling in the ToolBar control.
202 // Revision 1.25 2004/08/20 00:12:51 jordi
203 // fixes methods signature
205 // Revision 1.24 2004/08/19 22:25:31 jordi
206 // theme enhancaments
208 // Revision 1.23 2004/08/18 19:16:53 jordi
209 // Move colors to a table
211 // Revision 1.22 2004/08/17 19:29:11 jackson
212 // Don't use KnownColor to create colours. It has a large startup time.
214 // Revision 1.21 2004/08/15 23:20:54 ravindra
215 // Changes to Theme for ToolBar control and also dos2unix format.
217 // Revision 1.20 2004/08/13 21:22:18 jordi
218 // removes redundant code and fixes issues with tickposition
220 // Revision 1.19 2004/08/12 20:29:01 jordi
221 // Trackbar enhancement, fix mouse problems, highli thumb, etc
223 // Revision 1.18 2004/08/12 18:54:37 jackson
224 // Handle owner draw status bars
226 // Revision 1.17 2004/08/11 01:31:35 jackson
227 // Create Brushes as little as possible
229 // Revision 1.16 2004/08/10 19:21:27 jordi
230 // scrollbar enhancements and standarize on win colors defaults
232 // Revision 1.15 2004/08/10 18:52:30 jackson
233 // Implement DrawItem functionality
235 // Revision 1.14 2004/08/09 21:34:54 jackson
236 // Add support for drawing status bar and get status bar item sizes
238 // Revision 1.13 2004/08/09 21:21:49 jackson
239 // Use known colors for default control colours
241 // Revision 1.12 2004/08/09 21:12:15 jackson
242 // Make the default font static, it is static in control so this doesn't change functionality and creating fonts is sloooooow.
244 // Revision 1.11 2004/08/09 17:31:13 jackson
245 // New names for control properties
247 // Revision 1.10 2004/08/09 17:00:00 jackson
248 // Add default window color properties
250 // Revision 1.9 2004/08/09 16:17:19 jackson
251 // Use correct default back color
253 // Revision 1.8 2004/08/09 15:53:12 jackson
254 // Themes now handle default control properties so coloring will be consistent
256 // Revision 1.7 2004/08/08 22:54:21 jordi
257 // Label BorderStyles
259 // Revision 1.6 2004/08/08 18:09:53 jackson
260 // Add pen_buttonface
262 // Revision 1.5 2004/08/08 17:34:28 jordi
263 // Use Windows Standard Colours
265 // Revision 1.4 2004/08/07 23:31:15 jordi
266 // fixes label bug and draw method name
268 // Revision 1.3 2004/08/07 19:05:44 jordi
269 // Theme colour support and GetSysColor defines
271 // Revision 1.2 2004/08/07 00:01:39 pbartok
272 // - Fixed some rounding issues with float/int
274 // Revision 1.1 2004/07/26 17:42:03 jordi
279 using System.Drawing;
280 using System.Drawing.Drawing2D;
281 using System.Drawing.Imaging;
283 namespace System.Windows.Forms
286 internal class ThemeWin32Classic : Theme
289 /* Default colors for Win32 classic theme */
290 uint [] theme_colors = { /* AARRGGBB */
291 (uint) XplatUIWin32.GetSysColorIndex.COLOR_SCROLLBAR, 0xffc0c0c0,
292 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BACKGROUND, 0xff008080,
293 (uint) XplatUIWin32.GetSysColorIndex.COLOR_ACTIVECAPTION, 0xff000080,
294 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVECAPTION, 0xff808080,
295 (uint) XplatUIWin32.GetSysColorIndex.COLOR_MENU, 0xffc0c0c0,
296 (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOW, 0xffffffff,
297 (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOWFRAME, 0xff000000,
298 (uint) XplatUIWin32.GetSysColorIndex.COLOR_MENUTEXT, 0xff000000,
299 (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOWTEXT, 0xff000000,
300 (uint) XplatUIWin32.GetSysColorIndex.COLOR_CAPTIONTEXT, 0xffffffff,
301 (uint) XplatUIWin32.GetSysColorIndex.COLOR_ACTIVEBORDER, 0xffc0c0c0,
302 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVEBORDER, 0xffc0c0c0,
303 (uint) XplatUIWin32.GetSysColorIndex.COLOR_APPWORKSPACE, 0xff808080,
304 (uint) XplatUIWin32.GetSysColorIndex.COLOR_HIGHLIGHT, 0xff000080,
305 (uint) XplatUIWin32.GetSysColorIndex.COLOR_HIGHLIGHTTEXT, 0xffffffff,
306 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNFACE, 0xffc0c0c0,
307 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNSHADOW, 0xff808080,
308 (uint) XplatUIWin32.GetSysColorIndex.COLOR_GRAYTEXT, 0xff808080,
309 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNTEXT, 0xff000000,
310 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVECAPTIONTEXT, 0xffc0c0c0,
311 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNHIGHLIGHT, 0xffffffff,
312 (uint) XplatUIWin32.GetSysColorIndex.COLOR_3DDKSHADOW, 0xff000000,
313 (uint) XplatUIWin32.GetSysColorIndex.COLOR_3DLIGHT, 0xffe0e0e0,
314 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INFOTEXT, 0xff000000,
315 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INFOBK, 0xffffffff,
319 /* Hardcoded colour values not exposed in the API constants in all configurations */
320 static readonly Color arrow_color = Color.Black;
321 static readonly Color pen_ticks_color = Color.Black;
322 static readonly Color progressbarblock_color = Color.FromArgb (255, 0, 0, 128);
324 #region Principal Theme Methods
325 public ThemeWin32Classic ()
327 /* Init Default colour array*/
328 syscolors = Array.CreateInstance (typeof (Color), (uint) XplatUIWin32.GetSysColorIndex.COLOR_MAXVALUE+1);
330 for (int i = 0; i < theme_colors.Length; i +=2)
331 syscolors.SetValue (Color.FromArgb ((int)theme_colors[i+1]), (int) theme_colors[i]);
333 defaultWindowBackColor = SystemColors.Window;
334 defaultWindowForeColor = ColorButtonText;
335 default_font = new Font (FontFamily.GenericSansSerif, 8.25f);
338 public override bool DoubleBufferingSupported {
341 #endregion // Principal Theme Methods
343 #region Internal Methods
344 protected SolidBrush GetControlBackBrush (Color c) {
345 if (c == DefaultControlBackColor)
346 return ResPool.GetSolidBrush (ColorButtonFace);
347 return new SolidBrush (c);
350 protected SolidBrush GetControlForeBrush (Color c) {
351 if (c == DefaultControlForeColor)
352 return ResPool.GetSolidBrush (ColorButtonText);
353 return new SolidBrush (c);
355 #endregion // Internal Methods
357 #region OwnerDraw Support
358 public override void DrawOwnerDrawBackground (DrawItemEventArgs e)
360 if (e.State == DrawItemState.Selected) {
361 e.Graphics.FillRectangle (SystemBrushes.Highlight, e.Bounds);
365 e.Graphics.FillRectangle (GetControlBackBrush (e.BackColor), e.Bounds);
368 public override void DrawOwnerDrawFocusRectangle (DrawItemEventArgs e)
370 if (e.State == DrawItemState.Focus)
371 CPDrawFocusRectangle (e.Graphics, e.Bounds, e.ForeColor, e.BackColor);
373 #endregion // OwnerDraw Support
376 public override void DrawButtonBase(Graphics dc, Rectangle clip_area, ButtonBase button) {
379 Rectangle buttonRectangle;
380 Rectangle borderRectangle;
382 width = button.ClientSize.Width;
383 height = button.ClientSize.Height;
385 dc.FillRectangle(ResPool.GetSolidBrush (button.BackColor), button.ClientRectangle);
387 // set up the button rectangle
388 buttonRectangle = button.ClientRectangle;
389 if (button.has_focus) {
390 // shrink the rectangle for the normal button drawing inside the focus rectangle
391 borderRectangle = Rectangle.Inflate(buttonRectangle, -1, -1);
393 borderRectangle = buttonRectangle;
396 if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
397 DrawFlatStyleButton (dc, borderRectangle, button);
399 CPDrawButton(dc, borderRectangle, button.ButtonState);
402 // First, draw the image
403 if ((button.image != null) || (button.image_list != null)) {
404 // Need to draw a picture
411 if (button.ImageIndex!=-1) { // We use ImageIndex instead of image_index since it will return -1 if image_list is null
412 i = button.image_list.Images[button.image_index];
417 image_width = button.image.Width;
418 image_height = button.image.Height;
420 switch(button.image_alignment) {
421 case ContentAlignment.TopLeft: {
427 case ContentAlignment.TopCenter: {
428 image_x=(width-image_width)/2;
433 case ContentAlignment.TopRight: {
434 image_x=width-image_width;
439 case ContentAlignment.MiddleLeft: {
441 image_y=(height-image_height)/2;
445 case ContentAlignment.MiddleCenter: {
446 image_x=(width-image_width)/2;
447 image_y=(height-image_height)/2;
451 case ContentAlignment.MiddleRight: {
452 image_x=width-image_width;
453 image_y=(height-image_height)/2;
457 case ContentAlignment.BottomLeft: {
459 image_y=height-image_height;
463 case ContentAlignment.BottomCenter: {
464 image_x=(width-image_width)/2;
465 image_y=height-image_height;
469 case ContentAlignment.BottomRight: {
470 image_x=width-image_width;
471 image_y=height-image_height;
482 if (button.is_pressed) {
487 if (button.is_enabled) {
488 dc.DrawImage(i, image_x, image_y);
490 CPDrawImageDisabled(dc, i, image_x, image_y, ColorButtonFace);
494 // Draw the focus rectangle
495 if (button.has_focus) {
496 if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
497 DrawFlatStyleFocusRectangle (dc, button.ClientRectangle, button, button.ForeColor, button.BackColor);
499 CPDrawFocusRectangle(dc, button.ClientRectangle, button.ForeColor, button.BackColor);
504 if (button.text != null && button.text != String.Empty) {
505 Rectangle text_rect = Rectangle.Inflate(buttonRectangle, -4, -4);
507 if (button.is_pressed) {
512 if (button.is_enabled) {
513 dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (button.ForeColor), text_rect, button.text_format);
516 if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
517 dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), text_rect, button.text_format);
519 CPDrawStringDisabled(dc, button.text, button.Font, ColorButtonText, text_rect, button.text_format);
525 // draw the flat style part of the rectangle
526 public void DrawFlatStyleButton (Graphics graphics, Rectangle rectangle, ButtonBase button) {
527 Color rect_back_color = button.BackColor;
528 Color rect_fore_color = button.ForeColor;
529 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
531 if (button.Enabled) {
532 if (button.Capture || button.is_entered) {
533 if (button.FlatStyle == FlatStyle.Flat) {
534 // fill the rectangle
535 graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
537 // now draw the outer border
538 if (button.Capture && button.is_entered) {
539 rect_back_color = ControlPaint.LightLight (rect_back_color);
541 rect_back_color = ControlPaint.Light (rect_back_color);
544 // draw rectangle and fill it
545 graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
546 graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
548 // else it must be a popup button
550 if (button.Capture && button.is_entered) {
551 graphics.DrawRectangle(ResPool.GetPen (this.ColorButtonText), trace_rectangle);
554 CPDrawBorder3D (graphics, rectangle, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, button.BackColor);
555 graphics.DrawLine ( ResPool.GetPen (this.ColorButtonText), trace_rectangle.X, trace_rectangle.Bottom, trace_rectangle.Right, trace_rectangle.Bottom);
556 graphics.DrawLine ( ResPool.GetPen (this.ColorButtonText), trace_rectangle.Right, trace_rectangle.Y, trace_rectangle.Right, trace_rectangle.Bottom);
560 // TODO: draw inner focus rectangle
563 // popup has a ButtonColorText forecolor, not a button.ForeCOlor
564 if (button.FlatStyle == FlatStyle.Popup) {
565 rect_fore_color = this.ColorButtonText;
568 // fill then draw outer rect
569 graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
570 graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
573 // finally some small tweaks to render radiobutton and checkbox
574 CheckBox checkbox = button as CheckBox;
575 RadioButton radiobutton = button as RadioButton;
576 if ((checkbox != null && checkbox.Checked) ||
577 (radiobutton != null && radiobutton.Checked)) {
578 if (button.FlatStyle == FlatStyle.Flat && button.is_entered && !button.Capture) {
579 // render the hover for flat flatstyle and cheked
580 graphics.DrawRectangle(ResPool.GetPen (this.ColorButtonText), trace_rectangle);
581 } else if (!button.is_entered && !button.Capture) {
582 // render the checked state for popup when unhovered
583 CPDrawBorder3D (graphics, rectangle, Border3DStyle.SunkenInner, Border3DSide.Right | Border3DSide.Bottom, button.BackColor);
587 // rendering checkbox or radio button style buttons
588 CheckBox checkbox = button as CheckBox;
589 RadioButton radiobutton = button as RadioButton;
590 bool draw_popup_checked = false;
592 if (button.FlatStyle == FlatStyle.Popup) {
593 rect_fore_color = this.ColorButtonText;
595 // see if we should draw a disabled checked popup button
596 draw_popup_checked = ((checkbox != null && checkbox.Checked) ||
597 (radiobutton != null && radiobutton.Checked));
600 graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
601 graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
603 // finally draw the flatstyle checked effect if need
604 if (draw_popup_checked) {
605 // render the checked state for popup when unhovered
606 CPDrawBorder3D (graphics, rectangle, Border3DStyle.SunkenInner, Border3DSide.Right | Border3DSide.Bottom, button.BackColor);
611 public override Size ButtonBaseDefaultSize {
613 return new Size (75, 23);
616 #endregion // ButtonBase
619 public override void DrawCheckBox(Graphics dc, Rectangle clip_area, CheckBox checkbox) {
620 StringFormat text_format;
621 Rectangle client_rectangle;
622 Rectangle text_rectangle;
623 Rectangle checkbox_rectangle;
625 int checkmark_size=13;
626 int checkmark_space = 4;
628 client_rectangle = checkbox.ClientRectangle;
629 text_rectangle = client_rectangle;
630 checkbox_rectangle = new Rectangle(text_rectangle.X, text_rectangle.Y, checkmark_size, checkmark_size);
632 text_format = new StringFormat();
633 text_format.Alignment=StringAlignment.Near;
634 text_format.LineAlignment=StringAlignment.Center;
636 /* Calculate the position of text and checkbox rectangle */
637 if (checkbox.appearance!=Appearance.Button) {
638 switch(checkbox.check_alignment) {
639 case ContentAlignment.BottomCenter: {
640 checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
641 checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
642 text_rectangle.X=client_rectangle.X;
643 text_rectangle.Width=client_rectangle.Width;
644 text_rectangle.Height=client_rectangle.Height-checkbox_rectangle.Y-checkmark_space;
648 case ContentAlignment.BottomLeft: {
649 checkbox_rectangle.X=client_rectangle.Left;
650 checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
651 text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
652 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
656 case ContentAlignment.BottomRight: {
657 checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
658 checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
659 text_rectangle.X=client_rectangle.X;
660 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
664 case ContentAlignment.MiddleCenter: {
665 checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
666 checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
667 text_rectangle.X=client_rectangle.X;
668 text_rectangle.Width=client_rectangle.Width;
673 case ContentAlignment.MiddleLeft: {
674 checkbox_rectangle.X=client_rectangle.Left;
675 checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
676 text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
677 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
681 case ContentAlignment.MiddleRight: {
682 checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
683 checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
684 text_rectangle.X=client_rectangle.X;
685 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
689 case ContentAlignment.TopCenter: {
690 checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
691 checkbox_rectangle.Y=client_rectangle.Top;
692 text_rectangle.X=client_rectangle.X;
693 text_rectangle.Width=client_rectangle.Width;
694 text_rectangle.Y=checkmark_size+checkmark_space;
695 text_rectangle.Height=client_rectangle.Height-checkmark_size-checkmark_space;
699 case ContentAlignment.TopLeft: {
700 checkbox_rectangle.X=client_rectangle.Left;
701 text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
702 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
706 case ContentAlignment.TopRight: {
707 checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
708 text_rectangle.X=client_rectangle.X;
709 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
714 text_rectangle.X=client_rectangle.X;
715 text_rectangle.Width=client_rectangle.Width;
718 /* Set the horizontal alignment of our text */
719 switch(checkbox.text_alignment) {
720 case ContentAlignment.BottomLeft:
721 case ContentAlignment.MiddleLeft:
722 case ContentAlignment.TopLeft: {
723 text_format.Alignment=StringAlignment.Near;
727 case ContentAlignment.BottomCenter:
728 case ContentAlignment.MiddleCenter:
729 case ContentAlignment.TopCenter: {
730 text_format.Alignment=StringAlignment.Center;
734 case ContentAlignment.BottomRight:
735 case ContentAlignment.MiddleRight:
736 case ContentAlignment.TopRight: {
737 text_format.Alignment=StringAlignment.Far;
742 /* Set the vertical alignment of our text */
743 switch(checkbox.text_alignment) {
744 case ContentAlignment.TopLeft:
745 case ContentAlignment.TopCenter:
746 case ContentAlignment.TopRight: {
747 text_format.LineAlignment=StringAlignment.Near;
751 case ContentAlignment.BottomLeft:
752 case ContentAlignment.BottomCenter:
753 case ContentAlignment.BottomRight: {
754 text_format.LineAlignment=StringAlignment.Far;
758 case ContentAlignment.MiddleLeft:
759 case ContentAlignment.MiddleCenter:
760 case ContentAlignment.MiddleRight: {
761 text_format.LineAlignment=StringAlignment.Center;
766 ButtonState state = ButtonState.Normal;
767 if (checkbox.FlatStyle == FlatStyle.Flat) {
768 state |= ButtonState.Flat;
771 if (checkbox.Checked) {
772 state |= ButtonState.Checked;
775 if (checkbox.ThreeState && (checkbox.CheckState == CheckState.Indeterminate)) {
776 state |= ButtonState.Checked;
777 state |= ButtonState.Pushed;
780 // finally make sure the pushed and inavtive states are rendered
781 if (!checkbox.Enabled) {
782 state |= ButtonState.Inactive;
784 else if (checkbox.is_pressed) {
785 state |= ButtonState.Pushed;
791 sb=new SolidBrush(checkbox.BackColor);
792 dc.FillRectangle(sb, checkbox.ClientRectangle);
795 // render as per normal button
796 if (checkbox.appearance==Appearance.Button) {
797 if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
798 DrawFlatStyleButton(dc, checkbox.ClientRectangle, checkbox);
800 CPDrawButton(dc, checkbox.ClientRectangle, state);
803 // establish if we are rendering a flat style of some sort
804 if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
805 DrawFlatStyleCheckBox (dc, checkbox_rectangle, checkbox);
807 ControlPaint.DrawCheckBox(dc, checkbox_rectangle, state);
811 // offset the text if it's pressed and a button
812 if (checkbox.Appearance == Appearance.Button) {
813 if (checkbox.Checked || (checkbox.Capture && checkbox.FlatStyle != FlatStyle.Flat)) {
818 text_rectangle.Inflate(-4, -4);
821 /* Place the text; to be compatible with Windows place it after the checkbox has been drawn */
822 if (checkbox.Enabled) {
823 sb = ResPool.GetSolidBrush(checkbox.ForeColor);
824 dc.DrawString(checkbox.Text, checkbox.Font, sb, text_rectangle, text_format);
825 } else if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
826 dc.DrawString(checkbox.Text, checkbox.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), text_rectangle, text_format);
828 CPDrawStringDisabled(dc, checkbox.Text, checkbox.Font, ColorButtonText, text_rectangle, text_format);
831 if (checkbox.Focused) {
832 if (checkbox.FlatStyle != FlatStyle.Flat) {
833 DrawInnerFocusRectangle (dc, Rectangle.Inflate (client_rectangle, -4, -4), checkbox.BackColor);
835 dc.DrawRectangle (ResPool.GetPen (checkbox.ForeColor), Rectangle.Inflate (client_rectangle, -4, -4));
840 // renders a checkBox with the Flat and Popup FlatStyle
841 private void DrawFlatStyleCheckBox (Graphics graphics, Rectangle rectangle, CheckBox checkbox)
845 Rectangle checkbox_rectangle;
846 Rectangle fill_rectangle;
850 // set up our rectangles first
851 if (checkbox.FlatStyle == FlatStyle.Popup && checkbox.is_entered) {
852 // clip one pixel from bottom right for non popup rendered checkboxes
853 checkbox_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max(rectangle.Width-1, 0), Math.Max(rectangle.Height-1,0));
854 fill_rectangle = new Rectangle(checkbox_rectangle.X+1, checkbox_rectangle.Y+1, Math.Max(checkbox_rectangle.Width-3, 0), Math.Max(checkbox_rectangle.Height-3,0));
856 // clip two pixels from bottom right for non popup rendered checkboxes
857 checkbox_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max(rectangle.Width-2, 0), Math.Max(rectangle.Height-2,0));
858 fill_rectangle = new Rectangle(checkbox_rectangle.X+1, checkbox_rectangle.Y+1, Math.Max(checkbox_rectangle.Width-2, 0), Math.Max(checkbox_rectangle.Height-2,0));
861 // if disabled render in disabled state
862 if (checkbox.Enabled) {
863 // process the state of the checkbox
864 if (checkbox.is_entered || checkbox.Capture) {
865 // decide on which background color to use
866 if (checkbox.FlatStyle == FlatStyle.Popup && checkbox.is_entered && checkbox.Capture) {
867 graphics.FillRectangle(ResPool.GetSolidBrush (checkbox.BackColor), fill_rectangle);
868 } else if (checkbox.FlatStyle == FlatStyle.Flat && !(checkbox.is_entered && checkbox.Capture)) {
869 graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.Light(checkbox.BackColor)), fill_rectangle);
871 // use regular window background color
872 graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);
875 // render the outer border
876 if (checkbox.FlatStyle == FlatStyle.Flat) {
877 ControlPaint.DrawBorder(graphics, checkbox_rectangle, checkbox.ForeColor, ButtonBorderStyle.Solid);
879 // draw sunken effect
880 CPDrawBorder3D (graphics, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.All, checkbox.BackColor);
883 graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);
885 if (checkbox.FlatStyle == FlatStyle.Flat) {
886 ControlPaint.DrawBorder(graphics, checkbox_rectangle, checkbox.ForeColor, ButtonBorderStyle.Solid);
888 // draw the outer border
889 ControlPaint.DrawBorder(graphics, checkbox_rectangle, ControlPaint.DarkDark (checkbox.BackColor), ButtonBorderStyle.Solid);
893 if (checkbox.FlatStyle == FlatStyle.Popup) {
894 graphics.FillRectangle(SystemBrushes.Control, fill_rectangle);
897 // draw disabled state,
898 ControlPaint.DrawBorder(graphics, checkbox_rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
901 /* Make sure we've got at least a line width of 1 */
902 lineWidth = Math.Max(3, fill_rectangle.Width/3);
903 Scale=Math.Max(1, fill_rectangle.Width/9);
905 // flat style check box is rendered inside a rectangle shifted down by one
906 rect=new Rectangle(fill_rectangle.X, fill_rectangle.Y+1, fill_rectangle.Width, fill_rectangle.Height);
907 if (checkbox.Enabled) {
908 pen=ResPool.GetPen(checkbox.ForeColor);
910 pen=SystemPens.ControlDark;
913 if (checkbox.Checked) {
914 /* Need to draw a check-mark */
915 for (int i=0; i<lineWidth; i++) {
916 graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
917 graphics.DrawLine(pen, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i, rect.Left+lineWidth/2+6*Scale, rect.Top+lineWidth-2*Scale+i);
923 #endregion // CheckBox
926 public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box) {
929 Rectangle rect = box.ClientRectangle;
930 Color disabled = ColorGrayText;
932 Pen pen_light = ResPool.GetPen (Color.FromArgb (255,255,255,255));
933 Pen pen_dark = ResPool.GetPen (Color.FromArgb (255, 128, 128,128));
935 // TODO: When the Light and Dark methods work this code should be activate it
936 //Pen pen_light = new Pen (ControlPaint.Light (disabled, 1));
937 //Pen pen_dark = new Pen (ControlPaint.Dark (disabled, 0));
939 dc.FillRectangle (ResPool.GetSolidBrush (box.BackColor), rect);
941 size = dc.MeasureString (box.Text, box.Font);
942 width = (int) size.Width;
944 if (width > box.Width - 16)
945 width = box.Width - 16;
947 y = box.Font.Height / 2;
950 dc.DrawLine (pen_dark, 0, y, 8, y); // top
951 dc.DrawLine (pen_light, 0, y + 1, 8, y + 1);
952 dc.DrawLine (pen_dark, 8 + width, y, box.Width, y);
953 dc.DrawLine (pen_light, 8 + width, y + 1, box.Width, y + 1);
955 dc.DrawLine (pen_dark, 0, y + 1, 0, box.Height); // left
956 dc.DrawLine (pen_light, 1, y + 1, 1, box.Height);
958 dc.DrawLine (pen_dark, 0, box.Height - 2, box.Width, box.Height - 2); // bottom
959 dc.DrawLine (pen_light, 0, box.Height - 1, box.Width, box.Height - 1);
961 dc.DrawLine (pen_dark, box.Width - 2, y, box.Width - 2, box.Height - 2); // right
962 dc.DrawLine (pen_light, box.Width - 1, y, box.Width - 1, box.Height - 2);
967 dc.DrawString (box.Text, box.Font, new SolidBrush (box.ForeColor), 10, 0);
969 CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor,
970 new RectangleF (10, 0, width, box.Font.Height), new StringFormat ());
974 public override Size GroupBoxDefaultSize {
976 return new Size (200,100);
982 public override Size HScrollBarDefaultSize {
984 return new Size (80, this.ScrollBarButtonSize);
988 #endregion // HScrollBar
991 public override void DrawLabel (Graphics dc, Rectangle clip_rectangle, Label label)
993 dc.FillRectangle (ResPool.GetSolidBrush (label.BackColor), clip_rectangle);
995 CPDrawBorderStyle (dc, clip_rectangle, label.BorderStyle);
998 dc.DrawString (label.Text, label.Font, ResPool.GetSolidBrush (label.ForeColor), clip_rectangle, label.string_format);
1000 ControlPaint.DrawStringDisabled (dc, label.Text, label.Font, label.ForeColor, clip_rectangle, label.string_format);
1005 public override Size LabelDefaultSize {
1007 return new Size (100, 23);
1016 public override void DrawListBoxDecorations (Graphics dc, ListBox ctrl)
1018 Rectangle cl = ctrl.LBoxInfo.client_rect;
1021 switch (ctrl.BorderStyle) {
1022 case BorderStyle.Fixed3D: {
1023 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top
1024 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
1025 dc.DrawLine (ResPool.GetPen (ColorButtonFace), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
1026 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
1027 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
1028 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2);
1029 dc.DrawLine (ResPool.GetPen (ColorButtonFace), cl.X + cl.Width - 2, cl.Y, cl.X + cl.Width - 2, cl.Y + cl.Height); //right
1030 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), cl.X + cl.Width - 1, cl.Y + 1 , cl.X + cl.Width - 1, cl.Y + cl.Height - 1);
1033 case BorderStyle.FixedSingle:
1034 dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame), cl.X, cl.Y, cl.Width - 1, cl.Height - 1);
1036 case BorderStyle.None:
1042 private int DrawListBoxDecorationSize (BorderStyle border_style)
1044 switch (border_style) {
1045 case BorderStyle.Fixed3D:
1047 case BorderStyle.FixedSingle:
1049 case BorderStyle.None:
1058 public override int DrawListBoxDecorationTop (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
1059 public override int DrawListBoxDecorationBottom (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
1060 public override int DrawListBoxDecorationRight (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
1061 public override int DrawListBoxDecorationLeft (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
1067 public override void DrawListView (Graphics dc, Rectangle clip_rectangle, ListView control)
1069 bool details = (control.View == View.Details);
1071 // Clear the graphics context
1072 dc.Clear (control.BackColor);
1074 // border is drawn directly in the Paint method
1075 if (details && control.HeaderStyle != ColumnHeaderStyle.None) {
1076 dc.FillRectangle (ResPool.GetSolidBrush (SystemColors.Control),
1077 0, 0, control.TotalWidth, control.Font.Height);
1078 if (control.Columns.Count > 0) {
1079 if (control.HeaderStyle == ColumnHeaderStyle.Clickable) {
1080 foreach (ColumnHeader col in control.Columns) {
1081 this.CPDrawButton (dc, col.Rect,
1083 ButtonState.Pushed :
1084 ButtonState.Normal));
1085 dc.DrawString (col.Text, control.Font,
1086 ResPool.GetSolidBrush
1087 (this.ColorButtonText),
1088 col.Rect, col.Format);
1091 // Non-clickable columns
1093 foreach (ColumnHeader col in control.Columns) {
1094 this.CPDrawButton (dc, col.Rect, ButtonState.Flat);
1095 dc.DrawString (col.Text, control.Font,
1096 ResPool.GetSolidBrush
1097 (this.ColorButtonText),
1098 col.Rect, col.Format);
1104 // In case of details view draw the items only if
1105 // columns are non-zero
1106 if (!details || control.Columns.Count > 0)
1107 foreach (ListViewItem item in control.Items)
1108 this.DrawListViewItem (dc, control, item);
1110 // draw the gridlines
1111 if (details && control.GridLines) {
1112 int top = (control.HeaderStyle == ColumnHeaderStyle.None) ?
1113 2 : control.Font.Height + 2;
1115 // draw vertical gridlines
1116 foreach (ColumnHeader col in control.Columns)
1117 dc.DrawLine (this.ResPool.GetPen (this.ColorButtonFace),
1118 col.Rect.Right, top,
1119 col.Rect.Right, control.TotalHeight);
1120 // draw horizontal gridlines
1121 ListViewItem last_item = null;
1122 foreach (ListViewItem item in control.Items) {
1123 dc.DrawLine (this.ResPool.GetPen (this.ColorButtonFace),
1124 item.EntireRect.Left, item.EntireRect.Top,
1125 control.TotalWidth, item.EntireRect.Top);
1129 // draw a line after at the bottom of the last item
1130 if (last_item != null) {
1131 dc.DrawLine (this.ResPool.GetPen (this.ColorButtonFace),
1132 last_item.EntireRect.Left,
1133 last_item.EntireRect.Bottom,
1135 last_item.EntireRect.Bottom);
1140 // draws the ListViewItem of the given index
1141 private void DrawListViewItem (Graphics dc, ListView control, ListViewItem item)
1143 if (control.CheckBoxes) {
1144 if (control.StateImageList == null) {
1145 // Make sure we've got at least a line width of 1
1146 int check_wd = Math.Max (3, item.CheckRect.Width / 6);
1147 int scale = Math.Max (1, item.CheckRect.Width / 12);
1149 // set the checkbox background
1150 dc.FillRectangle (this.ResPool.GetSolidBrush (this.ColorWindow),
1152 // define a rectangle inside the border area
1153 Rectangle rect = new Rectangle (item.CheckRect.X + 2,
1154 item.CheckRect.Y + 2,
1155 item.CheckRect.Width - 4,
1156 item.CheckRect.Height - 4);
1157 Pen pen = new Pen (this.ColorWindowText, 2);
1158 dc.DrawRectangle (pen, rect);
1160 // Need to draw a check-mark
1163 // adjustments to get the check-mark at the right place
1164 rect.X ++; rect.Y ++;
1165 // following logic is taken from DrawFrameControl method
1166 for (int i = 0; i < check_wd; i++) {
1167 dc.DrawLine (pen, rect.Left + check_wd / 2,
1168 rect.Top + check_wd + i,
1169 rect.Left + check_wd / 2 + 2 * scale,
1170 rect.Top + check_wd + 2 * scale + i);
1172 rect.Left + check_wd / 2 + 2 * scale,
1173 rect.Top + check_wd + 2 * scale + i,
1174 rect.Left + check_wd / 2 + 6 * scale,
1175 rect.Top + check_wd - 2 * scale + i);
1180 if (item.Checked && control.StateImageList.Images.Count > 1)
1181 control.StateImageList.Draw (dc,
1182 item.CheckRect.Location, 1);
1183 else if (! item.Checked && control.StateImageList.Images.Count > 0)
1184 control.StateImageList.Draw (dc,
1185 item.CheckRect.Location, 0);
1189 // Item is drawn as a special case, as it is not just text
1190 if (control.View == View.LargeIcon) {
1191 if (item.ImageIndex > -1 &&
1192 control.LargeImageList != null &&
1193 item.ImageIndex < control.LargeImageList.Images.Count)
1194 control.LargeImageList.Draw (dc, item.IconRect.Location,
1198 if (item.ImageIndex > -1 &&
1199 control.SmallImageList != null &&
1200 item.ImageIndex < control.SmallImageList.Images.Count)
1201 control.SmallImageList.Draw (dc, item.IconRect.Location,
1205 // draw the item text
1206 Rectangle text_rect = item.LabelRect;
1207 // format for the item text
1208 StringFormat format = new StringFormat ();
1209 format.LineAlignment = StringAlignment.Center;
1210 if (control.View == View.LargeIcon)
1211 format.Alignment = StringAlignment.Center;
1213 format.Alignment = StringAlignment.Near;
1215 if (!control.LabelWrap)
1216 format.FormatFlags = StringFormatFlags.NoWrap;
1218 if (item.Selected) {
1219 if (control.View == View.Details) {
1220 if (control.FullRowSelect) {
1221 // fill the entire rect excluding the checkbox
1222 Rectangle full_rect = item.EntireRect;
1223 full_rect.Location = item.LabelRect.Location;
1224 dc.FillRectangle (this.ResPool.GetSolidBrush
1225 (this.ColorHilight), full_rect);
1228 Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
1230 text_rect.Width = text_size.Width;
1231 dc.FillRectangle (this.ResPool.GetSolidBrush
1232 (this.ColorHilight), text_rect);
1236 /*Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
1238 Point loc = text_rect.Location;
1239 loc.X += (text_rect.Width - text_size.Width) / 2;
1240 text_rect.Width = text_size.Width;*/
1241 dc.FillRectangle (this.ResPool.GetSolidBrush (this.ColorHilight),
1246 dc.FillRectangle (ResPool.GetSolidBrush (item.BackColor), text_rect);
1248 if (item.Text != null && item.Text.Length > 0) {
1250 dc.DrawString (item.Text, item.Font, this.ResPool.GetSolidBrush
1251 (this.ColorHilightText), text_rect, format);
1253 dc.DrawString (item.Text, item.Font, this.ResPool.GetSolidBrush
1254 (item.ForeColor), text_rect, format);
1257 if (control.View == View.Details && control.Columns.Count > 0) {
1258 // draw subitems for details view
1259 ListViewItem.ListViewSubItemCollection subItems = item.SubItems;
1260 int count = (control.Columns.Count < subItems.Count ?
1261 control.Columns.Count : subItems.Count);
1265 ListViewItem.ListViewSubItem subItem;
1266 Rectangle sub_item_rect = item.LabelRect;
1268 // set the format for subitems
1269 format.FormatFlags = StringFormatFlags.NoWrap;
1270 format.Alignment = StringAlignment.Near;
1272 // 0th subitem is the item already drawn
1273 for (int index = 1; index < count; index++) {
1274 subItem = subItems [index];
1275 col = control.Columns [index];
1276 sub_item_rect.X = col.Rect.Left;
1277 sub_item_rect.Width = col.Wd;
1279 SolidBrush sub_item_back_br = null;
1280 SolidBrush sub_item_fore_br = null;
1281 Font sub_item_font = null;
1283 if (item.UseItemStyleForSubItems) {
1284 sub_item_back_br = this.ResPool.GetSolidBrush
1286 sub_item_fore_br = this.ResPool.GetSolidBrush
1288 sub_item_font = item.Font;
1291 sub_item_back_br = this.ResPool.GetSolidBrush
1292 (subItem.BackColor);
1293 sub_item_fore_br = this.ResPool.GetSolidBrush
1294 (subItem.ForeColor);
1295 sub_item_font = subItem.Font;
1298 // In case of fullrowselect, background is filled
1299 // for the entire rect above
1300 if (item.Selected && control.FullRowSelect) {
1301 if (subItem.Text != null && subItem.Text.Length > 0)
1302 dc.DrawString (subItem.Text, sub_item_font,
1303 this.ResPool.GetSolidBrush
1304 (this.ColorHilightText),
1305 sub_item_rect, format);
1308 dc.FillRectangle (sub_item_back_br, sub_item_rect);
1309 if (subItem.Text != null && subItem.Text.Length > 0)
1310 dc.DrawString (subItem.Text, sub_item_font,
1312 sub_item_rect, format);
1314 sub_item_rect.X += col.Wd;
1321 public override Size ListViewCheckBoxSize {
1322 get { return new Size (16, 16); }
1325 public override int ListViewColumnHeaderHeight {
1329 public override int ListViewDefaultColumnWidth {
1333 public override int ListViewVerticalSpacing {
1337 public override int ListViewEmptyColumnWidth {
1341 public override int ListViewHorizontalSpacing {
1345 public override Size ListViewDefaultSize {
1346 get { return new Size (121, 97); }
1348 #endregion // ListView
1350 #region MonthCalendar
1352 // draw the month calendar
1353 public override void DrawMonthCalendar(Graphics dc, Rectangle clip_rectangle, MonthCalendar mc)
\r
1355 Rectangle client_rectangle = mc.ClientRectangle;
1356 Size month_size = mc.SingleMonthSize;
1357 // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
1358 Size calendar_spacing = (Size)((object)mc.calendar_spacing);
1359 Size date_cell_size = (Size)((object)mc.date_cell_size);
1361 // draw the singlecalendars
1364 // adjust for the position of the specific month
1365 for (int i=0; i < mc.CalendarDimensions.Height; i++)
\r
1369 y_offset += month_size.Height + calendar_spacing.Height;
1371 // now adjust for x position
1372 for (int j=0; j < mc.CalendarDimensions.Width; j++)
\r
1376 x_offset += month_size.Width + calendar_spacing.Width;
1383 Rectangle month_rect = new Rectangle (x_offset, y_offset, month_size.Width, month_size.Height);
1384 if (month_rect.IntersectsWith (clip_rectangle)) {
1396 Rectangle bottom_rect = new Rectangle (
1398 Math.Max(client_rectangle.Bottom - date_cell_size.Height - 3, 0),
1399 client_rectangle.Width,
1400 date_cell_size.Height + 2);
1401 // draw the today date if it's set
1402 if (mc.ShowToday && bottom_rect.IntersectsWith (clip_rectangle))
\r
1404 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), bottom_rect);
1406 int today_offset = 5;
1407 if (mc.ShowTodayCircle)
\r
1409 Rectangle today_circle_rect = new Rectangle (
1410 client_rectangle.X + 5,
1411 Math.Max(client_rectangle.Bottom - date_cell_size.Height - 2, 0),
1412 date_cell_size.Width,
1413 date_cell_size.Height);
1414 DrawTodayCircle (dc, today_circle_rect);
1415 today_offset += date_cell_size.Width + 5;
1417 // draw today's date
1418 StringFormat text_format = new StringFormat();
1419 text_format.LineAlignment = StringAlignment.Center;
1420 text_format.Alignment = StringAlignment.Near;
1421 Font bold_font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
1422 Rectangle today_rect = new Rectangle (
1423 today_offset + client_rectangle.X,
1424 Math.Max(client_rectangle.Bottom - date_cell_size.Height, 0),
1425 Math.Max(client_rectangle.Width - today_offset, 0),
1426 date_cell_size.Height);
1427 dc.DrawString ("Today: " + DateTime.Now.ToShortDateString(), bold_font, ResPool.GetSolidBrush (mc.ForeColor), today_rect, text_format);
1431 // finally paint the borders of the calendars as required
1432 for (int i = 0; i <= mc.CalendarDimensions.Width; i++) {
1433 if (i == 0 && clip_rectangle.X == client_rectangle.X) {
1434 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, 1, client_rectangle.Height));
1435 } else if (i == mc.CalendarDimensions.Width && clip_rectangle.Right == client_rectangle.Right) {
1436 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.Right-1, client_rectangle.Y, 1, client_rectangle.Height));
1438 Rectangle rect = new Rectangle (
1439 client_rectangle.X + (month_size.Width*i) + (calendar_spacing.Width * (i-1)) + 1,
1441 calendar_spacing.Width,
1442 client_rectangle.Height);
1443 if (i < mc.CalendarDimensions.Width && i > 0 && clip_rectangle.IntersectsWith (rect)) {
1444 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
1448 for (int i = 0; i <= mc.CalendarDimensions.Height; i++) {
1449 if (i == 0 && clip_rectangle.Y == client_rectangle.Y) {
1450 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, client_rectangle.Width, 1));
1451 } else if (i == mc.CalendarDimensions.Height && clip_rectangle.Bottom == client_rectangle.Bottom) {
1452 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Bottom-1, client_rectangle.Width, 1));
1454 Rectangle rect = new Rectangle (
1456 client_rectangle.Y + (month_size.Height*i) + (calendar_spacing.Height*(i-1)) + 1,
1457 client_rectangle.Width,
1458 calendar_spacing.Height);
1459 if (i < mc.CalendarDimensions.Height && i > 0 && clip_rectangle.IntersectsWith (rect)) {
1460 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
1466 // darws a single part of the month calendar (with one month)
1467 private void DrawSingleMonth(Graphics dc, Rectangle clip_rectangle, Rectangle rectangle, MonthCalendar mc, int row, int col)
\r
1469 // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
1470 Size title_size = (Size)((object)mc.title_size);
1471 Size date_cell_size = (Size)((object)mc.date_cell_size);
1472 DateTime current_month = (DateTime)((object)mc.current_month);
1474 // set up some standard string formating variables
1475 StringFormat text_format = new StringFormat();
1476 text_format.LineAlignment = StringAlignment.Center;
1477 text_format.Alignment = StringAlignment.Center;
1480 // draw the title back ground
1481 DateTime this_month = current_month.AddMonths (row*mc.CalendarDimensions.Width+col);
1482 Rectangle title_rect = new Rectangle(rectangle.X, rectangle.Y, title_size.Width, title_size.Height);
1483 if (title_rect.IntersectsWith (clip_rectangle)) {
1484 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), title_rect);
1486 string title_text = this_month.ToString ("MMMM yyyy");
1487 dc.DrawString (title_text, mc.Font, ResPool.GetSolidBrush (mc.TitleForeColor), title_rect, text_format);
1489 // draw previous and next buttons if it's time
1490 if (row == 0 && col == 0)
\r
1492 // draw previous button
1493 DrawMonthCalendarButton (
1499 (System.Drawing.Size)((object)mc.button_size),
1502 if (row == 0 && col == mc.CalendarDimensions.Width-1)
\r
1505 DrawMonthCalendarButton (
1511 (System.Drawing.Size)((object)mc.button_size),
1516 // set the week offset and draw week nums if needed
1517 int col_offset = (mc.ShowWeekNumbers) ? 1 : 0;
1518 Rectangle day_name_rect = new Rectangle(
1520 rectangle.Y + title_size.Height,
1521 (7 + col_offset) * date_cell_size.Width,
1522 date_cell_size.Height);
1523 if (day_name_rect.IntersectsWith (clip_rectangle)) {
1524 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), day_name_rect);
1525 // draw the day names
1526 DayOfWeek first_day_of_week = mc.GetDayOfWeek(mc.FirstDayOfWeek);
1527 for (int i=0; i < 7; i++)
\r
1529 int position = i - (int) first_day_of_week;
1530 if (position < 0)
\r
1532 position = 7 + position;
1535 Rectangle day_rect = new Rectangle(
1536 day_name_rect.X + ((i + col_offset)* date_cell_size.Width),
1538 date_cell_size.Width,
1539 date_cell_size.Height);
1540 dc.DrawString (((DayOfWeek)i).ToString().Substring(0, 3), mc.Font, ResPool.GetSolidBrush (mc.TitleBackColor), day_rect, text_format);
1543 // draw the vertical divider
1544 int vert_divider_y = Math.Max(title_size.Height+ date_cell_size.Height-1, 0);
1546 ResPool.GetPen (mc.ForeColor),
1547 rectangle.X + (col_offset * date_cell_size.Width) + mc.divider_line_offset,
1548 rectangle.Y + vert_divider_y,
1549 rectangle.Right - mc.divider_line_offset,
1550 rectangle.Y + vert_divider_y);
1554 // draw the actual date items in the grid (including the week numbers)
1555 Rectangle date_rect = new Rectangle (
1557 rectangle.Y + title_size.Height + date_cell_size.Height,
1558 date_cell_size.Width,
1559 date_cell_size.Height);
1560 int month_row_count = 0;
1561 bool draw_week_num_divider = false;
1562 bool no_more_content = false; // required to enable us to fill the background rect and not draw any dates on it (if none are required)
1563 DateTime current_date = mc.GetFirstDateInMonthGrid ( new DateTime (this_month.Year, this_month.Month, 1));
1564 for (int i=0; i < 6; i++)
\r
1566 // establish if this row is in our clip_area
1567 Rectangle row_rect = new Rectangle (
1569 rectangle.Y + title_size.Height + (date_cell_size.Height * (i+1)),
1570 date_cell_size.Width * 7,
1571 date_cell_size.Height);
1572 if (mc.ShowWeekNumbers) {
1573 row_rect.Width += date_cell_size.Width;
1576 bool draw_row = row_rect.IntersectsWith (clip_rectangle);
1578 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), row_rect);
1580 // establish if this is a valid week to draw
1581 if (mc.IsValidWeekToDraw (this_month, current_date, row, col)) {
1582 month_row_count = i;
1585 // draw the week number if required
1586 if (mc.ShowWeekNumbers && month_row_count == i) {
1587 if (!draw_week_num_divider) {
1588 draw_week_num_divider = draw_row;
1590 // get the week for this row
1591 int week = mc.GetWeekOfYear (current_date);
1597 ResPool.GetSolidBrush (mc.TitleBackColor),
1601 date_rect.Offset(date_cell_size.Width, 0);
1604 // only draw the days if we have to
1605 if(month_row_count == i) {
1606 for (int j=0; j < 7; j++)
\r
1609 DrawMonthCalendarDate (
1620 current_date = current_date.AddDays(1);
1621 date_rect.Offset(date_cell_size.Width, 0);
1624 // shift the rectangle down one row
1625 int offset = (mc.ShowWeekNumbers) ? -8 : -7;
1626 date_rect.Offset(offset*date_cell_size.Width, date_cell_size.Height);
1630 // month_row_count is zero based, so add one
1633 // draw week numbers if required
1634 if (draw_week_num_divider) {
1637 ResPool.GetPen (mc.ForeColor),
1638 rectangle.X + date_cell_size.Width - 1,
1639 rectangle.Y + title_size.Height + date_cell_size.Height + mc.divider_line_offset,
1640 rectangle.X + date_cell_size.Width - 1,
1641 rectangle.Y + title_size.Height + date_cell_size.Height + (month_row_count * date_cell_size.Height) - mc.divider_line_offset);
1645 // draws the pervious or next button
1646 private void DrawMonthCalendarButton (Graphics dc, Rectangle rectangle, MonthCalendar mc, Size title_size, int x_offset, Size button_size, bool is_previous)
\r
1648 bool is_clicked = false;
1649 Rectangle button_rect;
1650 Rectangle arrow_rect = new Rectangle (rectangle.X, rectangle.Y, 4, 7);
1651 Point[] arrow_path = new Point[3];
1652 // prepare the button
1655 is_clicked = mc.is_previous_clicked;
1656 button_rect = new Rectangle (
1657 rectangle.X + 1 + x_offset,
1658 rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
1659 Math.Max(button_size.Width - 1, 0),
1660 Math.Max(button_size.Height - 1, 0));
1661 arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
1662 arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
1664 arrow_rect.Offset(1,1);
1666 arrow_path[0] = new Point (arrow_rect.Right, arrow_rect.Y);
1667 arrow_path[1] = new Point (arrow_rect.X, arrow_rect.Y + arrow_rect.Height/2);
1668 arrow_path[2] = new Point (arrow_rect.Right, arrow_rect.Bottom);
1672 is_clicked = mc.is_next_clicked;
1673 button_rect = new Rectangle (
1674 rectangle.Right - 1 - x_offset - button_size.Width,
1675 rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
1676 Math.Max(button_size.Width - 1, 0),
1677 Math.Max(button_size.Height - 1, 0));
1678 arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
1679 arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
1681 arrow_rect.Offset(1,1);
1683 arrow_path[0] = new Point (arrow_rect.X, arrow_rect.Y);
1684 arrow_path[1] = new Point (arrow_rect.Right, arrow_rect.Y + arrow_rect.Height/2);
1685 arrow_path[2] = new Point (arrow_rect.X, arrow_rect.Bottom);
1688 // fill the background
1689 dc.FillRectangle (SystemBrushes.Control, button_rect);
1692 dc.DrawRectangle (SystemPens.ControlDark, button_rect);
1695 CPDrawBorder3D (dc, button_rect, Border3DStyle.Raised, Border3DSide.All);
1698 dc.FillPolygon (SystemBrushes.ControlText, arrow_path);
1702 // draws one day in the calendar grid
1703 private void DrawMonthCalendarDate (Graphics dc, Rectangle rectangle, MonthCalendar mc, DateTime date, DateTime month, int row, int col) {
1704 Color date_color = mc.ForeColor;
1705 Rectangle interior = new Rectangle (rectangle.X, rectangle.Y, Math.Max(rectangle.Width - 1, 0), Math.Max(rectangle.Height - 1, 0));
1707 // find out if we are the lead of the first calendar or the trail of the last calendar
1708 if (date.Year != month.Year || date.Month != month.Month) {
1709 DateTime check_date = month.AddMonths (-1);
1710 // check if it's the month before
1711 if (check_date.Year == date.Year && check_date.Month == date.Month && row == 0 && col == 0) {
1712 date_color = mc.TrailingForeColor;
1714 // check if it's the month after
1715 check_date = month.AddMonths (1);
1716 if (check_date.Year == date.Year && check_date.Month == date.Month && row == mc.CalendarDimensions.Height-1 && col == mc.CalendarDimensions.Width-1) {
1717 date_color = mc.TrailingForeColor;
1723 date_color = mc.ForeColor;
1727 if (date == mc.SelectionStart && date == mc.SelectionEnd) {
1728 // see if the date is in the start of selection
1729 date_color = mc.BackColor;
1730 // draw the left hand of the back ground
1731 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
1732 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 0, 359);
1733 } else if (date == mc.SelectionStart) {
1734 // see if the date is in the start of selection
1735 date_color = mc.BackColor;
1736 // draw the left hand of the back ground
1737 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
1738 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 90, 180);
1739 // fill the other side as a straight rect
1740 if (date < mc.SelectionEnd)
\r
1742 // use rectangle instead of rectangle to go all the way to edge of rect
1743 selection_rect.X = (int) Math.Floor(rectangle.X + rectangle.Width / 2);
1744 selection_rect.Width = Math.Max(rectangle.Right - selection_rect.X, 0);
1745 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
1747 } else if (date == mc.SelectionEnd) {
1748 // see if it is the end of selection
1749 date_color = mc.BackColor;
1750 // draw the left hand of the back ground
1751 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
1752 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 270, 180);
1753 // fill the other side as a straight rect
1754 if (date > mc.SelectionStart) {
1755 selection_rect.X = rectangle.X;
1756 selection_rect.Width = rectangle.Width - (rectangle.Width / 2);
1757 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
1759 } else if (date > mc.SelectionStart && date < mc.SelectionEnd) {
1760 // now see if it's in the middle
1761 date_color = mc.BackColor;
1762 // draw the left hand of the back ground
1763 Rectangle selection_rect = Rectangle.Inflate(rectangle, 0, -3);
1764 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
1767 // set up some standard string formating variables
1768 StringFormat text_format = new StringFormat();
1769 text_format.LineAlignment = StringAlignment.Center;
1770 text_format.Alignment = StringAlignment.Center;
1773 // establish if it's a bolded font
1775 if (mc.IsBoldedDate (date)) {
1776 font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
1781 // just draw the date now
1782 dc.DrawString (date.Day.ToString(), font, ResPool.GetSolidBrush (date_color), rectangle, text_format);
1784 // today circle if needed
1785 if (mc.ShowTodayCircle && date == DateTime.Now.Date) {
1786 DrawTodayCircle (dc, interior);
1789 // draw the selection grid
1790 if (mc.is_date_clicked && mc.clicked_date == date) {
1791 using (Pen pen = new Pen (Color.Black, 1) ) {
1792 pen.DashStyle = DashStyle.Dot;
1793 dc.DrawRectangle (pen, interior);
1798 private void DrawTodayCircle (Graphics dc, Rectangle rectangle) {
1799 Color circle_color = Color.FromArgb (248, 0, 0);
1800 // draw the left hand of the circle
1801 Rectangle lhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 4, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 5, 0));
1802 Rectangle rhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 1, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 2, 0));
1803 Point [] curve_points = new Point [3];
1804 curve_points [0] = new Point (lhs_circle_rect.X, rhs_circle_rect.Y + rhs_circle_rect.Height/12);
1805 curve_points [1] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/9, rhs_circle_rect.Y);
1806 curve_points [2] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/2 + 1, rhs_circle_rect.Y);
1808 using (Pen pen = new Pen (circle_color, 2)) {
1809 dc.DrawArc (pen, lhs_circle_rect, 90, 180);
1810 dc.DrawArc (pen, rhs_circle_rect, 270, 180);
1811 dc.DrawCurve (pen, curve_points);
1812 dc.DrawLine (ResPool.GetPen (circle_color), curve_points [2], new Point (curve_points [2].X, lhs_circle_rect.Y));
1816 #endregion // MonthCalendar
1819 public override Size PanelDefaultSize {
1821 return new Size (200, 100);
1827 public override void DrawPictureBox (Graphics dc, PictureBox pb) {
1828 Rectangle client = pb.ClientRectangle;
1829 int x, y, width, height;
1831 dc.FillRectangle (new SolidBrush (pb.BackColor), client);
1834 if (pb.Image != null) {
1835 switch (pb.SizeMode) {
1836 case PictureBoxSizeMode.StretchImage:
1837 width = client.Width;
1838 height = client.Height;
1840 case PictureBoxSizeMode.CenterImage:
1841 width = client.Width;
1842 height = client.Height;
1844 y = (height - pb.Image.Height) / 2;
1848 width = client.Width;
1849 height = client.Height;
1852 dc.DrawImage (pb.Image, x, y, width, height);
1854 CPDrawBorderStyle (dc, client, pb.BorderStyle);
1857 public override Size PictureBoxDefaultSize {
1859 return new Size (100, 50);
1862 #endregion // PictureBox
1865 public override void DrawProgressBar (Graphics dc, Rectangle clip_rectangle, ProgressBar progress_bar) {
1866 Rectangle client_area = progress_bar.client_area;
1867 Rectangle paint_area = progress_bar.paint_area;
1868 int steps = (progress_bar.Maximum - progress_bar.Minimum) / progress_bar.step;
1869 int space_betweenblocks = 2;
1876 block_width = ((client_area.Height) * 2 ) / 3;
1877 barpos_pixels = ((progress_bar.Value - progress_bar.Minimum) * client_area.Width) / (progress_bar.Maximum - progress_bar.Minimum);
1878 increment = block_width + space_betweenblocks;
1881 CPDrawBorder3D (dc, progress_bar.paint_area, Border3DStyle.SunkenInner, Border3DSide.All, ColorButtonFace);
1884 while ((x - client_area.X) < barpos_pixels) {
1885 dc.FillRectangle (ResPool.GetSolidBrush (progressbarblock_color), x, client_area.Y, block_width, client_area.Height);
1890 public override Size ProgressBarDefaultSize {
1892 return new Size (100, 23);
1896 #endregion // ProgressBar
1899 public override void DrawRadioButton (Graphics dc, Rectangle clip_rectangle, RadioButton radio_button) {
1900 StringFormat text_format;
1901 Rectangle client_rectangle;
1902 Rectangle text_rectangle;
1903 Rectangle radiobutton_rectangle;
1905 int radiobutton_size = 12;
1906 int radiobutton_space = 4;
1908 client_rectangle = radio_button.ClientRectangle;
1909 text_rectangle = client_rectangle;
1910 radiobutton_rectangle = new Rectangle(text_rectangle.X, text_rectangle.Y, radiobutton_size, radiobutton_size);
1912 text_format = new StringFormat();
1913 text_format.Alignment = StringAlignment.Near;
1914 text_format.LineAlignment = StringAlignment.Center;
1916 /* Calculate the position of text and checkbox rectangle */
1917 if (radio_button.appearance!=Appearance.Button) {
1918 switch(radio_button.radiobutton_alignment) {
1919 case ContentAlignment.BottomCenter: {
1920 radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
1921 radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
1922 text_rectangle.X=client_rectangle.X;
1923 text_rectangle.Width=client_rectangle.Width;
1924 text_rectangle.Height=client_rectangle.Height-radiobutton_size-radiobutton_space;
1928 case ContentAlignment.BottomLeft: {
1929 radiobutton_rectangle.X=client_rectangle.Left;
1930 radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
1931 text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
1932 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
1936 case ContentAlignment.BottomRight: {
1937 radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
1938 radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
1939 text_rectangle.X=client_rectangle.X;
1940 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
1944 case ContentAlignment.MiddleCenter: {
1945 radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
1946 radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
1947 text_rectangle.X=client_rectangle.X;
1948 text_rectangle.Width=client_rectangle.Width;
1953 case ContentAlignment.MiddleLeft: {
1954 radiobutton_rectangle.X=client_rectangle.Left;
1955 radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
1956 text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
1957 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
1961 case ContentAlignment.MiddleRight: {
1962 radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
1963 radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
1964 text_rectangle.X=client_rectangle.X;
1965 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
1969 case ContentAlignment.TopCenter: {
1970 radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
1971 radiobutton_rectangle.Y=client_rectangle.Top;
1972 text_rectangle.X=client_rectangle.X;
1973 text_rectangle.Y=radiobutton_size+radiobutton_space;
1974 text_rectangle.Width=client_rectangle.Width;
1975 text_rectangle.Height=client_rectangle.Height-radiobutton_size-radiobutton_space;
1979 case ContentAlignment.TopLeft: {
1980 radiobutton_rectangle.X=client_rectangle.Left;
1981 radiobutton_rectangle.Y=client_rectangle.Top;
1982 text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
1983 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
1987 case ContentAlignment.TopRight: {
1988 radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
1989 radiobutton_rectangle.Y=client_rectangle.Top;
1990 text_rectangle.X=client_rectangle.X;
1991 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
1996 text_rectangle.X=client_rectangle.X;
1997 text_rectangle.Width=client_rectangle.Width;
2000 /* Set the horizontal alignment of our text */
2001 switch(radio_button.text_alignment) {
2002 case ContentAlignment.BottomLeft:
2003 case ContentAlignment.MiddleLeft:
2004 case ContentAlignment.TopLeft: {
2005 text_format.Alignment=StringAlignment.Near;
2009 case ContentAlignment.BottomCenter:
2010 case ContentAlignment.MiddleCenter:
2011 case ContentAlignment.TopCenter: {
2012 text_format.Alignment=StringAlignment.Center;
2016 case ContentAlignment.BottomRight:
2017 case ContentAlignment.MiddleRight:
2018 case ContentAlignment.TopRight: {
2019 text_format.Alignment=StringAlignment.Far;
2024 /* Set the vertical alignment of our text */
2025 switch(radio_button.text_alignment) {
2026 case ContentAlignment.TopLeft:
2027 case ContentAlignment.TopCenter:
2028 case ContentAlignment.TopRight: {
2029 text_format.LineAlignment=StringAlignment.Near;
2033 case ContentAlignment.BottomLeft:
2034 case ContentAlignment.BottomCenter:
2035 case ContentAlignment.BottomRight: {
2036 text_format.LineAlignment=StringAlignment.Far;
2040 case ContentAlignment.MiddleLeft:
2041 case ContentAlignment.MiddleCenter:
2042 case ContentAlignment.MiddleRight: {
2043 text_format.LineAlignment=StringAlignment.Center;
2048 ButtonState state = ButtonState.Normal;
2049 if (radio_button.FlatStyle == FlatStyle.Flat) {
2050 state |= ButtonState.Flat;
2053 if (radio_button.Checked) {
2054 state |= ButtonState.Checked;
2059 sb=new SolidBrush(radio_button.BackColor);
2060 dc.FillRectangle(sb, radio_button.ClientRectangle);
2065 if (radio_button.appearance==Appearance.Button) {
2066 if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
2067 DrawFlatStyleButton(dc, radio_button.ClientRectangle, radio_button);
2069 CPDrawButton(dc, radio_button.ClientRectangle, state);
2072 // establish if we are rendering a flat style of some sort
2073 if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
2074 DrawFlatStyleRadioButton (dc, radiobutton_rectangle, radio_button);
2076 ControlPaint.DrawRadioButton (dc, radiobutton_rectangle, state);
2080 // offset the text if it's pressed and a button
2081 if (radio_button.Appearance == Appearance.Button) {
2082 if (radio_button.Checked || (radio_button.Capture && radio_button.FlatStyle != FlatStyle.Flat)) {
2083 text_rectangle.X ++;
2084 text_rectangle.Y ++;
2087 text_rectangle.Inflate(-4,-4);
2090 /* Place the text; to be compatible with Windows place it after the radiobutton has been drawn */
2091 sb=new SolidBrush(radio_button.ForeColor);
2092 dc.DrawString (radio_button.Text, radio_button.Font, sb, text_rectangle, text_format);
2094 if (radio_button.Enabled) {
2095 sb = ResPool.GetSolidBrush(radio_button.ForeColor);
2096 dc.DrawString(radio_button.Text, radio_button.Font, sb, text_rectangle, text_format);
2097 } else if (radio_button.FlatStyle == FlatStyle.Flat) {
2098 dc.DrawString(radio_button.Text, radio_button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), text_rectangle, text_format);
2100 CPDrawStringDisabled(dc, radio_button.Text, radio_button.Font, this.ColorButtonText, text_rectangle, text_format);
2103 if (radio_button.Focused) {
2104 if (radio_button.FlatStyle != FlatStyle.Flat) {
2105 DrawInnerFocusRectangle (dc, text_rectangle, radio_button.BackColor);
2107 dc.DrawRectangle (ResPool.GetPen (radio_button.ForeColor), text_rectangle);
2112 // renders a radio button with the Flat and Popup FlatStyle
2113 private void DrawFlatStyleRadioButton (Graphics graphics, Rectangle rectangle, RadioButton radio_button)
2117 if (radio_button.Enabled) {
2118 // draw the outer flatstyle arcs
2119 if (radio_button.FlatStyle == FlatStyle.Flat) {
2120 graphics.DrawArc (ResPool.GetPen (radio_button.ForeColor), rectangle, 0, 359);
2122 // fill in the area depending on whether or not the mouse is hovering
2123 if (radio_button.is_entered && radio_button.Capture) {
2124 graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.Light (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
2126 graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
2129 // must be a popup radio button
2131 graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 0, 359);
2133 if (radio_button.is_entered || radio_button.Capture) {
2134 // draw the popup 3d button knob
2135 graphics.DrawArc (ResPool.GetPen (ControlPaint.Light (radio_button.BackColor)), rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 0, 359);
2137 graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (radio_button.BackColor)), rectangle, 135, 180);
2138 graphics.DrawArc (ResPool.GetPen (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 315, 180);
2141 // just draw lighter flatstyle outer circle
2142 graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (this.ColorButtonFace)), rectangle, 0, 359);
2147 // fill control background color regardless of actual backcolor
2148 graphics.FillPie (ResPool.GetSolidBrush (this.ColorButtonFace), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
2149 // draw the ark as control dark
2150 graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark(this.ColorButtonFace)), rectangle, 0, 359);
2154 lineWidth = Math.Max (1, Math.Min(rectangle.Width, rectangle.Height)/3);
2155 if (radio_button.Checked) {
2156 SolidBrush buttonBrush;
2158 if (!radio_button.Enabled) {
2159 buttonBrush = ResPool.GetSolidBrush (ControlPaint.Dark (this.ColorButtonFace));
2160 } else if (radio_button.FlatStyle == FlatStyle.Popup && radio_button.is_entered && radio_button.Capture) {
2161 buttonBrush = ResPool.GetSolidBrush (this.ColorButtonText);
2163 buttonBrush = ResPool.GetSolidBrush (radio_button.ForeColor);
2165 graphics.FillPie (buttonBrush, rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2, 0, 359);
2169 public override Size RadioButtonDefaultSize {
2171 return new Size (104,24);
2174 #endregion // RadioButton
2177 public override void DrawScrollBar(Graphics dc, Rectangle clip_rectangle, ScrollBar bar) {
2178 int scrollbutton_width = bar.scrollbutton_width;
2179 int scrollbutton_height = bar.scrollbutton_height;
2180 Rectangle first_arrow_area;
2181 Rectangle second_arrow_area;
2182 Rectangle thumb_pos;
2184 thumb_pos = bar.ThumbPos;
2187 first_arrow_area = new Rectangle(0, 0, bar.Width, scrollbutton_height);
2188 bar.FirstArrowArea = first_arrow_area;
2190 second_arrow_area = new Rectangle(0, bar.ClientRectangle.Height - scrollbutton_height, bar.Width, scrollbutton_height);
2191 bar.SecondArrowArea = second_arrow_area;
2193 thumb_pos.Width = bar.Width;
2194 bar.ThumbPos = thumb_pos;
2197 CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state);
2198 CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state);
2201 switch (bar.thumb_moving) {
2202 case ScrollBar.ThumbMoving.None: {
2203 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), 0,
2204 scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - (scrollbutton_height * 2));
2208 case ScrollBar.ThumbMoving.Forward: {
2209 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
2210 0, scrollbutton_height,
2211 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height);
2213 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
2214 0, thumb_pos.Y + thumb_pos.Height,
2215 bar.ClientRectangle.Width, bar.ClientRectangle.Height - (thumb_pos.Y + thumb_pos.Height) - scrollbutton_height);
2220 case ScrollBar.ThumbMoving.Backwards: {
2221 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
2222 0, scrollbutton_height,
2223 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height);
2225 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
2226 0, thumb_pos.Y + thumb_pos.Height,
2227 bar.ClientRectangle.Width, bar.ClientRectangle.Height - (thumb_pos.Y + thumb_pos.Height) - scrollbutton_height);
2238 first_arrow_area = new Rectangle(0, 0, scrollbutton_width, bar.Height);
2239 bar.FirstArrowArea = first_arrow_area;
2241 second_arrow_area = new Rectangle (bar.ClientRectangle.Width - scrollbutton_width, 0, scrollbutton_width, bar.Height);
2242 bar.SecondArrowArea = second_arrow_area;
2244 thumb_pos.Height = bar.Height;
2245 bar.ThumbPos = thumb_pos;
2248 CPDrawScrollButton (dc, bar.FirstArrowArea, ScrollButton.Left, bar.firstbutton_state);
2249 CPDrawScrollButton (dc, bar.SecondArrowArea, ScrollButton.Right, bar.secondbutton_state);
2252 switch (bar.thumb_moving) {
2253 case ScrollBar.ThumbMoving.None: {
2254 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), scrollbutton_width,
2255 0, bar.ClientRectangle.Width - (scrollbutton_width * 2), bar.ClientRectangle.Height);
2260 case ScrollBar.ThumbMoving.Forward: {
2261 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
2262 scrollbutton_width, 0,
2263 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height);
2265 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
2266 thumb_pos.X + thumb_pos.Width, 0,
2267 bar.ClientRectangle.Width - (thumb_pos.X + thumb_pos.Width) - scrollbutton_width, bar.ClientRectangle.Height);
2272 case ScrollBar.ThumbMoving.Backwards: {
2273 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
2274 scrollbutton_width, 0,
2275 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height);
2277 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
2278 thumb_pos.X + thumb_pos.Width, 0,
2279 bar.ClientRectangle.Width - (thumb_pos.X + thumb_pos.Width) - scrollbutton_width, bar.ClientRectangle.Height);
2291 if (bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0)
2292 DrawScrollButtonPrimitive (dc, thumb_pos, ButtonState.Normal);
2295 public override int ScrollBarButtonSize {
2298 #endregion // ScrollBar
2301 public override void DrawStatusBar (Graphics dc, Rectangle clip_rectangle, StatusBar sb) {
2302 Rectangle area = sb.paint_area;
2303 int horz_border = 2;
2304 int vert_border = 2;
2306 dc.FillRectangle (GetControlBackBrush (sb.BackColor), area);
2308 if (sb.ShowPanels && sb.Panels.Count == 0) {
2309 // Create a default panel.
2310 SolidBrush br_forecolor = GetControlForeBrush (sb.ForeColor);
2312 StatusBarPanel panel = new StatusBarPanel ();
2313 Rectangle new_area = new Rectangle (area.X + horz_border,
2314 area.Y + horz_border,
2315 area.Width - StatusBarSizeGripWidth - horz_border,
2316 area.Height - horz_border);
2317 DrawStatusBarPanel (dc, new_area, -1, br_forecolor, panel);
2318 } else if (sb.ShowPanels) {
2319 SolidBrush br_forecolor = GetControlForeBrush (sb.ForeColor);
2320 int prev_x = area.X + horz_border;
2321 int y = area.Y + vert_border;
2322 for (int i = 0; i < sb.Panels.Count; i++) {
2323 Rectangle pr = new Rectangle (prev_x, y,
2324 sb.Panels [i].Width, area.Height);
2325 prev_x += pr.Width + StatusBarHorzGapWidth;
2326 DrawStatusBarPanel (dc, pr, i, br_forecolor, sb.Panels [i]);
2331 CPDrawSizeGrip (dc, ColorButtonFace, area);
2336 private void DrawStatusBarPanel (Graphics dc, Rectangle area, int index,
2337 SolidBrush br_forecolor, StatusBarPanel panel) {
2338 int border_size = 3; // this is actually const, even if the border style is none
2340 area.Height -= border_size;
2341 if (panel.BorderStyle != StatusBarPanelBorderStyle.None) {
2342 Border3DStyle border_style = Border3DStyle.SunkenInner;
2343 if (panel.BorderStyle == StatusBarPanelBorderStyle.Raised)
2344 border_style = Border3DStyle.RaisedOuter;
2345 CPDrawBorder3D(dc, area, border_style, Border3DSide.All, ColorButtonFace);
2348 if (panel.Style == StatusBarPanelStyle.OwnerDraw) {
2349 StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs (
2350 dc, panel.Parent.Font, area, index, DrawItemState.Default,
2351 panel, panel.Parent.ForeColor, panel.Parent.BackColor);
2352 panel.Parent.OnDrawItemInternal (e);
2356 int left = area.Left;
2357 if (panel.Icon != null) {
2359 int size = area.Height - border_size;
2360 Rectangle ia = new Rectangle (left, border_size, size, size);
2361 dc.DrawIcon (panel.Icon, left, area.Top);
2362 left += panel.Icon.Width;
2365 if (panel.Text == String.Empty)
2368 string text = panel.Text;
2369 StringFormat string_format = new StringFormat ();
2370 string_format.LineAlignment = StringAlignment.Center;
2371 string_format.Alignment = StringAlignment.Near;
2372 string_format.FormatFlags = StringFormatFlags.NoWrap;
2374 if (text [0] == '\t') {
2375 string_format.Alignment = StringAlignment.Center;
2376 text = text.Substring (1);
2377 if (text [0] == '\t') {
2378 string_format.Alignment = StringAlignment.Far;
2379 text = text.Substring (1);
2383 float x = left + border_size;
2384 float y = ((area.Bottom - area.Top) / 2.0F) + border_size;
2386 dc.DrawString (text, panel.Parent.Font, br_forecolor, x, y, string_format);
2389 public override int StatusBarSizeGripWidth {
2393 public override int StatusBarHorzGapWidth {
2397 public override Size StatusBarDefaultSize {
2399 return new Size (100, 22);
2402 #endregion // StatusBar
2404 public override void DrawTabControl (Graphics dc, Rectangle area, TabControl tab)
2406 // Do we need to fill the back color? It can't be changed...
2407 dc.FillRectangle (GetControlBackBrush (tab.BackColor), area);
2408 Rectangle panel_rect = GetTabPanelRectExt (tab);
2410 if (tab.Appearance == TabAppearance.Normal) {
2411 CPDrawBorder3D (dc, panel_rect, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, ColorButtonFace);
2412 CPDrawBorder3D (dc, panel_rect, Border3DStyle.Raised, Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
2415 if (tab.Alignment == TabAlignment.Top) {
2416 for (int r = tab.TabPages.Count; r > 0; r--) {
2417 for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
2418 if (i == tab.SelectedIndex)
2420 if (r != tab.TabPages [i].Row)
2422 Rectangle rect = tab.GetTabRect (i);
2423 if (!rect.IntersectsWith (area))
2425 DrawTab (dc, tab.TabPages [i], tab, rect, false);
2429 for (int r = 0; r < tab.TabPages.Count; r++) {
2430 for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
2431 if (i == tab.SelectedIndex)
2433 if (r != tab.TabPages [i].Row)
2435 Rectangle rect = tab.GetTabRect (i);
2436 if (!rect.IntersectsWith (area))
2438 DrawTab (dc, tab.TabPages [i], tab, rect, false);
2443 if (tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos) {
2444 Rectangle rect = tab.GetTabRect (tab.SelectedIndex);
2445 if (rect.IntersectsWith (area))
2446 DrawTab (dc, tab.TabPages [tab.SelectedIndex], tab, rect, true);
2449 if (tab.ShowSlider) {
2450 Rectangle right = GetTabControlRightScrollRect (tab);
2451 Rectangle left = GetTabControlLeftScrollRect (tab);
2452 CPDrawScrollButton (dc, right, ScrollButton.Right, tab.RightSliderState);
2453 CPDrawScrollButton (dc, left, ScrollButton.Left, tab.LeftSliderState);
2457 public override Rectangle GetTabControlLeftScrollRect (TabControl tab)
2459 switch (tab.Alignment) {
2460 case TabAlignment.Top:
2461 return new Rectangle (tab.ClientRectangle.Right - 34, tab.ClientRectangle.Top + 1, 17, 17);
2463 Rectangle panel_rect = GetTabPanelRectExt (tab);
2464 return new Rectangle (tab.ClientRectangle.Right - 34, panel_rect.Bottom + 2, 17, 17);
2468 public override Rectangle GetTabControlRightScrollRect (TabControl tab)
2470 switch (tab.Alignment) {
2471 case TabAlignment.Top:
2472 return new Rectangle (tab.ClientRectangle.Right - 17, tab.ClientRectangle.Top + 1, 17, 17);
2474 Rectangle panel_rect = GetTabPanelRectExt (tab);
2475 return new Rectangle (tab.ClientRectangle.Right - 17, panel_rect.Bottom + 2, 17, 17);
2479 public override Size TabControlDefaultItemSize {
2480 get { return new Size (42, 21); }
2483 public override Point TabControlDefaultPadding {
2484 get { return new Point (6, 3); }
2487 public override int TabControlMinimumTabWidth {
2491 public override Rectangle GetTabControlDisplayRectangle (TabControl tab)
2493 Rectangle ext = GetTabPanelRectExt (tab);
2494 // Account for border size
2495 return new Rectangle (ext.Left + 2, ext.Top + 1, ext.Width - 6, ext.Height - 4);
2498 public override Size TabControlGetSpacing (TabControl tab) {
2499 switch (tab.Appearance) {
2500 case TabAppearance.Normal:
2501 return new Size (1, -2);
2502 case TabAppearance.Buttons:
2503 return new Size (3, 3);
2504 case TabAppearance.FlatButtons:
2505 return new Size (9, 3);
2507 throw new Exception ("Invalid Appearance value: " + tab.Appearance);
2511 private Rectangle GetTabPanelRectExt (TabControl tab)
2513 // Offset the tab from the top corner
2514 Rectangle res = new Rectangle (tab.ClientRectangle.X + 2,
2515 tab.ClientRectangle.Y,
2516 tab.ClientRectangle.Width - 2,
2517 tab.ClientRectangle.Height - 1);
2519 if (tab.TabCount == 0)
2522 int spacing = TabControlGetSpacing (tab).Height;
2523 int offset = (tab.ItemSize.Height + spacing) * tab.RowCount + 3;
2525 switch (tab.Alignment) {
2526 case TabAlignment.Left:
2528 res.Width -= offset;
2530 case TabAlignment.Right:
2531 res.Width -= offset;
2533 case TabAlignment.Top:
2535 res.Height -= offset;
2537 case TabAlignment.Bottom:
2538 res.Height -= offset;
2545 private int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
2547 int FlatButtonSpacing = 8;
2549 int res = bounds.Width;
2551 // we can't fill the background right away because the bounds might be adjusted if the tab is selected
2553 if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) {
2555 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
2558 if (tab.Appearance == TabAppearance.FlatButtons) {
2559 int width = bounds.Width;
2560 bounds.Width += (FlatButtonSpacing - 2);
2562 CPDrawBorder3D (dc, bounds, Border3DStyle.Etched, Border3DSide.Right);
2563 bounds.Width = width;
2567 CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.All);
2568 } else if (tab.Appearance != TabAppearance.FlatButtons) {
2569 CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.All);
2572 interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4);
2574 Pen light = ResPool.GetPen (ControlPaint.LightLight (tab.BackColor));
2576 switch (tab.Alignment) {
2578 case TabAlignment.Top:
2581 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
2583 dc.DrawLine (light, bounds.Left, bounds.Bottom, bounds.Left, bounds.Top + 3);
2584 dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
2585 dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right - 3, bounds.Top);
2587 dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom);
2588 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 1, bounds.Top + 2, bounds.Right, bounds.Top + 3);
2589 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom);
2591 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
2593 if (page.Text != String.Empty) {
2594 StringFormat string_format = new StringFormat ();
2595 string_format.Alignment = StringAlignment.Center;
2596 string_format.LineAlignment = StringAlignment.Center;
2597 string_format.FormatFlags = StringFormatFlags.NoWrap;
2599 dc.DrawString (page.Text, page.Font, new SolidBrush (SystemColors.ControlText), interior, string_format);
2604 case TabAlignment.Bottom:
2606 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
2608 dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 3);
2609 dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left + 2, bounds.Bottom - 1);
2611 dc.DrawLine (SystemPens.ControlDark, bounds.Left + 3, bounds.Bottom - 1, bounds.Right - 3, bounds.Bottom - 1);
2612 dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Bottom - 3, bounds.Right - 1, bounds.Top);
2614 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
2615 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 3, bounds.Bottom, bounds.Right, bounds.Bottom - 3);
2616 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom - 3, bounds.Right, bounds.Top);
2618 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
2620 if (page.Text != String.Empty) {
2621 StringFormat string_format = new StringFormat ();
2622 string_format.Alignment = StringAlignment.Center;
2623 string_format.LineAlignment = StringAlignment.Center;
2624 string_format.FormatFlags = StringFormatFlags.NoWrap;
2626 dc.DrawString (page.Text, page.Font, new SolidBrush (SystemColors.ControlText), interior, string_format);
2631 case TabAlignment.Left:
2633 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
2635 dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left, bounds.Top + 3);
2636 dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
2637 dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right, bounds.Top);
2639 dc.DrawLine (SystemPens.ControlDark, bounds.Right, bounds.Bottom - 1, bounds.Left + 2, bounds.Bottom - 1);
2641 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom, bounds.Left + 2, bounds.Bottom);
2642 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 2, bounds.Bottom, bounds.Left, bounds.Bottom - 3);
2644 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
2646 if (page.Text != String.Empty) {
2647 StringFormat string_format = new StringFormat ();
2648 // Flip the text around
2649 string_format.Alignment = StringAlignment.Center;
2650 string_format.LineAlignment = StringAlignment.Center;
2651 string_format.FormatFlags = StringFormatFlags.NoWrap;
2652 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
2653 int wo = interior.Width / 2;
2654 int ho = interior.Height / 2;
2655 dc.TranslateTransform (interior.X + wo, interior.Y + ho);
2656 dc.RotateTransform (180);
2657 dc.DrawString (page.Text, page.Font, new SolidBrush (SystemColors.ControlText), 0, 0, string_format);
2658 dc.ResetTransform ();
2664 // TabAlignment.Right
2666 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
2668 dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Right - 3, bounds.Top);
2669 dc.DrawLine (light, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3);
2671 dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom - 1);
2672 dc.DrawLine (SystemPens.ControlDark, bounds.Left, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1);
2674 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom - 3);
2675 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
2677 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
2679 if (page.Text != String.Empty) {
2680 StringFormat string_format = new StringFormat ();
2681 string_format.Alignment = StringAlignment.Center;
2682 string_format.LineAlignment = StringAlignment.Center;
2683 string_format.FormatFlags = StringFormatFlags.NoWrap;
2684 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
2686 dc.DrawString (page.Text, page.Font, new SolidBrush (SystemColors.ControlText), interior, string_format);
2695 using (Pen pen = new Pen (Color.Black, 1) ) {
2696 pen.DashStyle = DashStyle.Dot;
2697 dc.DrawRectangle (pen, interior);
2705 public override void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control) {
2706 StringFormat format = new StringFormat ();
2707 format.Trimming = StringTrimming.EllipsisWord;
2708 if (control.textAlignment == ToolBarTextAlign.Underneath) {
2709 format.LineAlignment = StringAlignment.Center;
2710 format.Alignment = StringAlignment.Center;
2712 format.LineAlignment = StringAlignment.Center;
2713 format.Alignment = StringAlignment.Near;
2716 // Exclude the area for divider
2717 Rectangle paint_area = new Rectangle (0, ToolBarGripWidth / 2,
2718 control.Width, control.Height - ToolBarGripWidth / 2);
2719 bool flat = (control.Appearance == ToolBarAppearance.Flat);
2720 dc.FillRectangle (SystemBrushes.Control, paint_area);
2721 CPDrawBorderStyle (dc, paint_area, control.BorderStyle);
2723 if (control.Divider)
2724 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), 0, 0, paint_area.Width, 0);
2726 foreach (ToolBarButton button in control.Buttons) {
2729 Rectangle buttonArea = button.Rectangle;
2730 Rectangle imgRect = Rectangle.Empty; // rect to draw the image
2731 Rectangle txtRect = buttonArea; // rect to draw the text
2732 Rectangle ddRect = Rectangle.Empty; // rect for the drop down arrow
2734 // calculate different rects and draw the frame if its not separator button
2735 if (button.Style != ToolBarButtonStyle.Separator) {
2736 /* Adjustment for drop down arrow */
2737 if (button.Style == ToolBarButtonStyle.DropDownButton && control.DropDownArrows) {
2738 ddRect.X = buttonArea.X + buttonArea.Width - this.ToolBarDropDownWidth;
2739 ddRect.Y = buttonArea.Y;
2740 ddRect.Width = this.ToolBarDropDownWidth;
2741 ddRect.Height = buttonArea.Height;
2744 // calculate txtRect and imgRect, if imageIndex and imageList are present
2745 if (button.ImageIndex > -1 && control.ImageList != null) {
2746 if (button.ImageIndex < control.ImageList.Images.Count)
2747 image = control.ImageList.Images [button.ImageIndex];
2748 // draw the image at the centre if textalignment is underneath
2749 if (control.TextAlign == ToolBarTextAlign.Underneath) {
2750 imgRect.X = buttonArea.X + ((buttonArea.Width - ddRect.Width
2751 - control.ImageSize.Width) / 2)
2752 + this.ToolBarImageGripWidth;
2753 imgRect.Y = buttonArea.Y + this.ToolBarImageGripWidth;
2754 imgRect.Width = control.ImageSize.Width;
2755 imgRect.Height = control.ImageSize.Height;
2757 txtRect.X = buttonArea.X;
2758 txtRect.Y = buttonArea.Y + imgRect.Height + 2 * this.ToolBarImageGripWidth;
2759 txtRect.Width = buttonArea.Width - ddRect.Width;
2760 txtRect.Height = buttonArea.Height - imgRect.Height
2761 - 2 * this.ToolBarImageGripWidth;
2764 imgRect.X = buttonArea.X + this.ToolBarImageGripWidth;
2765 imgRect.Y = buttonArea.Y + this.ToolBarImageGripWidth;
2766 imgRect.Width = control.ImageSize.Width;
2767 imgRect.Height = control.ImageSize.Height;
2769 txtRect.X = buttonArea.X + imgRect.Width + 2 * this.ToolBarImageGripWidth;
2770 txtRect.Y = buttonArea.Y;
2771 txtRect.Width = buttonArea.Width - imgRect.Width
2772 - 2 * this.ToolBarImageGripWidth - ddRect.Width;
2773 txtRect.Height = buttonArea.Height;
2776 /* Draw the button frame, only if it is not a separator */
2778 if (button.Pushed || button.Pressed) {
2779 CPDrawBorder3D (dc, buttonArea, Border3DStyle.SunkenOuter, Border3DSide.All, ColorButtonFace);
2780 } else if (button.Hilight) {
2781 dc.DrawRectangle (ResPool.GetPen (ColorButtonText), buttonArea);
2782 if (! ddRect.IsEmpty) {
2783 dc.DrawLine (ResPool.GetPen (ColorButtonText), ddRect.X, ddRect.Y, ddRect.X,
2784 ddRect.Y + ddRect.Height);
2785 buttonArea.Width -= this.ToolBarDropDownWidth;
2789 else { // normal toolbar
2790 if (button.Pushed || button.Pressed) {
2791 CPDrawBorder3D (dc, buttonArea, Border3DStyle.SunkenInner,
2792 Border3DSide.All, ColorButtonFace);
2793 if (! ddRect.IsEmpty) {
2794 CPDrawBorder3D (dc, ddRect, Border3DStyle.SunkenInner,
2795 Border3DSide.Left, ColorButtonFace);
2796 buttonArea.Width -= this.ToolBarDropDownWidth;
2800 CPDrawBorder3D (dc, buttonArea, Border3DStyle.RaisedInner,
2801 Border3DSide.All, ColorButtonFace);
2802 if (! ddRect.IsEmpty) {
2803 CPDrawBorder3D (dc, ddRect, Border3DStyle.RaisedInner,
2804 Border3DSide.Left, ColorButtonFace);
2805 buttonArea.Width -= this.ToolBarDropDownWidth;
2810 DrawToolBarButton (dc, button, control.Font, format, paint_area, buttonArea,
2811 imgRect, image, txtRect, ddRect, flat);
2815 private void DrawToolBarButton (Graphics dc, ToolBarButton button, Font font, StringFormat format,
2816 Rectangle controlArea, Rectangle buttonArea, Rectangle imgRect,
2817 Image image, Rectangle txtRect, Rectangle ddRect, bool flat) {
2818 if (! button.Visible)
2821 switch (button.Style) {
2823 case ToolBarButtonStyle.Separator:
2824 // separator is drawn only in the case of flat appearance
2826 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), buttonArea.X + 1, buttonArea.Y,
2827 buttonArea.X + 1, buttonArea.Height);
2828 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), buttonArea.X + 1 + (int) ResPool.GetPen (ColorButtonFace).Width,
2829 buttonArea.Y, buttonArea.X + 1 + (int) ResPool.GetPen (ColorButtonFace).Width, buttonArea.Height);
2830 /* draw a horizontal separator */
2831 if (button.Wrapper) {
2832 int y = buttonArea.Height + this.ToolBarSeparatorWidth / 2;
2833 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), 0, y, controlArea.Width, y);
2834 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), 0, y + 1 + (int) ResPool.GetPen (ColorButtonFace).Width, controlArea.Width,
2835 y + 1 + (int) ResPool.GetPen (ColorButtonFace).Width);
2840 case ToolBarButtonStyle.ToggleButton:
2841 Rectangle toggleArea = Rectangle.Empty;
2842 toggleArea.X = buttonArea.X + this.ToolBarImageGripWidth;
2843 toggleArea.Y = buttonArea.Y + this.ToolBarImageGripWidth;
2844 toggleArea.Width = buttonArea.Width - 2 * this.ToolBarImageGripWidth;
2845 toggleArea.Height = buttonArea.Height - 2 * this.ToolBarImageGripWidth;
2846 if (button.PartialPush && button.Pushed) {
2847 dc.FillRectangle (SystemBrushes.ControlLightLight, toggleArea);
2848 if (! imgRect.IsEmpty) {
2849 if (button.Enabled && image != null)
2850 button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
2851 imgRect.Height, button.ImageIndex);
2853 dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
2854 ControlPaint.DrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
2855 Border3DSide.Right | Border3DSide.Bottom);
2859 dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
2861 CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight, txtRect, format);
2864 else if (button.PartialPush) {
2865 dc.FillRectangle (SystemBrushes.ControlLight, toggleArea);
2866 if (! imgRect.IsEmpty) {
2867 if (button.Enabled && image != null)
2868 button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
2869 imgRect.Height, button.ImageIndex);
2871 dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
2872 ControlPaint.DrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
2873 Border3DSide.Right | Border3DSide.Bottom);
2877 dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
2879 CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight,
2883 else if (button.Pushed) {
2884 dc.FillRectangle (SystemBrushes.ControlLightLight, toggleArea);
2885 if (! imgRect.IsEmpty) {
2886 if (button.Enabled && image != null)
2887 button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
2888 imgRect.Height, button.ImageIndex);
2890 dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
2891 CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
2892 Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
2896 dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
2898 CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight,
2903 dc.FillRectangle (SystemBrushes.Control, toggleArea);
2904 if (! imgRect.IsEmpty) {
2905 if (button.Enabled && image != null)
2906 button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
2907 imgRect.Height, button.ImageIndex);
2909 dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
2910 CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
2911 Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
2915 dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
2917 CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight,
2922 case ToolBarButtonStyle.DropDownButton:
2923 // draw the dropdown arrow
2924 if (! ddRect.IsEmpty) {
2925 PointF [] vertices = new PointF [3];
2926 PointF ddCenter = new PointF (ddRect.X + (ddRect.Width/2.0f), ddRect.Y + (ddRect.Height/2.0f));
2927 vertices [0].X = ddCenter.X - this.ToolBarDropDownArrowWidth / 2.0f + 0.5f;
2928 vertices [0].Y = ddCenter.Y;
2929 vertices [1].X = ddCenter.X + this.ToolBarDropDownArrowWidth / 2.0f + 0.5f;
2930 vertices [1].Y = ddCenter.Y;
2931 vertices [2].X = ddCenter.X + 0.5f; // 0.5 is added for adjustment
2932 vertices [2].Y = ddCenter.Y + this.ToolBarDropDownArrowHeight;
2933 dc.FillPolygon (SystemBrushes.ControlText, vertices);
2935 goto case ToolBarButtonStyle.PushButton;
2937 case ToolBarButtonStyle.PushButton:
2938 if (! imgRect.IsEmpty){
2939 if (button.Enabled && image != null)
2940 button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width, imgRect.Height,
2943 dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
2944 CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
2945 Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
2949 dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
2951 CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight,
2957 // Grip width for the ToolBar
2958 public override int ToolBarGripWidth {
2962 // Grip width for the Image on the ToolBarButton
2963 public override int ToolBarImageGripWidth {
2967 // width of the separator
2968 public override int ToolBarSeparatorWidth {
2972 // width of the dropdown arrow rect
2973 public override int ToolBarDropDownWidth {
2977 // width for the dropdown arrow on the ToolBarButton
2978 public override int ToolBarDropDownArrowWidth {
2982 // height for the dropdown arrow on the ToolBarButton
2983 public override int ToolBarDropDownArrowHeight {
2987 public override Size ToolBarDefaultSize {
2989 return new Size (100, 42);
2992 #endregion // ToolBar
2995 public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip tt) {
2998 control = tt.tooltip_window;
2999 dc.FillRectangle(ResPool.GetSolidBrush(this.ColorInfoWindow), control.client_rect);
3000 dc.DrawRectangle(ResPool.GetPen(this.ColorWindowFrame), 0, 0, control.Width-1, control.Height-1);
3001 dc.DrawString(control.text, control.Font, ResPool.GetSolidBrush(this.ColorInfoText), control.client_rect, tt.tooltip_window.string_format);
3004 public override Size ToolTipSize(ToolTip tt, string text) {
3007 sizef = tt.tooltip_window.DeviceContext.MeasureString(text, tt.tooltip_window.Font);
3008 return new Size((int)sizef.Width+2, (int)sizef.Height+3); // Need space for the border
3010 #endregion // ToolTip
3013 private void DrawTrackBar_Vertical (Graphics dc, Rectangle area, TrackBar tb,
3014 ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
3015 float ticks, int value_pos, bool mouse_value) {
3017 Point toptick_startpoint = new Point ();
3018 Point bottomtick_startpoint = new Point ();
3019 Point channel_startpoint = new Point ();
3021 float pixels_betweenticks;
3022 const int space_from_right = 8;
3023 const int space_from_left = 8;
3025 switch (tb.TickStyle) {
3026 case TickStyle.BottomRight:
3027 case TickStyle.None:
3028 channel_startpoint.Y = 8;
3029 channel_startpoint.X = 9;
3030 bottomtick_startpoint.Y = 13;
3031 bottomtick_startpoint.X = 24;
3033 case TickStyle.TopLeft:
3034 channel_startpoint.Y = 8;
3035 channel_startpoint.X = 19;
3036 toptick_startpoint.Y = 13;
3037 toptick_startpoint.X = 8;
3039 case TickStyle.Both:
3040 channel_startpoint.Y = 8;
3041 channel_startpoint.X = 18;
3042 bottomtick_startpoint.Y = 13;
3043 bottomtick_startpoint.X = 32;
3044 toptick_startpoint.Y = 13;
3045 toptick_startpoint.X = 8;
3051 thumb_area.X = area.X + channel_startpoint.X;
3052 thumb_area.Y = area.Y + channel_startpoint.Y;
3053 thumb_area.Height = area.Height - space_from_right - space_from_left;
3054 thumb_area.Width = 4;
3057 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonShadow), channel_startpoint.X, channel_startpoint.Y,
3058 1, thumb_area.Height);
3060 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonDkShadow), channel_startpoint.X + 1, channel_startpoint.Y,
3061 1, thumb_area.Height);
3063 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonHilight), channel_startpoint.X + 3, channel_startpoint.Y,
3064 1, thumb_area.Height);
3066 pixel_len = thumb_area.Height - 11;
3067 pixels_betweenticks = pixel_len / (tb.Maximum - tb.Minimum);
3069 /* Convert thumb position from mouse position to value*/
3072 if (value_pos >= channel_startpoint.Y)
3073 value_pos = (int)(((float) (value_pos - channel_startpoint.Y)) / pixels_betweenticks);
3077 if (value_pos + tb.Minimum > tb.Maximum)
3078 value_pos = tb.Maximum - tb.Minimum;
3080 tb.Value = value_pos + tb.Minimum;
3083 thumb_pos.Y = channel_startpoint.Y + (int) (pixels_betweenticks * (float) value_pos);
3085 /* Draw thumb fixed 10x22 size */
3086 thumb_pos.Width = 10;
3087 thumb_pos.Height = 22;
3089 switch (tb.TickStyle) {
3090 case TickStyle.BottomRight:
3091 case TickStyle.None: {
3092 thumb_pos.X = channel_startpoint.X - 8;
3094 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X , thumb_pos.Y + 10);
3095 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 16, thumb_pos.Y);
3096 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X + 16, thumb_pos.Y, thumb_pos.X + 16 + 4, thumb_pos.Y + 4);
3098 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X +1, thumb_pos.Y + 9, thumb_pos.X +15, thumb_pos.Y +9);
3099 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 16, thumb_pos.Y + 9, thumb_pos.X +16 + 4, thumb_pos.Y +9 - 4);
3101 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X +16, thumb_pos.Y +10);
3102 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 16, thumb_pos.Y + 10, thumb_pos.X +16 + 5, thumb_pos.Y +10 - 5);
3104 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 16, 8);
3105 dc.FillRectangle (br_thumb, thumb_pos.X + 17, thumb_pos.Y + 2, 1, 6);
3106 dc.FillRectangle (br_thumb, thumb_pos.X + 18, thumb_pos.Y + 3, 1, 4);
3107 dc.FillRectangle (br_thumb, thumb_pos.X + 19, thumb_pos.Y + 4, 1, 2);
3111 case TickStyle.TopLeft: {
3112 thumb_pos.X = channel_startpoint.X - 10;
3114 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X + 4 + 16, thumb_pos.Y);
3115 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 4);
3117 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X + 4 + 16 , thumb_pos.Y+ 9);
3118 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X, thumb_pos.Y + 5);
3119 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 19, thumb_pos.Y + 9, thumb_pos.X +19 , thumb_pos.Y+ 1);
3121 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 4, thumb_pos.Y+ 10, thumb_pos.X + 4 + 16, thumb_pos.Y+ 10);
3122 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 4, thumb_pos.Y + 10, thumb_pos.X -1, thumb_pos.Y+ 5);
3123 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X+ 20, thumb_pos.Y + 10);
3125 dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 15, 8);
3126 dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 1, 6);
3127 dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 1, 4);
3128 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 1, 2);
3133 case TickStyle.Both: {
3134 thumb_pos.X = area.X + 10;
3135 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 9);
3136 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 19, thumb_pos.Y);
3138 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 1, thumb_pos.Y + 9, thumb_pos.X+ 19, thumb_pos.Y + 9);
3139 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 10, thumb_pos.Y+ 1, thumb_pos.X + 19, thumb_pos.Y + 8);
3141 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X+ 20, thumb_pos.Y +10);
3142 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X + 20, thumb_pos.Y+ 9);
3144 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 18, 8);
3153 pixel_len = thumb_area.Height - 11;
3154 pixels_betweenticks = pixel_len / ticks;
3157 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
3158 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
3160 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
3161 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
3162 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
3163 area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc);
3165 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
3166 area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc);
3170 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
3171 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
3173 pixel_len = thumb_area.Height - 11;
3174 pixels_betweenticks = pixel_len / ticks;
3176 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
3177 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
3178 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
3179 area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
3181 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
3182 area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
3190 Does not matter the size of the control, Win32 always draws:
3191 - Ticks starting from pixel 13, 8
3192 - Channel starting at pos 8, 19 and ends at Width - 8
3193 - Autosize makes always the control 40 pixels height
3194 - Ticks are draw at (channel.Witdh - 10) / (Maximum - Minimum)
3197 private void DrawTrackBar_Horizontal (Graphics dc, Rectangle area, TrackBar tb,
3198 ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
3199 float ticks, int value_pos, bool mouse_value) {
3200 Point toptick_startpoint = new Point ();
3201 Point bottomtick_startpoint = new Point ();
3202 Point channel_startpoint = new Point ();
3204 float pixels_betweenticks;
3205 const int space_from_right = 8;
3206 const int space_from_left = 8;
3208 switch (tb.TickStyle) {
3209 case TickStyle.BottomRight:
3210 case TickStyle.None:
3211 channel_startpoint.X = 8;
3212 channel_startpoint.Y = 9;
3213 bottomtick_startpoint.X = 13;
3214 bottomtick_startpoint.Y = 24;
3216 case TickStyle.TopLeft:
3217 channel_startpoint.X = 8;
3218 channel_startpoint.Y = 19;
3219 toptick_startpoint.X = 13;
3220 toptick_startpoint.Y = 8;
3222 case TickStyle.Both:
3223 channel_startpoint.X = 8;
3224 channel_startpoint.Y = 18;
3225 bottomtick_startpoint.X = 13;
3226 bottomtick_startpoint.Y = 32;
3227 toptick_startpoint.X = 13;
3228 toptick_startpoint.Y = 8;
3234 thumb_area.X = area.X + channel_startpoint.X;
3235 thumb_area.Y = area.Y + channel_startpoint.Y;
3236 thumb_area.Width = area.Width - space_from_right - space_from_left;
3237 thumb_area.Height = 4;
3240 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonShadow), channel_startpoint.X, channel_startpoint.Y,
3241 thumb_area.Width, 1);
3243 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonDkShadow), channel_startpoint.X, channel_startpoint.Y + 1,
3244 thumb_area.Width, 1);
3246 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonHilight), channel_startpoint.X, channel_startpoint.Y +3,
3247 thumb_area.Width, 1);
3249 pixel_len = thumb_area.Width - 11;
3250 pixels_betweenticks = pixel_len / (tb.Maximum - tb.Minimum);
3252 /* Convert thumb position from mouse position to value*/
3254 if (value_pos >= channel_startpoint.X)
3255 value_pos = (int)(((float) (value_pos - channel_startpoint.X)) / pixels_betweenticks);
3259 if (value_pos + tb.Minimum > tb.Maximum)
3260 value_pos = tb.Maximum - tb.Minimum;
3262 tb.Value = value_pos + tb.Minimum;
3265 thumb_pos.X = channel_startpoint.X + (int) (pixels_betweenticks * (float) value_pos);
3267 /* Draw thumb fixed 10x22 size */
3268 thumb_pos.Width = 10;
3269 thumb_pos.Height = 22;
3271 switch (tb.TickStyle) {
3272 case TickStyle.BottomRight:
3273 case TickStyle.None: {
3274 thumb_pos.Y = channel_startpoint.Y - 8;
3276 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y);
3277 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 16);
3278 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y + 16, thumb_pos.X + 4, thumb_pos.Y + 16 + 4);
3280 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X +9, thumb_pos.Y +15);
3281 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 16, thumb_pos.X +9 - 4, thumb_pos.Y +16 + 4);
3283 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y +16);
3284 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y + 16, thumb_pos.X +10 - 5, thumb_pos.Y +16 + 5);
3286 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 16);
3287 dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 17, 6, 1);
3288 dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 18, 4, 1);
3289 dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 19, 2, 1);
3292 case TickStyle.TopLeft: {
3293 thumb_pos.Y = channel_startpoint.Y - 10;
3295 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X, thumb_pos.Y + 4 + 16);
3296 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X + 4, thumb_pos.Y);
3298 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 9, thumb_pos.Y + 4 + 16);
3299 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y);
3300 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 19, thumb_pos.X + 1 , thumb_pos.Y +19);
3302 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 10, thumb_pos.Y + 4 + 16);
3303 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y -1);
3304 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 10, thumb_pos.Y + 20);
3306 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 8, 15);
3307 dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 6, 1);
3308 dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 4, 1);
3309 dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 2, 1);
3313 case TickStyle.Both: {
3314 thumb_pos.Y = area.Y + 10;
3315 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 9, thumb_pos.Y);
3316 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 19);
3318 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 19);
3319 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 1, thumb_pos.Y + 10, thumb_pos.X + 8, thumb_pos.Y + 19);
3321 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y + 20);
3322 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 9, thumb_pos.Y + 20);
3324 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 18);
3333 pixel_len = thumb_area.Width - 11;
3334 pixels_betweenticks = pixel_len / ticks;
3337 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
3338 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
3340 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
3341 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
3342 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
3343 area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3);
3345 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
3346 area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2);
3350 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
3351 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
3353 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
3354 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
3355 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
3356 area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y);
3358 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
3359 area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
3364 public override void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb) {
3365 //public override void DrawTrackBar (Graphics dc,
3368 //ref Rectangle thumb_pos,
3369 //ref Rectangle thumb_area,
3373 float ticks = (tb.Maximum - tb.Minimum) / tb.tickFrequency; /* N of ticks draw*/
3375 Rectangle thumb_pos = tb.ThumbPos;
3376 Rectangle thumb_area = tb.ThumbArea;
3378 if (tb.thumb_pressed) {
3379 value_pos = tb.thumb_mouseclick;
3382 value_pos = tb.Value - tb.Minimum;
3383 mouse_value = false;
3386 area = tb.paint_area;
3388 if (tb.thumb_pressed == true) {
3389 br_thumb = (Brush) ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace);
3391 br_thumb = ResPool.GetSolidBrush (ColorButtonFace);
3395 /* Control Background */
3396 if (tb.BackColor == DefaultControlBackColor) {
3397 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area);
3399 dc.FillRectangle (ResPool.GetSolidBrush (tb.BackColor), area);
3404 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonFace, Color.Black), area.X, area.Y, area.Width - 1, 1);
3405 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonFace, Color.Black), area.X, area.Y + area.Height - 1, area.Width - 1, 1);
3406 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonFace, Color.Black), area.X, area.Y, 1, area.Height - 1);
3407 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonFace, Color.Black), area.X + area.Width - 1, area.Y, 1, area.Height - 1);
3410 if (tb.Orientation == Orientation.Vertical) {
3411 DrawTrackBar_Vertical (dc, area, tb, ref thumb_pos, ref thumb_area,
3412 br_thumb, ticks, value_pos, mouse_value);
3415 DrawTrackBar_Horizontal (dc, area, tb, ref thumb_pos, ref thumb_area,
3416 br_thumb, ticks, value_pos, mouse_value);
3419 tb.ThumbPos = thumb_pos;
3420 tb.ThumbArea = thumb_area;
3423 public override Size TrackBarDefaultSize {
3425 return new Size (104, 42);
3429 #endregion // TrackBar
3432 public override Size VScrollBarDefaultSize {
3434 return new Size (this.ScrollBarButtonSize, 80);
3437 #endregion // VScrollBar
3440 public override Size TreeViewDefaultSize {
\r
3442 return new Size (121, 97);
\r
3448 #region ControlPaint
3449 private enum DrawFrameControlStates {
3450 ButtonCheck = 0x0000,
3451 ButtonRadioImage = 0x0001,
3452 ButtonRadioMask = 0x0002,
3453 ButtonRadio = 0x0004,
3454 Button3State = 0x0008,
3455 ButtonPush = 0x0010,
3457 CaptionClose = 0x0000,
3458 CaptionMin = 0x0001,
3459 CaptionMax = 0x0002,
3460 CaptionRestore = 0x0004,
3461 CaptionHelp = 0x0008,
3465 MenuBullet = 0x0002,
3466 MenuArrowRight = 0x0004,
3469 ScrollDown = 0x0001,
3470 ScrollLeft = 0x0002,
3471 ScrollRight = 0x0003,
3472 ScrollComboBox = 0x0005,
3473 ScrollSizeGrip = 0x0008,
3474 ScrollSizeGripRight = 0x0010,
3479 Transparent = 0x0800,
3481 AdjustRect = 0x2000,
3487 private enum DrawFrameControlTypes {
3494 public override void CPDrawBorder (Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
3495 ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
3496 Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
3497 int bottomWidth, ButtonBorderStyle bottomStyle) {
3498 DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom-1, leftWidth, leftColor, leftStyle, Border3DSide.Left);
3499 DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Right-1, bounds.Top, topWidth, topColor, topStyle, Border3DSide.Top);
3500 DrawBorderInternal(graphics, bounds.Right-1, bounds.Top, bounds.Right-1, bounds.Bottom-1, rightWidth, rightColor, rightStyle, Border3DSide.Right);
3501 DrawBorderInternal(graphics, bounds.Left, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1, bottomWidth, bottomColor, bottomStyle, Border3DSide.Bottom);
3504 public override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) {
3505 CPDrawBorder3D(graphics, rectangle, style, sides, ColorButtonFace);
3508 private void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color) {
3510 Pen penTopLeftInner;
3512 Pen penBottomRightInner;
3513 Rectangle rect= new Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
3514 bool doInner = false;
3516 if ((style & Border3DStyle.Adjust)!=0) {
3523 /* default to flat */
3524 penTopLeft=ResPool.GetPen(ControlPaint.Dark(control_color));
3525 penTopLeftInner=ResPool.GetPen(ControlPaint.Dark(control_color));
3526 penBottomRight=ResPool.GetPen(ControlPaint.Dark(control_color));
3527 penBottomRightInner=ResPool.GetPen(ControlPaint.Dark(control_color));
3529 if ((style & Border3DStyle.RaisedOuter)!=0) {
3530 penTopLeft=ResPool.GetPen(ControlPaint.LightLight(control_color));
3531 penBottomRight=ResPool.GetPen(ControlPaint.DarkDark(control_color));
3532 if ((style & (Border3DStyle.RaisedInner | Border3DStyle.SunkenInner))!=0) {
3535 } else if ((style & Border3DStyle.SunkenOuter)!=0) {
3536 penTopLeft=ResPool.GetPen(ControlPaint.DarkDark(control_color));
3537 penBottomRight=ResPool.GetPen(ControlPaint.LightLight(control_color));
3538 if ((style & (Border3DStyle.RaisedInner | Border3DStyle.SunkenInner))!=0) {
3543 if ((style & Border3DStyle.RaisedInner)!=0) {
3545 penTopLeftInner=ResPool.GetPen(control_color);
3546 penBottomRightInner=ResPool.GetPen(ControlPaint.Dark(control_color));
3548 penTopLeft=ResPool.GetPen(ControlPaint.LightLight(control_color));
3549 penBottomRight=ResPool.GetPen(ControlPaint.DarkDark(control_color));
3551 } else if ((style & Border3DStyle.SunkenInner)!=0) {
3553 penTopLeftInner=ResPool.GetPen(ControlPaint.Dark(control_color));
3554 penBottomRightInner=ResPool.GetPen(control_color);
3556 penTopLeft=ResPool.GetPen(ControlPaint.DarkDark(control_color));
3557 penBottomRight=ResPool.GetPen(ControlPaint.LightLight(control_color));
3561 if ((sides & Border3DSide.Middle)!=0) {
3562 graphics.FillRectangle(ResPool.GetSolidBrush(control_color), rect);
3565 if ((sides & Border3DSide.Left)!=0) {
3566 graphics.DrawLine(penTopLeft, rect.Left, rect.Bottom-2, rect.Left, rect.Top);
3568 graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Bottom-2, rect.Left+1, rect.Top);
3572 if ((sides & Border3DSide.Top)!=0) {
3573 graphics.DrawLine(penTopLeft, rect.Left, rect.Top, rect.Right-2, rect.Top);
3576 if ((sides & Border3DSide.Left)!=0) {
3577 graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Top+1, rect.Right-3, rect.Top+1);
3579 graphics.DrawLine(penTopLeftInner, rect.Left, rect.Top+1, rect.Right-3, rect.Top+1);
3584 if ((sides & Border3DSide.Right)!=0) {
3585 graphics.DrawLine(penBottomRight, rect.Right-1, rect.Top, rect.Right-1, rect.Bottom-1);
3588 if ((sides & Border3DSide.Top)!=0) {
3589 graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top+1, rect.Right-2, rect.Bottom-2);
3591 graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top, rect.Right-2, rect.Bottom-2);
3596 if ((sides & Border3DSide.Bottom)!=0) {
3599 if ((sides & Border3DSide.Left)!=0) {
3603 graphics.DrawLine(penBottomRight, rect.Left, rect.Bottom-1, rect.Right-1, rect.Bottom-1);
3606 if ((sides & Border3DSide.Right)!=0) {
3607 graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-2, rect.Bottom-2);
3609 graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-2, rect.Bottom-2);
3617 public override void CPDrawButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
3618 DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonPush;
3620 if ((state & ButtonState.Pushed)!=0) {
3621 dfcs |= DrawFrameControlStates.Pushed;
3624 if ((state & ButtonState.Checked)!=0) {
3625 dfcs |= DrawFrameControlStates.Checked;
3628 if ((state & ButtonState.Flat)!=0) {
3629 dfcs |= DrawFrameControlStates.Flat;
3632 if ((state & ButtonState.Inactive)!=0) {
3633 dfcs |= DrawFrameControlStates.Inactive;
3635 DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.Button, dfcs);
3639 public override void CPDrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state) {
3640 Rectangle captionRect;
3643 CPDrawButton(graphics, rectangle, state);
3645 if (rectangle.Width<rectangle.Height) {
3646 captionRect=new Rectangle(rectangle.X+1, rectangle.Y+rectangle.Height/2-rectangle.Width/2+1, rectangle.Width-4, rectangle.Width-4);
3648 captionRect=new Rectangle(rectangle.X+rectangle.Width/2-rectangle.Height/2+1, rectangle.Y+1, rectangle.Height-4, rectangle.Height-4);
3651 if ((state & ButtonState.Pushed)!=0) {
3652 captionRect=new Rectangle(rectangle.X+2, rectangle.Y+2, rectangle.Width-3, rectangle.Height-3);
3655 /* Make sure we've got at least a line width of 1 */
3656 lineWidth=Math.Max(1, captionRect.Width/7);
3659 case CaptionButton.Close: {
3662 if ((state & ButtonState.Inactive)!=0) {
3663 pen=new Pen(ColorButtonHilight, lineWidth);
3664 DrawCaptionHelper(graphics, ColorButtonHilight, pen, lineWidth, 1, captionRect, button);
3667 pen=new Pen(ColorButtonShadow, lineWidth);
3668 DrawCaptionHelper(graphics, ColorButtonShadow, pen, lineWidth, 0, captionRect, button);
3672 pen=new Pen(ColorButtonText, lineWidth);
3673 DrawCaptionHelper(graphics, ColorButtonText, pen, lineWidth, 0, captionRect, button);
3679 case CaptionButton.Help:
3680 case CaptionButton.Maximize:
3681 case CaptionButton.Minimize:
3682 case CaptionButton.Restore: {
3683 if ((state & ButtonState.Inactive)!=0) {
3684 DrawCaptionHelper(graphics, ColorButtonHilight, SystemPens.ControlLightLight, lineWidth, 1, captionRect, button);
3686 DrawCaptionHelper(graphics, ColorButtonShadow, SystemPens.ControlDark, lineWidth, 0, captionRect, button);
3689 DrawCaptionHelper(graphics, ColorButtonText, SystemPens.ControlText, lineWidth, 0, captionRect, button);
3697 public override void CPDrawCheckBox (Graphics graphics, Rectangle rectangle, ButtonState state) {
3698 DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonCheck;
3700 if ((state & ButtonState.Pushed)!=0) {
3701 dfcs |= DrawFrameControlStates.Pushed;
3704 if ((state & ButtonState.Checked)!=0) {
3705 dfcs |= DrawFrameControlStates.Checked;
3708 if ((state & ButtonState.Flat)!=0) {
3709 dfcs |= DrawFrameControlStates.Flat;
3712 if ((state & ButtonState.Inactive)!=0) {
3713 dfcs |= DrawFrameControlStates.Inactive;
3716 DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.Button, dfcs);
3720 public override void CPDrawComboButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
3721 Point[] arrow = new Point[3];
3731 if ((state & ButtonState.Checked)!=0) {
3732 graphics.FillRectangle(ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonLight, ColorButtonHilight),rectangle);
3735 if ((state & ButtonState.Flat)!=0) {
3736 ControlPaint.DrawBorder(graphics, rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
3738 if ((state & (ButtonState.Pushed | ButtonState.Checked))!=0) {
3739 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
3741 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
3745 rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
3746 centerX=rect.Left+rect.Width/2;
3747 centerY=rect.Top+rect.Height/2;
3748 shiftX=Math.Max(1, rect.Width/8);
3749 shiftY=Math.Max(1, rect.Height/8);
3751 if ((state & ButtonState.Pushed)!=0) {
3758 P1=new Point(rect.Left, centerY);
3759 P2=new Point(rect.Right, centerY);
3760 P3=new Point(centerX, rect.Bottom);
3766 /* Draw the arrow */
3767 if ((state & ButtonState.Inactive)!=0) {
3768 graphics.FillPolygon(SystemBrushes.ControlLightLight, arrow, FillMode.Winding);
3770 /* Move away from the shadow */
3780 graphics.FillPolygon(SystemBrushes.ControlDark, arrow, FillMode.Winding);
3782 graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding);
3787 public override void CPDrawContainerGrabHandle (Graphics graphics, Rectangle bounds) {
3789 Pen pen = new Pen(Color.Black, 1);
3790 Rectangle rect = new Rectangle(bounds.X, bounds.Y, bounds.Width-1, bounds.Height-1); // Dunno why, but MS does it that way, too
3794 graphics.FillRectangle(ResPool.GetSolidBrush (ColorButtonText), rect);
3795 graphics.DrawRectangle(pen, rect);
3797 X=rect.X+rect.Width/2;
3798 Y=rect.Y+rect.Height/2;
3800 /* Draw the cross */
3801 graphics.DrawLine(pen, X, rect.Y+2, X, rect.Bottom-2);
3802 graphics.DrawLine(pen, rect.X+2, Y, rect.Right-2, Y);
3804 /* Draw 'arrows' for vertical lines */
3805 graphics.DrawLine(pen, X-1, rect.Y+3, X+1, rect.Y+3);
3806 graphics.DrawLine(pen, X-1, rect.Bottom-3, X+1, rect.Bottom-3);
3808 /* Draw 'arrows' for horizontal lines */
3809 graphics.DrawLine(pen, rect.X+3, Y-1, rect.X+3, Y+1);
3810 graphics.DrawLine(pen, rect.Right-3, Y-1, rect.Right-3, Y+1);
3814 public virtual void DrawFlatStyleFocusRectangle (Graphics graphics, Rectangle rectangle, ButtonBase button, Color foreColor, Color backColor) {
3815 // make a rectange to trace around border of the button
3816 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
3818 Color outerColor = foreColor;
3819 // adjust focus color according to the flatstyle
3820 if (button.FlatStyle == FlatStyle.Popup && !button.is_pressed) {
3821 outerColor = (backColor == ColorButtonFace) ? ControlPaint.Dark(ColorButtonFace) : ColorButtonText;
3824 // draw the outer rectangle
3825 graphics.DrawRectangle (ResPool.GetPen (outerColor), trace_rectangle);
3827 // draw the inner rectangle
3828 if (button.FlatStyle == FlatStyle.Popup) {
3829 DrawInnerFocusRectangle (graphics, Rectangle.Inflate (rectangle, -4, -4), backColor);
3831 // draw a flat inner rectangle
3832 Pen pen = ResPool.GetPen (ControlPaint.LightLight (backColor));
3833 graphics.DrawRectangle(pen, Rectangle.Inflate (trace_rectangle, -4, -4));
3837 public virtual void DrawInnerFocusRectangle(Graphics graphics, Rectangle rectangle, Color backColor)
3839 // make a rectange to trace around border of the button
3840 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
3842 Color colorBackInverted = Color.FromArgb (Math.Abs (backColor.R-255), Math.Abs (backColor.G-255), Math.Abs (backColor.B-255));
3843 DashStyle oldStyle; // used for caching old penstyle
3844 Pen pen = ResPool.GetPen (colorBackInverted);
3846 oldStyle = pen.DashStyle;
3847 pen.DashStyle = DashStyle.Dot;
3848 graphics.DrawRectangle (pen, trace_rectangle);
3849 pen.DashStyle = oldStyle;
3853 public override void CPDrawFocusRectangle (Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor) {
3854 // make a rectange to trace around border of the button
3855 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
3857 //Color colorForeInverted;
3860 //colorForeInverted=Color.FromArgb(Math.Abs(foreColor.R-255), Math.Abs(foreColor.G-255), Math.Abs(foreColor.B-255));
3861 //pen=new Pen(colorForeInverted, 1);
3862 // MS seems to always use black
3863 pen = ResPool.GetPen (Color.Black);
3864 graphics.DrawRectangle(pen, trace_rectangle);
3866 DrawInnerFocusRectangle (graphics, Rectangle.Inflate (rectangle, -4, -4), backColor);
3869 public override void CPDrawGrabHandle (Graphics graphics, Rectangle rectangle, bool primary, bool enabled) {
3873 if (primary==true) {
3874 pen=new Pen(Color.Black, 1);
3875 if (enabled==true) {
3876 sb=ResPool.GetSolidBrush (ColorButtonText);
3878 sb=ResPool.GetSolidBrush (ColorButtonFace);
3881 pen=new Pen(Color.White, 1);
3882 if (enabled==true) {
3883 sb=new SolidBrush(Color.Black);
3885 sb=ResPool.GetSolidBrush (ColorButtonFace);
3888 graphics.FillRectangle(sb, rectangle);
3889 graphics.DrawRectangle(pen, rectangle);
3894 public override void CPDrawGrid (Graphics graphics, Rectangle area, Size pixelsBetweenDots, Color backColor) {
3900 ControlPaint.Color2HBS(backColor, out h, out b, out s);
3903 foreColor=Color.Black;
3905 foreColor=Color.White;
3909 /* Commented out until I take the time and figure out
3910 which HatchStyle will match requirements. The code below
3911 is only correct for Percent50.
3913 if (pixelsBetweenDots.Width==pixelsBetweenDots.Height) {
3914 HatchBrush brush=null;
3916 switch(pixelsBetweenDots.Width) {
3917 case 2: brush=new HatchBrush(HatchStyle.Percent50, foreColor, backColor); break;
3918 case 4: brush=new HatchBrush(HatchStyle.Percent25, foreColor, backColor); break;
3919 case 5: brush=new HatchBrush(HatchStyle.Percent20, foreColor, backColor); break;
3921 /* Have to do it the slow way */
3926 graphics.FillRectangle(brush, area);
3935 Bitmap bitmap = new Bitmap(area.Width, area.Height, graphics);
3937 for (int x=0; x<area.Width; x+=pixelsBetweenDots.Width) {
3938 for (int y=0; y<area.Height; y+=pixelsBetweenDots.Height) {
3939 bitmap.SetPixel(x, y, foreColor);
3942 graphics.DrawImage(bitmap, area.X, area.Y, area.Width, area.Height);
3946 public override void CPDrawImageDisabled (Graphics graphics, Image image, int x, int y, Color background) {
3948 Microsoft seems to ignore the background and simply make
3949 the image grayscale. At least when having > 256 colors on
3953 ImageAttributes imageAttributes=new ImageAttributes();
3954 ColorMatrix colorMatrix=new ColorMatrix(new float[][] {
3955 // This table would create a perfect grayscale image, based on luminance
3956 // new float[]{0.3f,0.3f,0.3f,0,0},
3957 // new float[]{0.59f,0.59f,0.59f,0,0},
3958 // new float[]{0.11f,0.11f,0.11f,0,0},
3959 // new float[]{0,0,0,1,0,0},
3960 // new float[]{0,0,0,0,1,0},
3961 // new float[]{0,0,0,0,0,1}
3963 // This table generates a image that is grayscaled and then
3964 // brightened up. Seems to match MS close enough.
3965 new float[]{0.2f,0.2f,0.2f,0,0},
3966 new float[]{0.41f,0.41f,0.41f,0,0},
3967 new float[]{0.11f,0.11f,0.11f,0,0},
3968 new float[]{0.15f,0.15f,0.15f,1,0,0},
3969 new float[]{0.15f,0.15f,0.15f,0,1,0},
3970 new float[]{0.15f,0.15f,0.15f,0,0,1}
3973 imageAttributes.SetColorMatrix(colorMatrix);
3974 graphics.DrawImage(image, new Rectangle(x, y, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
3975 imageAttributes.Dispose();
3979 public override void CPDrawLockedFrame (Graphics graphics, Rectangle rectangle, bool primary) {
3984 penBorder=new Pen(Color.White, 2);
3985 penInside=new Pen(Color.Black, 1);
3987 penBorder=new Pen(Color.Black, 2);
3988 penInside=new Pen(Color.White, 1);
3990 penBorder.Alignment=PenAlignment.Inset;
3991 penInside.Alignment=PenAlignment.Inset;
3993 graphics.DrawRectangle(penBorder, rectangle);
3994 graphics.DrawRectangle(penInside, rectangle.X+2, rectangle.Y+2, rectangle.Width-5, rectangle.Height-5);
3995 penBorder.Dispose();
3996 penInside.Dispose();
4000 public override void CPDrawMenuGlyph (Graphics graphics, Rectangle rectangle, MenuGlyph glyph) {
4004 // MS draws always the background white
4005 graphics.FillRectangle(ResPool.GetSolidBrush (Color.White), rectangle);
4008 case MenuGlyph.Arrow: {
4009 Point[] arrow = new Point[3];
4018 rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
4019 centerX=rect.Left+rect.Width/2;
4020 centerY=rect.Top+rect.Height/2;
4021 shiftX=Math.Max(1, rect.Width/8);
4022 shiftY=Math.Max(1, rect.Height/8);
4027 P1=new Point(centerX, rect.Top-1);
4028 P2=new Point(centerX, rect.Bottom);
4029 P3=new Point(rect.Right, centerY);
4035 graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding);
4040 case MenuGlyph.Bullet: {
4042 lineWidth=Math.Max(2, rectangle.Width/3);
4043 rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
4045 graphics.FillEllipse(ResPool.GetSolidBrush (ColorButtonText), rect);
4050 case MenuGlyph.Checkmark: {
4053 lineWidth=Math.Max(2, rectangle.Width/6);
4054 Scale=Math.Max(1, rectangle.Width/12);
4056 rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
4058 for (int i=0; i<lineWidth; i++) {
4059 graphics.DrawLine(SystemPens.MenuText, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
4060 graphics.DrawLine(SystemPens.MenuText, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i, rect.Left+lineWidth/2+6*Scale, rect.Top+lineWidth-2*Scale+i);
4068 public override void CPDrawRadioButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
4069 DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonRadio;
4071 if ((state & ButtonState.Pushed)!=0) {
4072 dfcs |= DrawFrameControlStates.Pushed;
4075 if ((state & ButtonState.Checked)!=0) {
4076 dfcs |= DrawFrameControlStates.Checked;
4079 if ((state & ButtonState.Flat)!=0) {
4080 dfcs |= DrawFrameControlStates.Flat;
4083 if ((state & ButtonState.Inactive)!=0) {
4084 dfcs |= DrawFrameControlStates.Inactive;
4086 DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.Button, dfcs);
4091 public override void CPDrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style) {
4096 public override void CPDrawReversibleLine (Point start, Point end, Color backColor) {
4101 /* Scroll button: regular button + direction arrow */
4102 public override void CPDrawScrollButton (Graphics dc, Rectangle area, ScrollButton type, ButtonState state) {
4103 bool enabled = (state == ButtonState.Inactive) ? false: true;
4105 DrawScrollButtonPrimitive (dc, area, state);
4107 if (area.Width < 12 || area.Height < 12) /* Cannot see a thing at smaller sizes */
4112 case ScrollButton.Up: {
4113 int x = area.X + (area.Width / 2) - 4;
4116 for (int i = 0; i < 3; i++)
4118 dc.DrawLine (ResPool.GetPen (arrow_color), x + i, y - i, x + i + 6 - 2*i, y - i);
4120 dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y - i, x + i + 6 - 2*i, y - i);
4123 dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
4124 x + 3, area.Y + 6, 1, 1);
4128 case ScrollButton.Down: {
4129 int x = area.X + (area.Width / 2) - 5;
4132 for (int i = 4; i != 0; i--)
4134 dc.DrawLine (ResPool.GetPen (arrow_color), x + i, y + i, x + i + 8 - 2*i, y + i);
4136 dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y + i, x + i + 8 - 2*i, y + i);
4139 dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
4140 x + 4, y + 4, 1, 1);
4144 case ScrollButton.Left: {
4145 int y = area.Y + (area.Height / 2) - 4;
4148 for (int i = 0; i < 3; i++)
4150 dc.DrawLine (ResPool.GetPen (arrow_color), x - i, y + i, x - i, y + i + 6 - 2*i);
4152 dc.DrawLine (ResPool.GetPen (ColorGrayText), x - i, y + i, x - i, y + i + 6 - 2*i);
4154 dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
4155 x - 3, y + 3, 1, 1);
4159 case ScrollButton.Right: {
4160 int y = area.Y + (area.Height / 2) - 5;
4163 for (int i = 4; i != 0; i--)
4165 dc.DrawLine (ResPool.GetPen (arrow_color), x + i, y + i, x + i, y + i + 8 - 2*i);
4167 dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y + i, x + i, y + i + 8 - 2*i);
4169 dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
4170 x + 4, y + 4, 1, 1);
4181 public override void CPDrawSelectionFrame (Graphics graphics, bool active, Rectangle outsideRect, Rectangle insideRect,
4187 public override void CPDrawSizeGrip (Graphics dc, Color backColor, Rectangle bounds) {
4188 Point pt = new Point (bounds.Right - 2, bounds.Bottom - 1);
4190 dc.DrawLine (ResPool.GetPen (ColorButtonFace), pt.X - 12, pt.Y, pt.X, pt.Y);
4191 dc.DrawLine (ResPool.GetPen (ColorButtonFace), pt.X, pt.Y, pt.X, pt.Y - 13);
4194 for (int i = 0; i < 11; i += 4) {
4195 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), pt.X - i, pt.Y, pt.X + 1, pt.Y - i - 2);
4196 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), pt.X - i - 1, pt.Y, pt.X + 1, pt.Y - i - 2);
4199 for (int i = 3; i < 13; i += 4)
4200 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), pt.X - i, pt.Y, pt.X + 1, pt.Y - i - 1);
4204 public override void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
4205 StringFormat format) {
4208 brush=new SolidBrush(ControlPaint.Light(color, 95));
4210 layoutRectangle.Offset(1.0f, 1.0f);
4211 graphics.DrawString(s, font, brush, layoutRectangle, format);
4213 brush.Color=ControlPaint.Light(color, 50);
4214 layoutRectangle.Offset(-1.0f, -1.0f);
4215 graphics.DrawString(s, font, brush, layoutRectangle, format);
4220 private static void DrawBorderInternal(Graphics graphics, int startX, int startY, int endX, int endY,
4221 int width, Color color, ButtonBorderStyle style, Border3DSide side) {
4223 Pen pen=new Pen(color, 1);
4226 case ButtonBorderStyle.Solid: {
4227 pen.DashStyle=DashStyle.Solid;
4231 case ButtonBorderStyle.Dashed: {
4232 pen.DashStyle=DashStyle.Dash;
4236 case ButtonBorderStyle.Dotted: {
4237 pen.DashStyle=DashStyle.Dot;
4241 case ButtonBorderStyle.Inset: {
4242 pen.DashStyle=DashStyle.Solid;
4246 case ButtonBorderStyle.Outset: {
4247 pen.DashStyle=DashStyle.Solid;
4252 case ButtonBorderStyle.None: {
4260 case ButtonBorderStyle.Outset: {
4262 int hue, brightness, saturation;
4263 int brightnessSteps;
4264 int brightnessDownSteps;
4266 ControlPaint.Color2HBS(color, out hue, out brightness, out saturation);
4268 brightnessDownSteps=brightness/width;
4269 if (brightness>127) {
4270 brightnessSteps=Math.Max(6, (160-brightness)/width);
4272 brightnessSteps=(127-brightness)/width;
4275 for (int i=0; i<width; i++) {
4277 case Border3DSide.Left: {
4279 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
4280 pen=new Pen(colorGrade, 1);
4281 graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
4285 case Border3DSide.Right: {
4287 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
4288 pen=new Pen(colorGrade, 1);
4289 graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
4293 case Border3DSide.Top: {
4295 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
4296 pen=new Pen(colorGrade, 1);
4297 graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
4301 case Border3DSide.Bottom: {
4303 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
4304 pen=new Pen(colorGrade, 1);
4305 graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
4313 case ButtonBorderStyle.Inset: {
4315 int hue, brightness, saturation;
4316 int brightnessSteps;
4317 int brightnessDownSteps;
4319 ControlPaint.Color2HBS(color, out hue, out brightness, out saturation);
4321 brightnessDownSteps=brightness/width;
4322 if (brightness>127) {
4323 brightnessSteps=Math.Max(6, (160-brightness)/width);
4325 brightnessSteps=(127-brightness)/width;
4328 for (int i=0; i<width; i++) {
4330 case Border3DSide.Left: {
4332 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
4333 pen=new Pen(colorGrade, 1);
4334 graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
4338 case Border3DSide.Right: {
4340 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
4341 pen=new Pen(colorGrade, 1);
4342 graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
4346 case Border3DSide.Top: {
4348 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
4349 pen=new Pen(colorGrade, 1);
4350 graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
4354 case Border3DSide.Bottom: {
4356 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
4357 pen=new Pen(colorGrade, 1);
4358 graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
4367 I decided to have the for-loop duplicated for speed reasons;
4368 that way we only have to switch once (as opposed to have the
4369 for-loop around the switch)
4373 case Border3DSide.Left: {
4374 for (int i=0; i<width; i++) {
4375 graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
4380 case Border3DSide.Right: {
4381 for (int i=0; i<width; i++) {
4382 graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
4387 case Border3DSide.Top: {
4388 for (int i=0; i<width; i++) {
4389 graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
4394 case Border3DSide.Bottom: {
4395 for (int i=0; i<width; i++) {
4396 graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
4408 This function actually draws the various caption elements.
4409 This way we can scale them nicely, no matter what size, and they
4410 still look like MS's scaled caption buttons. (as opposed to scaling a bitmap)
4413 private static void DrawCaptionHelper(Graphics graphics, Color color, Pen pen, int lineWidth, int shift, Rectangle captionRect, CaptionButton button) {
4415 case CaptionButton.Close: {
4416 pen.StartCap=LineCap.Triangle;
4417 pen.EndCap=LineCap.Triangle;
4419 graphics.DrawLine(pen, captionRect.Left+2*lineWidth+1+shift, captionRect.Top+2*lineWidth+shift, captionRect.Right-2*lineWidth+1+shift, captionRect.Bottom-2*lineWidth+shift);
4420 graphics.DrawLine(pen, captionRect.Right-2*lineWidth+1+shift, captionRect.Top+2*lineWidth+shift, captionRect.Left+2*lineWidth+1+shift, captionRect.Bottom-2*lineWidth+shift);
4423 graphics.DrawLine(pen, captionRect.Left+2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Right-2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
4424 graphics.DrawLine(pen, captionRect.Right-2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Left+2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
4428 case CaptionButton.Help: {
4429 StringFormat sf = new StringFormat();
4430 SolidBrush sb = new SolidBrush(color);
4431 Font font = new Font("Microsoft Sans Serif", captionRect.Height, FontStyle.Bold, GraphicsUnit.Pixel);
4433 sf.Alignment=StringAlignment.Center;
4434 sf.LineAlignment=StringAlignment.Center;
4437 graphics.DrawString("?", font, sb, captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
4446 case CaptionButton.Maximize: {
4447 /* Top 'caption bar' line */
4448 for (int i=0; i<Math.Max(2, lineWidth); i++) {
4449 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Top+2*lineWidth+shift+i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Top+2*lineWidth+shift+i);
4452 /* Left side line */
4453 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
4454 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
4457 /* Right side line */
4458 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
4459 graphics.DrawLine(pen, captionRect.Right-lineWidth-lineWidth/2+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Right-lineWidth-lineWidth/2+shift+i, captionRect.Bottom-lineWidth+shift);
4463 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
4464 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
4469 case CaptionButton.Minimize: {
4471 for (int i=0; i<Math.Max(2, lineWidth); i++) {
4472 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth+shift, captionRect.Bottom-lineWidth+shift-i);
4477 case CaptionButton.Restore: {
4478 /** First 'window' **/
4479 /* Top 'caption bar' line */
4480 for (int i=0; i<Math.Max(2, lineWidth); i++) {
4481 graphics.DrawLine(pen, captionRect.Left+3*lineWidth+shift, captionRect.Top+2*lineWidth+shift-i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Top+2*lineWidth+shift-i);
4484 /* Left side line */
4485 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
4486 graphics.DrawLine(pen, captionRect.Left+3*lineWidth+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Left+3*lineWidth+shift+i, captionRect.Top+4*lineWidth+shift);
4489 /* Right side line */
4490 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
4491 graphics.DrawLine(pen, captionRect.Right-lineWidth-lineWidth/2+shift-i, captionRect.Top+2*lineWidth+shift, captionRect.Right-lineWidth-lineWidth/2+shift-i, captionRect.Top+5*lineWidth-lineWidth/2+shift);
4495 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
4496 graphics.DrawLine(pen, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Top+5*lineWidth-lineWidth/2+shift+1+i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Top+5*lineWidth-lineWidth/2+shift+1+i);
4499 /** Second 'window' **/
4500 /* Top 'caption bar' line */
4501 for (int i=0; i<Math.Max(2, lineWidth); i++) {
4502 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Top+4*lineWidth+shift+1-i, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Top+4*lineWidth+shift+1-i);
4505 /* Left side line */
4506 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
4507 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+4*lineWidth+shift+1, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
4510 /* Right side line */
4511 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
4512 graphics.DrawLine(pen, captionRect.Right-3*lineWidth-lineWidth/2+shift-i, captionRect.Top+4*lineWidth+shift+1, captionRect.Right-3*lineWidth-lineWidth/2+shift-i, captionRect.Bottom-lineWidth+shift);
4516 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
4517 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
4526 [MonoTODO("Finish drawing code for Caption, Menu and Scroll")]
4527 private void DrawFrameControl(Graphics graphics, Rectangle rectangle, DrawFrameControlTypes Type, DrawFrameControlStates State) {
4528 // make a rectange to trace around border of the button
4529 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
4531 case DrawFrameControlTypes.Button: {
4533 if ((State & DrawFrameControlStates.ButtonPush)!=0) {
4534 // JBA 31 oct 2004 - I don't think that button style should be rendered like this
4535 // /* Goes first, affects the background */
4536 // if ((State & DrawFrameControlStates.Checked)!=0) {
4537 // HatchBrush hatchBrush=new HatchBrush(HatchStyle.Percent50, ColorButtonLight, ColorButtonHilight);
4538 // graphics.FillRectangle(hatchBrush,rectangle);
4539 // hatchBrush.Dispose();
4542 if ((State & DrawFrameControlStates.Pushed)!=0 || (State & DrawFrameControlStates.Checked)!=0) {
4543 graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorButtonFace)), trace_rectangle);
4544 } else if ((State & DrawFrameControlStates.Flat)!=0) {
4545 ControlPaint.DrawBorder(graphics, rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
4546 } else if ((State & DrawFrameControlStates.Inactive)!=0) {
4547 /* Same as normal, it would seem */
4548 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
4550 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
4552 } else if ((State & DrawFrameControlStates.ButtonRadio)!=0) {
4553 Pen penFatDark = new Pen(ColorButtonShadow, 1);
4554 Pen penFatLight = new Pen(ColorButtonLight, 1);
4557 graphics.FillPie (ResPool.GetSolidBrush (this.ColorWindow), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
4559 graphics.DrawArc(penFatDark, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 135, 180);
4560 graphics.DrawArc(penFatLight, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 315, 180);
4562 graphics.DrawArc(SystemPens.ControlDark, rectangle, 135, 180);
4563 graphics.DrawArc(SystemPens.ControlLightLight, rectangle, 315, 180);
4565 lineWidth=Math.Max(1, Math.Min(rectangle.Width, rectangle.Height)/3);
4567 if ((State & DrawFrameControlStates.Checked)!=0) {
4568 SolidBrush buttonBrush;
4570 if ((State & DrawFrameControlStates.Inactive)!=0) {
4571 buttonBrush=(SolidBrush)SystemBrushes.ControlDark;
4573 buttonBrush=(SolidBrush)SystemBrushes.ControlText;
4575 graphics.FillPie(buttonBrush, rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2, 0, 359);
4577 penFatDark.Dispose();
4578 penFatLight.Dispose();
4579 } else if ((State & DrawFrameControlStates.ButtonRadioImage)!=0) {
4580 throw new NotImplementedException () ;
4581 } else if ((State & DrawFrameControlStates.ButtonRadioMask)!=0) {
4582 throw new NotImplementedException ();
4583 } else { /* Must be Checkbox */
4589 /* Goes first, affects the background */
4590 if ((State & DrawFrameControlStates.Pushed)!=0 ||
4591 (State & DrawFrameControlStates.Inactive)!=0) {
4592 graphics.FillRectangle(SystemBrushes.Control, rectangle);
4594 graphics.FillRectangle(SystemBrushes.Window, rectangle);
4597 /* Draw the sunken frame */
4598 if ((State & DrawFrameControlStates.Flat)!=0) {
4599 ControlPaint.DrawBorder(graphics, rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
4601 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
4604 /* Make sure we've got at least a line width of 1 */
4605 lineWidth=Math.Max(3, rectangle.Width/6);
4606 Scale=Math.Max(1, rectangle.Width/12);
4608 // define a rectangle inside the border area
4609 rect=new Rectangle(rectangle.X+2, rectangle.Y+2, rectangle.Width-4, rectangle.Height-4);
4610 if ((State & DrawFrameControlStates.Inactive)!=0) {
4611 pen=SystemPens.ControlDark;
4613 pen=SystemPens.ControlText;
4616 if ((State & DrawFrameControlStates.Checked)!=0) {
4617 /* Need to draw a check-mark */
4618 for (int i=0; i<lineWidth; i++) {
4619 graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
4620 graphics.DrawLine(pen, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i, rect.Left+lineWidth/2+6*Scale, rect.Top+lineWidth-2*Scale+i);
4628 case DrawFrameControlTypes.Caption: {
4633 case DrawFrameControlTypes.Menu: {
4638 case DrawFrameControlTypes.Scroll: {
4645 /* Generic scroll button */
4646 public void DrawScrollButtonPrimitive (Graphics dc, Rectangle area, ButtonState state) {
4647 if ((state & ButtonState.Pushed) == ButtonState.Pushed) {
4648 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X + 1,
4649 area.Y + 1, area.Width - 2 , area.Height - 2);
4651 dc.DrawRectangle (ResPool.GetPen (ColorButtonShadow), area.X,
4652 area.Y, area.Width, area.Height);
4657 dc.FillRectangle (new SolidBrush (Color.Blue), area);
4659 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X, area.Y, area.Width, 1);
4660 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X, area.Y, 1, area.Height);
4662 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonHilight), area.X + 1, area.Y + 1, area.Width - 1, 1);
4663 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonHilight), area.X + 1, area.Y + 2, 1,
4666 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonShadow), area.X + 1, area.Y + area.Height - 2,
4669 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonDkShadow), area.X, area.Y + area.Height -1,
4672 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonShadow), area.X + area.Width - 2,
4673 area.Y + 1, 1, area.Height -3);
4675 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonDkShadow), area.X + area.Width -1,
4676 area.Y, 1, area.Height - 1);
4678 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X + 2,
4679 area.Y + 2, area.Width - 4, area.Height - 4);
4683 public override void CPDrawBorderStyle (Graphics dc, Rectangle area, BorderStyle border_style) {
4684 switch (border_style){
4685 case BorderStyle.Fixed3D:
4686 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), area.X, area.Y, area.X +area.Width, area.Y);
4687 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), area.X, area.Y, area.X, area.Y + area.Height);
4688 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), area.X , area.Y + area.Height - 1, area.X + area.Width ,
4689 area.Y + area.Height - 1);
4690 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), area.X + area.Width -1 , area.Y, area.X + area.Width -1,
4691 area.Y + area.Height);
4693 // FIXME: These colors are not correct. Microsoft uses different ones but I didn't find them.
4694 dc.DrawLine (ResPool.GetPen (ColorButtonLight), area.X + 1, area.Bottom - 2, area.Right - 2, area.Bottom - 2);
4695 dc.DrawLine (ResPool.GetPen (ColorButtonLight), area.Right - 2, area.Top + 1, area.Right - 2, area.Bottom - 2);
4696 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), area.X + 1, area.Top + 1, area.X + 1, area.Bottom - 3);
4697 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), area.X + 1, area.Top + 1, area.Right - 3, area.Top + 1);
4699 case BorderStyle.FixedSingle:
4700 dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame), area.X, area.Y, area.Width - 1, area.Height - 1);
4702 case BorderStyle.None:
4708 #endregion // ControlPaint