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.64 2004/11/10 19:22:26 jackson
33 // * ThemeWin32Classic.cs: Don't bother drawing tabs outside of the
36 // Revision 1.63 2004/11/10 01:04:28 jackson
37 // * TabControl.cs (CalcXPos): New helper method so we can determine
38 // the proper place to start drawing vertical tabs.
39 // * ThemeWin32Classic.cs (DrawTab): Draw right aligned tabs.
41 // Revision 1.62 2004/11/09 21:44:54 jackson
42 // * TabControl.cs: Calculate sizing and rects for left aligned tabs.
43 // * ThemeWin32Classic.cs (GetTabControl*ScrollRect): Only handle Top
44 // and Bottom, left and right are illegal values for this and
45 // multiline is enabled when the alignment is set to left or right.
46 // (DrawTab): Each alignment block should draw the text itself now
47 // because Left requires special love. Also add rendering for Left
50 // Revision 1.61 2004/11/09 11:06:21 jba
51 // - (DrawButtonBase): Fix verticle text rect clipping in windows
52 // - (DrawCheckBox): Fix CheckAlign.TopCenter and CheckAlign.BottomCenter
53 // rendering and incorrect text rect clipping
54 // - (DrawRadioButton): Fix CheckAlign.TopCenter and CheckAlign.BottomCenter
55 // rendering and incorrect text rect clipping
57 // Revision 1.60 2004/11/09 03:12:00 jackson
58 // * ThemeWin32Classic.cs (DrawTabControl): Render tabs from top to
59 // bottom when they are bottom aligned so the bottoms of the tabs get
61 // * TabControl.cs (DropRow): Move rows up instead of down when the
62 // tab control is bottom aligned.
64 // Revision 1.59 2004/11/08 20:40:08 jackson
65 // Render the little scrolling jimmi in the correct location with bottom aligned tabs
67 // Revision 1.58 2004/11/08 14:15:00 jordi
68 // fixes vertical scrollbar and removes dead code
70 // Revision 1.57 2004/11/05 05:47:34 jba
71 // - Fix Button rendering for FlatStyle = Flat or Popup
72 // - Fix RadioButton and CheckBox rendering when Appearance = Button (normal and
74 // - Correct outer rectangle color when drawing focus rectangle
75 // - Adjust button bounds to be 1 px smaller when focused
76 // - Make button not draw sunken 3d border when pushed (windows compat)
77 // - Fix CPDrawBorder3D to not make bottom right hand corner rounded
78 // - Offset the text in RadioButton and Checkbox when being rendered as a button.
79 // - Hover and Click behaviour for Colored FlatStyle.Flat and Popup radiobuttons
80 // - Fixed disabled rendering for colored flatstyle radiobuttons (both)
81 // - Fixed disabled text rendering for normally rendered radiobuttons
83 // Revision 1.56 2004/11/04 11:26:09 ravindra
84 // - Changed default ListView values signatures (prefixed all with ListView).
85 // - Fixed default size values for VScrollBar and HScrollBar.
86 // - Fixed DrawListViewItem method.
88 // Revision 1.55 2004/11/03 18:52:14 jackson
89 // Initial implementation of the scrolly widgerywoo
91 // Revision 1.54 2004/11/02 20:40:54 jackson
92 // Move the row with the selected tab to the bottom
94 // Revision 1.53 2004/11/02 02:47:55 jackson
95 // New rendering and sizing code for tab controls
97 // Revision 1.52 2004/10/30 10:23:02 ravindra
98 // Drawing ListView and some default values.
100 // Revision 1.51 2004/10/26 09:55:48 ravindra
101 // Some formatting for my last checkins.
103 // Revision 1.50 2004/10/26 09:36:32 ravindra
104 // Implemented DetailView drawing for ListView control and default values.
106 // Revision 1.49 2004/10/18 04:49:25 pbartok
107 // - Added ToolTip drawing code
109 // Revision 1.48 2004/10/15 15:08:49 ravindra
110 // Added ColumnHeaderHeight property in Theme for ListView.
112 // Revision 1.47 2004/10/13 15:06:37 pbartok
113 // - Path from John BouAntoun:
114 // * Fix check rendering (centre correctly for normal style, offset
115 // correctly for FlatStyle).
116 // * Fix border color usage (use backcolor) for FlatStyle.Popup
117 // * Use checkbox.Capture instead of checkbox.is_pressed when rendering
120 // Revision 1.46 2004/10/13 03:48:15 pbartok
121 // - Removed all occurences of SystemColors and replaced them with the
122 // matching theme color
124 // Revision 1.45 2004/10/13 03:41:45 pbartok
125 // - From John BouAntoun: Added an overload to CPDrawBorder3D to allow him
126 // using the function for flatstyle drawing
127 // - Changed functions to use the new version of CPDrawBorder3D
129 // Revision 1.44 2004/10/13 02:45:21 pbartok
130 // - Fixes from John BouAntoun: now handles forecolors and backcolors for
131 // flatstyle rendered controls much better; It also fixes normal checkbox
132 // rendering when pushed or disabled.
134 // Revision 1.43 2004/10/07 14:56:51 jordi
135 // Removes deletion of cached brushes
137 // Revision 1.42 2004/10/06 09:59:05 jordi
138 // removes warnings from compilation
140 // Revision 1.41 2004/10/05 16:15:30 jackson
141 // Improve rendering of the radio button patch by John BouAntoun
143 // Revision 1.40 2004/10/05 09:04:31 ravindra
144 // - Added DrawListView method and ListViewDefaultSize property.
145 // - Changed ControlPaint method calls to CPDrawXXX wherever possible.
146 // - Changed DOS style CRLF to Unix format (dos2unix).
148 // Revision 1.39 2004/10/04 07:09:37 jordi
149 // fixes right button position causing right button not showing on horizontal scrollbars
151 // Revision 1.38 2004/09/28 18:44:25 pbartok
152 // - Streamlined Theme interfaces:
153 // * Each DrawXXX method for a control now is passed the object for the
154 // control to be drawn in order to allow accessing any state the theme
157 // * ControlPaint methods for the theme now have a CP prefix to avoid
158 // name clashes with the Draw methods for controls
160 // * Every control now retrieves it's DefaultSize from the current theme
162 // Revision 1.37 2004/09/09 08:28:11 pbartok
163 // - Improve disabled string look
165 // Revision 1.36 2004/09/09 03:03:49 ravindra
166 // PictureBox would not draw a null image to avoid crash.
168 // Revision 1.35 2004/09/07 17:12:26 jordi
171 // Revision 1.34 2004/09/07 09:40:15 jordi
172 // LinkLabel fixes, methods, multiple links
174 // Revision 1.33 2004/09/05 08:03:51 jordi
175 // fixes bugs, adds flashing on certain situations
177 // Revision 1.32 2004/09/02 16:32:54 jordi
178 // implements resource pool for pens, brushes, and hatchbruses
180 // Revision 1.31 2004/08/25 20:04:40 ravindra
181 // Added the missing divider code and grip for ToolBar Control.
183 // Revision 1.30 2004/08/25 18:29:14 jordi
184 // new methods, properties, and fixes for progressbar
186 // Revision 1.29 2004/08/25 00:43:13 ravindra
187 // Fixed wrapping related issues in ToolBar control.
189 // Revision 1.28 2004/08/24 18:37:02 jordi
190 // fixes formmating, methods signature, and adds missing events
192 // Revision 1.27 2004/08/24 16:16:46 jackson
193 // Handle drawing picture boxes in the theme now. Draw picture box borders and obey sizing modes
195 // Revision 1.26 2004/08/21 01:52:08 ravindra
196 // Improvments in mouse event handling in the ToolBar control.
198 // Revision 1.25 2004/08/20 00:12:51 jordi
199 // fixes methods signature
201 // Revision 1.24 2004/08/19 22:25:31 jordi
202 // theme enhancaments
204 // Revision 1.23 2004/08/18 19:16:53 jordi
205 // Move colors to a table
207 // Revision 1.22 2004/08/17 19:29:11 jackson
208 // Don't use KnownColor to create colours. It has a large startup time.
210 // Revision 1.21 2004/08/15 23:20:54 ravindra
211 // Changes to Theme for ToolBar control and also dos2unix format.
213 // Revision 1.20 2004/08/13 21:22:18 jordi
214 // removes redundant code and fixes issues with tickposition
216 // Revision 1.19 2004/08/12 20:29:01 jordi
217 // Trackbar enhancement, fix mouse problems, highli thumb, etc
219 // Revision 1.18 2004/08/12 18:54:37 jackson
220 // Handle owner draw status bars
222 // Revision 1.17 2004/08/11 01:31:35 jackson
223 // Create Brushes as little as possible
225 // Revision 1.16 2004/08/10 19:21:27 jordi
226 // scrollbar enhancements and standarize on win colors defaults
228 // Revision 1.15 2004/08/10 18:52:30 jackson
229 // Implement DrawItem functionality
231 // Revision 1.14 2004/08/09 21:34:54 jackson
232 // Add support for drawing status bar and get status bar item sizes
234 // Revision 1.13 2004/08/09 21:21:49 jackson
235 // Use known colors for default control colours
237 // Revision 1.12 2004/08/09 21:12:15 jackson
238 // Make the default font static, it is static in control so this doesn't change functionality and creating fonts is sloooooow.
240 // Revision 1.11 2004/08/09 17:31:13 jackson
241 // New names for control properties
243 // Revision 1.10 2004/08/09 17:00:00 jackson
244 // Add default window color properties
246 // Revision 1.9 2004/08/09 16:17:19 jackson
247 // Use correct default back color
249 // Revision 1.8 2004/08/09 15:53:12 jackson
250 // Themes now handle default control properties so coloring will be consistent
252 // Revision 1.7 2004/08/08 22:54:21 jordi
253 // Label BorderStyles
255 // Revision 1.6 2004/08/08 18:09:53 jackson
256 // Add pen_buttonface
258 // Revision 1.5 2004/08/08 17:34:28 jordi
259 // Use Windows Standard Colours
261 // Revision 1.4 2004/08/07 23:31:15 jordi
262 // fixes label bug and draw method name
264 // Revision 1.3 2004/08/07 19:05:44 jordi
265 // Theme colour support and GetSysColor defines
267 // Revision 1.2 2004/08/07 00:01:39 pbartok
268 // - Fixed some rounding issues with float/int
270 // Revision 1.1 2004/07/26 17:42:03 jordi
275 using System.Drawing;
276 using System.Drawing.Drawing2D;
277 using System.Drawing.Imaging;
279 namespace System.Windows.Forms
282 internal class ThemeWin32Classic : Theme
285 /* Default colors for Win32 classic theme */
286 uint [] theme_colors = { /* AARRGGBB */
287 (uint) XplatUIWin32.GetSysColorIndex.COLOR_SCROLLBAR, 0xffc0c0c0,
288 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BACKGROUND, 0xff008080,
289 (uint) XplatUIWin32.GetSysColorIndex.COLOR_ACTIVECAPTION, 0xff000080,
290 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVECAPTION, 0xff808080,
291 (uint) XplatUIWin32.GetSysColorIndex.COLOR_MENU, 0xffc0c0c0,
292 (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOW, 0xffffffff,
293 (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOWFRAME, 0xff000000,
294 (uint) XplatUIWin32.GetSysColorIndex.COLOR_MENUTEXT, 0xff000000,
295 (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOWTEXT, 0xff000000,
296 (uint) XplatUIWin32.GetSysColorIndex.COLOR_CAPTIONTEXT, 0xffffffff,
297 (uint) XplatUIWin32.GetSysColorIndex.COLOR_ACTIVEBORDER, 0xffc0c0c0,
298 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVEBORDER, 0xffc0c0c0,
299 (uint) XplatUIWin32.GetSysColorIndex.COLOR_APPWORKSPACE, 0xff808080,
300 (uint) XplatUIWin32.GetSysColorIndex.COLOR_HIGHLIGHT, 0xff000080,
301 (uint) XplatUIWin32.GetSysColorIndex.COLOR_HIGHLIGHTTEXT, 0xffffffff,
302 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNFACE, 0xffc0c0c0,
303 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNSHADOW, 0xff808080,
304 (uint) XplatUIWin32.GetSysColorIndex.COLOR_GRAYTEXT, 0xff808080,
305 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNTEXT, 0xff000000,
306 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVECAPTIONTEXT, 0xffc0c0c0,
307 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNHIGHLIGHT, 0xffffffff,
308 (uint) XplatUIWin32.GetSysColorIndex.COLOR_3DDKSHADOW, 0xff000000,
309 (uint) XplatUIWin32.GetSysColorIndex.COLOR_3DLIGHT, 0xffe0e0e0,
310 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INFOTEXT, 0xff000000,
311 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INFOBK, 0xffffffff,
315 static protected Pen pen_ticks;
316 static protected SolidBrush br_arrow;
317 static protected SolidBrush br_progressbarblock;
318 static protected Pen pen_arrow;
322 protected SolidBrush label_br_fore_color;
323 protected SolidBrush label_br_back_color;
325 #region Principal Theme Methods
326 public ThemeWin32Classic ()
328 label_br_fore_color = null;
329 label_br_back_color = null;
331 /* Init Default colour array*/
332 syscolors = Array.CreateInstance (typeof (Color), (uint) XplatUIWin32.GetSysColorIndex.COLOR_MAXVALUE+1);
334 for (int i = 0; i < theme_colors.Length; i +=2)
335 syscolors.SetValue (Color.FromArgb ((int)theme_colors[i+1]), (int) theme_colors[i]);
337 pen_ticks = new Pen (Color.Black);
338 br_arrow = new SolidBrush (Color.Black);
339 pen_arrow = new Pen (Color.Black);
340 br_progressbarblock = new SolidBrush (Color.FromArgb (255, 0, 0, 128));
342 defaultWindowBackColor = Color.FromArgb (255, 10, 10, 10);
343 defaultWindowForeColor = ColorButtonText;
344 default_font = new Font (FontFamily.GenericSansSerif, 8.25f);
347 public override bool DoubleBufferingSupported {
350 #endregion // Principal Theme Methods
352 #region Internal Methods
353 protected SolidBrush GetControlBackBrush (Color c) {
354 if (c == DefaultControlBackColor)
355 return ResPool.GetSolidBrush (ColorButtonFace);
356 return new SolidBrush (c);
359 protected SolidBrush GetControlForeBrush (Color c) {
360 if (c == DefaultControlForeColor)
361 return ResPool.GetSolidBrush (ColorButtonText);
362 return new SolidBrush (c);
364 #endregion // Internal Methods
366 #region OwnerDraw Support
367 public override void DrawOwnerDrawBackground (DrawItemEventArgs e)
369 if (e.State == DrawItemState.Selected) {
370 e.Graphics.FillRectangle (SystemBrushes.Highlight, e.Bounds);
374 e.Graphics.FillRectangle (GetControlBackBrush (e.BackColor), e.Bounds);
377 public override void DrawOwnerDrawFocusRectangle (DrawItemEventArgs e)
379 if (e.State == DrawItemState.Focus)
380 CPDrawFocusRectangle (e.Graphics, e.Bounds, e.ForeColor, e.BackColor);
382 #endregion // OwnerDraw Support
385 public override void DrawButtonBase(Graphics dc, Rectangle clip_area, ButtonBase button) {
388 Rectangle buttonRectangle;
389 Rectangle borderRectangle;
391 width = button.ClientSize.Width;
392 height = button.ClientSize.Height;
394 SolidBrush sb = new SolidBrush(button.BackColor);
395 dc.FillRectangle(sb, button.ClientRectangle);
398 // set up the button rectangle
399 buttonRectangle = button.ClientRectangle;
400 if (button.has_focus) {
401 // shrink the rectangle for the normal button drawing inside the focus rectangle
402 borderRectangle = Rectangle.Inflate(buttonRectangle, -1, -1);
404 borderRectangle = buttonRectangle;
407 if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
408 DrawFlatStyleButton (dc, borderRectangle, button);
410 CPDrawButton(dc, borderRectangle, button.ButtonState);
413 // First, draw the image
414 if ((button.image != null) || (button.image_list != null)) {
415 // Need to draw a picture
422 if (button.ImageIndex!=-1) { // We use ImageIndex instead of image_index since it will return -1 if image_list is null
423 i = button.image_list.Images[button.image_index];
428 image_width = button.image.Width;
429 image_height = button.image.Height;
431 switch(button.image_alignment) {
432 case ContentAlignment.TopLeft: {
438 case ContentAlignment.TopCenter: {
439 image_x=(width-image_width)/2;
444 case ContentAlignment.TopRight: {
445 image_x=width-image_width;
450 case ContentAlignment.MiddleLeft: {
452 image_y=(height-image_height)/2;
456 case ContentAlignment.MiddleCenter: {
457 image_x=(width-image_width)/2;
458 image_y=(height-image_height)/2;
462 case ContentAlignment.MiddleRight: {
463 image_x=width-image_width;
464 image_y=(height-image_height)/2;
468 case ContentAlignment.BottomLeft: {
470 image_y=height-image_height;
474 case ContentAlignment.BottomCenter: {
475 image_x=(width-image_width)/2;
476 image_y=height-image_height;
480 case ContentAlignment.BottomRight: {
481 image_x=width-image_width;
482 image_y=height-image_height;
493 if (button.is_pressed) {
498 if (button.is_enabled) {
499 dc.DrawImage(i, image_x, image_y);
501 CPDrawImageDisabled(dc, i, image_x, image_y, ColorButtonFace);
505 // Draw the focus rectangle
506 if (button.has_focus) {
507 if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
508 DrawFlatStyleFocusRectangle (dc, button.ClientRectangle, button, button.ForeColor, button.BackColor);
510 CPDrawFocusRectangle(dc, button.ClientRectangle, button.ForeColor, button.BackColor);
515 if (button.text != null && button.text != String.Empty) {
516 Rectangle text_rect = Rectangle.Inflate(buttonRectangle, -4, -4);
518 if (button.is_pressed) {
523 if (button.is_enabled) {
524 SolidBrush b = new SolidBrush(button.ForeColor);
525 dc.DrawString(button.text, button.Font, b, text_rect, button.text_format);
528 if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
529 dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), text_rect, button.text_format);
531 CPDrawStringDisabled(dc, button.text, button.Font, ColorButtonText, text_rect, button.text_format);
537 // draw the flat style part of the rectangle
538 public void DrawFlatStyleButton (Graphics graphics, Rectangle rectangle, ButtonBase button) {
539 Color rect_back_color = button.BackColor;
540 Color rect_fore_color = button.ForeColor;
541 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
543 if (button.Enabled) {
544 if (button.Capture || button.is_entered) {
545 if (button.FlatStyle == FlatStyle.Flat) {
546 // fill the rectangle
547 graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
549 // now draw the outer border
550 if (button.Capture && button.is_entered) {
551 rect_back_color = ControlPaint.LightLight (rect_back_color);
553 rect_back_color = ControlPaint.Light (rect_back_color);
556 // draw rectangle and fill it
557 graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
558 graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
560 // else it must be a popup button
562 if (button.Capture && button.is_entered) {
563 graphics.DrawRectangle(ResPool.GetPen (this.ColorButtonText), trace_rectangle);
566 CPDrawBorder3D (graphics, rectangle, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, button.BackColor);
567 graphics.DrawLine ( ResPool.GetPen (this.ColorButtonText), trace_rectangle.X, trace_rectangle.Bottom, trace_rectangle.Right, trace_rectangle.Bottom);
568 graphics.DrawLine ( ResPool.GetPen (this.ColorButtonText), trace_rectangle.Right, trace_rectangle.Y, trace_rectangle.Right, trace_rectangle.Bottom);
572 // TODO: draw inner focus rectangle
575 // popup has a ButtonColorText forecolor, not a button.ForeCOlor
576 if (button.FlatStyle == FlatStyle.Popup) {
577 rect_fore_color = this.ColorButtonText;
580 // fill then draw outer rect
581 graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
582 graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
585 // finally some small tweaks to render radiobutton and checkbox
586 CheckBox checkbox = button as CheckBox;
587 RadioButton radiobutton = button as RadioButton;
588 if ((checkbox != null && checkbox.Checked) ||
589 (radiobutton != null && radiobutton.Checked)) {
590 if (button.FlatStyle == FlatStyle.Flat && button.is_entered && !button.Capture) {
591 // render the hover for flat flatstyle and cheked
592 graphics.DrawRectangle(ResPool.GetPen (this.ColorButtonText), trace_rectangle);
593 } else if (!button.is_entered && !button.Capture) {
594 // render the checked state for popup when unhovered
595 CPDrawBorder3D (graphics, rectangle, Border3DStyle.SunkenInner, Border3DSide.Right | Border3DSide.Bottom, button.BackColor);
599 // rendering checkbox or radio button style buttons
600 CheckBox checkbox = button as CheckBox;
601 RadioButton radiobutton = button as RadioButton;
602 bool draw_popup_checked = false;
604 if (button.FlatStyle == FlatStyle.Popup) {
605 rect_fore_color = this.ColorButtonText;
607 // see if we should draw a disabled checked popup button
608 draw_popup_checked = ((checkbox != null && checkbox.Checked) ||
609 (radiobutton != null && radiobutton.Checked));
612 graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
613 graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
615 // finally draw the flatstyle checked effect if need
616 if (draw_popup_checked) {
617 // render the checked state for popup when unhovered
618 CPDrawBorder3D (graphics, rectangle, Border3DStyle.SunkenInner, Border3DSide.Right | Border3DSide.Bottom, button.BackColor);
623 public override Size ButtonBaseDefaultSize {
625 return new Size (75, 23);
628 #endregion // ButtonBase
631 public override void DrawCheckBox(Graphics dc, Rectangle clip_area, CheckBox checkbox) {
632 StringFormat text_format;
633 Rectangle client_rectangle;
634 Rectangle text_rectangle;
635 Rectangle checkbox_rectangle;
637 int checkmark_size=13;
638 int checkmark_space = 4;
640 client_rectangle = checkbox.ClientRectangle;
641 text_rectangle = client_rectangle;
642 checkbox_rectangle = new Rectangle(text_rectangle.X, text_rectangle.Y, checkmark_size, checkmark_size);
644 text_format = new StringFormat();
645 text_format.Alignment=StringAlignment.Near;
646 text_format.LineAlignment=StringAlignment.Center;
648 /* Calculate the position of text and checkbox rectangle */
649 if (checkbox.appearance!=Appearance.Button) {
650 switch(checkbox.check_alignment) {
651 case ContentAlignment.BottomCenter: {
652 checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
653 checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
654 text_rectangle.X=client_rectangle.X;
655 text_rectangle.Width=client_rectangle.Width;
656 text_rectangle.Height=client_rectangle.Height-checkbox_rectangle.Y-checkmark_space;
660 case ContentAlignment.BottomLeft: {
661 checkbox_rectangle.X=client_rectangle.Left;
662 checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
663 text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
664 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
668 case ContentAlignment.BottomRight: {
669 checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
670 checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
671 text_rectangle.X=client_rectangle.X;
672 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
676 case ContentAlignment.MiddleCenter: {
677 checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
678 checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
679 text_rectangle.X=client_rectangle.X;
680 text_rectangle.Width=client_rectangle.Width;
685 case ContentAlignment.MiddleLeft: {
686 checkbox_rectangle.X=client_rectangle.Left;
687 checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
688 text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
689 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
693 case ContentAlignment.MiddleRight: {
694 checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
695 checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
696 text_rectangle.X=client_rectangle.X;
697 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
701 case ContentAlignment.TopCenter: {
702 checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
703 checkbox_rectangle.Y=client_rectangle.Top;
704 text_rectangle.X=client_rectangle.X;
705 text_rectangle.Width=client_rectangle.Width;
706 text_rectangle.Y=checkmark_size+checkmark_space;
707 text_rectangle.Height=client_rectangle.Height-checkmark_size-checkmark_space;
711 case ContentAlignment.TopLeft: {
712 checkbox_rectangle.X=client_rectangle.Left;
713 text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
714 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
718 case ContentAlignment.TopRight: {
719 checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
720 text_rectangle.X=client_rectangle.X;
721 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
726 text_rectangle.X=client_rectangle.X;
727 text_rectangle.Width=client_rectangle.Width;
730 /* Set the horizontal alignment of our text */
731 switch(checkbox.text_alignment) {
732 case ContentAlignment.BottomLeft:
733 case ContentAlignment.MiddleLeft:
734 case ContentAlignment.TopLeft: {
735 text_format.Alignment=StringAlignment.Near;
739 case ContentAlignment.BottomCenter:
740 case ContentAlignment.MiddleCenter:
741 case ContentAlignment.TopCenter: {
742 text_format.Alignment=StringAlignment.Center;
746 case ContentAlignment.BottomRight:
747 case ContentAlignment.MiddleRight:
748 case ContentAlignment.TopRight: {
749 text_format.Alignment=StringAlignment.Far;
754 /* Set the vertical alignment of our text */
755 switch(checkbox.text_alignment) {
756 case ContentAlignment.TopLeft:
757 case ContentAlignment.TopCenter:
758 case ContentAlignment.TopRight: {
759 text_format.LineAlignment=StringAlignment.Near;
763 case ContentAlignment.BottomLeft:
764 case ContentAlignment.BottomCenter:
765 case ContentAlignment.BottomRight: {
766 text_format.LineAlignment=StringAlignment.Far;
770 case ContentAlignment.MiddleLeft:
771 case ContentAlignment.MiddleCenter:
772 case ContentAlignment.MiddleRight: {
773 text_format.LineAlignment=StringAlignment.Center;
778 ButtonState state = ButtonState.Normal;
779 if (checkbox.FlatStyle == FlatStyle.Flat) {
780 state |= ButtonState.Flat;
783 if (checkbox.Checked) {
784 state |= ButtonState.Checked;
787 if (checkbox.ThreeState && (checkbox.CheckState == CheckState.Indeterminate)) {
788 state |= ButtonState.Checked;
789 state |= ButtonState.Pushed;
792 // finally make sure the pushed and inavtive states are rendered
793 if (!checkbox.Enabled) {
794 state |= ButtonState.Inactive;
796 else if (checkbox.is_pressed) {
797 state |= ButtonState.Pushed;
803 sb=new SolidBrush(checkbox.BackColor);
804 dc.FillRectangle(sb, checkbox.ClientRectangle);
807 // render as per normal button
808 if (checkbox.appearance==Appearance.Button) {
809 if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
810 DrawFlatStyleButton(dc, checkbox.ClientRectangle, checkbox);
812 CPDrawButton(dc, checkbox.ClientRectangle, state);
815 // establish if we are rendering a flat style of some sort
816 if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
817 DrawFlatStyleCheckBox (dc, checkbox_rectangle, checkbox);
819 ControlPaint.DrawCheckBox(dc, checkbox_rectangle, state);
823 // offset the text if it's pressed and a button
824 if (checkbox.Appearance == Appearance.Button) {
825 if (checkbox.Checked || (checkbox.Capture && checkbox.FlatStyle != FlatStyle.Flat)) {
830 text_rectangle.Inflate(-4, -4);
833 /* Place the text; to be compatible with Windows place it after the checkbox has been drawn */
834 if (checkbox.Enabled) {
835 sb = ResPool.GetSolidBrush(checkbox.ForeColor);
836 dc.DrawString(checkbox.Text, checkbox.Font, sb, text_rectangle, text_format);
837 } else if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
838 dc.DrawString(checkbox.Text, checkbox.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), text_rectangle, text_format);
840 CPDrawStringDisabled(dc, checkbox.Text, checkbox.Font, ColorButtonText, text_rectangle, text_format);
843 if (checkbox.Focused) {
844 if (checkbox.FlatStyle != FlatStyle.Flat) {
845 DrawInnerFocusRectangle (dc, Rectangle.Inflate (client_rectangle, -4, -4), checkbox.BackColor);
847 dc.DrawRectangle (ResPool.GetPen (checkbox.ForeColor), Rectangle.Inflate (client_rectangle, -4, -4));
852 // renders a checkBox with the Flat and Popup FlatStyle
853 private void DrawFlatStyleCheckBox (Graphics graphics, Rectangle rectangle, CheckBox checkbox)
857 Rectangle checkbox_rectangle;
858 Rectangle fill_rectangle;
862 // set up our rectangles first
863 if (checkbox.FlatStyle == FlatStyle.Popup && checkbox.is_entered) {
864 // clip one pixel from bottom right for non popup rendered checkboxes
865 checkbox_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max(rectangle.Width-1, 0), Math.Max(rectangle.Height-1,0));
866 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));
868 // clip two pixels from bottom right for non popup rendered checkboxes
869 checkbox_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max(rectangle.Width-2, 0), Math.Max(rectangle.Height-2,0));
870 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));
873 // if disabled render in disabled state
874 if (checkbox.Enabled) {
875 // process the state of the checkbox
876 if (checkbox.is_entered || checkbox.Capture) {
877 // decide on which background color to use
878 if (checkbox.FlatStyle == FlatStyle.Popup && checkbox.is_entered && checkbox.Capture) {
879 graphics.FillRectangle(ResPool.GetSolidBrush (checkbox.BackColor), fill_rectangle);
880 } else if (checkbox.FlatStyle == FlatStyle.Flat && !(checkbox.is_entered && checkbox.Capture)) {
881 graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.Light(checkbox.BackColor)), fill_rectangle);
883 // use regular window background color
884 graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);
887 // render the outer border
888 if (checkbox.FlatStyle == FlatStyle.Flat) {
889 ControlPaint.DrawBorder(graphics, checkbox_rectangle, checkbox.ForeColor, ButtonBorderStyle.Solid);
891 // draw sunken effect
892 CPDrawBorder3D (graphics, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.All, checkbox.BackColor);
895 graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);
897 if (checkbox.FlatStyle == FlatStyle.Flat) {
898 ControlPaint.DrawBorder(graphics, checkbox_rectangle, checkbox.ForeColor, ButtonBorderStyle.Solid);
900 // draw the outer border
901 ControlPaint.DrawBorder(graphics, checkbox_rectangle, ControlPaint.DarkDark (checkbox.BackColor), ButtonBorderStyle.Solid);
905 if (checkbox.FlatStyle == FlatStyle.Popup) {
906 graphics.FillRectangle(SystemBrushes.Control, fill_rectangle);
909 // draw disabled state,
910 ControlPaint.DrawBorder(graphics, checkbox_rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
913 /* Make sure we've got at least a line width of 1 */
914 lineWidth = Math.Max(3, fill_rectangle.Width/3);
915 Scale=Math.Max(1, fill_rectangle.Width/9);
917 // flat style check box is rendered inside a rectangle shifted down by one
918 rect=new Rectangle(fill_rectangle.X, fill_rectangle.Y+1, fill_rectangle.Width, fill_rectangle.Height);
919 if (checkbox.Enabled) {
920 pen=ResPool.GetPen(checkbox.ForeColor);
922 pen=SystemPens.ControlDark;
925 if (checkbox.Checked) {
926 /* Need to draw a check-mark */
927 for (int i=0; i<lineWidth; i++) {
928 graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
929 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);
935 #endregion // CheckBox
938 public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box) {
941 Rectangle rect = box.ClientRectangle;
942 Color disabled = ColorGrayText;
944 Pen pen_light = ResPool.GetPen (Color.FromArgb (255,255,255,255));
945 Pen pen_dark = ResPool.GetPen (Color.FromArgb (255, 128, 128,128));
947 // TODO: When the Light and Dark methods work this code should be activate it
948 //Pen pen_light = new Pen (ControlPaint.Light (disabled, 1));
949 //Pen pen_dark = new Pen (ControlPaint.Dark (disabled, 0));
951 dc.FillRectangle (ResPool.GetSolidBrush (box.BackColor), rect);
953 size = dc.MeasureString (box.Text, box.Font);
954 width = (int) size.Width;
956 if (width > box.Width - 16)
957 width = box.Width - 16;
959 y = box.Font.Height / 2;
962 dc.DrawLine (pen_dark, 0, y, 8, y); // top
963 dc.DrawLine (pen_light, 0, y + 1, 8, y + 1);
964 dc.DrawLine (pen_dark, 8 + width, y, box.Width, y);
965 dc.DrawLine (pen_light, 8 + width, y + 1, box.Width, y + 1);
967 dc.DrawLine (pen_dark, 0, y + 1, 0, box.Height); // left
968 dc.DrawLine (pen_light, 1, y + 1, 1, box.Height);
970 dc.DrawLine (pen_dark, 0, box.Height - 2, box.Width, box.Height - 2); // bottom
971 dc.DrawLine (pen_light, 0, box.Height - 1, box.Width, box.Height - 1);
973 dc.DrawLine (pen_dark, box.Width - 2, y, box.Width - 2, box.Height - 2); // right
974 dc.DrawLine (pen_light, box.Width - 1, y, box.Width - 1, box.Height - 2);
979 dc.DrawString (box.Text, box.Font, new SolidBrush (box.ForeColor), 10, 0);
981 CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor,
982 new RectangleF (10, 0, width, box.Font.Height), new StringFormat ());
986 public override Size GroupBoxDefaultSize {
988 return new Size (200,100);
994 public override Size HScrollBarDefaultSize {
996 return new Size (80, this.ScrollBarButtonSize);
1000 #endregion // HScrollBar
1003 public override void DrawLabel (Graphics dc, Rectangle clip_rectangle, Label label) {
1004 if (label_br_fore_color == null || label_br_fore_color.Color != label.ForeColor) {
1005 label_br_fore_color = GetControlForeBrush (label.ForeColor);
1008 if (label_br_back_color == null || label_br_back_color.Color != label.BackColor) {
1009 label_br_back_color = GetControlBackBrush (label.BackColor);
1012 dc.FillRectangle (label_br_back_color, clip_rectangle);
1014 CPDrawBorderStyle (dc, clip_rectangle, label.BorderStyle);
1016 if (label.Enabled) {
1017 dc.DrawString (label.Text, label.Font, label_br_fore_color, clip_rectangle, label.string_format);
1019 ControlPaint.DrawStringDisabled (dc, label.Text, label.Font, label.ForeColor, clip_rectangle, label.string_format);
1024 public override Size LabelDefaultSize {
1026 return new Size (100, 23);
1033 public override void DrawListView (Graphics dc, Rectangle clip_rectangle, ListView control)
1035 Rectangle control_area = control.ClientRectangle;
1036 bool details = (control.View == View.Details);
1038 // Draw the border of the list view with a background
1039 dc.FillRectangle (ResPool.GetSolidBrush (control.BackColor), control_area);
1040 this.CPDrawBorderStyle (dc, control_area, control.BorderStyle);
1042 dc.FillRectangle (ResPool.GetSolidBrush (SystemColors.Control),
1043 0, 0, control.TotalWidth, control.Font.Height);
1044 if (control.Columns.Count > 0) {
1045 foreach (ColumnHeader col in control.Columns) {
1046 this.CPDrawButton (dc, col.Rect, ButtonState.Normal);
1047 dc.DrawString (col.Text, control.Font,
1048 ResPool.GetSolidBrush (this.ColorButtonText),
1049 col.Rect, col.Format);
1052 if (control.GridLines) {
1053 // draw vertical gridlines
1054 foreach (ColumnHeader col in control.Columns)
1055 dc.DrawLine (this.ResPool.GetPen (this.ColorButtonFace),
1056 col.Rect.Right, col.Rect.Bottom,
1057 col.Rect.Right, control.TotalHeight);
1058 // draw horizontal gridlines
1059 foreach (ListViewItem item in control.Items)
1060 dc.DrawLine (this.ResPool.GetPen (this.ColorButtonFace),
1061 item.EntireRect.Left, item.EntireRect.Bottom,
1062 control.TotalWidth, item.EntireRect.Bottom);
1066 foreach (ListViewItem item in control.Items)
1067 this.DrawListViewItem (dc, control, item);
1070 // draws the ListViewItem of the given index
1071 private void DrawListViewItem (Graphics dc, ListView control, ListViewItem item)
1073 if (control.CheckBoxes) {
1074 if (control.StateImageList == null) {
1075 // Make sure we've got at least a line width of 1
1076 int check_wd = Math.Max (3, item.CheckRect.Width / 6);
1077 int scale = Math.Max (1, item.CheckRect.Width / 12);
1079 // define a rectangle inside the border area
1080 Rectangle rect = new Rectangle (item.CheckRect.X + 2,
1081 item.CheckRect.Y + 2,
1082 item.CheckRect.Width - 4,
1083 item.CheckRect.Height - 4);
1084 Pen pen = new Pen (SystemColors.WindowText, 2);
1085 dc.DrawRectangle (pen, rect);
1087 // Need to draw a check-mark
1090 // adjustments to get the check-mark at the right place
1091 rect.X ++; rect.Y ++;
1092 // following logic is taken from DrawFrameControl method
1093 for (int i = 0; i < check_wd; i++) {
1094 dc.DrawLine (pen, rect.Left + check_wd / 2,
1095 rect.Top + check_wd + i,
1096 rect.Left + check_wd / 2 + 2 * scale,
1097 rect.Top + check_wd + 2 * scale + i);
1099 rect.Left + check_wd / 2 + 2 * scale,
1100 rect.Top + check_wd + 2 * scale + i,
1101 rect.Left + check_wd / 2 + 6 * scale,
1102 rect.Top + check_wd - 2 * scale + i);
1107 if (item.Checked && control.StateImageList.Images.Count > 1)
1108 control.StateImageList.Draw (dc,
1109 item.CheckRect.Location, 1);
1110 else if (! item.Checked && control.StateImageList.Images.Count > 0)
1111 control.StateImageList.Draw (dc,
1112 item.CheckRect.Location, 0);
1116 // Item is drawn as a special case, as it is not just text
1117 if (control.View == View.LargeIcon) {
1118 if (item.ImageIndex > -1 &&
1119 control.LargeImageList != null &&
1120 item.ImageIndex < control.LargeImageList.Images.Count)
1121 control.LargeImageList.Draw (dc, item.IconRect.Location,
1125 if (item.ImageIndex > -1 &&
1126 control.SmallImageList != null &&
1127 item.ImageIndex < control.SmallImageList.Images.Count)
1128 control.SmallImageList.Draw (dc, item.IconRect.Location,
1132 // draw the item text
1133 Rectangle text_rect = Rectangle.Empty;
1134 text_rect.X = item.LabelRect.X + 1;
1135 text_rect.Y = item.LabelRect.Y + 1;
1136 text_rect.Width = item.LabelRect.Width - 3;
1137 text_rect.Height = item.LabelRect.Height - 2;
1139 // format for the item text
1140 StringFormat format = new StringFormat ();
1141 format.LineAlignment = StringAlignment.Center;
1142 if (control.View == View.LargeIcon)
1143 format.Alignment = StringAlignment.Center;
1145 format.Alignment = StringAlignment.Near;
1147 if (!control.LabelWrap)
1148 format.FormatFlags = StringFormatFlags.NoWrap;
1150 dc.FillRectangle (ResPool.GetSolidBrush (item.BackColor), text_rect);
1151 if (item.Text != null && item.Text.Length > 0)
1152 dc.DrawString (item.Text, item.Font, this.ResPool.GetSolidBrush
1153 (item.ForeColor), text_rect, format);
1155 if (control.View == View.Details && control.Columns.Count > 0) {
1156 // draw subitems for details view
1157 ListViewItem.ListViewSubItemCollection subItems = item.SubItems;
1158 int count = (control.Columns.Count < subItems.Count ?
1159 control.Columns.Count : subItems.Count);
1162 Rectangle sub_item_rect = Rectangle.Empty;
1163 sub_item_rect.X = item.LabelRect.Right + 1;
1164 sub_item_rect.Y = item.LabelRect.Y + 1;
1165 sub_item_rect.Height = item.LabelRect.Height - 2;
1167 ListViewItem.ListViewSubItem subItem;
1170 // set the format for subitems
1171 format.FormatFlags = StringFormatFlags.NoWrap;
1172 format.Alignment = StringAlignment.Near;
1174 // 0th subitem is the item already drawn
1175 for (int index = 1; index < count; index++) {
1176 subItem = subItems [index];
1177 col = control.Columns [index];
1178 sub_item_rect.Width = col.Wd - 3;
1180 if (item.UseItemStyleForSubItems) {
1181 dc.FillRectangle (this.ResPool.GetSolidBrush
1182 (item.BackColor), sub_item_rect);
1183 if (subItem.Text != null && subItem.Text.Length > 0)
1184 dc.DrawString (subItem.Text, item.Font,
1185 this.ResPool.GetSolidBrush
1187 sub_item_rect, format);
1190 dc.FillRectangle (this.ResPool.GetSolidBrush
1191 (subItem.BackColor),
1193 if (subItem.Text != null && subItem.Text.Length > 0)
1194 dc.DrawString (subItem.Text, subItem.Font,
1195 this.ResPool.GetSolidBrush
1196 (subItem.ForeColor),
1197 sub_item_rect, format);
1199 sub_item_rect.X += col.Wd;
1206 public override Size ListViewCheckBoxSize {
1207 get { return new Size (16, 16); }
1210 public override int ListViewColumnHeaderHeight {
1214 public override int ListViewDefaultColumnWidth {
1218 public override int ListViewVerticalSpacing {
1222 public override int ListViewEmptyColumnWidth {
1226 public override int ListViewHorizontalSpacing {
1230 public override Size ListViewDefaultSize {
1231 get { return new Size (121, 97); }
1233 #endregion // ListView
1236 public override Size PanelDefaultSize {
1238 return new Size (200, 100);
1244 public override void DrawPictureBox (Graphics dc, PictureBox pb) {
1245 Rectangle client = pb.ClientRectangle;
1246 int x, y, width, height;
1248 dc.FillRectangle (new SolidBrush (pb.BackColor), client);
1251 if (pb.Image != null) {
1252 switch (pb.SizeMode) {
1253 case PictureBoxSizeMode.StretchImage:
1254 width = client.Width;
1255 height = client.Height;
1257 case PictureBoxSizeMode.CenterImage:
1258 width = client.Width;
1259 height = client.Height;
1261 y = (height - pb.Image.Height) / 2;
1265 width = client.Width;
1266 height = client.Height;
1269 dc.DrawImage (pb.Image, x, y, width, height);
1271 CPDrawBorderStyle (dc, client, pb.BorderStyle);
1274 public override Size PictureBoxDefaultSize {
1276 return new Size (100, 50);
1279 #endregion // PictureBox
1282 public override void DrawProgressBar (Graphics dc, Rectangle clip_rectangle, ProgressBar progress_bar) {
1283 Rectangle client_area = progress_bar.client_area;
1284 Rectangle paint_area = progress_bar.paint_area;
1285 int steps = (progress_bar.Maximum - progress_bar.Minimum) / progress_bar.step;
1286 int space_betweenblocks = 2;
1293 block_width = ((client_area.Height) * 2 ) / 3;
1294 barpos_pixels = ((progress_bar.Value - progress_bar.Minimum) * client_area.Width) / (progress_bar.Maximum - progress_bar.Minimum);
1295 increment = block_width + space_betweenblocks;
1298 CPDrawBorder3D (dc, progress_bar.paint_area, Border3DStyle.SunkenInner, Border3DSide.All, ColorButtonFace);
1301 while ((x - client_area.X) < barpos_pixels) {
1302 dc.FillRectangle (br_progressbarblock, x, client_area.Y, block_width, client_area.Height);
1307 public override Size ProgressBarDefaultSize {
1309 return new Size (100, 23);
1313 #endregion // ProgressBar
1316 public override void DrawRadioButton (Graphics dc, Rectangle clip_rectangle, RadioButton radio_button) {
1317 StringFormat text_format;
1318 Rectangle client_rectangle;
1319 Rectangle text_rectangle;
1320 Rectangle radiobutton_rectangle;
1322 int radiobutton_size = 12;
1323 int radiobutton_space = 4;
1325 client_rectangle = radio_button.ClientRectangle;
1326 text_rectangle = client_rectangle;
1327 radiobutton_rectangle = new Rectangle(text_rectangle.X, text_rectangle.Y, radiobutton_size, radiobutton_size);
1329 text_format = new StringFormat();
1330 text_format.Alignment = StringAlignment.Near;
1331 text_format.LineAlignment = StringAlignment.Center;
1333 /* Calculate the position of text and checkbox rectangle */
1334 if (radio_button.appearance!=Appearance.Button) {
1335 switch(radio_button.radiobutton_alignment) {
1336 case ContentAlignment.BottomCenter: {
1337 radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
1338 radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
1339 text_rectangle.X=client_rectangle.X;
1340 text_rectangle.Width=client_rectangle.Width;
1341 text_rectangle.Height=client_rectangle.Height-radiobutton_size-radiobutton_space;
1345 case ContentAlignment.BottomLeft: {
1346 radiobutton_rectangle.X=client_rectangle.Left;
1347 radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
1348 text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
1349 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
1353 case ContentAlignment.BottomRight: {
1354 radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
1355 radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
1356 text_rectangle.X=client_rectangle.X;
1357 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
1361 case ContentAlignment.MiddleCenter: {
1362 radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
1363 radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
1364 text_rectangle.X=client_rectangle.X;
1365 text_rectangle.Width=client_rectangle.Width;
1370 case ContentAlignment.MiddleLeft: {
1371 radiobutton_rectangle.X=client_rectangle.Left;
1372 radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
1373 text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
1374 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
1378 case ContentAlignment.MiddleRight: {
1379 radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
1380 radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
1381 text_rectangle.X=client_rectangle.X;
1382 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
1386 case ContentAlignment.TopCenter: {
1387 radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
1388 radiobutton_rectangle.Y=client_rectangle.Top;
1389 text_rectangle.X=client_rectangle.X;
1390 text_rectangle.Y=radiobutton_size+radiobutton_space;
1391 text_rectangle.Width=client_rectangle.Width;
1392 text_rectangle.Height=client_rectangle.Height-radiobutton_size-radiobutton_space;
1396 case ContentAlignment.TopLeft: {
1397 radiobutton_rectangle.X=client_rectangle.Left;
1398 radiobutton_rectangle.Y=client_rectangle.Top;
1399 text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
1400 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
1404 case ContentAlignment.TopRight: {
1405 radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
1406 radiobutton_rectangle.Y=client_rectangle.Top;
1407 text_rectangle.X=client_rectangle.X;
1408 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
1413 text_rectangle.X=client_rectangle.X;
1414 text_rectangle.Width=client_rectangle.Width;
1417 /* Set the horizontal alignment of our text */
1418 switch(radio_button.text_alignment) {
1419 case ContentAlignment.BottomLeft:
1420 case ContentAlignment.MiddleLeft:
1421 case ContentAlignment.TopLeft: {
1422 text_format.Alignment=StringAlignment.Near;
1426 case ContentAlignment.BottomCenter:
1427 case ContentAlignment.MiddleCenter:
1428 case ContentAlignment.TopCenter: {
1429 text_format.Alignment=StringAlignment.Center;
1433 case ContentAlignment.BottomRight:
1434 case ContentAlignment.MiddleRight:
1435 case ContentAlignment.TopRight: {
1436 text_format.Alignment=StringAlignment.Far;
1441 /* Set the vertical alignment of our text */
1442 switch(radio_button.text_alignment) {
1443 case ContentAlignment.TopLeft:
1444 case ContentAlignment.TopCenter:
1445 case ContentAlignment.TopRight: {
1446 text_format.LineAlignment=StringAlignment.Near;
1450 case ContentAlignment.BottomLeft:
1451 case ContentAlignment.BottomCenter:
1452 case ContentAlignment.BottomRight: {
1453 text_format.LineAlignment=StringAlignment.Far;
1457 case ContentAlignment.MiddleLeft:
1458 case ContentAlignment.MiddleCenter:
1459 case ContentAlignment.MiddleRight: {
1460 text_format.LineAlignment=StringAlignment.Center;
1465 ButtonState state = ButtonState.Normal;
1466 if (radio_button.FlatStyle == FlatStyle.Flat) {
1467 state |= ButtonState.Flat;
1470 if (radio_button.Checked) {
1471 state |= ButtonState.Checked;
1476 sb=new SolidBrush(radio_button.BackColor);
1477 dc.FillRectangle(sb, radio_button.ClientRectangle);
1482 if (radio_button.appearance==Appearance.Button) {
1483 if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
1484 DrawFlatStyleButton(dc, radio_button.ClientRectangle, radio_button);
1486 CPDrawButton(dc, radio_button.ClientRectangle, state);
1489 // establish if we are rendering a flat style of some sort
1490 if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
1491 DrawFlatStyleRadioButton (dc, radiobutton_rectangle, radio_button);
1493 ControlPaint.DrawRadioButton (dc, radiobutton_rectangle, state);
1497 // offset the text if it's pressed and a button
1498 if (radio_button.Appearance == Appearance.Button) {
1499 if (radio_button.Checked || (radio_button.Capture && radio_button.FlatStyle != FlatStyle.Flat)) {
1500 text_rectangle.X ++;
1501 text_rectangle.Y ++;
1504 text_rectangle.Inflate(-4,-4);
1507 /* Place the text; to be compatible with Windows place it after the radiobutton has been drawn */
1508 sb=new SolidBrush(radio_button.ForeColor);
1509 dc.DrawString (radio_button.Text, radio_button.Font, sb, text_rectangle, text_format);
1511 if (radio_button.Enabled) {
1512 sb = ResPool.GetSolidBrush(radio_button.ForeColor);
1513 dc.DrawString(radio_button.Text, radio_button.Font, sb, text_rectangle, text_format);
1514 } else if (radio_button.FlatStyle == FlatStyle.Flat) {
1515 dc.DrawString(radio_button.Text, radio_button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), text_rectangle, text_format);
1517 CPDrawStringDisabled(dc, radio_button.Text, radio_button.Font, this.ColorButtonText, text_rectangle, text_format);
1520 if (radio_button.Focused) {
1521 if (radio_button.FlatStyle != FlatStyle.Flat) {
1522 DrawInnerFocusRectangle (dc, text_rectangle, radio_button.BackColor);
1524 dc.DrawRectangle (ResPool.GetPen (radio_button.ForeColor), text_rectangle);
1529 // renders a radio button with the Flat and Popup FlatStyle
1530 private void DrawFlatStyleRadioButton (Graphics graphics, Rectangle rectangle, RadioButton radio_button)
1534 if (radio_button.Enabled) {
1535 // draw the outer flatstyle arcs
1536 if (radio_button.FlatStyle == FlatStyle.Flat) {
1537 graphics.DrawArc (ResPool.GetPen (radio_button.ForeColor), rectangle, 0, 359);
1539 // fill in the area depending on whether or not the mouse is hovering
1540 if (radio_button.is_entered && radio_button.Capture) {
1541 graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.Light (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
1543 graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
1546 // must be a popup radio button
1548 graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 0, 359);
1550 if (radio_button.is_entered || radio_button.Capture) {
1551 // draw the popup 3d button knob
1552 graphics.DrawArc (ResPool.GetPen (ControlPaint.Light (radio_button.BackColor)), rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 0, 359);
1554 graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (radio_button.BackColor)), rectangle, 135, 180);
1555 graphics.DrawArc (ResPool.GetPen (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 315, 180);
1558 // just draw lighter flatstyle outer circle
1559 graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (this.ColorButtonFace)), rectangle, 0, 359);
1564 // fill control background color regardless of actual backcolor
1565 graphics.FillPie (ResPool.GetSolidBrush (this.ColorButtonFace), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
1566 // draw the ark as control dark
1567 graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark(this.ColorButtonFace)), rectangle, 0, 359);
1571 lineWidth = Math.Max (1, Math.Min(rectangle.Width, rectangle.Height)/3);
1572 if (radio_button.Checked) {
1573 SolidBrush buttonBrush;
1575 if (!radio_button.Enabled) {
1576 buttonBrush = ResPool.GetSolidBrush (ControlPaint.Dark (this.ColorButtonFace));
1577 } else if (radio_button.FlatStyle == FlatStyle.Popup && radio_button.is_entered && radio_button.Capture) {
1578 buttonBrush = ResPool.GetSolidBrush (this.ColorButtonText);
1580 buttonBrush = ResPool.GetSolidBrush (radio_button.ForeColor);
1582 graphics.FillPie (buttonBrush, rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2, 0, 359);
1586 public override Size RadioButtonDefaultSize {
1588 return new Size (104,24);
1591 #endregion // RadioButton
1594 public override void DrawScrollBar(Graphics dc, Rectangle clip_rectangle, ScrollBar bar) {
1595 int scrollbutton_width = bar.scrollbutton_width;
1596 int scrollbutton_height = bar.scrollbutton_height;
1597 Rectangle first_arrow_area;
1598 Rectangle second_arrow_area;
1599 Rectangle thumb_pos;
1601 thumb_pos = bar.ThumbPos;
1604 first_arrow_area = new Rectangle(0, 0, bar.Width, scrollbutton_height);
1605 bar.FirstArrowArea = first_arrow_area;
1607 second_arrow_area = new Rectangle(0, bar.ClientRectangle.Height - scrollbutton_height, bar.Width, scrollbutton_height);
1608 bar.SecondArrowArea = second_arrow_area;
1610 thumb_pos.Width = bar.Width;
1611 bar.ThumbPos = thumb_pos;
1614 CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state);
1615 CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state);
1618 switch (bar.thumb_moving) {
1619 case ScrollBar.ThumbMoving.None: {
1620 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), 0,
1621 scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - (scrollbutton_height * 2));
1625 case ScrollBar.ThumbMoving.Forward: {
1626 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
1627 0, scrollbutton_height,
1628 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height);
1630 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
1631 0, thumb_pos.Y + thumb_pos.Height,
1632 bar.ClientRectangle.Width, bar.ClientRectangle.Height - (thumb_pos.Y + thumb_pos.Height) - scrollbutton_height);
1637 case ScrollBar.ThumbMoving.Backwards: {
1638 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
1639 0, scrollbutton_height,
1640 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height);
1642 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
1643 0, thumb_pos.Y + thumb_pos.Height,
1644 bar.ClientRectangle.Width, bar.ClientRectangle.Height - (thumb_pos.Y + thumb_pos.Height) - scrollbutton_height);
1655 first_arrow_area = new Rectangle(0, 0, scrollbutton_width, bar.Height);
1656 bar.FirstArrowArea = first_arrow_area;
1658 second_arrow_area = new Rectangle (bar.ClientRectangle.Width - scrollbutton_width, 0, scrollbutton_width, bar.Height);
1659 bar.SecondArrowArea = second_arrow_area;
1661 thumb_pos.Height = bar.Height;
1662 bar.ThumbPos = thumb_pos;
1665 CPDrawScrollButton (dc, bar.FirstArrowArea, ScrollButton.Left, bar.firstbutton_state);
1666 CPDrawScrollButton (dc, bar.SecondArrowArea, ScrollButton.Right, bar.secondbutton_state);
1669 //dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), scrollbutton_width,
1670 // 0, area.Width - (scrollbutton_width * 2), area.Height);
1672 switch (bar.thumb_moving) {
1673 case ScrollBar.ThumbMoving.None: {
1674 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), scrollbutton_width,
1675 0, bar.ClientRectangle.Width - (scrollbutton_width * 2), bar.ClientRectangle.Height);
1680 case ScrollBar.ThumbMoving.Forward: {
1681 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
1682 scrollbutton_width, 0,
1683 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height);
1685 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
1686 thumb_pos.X + thumb_pos.Width, 0,
1687 bar.ClientRectangle.Width - (thumb_pos.X + thumb_pos.Width) - scrollbutton_width, bar.ClientRectangle.Height);
1692 case ScrollBar.ThumbMoving.Backwards: {
1693 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
1694 scrollbutton_width, 0,
1695 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height);
1697 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
1698 thumb_pos.X + thumb_pos.Width, 0,
1699 bar.ClientRectangle.Width - (thumb_pos.X + thumb_pos.Width) - scrollbutton_width, bar.ClientRectangle.Height);
1712 DrawScrollButtonPrimitive (dc, thumb_pos, ButtonState.Normal);
1715 public override int ScrollBarButtonSize {
1718 #endregion // ScrollBar
1721 public override void DrawStatusBar (Graphics dc, Rectangle clip_rectangle, StatusBar sb) {
1722 Rectangle area = sb.paint_area;
1723 int horz_border = 2;
1724 int vert_border = 2;
1726 dc.FillRectangle (GetControlBackBrush (sb.BackColor), area);
1728 if (sb.ShowPanels && sb.Panels.Count == 0) {
1729 // Create a default panel.
1730 SolidBrush br_forecolor = GetControlForeBrush (sb.ForeColor);
1732 StatusBarPanel panel = new StatusBarPanel ();
1733 Rectangle new_area = new Rectangle (area.X + horz_border,
1734 area.Y + horz_border,
1735 area.Width - StatusBarSizeGripWidth - horz_border,
1736 area.Height - horz_border);
1737 DrawStatusBarPanel (dc, new_area, -1, br_forecolor, panel);
1738 } else if (sb.ShowPanels) {
1739 SolidBrush br_forecolor = GetControlForeBrush (sb.ForeColor);
1740 int prev_x = area.X + horz_border;
1741 int y = area.Y + vert_border;
1742 for (int i = 0; i < sb.Panels.Count; i++) {
1743 Rectangle pr = new Rectangle (prev_x, y,
1744 sb.Panels [i].Width, area.Height);
1745 prev_x += pr.Width + StatusBarHorzGapWidth;
1746 DrawStatusBarPanel (dc, pr, i, br_forecolor, sb.Panels [i]);
1751 CPDrawSizeGrip (dc, ColorButtonFace, area);
1756 private void DrawStatusBarPanel (Graphics dc, Rectangle area, int index,
1757 SolidBrush br_forecolor, StatusBarPanel panel) {
1758 int border_size = 3; // this is actually const, even if the border style is none
1760 area.Height -= border_size;
1761 if (panel.BorderStyle != StatusBarPanelBorderStyle.None) {
1762 Border3DStyle border_style = Border3DStyle.SunkenInner;
1763 if (panel.BorderStyle == StatusBarPanelBorderStyle.Raised)
1764 border_style = Border3DStyle.RaisedOuter;
1765 CPDrawBorder3D(dc, area, border_style, Border3DSide.All, ColorButtonFace);
1768 if (panel.Style == StatusBarPanelStyle.OwnerDraw) {
1769 StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs (
1770 dc, panel.Parent.Font, area, index, DrawItemState.Default,
1771 panel, panel.Parent.ForeColor, panel.Parent.BackColor);
1772 panel.Parent.OnDrawItemInternal (e);
1776 int left = area.Left;
1777 if (panel.Icon != null) {
1779 int size = area.Height - border_size;
1780 Rectangle ia = new Rectangle (left, border_size, size, size);
1781 dc.DrawIcon (panel.Icon, left, area.Top);
1782 left += panel.Icon.Width;
1785 if (panel.Text == String.Empty)
1788 string text = panel.Text;
1789 StringFormat string_format = new StringFormat ();
1790 string_format.LineAlignment = StringAlignment.Center;
1791 string_format.Alignment = StringAlignment.Near;
1792 string_format.FormatFlags = StringFormatFlags.NoWrap;
1794 if (text [0] == '\t') {
1795 string_format.Alignment = StringAlignment.Center;
1796 text = text.Substring (1);
1797 if (text [0] == '\t') {
1798 string_format.Alignment = StringAlignment.Far;
1799 text = text.Substring (1);
1803 float x = left + border_size;
1804 float y = ((area.Bottom - area.Top) / 2.0F) + border_size;
1806 dc.DrawString (text, panel.Parent.Font, br_forecolor, x, y, string_format);
1809 public override int StatusBarSizeGripWidth {
1813 public override int StatusBarHorzGapWidth {
1817 public override Size StatusBarDefaultSize {
1819 return new Size (100, 22);
1822 #endregion // StatusBar
1824 public override void DrawTabControl (Graphics dc, Rectangle area, TabControl tab)
1826 // Do we need to fill the back color? It can't be changed...
1827 dc.FillRectangle (GetControlBackBrush (tab.BackColor), area);
1828 Rectangle panel_rect = GetTabPanelRectExt (tab);
1830 if (tab.Appearance == TabAppearance.Normal) {
1831 CPDrawBorder3D (dc, panel_rect, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, ColorButtonFace);
1832 CPDrawBorder3D (dc, panel_rect, Border3DStyle.Raised, Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
1835 if (tab.Alignment == TabAlignment.Top) {
1836 for (int r = tab.TabPages.Count; r > 0; r--) {
1837 for (int i = 0; i < tab.TabPages.Count; i++) {
1838 if (i == tab.SelectedIndex)
1840 if (r != tab.TabPages [i].Row)
1842 Rectangle rect = tab.GetTabRect (i);
1843 if (!rect.IntersectsWith (area))
1845 DrawTab (dc, tab.TabPages [i], tab, rect, false);
1849 for (int r = 0; r < tab.TabPages.Count; r++) {
1850 for (int i = 0; i < tab.TabPages.Count; i++) {
1851 if (i == tab.SelectedIndex)
1853 if (r != tab.TabPages [i].Row)
1855 Rectangle rect = tab.GetTabRect (i);
1856 if (!rect.IntersectsWith (area))
1858 DrawTab (dc, tab.TabPages [i], tab, rect, false);
1863 if (tab.SelectedIndex != -1) {
1864 DrawTab (dc, tab.TabPages [tab.SelectedIndex], tab, tab.GetTabRect (tab.SelectedIndex), true);
1867 if (tab.ShowSlider) {
1868 Rectangle right = GetTabControlRightScrollRect (tab);
1869 Rectangle left = GetTabControlLeftScrollRect (tab);
1870 CPDrawScrollButton (dc, right, ScrollButton.Right, tab.RightSliderState);
1871 CPDrawScrollButton (dc, left, ScrollButton.Left, tab.LeftSliderState);
1875 public override Rectangle GetTabControlLeftScrollRect (TabControl tab)
1877 switch (tab.Alignment) {
1878 case TabAlignment.Top:
1879 return new Rectangle (tab.ClientRectangle.Right - 34, tab.ClientRectangle.Top + 1, 17, 17);
1881 Rectangle panel_rect = GetTabPanelRectExt (tab);
1882 return new Rectangle (tab.ClientRectangle.Right - 34, panel_rect.Bottom + 2, 17, 17);
1886 public override Rectangle GetTabControlRightScrollRect (TabControl tab)
1888 switch (tab.Alignment) {
1889 case TabAlignment.Top:
1890 return new Rectangle (tab.ClientRectangle.Right - 17, tab.ClientRectangle.Top + 1, 17, 17);
1892 Rectangle panel_rect = GetTabPanelRectExt (tab);
1893 return new Rectangle (tab.ClientRectangle.Right - 17, panel_rect.Bottom + 2, 17, 17);
1897 public override Size TabControlDefaultItemSize {
1898 get { return new Size (42, 21); }
1901 public override Point TabControlDefaultPadding {
1902 get { return new Point (6, 3); }
1905 public override int TabControlMinimumTabWidth {
1909 public override Rectangle GetTabControlDisplayRectangle (TabControl tab)
1911 Rectangle ext = GetTabPanelRectExt (tab);
1912 // Account for border size
1913 return new Rectangle (ext.Left + 2, ext.Top + 1, ext.Width - 6, ext.Height - 4);
1916 public override Size TabControlGetSpacing (TabControl tab) {
1917 switch (tab.Appearance) {
1918 case TabAppearance.Normal:
1919 return new Size (1, -2);
1920 case TabAppearance.Buttons:
1921 return new Size (3, 3);
1922 case TabAppearance.FlatButtons:
1923 return new Size (9, 3);
1925 throw new Exception ("Invalid Appearance value: " + tab.Appearance);
1929 private Rectangle GetTabPanelRectExt (TabControl tab)
1931 // Offset the tab from the top corner
1932 Rectangle res = new Rectangle (tab.ClientRectangle.X + 2,
1933 tab.ClientRectangle.Y,
1934 tab.ClientRectangle.Width - 2,
1935 tab.ClientRectangle.Height - 1);
1937 if (tab.TabCount == 0)
1940 int spacing = TabControlGetSpacing (tab).Height;
1941 int offset = (tab.ItemSize.Height + spacing) * tab.RowCount + 3;
1943 switch (tab.Alignment) {
1944 case TabAlignment.Left:
1946 res.Width -= offset;
1948 case TabAlignment.Right:
1949 res.Width -= offset;
1951 case TabAlignment.Top:
1953 res.Height -= offset;
1955 case TabAlignment.Bottom:
1956 res.Height -= offset;
1963 private int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
1965 int FlatButtonSpacing = 8;
1966 int RoundCornerSize = 5;
1968 int res = bounds.Width;
1970 // we can't fill the background right away because the bounds might be adjusted if the tab is selected
1972 if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) {
1974 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
1977 if (tab.Appearance == TabAppearance.FlatButtons) {
1978 int width = bounds.Width;
1979 bounds.Width += (FlatButtonSpacing - 2);
1981 CPDrawBorder3D (dc, bounds, Border3DStyle.Etched, Border3DSide.Right);
1982 bounds.Width = width;
1986 CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.All);
1987 } else if (tab.Appearance != TabAppearance.FlatButtons) {
1988 CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.All);
1991 interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4);
1993 Pen light = ResPool.GetPen (ControlPaint.LightLight (tab.BackColor));
1995 switch (tab.Alignment) {
1997 case TabAlignment.Top:
2000 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
2002 dc.DrawLine (light, bounds.Left, bounds.Bottom, bounds.Left, bounds.Top + 3);
2003 dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
2004 dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right - 3, bounds.Top);
2006 dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom);
2007 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 1, bounds.Top + 2, bounds.Right, bounds.Top + 3);
2008 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom);
2010 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
2012 if (page.Text != String.Empty) {
2013 StringFormat string_format = new StringFormat ();
2014 string_format.Alignment = StringAlignment.Center;
2015 string_format.LineAlignment = StringAlignment.Center;
2016 string_format.FormatFlags = StringFormatFlags.NoWrap;
2018 dc.DrawString (page.Text, page.Font, new SolidBrush (SystemColors.ControlText), interior, string_format);
2023 case TabAlignment.Bottom:
2025 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
2027 dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 3);
2028 dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left + 2, bounds.Bottom - 1);
2030 dc.DrawLine (SystemPens.ControlDark, bounds.Left + 3, bounds.Bottom - 1, bounds.Right - 3, bounds.Bottom - 1);
2031 dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Bottom - 3, bounds.Right - 1, bounds.Top);
2033 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
2034 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 3, bounds.Bottom, bounds.Right, bounds.Bottom - 3);
2035 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom - 3, bounds.Right, bounds.Top);
2037 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
2039 if (page.Text != String.Empty) {
2040 StringFormat string_format = new StringFormat ();
2041 string_format.Alignment = StringAlignment.Center;
2042 string_format.LineAlignment = StringAlignment.Center;
2043 string_format.FormatFlags = StringFormatFlags.NoWrap;
2045 dc.DrawString (page.Text, page.Font, new SolidBrush (SystemColors.ControlText), interior, string_format);
2050 case TabAlignment.Left:
2052 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
2054 dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left, bounds.Top + 3);
2055 dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
2056 dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right, bounds.Top);
2058 dc.DrawLine (SystemPens.ControlDark, bounds.Right, bounds.Bottom - 1, bounds.Left + 2, bounds.Bottom - 1);
2060 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom, bounds.Left + 2, bounds.Bottom);
2061 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 2, bounds.Bottom, bounds.Left, bounds.Bottom - 3);
2063 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
2065 if (page.Text != String.Empty) {
2066 StringFormat string_format = new StringFormat ();
2067 // Flip the text around
2068 string_format.Alignment = StringAlignment.Center;
2069 string_format.LineAlignment = StringAlignment.Center;
2070 string_format.FormatFlags = StringFormatFlags.NoWrap;
2071 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
2072 int wo = interior.Width / 2;
2073 int ho = interior.Height / 2;
2074 dc.TranslateTransform (interior.X + wo, interior.Y + ho);
2075 dc.RotateTransform (180);
2076 dc.DrawString (page.Text, page.Font, new SolidBrush (SystemColors.ControlText), 0, 0, string_format);
2077 dc.ResetTransform ();
2083 // TabAlignment.Right
2085 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
2087 dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Right - 3, bounds.Top);
2088 dc.DrawLine (light, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3);
2090 dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom - 1);
2091 dc.DrawLine (SystemPens.ControlDark, bounds.Left, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1);
2093 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom - 3);
2094 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
2096 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
2098 if (page.Text != String.Empty) {
2099 StringFormat string_format = new StringFormat ();
2100 string_format.Alignment = StringAlignment.Center;
2101 string_format.LineAlignment = StringAlignment.Center;
2102 string_format.FormatFlags = StringFormatFlags.NoWrap;
2103 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
2105 dc.DrawString (page.Text, page.Font, new SolidBrush (SystemColors.ControlText), interior, string_format);
2114 using (Pen pen = new Pen (Color.Black, 1) ) {
2115 pen.DashStyle = DashStyle.Dot;
2116 dc.DrawRectangle (pen, interior);
2124 public override void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control) {
2125 StringFormat format = new StringFormat ();
2126 format.Trimming = StringTrimming.EllipsisWord;
2127 if (control.textAlignment == ToolBarTextAlign.Underneath) {
2128 format.LineAlignment = StringAlignment.Center;
2129 format.Alignment = StringAlignment.Center;
2131 format.LineAlignment = StringAlignment.Center;
2132 format.Alignment = StringAlignment.Near;
2135 // Exclude the area for divider
2136 Rectangle paint_area = new Rectangle (0, ToolBarGripWidth / 2,
2137 control.Width, control.Height - ToolBarGripWidth / 2);
2138 bool flat = (control.Appearance == ToolBarAppearance.Flat);
2139 dc.FillRectangle (SystemBrushes.Control, paint_area);
2140 CPDrawBorderStyle (dc, paint_area, control.BorderStyle);
2142 if (control.Divider)
2143 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), 0, 0, paint_area.Width, 0);
2145 foreach (ToolBarButton button in control.Buttons) {
2148 Rectangle buttonArea = button.Rectangle;
2149 Rectangle imgRect = Rectangle.Empty; // rect to draw the image
2150 Rectangle txtRect = buttonArea; // rect to draw the text
2151 Rectangle ddRect = Rectangle.Empty; // rect for the drop down arrow
2153 // calculate different rects and draw the frame if its not separator button
2154 if (button.Style != ToolBarButtonStyle.Separator) {
2155 /* Adjustment for drop down arrow */
2156 if (button.Style == ToolBarButtonStyle.DropDownButton && control.DropDownArrows) {
2157 ddRect.X = buttonArea.X + buttonArea.Width - this.ToolBarDropDownWidth;
2158 ddRect.Y = buttonArea.Y;
2159 ddRect.Width = this.ToolBarDropDownWidth;
2160 ddRect.Height = buttonArea.Height;
2163 // calculate txtRect and imgRect, if imageIndex and imageList are present
2164 if (button.ImageIndex > -1 && control.ImageList != null) {
2165 if (button.ImageIndex < control.ImageList.Images.Count)
2166 image = control.ImageList.Images [button.ImageIndex];
2167 // draw the image at the centre if textalignment is underneath
2168 if (control.TextAlign == ToolBarTextAlign.Underneath) {
2169 imgRect.X = buttonArea.X + ((buttonArea.Width - ddRect.Width
2170 - control.ImageSize.Width) / 2)
2171 + this.ToolBarImageGripWidth;
2172 imgRect.Y = buttonArea.Y + this.ToolBarImageGripWidth;
2173 imgRect.Width = control.ImageSize.Width;
2174 imgRect.Height = control.ImageSize.Height;
2176 txtRect.X = buttonArea.X;
2177 txtRect.Y = buttonArea.Y + imgRect.Height + 2 * this.ToolBarImageGripWidth;
2178 txtRect.Width = buttonArea.Width - ddRect.Width;
2179 txtRect.Height = buttonArea.Height - imgRect.Height
2180 - 2 * this.ToolBarImageGripWidth;
2183 imgRect.X = buttonArea.X + this.ToolBarImageGripWidth;
2184 imgRect.Y = buttonArea.Y + this.ToolBarImageGripWidth;
2185 imgRect.Width = control.ImageSize.Width;
2186 imgRect.Height = control.ImageSize.Height;
2188 txtRect.X = buttonArea.X + imgRect.Width + 2 * this.ToolBarImageGripWidth;
2189 txtRect.Y = buttonArea.Y;
2190 txtRect.Width = buttonArea.Width - imgRect.Width
2191 - 2 * this.ToolBarImageGripWidth - ddRect.Width;
2192 txtRect.Height = buttonArea.Height;
2195 /* Draw the button frame, only if it is not a separator */
2197 if (button.Pushed || button.Pressed) {
2198 CPDrawBorder3D (dc, buttonArea, Border3DStyle.SunkenOuter, Border3DSide.All, ColorButtonFace);
2199 } else if (button.Hilight) {
2200 dc.DrawRectangle (ResPool.GetPen (ColorButtonText), buttonArea);
2201 if (! ddRect.IsEmpty) {
2202 dc.DrawLine (ResPool.GetPen (ColorButtonText), ddRect.X, ddRect.Y, ddRect.X,
2203 ddRect.Y + ddRect.Height);
2204 buttonArea.Width -= this.ToolBarDropDownWidth;
2208 else { // normal toolbar
2209 if (button.Pushed || button.Pressed) {
2210 CPDrawBorder3D (dc, buttonArea, Border3DStyle.SunkenInner,
2211 Border3DSide.All, ColorButtonFace);
2212 if (! ddRect.IsEmpty) {
2213 CPDrawBorder3D (dc, ddRect, Border3DStyle.SunkenInner,
2214 Border3DSide.Left, ColorButtonFace);
2215 buttonArea.Width -= this.ToolBarDropDownWidth;
2219 CPDrawBorder3D (dc, buttonArea, Border3DStyle.RaisedInner,
2220 Border3DSide.All, ColorButtonFace);
2221 if (! ddRect.IsEmpty) {
2222 CPDrawBorder3D (dc, ddRect, Border3DStyle.RaisedInner,
2223 Border3DSide.Left, ColorButtonFace);
2224 buttonArea.Width -= this.ToolBarDropDownWidth;
2229 DrawToolBarButton (dc, button, control.Font, format, paint_area, buttonArea,
2230 imgRect, image, txtRect, ddRect, flat);
2234 private void DrawToolBarButton (Graphics dc, ToolBarButton button, Font font, StringFormat format,
2235 Rectangle controlArea, Rectangle buttonArea, Rectangle imgRect,
2236 Image image, Rectangle txtRect, Rectangle ddRect, bool flat) {
2237 if (! button.Visible)
2240 switch (button.Style) {
2242 case ToolBarButtonStyle.Separator:
2243 // separator is drawn only in the case of flat appearance
2245 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), buttonArea.X + 1, buttonArea.Y,
2246 buttonArea.X + 1, buttonArea.Height);
2247 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), buttonArea.X + 1 + (int) ResPool.GetPen (ColorButtonFace).Width,
2248 buttonArea.Y, buttonArea.X + 1 + (int) ResPool.GetPen (ColorButtonFace).Width, buttonArea.Height);
2249 /* draw a horizontal separator */
2250 if (button.Wrapper) {
2251 int y = buttonArea.Height + this.ToolBarSeparatorWidth / 2;
2252 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), 0, y, controlArea.Width, y);
2253 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), 0, y + 1 + (int) ResPool.GetPen (ColorButtonFace).Width, controlArea.Width,
2254 y + 1 + (int) ResPool.GetPen (ColorButtonFace).Width);
2259 case ToolBarButtonStyle.ToggleButton:
2260 Rectangle toggleArea = Rectangle.Empty;
2261 toggleArea.X = buttonArea.X + this.ToolBarImageGripWidth;
2262 toggleArea.Y = buttonArea.Y + this.ToolBarImageGripWidth;
2263 toggleArea.Width = buttonArea.Width - 2 * this.ToolBarImageGripWidth;
2264 toggleArea.Height = buttonArea.Height - 2 * this.ToolBarImageGripWidth;
2265 if (button.PartialPush && button.Pushed) {
2266 dc.FillRectangle (SystemBrushes.ControlLightLight, toggleArea);
2267 if (! imgRect.IsEmpty) {
2268 if (button.Enabled && image != null)
2269 button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
2270 imgRect.Height, button.ImageIndex);
2272 dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
2273 ControlPaint.DrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
2274 Border3DSide.Right | Border3DSide.Bottom);
2278 dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
2280 CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight, txtRect, format);
2283 else if (button.PartialPush) {
2284 dc.FillRectangle (SystemBrushes.ControlLight, toggleArea);
2285 if (! imgRect.IsEmpty) {
2286 if (button.Enabled && image != null)
2287 button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
2288 imgRect.Height, button.ImageIndex);
2290 dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
2291 ControlPaint.DrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
2292 Border3DSide.Right | Border3DSide.Bottom);
2296 dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
2298 CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight,
2302 else if (button.Pushed) {
2303 dc.FillRectangle (SystemBrushes.ControlLightLight, toggleArea);
2304 if (! imgRect.IsEmpty) {
2305 if (button.Enabled && image != null)
2306 button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
2307 imgRect.Height, button.ImageIndex);
2309 dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
2310 CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
2311 Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
2315 dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
2317 CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight,
2322 dc.FillRectangle (SystemBrushes.Control, toggleArea);
2323 if (! imgRect.IsEmpty) {
2324 if (button.Enabled && image != null)
2325 button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
2326 imgRect.Height, button.ImageIndex);
2328 dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
2329 CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
2330 Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
2334 dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
2336 CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight,
2341 case ToolBarButtonStyle.DropDownButton:
2342 // draw the dropdown arrow
2343 if (! ddRect.IsEmpty) {
2344 PointF [] vertices = new PointF [3];
2345 PointF ddCenter = new PointF (ddRect.X + (ddRect.Width/2.0f), ddRect.Y + (ddRect.Height/2.0f));
2346 vertices [0].X = ddCenter.X - this.ToolBarDropDownArrowWidth / 2.0f + 0.5f;
2347 vertices [0].Y = ddCenter.Y;
2348 vertices [1].X = ddCenter.X + this.ToolBarDropDownArrowWidth / 2.0f + 0.5f;
2349 vertices [1].Y = ddCenter.Y;
2350 vertices [2].X = ddCenter.X + 0.5f; // 0.5 is added for adjustment
2351 vertices [2].Y = ddCenter.Y + this.ToolBarDropDownArrowHeight;
2352 dc.FillPolygon (SystemBrushes.ControlText, vertices);
2354 goto case ToolBarButtonStyle.PushButton;
2356 case ToolBarButtonStyle.PushButton:
2357 if (! imgRect.IsEmpty){
2358 if (button.Enabled && image != null)
2359 button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width, imgRect.Height,
2362 dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
2363 CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
2364 Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
2368 dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
2370 CPDrawStringDisabled (dc, button.Text, font, ColorButtonHilight,
2376 // Grip width for the ToolBar
2377 public override int ToolBarGripWidth {
2381 // Grip width for the Image on the ToolBarButton
2382 public override int ToolBarImageGripWidth {
2386 // width of the separator
2387 public override int ToolBarSeparatorWidth {
2391 // width of the dropdown arrow rect
2392 public override int ToolBarDropDownWidth {
2396 // width for the dropdown arrow on the ToolBarButton
2397 public override int ToolBarDropDownArrowWidth {
2401 // height for the dropdown arrow on the ToolBarButton
2402 public override int ToolBarDropDownArrowHeight {
2406 public override Size ToolBarDefaultSize {
2408 return new Size (100, 42);
2411 #endregion // ToolBar
2414 public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip tt) {
2417 control = tt.tooltip_window;
2418 dc.FillRectangle(ResPool.GetSolidBrush(this.ColorInfoWindow), control.client_rect);
2419 dc.DrawRectangle(ResPool.GetPen(this.ColorWindowFrame), 0, 0, control.Width-1, control.Height-1);
2420 dc.DrawString(control.text, control.Font, ResPool.GetSolidBrush(this.ColorInfoText), control.client_rect, tt.tooltip_window.string_format);
2423 public override Size ToolTipSize(ToolTip tt, string text) {
2426 sizef = tt.tooltip_window.DeviceContext.MeasureString(text, tt.tooltip_window.Font);
\r
2427 return new Size((int)sizef.Width+2, (int)sizef.Height+3); // Need space for the border
\r
2429 #endregion // ToolTip
2432 private void DrawTrackBar_Vertical (Graphics dc, Rectangle area, TrackBar tb,
2433 ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
2434 float ticks, int value_pos, bool mouse_value) {
2436 Point toptick_startpoint = new Point ();
2437 Point bottomtick_startpoint = new Point ();
2438 Point channel_startpoint = new Point ();
2440 float pixels_betweenticks;
2441 const int space_from_right = 8;
2442 const int space_from_left = 8;
2444 switch (tb.TickStyle) {
2445 case TickStyle.BottomRight:
2446 case TickStyle.None:
2447 channel_startpoint.Y = 8;
2448 channel_startpoint.X = 9;
2449 bottomtick_startpoint.Y = 13;
2450 bottomtick_startpoint.X = 24;
2452 case TickStyle.TopLeft:
2453 channel_startpoint.Y = 8;
2454 channel_startpoint.X = 19;
2455 toptick_startpoint.Y = 13;
2456 toptick_startpoint.X = 8;
2458 case TickStyle.Both:
2459 channel_startpoint.Y = 8;
2460 channel_startpoint.X = 18;
2461 bottomtick_startpoint.Y = 13;
2462 bottomtick_startpoint.X = 32;
2463 toptick_startpoint.Y = 13;
2464 toptick_startpoint.X = 8;
2470 thumb_area.X = area.X + channel_startpoint.X;
2471 thumb_area.Y = area.Y + channel_startpoint.Y;
2472 thumb_area.Height = area.Height - space_from_right - space_from_left;
2473 thumb_area.Width = 4;
2476 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonShadow), channel_startpoint.X, channel_startpoint.Y,
2477 1, thumb_area.Height);
2479 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonDkShadow), channel_startpoint.X + 1, channel_startpoint.Y,
2480 1, thumb_area.Height);
2482 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonHilight), channel_startpoint.X + 3, channel_startpoint.Y,
2483 1, thumb_area.Height);
2485 pixel_len = thumb_area.Height - 11;
2486 pixels_betweenticks = pixel_len / (tb.Maximum - tb.Minimum);
2488 /* Convert thumb position from mouse position to value*/
2491 if (value_pos >= channel_startpoint.Y)
2492 value_pos = (int)(((float) (value_pos - channel_startpoint.Y)) / pixels_betweenticks);
2496 if (value_pos + tb.Minimum > tb.Maximum)
2497 value_pos = tb.Maximum - tb.Minimum;
2499 tb.Value = value_pos + tb.Minimum;
2502 thumb_pos.Y = channel_startpoint.Y + (int) (pixels_betweenticks * (float) value_pos);
2504 /* Draw thumb fixed 10x22 size */
2505 thumb_pos.Width = 10;
2506 thumb_pos.Height = 22;
2508 switch (tb.TickStyle) {
2509 case TickStyle.BottomRight:
2510 case TickStyle.None: {
2511 thumb_pos.X = channel_startpoint.X - 8;
2513 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X , thumb_pos.Y + 10);
2514 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 16, thumb_pos.Y);
2515 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X + 16, thumb_pos.Y, thumb_pos.X + 16 + 4, thumb_pos.Y + 4);
2517 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X +1, thumb_pos.Y + 9, thumb_pos.X +15, thumb_pos.Y +9);
2518 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 16, thumb_pos.Y + 9, thumb_pos.X +16 + 4, thumb_pos.Y +9 - 4);
2520 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X +16, thumb_pos.Y +10);
2521 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 16, thumb_pos.Y + 10, thumb_pos.X +16 + 5, thumb_pos.Y +10 - 5);
2523 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 16, 8);
2524 dc.FillRectangle (br_thumb, thumb_pos.X + 17, thumb_pos.Y + 2, 1, 6);
2525 dc.FillRectangle (br_thumb, thumb_pos.X + 18, thumb_pos.Y + 3, 1, 4);
2526 dc.FillRectangle (br_thumb, thumb_pos.X + 19, thumb_pos.Y + 4, 1, 2);
2530 case TickStyle.TopLeft: {
2531 thumb_pos.X = channel_startpoint.X - 10;
2533 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X + 4 + 16, thumb_pos.Y);
2534 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 4);
2536 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X + 4 + 16 , thumb_pos.Y+ 9);
2537 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X, thumb_pos.Y + 5);
2538 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 19, thumb_pos.Y + 9, thumb_pos.X +19 , thumb_pos.Y+ 1);
2540 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 4, thumb_pos.Y+ 10, thumb_pos.X + 4 + 16, thumb_pos.Y+ 10);
2541 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 4, thumb_pos.Y + 10, thumb_pos.X -1, thumb_pos.Y+ 5);
2542 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X+ 20, thumb_pos.Y + 10);
2544 dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 15, 8);
2545 dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 1, 6);
2546 dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 1, 4);
2547 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 1, 2);
2552 case TickStyle.Both: {
2553 thumb_pos.X = area.X + 10;
2554 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 9);
2555 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 19, thumb_pos.Y);
2557 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 1, thumb_pos.Y + 9, thumb_pos.X+ 19, thumb_pos.Y + 9);
2558 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 10, thumb_pos.Y+ 1, thumb_pos.X + 19, thumb_pos.Y + 8);
2560 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X+ 20, thumb_pos.Y +10);
2561 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X + 20, thumb_pos.Y+ 9);
2563 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 18, 8);
2572 pixel_len = thumb_area.Height - 11;
2573 pixels_betweenticks = pixel_len / ticks;
2576 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
2577 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
2579 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
2580 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
2581 dc.DrawLine (pen_ticks, area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
2582 area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc);
2584 dc.DrawLine (pen_ticks, area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
2585 area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc);
2589 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
2590 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
2592 pixel_len = thumb_area.Height - 11;
2593 pixels_betweenticks = pixel_len / ticks;
2595 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
2596 //Console.WriteLine ("{0} {1} {2}", pixel_len, inc, pixels_betweenticks );
2597 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
2598 dc.DrawLine (pen_ticks, area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
2599 area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
2601 dc.DrawLine (pen_ticks, area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
2602 area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
2610 Does not matter the size of the control, Win32 always draws:
2611 - Ticks starting from pixel 13, 8
2612 - Channel starting at pos 8, 19 and ends at Width - 8
2613 - Autosize makes always the control 40 pixels height
2614 - Ticks are draw at (channel.Witdh - 10) / (Maximum - Minimum)
2617 private void DrawTrackBar_Horizontal (Graphics dc, Rectangle area, TrackBar tb,
2618 ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
2619 float ticks, int value_pos, bool mouse_value) {
2620 Point toptick_startpoint = new Point ();
2621 Point bottomtick_startpoint = new Point ();
2622 Point channel_startpoint = new Point ();
2624 float pixels_betweenticks;
2625 const int space_from_right = 8;
2626 const int space_from_left = 8;
2628 switch (tb.TickStyle) {
2629 case TickStyle.BottomRight:
2630 case TickStyle.None:
2631 channel_startpoint.X = 8;
2632 channel_startpoint.Y = 9;
2633 bottomtick_startpoint.X = 13;
2634 bottomtick_startpoint.Y = 24;
2636 case TickStyle.TopLeft:
2637 channel_startpoint.X = 8;
2638 channel_startpoint.Y = 19;
2639 toptick_startpoint.X = 13;
2640 toptick_startpoint.Y = 8;
2642 case TickStyle.Both:
2643 channel_startpoint.X = 8;
2644 channel_startpoint.Y = 18;
2645 bottomtick_startpoint.X = 13;
2646 bottomtick_startpoint.Y = 32;
2647 toptick_startpoint.X = 13;
2648 toptick_startpoint.Y = 8;
2654 thumb_area.X = area.X + channel_startpoint.X;
2655 thumb_area.Y = area.Y + channel_startpoint.Y;
2656 thumb_area.Width = area.Width - space_from_right - space_from_left;
2657 thumb_area.Height = 4;
2660 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonShadow), channel_startpoint.X, channel_startpoint.Y,
2661 thumb_area.Width, 1);
2663 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonDkShadow), channel_startpoint.X, channel_startpoint.Y + 1,
2664 thumb_area.Width, 1);
2666 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonHilight), channel_startpoint.X, channel_startpoint.Y +3,
2667 thumb_area.Width, 1);
2669 pixel_len = thumb_area.Width - 11;
2670 pixels_betweenticks = pixel_len / (tb.Maximum - tb.Minimum);
2672 /* Convert thumb position from mouse position to value*/
2674 if (value_pos >= channel_startpoint.X)
2675 value_pos = (int)(((float) (value_pos - channel_startpoint.X)) / pixels_betweenticks);
2679 if (value_pos + tb.Minimum > tb.Maximum)
2680 value_pos = tb.Maximum - tb.Minimum;
2682 tb.Value = value_pos + tb.Minimum;
2685 thumb_pos.X = channel_startpoint.X + (int) (pixels_betweenticks * (float) value_pos);
2687 /* Draw thumb fixed 10x22 size */
2688 thumb_pos.Width = 10;
2689 thumb_pos.Height = 22;
2691 switch (tb.TickStyle) {
2692 case TickStyle.BottomRight:
2693 case TickStyle.None: {
2694 thumb_pos.Y = channel_startpoint.Y - 8;
2696 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y);
2697 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 16);
2698 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y + 16, thumb_pos.X + 4, thumb_pos.Y + 16 + 4);
2700 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X +9, thumb_pos.Y +15);
2701 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 16, thumb_pos.X +9 - 4, thumb_pos.Y +16 + 4);
2703 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y +16);
2704 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y + 16, thumb_pos.X +10 - 5, thumb_pos.Y +16 + 5);
2706 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 16);
2707 dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 17, 6, 1);
2708 dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 18, 4, 1);
2709 dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 19, 2, 1);
2712 case TickStyle.TopLeft: {
2713 thumb_pos.Y = channel_startpoint.Y - 10;
2715 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X, thumb_pos.Y + 4 + 16);
2716 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X + 4, thumb_pos.Y);
2718 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 9, thumb_pos.Y + 4 + 16);
2719 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y);
2720 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 19, thumb_pos.X + 1 , thumb_pos.Y +19);
2722 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 10, thumb_pos.Y + 4 + 16);
2723 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y -1);
2724 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 10, thumb_pos.Y + 20);
2726 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 8, 15);
2727 dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 6, 1);
2728 dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 4, 1);
2729 dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 2, 1);
2733 case TickStyle.Both: {
2734 thumb_pos.Y = area.Y + 10;
2735 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 9, thumb_pos.Y);
2736 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 19);
2738 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 19);
2739 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), thumb_pos.X + 1, thumb_pos.Y + 10, thumb_pos.X + 8, thumb_pos.Y + 19);
2741 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y + 20);
2742 dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 9, thumb_pos.Y + 20);
2744 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 18);
2753 pixel_len = thumb_area.Width - 11;
2754 pixels_betweenticks = pixel_len / ticks;
2757 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
2758 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
2760 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
2761 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
2762 dc.DrawLine (pen_ticks, area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
2763 area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3);
2765 dc.DrawLine (pen_ticks, area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
2766 area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2);
2770 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
2771 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
2773 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
2774 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
2775 dc.DrawLine (pen_ticks, area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
2776 area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y);
2778 dc.DrawLine (pen_ticks, area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
2779 area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
2784 public override void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb) {
2785 //public override void DrawTrackBar (Graphics dc,
2788 //ref Rectangle thumb_pos,
2789 //ref Rectangle thumb_area,
2793 float ticks = (tb.Maximum - tb.Minimum) / tb.tickFrequency; /* N of ticks draw*/
2795 Rectangle thumb_pos = tb.ThumbPos;
2796 Rectangle thumb_area = tb.ThumbArea;
2798 if (tb.thumb_pressed) {
2799 value_pos = tb.thumb_mouseclick;
2802 value_pos = tb.Value - tb.Minimum;
2803 mouse_value = false;
2806 area = tb.paint_area;
2808 if (tb.thumb_pressed == true) {
2809 br_thumb = (Brush) ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace);
2811 br_thumb = ResPool.GetSolidBrush (ColorButtonFace);
2815 /* Control Background */
2816 if (tb.BackColor == DefaultControlBackColor) {
2817 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area);
2819 dc.FillRectangle (ResPool.GetSolidBrush (tb.BackColor), area);
2824 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonFace, Color.Black), area.X, area.Y, area.Width - 1, 1);
2825 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonFace, Color.Black), area.X, area.Y + area.Height - 1, area.Width - 1, 1);
2826 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonFace, Color.Black), area.X, area.Y, 1, area.Height - 1);
2827 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonFace, Color.Black), area.X + area.Width - 1, area.Y, 1, area.Height - 1);
2830 if (tb.Orientation == Orientation.Vertical) {
2831 DrawTrackBar_Vertical (dc, area, tb, ref thumb_pos, ref thumb_area,
2832 br_thumb, ticks, value_pos, mouse_value);
2835 DrawTrackBar_Horizontal (dc, area, tb, ref thumb_pos, ref thumb_area,
2836 br_thumb, ticks, value_pos, mouse_value);
2839 tb.ThumbPos = thumb_pos;
2840 tb.ThumbArea = thumb_area;
2843 public override Size TrackBarDefaultSize {
2845 return new Size (104, 42);
2849 #endregion // TrackBar
2852 public override Size VScrollBarDefaultSize {
2854 return new Size (this.ScrollBarButtonSize, 80);
2857 #endregion // VScrollBar
2859 #region ControlPaint
2860 private enum DrawFrameControlStates {
2861 ButtonCheck = 0x0000,
2862 ButtonRadioImage = 0x0001,
2863 ButtonRadioMask = 0x0002,
2864 ButtonRadio = 0x0004,
2865 Button3State = 0x0008,
2866 ButtonPush = 0x0010,
2868 CaptionClose = 0x0000,
2869 CaptionMin = 0x0001,
2870 CaptionMax = 0x0002,
2871 CaptionRestore = 0x0004,
2872 CaptionHelp = 0x0008,
2876 MenuBullet = 0x0002,
2877 MenuArrowRight = 0x0004,
2880 ScrollDown = 0x0001,
2881 ScrollLeft = 0x0002,
2882 ScrollRight = 0x0003,
2883 ScrollComboBox = 0x0005,
2884 ScrollSizeGrip = 0x0008,
2885 ScrollSizeGripRight = 0x0010,
2890 Transparent = 0x0800,
2892 AdjustRect = 0x2000,
2898 private enum DrawFrameControlTypes {
2905 public override void CPDrawBorder (Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
2906 ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
2907 Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
2908 int bottomWidth, ButtonBorderStyle bottomStyle) {
2909 DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom-1, leftWidth, leftColor, leftStyle, Border3DSide.Left);
2910 DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Right-1, bounds.Top, topWidth, topColor, topStyle, Border3DSide.Top);
2911 DrawBorderInternal(graphics, bounds.Right-1, bounds.Top, bounds.Right-1, bounds.Bottom-1, rightWidth, rightColor, rightStyle, Border3DSide.Right);
2912 DrawBorderInternal(graphics, bounds.Left, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1, bottomWidth, bottomColor, bottomStyle, Border3DSide.Bottom);
2915 public override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) {
2916 CPDrawBorder3D(graphics, rectangle, style, sides, ColorButtonFace);
2919 private void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color) {
2921 Pen penTopLeftInner;
2923 Pen penBottomRightInner;
2924 Rectangle rect= new Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
2925 bool doInner = false;
2927 if ((style & Border3DStyle.Adjust)!=0) {
2934 /* default to flat */
2935 penTopLeft=ResPool.GetPen(ControlPaint.Dark(control_color));
2936 penTopLeftInner=ResPool.GetPen(ControlPaint.Dark(control_color));
2937 penBottomRight=ResPool.GetPen(ControlPaint.Dark(control_color));
2938 penBottomRightInner=ResPool.GetPen(ControlPaint.Dark(control_color));
2940 if ((style & Border3DStyle.RaisedOuter)!=0) {
2941 penTopLeft=ResPool.GetPen(ControlPaint.LightLight(control_color));
2942 penBottomRight=ResPool.GetPen(ControlPaint.DarkDark(control_color));
2943 if ((style & (Border3DStyle.RaisedInner | Border3DStyle.SunkenInner))!=0) {
2946 } else if ((style & Border3DStyle.SunkenOuter)!=0) {
2947 penTopLeft=ResPool.GetPen(ControlPaint.DarkDark(control_color));
2948 penBottomRight=ResPool.GetPen(ControlPaint.LightLight(control_color));
2949 if ((style & (Border3DStyle.RaisedInner | Border3DStyle.SunkenInner))!=0) {
2954 if ((style & Border3DStyle.RaisedInner)!=0) {
2956 penTopLeftInner=ResPool.GetPen(control_color);
2957 penBottomRightInner=ResPool.GetPen(ControlPaint.Dark(control_color));
2959 penTopLeft=ResPool.GetPen(ControlPaint.LightLight(control_color));
2960 penBottomRight=ResPool.GetPen(ControlPaint.DarkDark(control_color));
2962 } else if ((style & Border3DStyle.SunkenInner)!=0) {
2964 penTopLeftInner=ResPool.GetPen(ControlPaint.Dark(control_color));
2965 penBottomRightInner=ResPool.GetPen(control_color);
2967 penTopLeft=ResPool.GetPen(ControlPaint.DarkDark(control_color));
2968 penBottomRight=ResPool.GetPen(ControlPaint.LightLight(control_color));
2972 if ((sides & Border3DSide.Middle)!=0) {
2973 graphics.FillRectangle(ResPool.GetSolidBrush(control_color), rect);
2976 if ((sides & Border3DSide.Left)!=0) {
2977 graphics.DrawLine(penTopLeft, rect.Left, rect.Bottom-2, rect.Left, rect.Top);
2979 graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Bottom-2, rect.Left+1, rect.Top);
2983 if ((sides & Border3DSide.Top)!=0) {
2984 graphics.DrawLine(penTopLeft, rect.Left, rect.Top, rect.Right-2, rect.Top);
2987 if ((sides & Border3DSide.Left)!=0) {
2988 graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Top+1, rect.Right-3, rect.Top+1);
2990 graphics.DrawLine(penTopLeftInner, rect.Left, rect.Top+1, rect.Right-3, rect.Top+1);
2995 if ((sides & Border3DSide.Right)!=0) {
2996 graphics.DrawLine(penBottomRight, rect.Right-1, rect.Top, rect.Right-1, rect.Bottom-1);
2999 if ((sides & Border3DSide.Top)!=0) {
3000 graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top+1, rect.Right-2, rect.Bottom-2);
3002 graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top, rect.Right-2, rect.Bottom-2);
3007 if ((sides & Border3DSide.Bottom)!=0) {
3010 if ((sides & Border3DSide.Left)!=0) {
3014 graphics.DrawLine(penBottomRight, rect.Left, rect.Bottom-1, rect.Right-1, rect.Bottom-1);
3017 if ((sides & Border3DSide.Right)!=0) {
3018 graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-2, rect.Bottom-2);
3020 graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-2, rect.Bottom-2);
3028 public override void CPDrawButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
3029 DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonPush;
3031 if ((state & ButtonState.Pushed)!=0) {
3032 dfcs |= DrawFrameControlStates.Pushed;
3035 if ((state & ButtonState.Checked)!=0) {
3036 dfcs |= DrawFrameControlStates.Checked;
3039 if ((state & ButtonState.Flat)!=0) {
3040 dfcs |= DrawFrameControlStates.Flat;
3043 if ((state & ButtonState.Inactive)!=0) {
3044 dfcs |= DrawFrameControlStates.Inactive;
3046 DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.Button, dfcs);
3050 public override void CPDrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state) {
3051 Rectangle captionRect;
3054 CPDrawButton(graphics, rectangle, state);
3056 if (rectangle.Width<rectangle.Height) {
3057 captionRect=new Rectangle(rectangle.X+1, rectangle.Y+rectangle.Height/2-rectangle.Width/2+1, rectangle.Width-4, rectangle.Width-4);
3059 captionRect=new Rectangle(rectangle.X+rectangle.Width/2-rectangle.Height/2+1, rectangle.Y+1, rectangle.Height-4, rectangle.Height-4);
3062 if ((state & ButtonState.Pushed)!=0) {
3063 captionRect=new Rectangle(rectangle.X+2, rectangle.Y+2, rectangle.Width-3, rectangle.Height-3);
3066 /* Make sure we've got at least a line width of 1 */
3067 lineWidth=Math.Max(1, captionRect.Width/7);
3070 case CaptionButton.Close: {
3073 if ((state & ButtonState.Inactive)!=0) {
3074 pen=new Pen(ColorButtonHilight, lineWidth);
3075 DrawCaptionHelper(graphics, ColorButtonHilight, pen, lineWidth, 1, captionRect, button);
3078 pen=new Pen(ColorButtonShadow, lineWidth);
3079 DrawCaptionHelper(graphics, ColorButtonShadow, pen, lineWidth, 0, captionRect, button);
3083 pen=new Pen(ColorButtonText, lineWidth);
3084 DrawCaptionHelper(graphics, ColorButtonText, pen, lineWidth, 0, captionRect, button);
3090 case CaptionButton.Help:
3091 case CaptionButton.Maximize:
3092 case CaptionButton.Minimize:
3093 case CaptionButton.Restore: {
3094 if ((state & ButtonState.Inactive)!=0) {
3095 DrawCaptionHelper(graphics, ColorButtonHilight, SystemPens.ControlLightLight, lineWidth, 1, captionRect, button);
3097 DrawCaptionHelper(graphics, ColorButtonShadow, SystemPens.ControlDark, lineWidth, 0, captionRect, button);
3100 DrawCaptionHelper(graphics, ColorButtonText, SystemPens.ControlText, lineWidth, 0, captionRect, button);
3108 public override void CPDrawCheckBox (Graphics graphics, Rectangle rectangle, ButtonState state) {
3109 DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonCheck;
3111 if ((state & ButtonState.Pushed)!=0) {
3112 dfcs |= DrawFrameControlStates.Pushed;
3115 if ((state & ButtonState.Checked)!=0) {
3116 dfcs |= DrawFrameControlStates.Checked;
3119 if ((state & ButtonState.Flat)!=0) {
3120 dfcs |= DrawFrameControlStates.Flat;
3123 if ((state & ButtonState.Inactive)!=0) {
3124 dfcs |= DrawFrameControlStates.Inactive;
3127 DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.Button, dfcs);
3131 public override void CPDrawComboButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
3132 Point[] arrow = new Point[3];
3142 if ((state & ButtonState.Checked)!=0) {
3143 graphics.FillRectangle(ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonLight, ColorButtonHilight),rectangle);
3146 if ((state & ButtonState.Flat)!=0) {
3147 ControlPaint.DrawBorder(graphics, rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
3149 if ((state & (ButtonState.Pushed | ButtonState.Checked))!=0) {
3150 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
3152 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
3156 rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
3157 centerX=rect.Left+rect.Width/2;
3158 centerY=rect.Top+rect.Height/2;
3159 shiftX=Math.Max(1, rect.Width/8);
3160 shiftY=Math.Max(1, rect.Height/8);
3162 if ((state & ButtonState.Pushed)!=0) {
3169 P1=new Point(rect.Left, centerY);
3170 P2=new Point(rect.Right, centerY);
3171 P3=new Point(centerX, rect.Bottom);
3177 /* Draw the arrow */
3178 if ((state & ButtonState.Inactive)!=0) {
3179 graphics.FillPolygon(SystemBrushes.ControlLightLight, arrow, FillMode.Winding);
3181 /* Move away from the shadow */
3191 graphics.FillPolygon(SystemBrushes.ControlDark, arrow, FillMode.Winding);
3193 graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding);
3198 public override void CPDrawContainerGrabHandle (Graphics graphics, Rectangle bounds) {
3200 Pen pen = new Pen(Color.Black, 1);
3201 Rectangle rect = new Rectangle(bounds.X, bounds.Y, bounds.Width-1, bounds.Height-1); // Dunno why, but MS does it that way, too
3205 graphics.FillRectangle(ResPool.GetSolidBrush (ColorButtonText), rect);
3206 graphics.DrawRectangle(pen, rect);
3208 X=rect.X+rect.Width/2;
3209 Y=rect.Y+rect.Height/2;
3211 /* Draw the cross */
3212 graphics.DrawLine(pen, X, rect.Y+2, X, rect.Bottom-2);
3213 graphics.DrawLine(pen, rect.X+2, Y, rect.Right-2, Y);
3215 /* Draw 'arrows' for vertical lines */
3216 graphics.DrawLine(pen, X-1, rect.Y+3, X+1, rect.Y+3);
3217 graphics.DrawLine(pen, X-1, rect.Bottom-3, X+1, rect.Bottom-3);
3219 /* Draw 'arrows' for horizontal lines */
3220 graphics.DrawLine(pen, rect.X+3, Y-1, rect.X+3, Y+1);
3221 graphics.DrawLine(pen, rect.Right-3, Y-1, rect.Right-3, Y+1);
3225 public virtual void DrawFlatStyleFocusRectangle (Graphics graphics, Rectangle rectangle, ButtonBase button, Color foreColor, Color backColor) {
3226 // make a rectange to trace around border of the button
3227 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
3229 Color outerColor = foreColor;
3230 // adjust focus color according to the flatstyle
3231 if (button.FlatStyle == FlatStyle.Popup && !button.is_pressed) {
3232 outerColor = (backColor == ColorButtonFace) ? ControlPaint.Dark(ColorButtonFace) : ColorButtonText;
3235 // draw the outer rectangle
3236 graphics.DrawRectangle (ResPool.GetPen (outerColor), trace_rectangle);
3238 // draw the inner rectangle
3239 if (button.FlatStyle == FlatStyle.Popup) {
3240 DrawInnerFocusRectangle (graphics, Rectangle.Inflate (rectangle, -4, -4), backColor);
3242 // draw a flat inner rectangle
3243 Pen pen = ResPool.GetPen (ControlPaint.LightLight (backColor));
3244 graphics.DrawRectangle(pen, Rectangle.Inflate (trace_rectangle, -4, -4));
3248 public virtual void DrawInnerFocusRectangle(Graphics graphics, Rectangle rectangle, Color backColor)
3250 // make a rectange to trace around border of the button
3251 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
3253 Color colorBackInverted = Color.FromArgb (Math.Abs (backColor.R-255), Math.Abs (backColor.G-255), Math.Abs (backColor.B-255));
3254 DashStyle oldStyle; // used for caching old penstyle
3255 Pen pen = ResPool.GetPen (colorBackInverted);
3257 oldStyle = pen.DashStyle;
3258 pen.DashStyle = DashStyle.Dot;
3259 graphics.DrawRectangle (pen, trace_rectangle);
3260 pen.DashStyle = oldStyle;
3264 public override void CPDrawFocusRectangle (Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor) {
3265 // make a rectange to trace around border of the button
3266 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
3268 //Color colorForeInverted;
3271 //colorForeInverted=Color.FromArgb(Math.Abs(foreColor.R-255), Math.Abs(foreColor.G-255), Math.Abs(foreColor.B-255));
3272 //pen=new Pen(colorForeInverted, 1);
3273 // MS seems to always use black
3274 pen = ResPool.GetPen (Color.Black);
3275 graphics.DrawRectangle(pen, trace_rectangle);
3277 DrawInnerFocusRectangle (graphics, Rectangle.Inflate (rectangle, -4, -4), backColor);
3280 public override void CPDrawGrabHandle (Graphics graphics, Rectangle rectangle, bool primary, bool enabled) {
3284 if (primary==true) {
3285 pen=new Pen(Color.Black, 1);
3286 if (enabled==true) {
3287 sb=ResPool.GetSolidBrush (ColorButtonText);
3289 sb=ResPool.GetSolidBrush (ColorButtonFace);
3292 pen=new Pen(Color.White, 1);
3293 if (enabled==true) {
3294 sb=new SolidBrush(Color.Black);
3296 sb=ResPool.GetSolidBrush (ColorButtonFace);
3299 graphics.FillRectangle(sb, rectangle);
3300 graphics.DrawRectangle(pen, rectangle);
3305 public override void CPDrawGrid (Graphics graphics, Rectangle area, Size pixelsBetweenDots, Color backColor) {
3311 ControlPaint.Color2HBS(backColor, out h, out b, out s);
3314 foreColor=Color.Black;
3316 foreColor=Color.White;
3320 /* Commented out until I take the time and figure out
3321 which HatchStyle will match requirements. The code below
3322 is only correct for Percent50.
3324 if (pixelsBetweenDots.Width==pixelsBetweenDots.Height) {
3325 HatchBrush brush=null;
3327 switch(pixelsBetweenDots.Width) {
3328 case 2: brush=new HatchBrush(HatchStyle.Percent50, foreColor, backColor); break;
3329 case 4: brush=new HatchBrush(HatchStyle.Percent25, foreColor, backColor); break;
3330 case 5: brush=new HatchBrush(HatchStyle.Percent20, foreColor, backColor); break;
3332 /* Have to do it the slow way */
3337 graphics.FillRectangle(brush, area);
3346 Bitmap bitmap = new Bitmap(area.Width, area.Height, graphics);
3348 for (int x=0; x<area.Width; x+=pixelsBetweenDots.Width) {
3349 for (int y=0; y<area.Height; y+=pixelsBetweenDots.Height) {
3350 bitmap.SetPixel(x, y, foreColor);
3353 graphics.DrawImage(bitmap, area.X, area.Y, area.Width, area.Height);
3357 public override void CPDrawImageDisabled (Graphics graphics, Image image, int x, int y, Color background) {
3359 Microsoft seems to ignore the background and simply make
3360 the image grayscale. At least when having > 256 colors on
3364 ImageAttributes imageAttributes=new ImageAttributes();
3365 ColorMatrix colorMatrix=new ColorMatrix(new float[][] {
3366 // This table would create a perfect grayscale image, based on luminance
3367 // new float[]{0.3f,0.3f,0.3f,0,0},
3368 // new float[]{0.59f,0.59f,0.59f,0,0},
3369 // new float[]{0.11f,0.11f,0.11f,0,0},
3370 // new float[]{0,0,0,1,0,0},
3371 // new float[]{0,0,0,0,1,0},
3372 // new float[]{0,0,0,0,0,1}
3374 // This table generates a image that is grayscaled and then
3375 // brightened up. Seems to match MS close enough.
3376 new float[]{0.2f,0.2f,0.2f,0,0},
3377 new float[]{0.41f,0.41f,0.41f,0,0},
3378 new float[]{0.11f,0.11f,0.11f,0,0},
3379 new float[]{0.15f,0.15f,0.15f,1,0,0},
3380 new float[]{0.15f,0.15f,0.15f,0,1,0},
3381 new float[]{0.15f,0.15f,0.15f,0,0,1}
3384 imageAttributes.SetColorMatrix(colorMatrix);
3385 graphics.DrawImage(image, new Rectangle(x, y, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
3386 imageAttributes.Dispose();
3390 public override void CPDrawLockedFrame (Graphics graphics, Rectangle rectangle, bool primary) {
3395 penBorder=new Pen(Color.White, 2);
3396 penInside=new Pen(Color.Black, 1);
3398 penBorder=new Pen(Color.Black, 2);
3399 penInside=new Pen(Color.White, 1);
3401 penBorder.Alignment=PenAlignment.Inset;
3402 penInside.Alignment=PenAlignment.Inset;
3404 graphics.DrawRectangle(penBorder, rectangle);
3405 graphics.DrawRectangle(penInside, rectangle.X+2, rectangle.Y+2, rectangle.Width-5, rectangle.Height-5);
3406 penBorder.Dispose();
3407 penInside.Dispose();
3411 public override void CPDrawMenuGlyph (Graphics graphics, Rectangle rectangle, MenuGlyph glyph) {
3415 // MS draws always the background white
3416 graphics.FillRectangle(ResPool.GetSolidBrush (Color.White), rectangle);
3419 case MenuGlyph.Arrow: {
3420 Point[] arrow = new Point[3];
3429 rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
3430 centerX=rect.Left+rect.Width/2;
3431 centerY=rect.Top+rect.Height/2;
3432 shiftX=Math.Max(1, rect.Width/8);
3433 shiftY=Math.Max(1, rect.Height/8);
3438 P1=new Point(centerX, rect.Top-1);
3439 P2=new Point(centerX, rect.Bottom);
3440 P3=new Point(rect.Right, centerY);
3446 graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding);
3451 case MenuGlyph.Bullet: {
3453 lineWidth=Math.Max(2, rectangle.Width/3);
3454 rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
3456 graphics.FillEllipse(ResPool.GetSolidBrush (ColorButtonText), rect);
3461 case MenuGlyph.Checkmark: {
3464 lineWidth=Math.Max(2, rectangle.Width/6);
3465 Scale=Math.Max(1, rectangle.Width/12);
3467 rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
3469 for (int i=0; i<lineWidth; i++) {
3470 graphics.DrawLine(SystemPens.MenuText, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
3471 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);
3479 public override void CPDrawRadioButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
3480 DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonRadio;
3482 if ((state & ButtonState.Pushed)!=0) {
3483 dfcs |= DrawFrameControlStates.Pushed;
3486 if ((state & ButtonState.Checked)!=0) {
3487 dfcs |= DrawFrameControlStates.Checked;
3490 if ((state & ButtonState.Flat)!=0) {
3491 dfcs |= DrawFrameControlStates.Flat;
3494 if ((state & ButtonState.Inactive)!=0) {
3495 dfcs |= DrawFrameControlStates.Inactive;
3497 DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.Button, dfcs);
3502 public override void CPDrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style) {
3507 public override void CPDrawReversibleLine (Point start, Point end, Color backColor) {
3512 /* Scroll button: regular button + direction arrow */
3513 public override void CPDrawScrollButton (Graphics dc, Rectangle area, ScrollButton type, ButtonState state) {
3514 bool enabled = (state == ButtonState.Inactive) ? false: true;
3516 DrawScrollButtonPrimitive (dc, area, state);
3520 case ScrollButton.Up: {
3521 int x = area.X + (area.Width / 2) - 4;
3524 for (int i = 0; i < 3; i++)
3526 dc.DrawLine (pen_arrow, x + i, y - i, x + i + 6 - 2*i, y - i);
3528 dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y - i, x + i + 6 - 2*i, y - i);
3531 dc.FillRectangle (br_arrow, x + 3, area.Y + 6, 1, 1);
3534 case ScrollButton.Down: {
3535 int x = area.X + (area.Width / 2) - 4;
3538 for (int i = 4; i != 0; i--)
3540 dc.DrawLine (pen_arrow, x + i, y + i, x + i + 8 - 2*i, y + i);
3542 dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y + i, x + i + 8 - 2*i, y + i);
3545 dc.FillRectangle (br_arrow, x + 4, y + 4, 1, 1);
3549 case ScrollButton.Left: {
3550 int y = area.Y + (area.Height / 2) - 4;
3553 for (int i = 0; i < 3; i++)
3555 dc.DrawLine (pen_arrow, x - i, y + i, x - i, y + i + 6 - 2*i);
3557 dc.DrawLine (ResPool.GetPen (ColorGrayText), x - i, y + i, x - i, y + i + 6 - 2*i);
3559 dc.FillRectangle (br_arrow, x - 3, y + 3, 1, 1);
3563 case ScrollButton.Right: {
3564 int y = area.Y + (area.Height / 2) - 4;
3567 for (int i = 4; i != 0; i--)
3569 dc.DrawLine (pen_arrow, x + i, y + i, x + i, y + i + 8 - 2*i);
3571 dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y + i, x + i, y + i + 8 - 2*i);
3573 dc.FillRectangle (br_arrow, x + 4, y + 4, 1, 1);
3584 public override void CPDrawSelectionFrame (Graphics graphics, bool active, Rectangle outsideRect, Rectangle insideRect,
3590 public override void CPDrawSizeGrip (Graphics dc, Color backColor, Rectangle bounds) {
3591 Point pt = new Point (bounds.Right - 2, bounds.Bottom - 1);
3593 dc.DrawLine (ResPool.GetPen (ColorButtonFace), pt.X - 12, pt.Y, pt.X, pt.Y);
3594 dc.DrawLine (ResPool.GetPen (ColorButtonFace), pt.X, pt.Y, pt.X, pt.Y - 13);
3597 for (int i = 0; i < 11; i += 4) {
3598 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), pt.X - i, pt.Y, pt.X + 1, pt.Y - i - 2);
3599 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), pt.X - i - 1, pt.Y, pt.X + 1, pt.Y - i - 2);
3602 for (int i = 3; i < 13; i += 4)
3603 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), pt.X - i, pt.Y, pt.X + 1, pt.Y - i - 1);
3607 public override void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
3608 StringFormat format) {
3611 brush=new SolidBrush(ControlPaint.Light(color, 95));
3613 layoutRectangle.Offset(1.0f, 1.0f);
3614 graphics.DrawString(s, font, brush, layoutRectangle, format);
3616 brush.Color=ControlPaint.Light(color, 50);
3617 layoutRectangle.Offset(-1.0f, -1.0f);
3618 graphics.DrawString(s, font, brush, layoutRectangle, format);
3623 private static void DrawBorderInternal(Graphics graphics, int startX, int startY, int endX, int endY,
3624 int width, Color color, ButtonBorderStyle style, Border3DSide side) {
3626 Pen pen=new Pen(color, 1);
3629 case ButtonBorderStyle.Solid: {
3630 pen.DashStyle=DashStyle.Solid;
3634 case ButtonBorderStyle.Dashed: {
3635 pen.DashStyle=DashStyle.Dash;
3639 case ButtonBorderStyle.Dotted: {
3640 pen.DashStyle=DashStyle.Dot;
3644 case ButtonBorderStyle.Inset: {
3645 pen.DashStyle=DashStyle.Solid;
3649 case ButtonBorderStyle.Outset: {
3650 pen.DashStyle=DashStyle.Solid;
3655 case ButtonBorderStyle.None: {
3663 case ButtonBorderStyle.Outset: {
3665 int hue, brightness, saturation;
3666 int brightnessSteps;
3667 int brightnessDownSteps;
3669 ControlPaint.Color2HBS(color, out hue, out brightness, out saturation);
3671 brightnessDownSteps=brightness/width;
3672 if (brightness>127) {
3673 brightnessSteps=Math.Max(6, (160-brightness)/width);
3675 brightnessSteps=(127-brightness)/width;
3678 for (int i=0; i<width; i++) {
3680 case Border3DSide.Left: {
3682 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
3683 pen=new Pen(colorGrade, 1);
3684 graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
3688 case Border3DSide.Right: {
3690 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
3691 pen=new Pen(colorGrade, 1);
3692 graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
3696 case Border3DSide.Top: {
3698 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
3699 pen=new Pen(colorGrade, 1);
3700 graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
3704 case Border3DSide.Bottom: {
3706 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
3707 pen=new Pen(colorGrade, 1);
3708 graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
3716 case ButtonBorderStyle.Inset: {
3718 int hue, brightness, saturation;
3719 int brightnessSteps;
3720 int brightnessDownSteps;
3722 ControlPaint.Color2HBS(color, out hue, out brightness, out saturation);
3724 brightnessDownSteps=brightness/width;
3725 if (brightness>127) {
3726 brightnessSteps=Math.Max(6, (160-brightness)/width);
3728 brightnessSteps=(127-brightness)/width;
3731 for (int i=0; i<width; i++) {
3733 case Border3DSide.Left: {
3735 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
3736 pen=new Pen(colorGrade, 1);
3737 graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
3741 case Border3DSide.Right: {
3743 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
3744 pen=new Pen(colorGrade, 1);
3745 graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
3749 case Border3DSide.Top: {
3751 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
3752 pen=new Pen(colorGrade, 1);
3753 graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
3757 case Border3DSide.Bottom: {
3759 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
3760 pen=new Pen(colorGrade, 1);
3761 graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
3770 I decided to have the for-loop duplicated for speed reasons;
3771 that way we only have to switch once (as opposed to have the
3772 for-loop around the switch)
3776 case Border3DSide.Left: {
3777 for (int i=0; i<width; i++) {
3778 graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
3783 case Border3DSide.Right: {
3784 for (int i=0; i<width; i++) {
3785 graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
3790 case Border3DSide.Top: {
3791 for (int i=0; i<width; i++) {
3792 graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
3797 case Border3DSide.Bottom: {
3798 for (int i=0; i<width; i++) {
3799 graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
3811 This function actually draws the various caption elements.
3812 This way we can scale them nicely, no matter what size, and they
3813 still look like MS's scaled caption buttons. (as opposed to scaling a bitmap)
3816 private static void DrawCaptionHelper(Graphics graphics, Color color, Pen pen, int lineWidth, int shift, Rectangle captionRect, CaptionButton button) {
3818 case CaptionButton.Close: {
3819 pen.StartCap=LineCap.Triangle;
3820 pen.EndCap=LineCap.Triangle;
3822 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);
3823 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);
3826 graphics.DrawLine(pen, captionRect.Left+2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Right-2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
3827 graphics.DrawLine(pen, captionRect.Right-2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Left+2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
3831 case CaptionButton.Help: {
3832 StringFormat sf = new StringFormat();
3833 SolidBrush sb = new SolidBrush(color);
3834 Font font = new Font("Microsoft Sans Serif", captionRect.Height, FontStyle.Bold, GraphicsUnit.Pixel);
3836 sf.Alignment=StringAlignment.Center;
3837 sf.LineAlignment=StringAlignment.Center;
3840 graphics.DrawString("?", font, sb, captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
3849 case CaptionButton.Maximize: {
3850 /* Top 'caption bar' line */
3851 for (int i=0; i<Math.Max(2, lineWidth); i++) {
3852 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);
3855 /* Left side line */
3856 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
3857 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
3860 /* Right side line */
3861 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
3862 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);
3866 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
3867 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
3872 case CaptionButton.Minimize: {
3874 for (int i=0; i<Math.Max(2, lineWidth); i++) {
3875 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth+shift, captionRect.Bottom-lineWidth+shift-i);
3880 case CaptionButton.Restore: {
3881 /** First 'window' **/
3882 /* Top 'caption bar' line */
3883 for (int i=0; i<Math.Max(2, lineWidth); i++) {
3884 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);
3887 /* Left side line */
3888 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
3889 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);
3892 /* Right side line */
3893 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
3894 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);
3898 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
3899 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);
3902 /** Second 'window' **/
3903 /* Top 'caption bar' line */
3904 for (int i=0; i<Math.Max(2, lineWidth); i++) {
3905 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);
3908 /* Left side line */
3909 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
3910 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+4*lineWidth+shift+1, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
3913 /* Right side line */
3914 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
3915 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);
3919 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
3920 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
3929 [MonoTODO("Finish drawing code for Caption, Menu and Scroll")]
3930 private void DrawFrameControl(Graphics graphics, Rectangle rectangle, DrawFrameControlTypes Type, DrawFrameControlStates State) {
3931 // make a rectange to trace around border of the button
3932 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
3934 case DrawFrameControlTypes.Button: {
3936 if ((State & DrawFrameControlStates.ButtonPush)!=0) {
3937 // JBA 31 oct 2004 - I don't think that button style should be rendered like this
3938 // /* Goes first, affects the background */
3939 // if ((State & DrawFrameControlStates.Checked)!=0) {
3940 // HatchBrush hatchBrush=new HatchBrush(HatchStyle.Percent50, ColorButtonLight, ColorButtonHilight);
3941 // graphics.FillRectangle(hatchBrush,rectangle);
3942 // hatchBrush.Dispose();
3945 if ((State & DrawFrameControlStates.Pushed)!=0 || (State & DrawFrameControlStates.Checked)!=0) {
3946 graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorButtonFace)), trace_rectangle);
3947 } else if ((State & DrawFrameControlStates.Flat)!=0) {
3948 ControlPaint.DrawBorder(graphics, rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
3949 } else if ((State & DrawFrameControlStates.Inactive)!=0) {
3950 /* Same as normal, it would seem */
3951 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
3953 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
3955 } else if ((State & DrawFrameControlStates.ButtonRadio)!=0) {
3956 Pen penFatDark = new Pen(ColorButtonShadow, 1);
3957 Pen penFatLight = new Pen(ColorButtonLight, 1);
3960 graphics.FillPie (ResPool.GetSolidBrush (this.ColorWindow), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
3962 graphics.DrawArc(penFatDark, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 135, 180);
3963 graphics.DrawArc(penFatLight, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 315, 180);
3965 graphics.DrawArc(SystemPens.ControlDark, rectangle, 135, 180);
3966 graphics.DrawArc(SystemPens.ControlLightLight, rectangle, 315, 180);
3968 lineWidth=Math.Max(1, Math.Min(rectangle.Width, rectangle.Height)/3);
3970 if ((State & DrawFrameControlStates.Checked)!=0) {
3971 SolidBrush buttonBrush;
3973 if ((State & DrawFrameControlStates.Inactive)!=0) {
3974 buttonBrush=(SolidBrush)SystemBrushes.ControlDark;
3976 buttonBrush=(SolidBrush)SystemBrushes.ControlText;
3978 graphics.FillPie(buttonBrush, rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2, 0, 359);
3980 penFatDark.Dispose();
3981 penFatLight.Dispose();
3982 } else if ((State & DrawFrameControlStates.ButtonRadioImage)!=0) {
3983 throw new NotImplementedException () ;
3984 } else if ((State & DrawFrameControlStates.ButtonRadioMask)!=0) {
3985 throw new NotImplementedException ();
3986 } else { /* Must be Checkbox */
3992 /* Goes first, affects the background */
3993 if ((State & DrawFrameControlStates.Pushed)!=0 ||
3994 (State & DrawFrameControlStates.Inactive)!=0) {
3995 graphics.FillRectangle(SystemBrushes.Control, rectangle);
3997 graphics.FillRectangle(SystemBrushes.Window, rectangle);
4000 /* Draw the sunken frame */
4001 if ((State & DrawFrameControlStates.Flat)!=0) {
4002 ControlPaint.DrawBorder(graphics, rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
4004 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
4007 /* Make sure we've got at least a line width of 1 */
4008 lineWidth=Math.Max(3, rectangle.Width/6);
4009 Scale=Math.Max(1, rectangle.Width/12);
4011 // define a rectangle inside the border area
4012 rect=new Rectangle(rectangle.X+2, rectangle.Y+2, rectangle.Width-4, rectangle.Height-4);
4013 if ((State & DrawFrameControlStates.Inactive)!=0) {
4014 pen=SystemPens.ControlDark;
4016 pen=SystemPens.ControlText;
4019 if ((State & DrawFrameControlStates.Checked)!=0) {
4020 /* Need to draw a check-mark */
4021 for (int i=0; i<lineWidth; i++) {
4022 graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
4023 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);
4031 case DrawFrameControlTypes.Caption: {
4036 case DrawFrameControlTypes.Menu: {
4041 case DrawFrameControlTypes.Scroll: {
4048 /* Generic scroll button */
4049 public void DrawScrollButtonPrimitive (Graphics dc, Rectangle area, ButtonState state) {
4050 if ((state & ButtonState.Pushed) == ButtonState.Pushed) {
4051 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X + 1,
4052 area.Y + 1, area.Width - 2 , area.Height - 2);
4054 dc.DrawRectangle (ResPool.GetPen (ColorButtonShadow), area.X,
4055 area.Y, area.Width, area.Height);
4060 dc.FillRectangle (new SolidBrush (Color.Blue), area);
4062 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X, area.Y, area.Width, 1);
4063 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X, area.Y, 1, area.Height);
4065 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonHilight), area.X + 1, area.Y + 1, area.Width - 1, 1);
4066 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonHilight), area.X + 1, area.Y + 2, 1,
4069 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonShadow), area.X + 1, area.Y + area.Height - 2,
4072 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonDkShadow), area.X, area.Y + area.Height -1,
4075 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonShadow), area.X + area.Width - 2,
4076 area.Y + 1, 1, area.Height -3);
4078 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonDkShadow), area.X + area.Width -1,
4079 area.Y, 1, area.Height - 1);
4081 dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X + 2,
4082 area.Y + 2, area.Width - 4, area.Height - 4);
4086 public override void CPDrawBorderStyle (Graphics dc, Rectangle area, BorderStyle border_style) {
4087 switch (border_style){
4088 case BorderStyle.Fixed3D:
4089 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), area.X, area.Y, area.X +area.Width, area.Y);
4090 dc.DrawLine (ResPool.GetPen (ColorButtonShadow), area.X, area.Y, area.X, area.Y + area.Height);
4091 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), area.X , area.Y + area.Height - 1, area.X + area.Width ,
4092 area.Y + area.Height - 1);
4093 dc.DrawLine (ResPool.GetPen (ColorButtonHilight), area.X + area.Width -1 , area.Y, area.X + area.Width -1,
4094 area.Y + area.Height);
4096 case BorderStyle.FixedSingle:
4097 dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame), area.X, area.Y, area.Width - 1, area.Height - 1);
4099 case BorderStyle.None:
4105 #endregion // ControlPaint