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
27 // Alexander Olk, alex.olk@googlemail.com
32 using System.Drawing.Drawing2D;
33 using System.Drawing.Imaging;
34 using System.Drawing.Text;
36 namespace System.Windows.Forms
39 internal class ThemeWin32Classic : Theme
41 public override Version Version {
43 return new Version(0, 1, 0, 0);
47 /* Hardcoded colour values not exposed in the API constants in all configurations */
48 protected static readonly Color arrow_color = Color.Black;
49 protected static readonly Color pen_ticks_color = Color.Black;
50 protected static readonly Color progressbarblock_color = Color.FromArgb (255, 0, 0, 128);
51 protected static StringFormat string_format_menu_text;
52 protected static StringFormat string_format_menu_shortcut;
53 protected static StringFormat string_format_menu_menubar_text;
54 static readonly Rectangle checkbox_rect = new Rectangle (2, 2, 11,11); // Position of the checkbox relative to the item
55 static ImageAttributes imagedisabled_attributes = null;
56 const int SEPARATOR_HEIGHT = 5;
57 const int SM_CXBORDER = 1;
58 const int SM_CYBORDER = 1;
59 const int MENU_TAB_SPACE = 8; // Pixels added to the width of an item because of a tab
60 const int MENU_BAR_ITEMS_SPACE = 8; // Space between menu bar items
62 #region Principal Theme Methods
63 public ThemeWin32Classic ()
65 defaultWindowBackColor = this.ColorWindow;
66 defaultWindowForeColor = this.ColorControlText;
67 default_font = new Font (FontFamily.GenericSansSerif, 8.25f);
69 /* Menu string formats */
70 string_format_menu_text = new StringFormat ();
71 string_format_menu_text.LineAlignment = StringAlignment.Center;
72 string_format_menu_text.Alignment = StringAlignment.Near;
73 string_format_menu_text.HotkeyPrefix = HotkeyPrefix.Show;
75 string_format_menu_shortcut = new StringFormat ();
76 string_format_menu_shortcut.LineAlignment = StringAlignment.Center;
77 string_format_menu_shortcut.Alignment = StringAlignment.Far;
79 string_format_menu_menubar_text = new StringFormat ();
80 string_format_menu_menubar_text.LineAlignment = StringAlignment.Center;
81 string_format_menu_menubar_text.Alignment = StringAlignment.Center;
82 string_format_menu_menubar_text.HotkeyPrefix = HotkeyPrefix.Show;
83 always_draw_hotkeys = false;
86 public override void ResetDefaults() {
87 throw new NotImplementedException("Need to implement ResetDefaults() for Win32 theme");
90 public override bool DoubleBufferingSupported {
94 public override int HorizontalScrollBarHeight {
96 return XplatUI.HorizontalScrollBarHeight;
100 public override int VerticalScrollBarWidth {
102 return XplatUI.VerticalScrollBarWidth;
106 #endregion // Principal Theme Methods
108 #region Internal Methods
109 protected Brush GetControlBackBrush (Color c) {
110 if (c == DefaultControlBackColor)
111 return SystemBrushes.Control;
112 return ResPool.GetSolidBrush (c);
115 protected Brush GetControlForeBrush (Color c) {
116 if (c == DefaultControlForeColor)
117 return SystemBrushes.ControlText;
118 return ResPool.GetSolidBrush (c);
120 #endregion // Internal Methods
122 #region OwnerDraw Support
123 public override void DrawOwnerDrawBackground (DrawItemEventArgs e)
125 if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
126 e.Graphics.FillRectangle (SystemBrushes.Highlight, e.Bounds);
130 e.Graphics.FillRectangle (ResPool.GetSolidBrush(e.BackColor), e.Bounds);
133 public override void DrawOwnerDrawFocusRectangle (DrawItemEventArgs e)
135 if (e.State == DrawItemState.Focus)
136 CPDrawFocusRectangle (e.Graphics, e.Bounds, e.ForeColor, e.BackColor);
138 #endregion // OwnerDraw Support
141 public override void DrawButtonBase(Graphics dc, Rectangle clip_area, ButtonBase button) {
142 // Draw the button: fill rectangle, draw border, etc.
143 ButtonBase_DrawButton(button, dc);
145 // First, draw the image
146 if ((button.image != null) || (button.image_list != null))
147 ButtonBase_DrawImage(button, dc);
149 // Draw the focus rectangle
150 if ((button.has_focus || button.paint_as_acceptbutton) && button.is_enabled)
151 ButtonBase_DrawFocus(button, dc);
154 if (button.text != null && button.text != String.Empty)
155 ButtonBase_DrawText(button, dc);
158 protected virtual void ButtonBase_DrawButton (ButtonBase button, Graphics dc)
160 Rectangle borderRectangle;
161 bool check_or_radio = false;
162 bool check_or_radio_checked = false;
164 bool is_ColorControl = button.BackColor == ColorControl ? true : false;
166 CPColor cpcolor = is_ColorControl ? CPColor.Empty : ResPool.GetCPColor (button.BackColor);
168 dc.FillRectangle (is_ColorControl ? SystemBrushes.Control : ResPool.GetSolidBrush (button.BackColor), button.ClientRectangle);
170 if (button is CheckBox) {
171 check_or_radio = true;
172 check_or_radio_checked = ((CheckBox)button).Checked;
173 } else if (button is RadioButton) {
174 check_or_radio = true;
175 check_or_radio_checked = ((RadioButton)button).Checked;
178 if ((button.has_focus || button.paint_as_acceptbutton) && button.is_enabled && !check_or_radio) {
179 // shrink the rectangle for the normal button drawing inside the focus rectangle
180 borderRectangle = Rectangle.Inflate (button.ClientRectangle, -1, -1);
182 borderRectangle = button.ClientRectangle;
185 if (button.FlatStyle == FlatStyle.Popup) {
186 if (!button.is_pressed && !button.is_entered && !check_or_radio_checked)
187 Internal_DrawButton (dc, borderRectangle, 1, cpcolor, is_ColorControl);
188 else if (!button.is_pressed && button.is_entered &&!check_or_radio_checked)
189 Internal_DrawButton (dc, borderRectangle, 2, cpcolor, is_ColorControl);
190 else if (button.is_pressed || check_or_radio_checked)
191 Internal_DrawButton (dc, borderRectangle, 1, cpcolor, is_ColorControl);
192 } else if (button.FlatStyle == FlatStyle.Flat) {
193 if (button.is_entered && !button.is_pressed && !check_or_radio_checked) {
194 Brush brush = is_ColorControl ? SystemBrushes.ControlDark : ResPool.GetSolidBrush (cpcolor.Dark);
195 dc.FillRectangle (brush, borderRectangle);
196 } else if (button.is_pressed || check_or_radio_checked) {
197 Brush brush = is_ColorControl ? SystemBrushes.ControlLightLight : ResPool.GetSolidBrush (cpcolor.LightLight);
198 dc.FillRectangle (brush, borderRectangle);
200 Pen pen = is_ColorControl ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
201 dc.DrawRectangle (pen, borderRectangle.X + 4, borderRectangle.Y + 4,
202 borderRectangle.Width - 9, borderRectangle.Height - 9);
205 Internal_DrawButton (dc, borderRectangle, 3, cpcolor, is_ColorControl);
207 if ((!button.is_pressed || !button.is_enabled) && !check_or_radio_checked)
208 Internal_DrawButton (dc, borderRectangle, 0, cpcolor, is_ColorControl);
210 Internal_DrawButton (dc, borderRectangle, 1, cpcolor, is_ColorControl);
214 private void Internal_DrawButton (Graphics dc, Rectangle rect, int state, CPColor cpcolor, bool is_ColorControl)
217 case 0: // normal or normal disabled button
218 Pen pen = is_ColorControl ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
219 dc.DrawLine (pen, rect.X, rect.Y, rect.X, rect.Bottom - 2);
220 dc.DrawLine (pen, rect.X + 1, rect.Y, rect.Right - 2, rect.Y);
222 pen = is_ColorControl ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
223 dc.DrawLine (pen, rect.X + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2);
224 dc.DrawLine (pen, rect.Right - 2, rect.Y + 1, rect.Right - 2, rect.Bottom - 3);
226 pen = is_ColorControl ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
227 dc.DrawLine (pen, rect.X, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
228 dc.DrawLine (pen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 2);
230 case 1: // popup button normal (or pressed normal or popup button)
231 pen = is_ColorControl ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
232 dc.DrawRectangle (pen, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
234 case 2: // popup button poped up
235 pen = is_ColorControl ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
236 dc.DrawLine (pen, rect.X, rect.Y, rect.X, rect.Bottom - 2);
237 dc.DrawLine (pen, rect.X + 1, rect.Y, rect.Right - 2, rect.Y);
239 pen = is_ColorControl ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
240 dc.DrawLine (pen, rect.X, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
241 dc.DrawLine (pen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 2);
243 case 3: // flat button not entered
244 pen = is_ColorControl ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
245 dc.DrawRectangle (pen, rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
252 protected virtual void ButtonBase_DrawImage(ButtonBase button, Graphics dc)
254 // Need to draw a picture
261 int width = button.ClientSize.Width;
262 int height = button.ClientSize.Height;
264 if (button.ImageIndex != -1) { // We use ImageIndex instead of image_index since it will return -1 if image_list is null
265 i = button.image_list.Images[button.image_index];
270 image_width = button.image.Width;
271 image_height = button.image.Height;
273 switch (button.image_alignment) {
274 case ContentAlignment.TopLeft: {
280 case ContentAlignment.TopCenter: {
281 image_x=(width-image_width)/2;
286 case ContentAlignment.TopRight: {
287 image_x=width-image_width;
292 case ContentAlignment.MiddleLeft: {
294 image_y=(height-image_height)/2;
298 case ContentAlignment.MiddleCenter: {
299 image_x=(width-image_width)/2;
300 image_y=(height-image_height)/2;
304 case ContentAlignment.MiddleRight: {
305 image_x=width-image_width;
306 image_y=(height-image_height)/2;
310 case ContentAlignment.BottomLeft: {
312 image_y=height-image_height;
316 case ContentAlignment.BottomCenter: {
317 image_x=(width-image_width)/2;
318 image_y=height-image_height;
322 case ContentAlignment.BottomRight: {
323 image_x=width-image_width;
324 image_y=height-image_height;
335 if (button.is_pressed) {
340 if (button.is_enabled) {
341 dc.DrawImage(i, image_x, image_y);
344 CPDrawImageDisabled(dc, i, image_x, image_y, ColorControl);
348 protected virtual void ButtonBase_DrawFocus(ButtonBase button, Graphics dc)
350 Color focus_color = button.ForeColor;
352 if (button.FlatStyle == FlatStyle.Popup)
353 if (!button.is_pressed)
354 focus_color = ControlPaint.Dark(button.BackColor);
356 dc.DrawRectangle (ResPool.GetPen (focus_color), button.ClientRectangle.X, button.ClientRectangle.Y,
357 button.ClientRectangle.Width - 1, button.ClientRectangle.Height - 1);
360 protected virtual void ButtonBase_DrawText(ButtonBase button, Graphics dc)
362 Rectangle buttonRectangle = button.ClientRectangle;
363 Rectangle text_rect = Rectangle.Inflate(buttonRectangle, -4, -4);
365 if (button.is_pressed) {
370 if (button.is_enabled) {
371 dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (button.ForeColor), text_rect, button.text_format);
373 if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
374 dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ColorGrayText), text_rect, button.text_format);
376 CPDrawStringDisabled (dc, button.text, button.Font, button.BackColor, text_rect, button.text_format);
381 public override Size ButtonBaseDefaultSize {
383 return new Size (75, 23);
386 #endregion // ButtonBase
389 public override void DrawCheckBox(Graphics dc, Rectangle clip_area, CheckBox checkbox) {
390 StringFormat text_format;
391 Rectangle client_rectangle;
392 Rectangle text_rectangle;
393 Rectangle checkbox_rectangle;
394 int checkmark_size=13;
395 int checkmark_space = 4;
397 client_rectangle = checkbox.ClientRectangle;
398 text_rectangle = client_rectangle;
399 checkbox_rectangle = new Rectangle(text_rectangle.X, text_rectangle.Y, checkmark_size, checkmark_size);
401 text_format = new StringFormat();
402 text_format.Alignment=StringAlignment.Near;
403 text_format.LineAlignment=StringAlignment.Center;
404 text_format.HotkeyPrefix = HotkeyPrefix.Show;
406 /* Calculate the position of text and checkbox rectangle */
407 if (checkbox.appearance!=Appearance.Button) {
408 switch(checkbox.check_alignment) {
409 case ContentAlignment.BottomCenter: {
410 checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
411 checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
412 text_rectangle.X=client_rectangle.X;
413 text_rectangle.Width=client_rectangle.Width;
414 text_rectangle.Height=client_rectangle.Height-checkbox_rectangle.Y-checkmark_space;
418 case ContentAlignment.BottomLeft: {
419 checkbox_rectangle.X=client_rectangle.Left;
420 checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
421 text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
422 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
426 case ContentAlignment.BottomRight: {
427 checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
428 checkbox_rectangle.Y=client_rectangle.Bottom-checkmark_size;
429 text_rectangle.X=client_rectangle.X;
430 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
434 case ContentAlignment.MiddleCenter: {
435 checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
436 checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
437 text_rectangle.X=client_rectangle.X;
438 text_rectangle.Width=client_rectangle.Width;
443 case ContentAlignment.MiddleLeft: {
444 checkbox_rectangle.X=client_rectangle.Left;
445 checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
446 text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
447 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
451 case ContentAlignment.MiddleRight: {
452 checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
453 checkbox_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-checkmark_size/2;
454 text_rectangle.X=client_rectangle.X;
455 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
459 case ContentAlignment.TopCenter: {
460 checkbox_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-checkmark_size/2;
461 checkbox_rectangle.Y=client_rectangle.Top;
462 text_rectangle.X=client_rectangle.X;
463 text_rectangle.Width=client_rectangle.Width;
464 text_rectangle.Y=checkmark_size+checkmark_space;
465 text_rectangle.Height=client_rectangle.Height-checkmark_size-checkmark_space;
469 case ContentAlignment.TopLeft: {
470 checkbox_rectangle.X=client_rectangle.Left;
471 text_rectangle.X=client_rectangle.X+checkmark_size+checkmark_space;
472 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
476 case ContentAlignment.TopRight: {
477 checkbox_rectangle.X=client_rectangle.Right-checkmark_size;
478 text_rectangle.X=client_rectangle.X;
479 text_rectangle.Width=client_rectangle.Width-checkmark_size-checkmark_space;
484 text_rectangle.X=client_rectangle.X;
485 text_rectangle.Width=client_rectangle.Width;
488 /* Set the horizontal alignment of our text */
489 switch(checkbox.text_alignment) {
490 case ContentAlignment.BottomLeft:
491 case ContentAlignment.MiddleLeft:
492 case ContentAlignment.TopLeft: {
493 text_format.Alignment=StringAlignment.Near;
497 case ContentAlignment.BottomCenter:
498 case ContentAlignment.MiddleCenter:
499 case ContentAlignment.TopCenter: {
500 text_format.Alignment=StringAlignment.Center;
504 case ContentAlignment.BottomRight:
505 case ContentAlignment.MiddleRight:
506 case ContentAlignment.TopRight: {
507 text_format.Alignment=StringAlignment.Far;
512 /* Set the vertical alignment of our text */
513 switch(checkbox.text_alignment) {
514 case ContentAlignment.TopLeft:
515 case ContentAlignment.TopCenter:
516 case ContentAlignment.TopRight: {
517 text_format.LineAlignment=StringAlignment.Near;
521 case ContentAlignment.BottomLeft:
522 case ContentAlignment.BottomCenter:
523 case ContentAlignment.BottomRight: {
524 text_format.LineAlignment=StringAlignment.Far;
528 case ContentAlignment.MiddleLeft:
529 case ContentAlignment.MiddleCenter:
530 case ContentAlignment.MiddleRight: {
531 text_format.LineAlignment=StringAlignment.Center;
536 ButtonState state = ButtonState.Normal;
537 if (checkbox.FlatStyle == FlatStyle.Flat) {
538 state |= ButtonState.Flat;
541 if (checkbox.Checked) {
542 state |= ButtonState.Checked;
545 if (checkbox.ThreeState && (checkbox.CheckState == CheckState.Indeterminate)) {
546 state |= ButtonState.Checked;
547 state |= ButtonState.Pushed;
550 // finally make sure the pushed and inavtive states are rendered
551 if (!checkbox.Enabled) {
552 state |= ButtonState.Inactive;
554 else if (checkbox.is_pressed) {
555 state |= ButtonState.Pushed;
560 CheckBox_DrawCheckBox(dc, checkbox, state, checkbox_rectangle);
562 if ((checkbox.image != null) || (checkbox.image_list != null))
563 ButtonBase_DrawImage(checkbox, dc);
565 CheckBox_DrawText(checkbox, text_rectangle, dc, text_format);
567 CheckBox_DrawFocus(checkbox, dc, text_rectangle);
569 text_format.Dispose ();
572 protected virtual void CheckBox_DrawCheckBox( Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle )
574 Brush brush = checkbox.BackColor == ColorControl ? SystemBrushes.Control : ResPool.GetSolidBrush (checkbox.BackColor);
575 dc.FillRectangle (brush, checkbox.ClientRectangle);
576 // render as per normal button
577 if (checkbox.appearance==Appearance.Button) {
578 ButtonBase_DrawButton (checkbox, dc);
580 // establish if we are rendering a flat style of some sort
581 if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
582 DrawFlatStyleCheckBox (dc, checkbox_rectangle, checkbox);
584 CPDrawCheckBox (dc, checkbox_rectangle, state);
589 protected virtual void CheckBox_DrawText( CheckBox checkbox, Rectangle text_rectangle, Graphics dc, StringFormat text_format )
591 DrawCheckBox_and_RadioButtonText (checkbox, text_rectangle, dc,
592 text_format, checkbox.Appearance, checkbox.Checked);
595 protected virtual void CheckBox_DrawFocus( CheckBox checkbox, Graphics dc, Rectangle text_rectangle )
597 // do nothing here. maybe an other theme needs it
600 // renders a checkBox with the Flat and Popup FlatStyle
601 protected virtual void DrawFlatStyleCheckBox (Graphics graphics, Rectangle rectangle, CheckBox checkbox)
605 Rectangle checkbox_rectangle;
606 Rectangle fill_rectangle;
610 // set up our rectangles first
611 if (checkbox.FlatStyle == FlatStyle.Popup && checkbox.is_entered) {
612 // clip one pixel from bottom right for non popup rendered checkboxes
613 checkbox_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max(rectangle.Width-1, 0), Math.Max(rectangle.Height-1,0));
614 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));
616 // clip two pixels from bottom right for non popup rendered checkboxes
617 checkbox_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max(rectangle.Width-2, 0), Math.Max(rectangle.Height-2,0));
618 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));
622 // if disabled render in disabled state
623 if (checkbox.Enabled) {
624 // process the state of the checkbox
625 if (checkbox.is_entered || checkbox.Capture) {
626 // decide on which background color to use
627 if (checkbox.FlatStyle == FlatStyle.Popup && checkbox.is_entered && checkbox.Capture) {
628 graphics.FillRectangle(ResPool.GetSolidBrush (checkbox.BackColor), fill_rectangle);
629 } else if (checkbox.FlatStyle == FlatStyle.Flat) {
630 if (!checkbox.is_pressed) {
631 graphics.FillRectangle(ResPool.GetSolidBrush (checkbox.BackColor), fill_rectangle);
633 graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);
635 // use regular window background color
636 graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);
639 // render the outer border
640 if (checkbox.FlatStyle == FlatStyle.Flat) {
641 ControlPaint.DrawBorder(graphics, checkbox_rectangle, checkbox.ForeColor, ButtonBorderStyle.Solid);
643 // draw sunken effect
644 CPDrawBorder3D (graphics, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, checkbox.BackColor);
647 graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);
649 if (checkbox.FlatStyle == FlatStyle.Flat) {
650 ControlPaint.DrawBorder(graphics, checkbox_rectangle, checkbox.ForeColor, ButtonBorderStyle.Solid);
652 // draw the outer border
653 ControlPaint.DrawBorder(graphics, checkbox_rectangle, ControlPaint.DarkDark (checkbox.BackColor), ButtonBorderStyle.Solid);
657 if (checkbox.FlatStyle == FlatStyle.Popup) {
658 graphics.FillRectangle(SystemBrushes.Control, fill_rectangle);
661 // draw disabled state,
662 ControlPaint.DrawBorder(graphics, checkbox_rectangle, ColorControlDark, ButtonBorderStyle.Solid);
665 if (checkbox.Checked) {
666 /* Need to draw a check-mark */
668 /* Make sure we've got at least a line width of 1 */
669 lineWidth = Math.Max(3, fill_rectangle.Width/3);
670 Scale=Math.Max(1, fill_rectangle.Width/9);
672 // flat style check box is rendered inside a rectangle shifted down by one
673 rect=new Rectangle(fill_rectangle.X, fill_rectangle.Y+1, fill_rectangle.Width, fill_rectangle.Height);
674 if (checkbox.Enabled) {
675 pen=ResPool.GetPen(checkbox.ForeColor);
677 pen=SystemPens.ControlDark;
680 for (int i=0; i<lineWidth; i++) {
681 graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
682 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);
687 private void DrawCheckBox_and_RadioButtonText (ButtonBase button_base, Rectangle text_rectangle, Graphics dc,
688 StringFormat text_format, Appearance appearance, bool ischecked)
690 // offset the text if it's pressed and a button
691 if (appearance == Appearance.Button) {
692 if (ischecked || (button_base.Capture && button_base.FlatStyle != FlatStyle.Flat)) {
697 text_rectangle.Inflate (-4, -4);
700 /* Place the text; to be compatible with Windows place it after the checkbox has been drawn */
702 // Windows seems to not wrap text in certain situations, this matches as close as I could get it
703 if ((float)(button_base.Font.Height * 1.5f) > text_rectangle.Height) {
704 text_format.FormatFlags |= StringFormatFlags.NoWrap;
706 if (button_base.Enabled) {
707 dc.DrawString (button_base.Text, button_base.Font, ResPool.GetSolidBrush (button_base.ForeColor), text_rectangle, text_format);
708 } else if (button_base.FlatStyle == FlatStyle.Flat || button_base.FlatStyle == FlatStyle.Popup) {
709 dc.DrawString (button_base.Text, button_base.Font, SystemBrushes.ControlDarkDark, text_rectangle, text_format);
711 CPDrawStringDisabled (dc, button_base.Text, button_base.Font, button_base.BackColor, text_rectangle, text_format);
714 #endregion // CheckBox
716 #region CheckedListBox
718 public override Rectangle CheckedListBoxCheckRectangle ()
720 return checkbox_rect;
723 public override void DrawCheckedListBoxItem (CheckedListBox ctrl, DrawItemEventArgs e)
725 Color back_color, fore_color;
726 Rectangle item_rect = e.Bounds;
728 StringFormat string_format = ctrl.GetFormatString ();
732 if ((ctrl.Items.GetListBoxItem (e.Index)).State == CheckState.Checked)
733 state = ButtonState.Checked;
735 state = ButtonState.Normal;
737 if (ctrl.ThreeDCheckBoxes == false)
738 state |= ButtonState.Flat;
740 ControlPaint.DrawCheckBox (e.Graphics,
741 item_rect.X + checkbox_rect.X, item_rect.Y + checkbox_rect.Y,
742 checkbox_rect.Width, checkbox_rect.Height,
745 item_rect.X += checkbox_rect.Width + checkbox_rect.X * 2;
746 item_rect.Width -= checkbox_rect.Width + checkbox_rect.X * 2;
749 if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
750 back_color = ColorHighlight;
751 fore_color = ColorHighlightText;
754 back_color = e.BackColor;
755 fore_color = e.ForeColor;
758 e.Graphics.FillRectangle (ResPool.GetSolidBrush
759 (back_color), item_rect);
761 e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
762 ResPool.GetSolidBrush (fore_color),
763 item_rect, string_format);
765 if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
766 CPDrawFocusRectangle (e.Graphics, item_rect,
767 fore_color, back_color);
771 #endregion // CheckedListBox
774 public override void DrawComboBoxItem (ComboBox ctrl, DrawItemEventArgs e)
776 Color back_color, fore_color;
777 Rectangle text_draw = e.Bounds;
778 StringFormat string_format = new StringFormat ();
779 string_format.FormatFlags = StringFormatFlags.LineLimit;
781 if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
782 back_color = ColorHighlight;
783 fore_color = ColorHighlightText;
786 back_color = e.BackColor;
787 fore_color = e.ForeColor;
790 e.Graphics.FillRectangle (ResPool.GetSolidBrush (back_color), e.Bounds);
793 e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
794 ResPool.GetSolidBrush (fore_color),
795 text_draw, string_format);
798 if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
799 CPDrawFocusRectangle (e.Graphics, e.Bounds, fore_color, back_color);
802 string_format.Dispose ();
807 public override int DataGridPreferredColumnWidth { get { return 75;} }
808 public override int DataGridMinimumColumnCheckBoxHeight { get { return 16;} }
809 public override int DataGridMinimumColumnCheckBoxWidth { get { return 16;} }
810 public override Color DataGridAlternatingBackColor { get { return ColorWindow;} }
811 public override Color DataGridBackColor { get { return ColorWindow;} }
812 public override Color DataGridBackgroundColor { get { return ColorAppWorkspace;} }
813 public override Color DataGridCaptionBackColor { get { return ColorActiveCaption;} }
814 public override Color DataGridCaptionForeColor { get { return ColorActiveCaptionText;} }
815 public override Color DataGridGridLineColor { get { return ColorControl;} }
816 public override Color DataGridHeaderBackColor { get { return ColorControl;} }
817 public override Color DataGridHeaderForeColor { get { return ColorControlText;} }
818 public override Color DataGridLinkColor { get { return ColorHotTrack;} }
819 public override Color DataGridLinkHoverColor { get { return ColorHotTrack;} }
820 public override Color DataGridParentRowsBackColor { get { return ColorControl;} }
821 public override Color DataGridParentRowsForeColor { get { return ColorWindowText;} }
822 public override Color DataGridSelectionBackColor { get { return ColorActiveCaption;} }
823 public override Color DataGridSelectionForeColor { get { return ColorActiveCaptionText;} }
825 public override void DataGridPaint (PaintEventArgs pe, DataGrid grid)
828 if (pe.ClipRectangle.IntersectsWith (grid.grid_drawing.parent_rows)) {
829 pe.Graphics.FillRectangle (ResPool.GetSolidBrush (grid.ParentRowsBackColor), grid.grid_drawing.parent_rows);
832 DataGridPaintCaption (pe.Graphics, pe.ClipRectangle, grid);
833 DataGridPaintColumnsHdrs (pe.Graphics, pe.ClipRectangle, grid);
834 DataGridPaintRowsHeaders (pe.Graphics, pe.ClipRectangle, grid);
835 DataGridPaintRows (pe.Graphics, grid.grid_drawing.cells_area, pe.ClipRectangle, grid);
837 // Paint scrollBar corner
838 if (grid.vert_scrollbar.Visible && grid.horiz_scrollbar.Visible) {
840 Rectangle corner = new Rectangle (grid.ClientRectangle.X + grid.ClientRectangle.Width - grid.horiz_scrollbar.Height,
841 grid.ClientRectangle.Y + grid.ClientRectangle.Height - grid.horiz_scrollbar.Height,
842 grid.horiz_scrollbar.Height, grid.horiz_scrollbar.Height);
844 if (pe.ClipRectangle.IntersectsWith (corner)) {
845 pe.Graphics.FillRectangle (ResPool.GetSolidBrush (grid.ParentRowsBackColor),
851 public override void DataGridPaintCaption (Graphics g, Rectangle clip, DataGrid grid)
853 Rectangle modified_area = clip;
854 modified_area.Intersect (grid.grid_drawing.caption_area);
856 g.FillRectangle (ResPool.GetSolidBrush (grid.CaptionBackColor),
859 g.DrawString (grid.CaptionText, grid.CaptionFont,
860 ResPool.GetSolidBrush (grid.CaptionForeColor),
861 grid.grid_drawing.caption_area);
864 public override void DataGridPaintColumnsHdrs (Graphics g, Rectangle clip, DataGrid grid)
866 Rectangle columns_area = grid.grid_drawing.columnshdrs_area;
868 if (grid.CurrentTableStyle.CurrentRowHeadersVisible) { // Paint corner shared between row and column header
869 Rectangle rect_bloc = grid.grid_drawing.columnshdrs_area;
870 rect_bloc.Width = grid.RowHeaderWidth;
871 rect_bloc.Height = grid.grid_drawing.columnshdrs_area.Height;
872 if (clip.IntersectsWith (rect_bloc)) {
873 if (grid.visiblecolumn_count > 0) {
874 g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor), rect_bloc);
876 g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), rect_bloc);
880 columns_area.X += grid.RowHeaderWidth;
881 columns_area.Width -= grid.RowHeaderWidth;
885 Rectangle columnshdrs_area_complete = columns_area;
886 columnshdrs_area_complete.Width = grid.grid_drawing.columnshdrs_maxwidth;
888 if (grid.CurrentTableStyle.CurrentRowHeadersVisible) {
889 columnshdrs_area_complete.Width -= grid.RowHeaderWidth;
892 // Set column painting
893 Rectangle rect_columnhdr = new Rectangle ();
896 rect_columnhdr.Y = columns_area.Y;
897 rect_columnhdr.Height = columns_area.Height;
899 current_clip = new Region (columns_area);
900 g.Clip = current_clip;
901 int column_cnt = grid.first_visiblecolumn + grid.visiblecolumn_count;
902 for (int column = grid.first_visiblecolumn; column < column_cnt; column++) {
904 col_pixel = grid.grid_drawing.GetColumnStartingPixel (column);
905 rect_columnhdr.X = columns_area.X + col_pixel - grid.horz_pixeloffset;
906 rect_columnhdr.Width = grid.CurrentTableStyle.GridColumnStyles[column].Width;
908 if (clip.IntersectsWith (rect_columnhdr) == false)
911 grid.CurrentTableStyle.GridColumnStyles[column].PaintHeader (g, rect_columnhdr, column);
916 current_clip.Dispose ();
919 Rectangle not_usedarea = columnshdrs_area_complete;
920 not_usedarea.X = rect_columnhdr.X + rect_columnhdr.Width;
921 not_usedarea.Width = grid.ClientRectangle.X + grid.ClientRectangle.Width - rect_columnhdr.X - rect_columnhdr.Height;
922 g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
926 public override void DataGridPaintRowsHeaders (Graphics g, Rectangle clip, DataGrid grid)
928 Rectangle rowshdrs_area_complete = grid.grid_drawing.rowshdrs_area;
929 rowshdrs_area_complete.Height = grid.grid_drawing.rowshdrs_maxheight;
930 Rectangle rect_row = new Rectangle ();
931 rect_row.X = grid.grid_drawing.rowshdrs_area.X;
932 int rowcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
933 Rectangle not_usedarea = rowshdrs_area_complete;
935 if (rowcnt < grid.RowsCount) { // Paint one row more for partial rows
939 g.SetClip (grid.grid_drawing.rowshdrs_area);
940 for (int row = grid.FirstVisibleRow; row < rowcnt; row++) {
942 rect_row.Width = grid.grid_drawing.rowshdrs_area.Width;
943 rect_row.Height = grid.RowHeight;
944 rect_row.Y = grid.grid_drawing.rowshdrs_area.Y + ((row - grid.FirstVisibleRow) * grid.RowHeight);
946 if (clip.IntersectsWith (rect_row)) {
947 DataGridPaintRowHeader (g, rect_row, row, grid);
952 not_usedarea.Height = grid.grid_drawing.rowshdrs_maxheight - grid.grid_drawing.rowshdrs_area.Height;
953 not_usedarea.Y = grid.grid_drawing.rowshdrs_area.Y + grid.grid_drawing.rowshdrs_area.Height;
954 g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
957 public override void DataGridPaintRowHeaderArrow (Graphics g, Rectangle bounds, DataGrid grid)
959 Point[] arrow = new Point[3];
961 int centerX, centerY, shiftX;
964 rect = new Rectangle (bounds.X + bounds.Width /4,
965 bounds.Y + bounds.Height/4, bounds.Width / 2, bounds.Height / 2);
967 centerX = rect.Left + rect.Width / 2;
968 centerY = rect.Top + rect.Height / 2;
969 shiftX = Math.Max (1, rect.Width / 8);
972 P1 = new Point (centerX, rect.Top - 1);
973 P2 = new Point (centerX, rect.Bottom);
974 P3 = new Point (rect.Right, centerY);
979 g.FillPolygon (ResPool.GetSolidBrush
980 (grid.CurrentTableStyle.CurrentHeaderForeColor), arrow, FillMode.Winding);
983 public override void DataGridPaintRowHeader (Graphics g, Rectangle bounds, int row, DataGrid grid)
986 g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor),
989 if (grid.FlatMode == false) {
992 g.DrawLine (ResPool.GetPen (ColorControlLight),
993 bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
995 g.DrawLine (ResPool.GetPen (ColorControlLight),
996 bounds.X, bounds.Y + 1, bounds.X, bounds.Y + bounds.Height - 1);
998 g.DrawLine (ResPool.GetPen (ColorControlDark),
999 bounds.X + bounds.Width - 1, bounds.Y + 1 , bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
1001 g.DrawLine (ResPool.GetPen (ColorControlDark),
1002 bounds.X, bounds.Y + bounds.Height -1, bounds.X + bounds.Width, bounds.Y + bounds.Height -1);
1005 if (grid.ShowEditRow && grid.RowsCount > 0 && row == grid.RowsCount && !(row == grid.CurrentCell.RowNumber && grid.is_changing == true)) {
1007 g.DrawString ("*", grid.grid_drawing.font_newrow, ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
1012 if (row == grid.CurrentCell.RowNumber) {
1014 if (grid.is_changing == true) {
1015 g.DrawString ("...", grid.Font,
1016 ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
1021 Rectangle rect = new Rectangle (bounds.X - 2, bounds.Y, 18, 18);
1022 DataGridPaintRowHeaderArrow (g, rect, grid);
1028 public override void DataGridPaintRows (Graphics g, Rectangle cells, Rectangle clip, DataGrid grid)
1030 Rectangle rect_row = new Rectangle ();
1031 Rectangle not_usedarea = new Rectangle ();
1032 rect_row.X = cells.X;
1034 int rowcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
1036 if (grid.ShowEditRow && grid.RowsCount > 0) {
1040 if (rowcnt < grid.RowsCount) { // Paint one row more for partial rows
1044 rect_row.Height = grid.RowHeight;
1045 rect_row.Width = cells.Width;
1046 for (int row = grid.FirstVisibleRow; row < rowcnt; row++) {
1047 rect_row.Y = cells.Y + ((row - grid.FirstVisibleRow) * grid.RowHeight);
1048 if (clip.IntersectsWith (rect_row)) {
1049 DataGridPaintRow (g, row, rect_row, false, grid);
1053 if (grid.ShowEditRow && grid.RowsCount > 0 && grid.FirstVisibleRow + grid.VisibleRowCount == grid.RowsCount + 1) {
1054 rect_row.Y = cells.Y + ((rowcnt - grid.FirstVisibleRow) * grid.RowHeight);
1055 if (clip.IntersectsWith (rect_row)) {
1056 DataGridPaintRow (g, rowcnt, rect_row, true, grid);
1060 not_usedarea.Height = cells.Y + cells.Height - rect_row.Y - rect_row.Height;
1061 not_usedarea.Y = rect_row.Y + rect_row.Height;
1062 not_usedarea.Width = rect_row.Width = cells.Width;
1063 not_usedarea.X = cells.X;
1065 g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
1068 public override void DataGridPaintRow (Graphics g, int row, Rectangle row_rect, bool is_newrow, DataGrid grid)
1070 Rectangle rect_cell = new Rectangle ();
1072 Color backcolor, forecolor;
1073 Region prev_clip = g.Clip;
1074 Region current_clip;
1075 Rectangle not_usedarea = new Rectangle ();
1077 rect_cell.Y = row_rect.Y;
1078 rect_cell.Height = row_rect.Height;
1080 // PaintCells at row, column
1081 int column_cnt = grid.first_visiblecolumn + grid.visiblecolumn_count;
1082 for (int column = grid.first_visiblecolumn; column < column_cnt; column++) {
1084 col_pixel = grid.grid_drawing.GetColumnStartingPixel (column);
1086 rect_cell.X = row_rect.X + col_pixel - grid.horz_pixeloffset;
1087 rect_cell.Width = grid.CurrentTableStyle.GridColumnStyles[column].Width;
1089 current_clip = new Region (row_rect);
1090 g.Clip = current_clip;
1092 if (grid.IsSelected (row)) {
1093 backcolor = grid.SelectionBackColor;
1094 forecolor = grid.SelectionForeColor;
1097 backcolor = grid.BackColor;
1099 backcolor = grid.AlternatingBackColor;
1102 forecolor = grid.ForeColor;
1106 grid.CurrentTableStyle.GridColumnStyles[column].PaintNewRow (g, rect_cell,
1107 ResPool.GetSolidBrush (backcolor),
1108 ResPool.GetSolidBrush (forecolor));
1111 grid.CurrentTableStyle.GridColumnStyles[column].Paint (g, rect_cell, grid.ListManager, row,
1112 ResPool.GetSolidBrush (backcolor),
1113 ResPool.GetSolidBrush (forecolor),
1114 grid.RightToLeft == RightToLeft.Yes);
1118 current_clip.Dispose ();
1121 if (row_rect.X + row_rect.Width > rect_cell.X + rect_cell.Width) {
1123 not_usedarea.X = rect_cell.X + rect_cell.Width;
1124 not_usedarea.Width = row_rect.X + row_rect.Width - rect_cell.X - rect_cell.Width;
1125 not_usedarea.Y = row_rect.Y;
1126 not_usedarea.Height = row_rect.Height;
1127 g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
1132 #endregion // Datagrid
1134 #region DateTimePicker
1136 public override void DrawDateTimePicker (Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp) {
1137 // if not showing the numeric updown control then render border
1138 if (!dtp.ShowUpDown && clip_rectangle.IntersectsWith (dtp.ClientRectangle)) {
1139 // draw the outer border
1140 Rectangle button_bounds = dtp.ClientRectangle;
1141 this.CPDrawBorder3D (dc, button_bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, dtp.BackColor);
1143 // deflate by the border width
1144 if (clip_rectangle.IntersectsWith (dtp.drop_down_arrow_rect)) {
1145 button_bounds.Inflate (-2,-2);
1146 ButtonState state = dtp.is_drop_down_visible ? ButtonState.Pushed : ButtonState.Normal;
1147 this.CPDrawComboButton (
1149 dtp.drop_down_arrow_rect,
1154 // render the date part
1155 if (clip_rectangle.IntersectsWith (dtp.date_area_rect)) {
1156 // fill the background
1157 dc.FillRectangle (SystemBrushes.Window, dtp.date_area_rect);
1159 // fill the currently highlighted area
1160 if (dtp.hilight_date_area != Rectangle.Empty) {
1161 dc.FillRectangle (SystemBrushes.Highlight, dtp.hilight_date_area);
1164 // draw the text part
1165 // TODO: if date format is CUstom then we need to draw the dates as separate parts
1166 StringFormat text_format = new StringFormat();
1167 text_format.LineAlignment = StringAlignment.Center;
1168 text_format.Alignment = StringAlignment.Near;
1169 dc.DrawString (dtp.Text, dtp.Font, ResPool.GetSolidBrush (dtp.ForeColor), Rectangle.Inflate(dtp.date_area_rect, -1, -1), text_format);
1170 text_format.Dispose ();
1174 #endregion // DateTimePicker
1177 public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box) {
1178 StringFormat text_format;
1183 dc.FillRectangle (GetControlBackBrush (box.BackColor), box.ClientRectangle);
1185 text_format = new StringFormat();
1186 text_format.HotkeyPrefix = HotkeyPrefix.Show;
1188 size = dc.MeasureString (box.Text, box.Font);
1189 width = ((int) size.Width) + 7;
1191 if (width > box.Width - 16)
1192 width = box.Width - 16;
1194 y = box.Font.Height / 2;
1197 CPDrawBorder3D (dc, new Rectangle (0, y, box.Width, box.Height - y), Border3DStyle.Etched, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, box.BackColor);
1200 if (box.Text.Length != 0) {
1201 Pen pen = ResPool.GetPen (box.BackColor);
1202 dc.DrawLine (pen, 9, y, 8 + width, y);
1203 dc.DrawLine (pen, 9, y + 1, 8 + width, y + 1);
1206 dc.DrawString (box.Text, box.Font, ResPool.GetSolidBrush (box.ForeColor), 10, 0, text_format);
1208 CPDrawStringDisabled (dc, box.Text, box.Font, box.BackColor,
1209 new RectangleF (10, 0, width, box.Font.Height), text_format);
1213 text_format.Dispose ();
1216 public override Size GroupBoxDefaultSize {
1218 return new Size (200,100);
1224 public override Size HScrollBarDefaultSize {
1226 return new Size (80, this.ScrollBarButtonSize);
1230 #endregion // HScrollBar
1233 public override void DrawLabel (Graphics dc, Rectangle clip_rectangle, Label label)
1235 dc.FillRectangle (GetControlBackBrush (label.BackColor), clip_rectangle);
1237 if (label.Enabled) {
1238 dc.DrawString (label.Text, label.Font, ResPool.GetSolidBrush (label.ForeColor), clip_rectangle, label.string_format);
1240 ControlPaint.DrawStringDisabled (dc, label.Text, label.Font, label.BackColor, clip_rectangle, label.string_format);
1245 public override Size LabelDefaultSize {
1247 return new Size (100, 23);
1253 public override void DrawLinkLabel (Graphics dc, Rectangle clip_rectangle, LinkLabel label)
1257 dc.FillRectangle (GetControlBackBrush (label.BackColor), clip_rectangle);
1259 for (int i = 0; i < label.num_pieces; i++) {
1261 if (clip_rectangle.IntersectsWith (label.pieces[i].rect) == false) {
1265 color = label.GetLinkColor (label.pieces[i], i);
1267 if (label.pieces[i].link == null)
1268 dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (Color.Black),
1269 label.pieces[i].rect.X, label.pieces[i].rect.Y);
1271 dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (color),
1272 label.pieces[i].rect.X, label.pieces[i].rect.Y);
1274 if (label.pieces[i].focused) {
1275 CPDrawFocusRectangle (dc, label.pieces[i].rect, label.ForeColor, label.BackColor);
1280 #endregion // LinkLabel
1284 public override void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e)
1286 Color back_color, fore_color;
1287 StringFormat string_format = ctrl.GetFormatString ();
1289 if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
1290 back_color = ColorHighlight;
1291 fore_color = ColorHighlightText;
1294 back_color = e.BackColor;
1295 fore_color = e.ForeColor;
1298 e.Graphics.FillRectangle (ResPool.GetSolidBrush
1299 (back_color), e.Bounds);
1301 e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
1302 ResPool.GetSolidBrush (fore_color),
1303 e.Bounds.X, e.Bounds.Y, string_format);
1305 if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
1306 CPDrawFocusRectangle (e.Graphics, e.Bounds,
1307 fore_color, back_color);
1315 public override void DrawListViewItems (Graphics dc, Rectangle clip, ListView control)
1317 bool details = control.View == View.Details;
1319 dc.FillRectangle (GetControlBackBrush (control.BackColor), clip);
1320 int first = control.FirstVisibleIndex;
1322 for (int i = first; i <= control.LastVisibleIndex; i ++) {
1323 if (clip.IntersectsWith (control.Items[i].GetBounds (ItemBoundsPortion.Entire)))
1324 DrawListViewItem (dc, control, control.Items [i]);
1327 // draw the gridlines
1328 if (details && control.GridLines) {
1329 int top = (control.HeaderStyle == ColumnHeaderStyle.None) ?
1330 2 : control.Font.Height + 2;
1332 // draw vertical gridlines
1333 foreach (ColumnHeader col in control.Columns)
1334 dc.DrawLine (SystemPens.Control,
1335 col.Rect.Right, top,
1336 col.Rect.Right, control.TotalHeight);
1337 // draw horizontal gridlines
1338 ListViewItem last_item = null;
1339 foreach (ListViewItem item in control.Items) {
1340 dc.DrawLine (SystemPens.Control,
1341 item.GetBounds (ItemBoundsPortion.Entire).Left, item.GetBounds (ItemBoundsPortion.Entire).Top,
1342 control.TotalWidth, item.GetBounds (ItemBoundsPortion.Entire).Top);
1346 // draw a line after at the bottom of the last item
1347 if (last_item != null) {
1348 dc.DrawLine (SystemPens.Control,
1349 last_item.GetBounds (ItemBoundsPortion.Entire).Left,
1350 last_item.GetBounds (ItemBoundsPortion.Entire).Bottom,
1352 last_item.GetBounds (ItemBoundsPortion.Entire).Bottom);
1356 // Draw corner between the two scrollbars
1357 if (control.h_scroll.Visible == true && control.h_scroll.Visible == true) {
1358 Rectangle rect = new Rectangle ();
1359 rect.X = control.h_scroll.Location.X + control.h_scroll.Width;
1360 rect.Width = control.v_scroll.Width;
1361 rect.Y = control.v_scroll.Location.Y + control.v_scroll.Height;
1362 rect.Height = control.h_scroll.Height;
1363 dc.FillRectangle (SystemBrushes.Control, rect);
1366 Rectangle box_select_rect = control.item_control.BoxSelectRectangle;
1367 if (!box_select_rect.Size.IsEmpty)
1368 dc.DrawRectangle (ResPool.GetDashPen (ColorControlText, DashStyle.Dot), box_select_rect);
1372 public override void DrawListViewHeader (Graphics dc, Rectangle clip, ListView control)
1374 bool details = (control.View == View.Details);
1376 // border is drawn directly in the Paint method
1377 if (details && control.HeaderStyle != ColumnHeaderStyle.None) {
1378 dc.FillRectangle (GetControlBackBrush (control.BackColor),
1379 0, 0, control.TotalWidth, control.Font.Height + 5);
1380 if (control.Columns.Count > 0) {
1381 foreach (ColumnHeader col in control.Columns) {
1382 Rectangle rect = col.Rect;
1383 rect.X -= control.h_marker;
1385 if (control.HeaderStyle == ColumnHeaderStyle.Clickable)
1386 state = col.Pressed ? ButtonState.Pushed : ButtonState.Normal;
1388 state = ButtonState.Flat;
1389 this.CPDrawButton (dc, rect, state);
1392 if (rect.Width <= 0)
1394 dc.DrawString (col.Text, DefaultFont,
1395 SystemBrushes.ControlText,
1402 public override void DrawListViewHeaderDragDetails (Graphics dc, ListView view, ColumnHeader col, int target_x)
1404 Rectangle rect = col.Rect;
1405 rect.X -= view.h_marker;
1406 Color color = Color.FromArgb (0x7f, ColorControlDark.R, ColorControlDark.G, ColorControlDark.B);
1407 dc.FillRectangle (ResPool.GetSolidBrush (color), rect);
1410 if (rect.Width <= 0)
1412 color = Color.FromArgb (0x7f, ColorControlText.R, ColorControlText.G, ColorControlText.B);
1413 dc.DrawString (col.Text, DefaultFont, ResPool.GetSolidBrush (color), rect, col.Format);
1414 dc.DrawLine (ResPool.GetSizedPen (ColorHighlight, 2), target_x, 0, target_x, col.Rect.Height);
1417 protected virtual void DrawListViewItem (Graphics dc, ListView control, ListViewItem item)
1420 if (control.View == View.Details && control.Columns.Count > 0)
1421 col_offset = control.Columns [0].Rect.X;
1425 Rectangle rect_checkrect = item.CheckRectReal;
1426 rect_checkrect.X += col_offset;
1427 Rectangle icon_rect = item.GetBounds (ItemBoundsPortion.Icon);
1428 icon_rect.X += col_offset;
1429 Rectangle full_rect = item.GetBounds (ItemBoundsPortion.Entire);
1430 full_rect.X += col_offset;
1431 Rectangle text_rect = item.GetBounds (ItemBoundsPortion.Label);
1432 text_rect.X += col_offset;
1434 if (control.CheckBoxes) {
1435 if (control.StateImageList == null) {
1436 // Make sure we've got at least a line width of 1
1437 int check_wd = Math.Max (3, rect_checkrect.Width / 6);
1438 int scale = Math.Max (1, rect_checkrect.Width / 12);
1440 // set the checkbox background
1441 dc.FillRectangle (SystemBrushes.Window,
1443 // define a rectangle inside the border area
1444 Rectangle rect = new Rectangle (rect_checkrect.X + 2,
1445 rect_checkrect.Y + 2,
1446 rect_checkrect.Width - 4,
1447 rect_checkrect.Height - 4);
1448 Pen pen = ResPool.GetSizedPen (this.ColorWindowText, 2);
1449 dc.DrawRectangle (pen, rect);
1451 // Need to draw a check-mark
1454 // adjustments to get the check-mark at the right place
1455 rect.X ++; rect.Y ++;
1456 // following logic is taken from DrawFrameControl method
1457 for (int i = 0; i < check_wd; i++) {
1458 dc.DrawLine (pen, rect.Left + check_wd / 2,
1459 rect.Top + check_wd + i,
1460 rect.Left + check_wd / 2 + 2 * scale,
1461 rect.Top + check_wd + 2 * scale + i);
1463 rect.Left + check_wd / 2 + 2 * scale,
1464 rect.Top + check_wd + 2 * scale + i,
1465 rect.Left + check_wd / 2 + 6 * scale,
1466 rect.Top + check_wd - 2 * scale + i);
1471 if (item.Checked && control.StateImageList.Images.Count > 1)
1472 control.StateImageList.Draw (dc,
1473 rect_checkrect.Location, 1);
1474 else if (! item.Checked && control.StateImageList.Images.Count > 0)
1475 control.StateImageList.Draw (dc,
1476 rect_checkrect.Location, 0);
1480 if (control.View == View.LargeIcon) {
1481 if (control.LargeImageList == null) {
1482 dc.DrawLine (ResPool.GetSizedPen (this.ColorWindowText, 2), icon_rect.Left, icon_rect.Y, icon_rect.Left + 11, icon_rect.Y);
1483 } else if (item.ImageIndex > -1 && item.ImageIndex < control.LargeImageList.Images.Count)
1484 control.LargeImageList.Draw (dc, icon_rect.Location, item.ImageIndex);
1486 if (item.ImageIndex > -1 && control.SmallImageList != null &&
1487 item.ImageIndex < control.SmallImageList.Images.Count)
1488 control.SmallImageList.Draw (dc, icon_rect.Location, item.ImageIndex);
1491 // draw the item text
1492 // format for the item text
1493 StringFormat format = new StringFormat ();
1494 if (control.View == View.SmallIcon)
1495 format.LineAlignment = StringAlignment.Near;
1497 format.LineAlignment = StringAlignment.Center;
1498 if (control.View == View.LargeIcon)
1499 format.Alignment = StringAlignment.Center;
1501 format.Alignment = StringAlignment.Near;
1503 if (!control.LabelWrap)
1504 format.FormatFlags = StringFormatFlags.NoWrap;
1506 if (item.Selected) {
1507 if (control.View == View.Details) {
1508 if (control.FullRowSelect) {
1509 dc.FillRectangle (SystemBrushes.Highlight, text_rect);
1512 Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
1514 text_rect.Width = text_size.Width;
1515 dc.FillRectangle (SystemBrushes.Highlight, text_rect);
1519 /*Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
1521 Point loc = text_rect.Location;
1522 loc.X += (text_rect.Width - text_size.Width) / 2;
1523 text_rect.Width = text_size.Width;*/
1524 dc.FillRectangle (SystemBrushes.Highlight, text_rect);
1528 dc.FillRectangle (ResPool.GetSolidBrush (item.BackColor), text_rect);
1530 if (item.Text != null && item.Text.Length > 0) {
1532 dc.DrawString (item.Text, item.Font, SystemBrushes.HighlightText, text_rect, format);
1534 dc.DrawString (item.Text, item.Font, this.ResPool.GetSolidBrush
1535 (item.ForeColor), text_rect, format);
1538 if (control.View == View.Details && control.Columns.Count > 0) {
1539 // draw subitems for details view
1540 ListViewItem.ListViewSubItemCollection subItems = item.SubItems;
1541 int count = (control.Columns.Count < subItems.Count ?
1542 control.Columns.Count : subItems.Count);
1546 ListViewItem.ListViewSubItem subItem;
1547 Rectangle sub_item_rect = text_rect;
1549 // set the format for subitems
1550 format.FormatFlags = StringFormatFlags.NoWrap;
1552 // 0th subitem is the item already drawn
1553 for (int index = 1; index < count; index++) {
1554 subItem = subItems [index];
1555 col = control.Columns [index];
1556 format.Alignment = col.Format.Alignment;
1557 sub_item_rect.X = col.Rect.X - control.h_marker;
1558 sub_item_rect.Width = col.Wd;
1559 Rectangle sub_item_text_rect = sub_item_rect;
1560 sub_item_text_rect.X += 3;
1561 sub_item_text_rect.Width -= 6;
1563 SolidBrush sub_item_back_br = null;
1564 SolidBrush sub_item_fore_br = null;
1565 Font sub_item_font = null;
1567 if (item.UseItemStyleForSubItems) {
1568 sub_item_back_br = ResPool.GetSolidBrush (item.BackColor);
1569 sub_item_fore_br = ResPool.GetSolidBrush (item.ForeColor);
1570 sub_item_font = item.Font;
1572 sub_item_back_br = ResPool.GetSolidBrush (subItem.BackColor);
1573 sub_item_fore_br = ResPool.GetSolidBrush (subItem.ForeColor);
1574 sub_item_font = subItem.Font;
1577 if (item.Selected && control.FullRowSelect) {
1578 dc.FillRectangle (SystemBrushes.Highlight, sub_item_rect);
1579 if (subItem.Text != null && subItem.Text.Length > 0)
1580 dc.DrawString (subItem.Text, sub_item_font,
1581 SystemBrushes.HighlightText,
1582 sub_item_text_rect, format);
1584 dc.FillRectangle (sub_item_back_br, sub_item_rect);
1585 if (subItem.Text != null && subItem.Text.Length > 0)
1586 dc.DrawString (subItem.Text, sub_item_font,
1588 sub_item_text_rect, format);
1595 Rectangle focus_rect = text_rect;
1596 if (control.FullRowSelect && control.View == View.Details) {
1598 foreach (ColumnHeader col in control.Columns)
1600 focus_rect = new Rectangle (0, full_rect.Y, width, full_rect.Height);
1603 CPDrawFocusRectangle (dc, focus_rect, ColorHighlightText, ColorHighlight);
1605 CPDrawFocusRectangle (dc, focus_rect, control.ForeColor, control.BackColor);
1612 public override Size ListViewCheckBoxSize {
1613 get { return new Size (16, 16); }
1616 public override int ListViewColumnHeaderHeight {
1620 public override int ListViewDefaultColumnWidth {
1624 public override int ListViewVerticalSpacing {
1628 public override int ListViewEmptyColumnWidth {
1632 public override int ListViewHorizontalSpacing {
1636 public override Size ListViewDefaultSize {
1637 get { return new Size (121, 97); }
1639 #endregion // ListView
1642 public override void CalcItemSize (Graphics dc, MenuItem item, int y, int x, bool menuBar)
1647 if (item.Visible == false) {
1653 if (item.Separator == true) {
1654 item.Height = SEPARATOR_HEIGHT / 2;
1659 if (item.MeasureEventDefined) {
1660 MeasureItemEventArgs mi = new MeasureItemEventArgs (dc, item.Index);
1661 item.PerformMeasureItem (mi);
1662 item.Height = mi.ItemHeight;
1663 item.Width = mi.ItemWidth;
1667 size = dc.MeasureString (item.Text, MenuFont);
1668 item.Width = (int) size.Width;
1669 item.Height = (int) size.Height;
1672 if (item.Shortcut != Shortcut.None && item.ShowShortcut) {
1673 item.XTab = MenuCheckSize.Width + MENU_TAB_SPACE + (int) size.Width;
1674 size = dc.MeasureString (" " + item.GetShortCutText (), MenuFont);
1675 item.Width += MENU_TAB_SPACE + (int) size.Width;
1678 item.Width += 4 + (MenuCheckSize.Width * 2);
1680 item.Width += MENU_BAR_ITEMS_SPACE;
1684 if (item.Height < MenuHeight)
1685 item.Height = MenuHeight;
1689 // Updates the menu rect and returns the height
1690 public override int CalcMenuBarSize (Graphics dc, Menu menu, int width)
1696 foreach (MenuItem item in menu.MenuItems) {
1698 CalcItemSize (dc, item, y, x, true);
1700 if (x + item.Width > width) {
1708 item.MenuBar = true;
1710 if (y + item.Height > menu.Height)
1711 menu.Height = item.Height + y;
1718 public override void CalcPopupMenuSize (Graphics dc, Menu menu)
1726 while (start < menu.MenuItems.Count) {
1729 for (i = start; i < menu.MenuItems.Count; i++) {
1730 MenuItem item = menu.MenuItems [i];
1732 if ((i != start) && (item.Break || item.BarBreak))
1735 CalcItemSize (dc, item, y, x, false);
1738 if (item.Width > max)
1742 // Replace the -1 by the menu width (separators)
1743 for (n = start; n < i; n++, start++)
1744 menu.MenuItems [n].Width = max;
1746 if (y > menu.Height)
1758 menu.Width += SM_CXBORDER;
1759 menu.Height += SM_CYBORDER;
1762 // Draws a menu bar in a window
1763 public override void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect)
1765 if (menu.Height == 0)
1766 CalcMenuBarSize (dc, menu, rect.Width);
1768 bool keynav = (menu as MainMenu).tracker.Navigating;
1769 HotkeyPrefix hp = always_draw_hotkeys || keynav ? HotkeyPrefix.Show : HotkeyPrefix.Hide;
1770 string_format_menu_menubar_text.HotkeyPrefix = hp;
1771 string_format_menu_text.HotkeyPrefix = hp;
1773 rect.Height = menu.Height;
1774 dc.FillRectangle (SystemBrushes.Menu, rect);
1776 for (int i = 0; i < menu.MenuItems.Count; i++) {
1777 MenuItem item = menu.MenuItems [i];
1778 Rectangle item_rect = item.bounds;
1779 item_rect.X += rect.X;
1780 item_rect.Y += rect.Y;
1781 item.MenuHeight = menu.Height;
1782 item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont, item_rect, i, item.Status));
1786 protected Bitmap CreateGlyphBitmap (Size size, MenuGlyph glyph, Color color)
1789 if (color.R == 0 && color.G == 0 && color.B == 0)
1790 bg_color = Color.White;
1792 bg_color = Color.Black;
1793 Bitmap bmp = new Bitmap (size.Width, size.Height);
1794 Graphics gr = Graphics.FromImage (bmp);
1795 Rectangle rect = new Rectangle (Point.Empty, size);
1796 gr.FillRectangle (ResPool.GetSolidBrush (bg_color), rect);
1797 CPDrawMenuGlyph (gr, rect, glyph, color);
1798 bmp.MakeTransparent (bg_color);
1803 public override void DrawMenuItem (MenuItem item, DrawItemEventArgs e)
1805 StringFormat string_format;
1806 Rectangle rect_text = e.Bounds;
1808 if (item.Visible == false)
1812 string_format = string_format_menu_menubar_text;
1814 string_format = string_format_menu_text;
1816 if (item.Separator == true) {
1817 e.Graphics.DrawLine (SystemPens.ControlDark,
1818 e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y);
1820 e.Graphics.DrawLine (SystemPens.ControlLight,
1821 e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + 1);
1827 rect_text.X += MenuCheckSize.Width;
1829 if (item.BarBreak) { /* Draw vertical break bar*/
1830 Rectangle rect = e.Bounds;
1833 rect.Height = item.MenuHeight - 6;
1835 e.Graphics.DrawLine (SystemPens.ControlDark,
1836 rect.X, rect.Y , rect.X, rect.Y + rect.Height);
1838 e.Graphics.DrawLine (SystemPens.ControlLight,
1839 rect.X + 1, rect.Y , rect.X +1, rect.Y + rect.Height);
1844 Brush brush_text = null;
1845 Brush brush_back = null;
1847 if ((e.State & DrawItemState.Selected) == DrawItemState.Selected && !item.MenuBar) {
1848 color_text = ColorHighlightText;
1849 color_back = ColorHighlight;
1850 brush_text = SystemBrushes.HighlightText;
1851 brush_back = SystemBrushes.Highlight;
1853 color_text = ColorMenuText;
1854 color_back = ColorMenu;
1855 brush_text = ResPool.GetSolidBrush (ColorMenuText);
1856 brush_back = SystemBrushes.Menu;
1859 /* Draw background */
1860 Rectangle rect_back = e.Bounds;
1862 rect_back.Width -=2;
1864 e.Graphics.FillRectangle (brush_back, rect_back);
1867 e.Graphics.DrawString (item.Text, e.Font,
1869 rect_text, string_format);
1871 if (!item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut) {
1872 string str = item.GetShortCutText ();
1873 Rectangle rect = rect_text;
1875 rect.Width -= item.XTab;
1877 e.Graphics.DrawString (str, e.Font, brush_text,
1878 rect, string_format_menu_shortcut);
1882 Border3DStyle border_style = Border3DStyle.Adjust;
1883 if ((item.Status & DrawItemState.HotLight) != 0)
1884 border_style = Border3DStyle.RaisedInner;
1885 else if ((item.Status & DrawItemState.Selected) != 0)
1886 border_style = Border3DStyle.SunkenOuter;
1888 if (border_style != Border3DStyle.Adjust)
1889 CPDrawBorder3D(e.Graphics, rect_back, border_style, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, ColorMenu);
1892 if ((item.Status & DrawItemState.Selected) != DrawItemState.Selected) {
1893 e.Graphics.DrawString (item.Text, e.Font, Brushes.White,
1894 new RectangleF(rect_text.X + 1, rect_text.Y + 1, rect_text.Width, rect_text.Height),
1898 e.Graphics.DrawString (item.Text, e.Font, ResPool.GetSolidBrush(ColorGrayText), rect_text, string_format);
1902 if (item.MenuBar == false && item.IsPopup || item.MdiList) {
1904 int cx = MenuCheckSize.Width;
1905 int cy = MenuCheckSize.Height;
1906 Bitmap bmp = CreateGlyphBitmap (new Size (cx, cy), MenuGlyph.Arrow, color_text);
1909 e.Graphics.DrawImage (bmp, e.Bounds.X + e.Bounds.Width - cx,
1910 e.Bounds.Y + ((e.Bounds.Height - cy) /2));
1912 ControlPaint.DrawImageDisabled (e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
1913 e.Bounds.Y + ((e.Bounds.Height - cy) /2), color_back);
1919 /* Draw checked or radio */
1920 if (item.MenuBar == false && item.Checked) {
1922 Rectangle area = e.Bounds;
1923 int cx = MenuCheckSize.Width;
1924 int cy = MenuCheckSize.Height;
1925 Bitmap bmp = CreateGlyphBitmap (new Size (cx, cy), item.RadioCheck ? MenuGlyph.Bullet : MenuGlyph.Checkmark, color_text);
1927 e.Graphics.DrawImage (bmp, area.X, e.Bounds.Y + ((e.Bounds.Height - cy) / 2));
1933 public override void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect)
1936 dc.FillRectangle (SystemBrushes.Menu, cliparea);
1938 Pen pen_cht = SystemPens.HighlightText;
1939 Pen pen_ccd = SystemPens.ControlDark;
1940 Pen pen_ccdd = SystemPens.ControlDarkDark;
1942 /* Draw menu borders */
1943 dc.DrawLine (pen_cht,
1944 rect.X, rect.Y, rect.X + rect.Width, rect.Y);
1946 dc.DrawLine (pen_cht,
1947 rect.X, rect.Y, rect.X, rect.Y + rect.Height);
1949 dc.DrawLine (pen_ccd,
1950 rect.X + rect.Width - 1 , rect.Y , rect.X + rect.Width - 1, rect.Y + rect.Height);
1952 dc.DrawLine (pen_ccdd,
1953 rect.X + rect.Width, rect.Y , rect.X + rect.Width, rect.Y + rect.Height);
1955 dc.DrawLine (pen_ccd,
1956 rect.X , rect.Y + rect.Height - 1 , rect.X + rect.Width - 1, rect.Y + rect.Height -1);
1958 dc.DrawLine (pen_ccdd,
1959 rect.X , rect.Y + rect.Height, rect.X + rect.Width - 1, rect.Y + rect.Height);
1961 for (int i = 0; i < menu.MenuItems.Count; i++)
1962 if (cliparea.IntersectsWith (menu.MenuItems [i].bounds)) {
1963 MenuItem item = menu.MenuItems [i];
1964 item.MenuHeight = menu.Height;
1965 item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont,
1966 item.bounds, i, item.Status));
1972 #region MonthCalendar
1974 // draw the month calendar
1975 public override void DrawMonthCalendar(Graphics dc, Rectangle clip_rectangle, MonthCalendar mc)
1977 Rectangle client_rectangle = mc.ClientRectangle;
1978 Size month_size = mc.SingleMonthSize;
1979 // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
1980 Size calendar_spacing = (Size)((object)mc.calendar_spacing);
1981 Size date_cell_size = (Size)((object)mc.date_cell_size);
1983 // draw the singlecalendars
1986 // adjust for the position of the specific month
1987 for (int i=0; i < mc.CalendarDimensions.Height; i++)
1991 y_offset += month_size.Height + calendar_spacing.Height;
1993 // now adjust for x position
1994 for (int j=0; j < mc.CalendarDimensions.Width; j++)
1998 x_offset += month_size.Width + calendar_spacing.Width;
2005 Rectangle month_rect = new Rectangle (x_offset, y_offset, month_size.Width, month_size.Height);
2006 if (month_rect.IntersectsWith (clip_rectangle)) {
2018 Rectangle bottom_rect = new Rectangle (
2020 Math.Max(client_rectangle.Bottom - date_cell_size.Height - 3, 0),
2021 client_rectangle.Width,
2022 date_cell_size.Height + 2);
2023 // draw the today date if it's set
2024 if (mc.ShowToday && bottom_rect.IntersectsWith (clip_rectangle))
2026 dc.FillRectangle (GetControlBackBrush (mc.BackColor), bottom_rect);
2028 int today_offset = 5;
2029 if (mc.ShowTodayCircle)
2031 Rectangle today_circle_rect = new Rectangle (
2032 client_rectangle.X + 5,
2033 Math.Max(client_rectangle.Bottom - date_cell_size.Height - 2, 0),
2034 date_cell_size.Width,
2035 date_cell_size.Height);
2036 DrawTodayCircle (dc, today_circle_rect);
2037 today_offset += date_cell_size.Width + 5;
2039 // draw today's date
2040 StringFormat text_format = new StringFormat();
2041 text_format.LineAlignment = StringAlignment.Center;
2042 text_format.Alignment = StringAlignment.Near;
2043 Font bold_font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
2044 Rectangle today_rect = new Rectangle (
2045 today_offset + client_rectangle.X,
2046 Math.Max(client_rectangle.Bottom - date_cell_size.Height, 0),
2047 Math.Max(client_rectangle.Width - today_offset, 0),
2048 date_cell_size.Height);
2049 dc.DrawString ("Today: " + DateTime.Now.ToShortDateString(), bold_font, GetControlForeBrush (mc.ForeColor), today_rect, text_format);
2050 text_format.Dispose ();
2051 bold_font.Dispose ();
2055 // finally paint the borders of the calendars as required
2056 for (int i = 0; i <= mc.CalendarDimensions.Width; i++) {
2057 if (i == 0 && clip_rectangle.X == client_rectangle.X) {
2058 dc.FillRectangle (GetControlBackBrush (mc.BackColor), client_rectangle.X, client_rectangle.Y, 1, client_rectangle.Height);
2059 } else if (i == mc.CalendarDimensions.Width && clip_rectangle.Right == client_rectangle.Right) {
2060 dc.FillRectangle (GetControlBackBrush (mc.BackColor), client_rectangle.Right-1, client_rectangle.Y, 1, client_rectangle.Height);
2062 Rectangle rect = new Rectangle (
2063 client_rectangle.X + (month_size.Width*i) + (calendar_spacing.Width * (i-1)) + 1,
2065 calendar_spacing.Width,
2066 client_rectangle.Height);
2067 if (i < mc.CalendarDimensions.Width && i > 0 && clip_rectangle.IntersectsWith (rect)) {
2068 dc.FillRectangle (GetControlBackBrush (mc.BackColor), rect);
2072 for (int i = 0; i <= mc.CalendarDimensions.Height; i++) {
2073 if (i == 0 && clip_rectangle.Y == client_rectangle.Y) {
2074 dc.FillRectangle (GetControlBackBrush (mc.BackColor), client_rectangle.X, client_rectangle.Y, client_rectangle.Width, 1);
2075 } else if (i == mc.CalendarDimensions.Height && clip_rectangle.Bottom == client_rectangle.Bottom) {
2076 dc.FillRectangle (GetControlBackBrush (mc.BackColor), client_rectangle.X, client_rectangle.Bottom-1, client_rectangle.Width, 1);
2078 Rectangle rect = new Rectangle (
2080 client_rectangle.Y + (month_size.Height*i) + (calendar_spacing.Height*(i-1)) + 1,
2081 client_rectangle.Width,
2082 calendar_spacing.Height);
2083 if (i < mc.CalendarDimensions.Height && i > 0 && clip_rectangle.IntersectsWith (rect)) {
2084 dc.FillRectangle (GetControlBackBrush (mc.BackColor), rect);
2089 // draw the drop down border if need
2090 if (mc.owner != null) {
2091 Rectangle bounds = mc.ClientRectangle;
2092 if (clip_rectangle.Contains (mc.Location)) {
2093 // find out if top or left line to draw
2094 if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
2096 dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.X, bounds.Bottom-1);
2098 if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
2099 dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.Right-1, bounds.Y);
2102 if (clip_rectangle.Contains (new Point(bounds.Right, bounds.Bottom))) {
2103 // find out if bottom or right line to draw
2104 if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
2105 dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1);
2107 if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
2108 dc.DrawLine (SystemPens.ControlText, bounds.Right-1, bounds.Y, bounds.Right-1, bounds.Bottom-1);
2114 // darws a single part of the month calendar (with one month)
2115 private void DrawSingleMonth(Graphics dc, Rectangle clip_rectangle, Rectangle rectangle, MonthCalendar mc, int row, int col)
2117 // cache local copies of Marshal-by-ref internal members (gets around error CS0197)
2118 Size title_size = (Size)((object)mc.title_size);
2119 Size date_cell_size = (Size)((object)mc.date_cell_size);
2120 DateTime current_month = (DateTime)((object)mc.current_month);
2122 // set up some standard string formating variables
2123 StringFormat text_format = new StringFormat();
2124 text_format.LineAlignment = StringAlignment.Center;
2125 text_format.Alignment = StringAlignment.Center;
2128 // draw the title back ground
2129 DateTime this_month = current_month.AddMonths (row*mc.CalendarDimensions.Width+col);
2130 Rectangle title_rect = new Rectangle(rectangle.X, rectangle.Y, title_size.Width, title_size.Height);
2131 if (title_rect.IntersectsWith (clip_rectangle)) {
2132 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), title_rect);
2134 string title_text = this_month.ToString ("MMMM yyyy");
2135 dc.DrawString (title_text, mc.Font, ResPool.GetSolidBrush (mc.TitleForeColor), title_rect, text_format);
2137 // draw previous and next buttons if it's time
2138 if (row == 0 && col == 0)
2140 // draw previous button
2141 DrawMonthCalendarButton (
2147 (System.Drawing.Size)((object)mc.button_size),
2150 if (row == 0 && col == mc.CalendarDimensions.Width-1)
2153 DrawMonthCalendarButton (
2159 (System.Drawing.Size)((object)mc.button_size),
2164 // set the week offset and draw week nums if needed
2165 int col_offset = (mc.ShowWeekNumbers) ? 1 : 0;
2166 Rectangle day_name_rect = new Rectangle(
2168 rectangle.Y + title_size.Height,
2169 (7 + col_offset) * date_cell_size.Width,
2170 date_cell_size.Height);
2171 if (day_name_rect.IntersectsWith (clip_rectangle)) {
2172 dc.FillRectangle (GetControlBackBrush (mc.BackColor), day_name_rect);
2173 // draw the day names
2174 DayOfWeek first_day_of_week = mc.GetDayOfWeek(mc.FirstDayOfWeek);
2175 for (int i=0; i < 7; i++)
2177 int position = i - (int) first_day_of_week;
2180 position = 7 + position;
2183 Rectangle day_rect = new Rectangle(
2184 day_name_rect.X + ((i + col_offset)* date_cell_size.Width),
2186 date_cell_size.Width,
2187 date_cell_size.Height);
2188 dc.DrawString (((DayOfWeek)i).ToString().Substring(0, 3), mc.Font, ResPool.GetSolidBrush (mc.TitleBackColor), day_rect, text_format);
2191 // draw the vertical divider
2192 int vert_divider_y = Math.Max(title_size.Height+ date_cell_size.Height-1, 0);
2194 ResPool.GetPen (mc.ForeColor),
2195 rectangle.X + (col_offset * date_cell_size.Width) + mc.divider_line_offset,
2196 rectangle.Y + vert_divider_y,
2197 rectangle.Right - mc.divider_line_offset,
2198 rectangle.Y + vert_divider_y);
2202 // draw the actual date items in the grid (including the week numbers)
2203 Rectangle date_rect = new Rectangle (
2205 rectangle.Y + title_size.Height + date_cell_size.Height,
2206 date_cell_size.Width,
2207 date_cell_size.Height);
2208 int month_row_count = 0;
2209 bool draw_week_num_divider = false;
2210 DateTime current_date = mc.GetFirstDateInMonthGrid ( new DateTime (this_month.Year, this_month.Month, 1));
2211 for (int i=0; i < 6; i++)
2213 // establish if this row is in our clip_area
2214 Rectangle row_rect = new Rectangle (
2216 rectangle.Y + title_size.Height + (date_cell_size.Height * (i+1)),
2217 date_cell_size.Width * 7,
2218 date_cell_size.Height);
2219 if (mc.ShowWeekNumbers) {
2220 row_rect.Width += date_cell_size.Width;
2223 bool draw_row = row_rect.IntersectsWith (clip_rectangle);
2225 dc.FillRectangle (GetControlBackBrush (mc.BackColor), row_rect);
2227 // establish if this is a valid week to draw
2228 if (mc.IsValidWeekToDraw (this_month, current_date, row, col)) {
2229 month_row_count = i;
2232 // draw the week number if required
2233 if (mc.ShowWeekNumbers && month_row_count == i) {
2234 if (!draw_week_num_divider) {
2235 draw_week_num_divider = draw_row;
2237 // get the week for this row
2238 int week = mc.GetWeekOfYear (current_date);
2244 ResPool.GetSolidBrush (mc.TitleBackColor),
2248 date_rect.Offset(date_cell_size.Width, 0);
2251 // only draw the days if we have to
2252 if(month_row_count == i) {
2253 for (int j=0; j < 7; j++)
2256 DrawMonthCalendarDate (
2267 current_date = current_date.AddDays(1);
2268 date_rect.Offset(date_cell_size.Width, 0);
2271 // shift the rectangle down one row
2272 int offset = (mc.ShowWeekNumbers) ? -8 : -7;
2273 date_rect.Offset(offset*date_cell_size.Width, date_cell_size.Height);
2277 // month_row_count is zero based, so add one
2280 // draw week numbers if required
2281 if (draw_week_num_divider) {
2284 ResPool.GetPen (mc.ForeColor),
2285 rectangle.X + date_cell_size.Width - 1,
2286 rectangle.Y + title_size.Height + date_cell_size.Height + mc.divider_line_offset,
2287 rectangle.X + date_cell_size.Width - 1,
2288 rectangle.Y + title_size.Height + date_cell_size.Height + (month_row_count * date_cell_size.Height) - mc.divider_line_offset);
2290 text_format.Dispose ();
2293 // draws the pervious or next button
2294 private void DrawMonthCalendarButton (Graphics dc, Rectangle rectangle, MonthCalendar mc, Size title_size, int x_offset, Size button_size, bool is_previous)
2296 bool is_clicked = false;
2297 Rectangle button_rect;
2298 Rectangle arrow_rect = new Rectangle (rectangle.X, rectangle.Y, 4, 7);
2299 Point[] arrow_path = new Point[3];
2300 // prepare the button
2303 is_clicked = mc.is_previous_clicked;
2304 button_rect = new Rectangle (
2305 rectangle.X + 1 + x_offset,
2306 rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
2307 Math.Max(button_size.Width - 1, 0),
2308 Math.Max(button_size.Height - 1, 0));
2309 arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
2310 arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
2312 arrow_rect.Offset(1,1);
2314 arrow_path[0] = new Point (arrow_rect.Right, arrow_rect.Y);
2315 arrow_path[1] = new Point (arrow_rect.X, arrow_rect.Y + arrow_rect.Height/2);
2316 arrow_path[2] = new Point (arrow_rect.Right, arrow_rect.Bottom);
2320 is_clicked = mc.is_next_clicked;
2321 button_rect = new Rectangle (
2322 rectangle.Right - 1 - x_offset - button_size.Width,
2323 rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
2324 Math.Max(button_size.Width - 1, 0),
2325 Math.Max(button_size.Height - 1, 0));
2326 arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
2327 arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
2329 arrow_rect.Offset(1,1);
2331 arrow_path[0] = new Point (arrow_rect.X, arrow_rect.Y);
2332 arrow_path[1] = new Point (arrow_rect.Right, arrow_rect.Y + arrow_rect.Height/2);
2333 arrow_path[2] = new Point (arrow_rect.X, arrow_rect.Bottom);
2336 // fill the background
2337 dc.FillRectangle (SystemBrushes.Control, button_rect);
2340 dc.DrawRectangle (SystemPens.ControlDark, button_rect);
2343 CPDrawBorder3D (dc, button_rect, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
2346 dc.FillPolygon (SystemBrushes.ControlText, arrow_path);
2350 // draws one day in the calendar grid
2351 private void DrawMonthCalendarDate (Graphics dc, Rectangle rectangle, MonthCalendar mc, DateTime date, DateTime month, int row, int col) {
2352 Color date_color = mc.ForeColor;
2353 Rectangle interior = new Rectangle (rectangle.X, rectangle.Y, Math.Max(rectangle.Width - 1, 0), Math.Max(rectangle.Height - 1, 0));
2355 // find out if we are the lead of the first calendar or the trail of the last calendar
2356 if (date.Year != month.Year || date.Month != month.Month) {
2357 DateTime check_date = month.AddMonths (-1);
2358 // check if it's the month before
2359 if (check_date.Year == date.Year && check_date.Month == date.Month && row == 0 && col == 0) {
2360 date_color = mc.TrailingForeColor;
2362 // check if it's the month after
2363 check_date = month.AddMonths (1);
2364 if (check_date.Year == date.Year && check_date.Month == date.Month && row == mc.CalendarDimensions.Height-1 && col == mc.CalendarDimensions.Width-1) {
2365 date_color = mc.TrailingForeColor;
2371 date_color = mc.ForeColor;
2375 if (date == mc.SelectionStart && date == mc.SelectionEnd) {
2376 // see if the date is in the start of selection
2377 date_color = mc.BackColor;
2378 // draw the left hand of the back ground
2379 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
2380 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 0, 359);
2381 } else if (date == mc.SelectionStart) {
2382 // see if the date is in the start of selection
2383 date_color = mc.BackColor;
2384 // draw the left hand of the back ground
2385 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
2386 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 90, 180);
2387 // fill the other side as a straight rect
2388 if (date < mc.SelectionEnd)
2390 // use rectangle instead of rectangle to go all the way to edge of rect
2391 selection_rect.X = (int) Math.Floor((double)(rectangle.X + rectangle.Width / 2));
2392 selection_rect.Width = Math.Max(rectangle.Right - selection_rect.X, 0);
2393 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
2395 } else if (date == mc.SelectionEnd) {
2396 // see if it is the end of selection
2397 date_color = mc.BackColor;
2398 // draw the left hand of the back ground
2399 Rectangle selection_rect = Rectangle.Inflate(rectangle, -3, -3);
2400 dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 270, 180);
2401 // fill the other side as a straight rect
2402 if (date > mc.SelectionStart) {
2403 selection_rect.X = rectangle.X;
2404 selection_rect.Width = rectangle.Width - (rectangle.Width / 2);
2405 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
2407 } else if (date > mc.SelectionStart && date < mc.SelectionEnd) {
2408 // now see if it's in the middle
2409 date_color = mc.BackColor;
2410 // draw the left hand of the back ground
2411 Rectangle selection_rect = Rectangle.Inflate(rectangle, 0, -3);
2412 dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
2415 // set up some standard string formating variables
2416 StringFormat text_format = new StringFormat();
2417 text_format.LineAlignment = StringAlignment.Center;
2418 text_format.Alignment = StringAlignment.Center;
2421 // establish if it's a bolded font
2423 if (mc.IsBoldedDate (date)) {
2424 font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
2429 // just draw the date now
2430 dc.DrawString (date.Day.ToString(), font, ResPool.GetSolidBrush (date_color), rectangle, text_format);
2432 // today circle if needed
2433 if (mc.ShowTodayCircle && date == DateTime.Now.Date) {
2434 DrawTodayCircle (dc, interior);
2437 // draw the selection grid
2438 if (mc.is_date_clicked && mc.clicked_date == date) {
2439 Pen pen = ResPool.GetDashPen (Color.Black, DashStyle.Dot);
2440 dc.DrawRectangle (pen, interior);
2442 text_format.Dispose ();
2445 private void DrawTodayCircle (Graphics dc, Rectangle rectangle) {
2446 Color circle_color = Color.FromArgb (248, 0, 0);
2447 // draw the left hand of the circle
2448 Rectangle lhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 4, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 5, 0));
2449 Rectangle rhs_circle_rect = new Rectangle (rectangle.X + 1, rectangle.Y + 1, Math.Max(rectangle.Width - 2, 0), Math.Max(rectangle.Height - 2, 0));
2450 Point [] curve_points = new Point [3];
2451 curve_points [0] = new Point (lhs_circle_rect.X, rhs_circle_rect.Y + rhs_circle_rect.Height/12);
2452 curve_points [1] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/9, rhs_circle_rect.Y);
2453 curve_points [2] = new Point (lhs_circle_rect.X + lhs_circle_rect.Width/2 + 1, rhs_circle_rect.Y);
2455 Pen pen = ResPool.GetSizedPen(circle_color, 2);
2456 dc.DrawArc (pen, lhs_circle_rect, 90, 180);
2457 dc.DrawArc (pen, rhs_circle_rect, 270, 180);
2458 dc.DrawCurve (pen, curve_points);
2459 dc.DrawLine (ResPool.GetPen (circle_color), curve_points [2], new Point (curve_points [2].X, lhs_circle_rect.Y));
2462 #endregion // MonthCalendar
2465 public override Size PanelDefaultSize {
2467 return new Size (200, 100);
2473 public override void DrawPictureBox (Graphics dc, Rectangle clip, PictureBox pb) {
2474 Rectangle client = pb.ClientRectangle;
2476 // FIXME - instead of drawing the whole picturebox every time
2477 // intersect the clip rectangle with the drawn picture and only draw what's needed,
2478 // Also, we only need a background fill where no image goes
2479 if (pb.Image != null) {
2480 switch (pb.SizeMode) {
2481 case PictureBoxSizeMode.StretchImage:
2482 dc.DrawImage (pb.Image, 0, 0, client.Width, client.Height);
2485 case PictureBoxSizeMode.CenterImage:
2486 dc.FillRectangle(GetControlBackBrush (pb.BackColor), clip);
2487 dc.DrawImage (pb.Image, (client.Width / 2) - (pb.Image.Width / 2), (client.Height / 2) - (pb.Image.Height / 2));
2490 dc.FillRectangle(GetControlBackBrush (pb.BackColor), clip);
2492 dc.DrawImage(pb.Image, 0, 0, pb.Image.Width, pb.Image.Height);
2499 // We only get here if no image is set. At least paint the background
2500 dc.FillRectangle(GetControlBackBrush (pb.BackColor), clip);
2503 public override Size PictureBoxDefaultSize {
2505 return new Size (100, 50);
2508 #endregion // PictureBox
2511 public override void DrawProgressBar (Graphics dc, Rectangle clip_rect, ProgressBar ctrl)
2513 Rectangle block_rect;
2514 Rectangle client_area = ctrl.client_area;
2515 int space_betweenblocks = 2;
2520 block_width = (client_area.Height * 2 ) / 3;
2521 barpos_pixels = ((ctrl.Value - ctrl.Minimum) * client_area.Width) / (ctrl.Maximum - ctrl.Minimum);
2522 increment = block_width + space_betweenblocks;
2525 CPDrawBorder3D (dc, ctrl.ClientRectangle, Border3DStyle.SunkenOuter, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom & ~Border3DSide.Middle, ColorControl);
2528 block_rect = new Rectangle (client_area.X, client_area.Y, block_width, client_area.Height);
2529 while ((block_rect.X - client_area.X) < barpos_pixels) {
2531 if (clip_rect.IntersectsWith (block_rect) == true) {
2532 dc.FillRectangle (ResPool.GetSolidBrush (progressbarblock_color), block_rect);
2535 block_rect.X += increment;
2539 public override Size ProgressBarDefaultSize {
2541 return new Size (100, 23);
2545 #endregion // ProgressBar
2548 public override void DrawRadioButton (Graphics dc, Rectangle clip_rectangle, RadioButton radio_button) {
2549 StringFormat text_format;
2550 Rectangle client_rectangle;
2551 Rectangle text_rectangle;
2552 Rectangle radiobutton_rectangle;
2553 int radiobutton_size = 13;
2554 int radiobutton_space = 4;
2556 client_rectangle = radio_button.ClientRectangle;
2557 text_rectangle = client_rectangle;
2558 radiobutton_rectangle = new Rectangle(text_rectangle.X, text_rectangle.Y, radiobutton_size, radiobutton_size);
2560 text_format = new StringFormat();
2561 text_format.Alignment = StringAlignment.Near;
2562 text_format.LineAlignment = StringAlignment.Center;
2563 text_format.HotkeyPrefix = HotkeyPrefix.Show;
2565 /* Calculate the position of text and checkbox rectangle */
2566 if (radio_button.appearance!=Appearance.Button) {
2567 switch(radio_button.radiobutton_alignment) {
2568 case ContentAlignment.BottomCenter: {
2569 radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
2570 radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
2571 text_rectangle.X=client_rectangle.X;
2572 text_rectangle.Width=client_rectangle.Width;
2573 text_rectangle.Height=client_rectangle.Height-radiobutton_size-radiobutton_space;
2577 case ContentAlignment.BottomLeft: {
2578 radiobutton_rectangle.X=client_rectangle.Left;
2579 radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
2580 text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
2581 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
2585 case ContentAlignment.BottomRight: {
2586 radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
2587 radiobutton_rectangle.Y=client_rectangle.Bottom-radiobutton_size;
2588 text_rectangle.X=client_rectangle.X;
2589 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
2593 case ContentAlignment.MiddleCenter: {
2594 radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
2595 radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
2596 text_rectangle.X=client_rectangle.X;
2597 text_rectangle.Width=client_rectangle.Width;
2602 case ContentAlignment.MiddleLeft: {
2603 radiobutton_rectangle.X=client_rectangle.Left;
2604 radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
2605 text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
2606 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
2610 case ContentAlignment.MiddleRight: {
2611 radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
2612 radiobutton_rectangle.Y=(client_rectangle.Bottom-client_rectangle.Top)/2-radiobutton_size/2;
2613 text_rectangle.X=client_rectangle.X;
2614 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
2618 case ContentAlignment.TopCenter: {
2619 radiobutton_rectangle.X=(client_rectangle.Right-client_rectangle.Left)/2-radiobutton_size/2;
2620 radiobutton_rectangle.Y=client_rectangle.Top;
2621 text_rectangle.X=client_rectangle.X;
2622 text_rectangle.Y=radiobutton_size+radiobutton_space;
2623 text_rectangle.Width=client_rectangle.Width;
2624 text_rectangle.Height=client_rectangle.Height-radiobutton_size-radiobutton_space;
2628 case ContentAlignment.TopLeft: {
2629 radiobutton_rectangle.X=client_rectangle.Left;
2630 radiobutton_rectangle.Y=client_rectangle.Top;
2631 text_rectangle.X=client_rectangle.X+radiobutton_size+radiobutton_space;
2632 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
2636 case ContentAlignment.TopRight: {
2637 radiobutton_rectangle.X=client_rectangle.Right-radiobutton_size;
2638 radiobutton_rectangle.Y=client_rectangle.Top;
2639 text_rectangle.X=client_rectangle.X;
2640 text_rectangle.Width=client_rectangle.Width-radiobutton_size-radiobutton_space;
2645 text_rectangle.X=client_rectangle.X;
2646 text_rectangle.Width=client_rectangle.Width;
2649 /* Set the horizontal alignment of our text */
2650 switch(radio_button.text_alignment) {
2651 case ContentAlignment.BottomLeft:
2652 case ContentAlignment.MiddleLeft:
2653 case ContentAlignment.TopLeft: {
2654 text_format.Alignment=StringAlignment.Near;
2658 case ContentAlignment.BottomCenter:
2659 case ContentAlignment.MiddleCenter:
2660 case ContentAlignment.TopCenter: {
2661 text_format.Alignment=StringAlignment.Center;
2665 case ContentAlignment.BottomRight:
2666 case ContentAlignment.MiddleRight:
2667 case ContentAlignment.TopRight: {
2668 text_format.Alignment=StringAlignment.Far;
2673 /* Set the vertical alignment of our text */
2674 switch(radio_button.text_alignment) {
2675 case ContentAlignment.TopLeft:
2676 case ContentAlignment.TopCenter:
2677 case ContentAlignment.TopRight: {
2678 text_format.LineAlignment=StringAlignment.Near;
2682 case ContentAlignment.BottomLeft:
2683 case ContentAlignment.BottomCenter:
2684 case ContentAlignment.BottomRight: {
2685 text_format.LineAlignment=StringAlignment.Far;
2689 case ContentAlignment.MiddleLeft:
2690 case ContentAlignment.MiddleCenter:
2691 case ContentAlignment.MiddleRight: {
2692 text_format.LineAlignment=StringAlignment.Center;
2697 ButtonState state = ButtonState.Normal;
2698 if (radio_button.FlatStyle == FlatStyle.Flat) {
2699 state |= ButtonState.Flat;
2702 if (radio_button.Checked) {
2703 state |= ButtonState.Checked;
2706 if (!radio_button.Enabled) {
2707 state |= ButtonState.Inactive;
2711 RadioButton_DrawButton(radio_button, dc, state, radiobutton_rectangle);
2713 if ((radio_button.image != null) || (radio_button.image_list != null))
2714 ButtonBase_DrawImage(radio_button, dc);
2716 RadioButton_DrawText(radio_button, text_rectangle, dc, text_format);
2718 RadioButton_DrawFocus(radio_button, dc, text_rectangle);
2720 text_format.Dispose ();
2723 protected virtual void RadioButton_DrawButton(RadioButton radio_button, Graphics dc, ButtonState state, Rectangle radiobutton_rectangle)
2725 dc.FillRectangle(GetControlBackBrush (radio_button.BackColor), radio_button.ClientRectangle);
2727 if (radio_button.appearance==Appearance.Button) {
2728 ButtonBase_DrawButton (radio_button, dc);
2730 // establish if we are rendering a flat style of some sort
2731 if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
2732 DrawFlatStyleRadioButton (dc, radiobutton_rectangle, radio_button);
2734 CPDrawRadioButton(dc, radiobutton_rectangle, state);
2739 protected virtual void RadioButton_DrawText(RadioButton radio_button, Rectangle text_rectangle, Graphics dc, StringFormat text_format)
2741 DrawCheckBox_and_RadioButtonText (radio_button, text_rectangle, dc,
2742 text_format, radio_button.Appearance, radio_button.Checked);
2745 protected virtual void RadioButton_DrawFocus(RadioButton radio_button, Graphics dc, Rectangle text_rectangle)
2747 // do nothing here. maybe an other theme needs it
2750 // renders a radio button with the Flat and Popup FlatStyle
2751 protected virtual void DrawFlatStyleRadioButton (Graphics graphics, Rectangle rectangle, RadioButton radio_button)
2755 if (radio_button.Enabled) {
2757 // draw the outer flatstyle arcs
2758 if (radio_button.FlatStyle == FlatStyle.Flat) {
2759 graphics.DrawArc (SystemPens.ControlDarkDark, rectangle, 0, 359);
2761 // fill in the area depending on whether or not the mouse is hovering
2762 if ((radio_button.is_entered || radio_button.Capture) && !radio_button.is_pressed) {
2763 graphics.FillPie (SystemBrushes.ControlLight, rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
2765 graphics.FillPie (SystemBrushes.ControlLightLight, rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
2768 // must be a popup radio button
2770 graphics.FillPie (SystemBrushes.ControlLightLight, rectangle, 0, 359);
2772 if (radio_button.is_entered || radio_button.Capture) {
2773 // draw the popup 3d button knob
2774 graphics.DrawArc (SystemPens.ControlLight, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 0, 359);
2776 graphics.DrawArc (SystemPens.ControlDark, rectangle, 135, 180);
2777 graphics.DrawArc (SystemPens.ControlLightLight, rectangle, 315, 180);
2780 // just draw lighter flatstyle outer circle
2781 graphics.DrawArc (SystemPens.ControlDark, rectangle, 0, 359);
2786 // fill control background color regardless of actual backcolor
2787 graphics.FillPie (SystemBrushes.Control, rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
2788 // draw the ark as control dark
2789 graphics.DrawArc (SystemPens.ControlDark, rectangle, 0, 359);
2793 if (radio_button.Checked) {
2794 lineWidth = Math.Max (1, Math.Min(rectangle.Width, rectangle.Height)/3);
2796 Pen dot_pen = SystemPens.ControlDarkDark;
2797 Brush dot_brush = SystemBrushes.ControlDarkDark;
2799 if (!radio_button.Enabled || ((radio_button.FlatStyle == FlatStyle.Popup) && radio_button.is_pressed)) {
2800 dot_pen = SystemPens.ControlDark;
2801 dot_brush = SystemBrushes.ControlDark;
2804 if (rectangle.Height > 13) {
2805 graphics.FillPie (dot_brush, rectangle.X + lineWidth, rectangle.Y + lineWidth, rectangle.Width - lineWidth * 2, rectangle.Height - lineWidth * 2, 0, 359);
2807 int x_half_pos = (rectangle.Width / 2) + rectangle.X;
2808 int y_half_pos = (rectangle.Height / 2) + rectangle.Y;
2810 graphics.DrawLine (dot_pen, x_half_pos - 1, y_half_pos, x_half_pos + 2, y_half_pos);
2811 graphics.DrawLine (dot_pen, x_half_pos - 1, y_half_pos + 1, x_half_pos + 2, y_half_pos + 1);
2813 graphics.DrawLine (dot_pen, x_half_pos, y_half_pos - 1, x_half_pos, y_half_pos + 2);
2814 graphics.DrawLine (dot_pen, x_half_pos + 1, y_half_pos - 1, x_half_pos + 1, y_half_pos + 2);
2819 public override Size RadioButtonDefaultSize {
2821 return new Size (104,24);
2824 #endregion // RadioButton
2827 public override void DrawScrollBar (Graphics dc, Rectangle clip, ScrollBar bar)
2829 int scrollbutton_width = bar.scrollbutton_width;
2830 int scrollbutton_height = bar.scrollbutton_height;
2831 Rectangle first_arrow_area;
2832 Rectangle second_arrow_area;
2833 Rectangle thumb_pos;
2835 thumb_pos = bar.ThumbPos;
2838 first_arrow_area = new Rectangle(0, 0, bar.Width, scrollbutton_height);
2839 bar.FirstArrowArea = first_arrow_area;
2841 second_arrow_area = new Rectangle(0, bar.ClientRectangle.Height - scrollbutton_height, bar.Width, scrollbutton_height);
2842 bar.SecondArrowArea = second_arrow_area;
2844 thumb_pos.Width = bar.Width;
2845 bar.ThumbPos = thumb_pos;
2848 if (clip.IntersectsWith (first_arrow_area))
2849 CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state);
2850 if (clip.IntersectsWith (second_arrow_area))
2851 CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state);
2854 switch (bar.thumb_moving) {
2855 case ScrollBar.ThumbMoving.None: {
2856 ScrollBar_Vertical_Draw_ThumbMoving_None(scrollbutton_height, bar, clip, dc);
2859 case ScrollBar.ThumbMoving.Forward: {
2860 ScrollBar_Vertical_Draw_ThumbMoving_Forward(scrollbutton_height, bar, thumb_pos, clip, dc);
2864 case ScrollBar.ThumbMoving.Backwards: {
2865 ScrollBar_Vertical_Draw_ThumbMoving_Backwards(scrollbutton_height, bar, thumb_pos, clip, dc);
2873 first_arrow_area = new Rectangle(0, 0, scrollbutton_width, bar.Height);
2874 bar.FirstArrowArea = first_arrow_area;
2876 second_arrow_area = new Rectangle (bar.ClientRectangle.Width - scrollbutton_width, 0, scrollbutton_width, bar.Height);
2877 bar.SecondArrowArea = second_arrow_area;
2879 thumb_pos.Height = bar.Height;
2880 bar.ThumbPos = thumb_pos;
2883 if (clip.IntersectsWith (first_arrow_area))
2884 CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Left, bar.firstbutton_state);
2885 if (clip.IntersectsWith (second_arrow_area))
2886 CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Right, bar.secondbutton_state);
2889 switch (bar.thumb_moving) {
2890 case ScrollBar.ThumbMoving.None: {
2891 ScrollBar_Horizontal_Draw_ThumbMoving_None(scrollbutton_width, bar, clip, dc);
2895 case ScrollBar.ThumbMoving.Forward: {
2896 ScrollBar_Horizontal_Draw_ThumbMoving_Forward(scrollbutton_width, thumb_pos, bar, clip, dc);
2900 case ScrollBar.ThumbMoving.Backwards: {
2901 ScrollBar_Horizontal_Draw_ThumbMoving_Backwards(scrollbutton_width, thumb_pos, bar, clip, dc);
2908 ScrollBar_DrawThumb(bar, thumb_pos, clip, dc);
2911 protected virtual void ScrollBar_DrawThumb(ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc)
2913 if (bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith(thumb_pos))
2914 DrawScrollButtonPrimitive(dc, thumb_pos, ButtonState.Normal);
2917 protected virtual void ScrollBar_Vertical_Draw_ThumbMoving_None( int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc )
2919 Rectangle r = new Rectangle( 0,
2920 scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - ( scrollbutton_height * 2 ) );
2921 Rectangle intersect = Rectangle.Intersect( clip, r );
2923 if ( intersect != Rectangle.Empty )
2925 Brush h = ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White);
2926 dc.FillRectangle( h, intersect );
2930 protected virtual void ScrollBar_Vertical_Draw_ThumbMoving_Forward( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
2932 Rectangle r = new Rectangle( 0, scrollbutton_height,
2933 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
2934 Rectangle intersect = Rectangle.Intersect( clip, r );
2936 if ( intersect != Rectangle.Empty )
2937 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White ), intersect );
2940 r.Y = thumb_pos.Y + thumb_pos.Height;
2941 r.Width = bar.ClientRectangle.Width;
2942 r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
2944 intersect = Rectangle.Intersect( clip, r );
2945 if ( intersect != Rectangle.Empty )
2946 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
2949 protected virtual void ScrollBar_Vertical_Draw_ThumbMoving_Backwards( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
2951 Rectangle r = new Rectangle( 0, scrollbutton_height,
2952 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
2953 Rectangle intersect = Rectangle.Intersect( clip, r );
2955 if ( intersect != Rectangle.Empty )
2956 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
2959 r.Y = thumb_pos.Y + thumb_pos.Height;
2960 r.Width = bar.ClientRectangle.Width;
2961 r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
2963 intersect = Rectangle.Intersect( clip, r );
2964 if ( intersect != Rectangle.Empty )
2965 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
2968 protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc )
2970 Rectangle r = new Rectangle( scrollbutton_width,
2971 0, bar.ClientRectangle.Width - ( scrollbutton_width * 2 ), bar.ClientRectangle.Height );
2972 Rectangle intersect = Rectangle.Intersect( clip, r );
2974 if ( intersect != Rectangle.Empty )
2975 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
2978 protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
2980 Rectangle r = new Rectangle( scrollbutton_width, 0,
2981 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
2982 Rectangle intersect = Rectangle.Intersect( clip, r );
2984 if ( intersect != Rectangle.Empty )
2985 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
2987 r.X = thumb_pos.X + thumb_pos.Width;
2989 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
2990 r.Height = bar.ClientRectangle.Height;
2992 intersect = Rectangle.Intersect( clip, r );
2993 if ( intersect != Rectangle.Empty )
2994 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
2997 protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
2999 Rectangle r = new Rectangle( scrollbutton_width, 0,
3000 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
3001 Rectangle intersect = Rectangle.Intersect( clip, r );
3003 if ( intersect != Rectangle.Empty )
3004 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, Color.FromArgb( 255, 63, 63, 63 ), Color.Black ), intersect );
3006 r.X = thumb_pos.X + thumb_pos.Width;
3008 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
3009 r.Height = bar.ClientRectangle.Height;
3011 intersect = Rectangle.Intersect( clip, r );
3012 if ( intersect != Rectangle.Empty )
3013 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
3016 public override int ScrollBarButtonSize {
3019 #endregion // ScrollBar
3022 public override void DrawStatusBar (Graphics dc, Rectangle clip, StatusBar sb) {
3023 Rectangle area = sb.ClientRectangle;
3024 int horz_border = 2;
3025 int vert_border = 2;
3027 bool is_color_control = sb.BackColor == ColorControl;
3029 Brush brush = is_color_control ? SystemBrushes.Control : ResPool.GetSolidBrush (sb.BackColor);
3030 dc.FillRectangle (brush, clip);
3032 if (sb.Panels.Count == 0 && sb.Text != String.Empty) {
3033 string text = sb.Text;
3034 StringFormat string_format = new StringFormat ();
3035 string_format.Trimming = StringTrimming.Character;
3036 string_format.FormatFlags = StringFormatFlags.NoWrap;
3038 if (text [0] == '\t') {
3039 string_format.Alignment = StringAlignment.Center;
3040 text = text.Substring (1);
3041 if (text [0] == '\t') {
3042 string_format.Alignment = StringAlignment.Far;
3043 text = text.Substring (1);
3047 dc.DrawString (text, sb.Font, ResPool.GetSolidBrush (sb.ForeColor),
3048 new Rectangle(area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4), string_format);
3049 string_format.Dispose ();
3050 } else if (sb.ShowPanels) {
3051 Brush br_forecolor = GetControlForeBrush (sb.ForeColor);
3052 int prev_x = area.X + horz_border;
3053 int y = area.Y + vert_border;
3054 for (int i = 0; i < sb.Panels.Count; i++) {
3055 Rectangle pr = new Rectangle (prev_x, y,
3056 sb.Panels [i].Width, area.Height);
3057 prev_x += pr.Width + StatusBarHorzGapWidth;
3058 if (pr.IntersectsWith (clip))
3059 DrawStatusBarPanel (dc, pr, i, br_forecolor, sb.Panels [i]);
3063 if (sb.SizingGrip) {
3064 int sg_height = (area.Height / 3) * 2;
3065 area = new Rectangle (area.Right - sg_height - 4, area.Bottom - sg_height - 1, sg_height, sg_height);
3066 CPDrawSizeGrip (dc, ColorControl, area);
3072 protected virtual void DrawStatusBarPanel (Graphics dc, Rectangle area, int index,
3073 Brush br_forecolor, StatusBarPanel panel) {
3074 int border_size = 3; // this is actually const, even if the border style is none
3076 area.Height -= border_size;
3078 if (panel.BorderStyle != StatusBarPanelBorderStyle.None) {
3079 Border3DStyle border_style = Border3DStyle.SunkenOuter;
3080 if (panel.BorderStyle == StatusBarPanelBorderStyle.Raised)
3081 border_style = Border3DStyle.RaisedInner;
3083 CPDrawBorder3D(dc, area, border_style, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, panel.Parent.BackColor);
3086 if (panel.Style == StatusBarPanelStyle.OwnerDraw) {
3087 StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs (
3088 dc, panel.Parent.Font, area, index, DrawItemState.Default,
3089 panel, panel.Parent.ForeColor, panel.Parent.BackColor);
3090 panel.Parent.OnDrawItemInternal (e);
3094 int left = area.Left;
3095 if (panel.Icon != null) {
3097 dc.DrawIcon (panel.Icon, left, area.Top);
3098 left += panel.Icon.Width;
3101 if (panel.Text == String.Empty)
3104 string text = panel.Text;
3105 StringFormat string_format = new StringFormat ();
3106 string_format.Trimming = StringTrimming.Character;
3107 string_format.FormatFlags = StringFormatFlags.NoWrap;
3109 if (text [0] == '\t') {
3110 string_format.Alignment = StringAlignment.Center;
3111 text = text.Substring (1);
3112 if (text [0] == '\t') {
3113 string_format.Alignment = StringAlignment.Far;
3114 text = text.Substring (1);
3118 int x = left + border_size;
3119 int y = border_size + 2;
3120 Rectangle r = new Rectangle (x, y,
3121 area.Right - x - border_size,
3122 area.Bottom - y - border_size);
3124 dc.DrawString (text, panel.Parent.Font, br_forecolor, r, string_format);
3125 string_format.Dispose ();
3128 public override int StatusBarSizeGripWidth {
3132 public override int StatusBarHorzGapWidth {
3136 public override Size StatusBarDefaultSize {
3138 return new Size (100, 22);
3141 #endregion // StatusBar
3143 public override void DrawTabControl (Graphics dc, Rectangle area, TabControl tab)
3145 // Do we need to fill the back color? It can't be changed...
3146 Brush brush = tab.BackColor == DefaultControlBackColor ? SystemBrushes.Control : ResPool.GetSolidBrush (tab.BackColor);
3147 dc.FillRectangle (brush, area);
3148 Rectangle panel_rect = GetTabPanelRectExt (tab);
3150 if (tab.Appearance == TabAppearance.Normal) {
3151 CPDrawBorder3D (dc, panel_rect, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, ColorControl);
3152 CPDrawBorder3D (dc, panel_rect, Border3DStyle.Raised, Border3DSide.Right | Border3DSide.Bottom, ColorControl);
3155 if (tab.Alignment == TabAlignment.Top) {
3156 for (int r = tab.TabPages.Count; r > 0; r--) {
3157 for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
3158 if (i == tab.SelectedIndex)
3160 if (r != tab.TabPages [i].Row)
3162 Rectangle rect = tab.GetTabRect (i);
3163 if (!rect.IntersectsWith (area))
3165 DrawTab (dc, tab.TabPages [i], tab, rect, false);
3169 for (int r = 0; r < tab.TabPages.Count; r++) {
3170 for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
3171 if (i == tab.SelectedIndex)
3173 if (r != tab.TabPages [i].Row)
3175 Rectangle rect = tab.GetTabRect (i);
3176 if (!rect.IntersectsWith (area))
3178 DrawTab (dc, tab.TabPages [i], tab, rect, false);
3183 if (tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos) {
3184 Rectangle rect = tab.GetTabRect (tab.SelectedIndex);
3185 if (rect.IntersectsWith (area))
3186 DrawTab (dc, tab.TabPages [tab.SelectedIndex], tab, rect, true);
3189 if (tab.ShowSlider) {
3190 Rectangle right = GetTabControlRightScrollRect (tab);
3191 Rectangle left = GetTabControlLeftScrollRect (tab);
3192 CPDrawScrollButton (dc, right, ScrollButton.Right, tab.RightSliderState);
3193 CPDrawScrollButton (dc, left, ScrollButton.Left, tab.LeftSliderState);
3197 public override Rectangle GetTabControlLeftScrollRect (TabControl tab)
3199 switch (tab.Alignment) {
3200 case TabAlignment.Top:
3201 return new Rectangle (tab.ClientRectangle.Right - 34, tab.ClientRectangle.Top + 1, 17, 17);
3203 Rectangle panel_rect = GetTabPanelRectExt (tab);
3204 return new Rectangle (tab.ClientRectangle.Right - 34, panel_rect.Bottom + 2, 17, 17);
3208 public override Rectangle GetTabControlRightScrollRect (TabControl tab)
3210 switch (tab.Alignment) {
3211 case TabAlignment.Top:
3212 return new Rectangle (tab.ClientRectangle.Right - 17, tab.ClientRectangle.Top + 1, 17, 17);
3214 Rectangle panel_rect = GetTabPanelRectExt (tab);
3215 return new Rectangle (tab.ClientRectangle.Right - 17, panel_rect.Bottom + 2, 17, 17);
3219 public override Size TabControlDefaultItemSize {
3220 get { return new Size (42, 21); }
3223 public override Point TabControlDefaultPadding {
3224 get { return new Point (6, 3); }
3227 public override int TabControlMinimumTabWidth {
3231 public override Rectangle GetTabControlDisplayRectangle (TabControl tab)
3233 Rectangle ext = GetTabPanelRectExt (tab);
3234 // Account for border size
3235 return new Rectangle (ext.Left + 2, ext.Top + 1, ext.Width - 6, ext.Height - 4);
3238 public override Size TabControlGetSpacing (TabControl tab) {
3239 switch (tab.Appearance) {
3240 case TabAppearance.Normal:
3241 return new Size (1, -2);
3242 case TabAppearance.Buttons:
3243 return new Size (3, 3);
3244 case TabAppearance.FlatButtons:
3245 return new Size (9, 3);
3247 throw new Exception ("Invalid Appearance value: " + tab.Appearance);
3251 protected virtual Rectangle GetTabPanelRectExt (TabControl tab)
3253 // Offset the tab from the top corner
3254 Rectangle res = new Rectangle (tab.ClientRectangle.X + 2,
3255 tab.ClientRectangle.Y,
3256 tab.ClientRectangle.Width - 2,
3257 tab.ClientRectangle.Height - 1);
3259 if (tab.TabCount == 0)
3262 int spacing = TabControlGetSpacing (tab).Height;
3263 int offset = (tab.ItemSize.Height + spacing) * tab.RowCount + 3;
3265 switch (tab.Alignment) {
3266 case TabAlignment.Left:
3268 res.Width -= offset;
3270 case TabAlignment.Right:
3271 res.Width -= offset;
3273 case TabAlignment.Top:
3275 res.Height -= offset;
3277 case TabAlignment.Bottom:
3278 res.Height -= offset;
3285 protected virtual int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
3287 int FlatButtonSpacing = 8;
3289 int res = bounds.Width;
3293 // we can't fill the background right away because the bounds might be adjusted if the tab is selected
3295 StringFormat string_format = new StringFormat ();
3296 if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) {
3297 dc.FillRectangle (ResPool.GetSolidBrush (tab.BackColor), bounds);
3300 if (tab.Appearance == TabAppearance.FlatButtons) {
3301 int width = bounds.Width;
3302 bounds.Width += (FlatButtonSpacing - 2);
3304 CPDrawBorder3D (dc, bounds, Border3DStyle.Etched, Border3DSide.Right);
3305 bounds.Width = width;
3309 CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
3310 } else if (tab.Appearance != TabAppearance.FlatButtons) {
3311 CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
3314 interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4);
3317 string_format.Alignment = StringAlignment.Center;
3318 string_format.LineAlignment = StringAlignment.Center;
3319 string_format.FormatFlags = StringFormatFlags.NoWrap;
3321 CPColor cpcolor = ResPool.GetCPColor (tab.BackColor);
3323 Pen light = ResPool.GetPen (cpcolor.LightLight);
3325 switch (tab.Alignment) {
3327 case TabAlignment.Top:
3329 dc.FillRectangle (ResPool.GetSolidBrush (tab.BackColor), bounds);
3331 dc.DrawLine (light, bounds.Left, bounds.Bottom, bounds.Left, bounds.Top + 3);
3332 dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
3333 dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right - 3, bounds.Top);
3335 dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom);
3336 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 1, bounds.Top + 2, bounds.Right, bounds.Top + 3);
3337 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom);
3339 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
3341 string_format.Alignment = StringAlignment.Center;
3342 string_format.LineAlignment = StringAlignment.Center;
3343 string_format.FormatFlags = StringFormatFlags.NoWrap;
3347 case TabAlignment.Bottom:
3349 dc.FillRectangle (ResPool.GetSolidBrush (tab.BackColor), bounds);
3351 dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 3);
3352 dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left + 2, bounds.Bottom - 1);
3354 dc.DrawLine (SystemPens.ControlDark, bounds.Left + 3, bounds.Bottom - 1, bounds.Right - 3, bounds.Bottom - 1);
3355 dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Bottom - 3, bounds.Right - 1, bounds.Top);
3357 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
3358 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 3, bounds.Bottom, bounds.Right, bounds.Bottom - 3);
3359 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom - 3, bounds.Right, bounds.Top);
3361 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
3363 string_format.Alignment = StringAlignment.Center;
3364 string_format.LineAlignment = StringAlignment.Center;
3365 string_format.FormatFlags = StringFormatFlags.NoWrap;
3369 case TabAlignment.Left:
3371 dc.FillRectangle (ResPool.GetSolidBrush (tab.BackColor), bounds);
3373 dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left, bounds.Top + 3);
3374 dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
3375 dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right, bounds.Top);
3377 dc.DrawLine (SystemPens.ControlDark, bounds.Right, bounds.Bottom - 1, bounds.Left + 2, bounds.Bottom - 1);
3379 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom, bounds.Left + 2, bounds.Bottom);
3380 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 2, bounds.Bottom, bounds.Left, bounds.Bottom - 3);
3382 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
3384 string_format.Alignment = StringAlignment.Center;
3385 string_format.LineAlignment = StringAlignment.Center;
3386 string_format.FormatFlags = StringFormatFlags.NoWrap;
3387 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
3392 // TabAlignment.Right
3394 dc.FillRectangle (ResPool.GetSolidBrush (tab.BackColor), bounds);
3396 dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Right - 3, bounds.Top);
3397 dc.DrawLine (light, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3);
3399 dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom - 1);
3400 dc.DrawLine (SystemPens.ControlDark, bounds.Left, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1);
3402 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom - 3);
3403 dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
3405 interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
3407 string_format.Alignment = StringAlignment.Center;
3408 string_format.LineAlignment = StringAlignment.Center;
3409 string_format.FormatFlags = StringFormatFlags.NoWrap;
3410 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
3416 if (tab.DrawMode == TabDrawMode.Normal && page.Text != null) {
3417 if (tab.Alignment == TabAlignment.Left) {
3418 int wo = interior.Width / 2;
3419 int ho = interior.Height / 2;
3420 dc.TranslateTransform (interior.X + wo, interior.Y + ho);
3421 dc.RotateTransform (180);
3422 dc.DrawString (page.Text, page.Font, SystemBrushes.ControlText, 0, 0, string_format);
3423 dc.ResetTransform ();
3425 dc.DrawString (page.Text, page.Font,
3426 SystemBrushes.ControlText,
3427 interior, string_format);
3429 } else if (page.Text != null) {
3430 DrawItemState state = DrawItemState.None;
3431 if (page == tab.SelectedTab)
3432 state |= DrawItemState.Selected;
3433 DrawItemEventArgs e = new DrawItemEventArgs (dc,
3434 tab.Font, bounds, tab.IndexForTabPage (page),
3435 state, page.ForeColor, page.BackColor);
3436 tab.OnDrawItemInternal (e);
3440 if (page.parent.Focused && is_selected) {
3441 CPDrawFocusRectangle (dc, interior, tab.ForeColor, tab.BackColor);
3448 public override void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control)
3450 StringFormat format = new StringFormat ();
3451 format.Trimming = StringTrimming.EllipsisWord;
3452 format.LineAlignment = StringAlignment.Center;
3453 if (control.TextAlign == ToolBarTextAlign.Underneath)
3454 format.Alignment = StringAlignment.Center;
3456 format.Alignment = StringAlignment.Near;
3458 //dc.FillRectangle (ResPool.GetSolidBrush( DefaultControlBackColor ), clip_rectangle);
3459 dc.FillRectangle (SystemBrushes.Control, clip_rectangle);
3461 foreach (ToolBarButton button in control.Buttons)
3462 if (button.Visible && clip_rectangle.IntersectsWith (button.Rectangle))
3463 DrawToolBarButton (dc, control, button, format);
3468 void DrawToolBarButton (Graphics dc, ToolBar control, ToolBarButton button, StringFormat format)
3470 bool is_flat = control.Appearance == ToolBarAppearance.Flat;
3472 DrawToolBarButtonBorder (dc, button, is_flat);
3474 switch (button.Style) {
3475 case ToolBarButtonStyle.DropDownButton:
3476 if (control.DropDownArrows)
3477 DrawToolBarDropDownArrow (dc, button, is_flat);
3478 DrawToolBarButtonContents (dc, control, button, format);
3481 case ToolBarButtonStyle.Separator:
3483 DrawToolBarSeparator (dc, button);
3486 case ToolBarButtonStyle.ToggleButton:
3487 DrawToolBarToggleButtonBackground (dc, button);
3488 DrawToolBarButtonContents (dc, control, button, format);
3492 DrawToolBarButtonContents (dc, control, button, format);
3497 const Border3DSide all_sides = Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom;
3499 void DrawToolBarButtonBorder (Graphics dc, ToolBarButton button, bool is_flat)
3501 if (button.Style == ToolBarButtonStyle.Separator)
3504 Border3DStyle style;
3507 if (button.Pushed || button.Pressed)
3508 style = Border3DStyle.SunkenOuter;
3509 else if (button.Hilight)
3510 style = Border3DStyle.RaisedInner;
3515 if (button.Pushed || button.Pressed)
3516 style = Border3DStyle.Sunken;
3518 style = Border3DStyle.Raised;
3521 CPDrawBorder3D (dc, button.Rectangle, style, all_sides);
3524 void DrawToolBarSeparator (Graphics dc, ToolBarButton button)
3526 Rectangle area = button.Rectangle;
3527 int offset = (int) SystemPens.Control.Width + 1;
3528 dc.DrawLine (SystemPens.ControlDark, area.X + 1, area.Y, area.X + 1, area.Bottom);
3529 dc.DrawLine (SystemPens.ControlLight, area.X + offset, area.Y, area.X + offset, area.Bottom);
3532 void DrawToolBarToggleButtonBackground (Graphics dc, ToolBarButton button)
3534 Rectangle area = button.Rectangle;
3535 area.X += ToolBarImageGripWidth;
3536 area.Y += ToolBarImageGripWidth;
3537 area.Width -= 2 * ToolBarImageGripWidth;
3538 area.Height -= 2 * ToolBarImageGripWidth;
3541 dc.FillRectangle (SystemBrushes.ControlLightLight, area);
3542 else if (button.PartialPush)
3543 dc.FillRectangle (SystemBrushes.ControlLight, area);
3545 dc.FillRectangle (SystemBrushes.Control, area);
3548 void DrawToolBarDropDownArrow (Graphics dc, ToolBarButton button, bool is_flat)
3550 Rectangle rect = button.Rectangle;
3551 rect.X = button.Rectangle.Right - ToolBarDropDownWidth;
3552 rect.Width = ToolBarDropDownWidth;
3554 if (button.dd_pressed) {
3555 CPDrawBorder3D (dc, rect, Border3DStyle.SunkenOuter, all_sides);
3556 CPDrawBorder3D (dc, rect, Border3DStyle.SunkenInner, Border3DSide.Bottom | Border3DSide.Right);
3557 } else if (button.Pushed || button.Pressed)
3558 CPDrawBorder3D (dc, rect, Border3DStyle.Sunken, all_sides);
3561 CPDrawBorder3D (dc, rect, Border3DStyle.RaisedOuter, all_sides);
3563 CPDrawBorder3D (dc, rect, Border3DStyle.Raised, all_sides);
3565 PointF [] vertices = new PointF [3];
3566 PointF ddCenter = new PointF (rect.X + (rect.Width/2.0f), rect.Y + (rect.Height/2.0f));
3567 vertices [0].X = ddCenter.X - ToolBarDropDownArrowWidth / 2.0f + 0.5f;
3568 vertices [0].Y = ddCenter.Y;
3569 vertices [1].X = ddCenter.X + ToolBarDropDownArrowWidth / 2.0f + 0.5f;
3570 vertices [1].Y = ddCenter.Y;
3571 vertices [2].X = ddCenter.X + 0.5f; // 0.5 is added for adjustment
3572 vertices [2].Y = ddCenter.Y + ToolBarDropDownArrowHeight;
3573 dc.FillPolygon (SystemBrushes.ControlText, vertices);
3576 void DrawToolBarButtonContents (Graphics dc, ToolBar control, ToolBarButton button, StringFormat format)
3578 if (button.Image != null) {
3579 int x = button.ImageRectangle.X + ToolBarImageGripWidth;
3580 int y = button.ImageRectangle.Y + ToolBarImageGripWidth;
3582 dc.DrawImage (button.Image, x, y);
3584 CPDrawImageDisabled (dc, button.Image, x, y, ColorControl);
3588 dc.DrawString (button.Text, control.Font, SystemBrushes.ControlText, button.TextRectangle, format);
3590 CPDrawStringDisabled (dc, button.Text, control.Font, control.BackColor, button.TextRectangle, format);
3593 // Grip width for the ToolBar
3594 public override int ToolBarGripWidth {
3598 // Grip width for the Image on the ToolBarButton
3599 public override int ToolBarImageGripWidth {
3603 // width of the separator
3604 public override int ToolBarSeparatorWidth {
3608 // width of the dropdown arrow rect
3609 public override int ToolBarDropDownWidth {
3613 // width for the dropdown arrow on the ToolBarButton
3614 public override int ToolBarDropDownArrowWidth {
3618 // height for the dropdown arrow on the ToolBarButton
3619 public override int ToolBarDropDownArrowHeight {
3623 public override Size ToolBarDefaultSize {
3625 return new Size (100, 42);
3628 #endregion // ToolBar
3631 public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control) {
3632 dc.FillRectangle(SystemBrushes.Info, control.client_rect);
3633 dc.DrawRectangle(SystemPens.WindowFrame, 0, 0, control.Width-1, control.Height-1);
3634 dc.DrawString(control.text, control.Font, ResPool.GetSolidBrush(this.ColorInfoText), control.client_rect, control.string_format);
3637 public override Size ToolTipSize(ToolTip.ToolTipWindow tt, string text) {
3640 sizef = tt.DeviceContext.MeasureString(text, tt.Font);
3641 return new Size((int)sizef.Width+8, (int)sizef.Height+3); // Need space for the border
3643 #endregion // ToolTip
3646 private void DrawTrackBar_Vertical (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
3647 ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
3648 float ticks, int value_pos, bool mouse_value) {
3650 Point toptick_startpoint = new Point ();
3651 Point bottomtick_startpoint = new Point ();
3652 Point channel_startpoint = new Point ();
3654 float pixels_betweenticks;
3655 const int space_from_right = 8;
3656 const int space_from_left = 8;
3657 const int space_from_bottom = 11;
3658 Rectangle area = tb.ClientRectangle;
3660 switch (tb.TickStyle) {
3661 case TickStyle.BottomRight:
3662 case TickStyle.None:
3663 channel_startpoint.Y = 8;
3664 channel_startpoint.X = 9;
3665 bottomtick_startpoint.Y = 13;
3666 bottomtick_startpoint.X = 24;
3668 case TickStyle.TopLeft:
3669 channel_startpoint.Y = 8;
3670 channel_startpoint.X = 19;
3671 toptick_startpoint.Y = 13;
3672 toptick_startpoint.X = 8;
3674 case TickStyle.Both:
3675 channel_startpoint.Y = 8;
3676 channel_startpoint.X = 18;
3677 bottomtick_startpoint.Y = 13;
3678 bottomtick_startpoint.X = 32;
3679 toptick_startpoint.Y = 13;
3680 toptick_startpoint.X = 8;
3686 thumb_area.X = area.X + channel_startpoint.X;
3687 thumb_area.Y = area.Y + channel_startpoint.Y;
3688 thumb_area.Height = area.Height - space_from_right - space_from_left;
3689 thumb_area.Width = 4;
3692 dc.FillRectangle (SystemBrushes.ControlDark, channel_startpoint.X, channel_startpoint.Y,
3693 1, thumb_area.Height);
3695 dc.FillRectangle (SystemBrushes.ControlDarkDark, channel_startpoint.X + 1, channel_startpoint.Y,
3696 1, thumb_area.Height);
3698 dc.FillRectangle (SystemBrushes.ControlLight, channel_startpoint.X + 3, channel_startpoint.Y,
3699 1, thumb_area.Height);
3701 pixel_len = thumb_area.Height - 11;
3702 pixels_betweenticks = pixel_len / (tb.Maximum - tb.Minimum);
3704 /* Convert thumb position from mouse position to value*/
3706 if (value_pos < thumb_area.Bottom)
3707 value_pos = (int) ((thumb_area.Bottom - value_pos) / pixels_betweenticks);
3711 if (value_pos + tb.Minimum > tb.Maximum)
3712 value_pos = tb.Maximum - tb.Minimum;
3714 tb.Value = value_pos + tb.Minimum;
3717 // thumb_pos.Y = channel_startpoint.Y ; // + (int) (pixels_betweenticks * (float) value_pos);
3718 thumb_pos.Y = thumb_area.Bottom - space_from_bottom - (int) (pixels_betweenticks * (float) value_pos);
3720 /* Draw thumb fixed 10x22 size */
3721 thumb_pos.Width = 10;
3722 thumb_pos.Height = 22;
3724 switch (tb.TickStyle) {
3725 case TickStyle.BottomRight:
3726 case TickStyle.None: {
3727 thumb_pos.X = channel_startpoint.X - 8;
3729 Pen pen = SystemPens.ControlLight;
3730 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X , thumb_pos.Y + 10);
3731 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 16, thumb_pos.Y);
3732 dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y, thumb_pos.X + 16 + 4, thumb_pos.Y + 4);
3734 pen = SystemPens.ControlDark;
3735 dc.DrawLine (pen, thumb_pos.X +1, thumb_pos.Y + 9, thumb_pos.X +15, thumb_pos.Y +9);
3736 dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y + 9, thumb_pos.X +16 + 4, thumb_pos.Y +9 - 4);
3738 pen = SystemPens.ControlDarkDark;
3739 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X +16, thumb_pos.Y +10);
3740 dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y + 10, thumb_pos.X +16 + 5, thumb_pos.Y +10 - 5);
3742 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 16, 8);
3743 dc.FillRectangle (br_thumb, thumb_pos.X + 17, thumb_pos.Y + 2, 1, 6);
3744 dc.FillRectangle (br_thumb, thumb_pos.X + 18, thumb_pos.Y + 3, 1, 4);
3745 dc.FillRectangle (br_thumb, thumb_pos.X + 19, thumb_pos.Y + 4, 1, 2);
3749 case TickStyle.TopLeft: {
3750 thumb_pos.X = channel_startpoint.X - 10;
3752 Pen pen = SystemPens.ControlLight;
3753 dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X + 4 + 16, thumb_pos.Y);
3754 dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 4);
3756 pen = SystemPens.ControlDark;
3757 dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X + 4 + 16 , thumb_pos.Y+ 9);
3758 dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X, thumb_pos.Y + 5);
3759 dc.DrawLine (pen, thumb_pos.X + 19, thumb_pos.Y + 9, thumb_pos.X +19 , thumb_pos.Y+ 1);
3761 pen = SystemPens.ControlDarkDark;
3762 dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y+ 10, thumb_pos.X + 4 + 16, thumb_pos.Y+ 10);
3763 dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 10, thumb_pos.X -1, thumb_pos.Y+ 5);
3764 dc.DrawLine (pen, thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X+ 20, thumb_pos.Y + 10);
3766 dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 15, 8);
3767 dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 1, 6);
3768 dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 1, 4);
3769 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 1, 2);
3774 case TickStyle.Both: {
3775 thumb_pos.X = area.X + 10;
3777 Pen pen = SystemPens.ControlLight;
3778 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 9);
3779 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 19, thumb_pos.Y);
3781 pen = SystemPens.ControlDark;
3782 dc.DrawLine (pen, thumb_pos.X + 1, thumb_pos.Y + 9, thumb_pos.X+ 19, thumb_pos.Y + 9);
3783 dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y+ 1, thumb_pos.X + 19, thumb_pos.Y + 8);
3785 pen = SystemPens.ControlDarkDark;
3786 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X+ 20, thumb_pos.Y +10);
3787 dc.DrawLine (pen, thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X + 20, thumb_pos.Y+ 9);
3789 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 18, 8);
3798 pixel_len = thumb_area.Height - 11;
3799 pixels_betweenticks = pixel_len / ticks;
3801 thumb_area.X = thumb_pos.X;
3802 thumb_area.Y = channel_startpoint.Y;
3803 thumb_area.Width = thumb_pos.Height;
3806 Region outside = new Region (area);
3807 outside.Exclude (thumb_area);
3809 if (outside.IsVisible (clip_rectangle)) {
3810 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
3811 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
3813 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
3814 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
3815 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
3816 area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc);
3818 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
3819 area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc);
3823 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
3824 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
3826 pixel_len = thumb_area.Height - 11;
3827 pixels_betweenticks = pixel_len / ticks;
3829 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
3830 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
3831 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
3832 area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
3834 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
3835 area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
3847 Does not matter the size of the control, Win32 always draws:
3848 - Ticks starting from pixel 13, 8
3849 - Channel starting at pos 8, 19 and ends at Width - 8
3850 - Autosize makes always the control 40 pixels height
3851 - Ticks are draw at (channel.Witdh - 10) / (Maximum - Minimum)
3854 private void DrawTrackBar_Horizontal (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
3855 ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
3856 float ticks, int value_pos, bool mouse_value) {
3857 Point toptick_startpoint = new Point ();
3858 Point bottomtick_startpoint = new Point ();
3859 Point channel_startpoint = new Point ();
3861 float pixels_betweenticks;
3862 const int space_from_right = 8;
3863 const int space_from_left = 8;
3864 Rectangle area = tb.ClientRectangle;
3866 switch (tb.TickStyle) {
3867 case TickStyle.BottomRight:
3868 case TickStyle.None:
3869 channel_startpoint.X = 8;
3870 channel_startpoint.Y = 9;
3871 bottomtick_startpoint.X = 13;
3872 bottomtick_startpoint.Y = 24;
3874 case TickStyle.TopLeft:
3875 channel_startpoint.X = 8;
3876 channel_startpoint.Y = 19;
3877 toptick_startpoint.X = 13;
3878 toptick_startpoint.Y = 8;
3880 case TickStyle.Both:
3881 channel_startpoint.X = 8;
3882 channel_startpoint.Y = 18;
3883 bottomtick_startpoint.X = 13;
3884 bottomtick_startpoint.Y = 32;
3885 toptick_startpoint.X = 13;
3886 toptick_startpoint.Y = 8;
3892 thumb_area.X = area.X + channel_startpoint.X;
3893 thumb_area.Y = area.Y + channel_startpoint.Y;
3894 thumb_area.Width = area.Width - space_from_right - space_from_left;
3895 thumb_area.Height = 4;
3898 dc.FillRectangle (SystemBrushes.ControlDark, channel_startpoint.X, channel_startpoint.Y,
3899 thumb_area.Width, 1);
3901 dc.FillRectangle (SystemBrushes.ControlDarkDark, channel_startpoint.X, channel_startpoint.Y + 1,
3902 thumb_area.Width, 1);
3904 dc.FillRectangle (SystemBrushes.ControlLight, channel_startpoint.X, channel_startpoint.Y +3,
3905 thumb_area.Width, 1);
3907 pixel_len = thumb_area.Width - 11;
3908 pixels_betweenticks = pixel_len / (tb.Maximum - tb.Minimum);
3910 /* Convert thumb position from mouse position to value*/
3912 if (value_pos >= channel_startpoint.X)
3913 value_pos = (int)(((float) (value_pos - channel_startpoint.X)) / pixels_betweenticks);
3917 if (value_pos + tb.Minimum > tb.Maximum)
3918 value_pos = tb.Maximum - tb.Minimum;
3920 tb.Value = value_pos + tb.Minimum;
3923 thumb_pos.X = channel_startpoint.X + (int) (pixels_betweenticks * (float) value_pos);
3925 /* Draw thumb fixed 10x22 size */
3926 thumb_pos.Width = 10;
3927 thumb_pos.Height = 22;
3929 switch (tb.TickStyle) {
3930 case TickStyle.BottomRight:
3931 case TickStyle.None: {
3932 thumb_pos.Y = channel_startpoint.Y - 8;
3934 Pen pen = SystemPens.ControlLight;
3935 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y);
3936 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 16);
3937 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 16, thumb_pos.X + 4, thumb_pos.Y + 16 + 4);
3939 pen = SystemPens.ControlDark;
3940 dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X +9, thumb_pos.Y +15);
3941 dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 16, thumb_pos.X +9 - 4, thumb_pos.Y +16 + 4);
3943 pen = SystemPens.ControlDarkDark;
3944 dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y +16);
3945 dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 16, thumb_pos.X +10 - 5, thumb_pos.Y +16 + 5);
3947 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 16);
3948 dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 17, 6, 1);
3949 dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 18, 4, 1);
3950 dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 19, 2, 1);
3953 case TickStyle.TopLeft: {
3954 thumb_pos.Y = channel_startpoint.Y - 10;
3956 Pen pen = SystemPens.ControlLight;
3957 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X, thumb_pos.Y + 4 + 16);
3958 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X + 4, thumb_pos.Y);
3960 pen = SystemPens.ControlDark;
3961 dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 9, thumb_pos.Y + 4 + 16);
3962 dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y);
3963 dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 19, thumb_pos.X + 1 , thumb_pos.Y +19);
3965 pen = SystemPens.ControlDarkDark;
3966 dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 10, thumb_pos.Y + 4 + 16);
3967 dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y -1);
3968 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 10, thumb_pos.Y + 20);
3970 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 8, 15);
3971 dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 6, 1);
3972 dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 4, 1);
3973 dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 2, 1);
3977 case TickStyle.Both: {
3978 thumb_pos.Y = area.Y + 10;
3980 Pen pen = SystemPens.ControlLight;
3981 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 9, thumb_pos.Y);
3982 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 19);
3984 pen = SystemPens.ControlDark;
3985 dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 19);
3986 dc.DrawLine (pen, thumb_pos.X + 1, thumb_pos.Y + 10, thumb_pos.X + 8, thumb_pos.Y + 19);
3988 pen = SystemPens.ControlDarkDark;
3989 dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y + 20);
3990 dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 9, thumb_pos.Y + 20);
3992 dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 18);
4001 pixel_len = thumb_area.Width - 11;
4002 pixels_betweenticks = pixel_len / ticks;
4005 thumb_area.Y = thumb_pos.Y;
4006 thumb_area.X = channel_startpoint.X;
4007 thumb_area.Height = thumb_pos.Height;
4008 Region outside = new Region (area);
4009 outside.Exclude (thumb_area);
4011 if (outside.IsVisible (clip_rectangle)) {
4012 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
4013 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
4015 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
4016 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
4017 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
4018 area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3);
4020 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
4021 area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2);
4025 if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
4026 ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
4028 for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
4029 if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
4030 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
4031 area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y);
4033 dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
4034 area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
4042 public override void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb)
4047 float ticks = (tb.Maximum - tb.Minimum) / tb.tickFrequency; /* N of ticks draw*/
4049 Rectangle thumb_pos = tb.ThumbPos;
4050 Rectangle thumb_area = tb.ThumbArea;
4052 if (tb.thumb_pressed) {
4053 value_pos = tb.thumb_mouseclick;
4056 value_pos = tb.Value - tb.Minimum;
4057 mouse_value = false;
4060 area = tb.ClientRectangle;
4062 if (tb.thumb_pressed == true) {
4063 br_thumb = (Brush) ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControlLight, ColorControl);
4065 br_thumb = SystemBrushes.Control;
4069 /* Control Background */
4070 if (tb.BackColor == DefaultControlBackColor) {
4071 dc.FillRectangle (SystemBrushes.Control, clip_rectangle);
4073 dc.FillRectangle (ResPool.GetSolidBrush (tb.BackColor), clip_rectangle);
4078 Brush brush = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black);
4079 dc.FillRectangle (brush, area.X, area.Y, area.Width - 1, 1);
4080 dc.FillRectangle (brush, area.X, area.Y + area.Height - 1, area.Width - 1, 1);
4081 dc.FillRectangle (brush, area.X, area.Y, 1, area.Height - 1);
4082 dc.FillRectangle (brush, area.X + area.Width - 1, area.Y, 1, area.Height - 1);
4085 if (tb.Orientation == Orientation.Vertical) {
4086 DrawTrackBar_Vertical (dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
4087 br_thumb, ticks, value_pos, mouse_value);
4090 DrawTrackBar_Horizontal (dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
4091 br_thumb, ticks, value_pos, mouse_value);
4094 tb.ThumbPos = thumb_pos;
4095 tb.ThumbArea = thumb_area;
4098 public override Size TrackBarDefaultSize {
4100 return new Size (104, 42);
4104 #endregion // TrackBar
4107 public override Size VScrollBarDefaultSize {
4109 return new Size (this.ScrollBarButtonSize, 80);
4112 #endregion // VScrollBar
4115 public override Size TreeViewDefaultSize {
4117 return new Size (121, 97);
4123 #region ControlPaint
4124 public override void CPDrawBorder (Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
4125 ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
4126 Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
4127 int bottomWidth, ButtonBorderStyle bottomStyle) {
4128 DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom-1, leftWidth, leftColor, leftStyle, Border3DSide.Left);
4129 DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Right-1, bounds.Top, topWidth, topColor, topStyle, Border3DSide.Top);
4130 DrawBorderInternal(graphics, bounds.Right-1, bounds.Top, bounds.Right-1, bounds.Bottom-1, rightWidth, rightColor, rightStyle, Border3DSide.Right);
4131 DrawBorderInternal(graphics, bounds.Left, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1, bottomWidth, bottomColor, bottomStyle, Border3DSide.Bottom);
4134 public override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) {
4135 CPDrawBorder3D(graphics, rectangle, style, sides, ColorControl);
4138 protected virtual void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color)
4141 Pen penTopLeftInner;
4143 Pen penBottomRightInner;
4144 Rectangle rect= new Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
4145 bool is_ColorControl = control_color == ColorControl ? true : false;
4147 if ((style & Border3DStyle.Adjust) != 0) {
4154 penTopLeft = penTopLeftInner = penBottomRight = penBottomRightInner = is_ColorControl ? SystemPens.Control : ResPool.GetPen (control_color);
4156 CPColor cpcolor = CPColor.Empty;
4158 if (!is_ColorControl)
4159 cpcolor = ResPool.GetCPColor (control_color);
4162 case Border3DStyle.Raised:
4163 penTopLeftInner = is_ColorControl ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
4164 penBottomRight = is_ColorControl ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
4165 penBottomRightInner = is_ColorControl ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
4167 case Border3DStyle.Sunken:
4168 penTopLeft = is_ColorControl ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
4169 penTopLeftInner = is_ColorControl ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
4170 penBottomRight = is_ColorControl ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
4172 case Border3DStyle.Etched:
4173 penTopLeft = penBottomRightInner = is_ColorControl ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
4174 penTopLeftInner = penBottomRight = is_ColorControl ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
4176 case Border3DStyle.RaisedOuter:
4177 penBottomRight = is_ColorControl ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
4179 case Border3DStyle.SunkenOuter:
4180 penTopLeft = is_ColorControl ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
4181 penBottomRight = is_ColorControl ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
4183 case Border3DStyle.RaisedInner:
4184 penTopLeft = is_ColorControl ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
4185 penBottomRight = is_ColorControl ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
4187 case Border3DStyle.SunkenInner:
4188 penTopLeft = is_ColorControl ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
4190 case Border3DStyle.Flat:
4191 penTopLeft = penBottomRight = is_ColorControl ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
4193 case Border3DStyle.Bump:
4194 penTopLeftInner = penBottomRight = is_ColorControl ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
4200 if ((sides & Border3DSide.Middle) != 0) {
4201 Brush brush = is_ColorControl ? SystemBrushes.Control : ResPool.GetSolidBrush (control_color);
4202 graphics.FillRectangle (brush, rect);
4205 if ((sides & Border3DSide.Left) != 0) {
4206 graphics.DrawLine (penTopLeft, rect.Left, rect.Bottom - 2, rect.Left, rect.Top);
4207 graphics.DrawLine (penTopLeftInner, rect.Left + 1, rect.Bottom - 2, rect.Left + 1, rect.Top);
4210 if ((sides & Border3DSide.Top) != 0) {
4211 graphics.DrawLine (penTopLeft, rect.Left, rect.Top, rect.Right - 2, rect.Top);
4212 graphics.DrawLine (penTopLeftInner, rect.Left + 1, rect.Top + 1, rect.Right - 3, rect.Top + 1);
4215 if ((sides & Border3DSide.Right) != 0) {
4216 graphics.DrawLine (penBottomRight, rect.Right - 1, rect.Top, rect.Right - 1, rect.Bottom - 1);
4217 graphics.DrawLine (penBottomRightInner, rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 2);
4220 if ((sides & Border3DSide.Bottom) != 0) {
4221 graphics.DrawLine (penBottomRight, rect.Left, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
4222 graphics.DrawLine (penBottomRightInner, rect.Left + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2);
4226 public override void CPDrawButton (Graphics dc, Rectangle rectangle, ButtonState state)
4228 // sadly enough, the rectangle gets always filled with a hatchbrush
4229 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (ColorControl.R + 3, ColorControl.G, ColorControl.B), ColorControl), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2);
4231 if ((state & ButtonState.All) == ButtonState.All || ((state & ButtonState.Checked) == ButtonState.Checked && (state & ButtonState.Flat) == ButtonState.Flat)) {
4232 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControlLight, ColorControl), rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4);
4234 dc.DrawRectangle (SystemPens.ControlDark, rectangle.X, rectangle.Y, rectangle.Width - 1, rectangle.Height - 1);
4236 if ((state & ButtonState.Flat) == ButtonState.Flat) {
4237 dc.DrawRectangle (SystemPens.ControlDark, rectangle.X, rectangle.Y, rectangle.Width - 1, rectangle.Height - 1);
4239 if ((state & ButtonState.Checked) == ButtonState.Checked) {
4240 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControlLight, ColorControl), rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4);
4242 Pen pen = SystemPens.ControlDarkDark;
4243 dc.DrawLine (pen, rectangle.X, rectangle.Y, rectangle.X, rectangle.Bottom - 2);
4244 dc.DrawLine (pen, rectangle.X + 1, rectangle.Y, rectangle.Right - 2, rectangle.Y);
4246 pen = SystemPens.ControlDark;
4247 dc.DrawLine (pen, rectangle.X + 1, rectangle.Y + 1, rectangle.X + 1, rectangle.Bottom - 3);
4248 dc.DrawLine (pen, rectangle.X + 2, rectangle.Y + 1, rectangle.Right - 3, rectangle.Y + 1);
4250 pen = SystemPens.ControlLight;
4251 dc.DrawLine (pen, rectangle.X, rectangle.Bottom - 1, rectangle.Right - 2, rectangle.Bottom - 1);
4252 dc.DrawLine (pen, rectangle.Right - 1, rectangle.Y, rectangle.Right - 1, rectangle.Bottom - 1);
4254 if (((state & ButtonState.Pushed) == ButtonState.Pushed) && ((state & ButtonState.Normal) == ButtonState.Normal)) {
4255 Pen pen = SystemPens.ControlDarkDark;
4256 dc.DrawLine (pen, rectangle.X, rectangle.Y, rectangle.X, rectangle.Bottom - 2);
4257 dc.DrawLine (pen, rectangle.X + 1, rectangle.Y, rectangle.Right - 2, rectangle.Y);
4259 pen = SystemPens.ControlDark;
4260 dc.DrawLine (pen, rectangle.X + 1, rectangle.Y + 1, rectangle.X + 1, rectangle.Bottom - 3);
4261 dc.DrawLine (pen, rectangle.X + 2, rectangle.Y + 1, rectangle.Right - 3, rectangle.Y + 1);
4263 pen = SystemPens.ControlLight;
4264 dc.DrawLine (pen, rectangle.X, rectangle.Bottom - 1, rectangle.Right - 2, rectangle.Bottom - 1);
4265 dc.DrawLine (pen, rectangle.Right - 1, rectangle.Y, rectangle.Right - 1, rectangle.Bottom - 1);
4267 if (((state & ButtonState.Inactive) == ButtonState.Inactive) || ((state & ButtonState.Normal) == ButtonState.Normal)) {
4268 Pen pen = SystemPens.ControlLight;
4269 dc.DrawLine (pen, rectangle.X, rectangle.Y, rectangle.Right - 2, rectangle.Y);
4270 dc.DrawLine (pen, rectangle.X, rectangle.Y, rectangle.X, rectangle.Bottom - 2);
4272 pen = SystemPens.ControlDark;
4273 dc.DrawLine (pen, rectangle.X + 1, rectangle.Bottom - 2, rectangle.Right - 2, rectangle.Bottom - 2);
4274 dc.DrawLine (pen, rectangle.Right - 2, rectangle.Y + 1, rectangle.Right - 2, rectangle.Bottom - 3);
4276 pen = SystemPens.ControlDarkDark;
4277 dc.DrawLine (pen, rectangle.X, rectangle.Bottom - 1, rectangle.Right - 1, rectangle.Bottom - 1);
4278 dc.DrawLine (pen, rectangle.Right - 1, rectangle.Y, rectangle.Right - 1, rectangle.Bottom - 2);
4283 public override void CPDrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state) {
4284 Rectangle captionRect;
4287 CPDrawButton(graphics, rectangle, state);
4289 if (rectangle.Width<rectangle.Height) {
4290 captionRect=new Rectangle(rectangle.X+1, rectangle.Y+rectangle.Height/2-rectangle.Width/2+1, rectangle.Width-4, rectangle.Width-4);
4292 captionRect=new Rectangle(rectangle.X+rectangle.Width/2-rectangle.Height/2+1, rectangle.Y+1, rectangle.Height-4, rectangle.Height-4);
4295 if ((state & ButtonState.Pushed)!=0) {
4296 captionRect=new Rectangle(rectangle.X+2, rectangle.Y+2, rectangle.Width-3, rectangle.Height-3);
4299 /* Make sure we've got at least a line width of 1 */
4300 lineWidth=Math.Max(1, captionRect.Width/7);
4303 case CaptionButton.Close: {
4306 if ((state & ButtonState.Inactive)!=0) {
4307 pen = ResPool.GetSizedPen (ColorControlLight, lineWidth);
4308 DrawCaptionHelper(graphics, ColorControlLight, pen, lineWidth, 1, captionRect, button);
4310 pen = ResPool.GetSizedPen (ColorControlDark, lineWidth);
4311 DrawCaptionHelper(graphics, ColorControlDark, pen, lineWidth, 0, captionRect, button);
4314 pen = ResPool.GetSizedPen (ColorControlText, lineWidth);
4315 DrawCaptionHelper(graphics, ColorControlText, pen, lineWidth, 0, captionRect, button);
4320 case CaptionButton.Help:
4321 case CaptionButton.Maximize:
4322 case CaptionButton.Minimize:
4323 case CaptionButton.Restore: {
4324 if ((state & ButtonState.Inactive)!=0) {
4325 DrawCaptionHelper(graphics, ColorControlLight, SystemPens.ControlLightLight, lineWidth, 1, captionRect, button);
4327 DrawCaptionHelper(graphics, ColorControlDark, SystemPens.ControlDark, lineWidth, 0, captionRect, button);
4330 DrawCaptionHelper(graphics, ColorControlText, SystemPens.ControlText, lineWidth, 0, captionRect, button);
4337 public override void CPDrawCheckBox (Graphics dc, Rectangle rectangle, ButtonState state)
4339 Pen check_pen = SystemPens.ControlDarkDark;
4341 Rectangle cb_rect = new Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
4343 if ((state & ButtonState.All) == ButtonState.All) {
4345 cb_rect.Height -= 2;
4347 dc.FillRectangle (SystemBrushes.Control, cb_rect.X, cb_rect.Y, cb_rect.Width - 1, cb_rect.Height - 1);
4348 dc.DrawRectangle (SystemPens.ControlDark, cb_rect.X, cb_rect.Y, cb_rect.Width - 1, cb_rect.Height - 1);
4350 check_pen = SystemPens.ControlDark;
4352 if ((state & ButtonState.Flat) == ButtonState.Flat) {
4354 cb_rect.Height -= 2;
4356 dc.FillRectangle (SystemBrushes.ControlLight, cb_rect.X, cb_rect.Y, cb_rect.Width - 1, cb_rect.Height - 1);
4357 dc.DrawRectangle (SystemPens.ControlDark, cb_rect.X, cb_rect.Y, cb_rect.Width - 1, cb_rect.Height - 1);
4360 cb_rect.Height -= 1;
4362 int check_box_visible_size = (cb_rect.Height > cb_rect.Width) ? cb_rect.Width : cb_rect.Height;
4364 int x_pos = Math.Max (0, cb_rect.X + (cb_rect.Width / 2) - check_box_visible_size / 2);
4365 int y_pos = Math.Max (0, cb_rect.Y + (cb_rect.Height / 2) - check_box_visible_size / 2);
4367 Rectangle rect = new Rectangle (x_pos, y_pos, check_box_visible_size, check_box_visible_size);
4369 if (((state & ButtonState.Pushed) == ButtonState.Pushed) || ((state & ButtonState.Inactive) == ButtonState.Inactive)) {
4370 dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (ColorControl.R + 3, ColorControl.G, ColorControl.B), ColorControl), rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3);
4372 dc.FillRectangle (SystemBrushes.ControlLightLight, rect.X + 2, rect.Y + 2, rect.Width - 3, rect.Height - 3);
4374 Pen pen = SystemPens.ControlDark;
4375 dc.DrawLine (pen, rect.X, rect.Y, rect.X, rect.Bottom - 1);
4376 dc.DrawLine (pen, rect.X + 1, rect.Y, rect.Right - 1, rect.Y);
4378 pen = SystemPens.ControlDarkDark;
4379 dc.DrawLine (pen, rect.X + 1, rect.Y + 1, rect.X + 1, rect.Bottom - 2);
4380 dc.DrawLine (pen, rect.X + 2, rect.Y + 1, rect.Right - 2, rect.Y + 1);
4382 pen = SystemPens.ControlLight;
4383 dc.DrawLine (pen, rect.Right, rect.Y, rect.Right, rect.Bottom);
4384 dc.DrawLine (pen, rect.X, rect.Bottom, rect.Right, rect.Bottom);
4386 // oh boy, matching ms is like fighting against windmills
4387 using (Pen h_pen = new Pen (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (ColorControl.R + 3, ColorControl.G, ColorControl.B), ColorControl))) {
4388 dc.DrawLine (h_pen, rect.X + 1, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
4389 dc.DrawLine (h_pen, rect.Right - 1, rect.Y + 1, rect.Right - 1, rect.Bottom - 1);
4392 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
4393 check_pen = SystemPens.ControlDark;
4396 if ((state & ButtonState.Checked) == ButtonState.Checked) {
4397 int check_size = (cb_rect.Height > cb_rect.Width) ? cb_rect.Width / 2: cb_rect.Height / 2;
4399 if (check_size < 7) {
4400 int lineWidth = Math.Max (3, check_size / 3);
4401 int Scale = Math.Max (1, check_size / 9);
4403 Rectangle rect = new Rectangle (cb_rect.X + (cb_rect.Width / 2) - (check_size / 2) - 1, cb_rect.Y + (cb_rect.Height / 2) - (check_size / 2) - 1,
4404 check_size, check_size);
4406 for (int i = 0; i < lineWidth; i++) {
4407 dc.DrawLine (check_pen, rect.Left + lineWidth / 2, rect.Top + lineWidth + i, rect.Left + lineWidth / 2 + 2 * Scale, rect.Top + lineWidth + 2 * Scale + i);
4408 dc.DrawLine (check_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);
4411 int lineWidth = Math.Max (3, check_size / 3) + 1;
4413 int x_half = cb_rect.Width / 2;
4414 int y_half = cb_rect.Height / 2;
4416 Rectangle rect = new Rectangle (cb_rect.X + x_half - (check_size / 2) - 1, cb_rect.Y + y_half - (check_size / 2),
4417 check_size, check_size);
4419 int gradient_left = check_size / 3;
4420 int gradient_right = check_size - gradient_left - 1;
4423 for (int i = 0; i < lineWidth; i++) {
4424 dc.DrawLine (check_pen, rect.X, rect.Bottom - 1 - gradient_left - i, rect.X + gradient_left, rect.Bottom - 1 - i);
4425 dc.DrawLine (check_pen, rect.X + gradient_left, rect.Bottom - 1 - i, rect.Right - 1, rect.Bottom - i - 1 - gradient_right);
4431 public override void CPDrawComboButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
4432 Point[] arrow = new Point[3];
4442 if ((state & ButtonState.Checked)!=0) {
4443 graphics.FillRectangle(ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControlLightLight, ColorControlLight),rectangle);
4446 if ((state & ButtonState.Flat)!=0) {
4447 ControlPaint.DrawBorder(graphics, rectangle, ColorControlDark, ButtonBorderStyle.Solid);
4449 if ((state & (ButtonState.Pushed | ButtonState.Checked))!=0) {
4450 // this needs to render like a pushed button - jba
4451 // CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
4452 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
4453 graphics.DrawRectangle (SystemPens.ControlDark, trace_rectangle);
4455 CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
4459 rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
4460 centerX=rect.Left+rect.Width/2;
4461 centerY=rect.Top+rect.Height/2;
4462 shiftX=Math.Max(1, rect.Width/8);
4463 shiftY=Math.Max(1, rect.Height/8);
4465 if ((state & ButtonState.Pushed)!=0) {
4472 P1=new Point(rect.Left, centerY);
4473 P2=new Point(rect.Right, centerY);
4474 P3=new Point(centerX, rect.Bottom);
4480 /* Draw the arrow */
4481 if ((state & ButtonState.Inactive)!=0) {
4482 graphics.FillPolygon(SystemBrushes.ControlLightLight, arrow, FillMode.Winding);
4484 /* Move away from the shadow */
4494 graphics.FillPolygon(SystemBrushes.ControlDark, arrow, FillMode.Winding);
4496 graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding);
4501 public override void CPDrawContainerGrabHandle (Graphics graphics, Rectangle bounds) {
4503 // Pen pen = ResPool.GetPen (Color.Black);
4504 Pen pen = SystemPens.ControlDarkDark;
4505 Rectangle rect = new Rectangle(bounds.X, bounds.Y, bounds.Width-1, bounds.Height-1); // Dunno why, but MS does it that way, too
4509 graphics.FillRectangle(SystemBrushes.ControlText, rect);
4510 graphics.DrawRectangle(pen, rect);
4512 X=rect.X+rect.Width/2;
4513 Y=rect.Y+rect.Height/2;
4515 /* Draw the cross */
4516 graphics.DrawLine(pen, X, rect.Y+2, X, rect.Bottom-2);
4517 graphics.DrawLine(pen, rect.X+2, Y, rect.Right-2, Y);
4519 /* Draw 'arrows' for vertical lines */
4520 graphics.DrawLine(pen, X-1, rect.Y+3, X+1, rect.Y+3);
4521 graphics.DrawLine(pen, X-1, rect.Bottom-3, X+1, rect.Bottom-3);
4523 /* Draw 'arrows' for horizontal lines */
4524 graphics.DrawLine(pen, rect.X+3, Y-1, rect.X+3, Y+1);
4525 graphics.DrawLine(pen, rect.Right-3, Y-1, rect.Right-3, Y+1);
4529 public virtual void DrawFlatStyleFocusRectangle (Graphics graphics, Rectangle rectangle, ButtonBase button, Color foreColor, Color backColor) {
4530 // make a rectange to trace around border of the button
4531 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
4533 Color outerColor = foreColor;
4534 // adjust focus color according to the flatstyle
4535 if (button.FlatStyle == FlatStyle.Popup && !button.is_pressed) {
4536 outerColor = (backColor == ColorControl) ? ControlPaint.Dark(ColorControl) : ColorControlText;
4539 // draw the outer rectangle
4540 graphics.DrawRectangle (ResPool.GetPen (outerColor), trace_rectangle);
4542 // draw the inner rectangle
4543 if (button.FlatStyle == FlatStyle.Popup) {
4544 DrawInnerFocusRectangle (graphics, Rectangle.Inflate (rectangle, -4, -4), backColor);
4546 // draw a flat inner rectangle
4547 Pen pen = ResPool.GetPen (ControlPaint.LightLight (backColor));
4548 graphics.DrawRectangle(pen, Rectangle.Inflate (trace_rectangle, -4, -4));
4552 public virtual void DrawInnerFocusRectangle(Graphics graphics, Rectangle rectangle, Color backColor)
4554 // make a rectange to trace around border of the button
4555 Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
4557 #if NotUntilCairoIsFixed
4558 Color colorBackInverted = Color.FromArgb (Math.Abs (backColor.R-255), Math.Abs (backColor.G-255), Math.Abs (backColor.B-255));
4559 DashStyle oldStyle; // used for caching old penstyle
4560 Pen pen = ResPool.GetPen (colorBackInverted);
4562 oldStyle = pen.DashStyle;
4563 pen.DashStyle = DashStyle.Dot;
4565 graphics.DrawRectangle (pen, trace_rectangle);
4566 pen.DashStyle = oldStyle;
4568 CPDrawFocusRectangle(graphics, trace_rectangle, Color.Wheat, backColor);
4573 public override void CPDrawFocusRectangle (Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor)
4575 Rectangle rect = rectangle;
4579 if (backColor.GetBrightness () >= 0.5) {
4580 foreColor = Color.Transparent;
4581 backColor = Color.Black;
4584 backColor = Color.FromArgb (Math.Abs (backColor.R-255), Math.Abs (backColor.G-255), Math.Abs (backColor.B-255));
4585 foreColor = Color.Black;
4588 brush = ResPool.GetHatchBrush (HatchStyle.Percent50, backColor, foreColor);
4589 pen = new Pen (brush, 1);
4594 graphics.DrawRectangle (pen, rect);
4598 public override void CPDrawGrabHandle (Graphics graphics, Rectangle rectangle, bool primary, bool enabled) {
4602 if (primary==true) {
4603 pen = ResPool.GetPen (Color.Black);
4604 if (enabled==true) {
4605 sb=SystemBrushes.ControlText;
4607 sb = SystemBrushes.Control;
4610 pen = ResPool.GetPen(Color.White);
4611 if (enabled==true) {
4612 sb=ResPool.GetSolidBrush (Color.Black);
4614 sb = SystemBrushes.Control;
4617 graphics.FillRectangle(sb, rectangle);
4618 graphics.DrawRectangle(pen, rectangle);
4622 public override void CPDrawGrid (Graphics graphics, Rectangle area, Size pixelsBetweenDots, Color backColor) {
4628 ControlPaint.Color2HBS(backColor, out h, out b, out s);
4631 foreColor=Color.Black;
4633 foreColor=Color.White;
4638 Bitmap bitmap = new Bitmap(area.Width, area.Height, graphics);
4640 for (int x=0; x<area.Width; x+=pixelsBetweenDots.Width) {
4641 for (int y=0; y<area.Height; y+=pixelsBetweenDots.Height) {
4642 bitmap.SetPixel(x, y, foreColor);
4645 graphics.DrawImage(bitmap, area.X, area.Y, area.Width, area.Height);
4648 #if correct_but_needs_libgdiplus_fix_bug_nr_78059
4649 using (Pen pen = new Pen (foreColor)) {
4650 pen.DashPattern = new float [] {1.0f, pixelsBetweenDots.Width - 1};
4652 for (int y = area.Y; y < area.Bottom; y += pixelsBetweenDots.Height - 1)
4653 graphics.DrawLine (pen, area.X, y, area.Right - 1, y);
4658 public override void CPDrawImageDisabled (Graphics graphics, Image image, int x, int y, Color background) {
4660 Microsoft seems to ignore the background and simply make
4661 the image grayscale. At least when having > 256 colors on
4665 if (imagedisabled_attributes == null) {
4666 imagedisabled_attributes = new ImageAttributes ();
4667 ColorMatrix colorMatrix=new ColorMatrix(new float[][] {
4668 // This table would create a perfect grayscale image, based on luminance
4669 // new float[]{0.3f,0.3f,0.3f,0,0},
4670 // new float[]{0.59f,0.59f,0.59f,0,0},
4671 // new float[]{0.11f,0.11f,0.11f,0,0},
4672 // new float[]{0,0,0,1,0,0},
4673 // new float[]{0,0,0,0,1,0},
4674 // new float[]{0,0,0,0,0,1}
4676 // This table generates a image that is grayscaled and then
4677 // brightened up. Seems to match MS close enough.
4678 new float[]{0.2f,0.2f,0.2f,0,0},
4679 new float[]{0.41f,0.41f,0.41f,0,0},
4680 new float[]{0.11f,0.11f,0.11f,0,0},
4681 new float[]{0.15f,0.15f,0.15f,1,0,0},
4682 new float[]{0.15f,0.15f,0.15f,0,1,0},
4683 new float[]{0.15f,0.15f,0.15f,0,0,1}
4686 imagedisabled_attributes.SetColorMatrix (colorMatrix);
4689 graphics.DrawImage(image, new Rectangle(x, y, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imagedisabled_attributes);
4694 public override void CPDrawLockedFrame (Graphics graphics, Rectangle rectangle, bool primary) {
4699 penBorder = ResPool.GetSizedPen (Color.White, 2);
4700 penInside = ResPool.GetPen (Color.Black);
4702 penBorder = ResPool.GetSizedPen (Color.Black, 2);
4703 penInside = ResPool.GetPen (Color.White);
4705 penBorder.Alignment=PenAlignment.Inset;
4706 penInside.Alignment=PenAlignment.Inset;
4708 graphics.DrawRectangle(penBorder, rectangle);
4709 graphics.DrawRectangle(penInside, rectangle.X+2, rectangle.Y+2, rectangle.Width-5, rectangle.Height-5);
4713 public override void CPDrawMenuGlyph (Graphics graphics, Rectangle rectangle, MenuGlyph glyph, Color color) {
4717 Brush brush = ResPool.GetSolidBrush (color);
4720 case MenuGlyph.Arrow: {
4721 Point[] arrow = new Point[3];
4729 rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
4730 centerX=rect.Left+rect.Width/2;
4731 centerY=rect.Top+rect.Height/2;
4732 shiftX=Math.Max(1, rect.Width/8);
4737 P1=new Point(centerX, rect.Top-1);
4738 P2=new Point(centerX, rect.Bottom);
4739 P3=new Point(rect.Right, centerY);
4745 graphics.FillPolygon(brush, arrow, FillMode.Winding);
4750 case MenuGlyph.Bullet: {
4752 lineWidth=Math.Max(2, rectangle.Width/3);
4753 rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
4755 graphics.FillEllipse(brush, rect);
4760 case MenuGlyph.Checkmark: {
4762 Pen pen = ResPool.GetPen (color);
4764 lineWidth=Math.Max(2, rectangle.Width/6);
4765 Scale=Math.Max(1, rectangle.Width/12);
4767 rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
4769 for (int i=0; i<lineWidth; i++) {
4770 graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
4771 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);
4779 public override void CPDrawRadioButton (Graphics dc, Rectangle rectangle, ButtonState state)
4781 CPColor cpcolor = ResPool.GetCPColor (ColorControl);
4783 Color dot_color = Color.Black;
4785 Color top_left_outer = Color.Black;
4786 Color top_left_inner = Color.Black;
4787 Color bottom_right_outer = Color.Black;
4788 Color bottom_right_inner = Color.Black;
4790 int ellipse_diameter = (rectangle.Width > rectangle.Height) ? (int)(rectangle.Height * 0.9f) : (int)(rectangle.Width * 0.9f);
4791 int radius = ellipse_diameter / 2;
4793 Rectangle rb_rect = new Rectangle (rectangle.X + (rectangle.Width / 2) - radius, rectangle.Y + (rectangle.Height / 2) - radius, ellipse_diameter, ellipse_diameter);
4797 if ((state & ButtonState.All) == ButtonState.All) {
4798 brush = ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (ColorControl.R + 3, ColorControl.G, ColorControl.B), ColorControl);
4799 dot_color = cpcolor.Dark;
4801 if ((state & ButtonState.Flat) == ButtonState.Flat) {
4802 if (((state & ButtonState.Inactive) == ButtonState.Inactive) || ((state & ButtonState.Pushed) == ButtonState.Pushed))
4803 brush = ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (ColorControl.R + 3, ColorControl.G, ColorControl.B), ColorControl);
4805 brush = SystemBrushes.ControlLightLight;
4807 if (((state & ButtonState.Inactive) == ButtonState.Inactive) || ((state & ButtonState.Pushed) == ButtonState.Pushed))
4808 brush = ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (ColorControl.R + 3, ColorControl.G, ColorControl.B), ColorControl);
4810 brush = SystemBrushes.ControlLightLight;
4812 top_left_outer = cpcolor.Dark;
4813 top_left_inner = cpcolor.DarkDark;
4814 bottom_right_outer = cpcolor.Light;
4815 bottom_right_inner = Color.Transparent;
4817 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
4818 dot_color = cpcolor.Dark;
4821 dc.FillEllipse (brush, rb_rect.X + 1, rb_rect.Y + 1, ellipse_diameter - 1, ellipse_diameter - 1);
4823 int line_width = Math.Max (1, (int)(ellipse_diameter * 0.08f));
4825 dc.DrawArc (ResPool.GetSizedPen (top_left_outer, line_width), rb_rect, 135.0f, 180.0f);
4826 dc.DrawArc (ResPool.GetSizedPen (top_left_inner, line_width), Rectangle.Inflate (rb_rect, -line_width, -line_width), 135.0f, 180.0f);
4827 dc.DrawArc (ResPool.GetSizedPen (bottom_right_outer, line_width), rb_rect, 315.0f, 180.0f);
4829 if (bottom_right_inner != Color.Transparent)
4830 dc.DrawArc (ResPool.GetSizedPen (bottom_right_inner, line_width), Rectangle.Inflate (rb_rect, -line_width, -line_width), 315.0f, 180.0f);
4832 using (Pen h_pen = new Pen (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (ColorControl.R + 3, ColorControl.G, ColorControl.B), ColorControl), line_width)) {
4833 dc.DrawArc (h_pen, Rectangle.Inflate (rb_rect, -line_width, -line_width), 315.0f, 180.0f);
4836 if ((state & ButtonState.Checked) == ButtonState.Checked) {
4837 int inflate = line_width * 4;
4838 Rectangle tmp = Rectangle.Inflate (rb_rect, -inflate, -inflate);
4839 if (rectangle.Height > 13) {
4843 dc.FillEllipse (ResPool.GetSolidBrush (dot_color), tmp);
4845 Pen pen = ResPool.GetPen (dot_color);
4846 dc.DrawLine (pen, tmp.X, tmp.Y + (tmp.Height / 2), tmp.Right, tmp.Y + (tmp.Height / 2));
4847 dc.DrawLine (pen, tmp.X, tmp.Y + (tmp.Height / 2) + 1, tmp.Right, tmp.Y + (tmp.Height / 2) + 1);
4849 dc.DrawLine (pen, tmp.X + (tmp.Width / 2), tmp.Y, tmp.X + (tmp.Width / 2), tmp.Bottom);
4850 dc.DrawLine (pen, tmp.X + (tmp.Width / 2) + 1, tmp.Y, tmp.X + (tmp.Width / 2) + 1, tmp.Bottom);
4855 public override void CPDrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style) {
4860 public override void CPDrawReversibleLine (Point start, Point end, Color backColor) {
4865 /* Scroll button: regular button + direction arrow */
4866 public override void CPDrawScrollButton (Graphics dc, Rectangle area, ScrollButton type, ButtonState state) {
4867 DrawScrollButtonPrimitive (dc, area, state);
4869 int arrow_y_pos_diff = 3;
4872 case ScrollButton.Up:
4873 arrow_y_pos_diff = 2;
4875 case ScrollButton.Down:
4876 arrow_y_pos_diff = 4;
4882 // A lot of the following is adapted from the rewind project
4883 Rectangle rect = new Rectangle (area.X - 3, area.Y - arrow_y_pos_diff,
4884 area.Width + 6, area.Height + 6);
4885 int small_diam = rect.Width > rect.Height ? rect.Height : rect.Width;
4886 if (rect.Width < rect.Height) {
4887 rect.Y += (rect.Height - rect.Width) / 2;
4888 rect.Height = small_diam;
4889 } else if (rect.Width > rect.Height) {
4890 rect.X += (rect.Width - rect.Height) / 2;
4891 rect.Width = small_diam;
4896 int tri = 290 * small_diam / 1000 - 1;
4900 Point [] arrow = new Point [3];
4901 for (int i = 0; i < 3; i++)
4902 arrow [i] = new Point ();
4906 case ScrollButton.Down:
4907 arrow [2].X = rect.Left + 470 * small_diam / 1000 + 2;
4908 arrow [2].Y = rect.Top + 687 * small_diam / 1000 + 1;
4909 arrow [0].X = arrow [2].X - tri;
4910 arrow [1].X = arrow [2].X + tri;
4911 arrow [0].Y = arrow [1].Y = arrow [2].Y - tri;
4914 case ScrollButton.Up:
4915 arrow [2].X = rect.Left + 470 * small_diam / 1000 + 2;
4916 arrow [2].Y = rect.Bottom - (687 * small_diam / 1000 + 1);
4917 arrow [0].X = arrow [2].X - tri;
4918 arrow [1].X = arrow [2].X + tri;
4919 arrow [0].Y = arrow [1].Y = arrow [2].Y + tri;
4922 case ScrollButton.Left:
4923 arrow [2].X = rect.Right - (687 * small_diam / 1000 + 1);
4924 arrow [2].Y = rect.Top + 470 * small_diam / 1000 + 2;
4925 arrow [0].Y = arrow [2].Y - tri;
4926 arrow [1].Y = arrow [2].Y + tri;
4927 arrow [0].X = arrow [1].X = arrow [2].X + tri;
4929 // Left and Right are not drawn correctly because of libgdiplus problems
4930 // once that is solved change it to the code below to match ms
4931 // case ScrollButton.Left:
4932 // arrow [2].X = rect.Right - (687 * small_diam / 1000 + 1);
4933 // arrow [2].Y = (rect.Top + 470 * small_diam / 1000 + 2) - 1;
4934 // arrow [1].Y = arrow [2].Y + tri;
4935 // arrow [0].Y = arrow [2].Y - tri + 1;
4936 // arrow [0].X = arrow [1].X = arrow [2].X + tri;
4938 case ScrollButton.Right:
4939 arrow [2].X = rect.Left + 687 * small_diam / 1000 + 1;
4940 arrow [2].Y = rect.Top + 470 * small_diam / 1000 + 2;
4941 arrow [0].Y = arrow [2].Y - tri;
4942 arrow [1].Y = arrow [2].Y + tri;
4943 arrow [0].X = arrow [1].X = arrow [2].X - tri;
4947 /* Draw the arrow */
4948 if ((state & ButtonState.Inactive)!=0) {
4949 dc.FillPolygon (SystemBrushes.ControlLightLight, arrow, FillMode.Winding);
4951 for (int i = 0; i < 3; i++) {
4956 dc.FillPolygon (SystemBrushes.ControlDark, arrow, FillMode.Winding);
4958 dc.FillPolygon (SystemBrushes.ControlText, arrow, FillMode.Winding);
4962 public override void CPDrawSelectionFrame (Graphics graphics, bool active, Rectangle outsideRect, Rectangle insideRect,
4968 public override void CPDrawSizeGrip (Graphics dc, Color backColor, Rectangle bounds)
4970 Pen pen_dark = ResPool.GetPen(ControlPaint.Dark(backColor));
4971 Pen pen_light_light = ResPool.GetPen(ControlPaint.LightLight(backColor));
4973 for (int i = 2; i < bounds.Width - 2; i += 4) {
4974 dc.DrawLine (pen_light_light, bounds.X + i, bounds.Bottom - 2, bounds.Right - 1, bounds.Y + i - 1);
4975 dc.DrawLine (pen_dark, bounds.X + i + 1, bounds.Bottom - 2, bounds.Right - 1, bounds.Y + i);
4976 dc.DrawLine (pen_dark, bounds.X + i + 2, bounds.Bottom - 2, bounds.Right - 1, bounds.Y + i + 1);
4980 public override void CPDrawStringDisabled (Graphics dc, string s, Font font, Color color, RectangleF layoutRectangle, StringFormat format)
4982 CPColor cpcolor = ResPool.GetCPColor (color);
4984 dc.DrawString (s, font, ResPool.GetSolidBrush(cpcolor.LightLight),
4985 new RectangleF(layoutRectangle.X + 1, layoutRectangle.Y + 1, layoutRectangle.Width, layoutRectangle.Height),
4987 dc.DrawString (s, font, ResPool.GetSolidBrush (cpcolor.Dark), layoutRectangle, format);
4990 private static void DrawBorderInternal(Graphics graphics, int startX, int startY, int endX, int endY,
4991 int width, Color color, ButtonBorderStyle style, Border3DSide side) {
4996 case ButtonBorderStyle.Solid:
4997 case ButtonBorderStyle.Inset:
4998 case ButtonBorderStyle.Outset:
4999 pen = ThemeEngine.Current.ResPool.GetDashPen (color, DashStyle.Solid);
5001 case ButtonBorderStyle.Dashed:
5002 pen = ThemeEngine.Current.ResPool.GetDashPen (color, DashStyle.Dash);
5004 case ButtonBorderStyle.Dotted:
5005 pen = ThemeEngine.Current.ResPool.GetDashPen (color, DashStyle.Dot);
5008 case ButtonBorderStyle.None:
5013 case ButtonBorderStyle.Outset: {
5015 int hue, brightness, saturation;
5016 int brightnessSteps;
5017 int brightnessDownSteps;
5019 ControlPaint.Color2HBS(color, out hue, out brightness, out saturation);
5021 brightnessDownSteps=brightness/width;
5022 if (brightness>127) {
5023 brightnessSteps=Math.Max(6, (160-brightness)/width);
5025 brightnessSteps=(127-brightness)/width;
5028 for (int i=0; i<width; i++) {
5030 case Border3DSide.Left: {
5031 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
5032 pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
5033 graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
5037 case Border3DSide.Right: {
5038 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
5039 pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
5040 graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
5044 case Border3DSide.Top: {
5045 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
5046 pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
5047 graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
5051 case Border3DSide.Bottom: {
5052 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
5053 pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
5054 graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
5062 case ButtonBorderStyle.Inset: {
5064 int hue, brightness, saturation;
5065 int brightnessSteps;
5066 int brightnessDownSteps;
5068 ControlPaint.Color2HBS(color, out hue, out brightness, out saturation);
5070 brightnessDownSteps=brightness/width;
5071 if (brightness>127) {
5072 brightnessSteps=Math.Max(6, (160-brightness)/width);
5074 brightnessSteps=(127-brightness)/width;
5077 for (int i=0; i<width; i++) {
5079 case Border3DSide.Left: {
5080 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
5081 pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
5082 graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
5086 case Border3DSide.Right: {
5087 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
5088 pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
5089 graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
5093 case Border3DSide.Top: {
5094 colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
5095 pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
5096 graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
5100 case Border3DSide.Bottom: {
5101 colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
5102 pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
5103 graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
5112 I decided to have the for-loop duplicated for speed reasons;
5113 that way we only have to switch once (as opposed to have the
5114 for-loop around the switch)
5118 case Border3DSide.Left: {
5119 for (int i=0; i<width; i++) {
5120 graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
5125 case Border3DSide.Right: {
5126 for (int i=0; i<width; i++) {
5127 graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
5132 case Border3DSide.Top: {
5133 for (int i=0; i<width; i++) {
5134 graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
5139 case Border3DSide.Bottom: {
5140 for (int i=0; i<width; i++) {
5141 graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
5152 This function actually draws the various caption elements.
5153 This way we can scale them nicely, no matter what size, and they
5154 still look like MS's scaled caption buttons. (as opposed to scaling a bitmap)
5157 private void DrawCaptionHelper(Graphics graphics, Color color, Pen pen, int lineWidth, int shift, Rectangle captionRect, CaptionButton button) {
5159 case CaptionButton.Close: {
5160 LineCap oldStartCap = pen.StartCap;
5161 LineCap oldEndCap = pen.EndCap;
5162 pen.StartCap=LineCap.Triangle;
5163 pen.EndCap=LineCap.Triangle;
5165 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);
5166 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);
5169 graphics.DrawLine(pen, captionRect.Left+2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Right-2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
5170 graphics.DrawLine(pen, captionRect.Right-2*lineWidth+shift, captionRect.Top+2*lineWidth+shift, captionRect.Left+2*lineWidth+shift, captionRect.Bottom-2*lineWidth+shift);
5171 pen.StartCap = oldStartCap;
5172 pen.EndCap = oldEndCap;
5176 case CaptionButton.Help: {
5177 StringFormat sf = new StringFormat();
5178 Font font = new Font("Microsoft Sans Serif", captionRect.Height, FontStyle.Bold, GraphicsUnit.Pixel);
5180 sf.Alignment=StringAlignment.Center;
5181 sf.LineAlignment=StringAlignment.Center;
5184 graphics.DrawString("?", font, ResPool.GetSolidBrush (color), captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
5192 case CaptionButton.Maximize: {
5193 /* Top 'caption bar' line */
5194 for (int i=0; i<Math.Max(2, lineWidth); i++) {
5195 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);
5198 /* Left side line */
5199 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5200 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+2*lineWidth+shift, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
5203 /* Right side line */
5204 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5205 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);
5209 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5210 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
5215 case CaptionButton.Minimize: {
5217 for (int i=0; i<Math.Max(2, lineWidth); i++) {
5218 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth+shift, captionRect.Bottom-lineWidth+shift-i);
5223 case CaptionButton.Restore: {
5224 /** First 'window' **/
5225 /* Top 'caption bar' line */
5226 for (int i=0; i<Math.Max(2, lineWidth); i++) {
5227 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);
5230 /* Left side line */
5231 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5232 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);
5235 /* Right side line */
5236 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5237 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);
5241 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5242 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);
5245 /** Second 'window' **/
5246 /* Top 'caption bar' line */
5247 for (int i=0; i<Math.Max(2, lineWidth); i++) {
5248 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);
5251 /* Left side line */
5252 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5253 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift+i, captionRect.Top+4*lineWidth+shift+1, captionRect.Left+lineWidth+shift+i, captionRect.Bottom-lineWidth+shift);
5256 /* Right side line */
5257 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5258 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);
5262 for (int i=0; i<Math.Max(1, lineWidth/2); i++) {
5263 graphics.DrawLine(pen, captionRect.Left+lineWidth+shift, captionRect.Bottom-lineWidth+shift-i, captionRect.Right-3*lineWidth-lineWidth/2+shift, captionRect.Bottom-lineWidth+shift-i);
5272 /* Generic scroll button */
5273 public void DrawScrollButtonPrimitive (Graphics dc, Rectangle area, ButtonState state) {
5274 if ((state & ButtonState.Pushed) == ButtonState.Pushed) {
5275 dc.FillRectangle (SystemBrushes.Control, area.X + 1,
5276 area.Y + 1, area.Width - 2 , area.Height - 2);
5278 dc.DrawRectangle (SystemPens.ControlDark, area.X,
5279 area.Y, area.Width, area.Height);
5284 Brush sb_control = SystemBrushes.Control;
5285 Brush sb_lightlight = SystemBrushes.ControlLightLight;
5286 Brush sb_dark = SystemBrushes.ControlDark;
5287 Brush sb_darkdark = SystemBrushes.ControlDarkDark;
5289 dc.FillRectangle (sb_control, area.X, area.Y, area.Width, 1);
5290 dc.FillRectangle (sb_control, area.X, area.Y, 1, area.Height);
5292 dc.FillRectangle (sb_lightlight, area.X + 1, area.Y + 1, area.Width - 1, 1);
5293 dc.FillRectangle (sb_lightlight, area.X + 1, area.Y + 2, 1,
5296 dc.FillRectangle (sb_dark, area.X + 1, area.Y + area.Height - 2,
5299 dc.FillRectangle (sb_darkdark, area.X, area.Y + area.Height -1,
5302 dc.FillRectangle (sb_dark, area.X + area.Width - 2,
5303 area.Y + 1, 1, area.Height -3);
5305 dc.FillRectangle (sb_darkdark, area.X + area.Width -1,
5306 area.Y, 1, area.Height - 1);
5308 dc.FillRectangle (sb_control, area.X + 2,
5309 area.Y + 2, area.Width - 4, area.Height - 4);
5313 public override void CPDrawBorderStyle (Graphics dc, Rectangle area, BorderStyle border_style) {
5314 switch (border_style){
5315 case BorderStyle.Fixed3D:
5316 dc.DrawLine (ResPool.GetPen (ColorControlDark), area.X, area.Y, area.X +area.Width, area.Y);
5317 dc.DrawLine (ResPool.GetPen (ColorControlDark), area.X, area.Y, area.X, area.Y + area.Height);
5318 dc.DrawLine (ResPool.GetPen (ColorControlLight), area.X , area.Y + area.Height - 1, area.X + area.Width ,
5319 area.Y + area.Height - 1);
5320 dc.DrawLine (ResPool.GetPen (ColorControlLight), area.X + area.Width -1 , area.Y, area.X + area.Width -1,
5321 area.Y + area.Height);
5323 dc.DrawLine (ResPool.GetPen (ColorActiveBorder), area.X + 1, area.Bottom - 2, area.Right - 2, area.Bottom - 2);
5324 dc.DrawLine (ResPool.GetPen (ColorActiveBorder), area.Right - 2, area.Top + 1, area.Right - 2, area.Bottom - 2);
5325 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), area.X + 1, area.Top + 1, area.X + 1, area.Bottom - 3);
5326 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), area.X + 1, area.Top + 1, area.Right - 3, area.Top + 1);
5328 case BorderStyle.FixedSingle:
5329 dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame), area.X, area.Y, area.Width - 1, area.Height - 1);
5331 case BorderStyle.None:
5337 #endregion // ControlPaint