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-2006 Novell, Inc.
23 // Jordi Mas i Hernandez, jordi@ximian.com
24 // Peter Bartok, pbartok@novell.com
25 // John BouAntoun, jba-mono@optusnet.com.au
26 // Marek Safar, marek.safar@seznam.cz
31 using System.Drawing.Drawing2D;
32 using System.Drawing.Imaging;
33 using System.Drawing.Text;
35 namespace System.Windows.Forms
38 internal class ThemeWin32Classic : Theme
40 public override Version Version {
42 return new Version(0, 1, 0, 0);
46 /* Hardcoded colour values not exposed in the API constants in all configurations */
47 protected static readonly Color arrow_color = Color.Black;
48 protected static readonly Color pen_ticks_color = Color.Black;
49 protected static readonly Color progressbarblock_color = Color.FromArgb (255, 0, 0, 128);
50 protected static StringFormat string_format_menu_text;
51 protected static StringFormat string_format_menu_shortcut;
52 protected static StringFormat string_format_menu_menubar_text;
53 static readonly Rectangle checkbox_rect = new Rectangle (2, 2, 11,11); // Position of the checkbox relative to the item
54 static ImageAttributes imagedisabled_attributes = null;
55 const int SEPARATOR_HEIGHT = 5;
56 const int SM_CXBORDER = 1;
57 const int SM_CYBORDER = 1;
58 const int MENU_TAB_SPACE = 8; // Pixels added to the width of an item because of a tab
59 const int MENU_BAR_ITEMS_SPACE = 8; // Space between menu bar items
61 #region Principal Theme Methods
62 public ThemeWin32Classic ()
64 defaultWindowBackColor = this.ColorWindow;
65 defaultWindowForeColor = this.ColorControlText;
66 default_font = new Font (FontFamily.GenericSansSerif, 8.25f);
68 /* Menu string formats */
69 string_format_menu_text = new StringFormat ();
70 string_format_menu_text.LineAlignment = StringAlignment.Center;
71 string_format_menu_text.Alignment = StringAlignment.Near;
72 string_format_menu_text.HotkeyPrefix = HotkeyPrefix.Show;
74 string_format_menu_shortcut = new StringFormat ();
75 string_format_menu_shortcut.LineAlignment = StringAlignment.Center;
76 string_format_menu_shortcut.Alignment = StringAlignment.Far;
78 string_format_menu_menubar_text = new StringFormat ();
79 string_format_menu_menubar_text.LineAlignment = StringAlignment.Center;
80 string_format_menu_menubar_text.Alignment = StringAlignment.Center;
81 string_format_menu_menubar_text.HotkeyPrefix = HotkeyPrefix.Show;
82 always_draw_hotkeys = false;
85 public override void ResetDefaults() {
86 throw new NotImplementedException("Need to implement ResetDefaults() for Win32 theme");
89 public override bool DoubleBufferingSupported {
92 #endregion // Principal Theme Methods
94 #region Internal Methods
95 protected SolidBrush GetControlBackBrush (Color c) {
96 if (c == DefaultControlBackColor)
97 return ResPool.GetSolidBrush (ColorControl);
98 return ResPool.GetSolidBrush (c);
101 protected SolidBrush GetControlForeBrush (Color c) {
102 if (c == DefaultControlForeColor)
103 return ResPool.GetSolidBrush (ColorControlText);
104 return ResPool.GetSolidBrush (c);
106 #endregion // Internal Methods
108 #region OwnerDraw Support
109 public override void DrawOwnerDrawBackground (DrawItemEventArgs e)
111 if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
112 e.Graphics.FillRectangle (SystemBrushes.Highlight, e.Bounds);
116 e.Graphics.FillRectangle (GetControlBackBrush (e.BackColor), e.Bounds);
119 public override void DrawOwnerDrawFocusRectangle (DrawItemEventArgs e)
121 if (e.State == DrawItemState.Focus)
122 CPDrawFocusRectangle (e.Graphics, e.Bounds, e.ForeColor, e.BackColor);
124 #endregion // OwnerDraw Support
127 public override void DrawButtonBase(Graphics dc, Rectangle clip_area, ButtonBase button) {
128 // Draw the button: fill rectangle, draw border, etc.
129 ButtonBase_DrawButton(button, dc);
131 // First, draw the image
132 if ((button.image != null) || (button.image_list != null))
133 ButtonBase_DrawImage(button, dc);
135 // Draw the focus rectangle
136 if (button.has_focus)
137 ButtonBase_DrawFocus(button, dc);
140 if (button.text != null && button.text != String.Empty)
141 ButtonBase_DrawText(button, dc);
144 protected virtual void ButtonBase_DrawButton(ButtonBase button, Graphics dc)
146 Rectangle buttonRectangle;
147 Rectangle borderRectangle;
149 dc.FillRectangle(ResPool.GetSolidBrush (button.BackColor), button.ClientRectangle);
151 // set up the button rectangle
152 buttonRectangle = button.ClientRectangle;
153 if (button.has_focus || button.paint_as_acceptbutton) {
154 // shrink the rectangle for the normal button drawing inside the focus rectangle
155 borderRectangle = Rectangle.Inflate(buttonRectangle, -1, -1);
157 borderRectangle = buttonRectangle;
160 if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
161 DrawFlatStyleButton (dc, borderRectangle, button);
163 CPDrawButton(dc, borderRectangle, button.ButtonState);
164 if (button.has_focus || button.paint_as_acceptbutton) {
165 dc.DrawRectangle(ResPool.GetPen(button.ForeColor), borderRectangle);
170 protected virtual void ButtonBase_DrawImage(ButtonBase button, Graphics dc)
172 // Need to draw a picture
179 int width = button.ClientSize.Width;
180 int height = button.ClientSize.Height;
182 if (button.ImageIndex != -1) { // We use ImageIndex instead of image_index since it will return -1 if image_list is null
183 i = button.image_list.Images[button.image_index];
188 image_width = button.image.Width;
189 image_height = button.image.Height;
191 switch (button.image_alignment) {
192 case ContentAlignment.TopLeft: {
198 case ContentAlignment.TopCenter: {
199 image_x=(width-image_width)/2;
204 case ContentAlignment.TopRight: {
205 image_x=width-image_width;
210 case ContentAlignment.MiddleLeft: {
212 image_y=(height-image_height)/2;
216 case ContentAlignment.MiddleCenter: {
217 image_x=(width-image_width)/2;
218 image_y=(height-image_height)/2;
222 case ContentAlignment.MiddleRight: {
223 image_x=width-image_width;
224 image_y=(height-image_height)/2;
228 case ContentAlignment.BottomLeft: {
230 image_y=height-image_height;
234 case ContentAlignment.BottomCenter: {
235 image_x=(width-image_width)/2;
236 image_y=height-image_height;
240 case ContentAlignment.BottomRight: {
241 image_x=width-image_width;
242 image_y=height-image_height;
253 if (button.is_pressed) {
258 if (button.is_enabled) {
259 dc.DrawImage(i, image_x, image_y);
262 CPDrawImageDisabled(dc, i, image_x, image_y, ColorControl);
266 protected virtual void ButtonBase_DrawFocus(ButtonBase button, Graphics dc)
268 if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
269 DrawFlatStyleFocusRectangle (dc, button.ClientRectangle, button, button.ForeColor, button.BackColor);
271 Rectangle rect = button.ClientRectangle;
272 rect.Inflate (-4, -4);
273 CPDrawFocusRectangle(dc, rect, button.ForeColor, button.BackColor);
277 protected virtual void ButtonBase_DrawText(ButtonBase button, Graphics dc)
279 Rectangle buttonRectangle = button.ClientRectangle;
280 Rectangle text_rect = Rectangle.Inflate(buttonRectangle, -4, -4);
282 if (button.is_pressed) {
287 if (button.is_enabled) {
288 dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (button.ForeColor), text_rect, button.text_format);
290 if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
291 dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorControl)), text_rect, button.text_format);
293 CPDrawStringDisabled(dc, button.text, button.Font, ColorControlText, text_rect, button.text_format);
298 // draw the flat style part of the rectangle
299 public void DrawFlatStyleButton (Graphics graphics, Rectangle rectangle, ButtonBase button) {
300 Color rect_back_color = button.BackColor;
301 Color rect_fore_color = button.ForeColor;
302 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
304 if (button.Enabled) {
305 if (button.Capture || button.is_entered) {
306 if (button.FlatStyle == FlatStyle.Flat) {
307 // fill the rectangle
308 graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
310 // now draw the outer border
311 if (button.Capture && button.is_entered) {
312 rect_back_color = ControlPaint.LightLight (rect_back_color);
314 rect_back_color = ControlPaint.Light (rect_back_color);
317 // draw rectangle and fill it
318 graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
319 graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
321 // else it must be a popup button
323 if (button.Capture && button.is_entered) {
324 graphics.DrawRectangle(ResPool.GetPen (this.ColorControlText), trace_rectangle);
327 CPDrawBorder3D (graphics, rectangle, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, button.BackColor);
328 graphics.DrawLine ( ResPool.GetPen (this.ColorControlText), trace_rectangle.X, trace_rectangle.Bottom, trace_rectangle.Right, trace_rectangle.Bottom);
329 graphics.DrawLine ( ResPool.GetPen (this.ColorControlText), trace_rectangle.Right, trace_rectangle.Y, trace_rectangle.Right, trace_rectangle.Bottom);
333 // TODO: draw inner focus rectangle
336 // popup has a ButtonColorText forecolor, not a button.ForeCOlor
337 if (button.FlatStyle == FlatStyle.Popup) {
338 rect_fore_color = this.ColorControlText;
341 // fill then draw outer rect
342 graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
343 graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
346 // finally some small tweaks to render radiobutton and checkbox
347 CheckBox checkbox = button as CheckBox;
348 RadioButton radiobutton = button as RadioButton;
349 if ((checkbox != null && checkbox.Checked) ||
350 (radiobutton != null && radiobutton.Checked)) {
351 if (button.FlatStyle == FlatStyle.Flat && button.is_entered && !button.Capture) {
352 // render the hover for flat flatstyle and cheked
353 graphics.DrawRectangle(ResPool.GetPen (this.ColorControlText), trace_rectangle);
354 } else if (!button.is_entered && !button.Capture) {
355 // render the checked state for popup when unhovered
356 CPDrawBorder3D (graphics, rectangle, Border3DStyle.SunkenInner, Border3DSide.Right | Border3DSide.Bottom, button.BackColor);
360 // rendering checkbox or radio button style buttons
361 CheckBox checkbox = button as CheckBox;
362 RadioButton radiobutton = button as RadioButton;
363 bool draw_popup_checked = false;
365 if (button.FlatStyle == FlatStyle.Popup) {
366 rect_fore_color = this.ColorControlText;
368 // see if we should draw a disabled checked popup button
369 draw_popup_checked = ((checkbox != null && checkbox.Checked) ||
370 (radiobutton != null && radiobutton.Checked));
373 graphics.FillRectangle (ResPool.GetSolidBrush (rect_back_color), rectangle);
374 graphics.DrawRectangle(ResPool.GetPen (rect_fore_color), trace_rectangle);
376 // finally draw the flatstyle checked effect if need
377 if (draw_popup_checked) {
378 // render the checked state for popup when unhovered
379 CPDrawBorder3D (graphics, rectangle, Border3DStyle.SunkenInner, Border3DSide.Right | Border3DSide.Bottom, button.BackColor);
384 public override Size ButtonBaseDefaultSize {
386 return new Size (75, 23);
389 #endregion // ButtonBase
392 public override void DrawCheckBox(Graphics dc, Rectangle clip_area, CheckBox checkbox) {
393 StringFormat text_format;
394 Rectangle client_rectangle;
395 Rectangle text_rectangle;
396 Rectangle checkbox_rectangle;
397 int checkmark_size=13;
398 int checkmark_space = 4;
400 client_rectangle = checkbox.ClientRectangle;
401 text_rectangle = client_rectangle;
402 checkbox_rectangle = new Rectangle(text_rectangle.X, text_rectangle.Y, checkmark_size, checkmark_size);
404 text_format = new StringFormat();
405 text_format.Alignment=StringAlignment.Near;
406 text_format.LineAlignment=StringAlignment.Center;
407 text_format.HotkeyPrefix = HotkeyPrefix.Show;
409 /* Calculate the position of text and checkbox rectangle */
410 if (checkbox.appearance!=Appearance.Button) {
411 switch(checkbox.check_alignment) {
412 case ContentAlignment.BottomCenter: {
413 checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
414 checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
415 text_rectangle.X=client_rectangle.X;
416 text_rectangle.Width=client_rectangle.Width;
417 text_rectangle.Height=client_rectangle.Height-checkbox_rectangle.Y-checkmark_space;
421 case ContentAlignment.BottomLeft: {
422 checkbox_rectangle.X=client_rectangle.Left;
423 checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
424 text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
425 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
429 case ContentAlignment.BottomRight: {
430 checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
431 checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
432 text_rectangle.X=client_rectangle.X;
433 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
437 case ContentAlignment.MiddleCenter: {
438 checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
439 checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
440 text_rectangle.X=client_rectangle.X;
441 text_rectangle.Width=client_rectangle.Width;
446 case ContentAlignment.MiddleLeft: {
447 checkbox_rectangle.X=client_rectangle.Left;
448 checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
449 text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
450 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
454 case ContentAlignment.MiddleRight: {
455 checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
456 checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
457 text_rectangle.X=client_rectangle.X;
458 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
462 case ContentAlignment.TopCenter: {
463 checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
464 checkbox_rectangle.Y=client_rectangle.Top;
465 text_rectangle.X=client_rectangle.X;
466 text_rectangle.Width=client_rectangle.Width;
467 text_rectangle.Y=checkmark_size+checkmark_space;
468 text_rectangle.Height=client_rectangle.Height-checkmark_size-checkmark_space;
472 case ContentAlignment.TopLeft: {
473 checkbox_rectangle.X=client_rectangle.Left;
474 text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
475 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
479 case ContentAlignment.TopRight: {
480 checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
481 text_rectangle.X=client_rectangle.X;
482 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
487 text_rectangle.X=client_rectangle.X;
488 text_rectangle.Width=client_rectangle.Width;
491 /* Set the horizontal alignment of our text */
492 switch(checkbox.text_alignment) {
493 case ContentAlignment.BottomLeft:
494 case ContentAlignment.MiddleLeft:
495 case ContentAlignment.TopLeft: {
496 text_format.Alignment=StringAlignment.Near;
500 case ContentAlignment.BottomCenter:
501 case ContentAlignment.MiddleCenter:
502 case ContentAlignment.TopCenter: {
503 text_format.Alignment=StringAlignment.Center;
507 case ContentAlignment.BottomRight:
508 case ContentAlignment.MiddleRight:
509 case ContentAlignment.TopRight: {
510 text_format.Alignment=StringAlignment.Far;
515 /* Set the vertical alignment of our text */
516 switch(checkbox.text_alignment) {
517 case ContentAlignment.TopLeft:
518 case ContentAlignment.TopCenter:
519 case ContentAlignment.TopRight: {
520 text_format.LineAlignment=StringAlignment.Near;
524 case ContentAlignment.BottomLeft:
525 case ContentAlignment.BottomCenter:
526 case ContentAlignment.BottomRight: {
527 text_format.LineAlignment=StringAlignment.Far;
531 case ContentAlignment.MiddleLeft:
532 case ContentAlignment.MiddleCenter:
533 case ContentAlignment.MiddleRight: {
534 text_format.LineAlignment=StringAlignment.Center;
539 ButtonState state = ButtonState.Normal;
540 if (checkbox.FlatStyle == FlatStyle.Flat) {
541 state |= ButtonState.Flat;
544 if (checkbox.Checked) {
545 state |= ButtonState.Checked;
548 if (checkbox.ThreeState && (checkbox.CheckState == CheckState.Indeterminate)) {
549 state |= ButtonState.Checked;
550 state |= ButtonState.Pushed;
553 // finally make sure the pushed and inavtive states are rendered
554 if (!checkbox.Enabled) {
555 state |= ButtonState.Inactive;
557 else if (checkbox.is_pressed) {
558 state |= ButtonState.Pushed;
564 CheckBox_DrawCheckBox(dc, checkbox, state, checkbox_rectangle);
566 CheckBox_DrawText(checkbox, text_rectangle, dc, text_format);
568 CheckBox_DrawFocus(checkbox, dc, text_rectangle);
570 text_format.Dispose ();
573 protected virtual void CheckBox_DrawCheckBox( Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle )
575 dc.FillRectangle (ResPool.GetSolidBrush (checkbox.BackColor), checkbox.ClientRectangle);
576 // render as per normal button
577 if (checkbox.appearance==Appearance.Button) {
578 if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
579 DrawFlatStyleButton(dc, checkbox.ClientRectangle, checkbox);
581 CPDrawButton(dc, checkbox.ClientRectangle, state);
584 // establish if we are rendering a flat style of some sort
585 if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
586 DrawFlatStyleCheckBox (dc, checkbox_rectangle, checkbox);
588 ControlPaint.DrawCheckBox(dc, checkbox_rectangle, state);
593 protected virtual void CheckBox_DrawText( CheckBox checkbox, Rectangle text_rectangle, Graphics dc, StringFormat text_format )
597 // offset the text if it's pressed and a button
598 if (checkbox.Appearance == Appearance.Button) {
599 if (checkbox.Checked || (checkbox.Capture && checkbox.FlatStyle != FlatStyle.Flat)) {
604 text_rectangle.Inflate(-4, -4);
607 /* Place the text; to be compatible with Windows place it after the checkbox has been drawn */
609 // Windows seems to not wrap text in certain situations, this matches as close as I could get it
610 if ((float)(checkbox.Font.Height * 1.5f) > text_rectangle.Height) {
611 text_format.FormatFlags |= StringFormatFlags.NoWrap;
613 if (checkbox.Enabled) {
614 sb = ResPool.GetSolidBrush(checkbox.ForeColor);
615 dc.DrawString(checkbox.Text, checkbox.Font, sb, text_rectangle, text_format);
616 } else if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
617 dc.DrawString(checkbox.Text, checkbox.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorControl)), text_rectangle, text_format);
619 CPDrawStringDisabled(dc, checkbox.Text, checkbox.Font, ColorControlText, text_rectangle, text_format);
623 protected virtual void CheckBox_DrawFocus( CheckBox checkbox, Graphics dc, Rectangle text_rectangle )
625 if (checkbox.Focused) {
626 if (checkbox.FlatStyle != FlatStyle.Flat) {
627 DrawInnerFocusRectangle (dc, Rectangle.Inflate (text_rectangle, -1, -1), checkbox.BackColor);
629 dc.DrawRectangle (ResPool.GetPen (checkbox.ForeColor), Rectangle.Inflate (text_rectangle, -1, -1));
634 // renders a checkBox with the Flat and Popup FlatStyle
635 protected virtual void DrawFlatStyleCheckBox (Graphics graphics, Rectangle rectangle, CheckBox checkbox)
639 Rectangle checkbox_rectangle;
640 Rectangle fill_rectangle;
644 // set up our rectangles first
645 if (checkbox.FlatStyle == FlatStyle.Popup && checkbox.is_entered) {
646 // clip one pixel from bottom right for non popup rendered checkboxes
647 checkbox_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max(rectangle.Width-1, 0), Math.Max(rectangle.Height-1,0));
648 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));
650 // clip two pixels from bottom right for non popup rendered checkboxes
651 checkbox_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max(rectangle.Width-2, 0), Math.Max(rectangle.Height-2,0));
652 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));
655 // if disabled render in disabled state
656 if (checkbox.Enabled) {
657 // process the state of the checkbox
658 if (checkbox.is_entered || checkbox.Capture) {
659 // decide on which background color to use
660 if (checkbox.FlatStyle == FlatStyle.Popup && checkbox.is_entered && checkbox.Capture) {
661 graphics.FillRectangle(ResPool.GetSolidBrush (checkbox.BackColor), fill_rectangle);
662 } else if (checkbox.FlatStyle == FlatStyle.Flat && !(checkbox.is_entered && checkbox.Capture)) {
663 graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.Light(checkbox.BackColor)), fill_rectangle);
665 // use regular window background color
666 graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);
669 // render the outer border
670 if (checkbox.FlatStyle == FlatStyle.Flat) {
671 ControlPaint.DrawBorder(graphics, checkbox_rectangle, checkbox.ForeColor, ButtonBorderStyle.Solid);
673 // draw sunken effect
674 CPDrawBorder3D (graphics, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, checkbox.BackColor);
677 graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);
679 if (checkbox.FlatStyle == FlatStyle.Flat) {
680 ControlPaint.DrawBorder(graphics, checkbox_rectangle, checkbox.ForeColor, ButtonBorderStyle.Solid);
682 // draw the outer border
683 ControlPaint.DrawBorder(graphics, checkbox_rectangle, ControlPaint.DarkDark (checkbox.BackColor), ButtonBorderStyle.Solid);
687 if (checkbox.FlatStyle == FlatStyle.Popup) {
688 graphics.FillRectangle(SystemBrushes.Control, fill_rectangle);
691 // draw disabled state,
692 ControlPaint.DrawBorder(graphics, checkbox_rectangle, ColorControlDark, ButtonBorderStyle.Solid);
695 /* Make sure we've got at least a line width of 1 */
696 lineWidth = Math.Max(3, fill_rectangle.Width/3);
697 Scale=Math.Max(1, fill_rectangle.Width/9);
699 // flat style check box is rendered inside a rectangle shifted down by one
700 rect=new Rectangle(fill_rectangle.X, fill_rectangle.Y+1, fill_rectangle.Width, fill_rectangle.Height);
701 if (checkbox.Enabled) {
702 pen=ResPool.GetPen(checkbox.ForeColor);
704 pen=SystemPens.ControlDark;
707 if (checkbox.Checked) {
708 /* Need to draw a check-mark */
709 for (int i=0; i<lineWidth; i++) {
710 graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
711 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);
717 #endregion // CheckBox
719 #region CheckedListBox
721 public override Rectangle CheckedListBoxCheckRectangle ()
723 return checkbox_rect;
726 public override void DrawCheckedListBoxItem (CheckedListBox ctrl, DrawItemEventArgs e)
728 Color back_color, fore_color;
729 Rectangle item_rect = e.Bounds;
731 StringFormat string_format = ctrl.GetFormatString ();
735 if ((ctrl.Items.GetListBoxItem (e.Index)).State == CheckState.Checked)
736 state = ButtonState.Checked;
738 state = ButtonState.Normal;
740 if (ctrl.ThreeDCheckBoxes == false)
741 state |= ButtonState.Flat;
743 ControlPaint.DrawCheckBox (e.Graphics,
744 item_rect.X + checkbox_rect.X, item_rect.Y + checkbox_rect.Y,
745 checkbox_rect.Width, checkbox_rect.Height,
748 item_rect.X += checkbox_rect.Width + checkbox_rect.X * 2;
749 item_rect.Width -= checkbox_rect.Width + checkbox_rect.X * 2;
752 if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
753 back_color = ColorHighlight;
754 fore_color = ColorHighlightText;
757 back_color = e.BackColor;
758 fore_color = e.ForeColor;
761 e.Graphics.FillRectangle (ResPool.GetSolidBrush
762 (back_color), item_rect);
764 e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
765 ResPool.GetSolidBrush (fore_color),
766 item_rect, string_format);
768 if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
769 CPDrawFocusRectangle (e.Graphics, item_rect,
770 fore_color, back_color);
774 #endregion // CheckedListBox
780 public override void DrawComboBoxEditDecorations (Graphics dc, ComboBox ctrl, Rectangle cl)
782 dc.DrawLine (ResPool.GetPen (ColorControlDark), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top
783 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
784 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
785 dc.DrawLine (ResPool.GetPen (ColorControlLight), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
786 dc.DrawLine (ResPool.GetPen (ColorControlDark), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
787 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2);
788 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + cl.Width - 2, cl.Y, cl.X + cl.Width - 2, cl.Y + cl.Height); //right
789 dc.DrawLine (ResPool.GetPen (ColorControlLight), cl.X + cl.Width - 1, cl.Y + 1 , cl.X + cl.Width - 1, cl.Y + cl.Height - 1);
793 public override int DrawComboBoxEditDecorationTop () { return 2;}
794 public override int DrawComboBoxEditDecorationBottom () { return 2;}
795 public override int DrawComboBoxEditDecorationRight () { return 2;}
796 public override int DrawComboBoxEditDecorationLeft () { return 2;}
798 private int DrawComboListBoxDecoration (ComboBoxStyle style)
800 if (style == ComboBoxStyle.Simple)
806 public override int DrawComboListBoxDecorationTop (ComboBoxStyle style)
808 return DrawComboListBoxDecoration (style);
811 public override int DrawComboListBoxDecorationBottom (ComboBoxStyle style)
813 return DrawComboListBoxDecoration (style);
816 public override int DrawComboListBoxDecorationRight (ComboBoxStyle style)
818 return DrawComboListBoxDecoration (style);
821 public override int DrawComboListBoxDecorationLeft (ComboBoxStyle style)
823 return DrawComboListBoxDecoration (style);
826 public override void DrawComboListBoxDecorations (Graphics dc, ComboBox ctrl, Rectangle cl)
828 if (ctrl.DropDownStyle == ComboBoxStyle.Simple) {
829 DrawComboBoxEditDecorations (dc, ctrl, cl);
832 dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame),
833 cl.X, cl.Y, cl.Width - 1, cl.Height - 1);
837 public override void DrawComboBoxItem (ComboBox ctrl, DrawItemEventArgs e)
839 Color back_color, fore_color;
840 Rectangle text_draw = e.Bounds;
841 StringFormat string_format = new StringFormat ();
842 string_format.FormatFlags = StringFormatFlags.LineLimit;
844 if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
845 back_color = ColorHighlight;
846 fore_color = ColorHighlightText;
849 back_color = e.BackColor;
850 fore_color = e.ForeColor;
853 e.Graphics.FillRectangle (ResPool.GetSolidBrush (back_color), e.Bounds);
856 e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
857 ResPool.GetSolidBrush (fore_color),
858 text_draw, string_format);
861 if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
862 CPDrawFocusRectangle (e.Graphics, e.Bounds, fore_color, back_color);
865 string_format.Dispose ();
871 public override int DataGridPreferredColumnWidth { get { return 75;} }
872 public override int DataGridMinimumColumnCheckBoxHeight { get { return 16;} }
873 public override int DataGridMinimumColumnCheckBoxWidth { get { return 16;} }
874 public override Color DataGridAlternatingBackColor { get { return ColorWindow;} }
875 public override Color DataGridBackColor { get { return ColorWindow;} }
876 public override Color DataGridBackgroundColor { get { return ColorAppWorkspace;} }
877 public override Color DataGridCaptionBackColor { get { return ColorActiveCaption;} }
878 public override Color DataGridCaptionForeColor { get { return ColorActiveCaptionText;} }
879 public override Color DataGridGridLineColor { get { return ColorControl;} }
880 public override Color DataGridHeaderBackColor { get { return ColorControl;} }
881 public override Color DataGridHeaderForeColor { get { return ColorControlText;} }
882 public override Color DataGridLinkColor { get { return ColorHotTrack;} }
883 public override Color DataGridLinkHoverColor { get { return ColorHotTrack;} }
884 public override Color DataGridParentRowsBackColor { get { return ColorControl;} }
885 public override Color DataGridParentRowsForeColor { get { return ColorWindowText;} }
886 public override Color DataGridSelectionBackColor { get { return ColorActiveCaption;} }
887 public override Color DataGridSelectionForeColor { get { return ColorActiveCaptionText;} }
889 public override void DataGridPaint (PaintEventArgs pe, DataGrid grid)
892 if (pe.ClipRectangle.IntersectsWith (grid.grid_drawing.parent_rows)) {
893 pe.Graphics.FillRectangle (ResPool.GetSolidBrush (grid.ParentRowsBackColor), grid.grid_drawing.parent_rows);
896 DataGridPaintCaption (pe.Graphics, pe.ClipRectangle, grid);
897 DataGridPaintColumnsHdrs (pe.Graphics, pe.ClipRectangle, grid);
898 DataGridPaintRowsHeaders (pe.Graphics, pe.ClipRectangle, grid);
899 DataGridPaintRows (pe.Graphics, grid.grid_drawing.cells_area, pe.ClipRectangle, grid);
901 // Paint scrollBar corner
902 if (grid.vert_scrollbar.Visible && grid.horiz_scrollbar.Visible) {
904 Rectangle corner = new Rectangle (grid.ClientRectangle.X + grid.ClientRectangle.Width - grid.horiz_scrollbar.Height,
905 grid.ClientRectangle.Y + grid.ClientRectangle.Height - grid.horiz_scrollbar.Height,
906 grid.horiz_scrollbar.Height, grid.horiz_scrollbar.Height);
908 if (pe.ClipRectangle.IntersectsWith (corner)) {
909 pe.Graphics.FillRectangle (ResPool.GetSolidBrush (grid.ParentRowsBackColor),
915 public override void DataGridPaintCaption (Graphics g, Rectangle clip, DataGrid grid)
917 Rectangle modified_area = clip;
918 modified_area.Intersect (grid.grid_drawing.caption_area);
920 g.FillRectangle (ResPool.GetSolidBrush (grid.CaptionBackColor),
923 g.DrawString (grid.CaptionText, grid.CaptionFont,
924 ResPool.GetSolidBrush (grid.CaptionForeColor),
925 grid.grid_drawing.caption_area);
928 public override void DataGridPaintColumnsHdrs (Graphics g, Rectangle clip, DataGrid grid)
930 Rectangle columns_area = grid.grid_drawing.columnshdrs_area;
932 if (grid.CurrentTableStyle.CurrentRowHeadersVisible) { // Paint corner shared between row and column header
933 Rectangle rect_bloc = grid.grid_drawing.columnshdrs_area;
934 rect_bloc.Width = grid.RowHeaderWidth;
935 rect_bloc.Height = grid.grid_drawing.columnshdrs_area.Height;
936 if (clip.IntersectsWith (rect_bloc)) {
937 if (grid.visiblecolumn_count > 0) {
938 g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor), rect_bloc);
940 g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), rect_bloc);
944 columns_area.X += grid.RowHeaderWidth;
945 columns_area.Width -= grid.RowHeaderWidth;
949 Rectangle columnshdrs_area_complete = columns_area;
950 columnshdrs_area_complete.Width = grid.grid_drawing.columnshdrs_maxwidth;
952 if (grid.CurrentTableStyle.CurrentRowHeadersVisible) {
953 columnshdrs_area_complete.Width -= grid.RowHeaderWidth;
956 // Set column painting
957 Rectangle rect_columnhdr = new Rectangle ();
960 rect_columnhdr.Y = columns_area.Y;
961 rect_columnhdr.Height = columns_area.Height;
963 current_clip = new Region (columns_area);
964 g.Clip = current_clip;
965 int column_cnt = grid.first_visiblecolumn + grid.visiblecolumn_count;
966 for (int column = grid.first_visiblecolumn; column < column_cnt; column++) {
968 col_pixel = grid.grid_drawing.GetColumnStartingPixel (column);
969 rect_columnhdr.X = columns_area.X + col_pixel - grid.horz_pixeloffset;
970 rect_columnhdr.Width = grid.CurrentTableStyle.GridColumnStyles[column].Width;
972 if (clip.IntersectsWith (rect_columnhdr) == false)
975 grid.CurrentTableStyle.GridColumnStyles[column].PaintHeader (g, rect_columnhdr, column);
980 current_clip.Dispose ();
983 Rectangle not_usedarea = columnshdrs_area_complete;
984 not_usedarea.X = rect_columnhdr.X + rect_columnhdr.Width;
985 not_usedarea.Width = grid.ClientRectangle.X + grid.ClientRectangle.Width - rect_columnhdr.X - rect_columnhdr.Height;
986 g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
990 public override void DataGridPaintRowsHeaders (Graphics g, Rectangle clip, DataGrid grid)
992 Rectangle rowshdrs_area_complete = grid.grid_drawing.rowshdrs_area;
993 rowshdrs_area_complete.Height = grid.grid_drawing.rowshdrs_maxheight;
994 Rectangle rect_row = new Rectangle ();
995 rect_row.X = grid.grid_drawing.rowshdrs_area.X;
996 int rowcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
997 Rectangle not_usedarea = rowshdrs_area_complete;
999 if (rowcnt < grid.RowsCount) { // Paint one row more for partial rows
1003 g.SetClip (grid.grid_drawing.rowshdrs_area);
1004 for (int row = grid.FirstVisibleRow; row < rowcnt; row++) {
1006 rect_row.Width = grid.grid_drawing.rowshdrs_area.Width;
1007 rect_row.Height = grid.RowHeight;
1008 rect_row.Y = grid.grid_drawing.rowshdrs_area.Y + ((row - grid.FirstVisibleRow) * grid.RowHeight);
1010 if (clip.IntersectsWith (rect_row)) {
1011 DataGridPaintRowHeader (g, rect_row, row, grid);
1016 not_usedarea.Height = grid.grid_drawing.rowshdrs_maxheight - grid.grid_drawing.rowshdrs_area.Height;
1017 not_usedarea.Y = grid.grid_drawing.rowshdrs_area.Y + grid.grid_drawing.rowshdrs_area.Height;
1018 g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
1021 public override void DataGridPaintRowHeaderArrow (Graphics g, Rectangle bounds, DataGrid grid)
1023 Point[] arrow = new Point[3];
1025 int centerX, centerY, shiftX;
1028 rect = new Rectangle (bounds.X + bounds.Width /4,
1029 bounds.Y + bounds.Height/4, bounds.Width / 2, bounds.Height / 2);
1031 centerX = rect.Left + rect.Width / 2;
1032 centerY = rect.Top + rect.Height / 2;
1033 shiftX = Math.Max (1, rect.Width / 8);
1036 P1 = new Point (centerX, rect.Top - 1);
1037 P2 = new Point (centerX, rect.Bottom);
1038 P3 = new Point (rect.Right, centerY);
1043 g.FillPolygon (ResPool.GetSolidBrush
1044 (grid.CurrentTableStyle.CurrentHeaderForeColor), arrow, FillMode.Winding);
1047 public override void DataGridPaintRowHeader (Graphics g, Rectangle bounds, int row, DataGrid grid)
1050 g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor),
1053 if (grid.FlatMode == false) {
1056 g.DrawLine (ResPool.GetPen (ColorControlLight),
1057 bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
1059 g.DrawLine (ResPool.GetPen (ColorControlLight),
1060 bounds.X, bounds.Y + 1, bounds.X, bounds.Y + bounds.Height - 1);
1062 g.DrawLine (ResPool.GetPen (ColorControlDark),
1063 bounds.X + bounds.Width - 1, bounds.Y + 1 , bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
1065 g.DrawLine (ResPool.GetPen (ColorControlDark),
1066 bounds.X, bounds.Y + bounds.Height -1, bounds.X + bounds.Width, bounds.Y + bounds.Height -1);
1069 if (grid.ShowEditRow && grid.RowsCount > 0 && row == grid.RowsCount && !(row == grid.CurrentCell.RowNumber && grid.is_changing == true)) {
1071 g.DrawString ("*", grid.grid_drawing.font_newrow, ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
1076 if (row == grid.CurrentCell.RowNumber) {
1078 if (grid.is_changing == true) {
1079 g.DrawString ("...", grid.Font,
1080 ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
1085 Rectangle rect = new Rectangle (bounds.X - 2, bounds.Y, 18, 18);
1086 DataGridPaintRowHeaderArrow (g, rect, grid);
1092 public override void DataGridPaintRows (Graphics g, Rectangle cells, Rectangle clip, DataGrid grid)
1094 Rectangle rect_row = new Rectangle ();
1095 Rectangle not_usedarea = new Rectangle ();
1096 rect_row.X = cells.X;
1098 int rowcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
1100 if (grid.ShowEditRow && grid.RowsCount > 0) {
1104 if (rowcnt < grid.RowsCount) { // Paint one row more for partial rows
1108 rect_row.Height = grid.RowHeight;
1109 rect_row.Width = cells.Width;
1110 for (int row = grid.FirstVisibleRow; row < rowcnt; row++) {
1111 rect_row.Y = cells.Y + ((row - grid.FirstVisibleRow) * grid.RowHeight);
1112 if (clip.IntersectsWith (rect_row)) {
1113 DataGridPaintRow (g, row, rect_row, false, grid);
1117 if (grid.ShowEditRow && grid.RowsCount > 0 && grid.FirstVisibleRow + grid.VisibleRowCount == grid.RowsCount + 1) {
1118 rect_row.Y = cells.Y + ((rowcnt - grid.FirstVisibleRow) * grid.RowHeight);
1119 if (clip.IntersectsWith (rect_row)) {
1120 DataGridPaintRow (g, rowcnt, rect_row, true, grid);
1124 not_usedarea.Height = cells.Y + cells.Height - rect_row.Y - rect_row.Height;
1125 not_usedarea.Y = rect_row.Y + rect_row.Height;
1126 not_usedarea.Width = rect_row.Width = cells.Width;
1127 not_usedarea.X = cells.X;
1129 g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
1132 public override void DataGridPaintRow (Graphics g, int row, Rectangle row_rect, bool is_newrow, DataGrid grid)
1134 Rectangle rect_cell = new Rectangle ();
1136 Color backcolor, forecolor;
1137 Region prev_clip = g.Clip;
1138 Region current_clip;
1139 Rectangle not_usedarea = new Rectangle ();
1141 rect_cell.Y = row_rect.Y;
1142 rect_cell.Height = row_rect.Height;
1144 // PaintCells at row, column
1145 int column_cnt = grid.first_visiblecolumn + grid.visiblecolumn_count;
1146 for (int column = grid.first_visiblecolumn; column < column_cnt; column++) {
1148 col_pixel = grid.grid_drawing.GetColumnStartingPixel (column);
1150 rect_cell.X = row_rect.X + col_pixel - grid.horz_pixeloffset;
1151 rect_cell.Width = grid.CurrentTableStyle.GridColumnStyles[column].Width;
1153 current_clip = new Region (row_rect);
1154 g.Clip = current_clip;
1156 if (grid.IsSelected (row)) {
1157 backcolor = grid.SelectionBackColor;
1158 forecolor = grid.SelectionForeColor;
1161 backcolor = grid.BackColor;
1163 backcolor = grid.AlternatingBackColor;
1166 forecolor = grid.ForeColor;
1170 grid.CurrentTableStyle.GridColumnStyles[column].PaintNewRow (g, rect_cell,
1171 ResPool.GetSolidBrush (backcolor),
1172 ResPool.GetSolidBrush (forecolor));
1175 grid.CurrentTableStyle.GridColumnStyles[column].Paint (g, rect_cell, grid.ListManager, row,
1176 ResPool.GetSolidBrush (backcolor),
1177 ResPool.GetSolidBrush (forecolor),
1178 grid.RightToLeft == RightToLeft.Yes);
1182 current_clip.Dispose ();
1185 if (row_rect.X + row_rect.Width > rect_cell.X + rect_cell.Width) {
1187 not_usedarea.X = rect_cell.X + rect_cell.Width;
1188 not_usedarea.Width = row_rect.X + row_rect.Width - rect_cell.X - rect_cell.Width;
1189 not_usedarea.Y = row_rect.Y;
1190 not_usedarea.Height = row_rect.Height;
1191 g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
1196 #endregion // Datagrid
1198 #region DateTimePicker
1200 public override void DrawDateTimePicker (Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp) {
1201 // if not showing the numeric updown control then render border
1202 if (!dtp.ShowUpDown && clip_rectangle.IntersectsWith (dtp.ClientRectangle)) {
1203 // draw the outer border
1204 Rectangle button_bounds = dtp.ClientRectangle;
1205 this.CPDrawBorder3D (dc, button_bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, dtp.BackColor);
1207 // deflate by the border width
1208 if (clip_rectangle.IntersectsWith (dtp.drop_down_arrow_rect)) {
1209 button_bounds.Inflate (-2,-2);
1210 ButtonState state = dtp.is_drop_down_visible ? ButtonState.Pushed : ButtonState.Normal;
1211 this.CPDrawComboButton (
1213 dtp.drop_down_arrow_rect,
1218 // render the date part
1219 if (clip_rectangle.IntersectsWith (dtp.date_area_rect)) {
1220 // fill the background
1221 dc.FillRectangle (ResPool.GetSolidBrush (ColorWindow), dtp.date_area_rect);
1223 // fill the currently highlighted area
1224 if (dtp.hilight_date_area != Rectangle.Empty) {
1225 dc.FillRectangle (ResPool.GetSolidBrush (ColorHighlight), dtp.hilight_date_area);
1228 // draw the text part
1229 // TODO: if date format is CUstom then we need to draw the dates as separate parts
1230 StringFormat text_format = new StringFormat();
1231 text_format.LineAlignment = StringAlignment.Center;
1232 text_format.Alignment = StringAlignment.Near;
1233 dc.DrawString (dtp.Text, dtp.Font, ResPool.GetSolidBrush (dtp.ForeColor), Rectangle.Inflate(dtp.date_area_rect, -1, -1), text_format);
1234 text_format.Dispose ();
1238 #endregion // DateTimePicker
1241 public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box) {
1242 StringFormat text_format;
1248 rect = box.ClientRectangle;
1250 // Needed once the Dark/Light code below is enabled again
1251 //Color disabled = ColorGrayText;
1253 Pen pen_light = ResPool.GetPen (Color.FromArgb (255,255,255,255));
1254 Pen pen_dark = ResPool.GetPen (Color.FromArgb (255, 128, 128,128));
1256 // TODO: When the Light and Dark methods work this code should be activate it
1257 //Pen pen_light = new Pen (ControlPaint.Light (disabled, 1));
1258 //Pen pen_dark = new Pen (ControlPaint.Dark (disabled, 0));
1260 dc.FillRectangle (ResPool.GetSolidBrush (box.BackColor), rect);
1262 text_format = new StringFormat();
1263 text_format.HotkeyPrefix = HotkeyPrefix.Show;
1265 size = dc.MeasureString (box.Text, box.Font);
1266 width = (int) size.Width;
1268 if (width > box.Width - 16)
1269 width = box.Width - 16;
1271 y = box.Font.Height / 2;
1274 dc.DrawLine (pen_dark, 0, y, 8, y); // top
1275 dc.DrawLine (pen_light, 0, y + 1, 8, y + 1);
1276 dc.DrawLine (pen_dark, 8 + width, y, box.Width, y);
1277 dc.DrawLine (pen_light, 8 + width, y + 1, box.Width, y + 1);
1279 dc.DrawLine (pen_dark, 0, y + 1, 0, box.Height); // left
1280 dc.DrawLine (pen_light, 1, y + 1, 1, box.Height);
1282 dc.DrawLine (pen_dark, 0, box.Height - 2, box.Width, box.Height - 2); // bottom
1283 dc.DrawLine (pen_light, 0, box.Height - 1, box.Width, box.Height - 1);
1285 dc.DrawLine (pen_dark, box.Width - 2, y, box.Width - 2, box.Height - 2); // right
1286 dc.DrawLine (pen_light, box.Width - 1, y, box.Width - 1, box.Height - 2);
1291 dc.DrawString (box.Text, box.Font, ResPool.GetSolidBrush (box.ForeColor), 10, 0, text_format);
1293 CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor,
1294 new RectangleF (10, 0, width, box.Font.Height), text_format);
1296 text_format.Dispose ();
1299 public override Size GroupBoxDefaultSize {
1301 return new Size (200,100);
1307 public override Size HScrollBarDefaultSize {
1309 return new Size (80, this.ScrollBarButtonSize);
1313 #endregion // HScrollBar
1316 public override void DrawLabel (Graphics dc, Rectangle clip_rectangle, Label label)
1318 dc.FillRectangle (ResPool.GetSolidBrush (label.BackColor), clip_rectangle);
1320 if (label.Enabled) {
1321 dc.DrawString (label.Text, label.Font, ResPool.GetSolidBrush (label.ForeColor), clip_rectangle, label.string_format);
1323 ControlPaint.DrawStringDisabled (dc, label.Text, label.Font, label.ForeColor, clip_rectangle, label.string_format);
1328 public override Size LabelDefaultSize {
1330 return new Size (100, 23);
1336 public override void DrawLinkLabel (Graphics dc, Rectangle clip_rectangle, LinkLabel label)
1340 dc.FillRectangle (ResPool.GetSolidBrush (label.BackColor), clip_rectangle);
1342 for (int i = 0; i < label.num_pieces; i++) {
1344 if (clip_rectangle.IntersectsWith (label.pieces[i].rect) == false) {
1348 color = label.GetLinkColor (label.pieces[i], i);
1350 if (label.pieces[i].link == null)
1351 dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (Color.Black),
1352 label.pieces[i].rect.X, label.pieces[i].rect.Y);
1354 dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (color),
1355 label.pieces[i].rect.X, label.pieces[i].rect.Y);
1357 if (label.pieces[i].focused) {
1358 CPDrawFocusRectangle (dc, label.pieces[i].rect, label.ForeColor, label.BackColor);
1363 #endregion // LinkLabel
1368 private int DrawListBoxDecorationSize (BorderStyle border_style)
1370 switch (border_style) {
1371 case BorderStyle.Fixed3D:
1373 case BorderStyle.FixedSingle:
1375 case BorderStyle.None:
1384 public override void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e)
1386 Color back_color, fore_color;
1387 StringFormat string_format = ctrl.GetFormatString ();
1389 if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
1390 back_color = ColorHighlight;
1391 fore_color = ColorHighlightText;
1394 back_color = e.BackColor;
1395 fore_color = e.ForeColor;
1398 e.Graphics.FillRectangle (ResPool.GetSolidBrush
1399 (back_color), e.Bounds);
1401 e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
1402 ResPool.GetSolidBrush (fore_color),
1403 e.Bounds.X, e.Bounds.Y, string_format);
1405 if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
1406 CPDrawFocusRectangle (e.Graphics, e.Bounds,
1407 fore_color, back_color);
1415 public override void DrawListViewItems (Graphics dc, Rectangle clip, ListView control)
1417 bool details = control.View == View.Details;
1419 dc.FillRectangle (ResPool.GetSolidBrush (control.BackColor), clip);
1420 int first = control.FirstVisibleIndex;
1422 for (int i = first; i <= control.LastVisibleIndex; i ++) {
1423 if (clip.IntersectsWith (control.Items[i].GetBounds (ItemBoundsPortion.Entire)))
1424 DrawListViewItem (dc, control, control.Items [i]);
1427 // draw the gridlines
1428 if (details && control.GridLines) {
1429 int top = (control.HeaderStyle == ColumnHeaderStyle.None) ?
1430 2 : control.Font.Height + 2;
1432 // draw vertical gridlines
1433 foreach (ColumnHeader col in control.Columns)
1434 dc.DrawLine (this.ResPool.GetPen (this.ColorControl),
1435 col.Rect.Right, top,
1436 col.Rect.Right, control.TotalHeight);
1437 // draw horizontal gridlines
1438 ListViewItem last_item = null;
1439 foreach (ListViewItem item in control.Items) {
1440 dc.DrawLine (this.ResPool.GetPen (this.ColorControl),
1441 item.GetBounds (ItemBoundsPortion.Entire).Left, item.GetBounds (ItemBoundsPortion.Entire).Top,
1442 control.TotalWidth, item.GetBounds (ItemBoundsPortion.Entire).Top);
1446 // draw a line after at the bottom of the last item
1447 if (last_item != null) {
1448 dc.DrawLine (this.ResPool.GetPen (this.ColorControl),
1449 last_item.GetBounds (ItemBoundsPortion.Entire).Left,
1450 last_item.GetBounds (ItemBoundsPortion.Entire).Bottom,
1452 last_item.GetBounds (ItemBoundsPortion.Entire).Bottom);
1458 // Draw corner between the two scrollbars
1459 if (control.h_scroll.Visible == true && control.h_scroll.Visible == true) {
1460 Rectangle rect = new Rectangle ();
1461 rect.X = control.h_scroll.Location.X + control.h_scroll.Width;
1462 rect.Width = control.v_scroll.Width;
1463 rect.Y = control.v_scroll.Location.Y + control.v_scroll.Height;
1464 rect.Height = control.h_scroll.Height;
1465 dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), rect);
1470 public override void DrawListViewHeader (Graphics dc, Rectangle clip, ListView control)
1472 bool details = (control.View == View.Details);
1474 // border is drawn directly in the Paint method
1475 if (details && control.HeaderStyle != ColumnHeaderStyle.None) {
1476 dc.FillRectangle (ResPool.GetSolidBrush (control.BackColor),
1477 0, 0, control.TotalWidth, control.Font.Height + 5);
1478 if (control.Columns.Count > 0) {
1479 foreach (ColumnHeader col in control.Columns) {
1480 Rectangle rect = col.Rect;
1481 rect.X -= control.h_marker;
1483 if (control.HeaderStyle == ColumnHeaderStyle.Clickable)
1484 state = col.Pressed ? ButtonState.Pushed : ButtonState.Normal;
1486 state = ButtonState.Flat;
1487 this.CPDrawButton (dc, rect, state);
1490 if (rect.Width <= 0)
1492 dc.DrawString (col.Text, DefaultFont,
1493 ResPool.GetSolidBrush (ColorControlText),
1500 public override void DrawListViewHeaderDragDetails (Graphics dc, ListView view, ColumnHeader col, int target_x)
1502 Rectangle rect = col.Rect;
1503 rect.X -= view.h_marker;
1504 Color color = Color.FromArgb (0x7f, ColorControlDark.R, ColorControlDark.G, ColorControlDark.B);
1505 dc.FillRectangle (ResPool.GetSolidBrush (color), rect);
1508 if (rect.Width <= 0)
1510 color = Color.FromArgb (0x7f, ColorControlText.R, ColorControlText.G, ColorControlText.B);
1511 dc.DrawString (col.Text, DefaultFont, ResPool.GetSolidBrush (color), rect, col.Format);
1512 Pen pen = new Pen (ColorHighlight, 2);
1513 dc.DrawLine (pen, target_x, 0, target_x, col.Rect.Height);
1516 protected virtual void DrawListViewItem (Graphics dc, ListView control, ListViewItem item)
1519 if (control.View == View.Details && control.Columns.Count > 0)
1520 col_offset = control.Columns [0].Rect.X;
1524 Rectangle rect_checkrect = item.CheckRectReal;
1525 rect_checkrect.X += col_offset;
1526 Rectangle rect_iconrect = item.GetBounds (ItemBoundsPortion.Icon);
1527 rect_iconrect.X += col_offset;
1528 Rectangle full_rect = item.GetBounds (ItemBoundsPortion.Entire);
1529 full_rect.X += col_offset;
1530 Rectangle text_rect = item.GetBounds (ItemBoundsPortion.Label);
1531 text_rect.X += col_offset;
1533 if (control.CheckBoxes) {
1534 if (control.StateImageList == null) {
1535 // Make sure we've got at least a line width of 1
1536 int check_wd = Math.Max (3, rect_checkrect.Width / 6);
1537 int scale = Math.Max (1, rect_checkrect.Width / 12);
1539 // set the checkbox background
1540 dc.FillRectangle (this.ResPool.GetSolidBrush (this.ColorWindow),
1542 // define a rectangle inside the border area
1543 Rectangle rect = new Rectangle (rect_checkrect.X + 2,
1544 rect_checkrect.Y + 2,
1545 rect_checkrect.Width - 4,
1546 rect_checkrect.Height - 4);
1547 Pen pen = new Pen (this.ColorWindowText, 2);
1548 dc.DrawRectangle (pen, rect);
1550 // Need to draw a check-mark
1553 // adjustments to get the check-mark at the right place
1554 rect.X ++; rect.Y ++;
1555 // following logic is taken from DrawFrameControl method
1556 for (int i = 0; i < check_wd; i++) {
1557 dc.DrawLine (pen, rect.Left + check_wd / 2,
1558 rect.Top + check_wd + i,
1559 rect.Left + check_wd / 2 + 2 * scale,
1560 rect.Top + check_wd + 2 * scale + i);
1562 rect.Left + check_wd / 2 + 2 * scale,
1563 rect.Top + check_wd + 2 * scale + i,
1564 rect.Left + check_wd / 2 + 6 * scale,
1565 rect.Top + check_wd - 2 * scale + i);
1570 if (item.Checked && control.StateImageList.Images.Count > 1)
1571 control.StateImageList.Draw (dc,
1572 rect_checkrect.Location, 1);
1573 else if (! item.Checked && control.StateImageList.Images.Count > 0)
1574 control.StateImageList.Draw (dc,
1575 rect_checkrect.Location, 0);
1579 // Item is drawn as a special case, as it is not just text
1580 if (control.View == View.LargeIcon) {
1581 if (item.ImageIndex > -1 &&
1582 control.LargeImageList != null &&
1583 item.ImageIndex < control.LargeImageList.Images.Count)
1584 control.LargeImageList.Draw (dc, rect_iconrect.Location,
1588 if (item.ImageIndex > -1 &&
1589 control.SmallImageList != null &&
1590 item.ImageIndex < control.SmallImageList.Images.Count)
1591 control.SmallImageList.Draw (dc, rect_iconrect.Location,
1595 // draw the item text
1596 // format for the item text
1597 StringFormat format = new StringFormat ();
1598 if (control.View == View.SmallIcon)
1599 format.LineAlignment = StringAlignment.Near;
1601 format.LineAlignment = StringAlignment.Center;
1602 if (control.View == View.LargeIcon)
1603 format.Alignment = StringAlignment.Center;
1605 format.Alignment = StringAlignment.Near;
1607 if (!control.LabelWrap)
1608 format.FormatFlags = StringFormatFlags.NoWrap;
1610 if (item.Selected) {
1611 if (control.View == View.Details) {
1612 if (control.FullRowSelect) {
1613 dc.FillRectangle (ResPool.GetSolidBrush (ColorHighlight), text_rect);
1616 Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
1618 text_rect.Width = text_size.Width;
1619 dc.FillRectangle (this.ResPool.GetSolidBrush
1620 (this.ColorHighlight), text_rect);
1624 /*Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
1626 Point loc = text_rect.Location;
1627 loc.X += (text_rect.Width - text_size.Width) / 2;
1628 text_rect.Width = text_size.Width;*/
1629 dc.FillRectangle (this.ResPool.GetSolidBrush (this.ColorHighlight),
1634 dc.FillRectangle (ResPool.GetSolidBrush (item.BackColor), text_rect);
1636 if (item.Text != null && item.Text.Length > 0) {
1638 dc.DrawString (item.Text, item.Font, this.ResPool.GetSolidBrush
1639 (this.ColorHighlightText), text_rect, format);
1641 dc.DrawString (item.Text, item.Font, this.ResPool.GetSolidBrush
1642 (item.ForeColor), text_rect, format);
1645 if (control.View == View.Details && control.Columns.Count > 0) {
1646 // draw subitems for details view
1647 ListViewItem.ListViewSubItemCollection subItems = item.SubItems;
1648 int count = (control.Columns.Count < subItems.Count ?
1649 control.Columns.Count : subItems.Count);
1653 ListViewItem.ListViewSubItem subItem;
1654 Rectangle sub_item_rect = text_rect;
1656 // set the format for subitems
1657 format.FormatFlags = StringFormatFlags.NoWrap;
1659 // 0th subitem is the item already drawn
1660 for (int index = 1; index < count; index++) {
1661 subItem = subItems [index];
1662 col = control.Columns [index];
1663 format.Alignment = col.Format.Alignment;
1664 sub_item_rect.X = col.Rect.X - control.h_marker;
1665 sub_item_rect.Width = col.Wd;
1666 Rectangle sub_item_text_rect = sub_item_rect;
1667 sub_item_text_rect.X += 3;
1668 sub_item_text_rect.Width -= 6;
1670 SolidBrush sub_item_back_br = null;
1671 SolidBrush sub_item_fore_br = null;
1672 Font sub_item_font = null;
1674 if (item.UseItemStyleForSubItems) {
1675 sub_item_back_br = ResPool.GetSolidBrush (item.BackColor);
1676 sub_item_fore_br = ResPool.GetSolidBrush (item.ForeColor);
1677 sub_item_font = item.Font;
1679 sub_item_back_br = ResPool.GetSolidBrush (subItem.BackColor);
1680 sub_item_fore_br = ResPool.GetSolidBrush (subItem.ForeColor);
1681 sub_item_font = subItem.Font;
1684 if (item.Selected && control.FullRowSelect) {
1685 dc.FillRectangle (ResPool.GetSolidBrush (ColorHighlight), sub_item_rect);
1686 if (subItem.Text != null && subItem.Text.Length > 0)
1687 dc.DrawString (subItem.Text, sub_item_font,
1688 this.ResPool.GetSolidBrush
1689 (this.ColorHighlightText),
1690 sub_item_text_rect, format);
1692 dc.FillRectangle (sub_item_back_br, sub_item_rect);
1693 if (subItem.Text != null && subItem.Text.Length > 0)
1694 dc.DrawString (subItem.Text, sub_item_font,
1696 sub_item_text_rect, format);
1703 Rectangle focus_rect = text_rect;
1704 if (control.FullRowSelect && control.View == View.Details) {
1706 foreach (ColumnHeader col in control.Columns)
1708 focus_rect = new Rectangle (0, full_rect.Y, width, full_rect.Height);
1711 CPDrawFocusRectangle (dc, focus_rect, ColorHighlightText, ColorHighlight);
1713 CPDrawFocusRectangle (dc, focus_rect, control.ForeColor, control.BackColor);
1720 public override Size ListViewCheckBoxSize {
1721 get { return new Size (16, 16); }
1724 public override int ListViewColumnHeaderHeight {
1728 public override int ListViewDefaultColumnWidth {
1732 public override int ListViewVerticalSpacing {
1736 public override int ListViewEmptyColumnWidth {
1740 public override int ListViewHorizontalSpacing {
1744 public override Size ListViewDefaultSize {
1745 get { return new Size (121, 97); }
1747 #endregion // ListView
1750 public override void CalcItemSize (Graphics dc, MenuItem item, int y, int x, bool menuBar)
1755 if (item.Visible == false) {
1761 if (item.Separator == true) {
1762 item.Height = SEPARATOR_HEIGHT / 2;
1767 if (item.MeasureEventDefined) {
1768 MeasureItemEventArgs mi = new MeasureItemEventArgs (dc, item.Index);
1769 item.PerformMeasureItem (mi);
1770 item.Height = mi.ItemHeight;
1771 item.Width = mi.ItemWidth;
1775 size = dc.MeasureString (item.Text, MenuFont);
1776 item.Width = (int) size.Width;
1777 item.Height = (int) size.Height;
1780 if (item.Shortcut != Shortcut.None && item.ShowShortcut) {
1781 item.XTab = MenuCheckSize.Width + MENU_TAB_SPACE + (int) size.Width;
1782 size = dc.MeasureString (" " + item.GetShortCutText (), MenuFont);
1783 item.Width += MENU_TAB_SPACE + (int) size.Width;
1786 item.Width += 4 + (MenuCheckSize.Width * 2);
1788 item.Width += MENU_BAR_ITEMS_SPACE;
1792 if (item.Height < MenuHeight)
1793 item.Height = MenuHeight;
1797 // Updates the menu rect and returns the height
1798 public override int CalcMenuBarSize (Graphics dc, Menu menu, int width)
1804 foreach (MenuItem item in menu.MenuItems) {
1806 CalcItemSize (dc, item, y, x, true);
1808 if (x + item.Width > width) {
1816 item.MenuBar = true;
1818 if (y + item.Height > menu.Height)
1819 menu.Height = item.Height + y;
1826 public override void CalcPopupMenuSize (Graphics dc, Menu menu)
1834 while (start < menu.MenuItems.Count) {
1837 for (i = start; i < menu.MenuItems.Count; i++) {
1838 MenuItem item = menu.MenuItems [i];
1840 if ((i != start) && (item.Break || item.BarBreak))
1843 CalcItemSize (dc, item, y, x, false);
1846 if (item.Width > max)
1850 // Replace the -1 by the menu width (separators)
1851 for (n = start; n < i; n++, start++)
1852 menu.MenuItems [n].Width = max;
1854 if (y > menu.Height)
1866 menu.Width += SM_CXBORDER;
1867 menu.Height += SM_CYBORDER;
1870 // Draws a menu bar in a window
1871 public override void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect)
1873 if (menu.Height == 0)
1874 CalcMenuBarSize (dc, menu, rect.Width);
1876 bool keynav = (menu as MainMenu).tracker.Navigating;
1877 HotkeyPrefix hp = always_draw_hotkeys || keynav ? HotkeyPrefix.Show : HotkeyPrefix.Hide;
1878 string_format_menu_menubar_text.HotkeyPrefix = hp;
1879 string_format_menu_text.HotkeyPrefix = hp;
1881 rect.Height = menu.Height;
1882 dc.FillRectangle (ResPool.GetSolidBrush(ColorMenu), rect);
1884 for (int i = 0; i < menu.MenuItems.Count; i++) {
1885 MenuItem item = menu.MenuItems [i];
1886 Rectangle item_rect = item.bounds;
1887 item_rect.X += rect.X;
1888 item_rect.Y += rect.Y;
1889 item.MenuHeight = menu.Height;
1890 item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont, item_rect, i, item.Status));
1894 Bitmap CreateGlyphBitmap (Size size, MenuGlyph glyph, Color color)
1897 if (color.R == 0 && color.G == 0 && color.B == 0)
1898 bg_color = Color.White;
1900 bg_color = Color.Black;
1901 Bitmap bmp = new Bitmap (size.Width, size.Height);
1902 Graphics gr = Graphics.FromImage (bmp);
1903 Rectangle rect = new Rectangle (Point.Empty, size);
1904 gr.FillRectangle (ResPool.GetSolidBrush (bg_color), rect);
1905 CPDrawMenuGlyph (gr, rect, glyph, color);
1906 bmp.MakeTransparent (bg_color);
1911 public override void DrawMenuItem (MenuItem item, DrawItemEventArgs e)
1913 StringFormat string_format;
1914 Rectangle rect_text = e.Bounds;
1916 if (item.Visible == false)
1920 string_format = string_format_menu_menubar_text;
1922 string_format = string_format_menu_text;
1924 if (item.Separator == true) {
1925 e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
1926 e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y);
1928 e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
1929 e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + 1);
1935 rect_text.X += MenuCheckSize.Width;
1937 if (item.BarBreak) { /* Draw vertical break bar*/
1938 Rectangle rect = e.Bounds;
1941 rect.Height = item.MenuHeight - 6;
1943 e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
1944 rect.X, rect.Y , rect.X, rect.Y + rect.Height);
1946 e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
1947 rect.X + 1, rect.Y , rect.X +1, rect.Y + rect.Height);
1953 if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
1954 color_text = ColorHighlightText;
1955 color_back = ColorHighlight;
1957 color_text = ColorMenuText;
1958 color_back = ColorMenu;
1961 /* Draw background */
1962 Rectangle rect_back = e.Bounds;
1964 rect_back.Width -=2;
1965 e.Graphics.FillRectangle (ResPool.GetSolidBrush (color_back), rect_back);
1968 e.Graphics.DrawString (item.Text, e.Font,
1969 ResPool.GetSolidBrush (color_text),
1970 rect_text, string_format);
1972 if (!item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut) {
1973 string str = item.GetShortCutText ();
1974 Rectangle rect = rect_text;
1976 rect.Width -= item.XTab;
1978 e.Graphics.DrawString (str, e.Font, ResPool.GetSolidBrush (color_text),
1979 rect, string_format_menu_shortcut);
1982 ControlPaint.DrawStringDisabled (e.Graphics, item.Text, e.Font,
1983 Color.Black, rect_text, string_format);
1987 if (item.MenuBar == false && item.IsPopup || item.MdiList) {
1989 int cx = MenuCheckSize.Width;
1990 int cy = MenuCheckSize.Height;
1991 Bitmap bmp = CreateGlyphBitmap (new Size (cx, cy), MenuGlyph.Arrow, color_text);
1994 e.Graphics.DrawImage (bmp, e.Bounds.X + e.Bounds.Width - cx,
1995 e.Bounds.Y + ((e.Bounds.Height - cy) /2));
1997 ControlPaint.DrawImageDisabled (e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
1998 e.Bounds.Y + ((e.Bounds.Height - cy) /2), color_back);
2004 /* Draw checked or radio */
2005 if (item.MenuBar == false && item.Checked) {
2007 Rectangle area = e.Bounds;
2008 int cx = MenuCheckSize.Width;
2009 int cy = MenuCheckSize.Height;
2010 Bitmap bmp = CreateGlyphBitmap (new Size (cx, cy), item.RadioCheck ? MenuGlyph.Bullet : MenuGlyph.Checkmark, color_text);
2012 e.Graphics.DrawImage (bmp, area.X, e.Bounds.Y + ((e.Bounds.Height - cy) / 2));
2018 public override void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect)
2021 dc.FillRectangle (ResPool.GetSolidBrush
2022 (ColorMenu), cliparea);
2024 /* Draw menu borders */
2025 dc.DrawLine (ResPool.GetPen (ColorHighlightText),
2026 rect.X, rect.Y, rect.X + rect.Width, rect.Y);
2028 dc.DrawLine (ResPool.GetPen (ColorHighlightText),
2029 rect.X, rect.Y, rect.X, rect.Y + rect.Height);
2031 dc.DrawLine (ResPool.GetPen (ColorControlDark),
2032 rect.X + rect.Width - 1 , rect.Y , rect.X + rect.Width - 1, rect.Y + rect.Height);
2034 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
2035 rect.X + rect.Width, rect.Y , rect.X + rect.Width, rect.Y + rect.Height);
2037 dc.DrawLine (ResPool.GetPen (ColorControlDark),
2038 rect.X , rect.Y + rect.Height - 1 , rect.X + rect.Width - 1, rect.Y + rect.Height -1);
2040 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
2041 rect.X , rect.Y + rect.Height, rect.X + rect.Width - 1, rect.Y + rect.Height);
2043 for (int i = 0; i < menu.MenuItems.Count; i++)
2044 if (cliparea.IntersectsWith (menu.MenuItems [i].bounds)) {
2045 MenuItem item = menu.MenuItems [i];
2046 item.MenuHeight = menu.Height;
2047 item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont,
2048 item.bounds, i, item.Status));
2054 #region MonthCalendar
2056 // draw the month calendar
2057 public override void DrawMonthCalendar(Graphics dc, Rectangle clip_rectangle, MonthCalendar mc)
2059 Rectangle client_rectangle = mc.ClientRectangle;
2060 Size month_size = mc.SingleMonthSize;
2061 // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
2062 Size calendar_spacing = (Size)((object)mc.calendar_spacing);
2063 Size date_cell_size = (Size)((object)mc.date_cell_size);
2065 // draw the singlecalendars
2068 // adjust for the position of the specific month
2069 for (int i=0; i < mc.CalendarDimensions.Height; i++)
2073 y_offset += month_size.Height + calendar_spacing.Height;
2075 // now adjust for x position
2076 for (int j=0; j < mc.CalendarDimensions.Width; j++)
2080 x_offset += month_size.Width + calendar_spacing.Width;
2087 Rectangle month_rect = new Rectangle (x_offset, y_offset, month_size.Width, month_size.Height);
2088 if (month_rect.IntersectsWith (clip_rectangle)) {
2100 Rectangle bottom_rect = new Rectangle (
2102 Math.Max(client_rectangle.Bottom - date_cell_size.Height - 3, 0),
2103 client_rectangle.Width,
2104 date_cell_size.Height + 2);
2105 // draw the today date if it's set
2106 if (mc.ShowToday && bottom_rect.IntersectsWith (clip_rectangle))
2108 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), bottom_rect);
2110 int today_offset = 5;
2111 if (mc.ShowTodayCircle)
2113 Rectangle today_circle_rect = new Rectangle (
2114 client_rectangle.X + 5,
2115 Math.Max(client_rectangle.Bottom - date_cell_size.Height - 2, 0),
2116 date_cell_size.Width,
2117 date_cell_size.Height);
2118 DrawTodayCircle (dc, today_circle_rect);
2119 today_offset += date_cell_size.Width + 5;
2121 // draw today's date
2122 StringFormat text_format = new StringFormat();
2123 text_format.LineAlignment = StringAlignment.Center;
2124 text_format.Alignment = StringAlignment.Near;
2125 Font bold_font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
2126 Rectangle today_rect = new Rectangle (
2127 today_offset + client_rectangle.X,
2128 Math.Max(client_rectangle.Bottom - date_cell_size.Height, 0),
2129 Math.Max(client_rectangle.Width - today_offset, 0),
2130 date_cell_size.Height);
2131 dc.DrawString ("Today: " + DateTime.Now.ToShortDateString(), bold_font, ResPool.GetSolidBrush (mc.ForeColor), today_rect, text_format);
2132 text_format.Dispose ();
2133 bold_font.Dispose ();
2137 // finally paint the borders of the calendars as required
2138 for (int i = 0; i <= mc.CalendarDimensions.Width; i++) {
2139 if (i == 0 && clip_rectangle.X == client_rectangle.X) {
2140 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, 1, client_rectangle.Height));
2141 } else if (i == mc.CalendarDimensions.Width && clip_rectangle.Right == client_rectangle.Right) {
2142 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.Right-1, client_rectangle.Y, 1, client_rectangle.Height));
2144 Rectangle rect = new Rectangle (
2145 client_rectangle.X + (month_size.Width*i) + (calendar_spacing.Width * (i-1)) + 1,
2147 calendar_spacing.Width,
2148 client_rectangle.Height);
2149 if (i < mc.CalendarDimensions.Width && i > 0 && clip_rectangle.IntersectsWith (rect)) {
2150 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
2154 for (int i = 0; i <= mc.CalendarDimensions.Height; i++) {
2155 if (i == 0 && clip_rectangle.Y == client_rectangle.Y) {
2156 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, client_rectangle.Width, 1));
2157 } else if (i == mc.CalendarDimensions.Height && clip_rectangle.Bottom == client_rectangle.Bottom) {
2158 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Bottom-1, client_rectangle.Width, 1));
2160 Rectangle rect = new Rectangle (
2162 client_rectangle.Y + (month_size.Height*i) + (calendar_spacing.Height*(i-1)) + 1,
2163 client_rectangle.Width,
2164 calendar_spacing.Height);
2165 if (i < mc.CalendarDimensions.Height && i > 0 && clip_rectangle.IntersectsWith (rect)) {
2166 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
2171 // draw the drop down border if need
2172 if (mc.owner != null) {
2173 Rectangle bounds = mc.ClientRectangle;
2174 if (clip_rectangle.Contains (mc.Location)) {
2175 // find out if top or left line to draw
2176 if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
2178 dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.X, bounds.Bottom-1);
2180 if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
2181 dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.Right-1, bounds.Y);
2184 if (clip_rectangle.Contains (new Point(bounds.Right, bounds.Bottom))) {
2185 // find out if bottom or right line to draw
2186 if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
2187 dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1);
2189 if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
2190 dc.DrawLine (SystemPens.ControlText, bounds.Right-1, bounds.Y, bounds.Right-1, bounds.Bottom-1);
2196 // darws a single part of the month calendar (with one month)
2197 private void DrawSingleMonth(Graphics dc, Rectangle clip_rectangle, Rectangle rectangle, MonthCalendar mc, int row, int col)
2199 // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
2200 Size title_size = (Size)((object)mc.title_size);
2201 Size date_cell_size = (Size)((object)mc.date_cell_size);
2202 DateTime current_month = (DateTime)((object)mc.current_month);
2204 // set up some standard string formating variables
2205 StringFormat text_format = new StringFormat();
2206 text_format.LineAlignment = StringAlignment.Center;
2207 text_format.Alignment = StringAlignment.Center;
2210 // draw the title back ground
2211 DateTime this_month = current_month.AddMonths (row*mc.CalendarDimensions.Width+col);
2212 Rectangle title_rect = new Rectangle(rectangle.X, rectangle.Y, title_size.Width, title_size.Height);
2213 if (title_rect.IntersectsWith (clip_rectangle)) {
2214 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), title_rect);
2216 string title_text = this_month.ToString ("MMMM yyyy");
2217 dc.DrawString (title_text, mc.Font, ResPool.GetSolidBrush (mc.TitleForeColor), title_rect, text_format);
2219 // draw previous and next buttons if it's time
2220 if (row == 0 && col == 0)
2222 // draw previous button
2223 DrawMonthCalendarButton (
2229 (System.Drawing.Size)((object)mc.button_size),
2232 if (row == 0 && col == mc.CalendarDimensions.Width-1)
2235 DrawMonthCalendarButton (
2241 (System.Drawing.Size)((object)mc.button_size),
2246 // set the week offset and draw week nums if needed
2247 int col_offset = (mc.ShowWeekNumbers) ? 1 : 0;
2248 Rectangle day_name_rect = new Rectangle(
2250 rectangle.Y + title_size.Height,
2251 (7 + col_offset) * date_cell_size.Width,
2252 date_cell_size.Height);
2253 if (day_name_rect.IntersectsWith (clip_rectangle)) {
2254 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), day_name_rect);
2255 // draw the day names
2256 DayOfWeek first_day_of_week = mc.GetDayOfWeek(mc.FirstDayOfWeek);
2257 for (int i=0; i < 7; i++)
2259 int position = i - (int) first_day_of_week;
2262 position = 7 + position;
2265 Rectangle day_rect = new Rectangle(
2266 day_name_rect.X + ((i + col_offset)* date_cell_size.Width),
2268 date_cell_size.Width,
2269 date_cell_size.Height);
2270 dc.DrawString (((DayOfWeek)i).ToString().Substring(0, 3), mc.Font, ResPool.GetSolidBrush (mc.TitleBackColor), day_rect, text_format);
2273 // draw the vertical divider
2274 int vert_divider_y = Math.Max(title_size.Height+ date_cell_size.Height-1, 0);
2276 ResPool.GetPen (mc.ForeColor),
2277 rectangle.X + (col_offset * date_cell_size.Width) + mc.divider_line_offset,
2278 rectangle.Y + vert_divider_y,
2279 rectangle.Right - mc.divider_line_offset,
2280 rectangle.Y + vert_divider_y);
2284 // draw the actual date items in the grid (including the week numbers)
2285 Rectangle date_rect = new Rectangle (
2287 rectangle.Y + title_size.Height + date_cell_size.Height,
2288 date_cell_size.Width,
2289 date_cell_size.Height);
2290 int month_row_count = 0;
2291 bool draw_week_num_divider = false;
2292 DateTime current_date = mc.GetFirstDateInMonthGrid ( new DateTime (this_month.Year, this_month.Month, 1));
2293 for (int i=0; i < 6; i++)
2295 // establish if this row is in our clip_area
2296 Rectangle row_rect = new Rectangle (
2298 rectangle.Y + title_size.Height + (date_cell_size.Height * (i+1)),
2299 date_cell_size.Width * 7,
2300 date_cell_size.Height);
2301 if (mc.ShowWeekNumbers) {
2302 row_rect.Width += date_cell_size.Width;
2305 bool draw_row = row_rect.IntersectsWith (clip_rectangle);
2307 dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), row_rect);
2309 // establish if this is a valid week to draw
2310 if (mc.IsValidWeekToDraw (this_month, current_date, row, col)) {
2311 month_row_count = i;
2314 // draw the week number if required
2315 if (mc.ShowWeekNumbers && month_row_count == i) {
2316 if (!draw_week_num_divider) {
2317 draw_week_num_divider = draw_row;
2319 // get the week for this row
2320 int week = mc.GetWeekOfYear (current_date);
2326 ResPool.GetSolidBrush (mc.TitleBackColor),
2330 date_rect.Offset(date_cell_size.Width, 0);
2333 // only draw the days if we have to
2334 if(month_row_count == i) {
2335 for (int j=0; j < 7; j++)
2338 DrawMonthCalendarDate (
2349 current_date = current_date.AddDays(1);
2350 date_rect.Offset(date_cell_size.Width, 0);
2353 // shift the rectangle down one row
2354 int offset = (mc.ShowWeekNumbers) ? -8 : -7;
2355 date_rect.Offset(offset*date_cell_size.Width, date_cell_size.Height);
2359 // month_row_count is zero based, so add one
2362 // draw week numbers if required
2363 if (draw_week_num_divider) {
2366 ResPool.GetPen (mc.ForeColor),
2367 rectangle.X + date_cell_size.Width - 1,
2368 rectangle.Y + title_size.Height + date_cell_size.Height + mc.divider_line_offset,
2369 rectangle.X + date_cell_size.Width - 1,
2370 rectangle.Y + title_size.Height + date_cell_size.Height + (month_row_count * date_cell_size.Height) - mc.divider_line_offset);
2372 text_format.Dispose ();
2375 // draws the pervious or next button
2376 private void DrawMonthCalendarButton (Graphics dc, Rectangle rectangle, MonthCalendar mc, Size title_size, int x_offset, Size button_size, bool is_previous)
2378 bool is_clicked = false;
2379 Rectangle button_rect;
2380 Rectangle arrow_rect = new Rectangle (rectangle.X, rectangle.Y, 4, 7);
2381 Point[] arrow_path = new Point[3];
2382 // prepare the button
2385 is_clicked = mc.is_previous_clicked;
2386 button_rect = new Rectangle (
2387 rectangle.X + 1 + x_offset,
2388 rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
2389 Math.Max(button_size.Width - 1, 0),
2390 Math.Max(button_size.Height - 1, 0));
2391 arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
2392 arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
2394 arrow_rect.Offset(1,1);
2396 arrow_path[0] = new Point (arrow_rect.Right, arrow_rect.Y);
2397 arrow_path[1] = new Point (arrow_rect.X, arrow_rect.Y + arrow_rect.Height/2);
2398 arrow_path[2] = new Point (arrow_rect.Right, arrow_rect.Bottom);
2402 is_clicked = mc.is_next_clicked;
2403 button_rect = new Rectangle (
2404 rectangle.Right - 1 - x_offset - button_size.Width,
2405 rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
2406 Math.Max(button_size.Width - 1, 0),
2407 Math.Max(button_size.Height - 1, 0));
2408 arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
2409 arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
2411 arrow_rect.Offset(1,1);
2413 arrow_path[0] = new Point (arrow_rect.X, arrow_rect.Y);
2414 arrow_path[1] = new Point (arrow_rect.Right, arrow_rect.Y + arrow_rect.Height/2);
2415 arrow_path[2] = new Point (arrow_rect.X, arrow_rect.Bottom);
2418 // fill the background
2419 dc.FillRectangle (SystemBrushes.Control, button_rect);
2422 dc.DrawRectangle (SystemPens.ControlDark, button_rect);
2425 CPDrawBorder3D (dc, button_rect, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
2428 dc.FillPolygon (SystemBrushes.ControlText, arrow_path);
2432 // draws one day in the calendar grid
2433 private void DrawMonthCalendarDate (Graphics dc, Rectangle rectangle, MonthCalendar mc, DateTime date, DateTime month, int row, int col) {
2434 Color date_color = mc.ForeColor;
2435 Rectangle interior = new Rectangle (rectangle.X, rectangle.Y, Math.Max(rectangle.Width - 1, 0), Math.Max(rectangle.Height - 1, 0));
2437 // find out if we are the lead of the first calendar or the trail of the last calendar
2438 if (date.Year != month.Year || date.Month != month.Month) {
2439 DateTime check_date = month.AddMonths (-1);
2440 // check if it's the month before
2441 if (check_date.Year == date.Year && check_date.Month == date.Month && row == 0 && col == 0) {
2442 date_color = mc.TrailingForeColor;
2444 // check if it's the month after
2445 check_date = month.AddMonths (1);
2446 if (check_date.Year == date.Year && check_date.Month == date.Month && row == mc.CalendarDimensions.Height-1 && col == mc.CalendarDimensions.Width-1) {
2447 date_color = mc.TrailingForeColor;
2453 date_color = mc.ForeColor;
2457 if (date == mc.SelectionStart && date == mc.SelectionEnd) {
2458 // see if the date is in the start of selection
2459 date_color = mc.BackColor;
2460 // draw the left hand of the back ground
2461 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
2462 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 0, 359);
2463 } else if (date == mc.SelectionStart) {
2464 // see if the date is in the start of selection
2465 date_color = mc.BackColor;
2466 // draw the left hand of the back ground
2467 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
2468 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 90, 180);
2469 // fill the other side as a straight rect
2470 if (date < mc.SelectionEnd)
2472 // use rectangle instead of rectangle to go all the way to edge of rect
2473 selection_rect.X = (int) Math.Floor((double)(rectangle.X + rectangle.Width / 2));
2474 selection_rect.Width = Math.Max(rectangle.Right - selection_rect.X, 0);
2475 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
2477 } else if (date == mc.SelectionEnd) {
2478 // see if it is the end of selection
2479 date_color = mc.BackColor;
2480 // draw the left hand of the back ground
2481 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
2482 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 270, 180);
2483 // fill the other side as a straight rect
2484 if (date > mc.SelectionStart) {
2485 selection_rect.X = rectangle.X;
2486 selection_rect.Width = rectangle.Width - (rectangle.Width / 2);
2487 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
2489 } else if (date > mc.SelectionStart && date < mc.SelectionEnd) {
2490 // now see if it's in the middle
2491 date_color = mc.BackColor;
2492 // draw the left hand of the back ground
2493 Rectangle selection_rect = Rectangle.Inflate(rectangle, 0, -3);
2494 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
2497 // set up some standard string formating variables
2498 StringFormat text_format = new StringFormat();
2499 text_format.LineAlignment = StringAlignment.Center;
2500 text_format.Alignment = StringAlignment.Center;
2503 // establish if it's a bolded font
2505 if (mc.IsBoldedDate (date)) {
2506 font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
2511 // just draw the date now
2512 dc.DrawString (date.Day.ToString(), font, ResPool.GetSolidBrush (date_color), rectangle, text_format);
2514 // today circle if needed
2515 if (mc.ShowTodayCircle && date == DateTime.Now.Date) {
2516 DrawTodayCircle (dc, interior);
2519 // draw the selection grid
2520 if (mc.is_date_clicked && mc.clicked_date == date) {
2521 using (Pen pen = new Pen (Color.Black, 1) ) {
2522 pen.DashStyle = DashStyle.Dot;
2523 dc.DrawRectangle (pen, interior);
2526 text_format.Dispose ();
2529 private void DrawTodayCircle (Graphics dc, Rectangle rectangle) {
2530 Color circle_color = Color.FromArgb (248, 0, 0);
2531 // draw the left hand of the circle
2532 Rectangle lhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 4, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 5, 0));
2533 Rectangle rhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 1, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 2, 0));
2534 Point [] curve_points = new Point [3];
2535 curve_points [0] = new Point (lhs_circle_rect.X, rhs_circle_rect.Y + rhs_circle_rect.Height/12);
2536 curve_points [1] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/9, rhs_circle_rect.Y);
2537 curve_points [2] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/2 + 1, rhs_circle_rect.Y);
2539 using (Pen pen = new Pen (circle_color, 2)) {
2540 dc.DrawArc (pen, lhs_circle_rect, 90, 180);
2541 dc.DrawArc (pen, rhs_circle_rect, 270, 180);
2542 dc.DrawCurve (pen, curve_points);
2543 dc.DrawLine (ResPool.GetPen (circle_color), curve_points [2], new Point (curve_points [2].X, lhs_circle_rect.Y));
2547 #endregion // MonthCalendar
2550 public override Size PanelDefaultSize {
2552 return new Size (200, 100);
2558 public override void DrawPictureBox (Graphics dc, Rectangle clip, PictureBox pb) {
2559 Rectangle client = pb.ClientRectangle;
2561 // FIXME - instead of drawing the whole picturebox every time
2562 // intersect the clip rectangle with the drawn picture and only draw what's needed,
2563 // Also, we only need a background fill where no image goes
2564 if (pb.Image != null) {
2565 switch (pb.SizeMode) {
2566 case PictureBoxSizeMode.StretchImage:
2567 dc.DrawImage (pb.Image, 0, 0, client.Width, client.Height);
2570 case PictureBoxSizeMode.CenterImage:
2571 dc.FillRectangle(ResPool.GetSolidBrush(pb.BackColor), clip);
2572 dc.DrawImage (pb.Image, (client.Width / 2) - (pb.Image.Width / 2), (client.Height / 2) - (pb.Image.Height / 2));
2575 dc.FillRectangle(ResPool.GetSolidBrush(pb.BackColor), clip);
2577 dc.DrawImage(pb.Image, 0, 0, pb.Image.Width, pb.Image.Height);
2584 // We only get here if no image is set. At least paint the background
2585 dc.FillRectangle(ResPool.GetSolidBrush(pb.BackColor), clip);
2588 public override Size PictureBoxDefaultSize {
2590 return new Size (100, 50);
2593 #endregion // PictureBox
2596 public override void DrawProgressBar (Graphics dc, Rectangle clip_rect, ProgressBar ctrl)
2598 Rectangle block_rect;
2599 Rectangle client_area = ctrl.client_area;
2600 int space_betweenblocks = 2;
2605 block_width = ((client_area.Height) * 2 ) / 3;
2606 barpos_pixels = ((ctrl.Value - ctrl.Minimum) * client_area.Width) / (ctrl.Maximum - ctrl.Minimum);
2607 increment = block_width + space_betweenblocks;
2610 CPDrawBorder3D (dc, ctrl.ClientRectangle, Border3DStyle.SunkenInner, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom & ~Border3DSide.Middle, ColorControl);
2613 block_rect = new Rectangle (client_area.X, client_area.Y, block_width, client_area.Height);
2614 while ((block_rect.X - client_area.X) < barpos_pixels) {
2616 if (clip_rect.IntersectsWith (block_rect) == true) {
2617 dc.FillRectangle (ResPool.GetSolidBrush (progressbarblock_color), block_rect);
2620 block_rect.X += increment;
2624 public override Size ProgressBarDefaultSize {
2626 return new Size (100, 23);
2630 #endregion // ProgressBar
2633 public override void DrawRadioButton (Graphics dc, Rectangle clip_rectangle, RadioButton radio_button) {
2634 StringFormat text_format;
2635 Rectangle client_rectangle;
2636 Rectangle text_rectangle;
2637 Rectangle radiobutton_rectangle;
2638 int radiobutton_size = 12;
2639 int radiobutton_space = 4;
2641 client_rectangle = radio_button.ClientRectangle;
2642 text_rectangle = client_rectangle;
2643 radiobutton_rectangle = new Rectangle(text_rectangle.X, text_rectangle.Y, radiobutton_size, radiobutton_size);
2645 text_format = new StringFormat();
2646 text_format.Alignment = StringAlignment.Near;
2647 text_format.LineAlignment = StringAlignment.Center;
2648 text_format.HotkeyPrefix = HotkeyPrefix.Show;
2650 /* Calculate the position of text and checkbox rectangle */
2651 if (radio_button.appearance!=Appearance.Button) {
2652 switch(radio_button.radiobutton_alignment) {
2653 case ContentAlignment.BottomCenter: {
2654 radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
2655 radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
2656 text_rectangle.X=client_rectangle.X;
2657 text_rectangle.Width=client_rectangle.Width;
2658 text_rectangle.Height=client_rectangle.Height-radiobutton_size-radiobutton_space;
2662 case ContentAlignment.BottomLeft: {
2663 radiobutton_rectangle.X=client_rectangle.Left;
2664 radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
2665 text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
2666 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
2670 case ContentAlignment.BottomRight: {
2671 radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
2672 radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
2673 text_rectangle.X=client_rectangle.X;
2674 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
2678 case ContentAlignment.MiddleCenter: {
2679 radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
2680 radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
2681 text_rectangle.X=client_rectangle.X;
2682 text_rectangle.Width=client_rectangle.Width;
2687 case ContentAlignment.MiddleLeft: {
2688 radiobutton_rectangle.X=client_rectangle.Left;
2689 radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
2690 text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
2691 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
2695 case ContentAlignment.MiddleRight: {
2696 radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
2697 radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
2698 text_rectangle.X=client_rectangle.X;
2699 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
2703 case ContentAlignment.TopCenter: {
2704 radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
2705 radiobutton_rectangle.Y=client_rectangle.Top;
2706 text_rectangle.X=client_rectangle.X;
2707 text_rectangle.Y=radiobutton_size+radiobutton_space;
2708 text_rectangle.Width=client_rectangle.Width;
2709 text_rectangle.Height=client_rectangle.Height-radiobutton_size-radiobutton_space;
2713 case ContentAlignment.TopLeft: {
2714 radiobutton_rectangle.X=client_rectangle.Left;
2715 radiobutton_rectangle.Y=client_rectangle.Top;
2716 text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
2717 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
2721 case ContentAlignment.TopRight: {
2722 radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
2723 radiobutton_rectangle.Y=client_rectangle.Top;
2724 text_rectangle.X=client_rectangle.X;
2725 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
2730 text_rectangle.X=client_rectangle.X;
2731 text_rectangle.Width=client_rectangle.Width;
2734 /* Set the horizontal alignment of our text */
2735 switch(radio_button.text_alignment) {
2736 case ContentAlignment.BottomLeft:
2737 case ContentAlignment.MiddleLeft:
2738 case ContentAlignment.TopLeft: {
2739 text_format.Alignment=StringAlignment.Near;
2743 case ContentAlignment.BottomCenter:
2744 case ContentAlignment.MiddleCenter:
2745 case ContentAlignment.TopCenter: {
2746 text_format.Alignment=StringAlignment.Center;
2750 case ContentAlignment.BottomRight:
2751 case ContentAlignment.MiddleRight:
2752 case ContentAlignment.TopRight: {
2753 text_format.Alignment=StringAlignment.Far;
2758 /* Set the vertical alignment of our text */
2759 switch(radio_button.text_alignment) {
2760 case ContentAlignment.TopLeft:
2761 case ContentAlignment.TopCenter:
2762 case ContentAlignment.TopRight: {
2763 text_format.LineAlignment=StringAlignment.Near;
2767 case ContentAlignment.BottomLeft:
2768 case ContentAlignment.BottomCenter:
2769 case ContentAlignment.BottomRight: {
2770 text_format.LineAlignment=StringAlignment.Far;
2774 case ContentAlignment.MiddleLeft:
2775 case ContentAlignment.MiddleCenter:
2776 case ContentAlignment.MiddleRight: {
2777 text_format.LineAlignment=StringAlignment.Center;
2782 ButtonState state = ButtonState.Normal;
2783 if (radio_button.FlatStyle == FlatStyle.Flat) {
2784 state |= ButtonState.Flat;
2787 if (radio_button.Checked) {
2788 state |= ButtonState.Checked;
2792 RadioButton_DrawButton(radio_button, dc, state, radiobutton_rectangle);
2794 RadioButton_DrawText(radio_button, text_rectangle, dc, text_format);
2796 RadioButton_DrawFocus(radio_button, dc, text_rectangle);
2797 text_format.Dispose ();
2800 protected virtual void RadioButton_DrawButton(RadioButton radio_button, Graphics dc, ButtonState state, Rectangle radiobutton_rectangle)
2802 SolidBrush sb = new SolidBrush(radio_button.BackColor);
2803 dc.FillRectangle(sb, radio_button.ClientRectangle);
2806 if (radio_button.appearance==Appearance.Button) {
2807 if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
2808 DrawFlatStyleButton(dc, radio_button.ClientRectangle, radio_button);
2810 CPDrawButton(dc, radio_button.ClientRectangle, state);
2813 // establish if we are rendering a flat style of some sort
2814 if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
2815 DrawFlatStyleRadioButton (dc, radiobutton_rectangle, radio_button);
2817 ControlPaint.DrawRadioButton (dc, radiobutton_rectangle, state);
2822 protected virtual void RadioButton_DrawText(RadioButton radio_button, Rectangle text_rectangle, Graphics dc, StringFormat text_format)
2824 // offset the text if it's pressed and a button
2825 if (radio_button.Appearance == Appearance.Button) {
2826 if (radio_button.Checked || (radio_button.Capture && radio_button.FlatStyle != FlatStyle.Flat)) {
2827 text_rectangle.X ++;
2828 text_rectangle.Y ++;
2831 text_rectangle.Inflate(-4,-4);
2834 /* Place the text; to be compatible with Windows place it after the radiobutton has been drawn */
2836 // Windows seems to not wrap text in certain situations, this matches as close as I could get it
2837 if ((float)(radio_button.Font.Height * 1.5f) > text_rectangle.Height) {
2838 text_format.FormatFlags |= StringFormatFlags.NoWrap;
2841 if (radio_button.Enabled) {
2842 dc.DrawString (radio_button.Text, radio_button.Font, ResPool.GetSolidBrush (radio_button.ForeColor), text_rectangle, text_format);
2843 } else if (radio_button.FlatStyle == FlatStyle.Flat) {
2844 dc.DrawString(radio_button.Text, radio_button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorControl)), text_rectangle, text_format);
2846 CPDrawStringDisabled(dc, radio_button.Text, radio_button.Font, this.ColorControlText, text_rectangle, text_format);
2850 protected virtual void RadioButton_DrawFocus(RadioButton radio_button, Graphics dc, Rectangle text_rectangle)
2852 if (radio_button.Focused) {
2853 if (radio_button.FlatStyle != FlatStyle.Flat) {
2854 DrawInnerFocusRectangle (dc, text_rectangle, radio_button.BackColor);
2856 dc.DrawRectangle (ResPool.GetPen (radio_button.ForeColor), text_rectangle);
2861 // renders a radio button with the Flat and Popup FlatStyle
2862 protected void DrawFlatStyleRadioButton (Graphics graphics, Rectangle rectangle, RadioButton radio_button)
2866 if (radio_button.Enabled) {
2867 // draw the outer flatstyle arcs
2868 if (radio_button.FlatStyle == FlatStyle.Flat) {
2869 graphics.DrawArc (ResPool.GetPen (radio_button.ForeColor), rectangle, 0, 359);
2871 // fill in the area depending on whether or not the mouse is hovering
2872 if (radio_button.is_entered && radio_button.Capture) {
2873 graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.Light (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
2875 graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
2878 // must be a popup radio button
2880 graphics.FillPie (ResPool.GetSolidBrush (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 0, 359);
2882 if (radio_button.is_entered || radio_button.Capture) {
2883 // draw the popup 3d button knob
2884 graphics.DrawArc (ResPool.GetPen (ControlPaint.Light (radio_button.BackColor)), rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 0, 359);
2886 graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (radio_button.BackColor)), rectangle, 135, 180);
2887 graphics.DrawArc (ResPool.GetPen (ControlPaint.LightLight (radio_button.BackColor)), rectangle, 315, 180);
2890 // just draw lighter flatstyle outer circle
2891 graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark (this.ColorControl)), rectangle, 0, 359);
2896 // fill control background color regardless of actual backcolor
2897 graphics.FillPie (ResPool.GetSolidBrush (this.ColorControl), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
2898 // draw the ark as control dark
2899 graphics.DrawArc (ResPool.GetPen (ControlPaint.Dark(this.ColorControl)), rectangle, 0, 359);
2903 lineWidth = Math.Max (1, Math.Min(rectangle.Width, rectangle.Height)/3);
2904 if (radio_button.Checked) {
2905 SolidBrush buttonBrush;
2907 if (!radio_button.Enabled) {
2908 buttonBrush = ResPool.GetSolidBrush (ControlPaint.Dark (this.ColorControl));
2909 } else if (radio_button.FlatStyle == FlatStyle.Popup && radio_button.is_entered && radio_button.Capture) {
2910 buttonBrush = ResPool.GetSolidBrush (this.ColorControlText);
2912 buttonBrush = ResPool.GetSolidBrush (radio_button.ForeColor);
2914 graphics.FillPie (buttonBrush, rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2, 0, 359);
2918 public override Size RadioButtonDefaultSize {
2920 return new Size (104,24);
2923 #endregion // RadioButton
2926 public override void DrawScrollBar (Graphics dc, Rectangle clip, ScrollBar bar)
2928 int scrollbutton_width = bar.scrollbutton_width;
2929 int scrollbutton_height = bar.scrollbutton_height;
2930 Rectangle first_arrow_area;
2931 Rectangle second_arrow_area;
2932 Rectangle thumb_pos;
2934 thumb_pos = bar.ThumbPos;
2937 first_arrow_area = new Rectangle(0, 0, bar.Width, scrollbutton_height);
2938 bar.FirstArrowArea = first_arrow_area;
2940 second_arrow_area = new Rectangle(0, bar.ClientRectangle.Height - scrollbutton_height, bar.Width, scrollbutton_height);
2941 bar.SecondArrowArea = second_arrow_area;
2943 thumb_pos.Width = bar.Width;
2944 bar.ThumbPos = thumb_pos;
2947 if (clip.IntersectsWith (first_arrow_area))
2948 CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state);
2949 if (clip.IntersectsWith (second_arrow_area))
2950 CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state);
2953 switch (bar.thumb_moving) {
2954 case ScrollBar.ThumbMoving.None: {
2955 ScrollBar_Vertical_Draw_ThumbMoving_None(scrollbutton_height, bar, clip, dc);
2958 case ScrollBar.ThumbMoving.Forward: {
2959 ScrollBar_Vertical_Draw_ThumbMoving_Forward(scrollbutton_height, bar, thumb_pos, clip, dc);
2963 case ScrollBar.ThumbMoving.Backwards: {
2964 ScrollBar_Vertical_Draw_ThumbMoving_Backwards(scrollbutton_height, bar, thumb_pos, clip, dc);
2972 first_arrow_area = new Rectangle(0, 0, scrollbutton_width, bar.Height);
2973 bar.FirstArrowArea = first_arrow_area;
2975 second_arrow_area = new Rectangle (bar.ClientRectangle.Width - scrollbutton_width, 0, scrollbutton_width, bar.Height);
2976 bar.SecondArrowArea = second_arrow_area;
2978 thumb_pos.Height = bar.Height;
2979 bar.ThumbPos = thumb_pos;
2982 if (clip.IntersectsWith (first_arrow_area))
2983 CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Left, bar.firstbutton_state);
2984 if (clip.IntersectsWith (second_arrow_area))
2985 CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Right, bar.secondbutton_state);
2988 switch (bar.thumb_moving) {
2989 case ScrollBar.ThumbMoving.None: {
2990 ScrollBar_Horizontal_Draw_ThumbMoving_None(scrollbutton_width, bar, clip, dc);
2994 case ScrollBar.ThumbMoving.Forward: {
2995 ScrollBar_Horizontal_Draw_ThumbMoving_Forward(scrollbutton_width, thumb_pos, bar, clip, dc);
2999 case ScrollBar.ThumbMoving.Backwards: {
3000 ScrollBar_Horizontal_Draw_ThumbMoving_Backwards(scrollbutton_width, thumb_pos, bar, clip, dc);
3007 ScrollBar_DrawThumb(bar, thumb_pos, clip, dc);
3010 protected virtual void ScrollBar_DrawThumb(ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc)
3012 if (bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith(thumb_pos))
3013 DrawScrollButtonPrimitive(dc, thumb_pos, ButtonState.Normal);
3016 protected virtual void ScrollBar_Vertical_Draw_ThumbMoving_None( int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc )
3018 Rectangle r = new Rectangle( 0,
3019 scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - ( scrollbutton_height * 2 ) );
3020 Rectangle intersect = Rectangle.Intersect( clip, r );
3022 if ( intersect != Rectangle.Empty )
3024 Brush h = ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White);
3025 dc.FillRectangle( h, intersect );
3029 protected virtual void ScrollBar_Vertical_Draw_ThumbMoving_Forward( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
3031 Rectangle r = new Rectangle( 0, scrollbutton_height,
3032 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
3033 Rectangle intersect = Rectangle.Intersect( clip, r );
3035 if ( intersect != Rectangle.Empty )
3036 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White ), intersect );
3039 r.Y = thumb_pos.Y + thumb_pos.Height;
3040 r.Width = bar.ClientRectangle.Width;
3041 r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
3043 intersect = Rectangle.Intersect( clip, r );
3044 if ( intersect != Rectangle.Empty )
3045 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
3048 protected virtual void ScrollBar_Vertical_Draw_ThumbMoving_Backwards( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
3050 Rectangle r = new Rectangle( 0, scrollbutton_height,
3051 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
3052 Rectangle intersect = Rectangle.Intersect( clip, r );
3054 if ( intersect != Rectangle.Empty )
3055 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
3058 r.Y = thumb_pos.Y + thumb_pos.Height;
3059 r.Width = bar.ClientRectangle.Width;
3060 r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
3062 intersect = Rectangle.Intersect( clip, r );
3063 if ( intersect != Rectangle.Empty )
3064 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
3067 protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc )
3069 Rectangle r = new Rectangle( scrollbutton_width,
3070 0, bar.ClientRectangle.Width - ( scrollbutton_width * 2 ), bar.ClientRectangle.Height );
3071 Rectangle intersect = Rectangle.Intersect( clip, r );
3073 if ( intersect != Rectangle.Empty )
3074 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
3077 protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
3079 Rectangle r = new Rectangle( scrollbutton_width, 0,
3080 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
3081 Rectangle intersect = Rectangle.Intersect( clip, r );
3083 if ( intersect != Rectangle.Empty )
3084 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
3086 r.X = thumb_pos.X + thumb_pos.Width;
3088 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
3089 r.Height = bar.ClientRectangle.Height;
3091 intersect = Rectangle.Intersect( clip, r );
3092 if ( intersect != Rectangle.Empty )
3093 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
3096 protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
3098 Rectangle r = new Rectangle( scrollbutton_width, 0,
3099 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
3100 Rectangle intersect = Rectangle.Intersect( clip, r );
3102 if ( intersect != Rectangle.Empty )
3103 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
3105 r.X = thumb_pos.X + thumb_pos.Width;
3107 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
3108 r.Height = bar.ClientRectangle.Height;
3110 intersect = Rectangle.Intersect( clip, r );
3111 if ( intersect != Rectangle.Empty )
3112 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
3115 public override int ScrollBarButtonSize {
3118 #endregion // ScrollBar
3121 public override void DrawStatusBar (Graphics dc, Rectangle clip, StatusBar sb) {
3122 Rectangle area = sb.ClientRectangle;
3123 int horz_border = 2;
3124 int vert_border = 2;
3126 dc.FillRectangle (GetControlBackBrush (sb.BackColor), clip);
3128 if (sb.Panels.Count == 0 && sb.Text != String.Empty) {
3129 string text = sb.Text;
3130 StringFormat string_format = new StringFormat ();
3131 string_format.Trimming = StringTrimming.Character;
3132 string_format.FormatFlags = StringFormatFlags.NoWrap;
3134 if (text [0] == '\t') {
3135 string_format.Alignment = StringAlignment.Center;
3136 text = text.Substring (1);
3137 if (text [0] == '\t') {
3138 string_format.Alignment = StringAlignment.Far;
3139 text = text.Substring (1);
3143 dc.DrawString (text, sb.Font, ResPool.GetSolidBrush (sb.ForeColor),
3144 new Rectangle(area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4), string_format);
3145 string_format.Dispose ();
3146 } else if (sb.ShowPanels) {
3147 SolidBrush br_forecolor = GetControlForeBrush (sb.ForeColor);
3148 int prev_x = area.X + horz_border;
3149 int y = area.Y + vert_border;
3150 for (int i = 0; i < sb.Panels.Count; i++) {
3151 Rectangle pr = new Rectangle (prev_x, y,
3152 sb.Panels [i].Width, area.Height);
3153 prev_x += pr.Width + StatusBarHorzGapWidth;
3154 if (pr.IntersectsWith (clip))
3155 DrawStatusBarPanel (dc, pr, i, br_forecolor, sb.Panels [i]);
3160 CPDrawSizeGrip (dc, ColorControl, area);
3165 protected virtual void DrawStatusBarPanel (Graphics dc, Rectangle area, int index,
3166 SolidBrush br_forecolor, StatusBarPanel panel) {
3167 int border_size = 3; // this is actually const, even if the border style is none
3169 area.Height -= border_size;
3170 if (panel.BorderStyle != StatusBarPanelBorderStyle.None) {
3171 Border3DStyle border_style = Border3DStyle.SunkenInner;
3172 if (panel.BorderStyle == StatusBarPanelBorderStyle.Raised)
3173 border_style = Border3DStyle.RaisedOuter;
3174 CPDrawBorder3D(dc, area, border_style, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, panel.Parent.BackColor);
3177 if (panel.Style == StatusBarPanelStyle.OwnerDraw) {
3178 StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs (
3179 dc, panel.Parent.Font, area, index, DrawItemState.Default,
3180 panel, panel.Parent.ForeColor, panel.Parent.BackColor);
3181 panel.Parent.OnDrawItemInternal (e);
3185 int left = area.Left;
3186 if (panel.Icon != null) {
3188 dc.DrawIcon (panel.Icon, left, area.Top);
3189 left += panel.Icon.Width;
3192 if (panel.Text == String.Empty)
3195 string text = panel.Text;
3196 StringFormat string_format = new StringFormat ();
3197 string_format.Trimming = StringTrimming.Character;
3198 string_format.FormatFlags = StringFormatFlags.NoWrap;
3200 if (text [0] == '\t') {
3201 string_format.Alignment = StringAlignment.Center;
3202 text = text.Substring (1);
3203 if (text [0] == '\t') {
3204 string_format.Alignment = StringAlignment.Far;
3205 text = text.Substring (1);
3209 int x = left + border_size;
3210 int y = border_size + 2;
3211 Rectangle r = new Rectangle (x, y,
3212 area.Right - x - border_size,
3213 area.Bottom - y - border_size);
3215 dc.DrawString (text, panel.Parent.Font, br_forecolor, r, string_format);
3216 string_format.Dispose ();
3219 public override int StatusBarSizeGripWidth {
3223 public override int StatusBarHorzGapWidth {
3227 public override Size StatusBarDefaultSize {
3229 return new Size (100, 22);
3232 #endregion // StatusBar
3234 public override void DrawTabControl (Graphics dc, Rectangle area, TabControl tab)
3236 // Do we need to fill the back color? It can't be changed...
3237 dc.FillRectangle (GetControlBackBrush (tab.BackColor), area);
3238 Rectangle panel_rect = GetTabPanelRectExt (tab);
3240 if (tab.Appearance == TabAppearance.Normal) {
3241 CPDrawBorder3D (dc, panel_rect, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, ColorControl);
3242 CPDrawBorder3D (dc, panel_rect, Border3DStyle.Raised, Border3DSide.Right | Border3DSide.Bottom, ColorControl);
3245 if (tab.Alignment == TabAlignment.Top) {
3246 for (int r = tab.TabPages.Count; r > 0; r--) {
3247 for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
3248 if (i == tab.SelectedIndex)
3250 if (r != tab.TabPages [i].Row)
3252 Rectangle rect = tab.GetTabRect (i);
3253 if (!rect.IntersectsWith (area))
3255 DrawTab (dc, tab.TabPages [i], tab, rect, false);
3259 for (int r = 0; r < tab.TabPages.Count; r++) {
3260 for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
3261 if (i == tab.SelectedIndex)
3263 if (r != tab.TabPages [i].Row)
3265 Rectangle rect = tab.GetTabRect (i);
3266 if (!rect.IntersectsWith (area))
3268 DrawTab (dc, tab.TabPages [i], tab, rect, false);
3273 if (tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos) {
3274 Rectangle rect = tab.GetTabRect (tab.SelectedIndex);
3275 if (rect.IntersectsWith (area))
3276 DrawTab (dc, tab.TabPages [tab.SelectedIndex], tab, rect, true);
3279 if (tab.ShowSlider) {
3280 Rectangle right = GetTabControlRightScrollRect (tab);
3281 Rectangle left = GetTabControlLeftScrollRect (tab);
3282 CPDrawScrollButton (dc, right, ScrollButton.Right, tab.RightSliderState);
3283 CPDrawScrollButton (dc, left, ScrollButton.Left, tab.LeftSliderState);
3287 public override Rectangle GetTabControlLeftScrollRect (TabControl tab)
3289 switch (tab.Alignment) {
3290 case TabAlignment.Top:
3291 return new Rectangle (tab.ClientRectangle.Right - 34, tab.ClientRectangle.Top + 1, 17, 17);
3293 Rectangle panel_rect = GetTabPanelRectExt (tab);
3294 return new Rectangle (tab.ClientRectangle.Right - 34, panel_rect.Bottom + 2, 17, 17);
3298 public override Rectangle GetTabControlRightScrollRect (TabControl tab)
3300 switch (tab.Alignment) {
3301 case TabAlignment.Top:
3302 return new Rectangle (tab.ClientRectangle.Right - 17, tab.ClientRectangle.Top + 1, 17, 17);
3304 Rectangle panel_rect = GetTabPanelRectExt (tab);
3305 return new Rectangle (tab.ClientRectangle.Right - 17, panel_rect.Bottom + 2, 17, 17);
3309 public override Size TabControlDefaultItemSize {
3310 get { return new Size (42, 21); }
3313 public override Point TabControlDefaultPadding {
3314 get { return new Point (6, 3); }
3317 public override int TabControlMinimumTabWidth {
3321 public override Rectangle GetTabControlDisplayRectangle (TabControl tab)
3323 Rectangle ext = GetTabPanelRectExt (tab);
3324 // Account for border size
3325 return new Rectangle (ext.Left + 2, ext.Top + 1, ext.Width - 6, ext.Height - 4);
3328 public override Size TabControlGetSpacing (TabControl tab) {
3329 switch (tab.Appearance) {
3330 case TabAppearance.Normal:
3331 return new Size (1, -2);
3332 case TabAppearance.Buttons:
3333 return new Size (3, 3);
3334 case TabAppearance.FlatButtons:
3335 return new Size (9, 3);
3337 throw new Exception ("Invalid Appearance value: " + tab.Appearance);
3341 protected virtual Rectangle GetTabPanelRectExt (TabControl tab)
3343 // Offset the tab from the top corner
3344 Rectangle res = new Rectangle (tab.ClientRectangle.X + 2,
3345 tab.ClientRectangle.Y,
3346 tab.ClientRectangle.Width - 2,
3347 tab.ClientRectangle.Height - 1);
3349 if (tab.TabCount == 0)
3352 int spacing = TabControlGetSpacing (tab).Height;
3353 int offset = (tab.ItemSize.Height + spacing) * tab.RowCount + 3;
3355 switch (tab.Alignment) {
3356 case TabAlignment.Left:
3358 res.Width -= offset;
3360 case TabAlignment.Right:
3361 res.Width -= offset;
3363 case TabAlignment.Top:
3365 res.Height -= offset;
3367 case TabAlignment.Bottom:
3368 res.Height -= offset;
3375 protected virtual int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
3377 int FlatButtonSpacing = 8;
3379 int res = bounds.Width;
3383 // we can't fill the background right away because the bounds might be adjusted if the tab is selected
3385 StringFormat string_format = new StringFormat ();
3386 if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) {
3387 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
3390 if (tab.Appearance == TabAppearance.FlatButtons) {
3391 int width = bounds.Width;
3392 bounds.Width += (FlatButtonSpacing - 2);
3394 CPDrawBorder3D (dc, bounds, Border3DStyle.Etched, Border3DSide.Right);
3395 bounds.Width = width;
3399 CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
3400 } else if (tab.Appearance != TabAppearance.FlatButtons) {
3401 CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
3404 interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4);
3407 string_format.Alignment = StringAlignment.Center;
3408 string_format.LineAlignment = StringAlignment.Center;
3409 string_format.FormatFlags = StringFormatFlags.NoWrap;
3411 Pen light = ResPool.GetPen (ControlPaint.LightLight (tab.BackColor));
3413 switch (tab.Alignment) {
3415 case TabAlignment.Top:
3418 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
3420 dc.DrawLine (light, bounds.Left, bounds.Bottom, bounds.Left, bounds.Top + 3);
3421 dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
3422 dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right - 3, bounds.Top);
3424 dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom);
3425 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 1, bounds.Top + 2, bounds.Right, bounds.Top + 3);
3426 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom);
3428 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
3430 string_format.Alignment = StringAlignment.Center;
3431 string_format.LineAlignment = StringAlignment.Center;
3432 string_format.FormatFlags = StringFormatFlags.NoWrap;
3436 case TabAlignment.Bottom:
3438 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
3440 dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 3);
3441 dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left + 2, bounds.Bottom - 1);
3443 dc.DrawLine (SystemPens.ControlDark, bounds.Left + 3, bounds.Bottom - 1, bounds.Right - 3, bounds.Bottom - 1);
3444 dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Bottom - 3, bounds.Right - 1, bounds.Top);
3446 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
3447 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 3, bounds.Bottom, bounds.Right, bounds.Bottom - 3);
3448 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom - 3, bounds.Right, bounds.Top);
3450 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
3452 string_format.Alignment = StringAlignment.Center;
3453 string_format.LineAlignment = StringAlignment.Center;
3454 string_format.FormatFlags = StringFormatFlags.NoWrap;
3458 case TabAlignment.Left:
3460 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
3462 dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left, bounds.Top + 3);
3463 dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
3464 dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right, bounds.Top);
3466 dc.DrawLine (SystemPens.ControlDark, bounds.Right, bounds.Bottom - 1, bounds.Left + 2, bounds.Bottom - 1);
3468 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom, bounds.Left + 2, bounds.Bottom);
3469 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 2, bounds.Bottom, bounds.Left, bounds.Bottom - 3);
3471 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
3473 string_format.Alignment = StringAlignment.Center;
3474 string_format.LineAlignment = StringAlignment.Center;
3475 string_format.FormatFlags = StringFormatFlags.NoWrap;
3476 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
3481 // TabAlignment.Right
3483 dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
3485 dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Right - 3, bounds.Top);
3486 dc.DrawLine (light, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3);
3488 dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom - 1);
3489 dc.DrawLine (SystemPens.ControlDark, bounds.Left, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1);
3491 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom - 3);
3492 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
3494 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
3496 string_format.Alignment = StringAlignment.Center;
3497 string_format.LineAlignment = StringAlignment.Center;
3498 string_format.FormatFlags = StringFormatFlags.NoWrap;
3499 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
3505 if (tab.DrawMode == TabDrawMode.Normal && page.Text != null) {
3506 if (tab.Alignment == TabAlignment.Left) {
3507 int wo = interior.Width / 2;
3508 int ho = interior.Height / 2;
3509 dc.TranslateTransform (interior.X + wo, interior.Y + ho);
3510 dc.RotateTransform (180);
3511 dc.DrawString (page.Text, page.Font, ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
3512 dc.ResetTransform ();
3514 dc.DrawString (page.Text, page.Font,
3515 ResPool.GetSolidBrush (SystemColors.ControlText),
3516 interior, string_format);
3518 } else if (page.Text != null) {
3519 DrawItemState state = DrawItemState.None;
3520 if (page == tab.SelectedTab)
3521 state |= DrawItemState.Selected;
3522 DrawItemEventArgs e = new DrawItemEventArgs (dc,
3523 tab.Font, bounds, tab.IndexForTabPage (page),
3524 state, page.ForeColor, page.BackColor);
3525 tab.OnDrawItemInternal (e);
3529 if (page.parent.Focused && is_selected) {
3530 CPDrawFocusRectangle (dc, interior, tab.ForeColor, tab.BackColor);
3537 public override void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control)
3539 StringFormat format = new StringFormat ();
3540 format.Trimming = StringTrimming.EllipsisWord;
3541 format.LineAlignment = StringAlignment.Center;
3542 if (control.TextAlign == ToolBarTextAlign.Underneath)
3543 format.Alignment = StringAlignment.Center;
3545 format.Alignment = StringAlignment.Near;
3547 dc.FillRectangle (ResPool.GetSolidBrush( DefaultControlBackColor ), clip_rectangle);
3549 foreach (ToolBarButton button in control.Buttons)
3550 if (button.Visible && clip_rectangle.IntersectsWith (button.Rectangle))
3551 DrawToolBarButton (dc, control, button, format);
3556 void DrawToolBarButton (Graphics dc, ToolBar control, ToolBarButton button, StringFormat format)
3558 bool is_flat = control.Appearance == ToolBarAppearance.Flat;
3560 DrawToolBarButtonBorder (dc, button, is_flat);
3562 switch (button.Style) {
3563 case ToolBarButtonStyle.DropDownButton:
3564 if (control.DropDownArrows)
3565 DrawToolBarDropDownArrow (dc, button, is_flat);
3566 DrawToolBarButtonContents (dc, control, button, format);
3569 case ToolBarButtonStyle.Separator:
3571 DrawToolBarSeparator (dc, button);
3574 case ToolBarButtonStyle.ToggleButton:
3575 DrawToolBarToggleButtonBackground (dc, button);
3576 DrawToolBarButtonContents (dc, control, button, format);
3580 DrawToolBarButtonContents (dc, control, button, format);
3585 const Border3DSide all_sides = Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom;
3587 void DrawToolBarButtonBorder (Graphics dc, ToolBarButton button, bool is_flat)
3589 if (button.Style == ToolBarButtonStyle.Separator)
3592 Border3DStyle style;
3595 if (button.Pushed || button.Pressed)
3596 style = Border3DStyle.SunkenOuter;
3597 else if (button.Hilight)
3598 style = Border3DStyle.RaisedOuter;
3603 if (button.Pushed || button.Pressed)
3604 style = Border3DStyle.Sunken;
3606 style = Border3DStyle.Raised;
3609 CPDrawBorder3D (dc, button.Rectangle, style, all_sides);
3612 void DrawToolBarSeparator (Graphics dc, ToolBarButton button)
3614 Rectangle area = button.Rectangle;
3615 int offset = (int) ResPool.GetPen (ColorControl).Width + 1;
3616 dc.DrawLine (ResPool.GetPen (ColorControlDark), area.X + 1, area.Y, area.X + 1, area.Bottom);
3617 dc.DrawLine (ResPool.GetPen (ColorControlLight), area.X + offset, area.Y, area.X + offset, area.Bottom);
3620 void DrawToolBarToggleButtonBackground (Graphics dc, ToolBarButton button)
3622 Rectangle area = button.Rectangle;
3623 area.X += ToolBarImageGripWidth;
3624 area.Y += ToolBarImageGripWidth;
3625 area.Width -= 2 * ToolBarImageGripWidth;
3626 area.Height -= 2 * ToolBarImageGripWidth;
3629 dc.FillRectangle (SystemBrushes.ControlLightLight, area);
3630 else if (button.PartialPush)
3631 dc.FillRectangle (SystemBrushes.ControlLight, area);
3633 dc.FillRectangle (SystemBrushes.Control, area);
3636 void DrawToolBarDropDownArrow (Graphics dc, ToolBarButton button, bool is_flat)
3638 Rectangle rect = button.Rectangle;
3639 rect.X = button.Rectangle.Right - ToolBarDropDownWidth;
3640 rect.Width = ToolBarDropDownWidth;
3642 if (button.dd_pressed) {
3643 CPDrawBorder3D (dc, rect, Border3DStyle.SunkenOuter, all_sides);
3644 CPDrawBorder3D (dc, rect, Border3DStyle.SunkenInner, Border3DSide.Bottom | Border3DSide.Right);
3645 } else if (button.Pushed || button.Pressed)
3646 CPDrawBorder3D (dc, rect, Border3DStyle.Sunken, all_sides);
3649 CPDrawBorder3D (dc, rect, Border3DStyle.RaisedOuter, all_sides);
3651 CPDrawBorder3D (dc, rect, Border3DStyle.Raised, all_sides);
3653 PointF [] vertices = new PointF [3];
3654 PointF ddCenter = new PointF (rect.X + (rect.Width/2.0f), rect.Y + (rect.Height/2.0f));
3655 vertices [0].X = ddCenter.X - ToolBarDropDownArrowWidth / 2.0f + 0.5f;
3656 vertices [0].Y = ddCenter.Y;
3657 vertices [1].X = ddCenter.X + ToolBarDropDownArrowWidth / 2.0f + 0.5f;
3658 vertices [1].Y = ddCenter.Y;
3659 vertices [2].X = ddCenter.X + 0.5f; // 0.5 is added for adjustment
3660 vertices [2].Y = ddCenter.Y + ToolBarDropDownArrowHeight;
3661 dc.FillPolygon (SystemBrushes.ControlText, vertices);
3664 void DrawToolBarButtonContents (Graphics dc, ToolBar control, ToolBarButton button, StringFormat format)
3666 if (button.Image != null) {
3667 int x = button.ImageRectangle.X + ToolBarImageGripWidth;
3668 int y = button.ImageRectangle.Y + ToolBarImageGripWidth;
3670 dc.DrawImage (button.Image, x, y);
3672 CPDrawImageDisabled (dc, button.Image, x, y, ColorControl);
3676 dc.DrawString (button.Text, control.Font, ResPool.GetSolidBrush (ColorControlText), button.TextRectangle, format);
3678 CPDrawStringDisabled (dc, button.Text, control.Font, ColorControlLight, button.TextRectangle, format);
3681 // Grip width for the ToolBar
3682 public override int ToolBarGripWidth {
3686 // Grip width for the Image on the ToolBarButton
3687 public override int ToolBarImageGripWidth {
3691 // width of the separator
3692 public override int ToolBarSeparatorWidth {
3696 // width of the dropdown arrow rect
3697 public override int ToolBarDropDownWidth {
3701 // width for the dropdown arrow on the ToolBarButton
3702 public override int ToolBarDropDownArrowWidth {
3706 // height for the dropdown arrow on the ToolBarButton
3707 public override int ToolBarDropDownArrowHeight {
3711 public override Size ToolBarDefaultSize {
3713 return new Size (100, 42);
3716 #endregion // ToolBar
3719 public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control) {
3720 dc.FillRectangle(ResPool.GetSolidBrush(this.ColorInfo), control.client_rect);
3721 dc.DrawRectangle(ResPool.GetPen(this.ColorWindowFrame), 0, 0, control.Width-1, control.Height-1);
3722 dc.DrawString(control.text, control.Font, ResPool.GetSolidBrush(this.ColorInfoText), control.client_rect, control.string_format);
3725 public override Size ToolTipSize(ToolTip.ToolTipWindow tt, string text) {
3728 sizef = tt.DeviceContext.MeasureString(text, tt.Font);
3729 return new Size((int)sizef.Width+2, (int)sizef.Height+3); // Need space for the border
3731 #endregion // ToolTip
3734 private void DrawTrackBar_Vertical (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
3735 ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
3736 float ticks, int value_pos, bool mouse_value) {
3738 Point toptick_startpoint = new Point ();
3739 Point bottomtick_startpoint = new Point ();
3740 Point channel_startpoint = new Point ();
3742 float pixels_betweenticks;
3743 const int space_from_right = 8;
3744 const int space_from_left = 8;
3745 const int space_from_bottom = 11;
3746 Rectangle area = tb.ClientRectangle;
3748 switch (tb.TickStyle) {
3749 case TickStyle.BottomRight:
3750 case TickStyle.None:
3751 channel_startpoint.Y = 8;
3752 channel_startpoint.X = 9;
3753 bottomtick_startpoint.Y = 13;
3754 bottomtick_startpoint.X = 24;
3756 case TickStyle.TopLeft:
3757 channel_startpoint.Y = 8;
3758 channel_startpoint.X = 19;
3759 toptick_startpoint.Y = 13;
3760 toptick_startpoint.X = 8;
3762 case TickStyle.Both:
3763 channel_startpoint.Y = 8;
3764 channel_startpoint.X = 18;
3765 bottomtick_startpoint.Y = 13;
3766 bottomtick_startpoint.X = 32;
3767 toptick_startpoint.Y = 13;
3768 toptick_startpoint.X = 8;
3774 thumb_area.X = area.X + channel_startpoint.X;
3775 thumb_area.Y = area.Y + channel_startpoint.Y;
3776 thumb_area.Height = area.Height - space_from_right - space_from_left;
3777 thumb_area.Width = 4;
3780 dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDark), channel_startpoint.X, channel_startpoint.Y,
3781 1, thumb_area.Height);
3783 dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDarkDark), channel_startpoint.X + 1, channel_startpoint.Y,
3784 1, thumb_area.Height);
3786 dc.FillRectangle (ResPool.GetSolidBrush (ColorControlLight), channel_startpoint.X + 3, channel_startpoint.Y,
3787 1, thumb_area.Height);
3789 pixel_len = thumb_area.Height - 11;
3790 pixels_betweenticks = pixel_len / (tb.Maximum - tb.Minimum);
3792 /* Convert thumb position from mouse position to value*/
3794 if (value_pos < thumb_area.Bottom)
3795 value_pos = (int) ((thumb_area.Bottom - value_pos) / pixels_betweenticks);
3799 if (value_pos + tb.Minimum > tb.Maximum)
3800 value_pos = tb.Maximum - tb.Minimum;
3802 tb.Value = value_pos + tb.Minimum;
3805 // thumb_pos.Y = channel_startpoint.Y ; // + (int) (pixels_betweenticks * (float) value_pos);
3806 thumb_pos.Y = thumb_area.Bottom - space_from_bottom - (int) (pixels_betweenticks * (float) value_pos);
3808 /* Draw thumb fixed 10x22 size */
3809 thumb_pos.Width = 10;
3810 thumb_pos.Height = 22;
3812 switch (tb.TickStyle) {
3813 case TickStyle.BottomRight:
3814 case TickStyle.None: {
3815 thumb_pos.X = channel_startpoint.X - 8;
3817 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X , thumb_pos.Y + 10);
3818 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 16, thumb_pos.Y);
3819 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X + 16, thumb_pos.Y, thumb_pos.X + 16 + 4, thumb_pos.Y + 4);
3821 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X +1, thumb_pos.Y + 9, thumb_pos.X +15, thumb_pos.Y +9);
3822 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 16, thumb_pos.Y + 9, thumb_pos.X +16 + 4, thumb_pos.Y +9 - 4);
3824 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X +16, thumb_pos.Y +10);
3825 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 16, thumb_pos.Y + 10, thumb_pos.X +16 + 5, thumb_pos.Y +10 - 5);
3827 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 16, 8);
3828 dc.FillRectangle (br_thumb, thumb_pos.X + 17, thumb_pos.Y + 2, 1, 6);
3829 dc.FillRectangle (br_thumb, thumb_pos.X + 18, thumb_pos.Y + 3, 1, 4);
3830 dc.FillRectangle (br_thumb, thumb_pos.X + 19, thumb_pos.Y + 4, 1, 2);
3834 case TickStyle.TopLeft: {
3835 thumb_pos.X = channel_startpoint.X - 10;
3837 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X + 4 + 16, thumb_pos.Y);
3838 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 4);
3840 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X + 4 + 16 , thumb_pos.Y+ 9);
3841 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X, thumb_pos.Y + 5);
3842 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 19, thumb_pos.Y + 9, thumb_pos.X +19 , thumb_pos.Y+ 1);
3844 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 4, thumb_pos.Y+ 10, thumb_pos.X + 4 + 16, thumb_pos.Y+ 10);
3845 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 4, thumb_pos.Y + 10, thumb_pos.X -1, thumb_pos.Y+ 5);
3846 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X+ 20, thumb_pos.Y + 10);
3848 dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 15, 8);
3849 dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 1, 6);
3850 dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 1, 4);
3851 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 1, 2);
3856 case TickStyle.Both: {
3857 thumb_pos.X = area.X + 10;
3858 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 9);
3859 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 19, thumb_pos.Y);
3861 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 1, thumb_pos.Y + 9, thumb_pos.X+ 19, thumb_pos.Y + 9);
3862 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 10, thumb_pos.Y+ 1, thumb_pos.X + 19, thumb_pos.Y + 8);
3864 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X+ 20, thumb_pos.Y +10);
3865 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X + 20, thumb_pos.Y+ 9);
3867 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 18, 8);
3876 pixel_len = thumb_area.Height - 11;
3877 pixels_betweenticks = pixel_len / ticks;
3879 thumb_area.X = thumb_pos.X;
3880 thumb_area.Y = channel_startpoint.Y;
3881 thumb_area.Width = thumb_pos.Height;
3884 Region outside = new Region (area);
3885 outside.Exclude (thumb_area);
3887 if (outside.IsVisible (clip_rectangle)) {
3888 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
3889 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
3891 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
3892 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
3893 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
3894 area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc);
3896 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
3897 area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc);
3901 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
3902 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
3904 pixel_len = thumb_area.Height - 11;
3905 pixels_betweenticks = pixel_len / ticks;
3907 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
3908 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
3909 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
3910 area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
3912 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
3913 area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
3925 Does not matter the size of the control, Win32 always draws:
3926 - Ticks starting from pixel 13, 8
3927 - Channel starting at pos 8, 19 and ends at Width - 8
3928 - Autosize makes always the control 40 pixels height
3929 - Ticks are draw at (channel.Witdh - 10) / (Maximum - Minimum)
3932 private void DrawTrackBar_Horizontal (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
3933 ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
3934 float ticks, int value_pos, bool mouse_value) {
3935 Point toptick_startpoint = new Point ();
3936 Point bottomtick_startpoint = new Point ();
3937 Point channel_startpoint = new Point ();
3939 float pixels_betweenticks;
3940 const int space_from_right = 8;
3941 const int space_from_left = 8;
3942 Rectangle area = tb.ClientRectangle;
3944 switch (tb.TickStyle) {
3945 case TickStyle.BottomRight:
3946 case TickStyle.None:
3947 channel_startpoint.X = 8;
3948 channel_startpoint.Y = 9;
3949 bottomtick_startpoint.X = 13;
3950 bottomtick_startpoint.Y = 24;
3952 case TickStyle.TopLeft:
3953 channel_startpoint.X = 8;
3954 channel_startpoint.Y = 19;
3955 toptick_startpoint.X = 13;
3956 toptick_startpoint.Y = 8;
3958 case TickStyle.Both:
3959 channel_startpoint.X = 8;
3960 channel_startpoint.Y = 18;
3961 bottomtick_startpoint.X = 13;
3962 bottomtick_startpoint.Y = 32;
3963 toptick_startpoint.X = 13;
3964 toptick_startpoint.Y = 8;
3970 thumb_area.X = area.X + channel_startpoint.X;
3971 thumb_area.Y = area.Y + channel_startpoint.Y;
3972 thumb_area.Width = area.Width - space_from_right - space_from_left;
3973 thumb_area.Height = 4;
3976 dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDark), channel_startpoint.X, channel_startpoint.Y,
3977 thumb_area.Width, 1);
3979 dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDarkDark), channel_startpoint.X, channel_startpoint.Y + 1,
3980 thumb_area.Width, 1);
3982 dc.FillRectangle (ResPool.GetSolidBrush (ColorControlLight), channel_startpoint.X, channel_startpoint.Y +3,
3983 thumb_area.Width, 1);
3985 pixel_len = thumb_area.Width - 11;
3986 pixels_betweenticks = pixel_len / (tb.Maximum - tb.Minimum);
3988 /* Convert thumb position from mouse position to value*/
3990 if (value_pos >= channel_startpoint.X)
3991 value_pos = (int)(((float) (value_pos - channel_startpoint.X)) / pixels_betweenticks);
3995 if (value_pos + tb.Minimum > tb.Maximum)
3996 value_pos = tb.Maximum - tb.Minimum;
3998 tb.Value = value_pos + tb.Minimum;
4001 thumb_pos.X = channel_startpoint.X + (int) (pixels_betweenticks * (float) value_pos);
4003 /* Draw thumb fixed 10x22 size */
4004 thumb_pos.Width = 10;
4005 thumb_pos.Height = 22;
4007 switch (tb.TickStyle) {
4008 case TickStyle.BottomRight:
4009 case TickStyle.None: {
4010 thumb_pos.Y = channel_startpoint.Y - 8;
4012 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y);
4013 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 16);
4014 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y + 16, thumb_pos.X + 4, thumb_pos.Y + 16 + 4);
4016 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X +9, thumb_pos.Y +15);
4017 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 16, thumb_pos.X +9 - 4, thumb_pos.Y +16 + 4);
4019 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y +16);
4020 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y + 16, thumb_pos.X +10 - 5, thumb_pos.Y +16 + 5);
4022 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 16);
4023 dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 17, 6, 1);
4024 dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 18, 4, 1);
4025 dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 19, 2, 1);
4028 case TickStyle.TopLeft: {
4029 thumb_pos.Y = channel_startpoint.Y - 10;
4031 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X, thumb_pos.Y + 4 + 16);
4032 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X + 4, thumb_pos.Y);
4034 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 9, thumb_pos.Y + 4 + 16);
4035 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y);
4036 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 19, thumb_pos.X + 1 , thumb_pos.Y +19);
4038 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 10, thumb_pos.Y + 4 + 16);
4039 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y -1);
4040 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 10, thumb_pos.Y + 20);
4042 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 8, 15);
4043 dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 6, 1);
4044 dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 4, 1);
4045 dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 2, 1);
4049 case TickStyle.Both: {
4050 thumb_pos.Y = area.Y + 10;
4051 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X + 9, thumb_pos.Y);
4052 dc.DrawLine (ResPool.GetPen (ColorControlLight), thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 19);
4054 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 19);
4055 dc.DrawLine (ResPool.GetPen (ColorControlDark), thumb_pos.X + 1, thumb_pos.Y + 10, thumb_pos.X + 8, thumb_pos.Y + 19);
4057 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y + 20);
4058 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 9, thumb_pos.Y + 20);
4060 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 18);
4069 pixel_len = thumb_area.Width - 11;
4070 pixels_betweenticks = pixel_len / ticks;
4073 thumb_area.Y = thumb_pos.Y;
4074 thumb_area.X = channel_startpoint.X;
4075 thumb_area.Height = thumb_pos.Height;
4076 Region outside = new Region (area);
4077 outside.Exclude (thumb_area);
4079 if (outside.IsVisible (clip_rectangle)) {
4080 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
4081 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
4083 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
4084 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
4085 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
4086 area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3);
4088 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
4089 area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2);
4093 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
4094 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
4096 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
4097 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
4098 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
4099 area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y);
4101 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
4102 area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
4110 public override void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb)
4115 float ticks = (tb.Maximum - tb.Minimum) / tb.tickFrequency; /* N of ticks draw*/
4117 Rectangle thumb_pos = tb.ThumbPos;
4118 Rectangle thumb_area = tb.ThumbArea;
4120 if (tb.thumb_pressed) {
4121 value_pos = tb.thumb_mouseclick;
4124 value_pos = tb.Value - tb.Minimum;
4125 mouse_value = false;
4128 area = tb.ClientRectangle;
4130 if (tb.thumb_pressed == true) {
4131 br_thumb = (Brush) ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControlLight, ColorControl);
4133 br_thumb = ResPool.GetSolidBrush (ColorControl);
4137 /* Control Background */
4138 if (tb.BackColor == DefaultControlBackColor) {
4139 dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), clip_rectangle);
4141 dc.FillRectangle (ResPool.GetSolidBrush (tb.BackColor), clip_rectangle);
4146 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black), area.X, area.Y, area.Width - 1, 1);
4147 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black), area.X, area.Y + area.Height - 1, area.Width - 1, 1);
4148 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black), area.X, area.Y, 1, area.Height - 1);
4149 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black), area.X + area.Width - 1, area.Y, 1, area.Height - 1);
4152 if (tb.Orientation == Orientation.Vertical) {
4153 DrawTrackBar_Vertical (dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
4154 br_thumb, ticks, value_pos, mouse_value);
4157 DrawTrackBar_Horizontal (dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
4158 br_thumb, ticks, value_pos, mouse_value);
4161 tb.ThumbPos = thumb_pos;
4162 tb.ThumbArea = thumb_area;
4165 public override Size TrackBarDefaultSize {
4167 return new Size (104, 42);
4171 #endregion // TrackBar
4174 public override Size VScrollBarDefaultSize {
4176 return new Size (this.ScrollBarButtonSize, 80);
4179 #endregion // VScrollBar
4182 public override Size TreeViewDefaultSize {
4184 return new Size (121, 97);
4190 #region ControlPaint
4191 private enum DrawFrameControlStates {
4192 ButtonCheck = 0x0000,
4193 ButtonRadioImage = 0x0001,
4194 ButtonRadioMask = 0x0002,
4195 ButtonRadio = 0x0004,
4196 Button3State = 0x0008,
4197 ButtonPush = 0x0010,
4199 CaptionClose = 0x0000,
4200 CaptionMin = 0x0001,
4201 CaptionMax = 0x0002,
4202 CaptionRestore = 0x0004,
4203 CaptionHelp = 0x0008,
4207 MenuBullet = 0x0002,
4208 MenuArrowRight = 0x0004,
4211 ScrollDown = 0x0001,
4212 ScrollLeft = 0x0002,
4213 ScrollRight = 0x0003,
4214 ScrollComboBox = 0x0005,
4215 ScrollSizeGrip = 0x0008,
4216 ScrollSizeGripRight = 0x0010,
4221 Transparent = 0x0800,
4223 AdjustRect = 0x2000,
4229 private enum DrawFrameControlTypes {
4236 public override void CPDrawBorder (Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
4237 ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
4238 Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
4239 int bottomWidth, ButtonBorderStyle bottomStyle) {
4240 DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom-1, leftWidth, leftColor, leftStyle, Border3DSide.Left);
4241 DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Right-1, bounds.Top, topWidth, topColor, topStyle, Border3DSide.Top);
4242 DrawBorderInternal(graphics, bounds.Right-1, bounds.Top, bounds.Right-1, bounds.Bottom-1, rightWidth, rightColor, rightStyle, Border3DSide.Right);
4243 DrawBorderInternal(graphics, bounds.Left, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1, bottomWidth, bottomColor, bottomStyle, Border3DSide.Bottom);
4246 public override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) {
4247 CPDrawBorder3D(graphics, rectangle, style, sides, ColorControl);
4250 private void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color) {
4252 Pen penTopLeftInner;
4254 Pen penBottomRightInner;
4255 Rectangle rect= new Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
4256 bool doInner = false;
4258 if ((style & Border3DStyle.Adjust)!=0) {
4265 /* default to flat */
4266 penTopLeft=ResPool.GetPen(ControlPaint.Dark(control_color));
4267 penTopLeftInner=ResPool.GetPen(ControlPaint.Dark(control_color));
4268 penBottomRight=ResPool.GetPen(ControlPaint.Dark(control_color));
4269 penBottomRightInner=ResPool.GetPen(ControlPaint.Dark(control_color));
4271 if ((style & Border3DStyle.RaisedOuter)!=0) {
4272 penTopLeft=ResPool.GetPen(ControlPaint.LightLight(control_color));
4273 penBottomRight=ResPool.GetPen(ControlPaint.DarkDark(control_color));
4274 if ((style & (Border3DStyle.RaisedInner | Border3DStyle.SunkenInner))!=0) {
4277 } else if ((style & Border3DStyle.SunkenOuter)!=0) {
4278 penTopLeft=ResPool.GetPen(ControlPaint.DarkDark(control_color));
4279 penBottomRight=ResPool.GetPen(ControlPaint.LightLight(control_color));
4280 if ((style & (Border3DStyle.RaisedInner | Border3DStyle.SunkenInner))!=0) {
4285 if ((style & Border3DStyle.RaisedInner)!=0) {
4287 penTopLeftInner=ResPool.GetPen(control_color);
4288 penBottomRightInner=ResPool.GetPen(ControlPaint.Dark(control_color));
4290 penTopLeft=ResPool.GetPen(ControlPaint.LightLight(control_color));
4291 penBottomRight=ResPool.GetPen(ControlPaint.DarkDark(control_color));
4293 } else if ((style & Border3DStyle.SunkenInner)!=0) {
4295 penTopLeftInner=ResPool.GetPen(ControlPaint.Dark(control_color));
4296 penBottomRightInner=ResPool.GetPen(control_color);
4298 penTopLeft=ResPool.GetPen(ControlPaint.DarkDark(control_color));
4299 penBottomRight=ResPool.GetPen(ControlPaint.LightLight(control_color));
4303 if ((sides & Border3DSide.Middle)!=0) {
4304 graphics.FillRectangle(ResPool.GetSolidBrush(control_color), rect);
4307 if ((sides & Border3DSide.Left)!=0) {
4308 graphics.DrawLine(penTopLeft, rect.Left, rect.Bottom-2, rect.Left, rect.Top);
4310 graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Bottom-2, rect.Left+1, rect.Top);
4314 if ((sides & Border3DSide.Top)!=0) {
4315 graphics.DrawLine(penTopLeft, rect.Left, rect.Top, rect.Right-2, rect.Top);
4318 if ((sides & Border3DSide.Left)!=0) {
4319 graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Top+1, rect.Right-3, rect.Top+1);
4321 graphics.DrawLine(penTopLeftInner, rect.Left, rect.Top+1, rect.Right-3, rect.Top+1);
4326 if ((sides & Border3DSide.Right)!=0) {
4327 graphics.DrawLine(penBottomRight, rect.Right-1, rect.Top, rect.Right-1, rect.Bottom-1);
4330 if ((sides & Border3DSide.Top)!=0) {
4331 graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top+1, rect.Right-2, rect.Bottom-2);
4333 graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top, rect.Right-2, rect.Bottom-2);
4338 if ((sides & Border3DSide.Bottom)!=0) {
4341 if ((sides & Border3DSide.Left)!=0) {
4345 graphics.DrawLine(penBottomRight, rect.Left, rect.Bottom-1, rect.Right-1, rect.Bottom-1);
4348 if ((sides & Border3DSide.Right)!=0) {
4349 graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-2, rect.Bottom-2);
4351 graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-2, rect.Bottom-2);
4359 public override void CPDrawButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
4360 DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonPush;
4362 if ((state & ButtonState.Pushed)!=0) {
4363 dfcs |= DrawFrameControlStates.Pushed;
4366 if ((state & ButtonState.Checked)!=0) {
4367 dfcs |= DrawFrameControlStates.Checked;
4370 if ((state & ButtonState.Flat)!=0) {
4371 dfcs |= DrawFrameControlStates.Flat;
4374 if ((state & ButtonState.Inactive)!=0) {
4375 dfcs |= DrawFrameControlStates.Inactive;
4377 DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.Button, dfcs);
4381 public override void CPDrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state) {
4382 Rectangle captionRect;
4385 CPDrawButton(graphics, rectangle, state);
4387 if (rectangle.Width<rectangle.Height) {
4388 captionRect=new Rectangle(rectangle.X+1, rectangle.Y+rectangle.Height/2-rectangle.Width/2+1, rectangle.Width-4, rectangle.Width-4);
4390 captionRect=new Rectangle(rectangle.X+rectangle.Width/2-rectangle.Height/2+1, rectangle.Y+1, rectangle.Height-4, rectangle.Height-4);
4393 if ((state & ButtonState.Pushed)!=0) {
4394 captionRect=new Rectangle(rectangle.X+2, rectangle.Y+2, rectangle.Width-3, rectangle.Height-3);
4397 /* Make sure we've got at least a line width of 1 */
4398 lineWidth=Math.Max(1, captionRect.Width/7);
4401 case CaptionButton.Close: {
4404 if ((state & ButtonState.Inactive)!=0) {
4405 pen=new Pen(ColorControlLight, lineWidth);
4406 DrawCaptionHelper(graphics, ColorControlLight, pen, lineWidth, 1, captionRect, button);
4409 pen=new Pen(ColorControlDark, lineWidth);
4410 DrawCaptionHelper(graphics, ColorControlDark, pen, lineWidth, 0, captionRect, button);
4414 pen=new Pen(ColorControlText, lineWidth);
4415 DrawCaptionHelper(graphics, ColorControlText, pen, lineWidth, 0, captionRect, button);
4421 case CaptionButton.Help:
4422 case CaptionButton.Maximize:
4423 case CaptionButton.Minimize:
4424 case CaptionButton.Restore: {
4425 if ((state & ButtonState.Inactive)!=0) {
4426 DrawCaptionHelper(graphics, ColorControlLight, SystemPens.ControlLightLight, lineWidth, 1, captionRect, button);
4428 DrawCaptionHelper(graphics, ColorControlDark, SystemPens.ControlDark, lineWidth, 0, captionRect, button);
4431 DrawCaptionHelper(graphics, ColorControlText, SystemPens.ControlText, lineWidth, 0, captionRect, button);
4439 public override void CPDrawCheckBox (Graphics graphics, Rectangle rectangle, ButtonState state) {
4440 DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonCheck;
4442 if ((state & ButtonState.Pushed)!=0) {
4443 dfcs |= DrawFrameControlStates.Pushed;
4446 if ((state & ButtonState.Checked)!=0) {
4447 dfcs |= DrawFrameControlStates.Checked;
4450 if ((state & ButtonState.Flat)!=0) {
4451 dfcs |= DrawFrameControlStates.Flat;
4454 if ((state & ButtonState.Inactive)!=0) {
4455 dfcs |= DrawFrameControlStates.Inactive;
4458 DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.Button, dfcs);
4462 public override void CPDrawComboButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
4463 Point[] arrow = new Point[3];
4473 if ((state & ButtonState.Checked)!=0) {
4474 graphics.FillRectangle(ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControlLightLight, ColorControlLight),rectangle);
4477 if ((state & ButtonState.Flat)!=0) {
4478 ControlPaint.DrawBorder(graphics, rectangle, ColorControlDark, ButtonBorderStyle.Solid);
4480 if ((state & (ButtonState.Pushed | ButtonState.Checked))!=0) {
4481 // this needs to render like a pushed button - jba
4482 // CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
4483 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
4484 graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorControl)), trace_rectangle);
4486 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
4490 rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
4491 centerX=rect.Left+rect.Width/2;
4492 centerY=rect.Top+rect.Height/2;
4493 shiftX=Math.Max(1, rect.Width/8);
4494 shiftY=Math.Max(1, rect.Height/8);
4496 if ((state & ButtonState.Pushed)!=0) {
4503 P1=new Point(rect.Left, centerY);
4504 P2=new Point(rect.Right, centerY);
4505 P3=new Point(centerX, rect.Bottom);
4511 /* Draw the arrow */
4512 if ((state & ButtonState.Inactive)!=0) {
4513 graphics.FillPolygon(SystemBrushes.ControlLightLight, arrow, FillMode.Winding);
4515 /* Move away from the shadow */
4525 graphics.FillPolygon(SystemBrushes.ControlDark, arrow, FillMode.Winding);
4527 graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding);
4532 public override void CPDrawContainerGrabHandle (Graphics graphics, Rectangle bounds) {
4534 Pen pen = new Pen(Color.Black, 1);
4535 Rectangle rect = new Rectangle(bounds.X, bounds.Y, bounds.Width-1, bounds.Height-1); // Dunno why, but MS does it that way, too
4539 graphics.FillRectangle(ResPool.GetSolidBrush (ColorControlText), rect);
4540 graphics.DrawRectangle(pen, rect);
4542 X=rect.X+rect.Width/2;
4543 Y=rect.Y+rect.Height/2;
4545 /* Draw the cross */
4546 graphics.DrawLine(pen, X, rect.Y+2, X, rect.Bottom-2);
4547 graphics.DrawLine(pen, rect.X+2, Y, rect.Right-2, Y);
4549 /* Draw 'arrows' for vertical lines */
4550 graphics.DrawLine(pen, X-1, rect.Y+3, X+1, rect.Y+3);
4551 graphics.DrawLine(pen, X-1, rect.Bottom-3, X+1, rect.Bottom-3);
4553 /* Draw 'arrows' for horizontal lines */
4554 graphics.DrawLine(pen, rect.X+3, Y-1, rect.X+3, Y+1);
4555 graphics.DrawLine(pen, rect.Right-3, Y-1, rect.Right-3, Y+1);
4560 public virtual void DrawFlatStyleFocusRectangle (Graphics graphics, Rectangle rectangle, ButtonBase button, Color foreColor, Color backColor) {
4561 // make a rectange to trace around border of the button
4562 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
4564 Color outerColor = foreColor;
4565 // adjust focus color according to the flatstyle
4566 if (button.FlatStyle == FlatStyle.Popup && !button.is_pressed) {
4567 outerColor = (backColor == ColorControl) ? ControlPaint.Dark(ColorControl) : ColorControlText;
4570 // draw the outer rectangle
4571 graphics.DrawRectangle (ResPool.GetPen (outerColor), trace_rectangle);
4573 // draw the inner rectangle
4574 if (button.FlatStyle == FlatStyle.Popup) {
4575 DrawInnerFocusRectangle (graphics, Rectangle.Inflate (rectangle, -4, -4), backColor);
4577 // draw a flat inner rectangle
4578 Pen pen = ResPool.GetPen (ControlPaint.LightLight (backColor));
4579 graphics.DrawRectangle(pen, Rectangle.Inflate (trace_rectangle, -4, -4));
4583 public virtual void DrawInnerFocusRectangle(Graphics graphics, Rectangle rectangle, Color backColor)
4585 // make a rectange to trace around border of the button
4586 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
4588 #if NotUntilCairoIsFixed
4589 Color colorBackInverted = Color.FromArgb (Math.Abs (backColor.R-255), Math.Abs (backColor.G-255), Math.Abs (backColor.B-255));
4590 DashStyle oldStyle; // used for caching old penstyle
4591 Pen pen = ResPool.GetPen (colorBackInverted);
4593 oldStyle = pen.DashStyle;
4594 pen.DashStyle = DashStyle.Dot;
4596 graphics.DrawRectangle (pen, trace_rectangle);
4597 pen.DashStyle = oldStyle;
4599 CPDrawFocusRectangle(graphics, trace_rectangle, Color.Wheat, backColor);
4604 public override void CPDrawFocusRectangle (Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor)
4606 Rectangle rect = rectangle;
4610 if (backColor.GetBrightness () >= 0.5) {
4611 foreColor = Color.Transparent;
4612 backColor = Color.Black;
4615 backColor = Color.FromArgb (Math.Abs (backColor.R-255), Math.Abs (backColor.G-255), Math.Abs (backColor.B-255));
4616 foreColor = Color.Black;
4619 brush = ResPool.GetHatchBrush (HatchStyle.Percent50, backColor, foreColor);
4620 pen = new Pen (brush, 1);
4625 graphics.DrawRectangle (pen, rect);
4629 public override void CPDrawGrabHandle (Graphics graphics, Rectangle rectangle, bool primary, bool enabled) {
4633 if (primary==true) {
4634 pen=new Pen(Color.Black, 1);
4635 if (enabled==true) {
4636 sb=ResPool.GetSolidBrush (ColorControlText);
4638 sb=ResPool.GetSolidBrush (ColorControl);
4641 pen=new Pen(Color.White, 1);
4642 if (enabled==true) {
4643 sb=ResPool.GetSolidBrush (Color.Black);
4645 sb=ResPool.GetSolidBrush (ColorControl);
4648 graphics.FillRectangle(sb, rectangle);
4649 graphics.DrawRectangle(pen, rectangle);
4654 public override void CPDrawGrid (Graphics graphics, Rectangle area, Size pixelsBetweenDots, Color backColor) {
4660 ControlPaint.Color2HBS(backColor, out h, out b, out s);
4663 foreColor=Color.Black;
4665 foreColor=Color.White;
4669 /* Commented out until I take the time and figure out
4670 which HatchStyle will match requirements. The code below
4671 is only correct for Percent50.
4673 if (pixelsBetweenDots.Width==pixelsBetweenDots.Height) {
4674 HatchBrush brush=null;
4676 switch(pixelsBetweenDots.Width) {
4677 case 2: brush=new HatchBrush(HatchStyle.Percent50, foreColor, backColor); break;
4678 case 4: brush=new HatchBrush(HatchStyle.Percent25, foreColor, backColor); break;
4679 case 5: brush=new HatchBrush(HatchStyle.Percent20, foreColor, backColor); break;
4681 /* Have to do it the slow way */
4686 graphics.FillRectangle(brush, area);
4695 Bitmap bitmap = new Bitmap(area.Width, area.Height, graphics);
4697 for (int x=0; x<area.Width; x+=pixelsBetweenDots.Width) {
4698 for (int y=0; y<area.Height; y+=pixelsBetweenDots.Height) {
4699 bitmap.SetPixel(x, y, foreColor);
4702 graphics.DrawImage(bitmap, area.X, area.Y, area.Width, area.Height);
4706 public override void CPDrawImageDisabled (Graphics graphics, Image image, int x, int y, Color background) {
4708 Microsoft seems to ignore the background and simply make
4709 the image grayscale. At least when having > 256 colors on
4713 if (imagedisabled_attributes == null) {
4714 imagedisabled_attributes = new ImageAttributes ();
4715 ColorMatrix colorMatrix=new ColorMatrix(new float[][] {
4716 // This table would create a perfect grayscale image, based on luminance
4717 // new float[]{0.3f,0.3f,0.3f,0,0},
4718 // new float[]{0.59f,0.59f,0.59f,0,0},
4719 // new float[]{0.11f,0.11f,0.11f,0,0},
4720 // new float[]{0,0,0,1,0,0},
4721 // new float[]{0,0,0,0,1,0},
4722 // new float[]{0,0,0,0,0,1}
4724 // This table generates a image that is grayscaled and then
4725 // brightened up. Seems to match MS close enough.
4726 new float[]{0.2f,0.2f,0.2f,0,0},
4727 new float[]{0.41f,0.41f,0.41f,0,0},
4728 new float[]{0.11f,0.11f,0.11f,0,0},
4729 new float[]{0.15f,0.15f,0.15f,1,0,0},
4730 new float[]{0.15f,0.15f,0.15f,0,1,0},
4731 new float[]{0.15f,0.15f,0.15f,0,0,1}
4734 imagedisabled_attributes.SetColorMatrix (colorMatrix);
4737 graphics.DrawImage(image, new Rectangle(x, y, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imagedisabled_attributes);
4742 public override void CPDrawLockedFrame (Graphics graphics, Rectangle rectangle, bool primary) {
4747 penBorder=new Pen(Color.White, 2);
4748 penInside=new Pen(Color.Black, 1);
4750 penBorder=new Pen(Color.Black, 2);
4751 penInside=new Pen(Color.White, 1);
4753 penBorder.Alignment=PenAlignment.Inset;
4754 penInside.Alignment=PenAlignment.Inset;
4756 graphics.DrawRectangle(penBorder, rectangle);
4757 graphics.DrawRectangle(penInside, rectangle.X+2, rectangle.Y+2, rectangle.Width-5, rectangle.Height-5);
4758 penBorder.Dispose();
4759 penInside.Dispose();
4763 public override void CPDrawMenuGlyph (Graphics graphics, Rectangle rectangle, MenuGlyph glyph, Color color) {
4767 Brush brush = ResPool.GetSolidBrush (color);
4770 case MenuGlyph.Arrow: {
4771 Point[] arrow = new Point[3];
4779 rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
4780 centerX=rect.Left+rect.Width/2;
4781 centerY=rect.Top+rect.Height/2;
4782 shiftX=Math.Max(1, rect.Width/8);
4787 P1=new Point(centerX, rect.Top-1);
4788 P2=new Point(centerX, rect.Bottom);
4789 P3=new Point(rect.Right, centerY);
4795 graphics.FillPolygon(brush, arrow, FillMode.Winding);
4800 case MenuGlyph.Bullet: {
4802 lineWidth=Math.Max(2, rectangle.Width/3);
4803 rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
4805 graphics.FillEllipse(brush, rect);
4810 case MenuGlyph.Checkmark: {
4812 Pen pen = ResPool.GetPen (color);
4814 lineWidth=Math.Max(2, rectangle.Width/6);
4815 Scale=Math.Max(1, rectangle.Width/12);
4817 rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
4819 for (int i=0; i<lineWidth; i++) {
4820 graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
4821 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);
4829 public override void CPDrawRadioButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
4830 DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonRadio;
4832 if ((state & ButtonState.Pushed)!=0) {
4833 dfcs |= DrawFrameControlStates.Pushed;
4836 if ((state & ButtonState.Checked)!=0) {
4837 dfcs |= DrawFrameControlStates.Checked;
4840 if ((state & ButtonState.Flat)!=0) {
4841 dfcs |= DrawFrameControlStates.Flat;
4844 if ((state & ButtonState.Inactive)!=0) {
4845 dfcs |= DrawFrameControlStates.Inactive;
4847 DrawFrameControl(graphics, rectangle, DrawFrameControlTypes.Button, dfcs);
4852 public override void CPDrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style) {
4857 public override void CPDrawReversibleLine (Point start, Point end, Color backColor) {
4862 /* Scroll button: regular button + direction arrow */
4863 public override void CPDrawScrollButton (Graphics dc, Rectangle area, ScrollButton type, ButtonState state) {
4864 DrawScrollButtonPrimitive (dc, area, state);
4866 // A lot of the following is adapted from the rewind project
4867 Rectangle rect = new Rectangle (area.X - 3, area.Y - 3,
4868 area.Width + 6, area.Height + 6);
4869 int small_diam = rect.Width > rect.Height ? rect.Height : rect.Width;
4870 if (rect.Width < rect.Height) {
4871 rect.Y += (rect.Height - rect.Width) / 2;
4872 rect.Height = small_diam;
4873 } else if (rect.Width > rect.Height) {
4874 rect.X += (rect.Width - rect.Height) / 2;
4875 rect.Width = small_diam;
4880 int tri = 290 * small_diam / 1000 - 1;
4884 Point [] arrow = new Point [3];
4885 for (int i = 0; i < 3; i++)
4886 arrow [i] = new Point ();
4890 case ScrollButton.Down:
4891 arrow [2].X = rect.Left + 470 * small_diam / 1000 + 2;
4892 arrow [2].Y = rect.Top + 687 * small_diam / 1000 + 1;
4893 arrow [0].X = arrow [2].X - tri;
4894 arrow [1].X = arrow [2].X + tri;
4895 arrow [0].Y = arrow [1].Y = arrow [2].Y - tri;
4898 case ScrollButton.Up:
4899 arrow [2].X = rect.Left + 470 * small_diam / 1000 + 2;
4900 arrow [2].Y = rect.Bottom - (687 * small_diam / 1000 + 1);
4901 arrow [0].X = arrow [2].X - tri;
4902 arrow [1].X = arrow [2].X + tri;
4903 arrow [0].Y = arrow [1].Y = arrow [2].Y + tri;
4906 case ScrollButton.Left:
4907 arrow [2].X = rect.Right - (687 * small_diam / 1000 + 1);
4908 arrow [2].Y = rect.Top + 470 * small_diam / 1000 + 2;
4909 arrow [0].Y = arrow [2].Y - tri;
4910 arrow [1].Y = arrow [2].Y + tri;
4911 arrow [0].X = arrow [1].X = arrow [2].X + tri;
4913 case ScrollButton.Right:
4914 arrow [2].X = rect.Left + 687 * small_diam / 1000 + 1;
4915 arrow [2].Y = rect.Top + 470 * small_diam / 1000 + 2;
4916 arrow [0].Y = arrow [2].Y - tri;
4917 arrow [1].Y = arrow [2].Y + tri;
4918 arrow [0].X = arrow [1].X = arrow [2].X - tri;
4922 /* Draw the arrow */
4923 if ((state & ButtonState.Inactive)!=0) {
4924 dc.FillPolygon (SystemBrushes.ControlLightLight, arrow, FillMode.Winding);
4926 for (int i = 0; i < 3; i++) {
4931 dc.FillPolygon (SystemBrushes.ControlDark, arrow, FillMode.Winding);
4933 dc.FillPolygon (SystemBrushes.ControlText, arrow, FillMode.Winding);
4937 public override void CPDrawSelectionFrame (Graphics graphics, bool active, Rectangle outsideRect, Rectangle insideRect,
4943 public override void CPDrawSizeGrip (Graphics dc, Color backColor, Rectangle bounds) {
4944 Point pt = new Point (bounds.Right - 2, bounds.Bottom - 1);
4946 dc.DrawLine (ResPool.GetPen (ColorControl), pt.X - 12, pt.Y, pt.X, pt.Y);
4947 dc.DrawLine (ResPool.GetPen (ColorControl), pt.X, pt.Y, pt.X, pt.Y - 13);
4950 for (int i = 0; i < 11; i += 4) {
4951 dc.DrawLine (ResPool.GetPen (ColorControlDark), pt.X - i, pt.Y, pt.X + 1, pt.Y - i - 2);
4952 dc.DrawLine (ResPool.GetPen (ColorControlDark), pt.X - i - 1, pt.Y, pt.X + 1, pt.Y - i - 2);
4955 for (int i = 3; i < 13; i += 4)
4956 dc.DrawLine (ResPool.GetPen (ColorControlLight), pt.X - i, pt.Y, pt.X + 1, pt.Y - i - 1);
4960 public override void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
4961 StringFormat format) {
4963 graphics.DrawString(s, font, ResPool.GetSolidBrush (ColorGrayText), layoutRectangle, format);
4967 private static void DrawBorderInternal(Graphics graphics, int startX, int startY, int endX, int endY,
4968 int width, Color color, ButtonBorderStyle style, Border3DSide side) {
4970 Pen pen=new Pen(color, 1);
4973 case ButtonBorderStyle.Solid: {
4974 pen.DashStyle=DashStyle.Solid;
4978 case ButtonBorderStyle.Dashed: {
4979 pen.DashStyle=DashStyle.Dash;
4983 case ButtonBorderStyle.Dotted: {
4984 pen.DashStyle=DashStyle.Dot;
4988 case ButtonBorderStyle.Inset: {
4989 pen.DashStyle=DashStyle.Solid;
4993 case ButtonBorderStyle.Outset: {
4994 pen.DashStyle=DashStyle.Solid;
4999 case ButtonBorderStyle.None: {
5007 case ButtonBorderStyle.Outset: {
5009 int hue, brightness, saturation;
5010 int brightnessSteps;
5011 int brightnessDownSteps;
5013 ControlPaint.Color2HBS(color, out hue, out brightness, out saturation);
5015 brightnessDownSteps=brightness/width;
5016 if (brightness>127) {
5017 brightnessSteps=Math.Max(6, (160-brightness)/width);
5019 brightnessSteps=(127-brightness)/width;
5022 for (int i=0; i<width; i++) {
5024 case Border3DSide.Left: {
5026 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
5027 pen=new Pen(colorGrade, 1);
5028 graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
5032 case Border3DSide.Right: {
5034 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
5035 pen=new Pen(colorGrade, 1);
5036 graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
5040 case Border3DSide.Top: {
5042 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
5043 pen=new Pen(colorGrade, 1);
5044 graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
5048 case Border3DSide.Bottom: {
5050 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
5051 pen=new Pen(colorGrade, 1);
5052 graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
5060 case ButtonBorderStyle.Inset: {
5062 int hue, brightness, saturation;
5063 int brightnessSteps;
5064 int brightnessDownSteps;
5066 ControlPaint.Color2HBS(color, out hue, out brightness, out saturation);
5068 brightnessDownSteps=brightness/width;
5069 if (brightness>127) {
5070 brightnessSteps=Math.Max(6, (160-brightness)/width);
5072 brightnessSteps=(127-brightness)/width;
5075 for (int i=0; i<width; i++) {
5077 case Border3DSide.Left: {
5079 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
5080 pen=new Pen(colorGrade, 1);
5081 graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
5085 case Border3DSide.Right: {
5087 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
5088 pen=new Pen(colorGrade, 1);
5089 graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
5093 case Border3DSide.Top: {
5095 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
5096 pen=new Pen(colorGrade, 1);
5097 graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
5101 case Border3DSide.Bottom: {
5103 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
5104 pen=new Pen(colorGrade, 1);
5105 graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
5114 I decided to have the for-loop duplicated for speed reasons;
5115 that way we only have to switch once (as opposed to have the
5116 for-loop around the switch)
5120 case Border3DSide.Left: {
5121 for (int i=0; i<width; i++) {
5122 graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
5127 case Border3DSide.Right: {
5128 for (int i=0; i<width; i++) {
5129 graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
5134 case Border3DSide.Top: {
5135 for (int i=0; i<width; i++) {
5136 graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
5141 case Border3DSide.Bottom: {
5142 for (int i=0; i<width; i++) {
5143 graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
5155 This function actually draws the various caption elements.
5156 This way we can scale them nicely, no matter what size, and they
5157 still look like MS's scaled caption buttons. (as opposed to scaling a bitmap)
5160 private void DrawCaptionHelper(Graphics graphics, Color color, Pen pen, int lineWidth, int shift, Rectangle captionRect, CaptionButton button) {
5162 case CaptionButton.Close: {
5163 pen.StartCap=LineCap.Triangle;
5164 pen.EndCap=LineCap.Triangle;
5166 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);
5167 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);
5170 graphics.DrawLine(pen, captionRect.Left+2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Right-2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
5171 graphics.DrawLine(pen, captionRect.Right-2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Left+2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
5175 case CaptionButton.Help: {
5176 StringFormat sf = new StringFormat();
5177 Font font = new Font("Microsoft Sans Serif", captionRect.Height, FontStyle.Bold, GraphicsUnit.Pixel);
5179 sf.Alignment=StringAlignment.Center;
5180 sf.LineAlignment=StringAlignment.Center;
5183 graphics.DrawString("?", font, ResPool.GetSolidBrush (color), captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
5191 case CaptionButton.Maximize: {
5192 /* Top 'caption bar' line */
5193 for (int i=0; i<Math.Max(2, lineWidth); i++) {
5194 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);
5197 /* Left side line */
5198 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5199 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
5202 /* Right side line */
5203 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5204 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);
5208 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5209 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
5214 case CaptionButton.Minimize: {
5216 for (int i=0; i<Math.Max(2, lineWidth); i++) {
5217 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth+shift, captionRect.Bottom-lineWidth+shift-i);
5222 case CaptionButton.Restore: {
5223 /** First 'window' **/
5224 /* Top 'caption bar' line */
5225 for (int i=0; i<Math.Max(2, lineWidth); i++) {
5226 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);
5229 /* Left side line */
5230 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5231 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);
5234 /* Right side line */
5235 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5236 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);
5240 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5241 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);
5244 /** Second 'window' **/
5245 /* Top 'caption bar' line */
5246 for (int i=0; i<Math.Max(2, lineWidth); i++) {
5247 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);
5250 /* Left side line */
5251 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5252 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+4*lineWidth+shift+1, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
5255 /* Right side line */
5256 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5257 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);
5261 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5262 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
5271 [MonoTODO("Finish drawing code for Caption, Menu and Scroll")]
5272 private void DrawFrameControl(Graphics graphics, Rectangle rectangle, DrawFrameControlTypes Type, DrawFrameControlStates State) {
5273 // make a rectange to trace around border of the button
5274 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
5276 case DrawFrameControlTypes.Button: {
5278 if ((State & DrawFrameControlStates.ButtonPush)!=0) {
5279 // JBA 31 oct 2004 - I don't think that button style should be rendered like this
5280 // /* Goes first, affects the background */
5281 // if ((State & DrawFrameControlStates.Checked)!=0) {
5282 // HatchBrush hatchBrush=new HatchBrush(HatchStyle.Percent50, ColorControlLightLight, ColorControlLight);
5283 // graphics.FillRectangle(hatchBrush,rectangle);
5284 // hatchBrush.Dispose();
5287 if ((State & DrawFrameControlStates.Pushed)!=0 || (State & DrawFrameControlStates.Checked)!=0) {
5288 graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorControl)), trace_rectangle);
5289 } else if ((State & DrawFrameControlStates.Flat)!=0) {
5290 ControlPaint.DrawBorder(graphics, rectangle, ColorControlDark, ButtonBorderStyle.Solid);
5291 } else if ((State & DrawFrameControlStates.Inactive)!=0) {
5292 /* Same as normal, it would seem */
5293 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
5295 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
5297 } else if ((State & DrawFrameControlStates.ButtonRadio)!=0) {
5298 Pen penFatDark = new Pen(ColorControlDark, 1);
5299 Pen penFatLight = new Pen(ColorControlLightLight, 1);
5302 graphics.FillPie (ResPool.GetSolidBrush (this.ColorWindow), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
5304 graphics.DrawArc(penFatDark, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 135, 180);
5305 graphics.DrawArc(penFatLight, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 315, 180);
5307 graphics.DrawArc(SystemPens.ControlDark, rectangle, 135, 180);
5308 graphics.DrawArc(SystemPens.ControlLightLight, rectangle, 315, 180);
5310 lineWidth=Math.Max(1, Math.Min(rectangle.Width, rectangle.Height)/3);
5312 if ((State & DrawFrameControlStates.Checked)!=0) {
5313 SolidBrush buttonBrush;
5315 if ((State & DrawFrameControlStates.Inactive)!=0) {
5316 buttonBrush=(SolidBrush)SystemBrushes.ControlDark;
5318 buttonBrush=(SolidBrush)SystemBrushes.ControlText;
5320 graphics.FillPie(buttonBrush, rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2, 0, 359);
5322 penFatDark.Dispose();
5323 penFatLight.Dispose();
5324 } else if ((State & DrawFrameControlStates.ButtonRadioImage)!=0) {
5325 throw new NotImplementedException () ;
5326 } else if ((State & DrawFrameControlStates.ButtonRadioMask)!=0) {
5327 throw new NotImplementedException ();
5328 } else { /* Must be Checkbox */
5334 /* Goes first, affects the background */
5335 if ((State & DrawFrameControlStates.Pushed)!=0 ||
5336 (State & DrawFrameControlStates.Inactive)!=0) {
5337 graphics.FillRectangle(SystemBrushes.Control, rectangle);
5339 graphics.FillRectangle(SystemBrushes.Window, rectangle);
5342 /* Draw the sunken frame */
5343 if ((State & DrawFrameControlStates.Flat)!=0) {
5344 ControlPaint.DrawBorder(graphics, rectangle, ColorControlDark, ButtonBorderStyle.Solid);
5346 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
5349 /* Make sure we've got at least a line width of 1 */
5350 lineWidth=Math.Max(3, rectangle.Width/6);
5351 Scale=Math.Max(1, rectangle.Width/12);
5353 // define a rectangle inside the border area
5354 rect=new Rectangle(rectangle.X+2, rectangle.Y+2, rectangle.Width-4, rectangle.Height-4);
5355 if ((State & DrawFrameControlStates.Inactive)!=0) {
5356 pen=SystemPens.ControlDark;
5358 pen=SystemPens.ControlText;
5361 if ((State & DrawFrameControlStates.Checked)!=0) {
5362 /* Need to draw a check-mark */
5363 for (int i=0; i<lineWidth; i++) {
5364 graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
5365 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);
5373 case DrawFrameControlTypes.Caption: {
5378 case DrawFrameControlTypes.Menu: {
5383 case DrawFrameControlTypes.Scroll: {
5390 /* Generic scroll button */
5391 public void DrawScrollButtonPrimitive (Graphics dc, Rectangle area, ButtonState state) {
5392 if ((state & ButtonState.Pushed) == ButtonState.Pushed) {
5393 dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), area.X + 1,
5394 area.Y + 1, area.Width - 2 , area.Height - 2);
5396 dc.DrawRectangle (ResPool.GetPen (ColorControlDark), area.X,
5397 area.Y, area.Width, area.Height);
5402 dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), area.X, area.Y, area.Width, 1);
5403 dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), area.X, area.Y, 1, area.Height);
5405 dc.FillRectangle (ResPool.GetSolidBrush (ColorControlLight), area.X + 1, area.Y + 1, area.Width - 1, 1);
5406 dc.FillRectangle (ResPool.GetSolidBrush (ColorControlLight), area.X + 1, area.Y + 2, 1,
5409 dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDark), area.X + 1, area.Y + area.Height - 2,
5412 dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDarkDark), area.X, area.Y + area.Height -1,
5415 dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDark), area.X + area.Width - 2,
5416 area.Y + 1, 1, area.Height -3);
5418 dc.FillRectangle (ResPool.GetSolidBrush (ColorControlDarkDark), area.X + area.Width -1,
5419 area.Y, 1, area.Height - 1);
5421 dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), area.X + 2,
5422 area.Y + 2, area.Width - 4, area.Height - 4);
5426 public override void CPDrawBorderStyle (Graphics dc, Rectangle area, BorderStyle border_style) {
5427 switch (border_style){
5428 case BorderStyle.Fixed3D:
5429 dc.DrawLine (ResPool.GetPen (ColorControlDark), area.X, area.Y, area.X +area.Width, area.Y);
5430 dc.DrawLine (ResPool.GetPen (ColorControlDark), area.X, area.Y, area.X, area.Y + area.Height);
5431 dc.DrawLine (ResPool.GetPen (ColorControlLight), area.X , area.Y + area.Height - 1, area.X + area.Width ,
5432 area.Y + area.Height - 1);
5433 dc.DrawLine (ResPool.GetPen (ColorControlLight), area.X + area.Width -1 , area.Y, area.X + area.Width -1,
5434 area.Y + area.Height);
5436 dc.DrawLine (ResPool.GetPen (ColorActiveBorder), area.X + 1, area.Bottom - 2, area.Right - 2, area.Bottom - 2);
5437 dc.DrawLine (ResPool.GetPen (ColorActiveBorder), area.Right - 2, area.Top + 1, area.Right - 2, area.Bottom - 2);
5438 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), area.X + 1, area.Top + 1, area.X + 1, area.Bottom - 3);
5439 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), area.X + 1, area.Top + 1, area.Right - 3, area.Top + 1);
5441 case BorderStyle.FixedSingle:
5442 dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame), area.X, area.Y, area.Width - 1, area.Height - 1);
5444 case BorderStyle.None:
5450 #endregion // ControlPaint