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) 2008 George Giolfan
21 // Copyright (c) 2004-2006 Novell, Inc.
24 // George Giolfan, georgegiolfan@yahoo.com
25 // Ernesto Carrea, equistango@gmail.com
28 using System.Drawing.Drawing2D;
29 using System.Windows.Forms.VisualStyles;
31 namespace System.Windows.Forms
34 /// VisualStyles theme.
37 /// This theme uses only the managed VisualStyles API.
38 /// To select it, set MONO_THEME to VisualStyles and call <see cref="Application.EnableVisualStyles"/>.
40 class ThemeVisualStyles : ThemeWin32Classic
43 public override void DrawButtonBase (Graphics dc, Rectangle clip_area, ButtonBase button)
45 if (button.FlatStyle == FlatStyle.System) {
46 ButtonRenderer.DrawButton (
48 new Rectangle (Point.Empty, button.Size),
51 button.TextFormatFlags,
54 ShouldPaintFocusRectagle (button),
55 GetPushButtonState (button)
59 base.DrawButtonBase (dc, clip_area, button);
61 static PushButtonState GetPushButtonState (ButtonBase button)
64 return PushButtonState.Disabled;
66 return PushButtonState.Pressed;
68 return PushButtonState.Hot;
69 if (button.IsDefault || button.Focused || button.paint_as_acceptbutton)
70 return PushButtonState.Default;
71 return PushButtonState.Normal;
76 public override void DrawButtonBackground (Graphics g, Button button, Rectangle clipArea)
78 if (!button.UseVisualStyleBackColor) {
79 base.DrawButtonBackground (g, button, clipArea);
82 ButtonRenderer.GetPushButtonRenderer (GetPushButtonState (button)).DrawBackground (g, new Rectangle (Point.Empty, button.Size));
87 protected override void CheckBox_DrawCheckBox (Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle)
89 if (checkbox.Appearance == Appearance.Normal && checkbox.FlatStyle == FlatStyle.System) {
90 CheckBoxRenderer.DrawCheckBox (
92 new Point (checkbox_rectangle.Left, checkbox_rectangle.Top),
93 GetCheckBoxState (checkbox)
97 base.CheckBox_DrawCheckBox(dc, checkbox, state, checkbox_rectangle);
99 static CheckBoxState GetCheckBoxState (CheckBox checkBox)
101 switch (checkBox.CheckState) {
102 case CheckState.Checked:
103 if (!checkBox.Enabled)
104 return CheckBoxState.CheckedDisabled;
105 else if (checkBox.Pressed)
106 return CheckBoxState.CheckedPressed;
107 else if (checkBox.Entered)
108 return CheckBoxState.CheckedHot;
109 return CheckBoxState.CheckedNormal;
110 case CheckState.Indeterminate:
111 if (!checkBox.Enabled)
112 return CheckBoxState.MixedDisabled;
113 else if (checkBox.Pressed)
114 return CheckBoxState.MixedPressed;
115 else if (checkBox.Entered)
116 return CheckBoxState.MixedHot;
117 return CheckBoxState.MixedNormal;
119 if (!checkBox.Enabled)
120 return CheckBoxState.UncheckedDisabled;
121 else if (checkBox.Pressed)
122 return CheckBoxState.UncheckedPressed;
123 else if (checkBox.Entered)
124 return CheckBoxState.UncheckedHot;
125 return CheckBoxState.UncheckedNormal;
130 static VisualStyleElement ComboBoxGetVisualStyleElement (ComboBox comboBox, ButtonState state)
132 if (state == ButtonState.Inactive)
133 return VisualStyleElement.ComboBox.DropDownButton.Disabled;
134 if (state == ButtonState.Pushed)
135 return VisualStyleElement.ComboBox.DropDownButton.Pressed;
136 if (comboBox.DropDownButtonEntered)
137 return VisualStyleElement.ComboBox.DropDownButton.Hot;
138 return VisualStyleElement.ComboBox.DropDownButton.Normal;
140 public override void ComboBoxDrawNormalDropDownButton (ComboBox comboBox, Graphics g, Rectangle clippingArea, Rectangle area, ButtonState state)
142 VisualStyleElement element = ComboBoxGetVisualStyleElement (comboBox, state);
143 if (!VisualStyleRenderer.IsElementDefined (element)) {
144 base.ComboBoxDrawNormalDropDownButton (comboBox, g, clippingArea, area, state);
147 new VisualStyleRenderer (element).DrawBackground (g, area, clippingArea);
149 public override bool ComboBoxNormalDropDownButtonHasTransparentBackground (ComboBox comboBox, ButtonState state)
151 VisualStyleElement element = ComboBoxGetVisualStyleElement (comboBox, state);
152 if (!VisualStyleRenderer.IsElementDefined (element))
153 return base.ComboBoxNormalDropDownButtonHasTransparentBackground (comboBox, state);
154 return new VisualStyleRenderer (element).IsBackgroundPartiallyTransparent ();
156 public override bool ComboBoxDropDownButtonHasHotElementStyle (ComboBox comboBox)
159 switch (comboBox.FlatStyle) {
161 case FlatStyle.Popup:
162 return base.ComboBoxDropDownButtonHasHotElementStyle (comboBox);
170 public override void CPDrawButton (Graphics dc, Rectangle rectangle, ButtonState state)
172 if ((state & ButtonState.Flat) == ButtonState.Flat ||
173 (state & ButtonState.Checked) == ButtonState.Checked) {
174 base.CPDrawButton (dc, rectangle, state);
177 VisualStyleElement element;
178 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
179 element = VisualStyleElement.Button.PushButton.Disabled;
180 else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
181 element = VisualStyleElement.Button.PushButton.Pressed;
183 element = VisualStyleElement.Button.PushButton.Normal;
184 if (!VisualStyleRenderer.IsElementDefined (element)) {
185 base.CPDrawButton (dc, rectangle, state);
188 new VisualStyleRenderer (element).DrawBackground (dc, rectangle);
191 #region DrawCaptionButton
192 public override void CPDrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state)
194 if ((state & ButtonState.Flat) == ButtonState.Flat ||
195 (state & ButtonState.Checked) == ButtonState.Checked) {
196 base.CPDrawCaptionButton (graphics, rectangle, button, state);
199 VisualStyleElement element = GetCaptionButtonVisualStyleElement (button, state);
200 if (!VisualStyleRenderer.IsElementDefined (element)) {
201 base.CPDrawCaptionButton (graphics, rectangle, button, state);
204 new VisualStyleRenderer (element).DrawBackground (graphics, rectangle);
206 static VisualStyleElement GetCaptionButtonVisualStyleElement (CaptionButton button, ButtonState state)
209 case CaptionButton.Minimize:
210 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
211 return VisualStyleElement.Window.MinButton.Disabled;
212 else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
213 return VisualStyleElement.Window.MinButton.Pressed;
215 return VisualStyleElement.Window.MinButton.Normal;
216 case CaptionButton.Maximize:
217 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
218 return VisualStyleElement.Window.MaxButton.Disabled;
219 else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
220 return VisualStyleElement.Window.MaxButton.Pressed;
222 return VisualStyleElement.Window.MaxButton.Normal;
223 case CaptionButton.Close:
224 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
225 return VisualStyleElement.Window.CloseButton.Disabled;
226 else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
227 return VisualStyleElement.Window.CloseButton.Pressed;
229 return VisualStyleElement.Window.CloseButton.Normal;
230 case CaptionButton.Restore:
231 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
232 return VisualStyleElement.Window.RestoreButton.Disabled;
233 else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
234 return VisualStyleElement.Window.RestoreButton.Pressed;
236 return VisualStyleElement.Window.RestoreButton.Normal;
238 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
239 return VisualStyleElement.Window.HelpButton.Disabled;
240 else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
241 return VisualStyleElement.Window.HelpButton.Pressed;
243 return VisualStyleElement.Window.HelpButton.Normal;
248 public override void CPDrawCheckBox (Graphics dc, Rectangle rectangle, ButtonState state)
250 if ((state & ButtonState.Flat) == ButtonState.Flat) {
251 base.CPDrawCheckBox (dc, rectangle, state);
254 VisualStyleElement element;
255 if ((state & ButtonState.Checked) == ButtonState.Checked)
256 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
257 element = VisualStyleElement.Button.CheckBox.CheckedDisabled;
258 else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
259 element = VisualStyleElement.Button.CheckBox.CheckedPressed;
261 element = VisualStyleElement.Button.CheckBox.CheckedNormal;
263 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
264 element = VisualStyleElement.Button.CheckBox.UncheckedDisabled;
265 else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
266 element = VisualStyleElement.Button.CheckBox.UncheckedPressed;
268 element = VisualStyleElement.Button.CheckBox.UncheckedNormal;
269 if (!VisualStyleRenderer.IsElementDefined (element)) {
270 base.CPDrawCheckBox (dc, rectangle, state);
273 new VisualStyleRenderer (element).DrawBackground (dc, rectangle);
276 #region DrawComboButton
277 public override void CPDrawComboButton (Graphics graphics, Rectangle rectangle, ButtonState state)
279 if ((state & ButtonState.Flat) == ButtonState.Flat ||
280 (state & ButtonState.Checked) == ButtonState.Checked) {
281 base.CPDrawComboButton (graphics, rectangle, state);
284 VisualStyleElement element;
285 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
286 element = VisualStyleElement.ComboBox.DropDownButton.Disabled;
287 else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
288 element = VisualStyleElement.ComboBox.DropDownButton.Pressed;
290 element = VisualStyleElement.ComboBox.DropDownButton.Normal;
291 if (!VisualStyleRenderer.IsElementDefined (element)) {
292 base.CPDrawComboButton (graphics, rectangle, state);
295 new VisualStyleRenderer (element).DrawBackground (graphics, rectangle);
298 #region DrawMixedCheckBox
299 public override void CPDrawMixedCheckBox (Graphics dc, Rectangle rectangle, ButtonState state)
301 if ((state & ButtonState.Flat) == ButtonState.Flat) {
302 base.CPDrawMixedCheckBox (dc, rectangle, state);
305 VisualStyleElement element;
306 if ((state & ButtonState.Checked) == ButtonState.Checked)
307 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
308 element = VisualStyleElement.Button.CheckBox.MixedDisabled;
309 else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
310 element = VisualStyleElement.Button.CheckBox.MixedPressed;
312 element = VisualStyleElement.Button.CheckBox.MixedNormal;
314 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
315 element = VisualStyleElement.Button.CheckBox.UncheckedDisabled;
316 else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
317 element = VisualStyleElement.Button.CheckBox.UncheckedPressed;
319 element = VisualStyleElement.Button.CheckBox.UncheckedNormal;
320 if (!VisualStyleRenderer.IsElementDefined (element)) {
321 base.CPDrawMixedCheckBox (dc, rectangle, state);
324 new VisualStyleRenderer (element).DrawBackground (dc, rectangle);
327 #region DrawRadioButton
328 public override void CPDrawRadioButton (Graphics dc, Rectangle rectangle, ButtonState state)
330 if ((state & ButtonState.Flat) == ButtonState.Flat) {
331 base.CPDrawRadioButton (dc, rectangle, state);
334 VisualStyleElement element;
335 if ((state & ButtonState.Checked) == ButtonState.Checked)
336 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
337 element = VisualStyleElement.Button.RadioButton.CheckedDisabled;
338 else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
339 element = VisualStyleElement.Button.RadioButton.CheckedPressed;
341 element = VisualStyleElement.Button.RadioButton.CheckedNormal;
343 if ((state & ButtonState.Inactive) == ButtonState.Inactive)
344 element = VisualStyleElement.Button.RadioButton.UncheckedDisabled;
345 else if ((state & ButtonState.Pushed) == ButtonState.Pushed)
346 element = VisualStyleElement.Button.RadioButton.UncheckedPressed;
348 element = VisualStyleElement.Button.RadioButton.UncheckedNormal;
349 if (!VisualStyleRenderer.IsElementDefined (element)) {
350 base.CPDrawRadioButton (dc, rectangle, state);
353 new VisualStyleRenderer (element).DrawBackground (dc, rectangle);
356 #region DrawScrollButton
357 public override void CPDrawScrollButton (Graphics dc, Rectangle area, ScrollButton type, ButtonState state)
359 if ((state & ButtonState.Flat) == ButtonState.Flat ||
360 (state & ButtonState.Checked) == ButtonState.Checked) {
361 base.CPDrawScrollButton (dc, area, type, state);
364 VisualStyleElement element = GetScrollButtonVisualStyleElement (type, state);
365 if (!VisualStyleRenderer.IsElementDefined (element)) {
366 base.CPDrawScrollButton (dc, area, type, state);
369 new VisualStyleRenderer (element).DrawBackground (dc, area);
371 static VisualStyleElement GetScrollButtonVisualStyleElement (ScrollButton type, ButtonState state)
374 case ScrollButton.Left:
375 if (IsDisabled (state))
376 return VisualStyleElement.ScrollBar.ArrowButton.LeftDisabled;
377 else if (IsPressed (state))
378 return VisualStyleElement.ScrollBar.ArrowButton.LeftPressed;
380 return VisualStyleElement.ScrollBar.ArrowButton.LeftNormal;
381 case ScrollButton.Right:
382 if (IsDisabled (state))
383 return VisualStyleElement.ScrollBar.ArrowButton.RightDisabled;
384 else if (IsPressed (state))
385 return VisualStyleElement.ScrollBar.ArrowButton.RightPressed;
387 return VisualStyleElement.ScrollBar.ArrowButton.RightNormal;
388 case ScrollButton.Up:
389 if (IsDisabled (state))
390 return VisualStyleElement.ScrollBar.ArrowButton.UpDisabled;
391 else if (IsPressed (state))
392 return VisualStyleElement.ScrollBar.ArrowButton.UpPressed;
394 return VisualStyleElement.ScrollBar.ArrowButton.UpNormal;
396 if (IsDisabled (state))
397 return VisualStyleElement.ScrollBar.ArrowButton.DownDisabled;
398 else if (IsPressed (state))
399 return VisualStyleElement.ScrollBar.ArrowButton.DownPressed;
401 return VisualStyleElement.ScrollBar.ArrowButton.DownNormal;
404 static bool IsDisabled (ButtonState state)
406 return (state & ButtonState.Inactive) == ButtonState.Inactive;
408 static bool IsPressed (ButtonState state)
410 return (state & ButtonState.Pushed) == ButtonState.Pushed;
416 #region DataGridViewHeaderCell
417 #region DataGridViewRowHeaderCell
418 public override bool DataGridViewRowHeaderCellDrawBackground (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds)
420 if (!cell.DataGridView.EnableHeadersVisualStyles)
421 return base.DataGridViewRowHeaderCellDrawBackground (cell, g, bounds);
422 VisualStyleElement element = DataGridViewRowHeaderCellGetVisualStyleElement (cell);
423 if (!VisualStyleRenderer.IsElementDefined (element))
424 return base.DataGridViewRowHeaderCellDrawBackground (cell, g, bounds);
426 Bitmap bitmap = new Bitmap (bounds.Height, bounds.Width);
427 Graphics bitmap_g = Graphics.FromImage (bitmap);
428 Rectangle bitmap_rectangle = new Rectangle (Point.Empty, bitmap.Size);
429 VisualStyleRenderer renderer = new VisualStyleRenderer (element);
430 if (!AreEqual (element, VisualStyleElement.Header.Item.Normal) && renderer.IsBackgroundPartiallyTransparent ())
431 new VisualStyleRenderer (VisualStyleElement.Header.Item.Normal).DrawBackground (bitmap_g, bitmap_rectangle);
432 renderer.DrawBackground (bitmap_g, bitmap_rectangle);
434 g.Transform = new Matrix(0, 1, 1, 0, 0, 0);
435 g.DrawImage (bitmap, bounds.Y, bounds.X);
440 public override bool DataGridViewRowHeaderCellDrawSelectionBackground (DataGridViewRowHeaderCell cell)
442 if (!cell.DataGridView.EnableHeadersVisualStyles || !VisualStyleRenderer.IsElementDefined (DataGridViewRowHeaderCellGetVisualStyleElement (cell)))
443 return base.DataGridViewRowHeaderCellDrawSelectionBackground (cell);
446 public override bool DataGridViewRowHeaderCellDrawBorder (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds)
448 if (!cell.DataGridView.EnableHeadersVisualStyles || !VisualStyleRenderer.IsElementDefined (DataGridViewRowHeaderCellGetVisualStyleElement (cell)))
449 return base.DataGridViewRowHeaderCellDrawBorder (cell, g, bounds);
450 g.DrawLine (cell.GetBorderPen (), bounds.Right - 1, bounds.Top, bounds.Right - 1, bounds.Bottom - 1);
453 static VisualStyleElement DataGridViewRowHeaderCellGetVisualStyleElement (DataGridViewRowHeaderCell cell)
455 if (cell.DataGridView.PressedHeaderCell == cell)
456 return VisualStyleElement.Header.Item.Pressed;
457 if (cell.DataGridView.EnteredHeaderCell == cell)
458 return VisualStyleElement.Header.Item.Hot;
459 if (cell.OwningRow.SelectedInternal)
460 return VisualStyleElement.Header.Item.Pressed;
461 return VisualStyleElement.Header.Item.Normal;
464 #region DataGridViewColumnHeaderCell
465 public override bool DataGridViewColumnHeaderCellDrawBackground (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds)
467 if (!cell.DataGridView.EnableHeadersVisualStyles || cell is DataGridViewTopLeftHeaderCell)
468 return base.DataGridViewColumnHeaderCellDrawBackground (cell, g, bounds);
469 VisualStyleElement element = DataGridViewColumnHeaderCellGetVisualStyleElement (cell);
470 if (!VisualStyleRenderer.IsElementDefined (element))
471 return base.DataGridViewColumnHeaderCellDrawBackground (cell, g, bounds);
473 VisualStyleRenderer renderer = new VisualStyleRenderer (element);
474 if (!AreEqual (element, VisualStyleElement.Header.Item.Normal) && renderer.IsBackgroundPartiallyTransparent ())
475 new VisualStyleRenderer (VisualStyleElement.Header.Item.Normal).DrawBackground (g, bounds);
476 renderer.DrawBackground (g, bounds);
479 public override bool DataGridViewColumnHeaderCellDrawBorder (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds)
481 if (!cell.DataGridView.EnableHeadersVisualStyles || cell is DataGridViewTopLeftHeaderCell || !VisualStyleRenderer.IsElementDefined (VisualStyleElement.Header.Item.Normal))
482 return base.DataGridViewColumnHeaderCellDrawBorder (cell, g, bounds);
483 g.DrawLine (cell.GetBorderPen (), bounds.Left, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1);
486 static VisualStyleElement DataGridViewColumnHeaderCellGetVisualStyleElement (DataGridViewColumnHeaderCell cell)
488 if (cell.DataGridView.PressedHeaderCell == cell)
489 return VisualStyleElement.Header.Item.Pressed;
490 if (cell.DataGridView.EnteredHeaderCell == cell)
491 return VisualStyleElement.Header.Item.Hot;
492 return VisualStyleElement.Header.Item.Normal;
495 public override bool DataGridViewHeaderCellHasPressedStyle (DataGridView dataGridView)
497 if (!dataGridView.EnableHeadersVisualStyles || !VisualStyleRenderer.IsElementDefined (VisualStyleElement.Header.Item.Pressed))
498 return base.DataGridViewHeaderCellHasPressedStyle (dataGridView);
501 public override bool DataGridViewHeaderCellHasHotStyle (DataGridView dataGridView)
503 if (!dataGridView.EnableHeadersVisualStyles || !VisualStyleRenderer.IsElementDefined (VisualStyleElement.Header.Item.Hot))
504 return base.DataGridViewHeaderCellHasHotStyle (dataGridView);
511 protected override void ListViewDrawColumnHeaderBackground (ListView listView, ColumnHeader columnHeader, Graphics g, Rectangle area, Rectangle clippingArea)
513 VisualStyleElement element;
514 if (listView.HeaderStyle == ColumnHeaderStyle.Clickable)
515 if (columnHeader.Pressed)
516 element = VisualStyleElement.Header.Item.Pressed;
517 else if (columnHeader == listView.EnteredColumnHeader)
518 element = VisualStyleElement.Header.Item.Hot;
520 element = VisualStyleElement.Header.Item.Normal;
522 element = VisualStyleElement.Header.Item.Normal;
523 if (!VisualStyleRenderer.IsElementDefined (element)) {
524 base.ListViewDrawColumnHeaderBackground (listView, columnHeader, g, area, clippingArea);
527 new VisualStyleRenderer (element).DrawBackground (g, area, clippingArea);
529 protected override void ListViewDrawUnusedHeaderBackground (ListView listView, Graphics g, Rectangle area, Rectangle clippingArea)
531 VisualStyleElement element = VisualStyleElement.Header.Item.Normal;
532 if (!VisualStyleRenderer.IsElementDefined (element)) {
533 base.ListViewDrawUnusedHeaderBackground (listView, g, area, clippingArea);
536 new VisualStyleRenderer (element).DrawBackground (g, area, clippingArea);
538 public override bool ListViewHasHotHeaderStyle {
540 if (!VisualStyleRenderer.IsElementDefined (VisualStyleElement.Header.Item.Hot))
541 return base.ListViewHasHotHeaderStyle;
545 public override int ListViewGetHeaderHeight (ListView listView, Font font)
547 VisualStyleElement element = VisualStyleElement.Header.Item.Normal;
548 if (!VisualStyleRenderer.IsElementDefined (element))
549 return base.ListViewGetHeaderHeight (listView, font);
550 Control control = null;
552 if (listView == null) {
553 control = new Control ();
554 g = control.CreateGraphics ();
556 g = listView.CreateGraphics ();
557 int result = new VisualStyleRenderer (element).GetPartSize (g, ThemeSizeType.True).Height;
559 if (listView == null)
565 public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box)
567 GroupBoxRenderer.DrawGroupBox (
569 new Rectangle (Point.Empty, box.Size),
572 box.ForeColor == GroupBox.DefaultForeColor ? Color.Empty : box.ForeColor,
573 box.Enabled ? GroupBoxState.Normal : GroupBoxState.Disabled);
576 #region Managed windows
577 [MonoTODO("When other VisualStyles implementations are supported, check if the visual style elements are defined.")]
578 [MonoTODO("When the rest of the MDI code is fixed, make sure minimized windows are painted correctly,restrict the caption text drawing area to exclude the title buttons and handle the title bar height correctly.")]
579 public override void DrawManagedWindowDecorations (Graphics dc, Rectangle clip, InternalWindowManager wm)
581 if (!wm.HasBorders || (wm.Form.IsMdiChild && wm.IsMaximized))
583 VisualStyleElement element;
584 #region Title bar background
585 #region Select caption visual style element
588 switch (wm.form.window_state) {
589 case FormWindowState.Minimized:
590 if (!wm.Form.Enabled)
591 element = VisualStyleElement.Window.SmallMinCaption.Disabled;
592 else if (wm.IsActive)
593 element = VisualStyleElement.Window.SmallMinCaption.Active;
595 element = VisualStyleElement.Window.SmallMinCaption.Inactive;
597 case FormWindowState.Maximized:
598 if (!wm.Form.Enabled)
599 element = VisualStyleElement.Window.SmallMaxCaption.Disabled;
600 else if (wm.IsActive)
601 element = VisualStyleElement.Window.SmallMaxCaption.Active;
603 element = VisualStyleElement.Window.SmallMaxCaption.Inactive;
606 if (!wm.Form.Enabled)
607 element = VisualStyleElement.Window.SmallCaption.Disabled;
608 else if (wm.IsActive)
609 element = VisualStyleElement.Window.SmallCaption.Active;
611 element = VisualStyleElement.Window.SmallCaption.Inactive;
616 #region Normal window
617 switch (wm.form.window_state) {
618 case FormWindowState.Minimized:
619 if (!wm.Form.Enabled)
620 element = VisualStyleElement.Window.MinCaption.Disabled;
621 else if (wm.IsActive)
622 element = VisualStyleElement.Window.MinCaption.Active;
624 element = VisualStyleElement.Window.MinCaption.Inactive;
626 case FormWindowState.Maximized:
627 if (!wm.Form.Enabled)
628 element = VisualStyleElement.Window.MaxCaption.Disabled;
629 else if (wm.IsActive)
630 element = VisualStyleElement.Window.MaxCaption.Active;
632 element = VisualStyleElement.Window.MaxCaption.Inactive;
635 if (!wm.Form.Enabled)
636 element = VisualStyleElement.Window.Caption.Disabled;
637 else if (wm.IsActive)
638 element = VisualStyleElement.Window.Caption.Active;
640 element = VisualStyleElement.Window.Caption.Inactive;
645 VisualStyleRenderer renderer = new VisualStyleRenderer (element);
646 Rectangle title_bar_rectangle = new Rectangle (
650 renderer.GetPartSize (dc, ThemeSizeType.True).Height
652 Rectangle caption_text_area = title_bar_rectangle;
653 renderer.DrawBackground (dc, title_bar_rectangle, clip);
655 int border_width = ManagedWindowBorderWidth (wm);
657 if (!wm.IsToolWindow && wm.Form.FormBorderStyle != FormBorderStyle.FixedDialog
662 Rectangle icon_rectangle = new Rectangle (
667 caption_text_area.X += icon_rectangle.Width;
668 if (icon_rectangle.IntersectsWith (clip))
669 dc.DrawIcon (wm.Form.Icon, icon_rectangle);
672 #region Title bar buttons
673 foreach (TitleButton button in wm.TitleButtons.AllButtons) {
674 if (!button.Visible || !button.Rectangle.IntersectsWith (clip))
676 new VisualStyleRenderer (GetCaptionButtonVisualStyleElement (button.Caption, button.State)).DrawBackground (dc, button.Rectangle, clip);
680 if (wm.GetWindowState () == FormWindowState.Normal) {
684 element = VisualStyleElement.Window.SmallFrameLeft.Active;
686 element = VisualStyleElement.Window.SmallFrameLeft.Inactive;
689 element = VisualStyleElement.Window.FrameLeft.Active;
691 element = VisualStyleElement.Window.FrameLeft.Inactive;
692 renderer = new VisualStyleRenderer (element);
693 renderer.DrawBackground (dc, new Rectangle (
695 title_bar_rectangle.Bottom,
697 wm.form.Height - title_bar_rectangle.Bottom
703 element = VisualStyleElement.Window.SmallFrameRight.Active;
705 element = VisualStyleElement.Window.SmallFrameRight.Inactive;
708 element = VisualStyleElement.Window.FrameRight.Active;
710 element = VisualStyleElement.Window.FrameRight.Inactive;
712 renderer = new VisualStyleRenderer (element);
713 renderer.DrawBackground (dc, new Rectangle (
714 wm.form.Width - border_width,
715 title_bar_rectangle.Bottom,
717 wm.form.Height - title_bar_rectangle.Bottom
723 element = VisualStyleElement.Window.SmallFrameBottom.Active;
725 element = VisualStyleElement.Window.SmallFrameBottom.Inactive;
728 element = VisualStyleElement.Window.FrameBottom.Active;
730 element = VisualStyleElement.Window.FrameBottom.Inactive;
732 renderer = new VisualStyleRenderer (element);
733 renderer.DrawBackground (dc, new Rectangle (
735 wm.form.Height - border_width,
740 caption_text_area.X += border_width;
744 string window_caption = wm.Form.Text;
745 if (window_caption != null && window_caption.Length != 0 && caption_text_area.IntersectsWith (clip)) {
746 StringFormat format = new StringFormat ();
747 format.FormatFlags = StringFormatFlags.NoWrap;
748 format.Trimming = StringTrimming.EllipsisCharacter;
749 format.LineAlignment = StringAlignment.Center;
753 ThemeEngine.Current.ResPool.GetSolidBrush (Color.White),
762 public override void DrawProgressBar (Graphics dc, Rectangle clip_rect, ProgressBar ctrl)
764 if (!VisualStyleRenderer.IsElementDefined (VisualStyleElement.ProgressBar.Bar.Normal) ||
765 !VisualStyleRenderer.IsElementDefined (VisualStyleElement.ProgressBar.Chunk.Normal)) {
766 base.DrawProgressBar (dc, clip_rect, ctrl);
769 VisualStyleRenderer renderer = new VisualStyleRenderer (VisualStyleElement.ProgressBar.Bar.Normal);
770 renderer.DrawBackground (dc, ctrl.ClientRectangle, clip_rect);
771 Rectangle client_area = renderer.GetBackgroundContentRectangle (dc, new Rectangle (Point.Empty, ctrl.Size));
772 renderer = new VisualStyleRenderer (VisualStyleElement.ProgressBar.Chunk.Normal);
775 int max_blocks = int.MaxValue;
776 int start_pixel = client_area.X;
778 draw_mode = (int)ctrl.Style;
782 case 1: // Continuous
783 client_area.Width = (int)(client_area.Width * ((double)(ctrl.Value - ctrl.Minimum) / (double)(Math.Max (ctrl.Maximum - ctrl.Minimum, 1))));
784 renderer.DrawBackground (dc, client_area, clip_rect);
787 int ms_diff = (int)(DateTime.Now - ctrl.start).TotalMilliseconds;
788 double percent_done = (double)ms_diff % (double)ctrl.MarqueeAnimationSpeed / (double)ctrl.MarqueeAnimationSpeed;
790 start_pixel = client_area.X + (int)(client_area.Width * percent_done);
794 int block_width = renderer.GetInteger (IntegerProperty.ProgressChunkSize);
795 int first_pixel_outside_filled_area = (int)(((double)(ctrl.Value - ctrl.Minimum) * client_area.Width) / (Math.Max (ctrl.Maximum - ctrl.Minimum, 1))) + client_area.X;
797 int increment = block_width + renderer.GetInteger (IntegerProperty.ProgressSpaceSize);
798 Rectangle block_rect = new Rectangle (start_pixel, client_area.Y, block_width, client_area.Height);
800 if (max_blocks != int.MaxValue) {
801 if (block_count == max_blocks)
803 if (block_rect.Right >= client_area.Width)
804 block_rect.X -= client_area.Width;
806 if (block_rect.X >= first_pixel_outside_filled_area)
808 if (block_rect.Right >= first_pixel_outside_filled_area)
809 if (first_pixel_outside_filled_area == client_area.Right)
810 block_rect.Width = first_pixel_outside_filled_area - block_rect.X;
814 if (clip_rect.IntersectsWith (block_rect))
815 renderer.DrawBackground (dc, block_rect, clip_rect);
816 block_rect.X += increment;
824 protected override void RadioButton_DrawButton (RadioButton radio_button, Graphics dc, ButtonState state, Rectangle radiobutton_rectangle) {
825 if (radio_button.Appearance == Appearance.Normal && radio_button.FlatStyle == FlatStyle.System) {
826 RadioButtonRenderer.DrawRadioButton (
828 new Point (radiobutton_rectangle.Left, radiobutton_rectangle.Top),
829 GetRadioButtonState (radio_button)
833 base.RadioButton_DrawButton(radio_button, dc, state, radiobutton_rectangle);
835 static RadioButtonState GetRadioButtonState (RadioButton checkBox)
837 if (checkBox.Checked) {
838 if (!checkBox.Enabled)
839 return RadioButtonState.CheckedDisabled;
840 else if (checkBox.Pressed)
841 return RadioButtonState.CheckedPressed;
842 else if (checkBox.Entered)
843 return RadioButtonState.CheckedHot;
844 return RadioButtonState.CheckedNormal;
846 if (!checkBox.Enabled)
847 return RadioButtonState.UncheckedDisabled;
848 else if (checkBox.Pressed)
849 return RadioButtonState.UncheckedPressed;
850 else if (checkBox.Entered)
851 return RadioButtonState.UncheckedHot;
852 return RadioButtonState.UncheckedNormal;
857 public override void DrawScrollBar (Graphics dc, Rectangle clip, ScrollBar bar)
859 if (!ScrollBarAreElementsDefined) {
860 base.DrawScrollBar (dc, clip, bar);
863 VisualStyleElement element;
864 VisualStyleRenderer renderer;
865 int scroll_button_width = bar.scrollbutton_width;
866 int scroll_button_height = bar.scrollbutton_height;
868 bar.FirstArrowArea = new Rectangle (0, 0, bar.Width, scroll_button_height);
869 bar.SecondArrowArea = new Rectangle (
871 bar.ClientRectangle.Height - scroll_button_height,
873 scroll_button_height);
874 Rectangle thumb_pos = bar.ThumbPos;
875 thumb_pos.Width = bar.Width;
876 bar.ThumbPos = thumb_pos;
877 #region Background, upper track
878 if (bar.thumb_moving == ScrollBar.ThumbMoving.Backwards)
879 element = VisualStyleElement.ScrollBar.LowerTrackVertical.Pressed;
881 element = bar.Enabled ?
882 VisualStyleElement.ScrollBar.LowerTrackVertical.Normal :
883 VisualStyleElement.ScrollBar.LowerTrackVertical.Disabled;
884 renderer = new VisualStyleRenderer (element);
885 Rectangle upper_track_rect = new Rectangle (
888 bar.ClientRectangle.Width,
890 if (clip.IntersectsWith (upper_track_rect))
891 renderer.DrawBackground (dc, upper_track_rect, clip);
893 #region Background, lower track
894 if (bar.thumb_moving == ScrollBar.ThumbMoving.Forward)
895 element = VisualStyles.VisualStyleElement.ScrollBar.LowerTrackVertical.Pressed;
897 element = bar.Enabled ?
898 VisualStyleElement.ScrollBar.LowerTrackVertical.Normal :
899 VisualStyleElement.ScrollBar.LowerTrackVertical.Disabled;
900 renderer = new VisualStyleRenderer (element);
901 Rectangle lower_track_rect = new Rectangle (
904 bar.ClientRectangle.Width,
905 bar.ClientRectangle.Height - bar.ThumbPos.Bottom);
906 if (clip.IntersectsWith (lower_track_rect))
907 renderer.DrawBackground (dc, lower_track_rect, clip);
910 if (clip.IntersectsWith (bar.FirstArrowArea)) {
912 element = VisualStyleElement.ScrollBar.ArrowButton.UpDisabled;
913 else if (bar.firstbutton_state == ButtonState.Pushed)
914 element = VisualStyleElement.ScrollBar.ArrowButton.UpPressed;
915 else if (bar.FirstButtonEntered)
916 element = VisualStyleElement.ScrollBar.ArrowButton.UpHot;
917 else if (ScrollBarHasHoverArrowButtonStyleVisualStyles && bar.Entered)
918 element = VisualStyleElement.ScrollBar.ArrowButton.UpHover;
920 element = VisualStyleElement.ScrollBar.ArrowButton.UpNormal;
921 renderer = new VisualStyleRenderer (element);
922 renderer.DrawBackground (dc, bar.FirstArrowArea);
924 if (clip.IntersectsWith (bar.SecondArrowArea)) {
926 element = VisualStyleElement.ScrollBar.ArrowButton.DownDisabled;
927 else if (bar.secondbutton_state == ButtonState.Pushed)
928 element = VisualStyleElement.ScrollBar.ArrowButton.DownPressed;
929 else if (bar.SecondButtonEntered)
930 element = VisualStyleElement.ScrollBar.ArrowButton.DownHot;
931 else if (ScrollBarHasHoverArrowButtonStyleVisualStyles && bar.Entered)
932 element = VisualStyleElement.ScrollBar.ArrowButton.DownHover;
934 element = VisualStyleElement.ScrollBar.ArrowButton.DownNormal;
935 renderer = new VisualStyleRenderer (element);
936 renderer.DrawBackground (dc, bar.SecondArrowArea);
939 #region Thumb and grip
941 element = VisualStyleElement.ScrollBar.LowerTrackVertical.Disabled;
942 else if (bar.ThumbPressed)
943 element = VisualStyleElement.ScrollBar.ThumbButtonVertical.Pressed;
944 else if (bar.ThumbEntered)
945 element = VisualStyleElement.ScrollBar.ThumbButtonVertical.Hot;
947 element = VisualStyleElement.ScrollBar.ThumbButtonVertical.Normal;
948 renderer = new VisualStyleRenderer (element);
949 renderer.DrawBackground (dc, bar.ThumbPos, clip);
951 if (bar.Enabled && bar.ThumbPos.Height >= 20) {
952 element = VisualStyleElement.ScrollBar.GripperVertical.Normal;
953 renderer = new VisualStyleRenderer (element);
954 renderer.DrawBackground (dc, bar.ThumbPos, clip);
958 bar.FirstArrowArea = new Rectangle (0, 0, scroll_button_width, bar.Height);
959 bar.SecondArrowArea = new Rectangle (
960 bar.ClientRectangle.Width - scroll_button_width,
964 Rectangle thumb_pos = bar.ThumbPos;
965 thumb_pos.Height = bar.Height;
966 bar.ThumbPos = thumb_pos;
967 #region Background, left track
968 if (bar.thumb_moving == ScrollBar.ThumbMoving.Backwards)
969 element = VisualStyleElement.ScrollBar.LeftTrackHorizontal.Pressed;
971 element = bar.Enabled ?
972 VisualStyleElement.ScrollBar.LeftTrackHorizontal.Normal :
973 VisualStyleElement.ScrollBar.LeftTrackHorizontal.Disabled;
974 renderer = new VisualStyleRenderer (element);
975 Rectangle left_track_rect = new Rectangle (
979 bar.ClientRectangle.Height);
980 if (clip.IntersectsWith (left_track_rect))
981 renderer.DrawBackground (dc, left_track_rect, clip);
983 #region Background, right track
984 if (bar.thumb_moving == ScrollBar.ThumbMoving.Forward)
985 element = VisualStyleElement.ScrollBar.RightTrackHorizontal.Pressed;
987 element = bar.Enabled ?
988 VisualStyleElement.ScrollBar.RightTrackHorizontal.Normal :
989 VisualStyleElement.ScrollBar.RightTrackHorizontal.Disabled;
990 renderer = new VisualStyleRenderer (element);
991 Rectangle right_track_rect = new Rectangle (
994 bar.ClientRectangle.Width - bar.ThumbPos.Right,
995 bar.ClientRectangle.Height);
996 if (clip.IntersectsWith (right_track_rect))
997 renderer.DrawBackground (dc, right_track_rect, clip);
1000 if (clip.IntersectsWith (bar.FirstArrowArea)) {
1002 element = VisualStyleElement.ScrollBar.ArrowButton.LeftDisabled;
1003 else if (bar.firstbutton_state == ButtonState.Pushed)
1004 element = VisualStyleElement.ScrollBar.ArrowButton.LeftPressed;
1005 else if (bar.FirstButtonEntered)
1006 element = VisualStyleElement.ScrollBar.ArrowButton.LeftHot;
1007 else if (ScrollBarHasHoverArrowButtonStyleVisualStyles && bar.Entered)
1008 element = VisualStyleElement.ScrollBar.ArrowButton.LeftHover;
1010 element = VisualStyleElement.ScrollBar.ArrowButton.LeftNormal;
1011 renderer = new VisualStyleRenderer (element);
1012 renderer.DrawBackground (dc, bar.FirstArrowArea);
1014 if (clip.IntersectsWith (bar.SecondArrowArea)) {
1016 element = VisualStyleElement.ScrollBar.ArrowButton.RightDisabled;
1017 else if (bar.secondbutton_state == ButtonState.Pushed)
1018 element = VisualStyleElement.ScrollBar.ArrowButton.RightPressed;
1019 else if (bar.SecondButtonEntered)
1020 element = VisualStyleElement.ScrollBar.ArrowButton.RightHot;
1021 else if (ScrollBarHasHoverArrowButtonStyleVisualStyles && bar.Entered)
1022 element = VisualStyleElement.ScrollBar.ArrowButton.RightHover;
1024 element = VisualStyleElement.ScrollBar.ArrowButton.RightNormal;
1025 renderer = new VisualStyleRenderer (element);
1026 renderer.DrawBackground (dc, bar.SecondArrowArea);
1029 #region Thumb and grip
1031 element = VisualStyleElement.ScrollBar.RightTrackHorizontal.Disabled;
1032 else if (bar.ThumbPressed)
1033 element = VisualStyleElement.ScrollBar.ThumbButtonHorizontal.Pressed;
1034 else if (bar.ThumbEntered)
1035 element = VisualStyleElement.ScrollBar.ThumbButtonHorizontal.Hot;
1037 element = VisualStyleElement.ScrollBar.ThumbButtonHorizontal.Normal;
1038 renderer = new VisualStyleRenderer (element);
1039 renderer.DrawBackground (dc, bar.ThumbPos, clip);
1041 if (bar.Enabled && bar.ThumbPos.Height >= 20) {
1042 element = VisualStyleElement.ScrollBar.GripperHorizontal.Normal;
1043 renderer = new VisualStyleRenderer (element);
1044 renderer.DrawBackground (dc, bar.ThumbPos, clip);
1049 public override bool ScrollBarHasHotElementStyles {
1051 return ScrollBarAreElementsDefined;
1054 public override bool ScrollBarHasPressedThumbStyle {
1056 return ScrollBarAreElementsDefined;
1059 const int WindowsVistaMajorVersion = 6;
1060 static bool ScrollBarHasHoverArrowButtonStyleVisualStyles =
1061 Environment.OSVersion.Version.Major >= WindowsVistaMajorVersion;
1062 public override bool ScrollBarHasHoverArrowButtonStyle {
1064 if (ScrollBarHasHoverArrowButtonStyleVisualStyles)
1065 return ScrollBarAreElementsDefined;
1066 return base.ScrollBarHasHoverArrowButtonStyle;
1069 static bool ScrollBarAreElementsDefined {
1072 VisualStyleRenderer.IsElementDefined (VisualStyleElement.ScrollBar.ArrowButton.DownDisabled) &&
1073 VisualStyleRenderer.IsElementDefined (VisualStyleElement.ScrollBar.GripperHorizontal.Normal) &&
1074 VisualStyleRenderer.IsElementDefined (VisualStyleElement.ScrollBar.GripperVertical.Normal) &&
1075 VisualStyleRenderer.IsElementDefined (VisualStyleElement.ScrollBar.LeftTrackHorizontal.Disabled) &&
1076 VisualStyleRenderer.IsElementDefined (VisualStyleElement.ScrollBar.LowerTrackVertical.Disabled) &&
1077 VisualStyleRenderer.IsElementDefined (VisualStyleElement.ScrollBar.RightTrackHorizontal.Disabled) &&
1078 VisualStyleRenderer.IsElementDefined (VisualStyleElement.ScrollBar.SizeBox.LeftAlign) &&
1079 VisualStyleRenderer.IsElementDefined (VisualStyleElement.ScrollBar.ThumbButtonHorizontal.Disabled) &&
1080 VisualStyleRenderer.IsElementDefined (VisualStyleElement.ScrollBar.ThumbButtonVertical.Disabled) &&
1081 VisualStyleRenderer.IsElementDefined (VisualStyleElement.ScrollBar.UpperTrackVertical.Disabled);
1086 protected override void DrawStatusBarBackground(Graphics dc, Rectangle clip, StatusBar sb) {
1087 VisualStyleElement element = VisualStyleElement.Status.Bar.Normal;
1088 if (!VisualStyleRenderer.IsElementDefined (element))
1089 base.DrawStatusBarBackground (dc, clip, sb);
1090 new VisualStyleRenderer (element).DrawBackground (dc, sb.ClientRectangle, clip);
1092 protected override void DrawStatusBarSizingGrip (Graphics dc, Rectangle clip, StatusBar sb, Rectangle area)
1094 VisualStyleElement element = VisualStyleElement.Status.Gripper.Normal;
1095 if (!VisualStyleRenderer.IsElementDefined (element))
1096 base.DrawStatusBarSizingGrip (dc, clip, sb, area);
1097 VisualStyleRenderer renderer = new VisualStyleRenderer (element);
1098 Rectangle sizing_grip_rectangle = new Rectangle (Point.Empty, renderer.GetPartSize (dc, ThemeSizeType.True));
1099 sizing_grip_rectangle.X = sb.Width - sizing_grip_rectangle.Width;
1100 sizing_grip_rectangle.Y = sb.Height - sizing_grip_rectangle.Height;
1101 renderer.DrawBackground (dc, sizing_grip_rectangle, clip);
1103 protected override void DrawStatusBarPanelBackground (Graphics dc, Rectangle area, StatusBarPanel panel)
1105 VisualStyleElement element = VisualStyleElement.Status.Pane.Normal;
1106 if (!VisualStyleRenderer.IsElementDefined (element))
1107 base.DrawStatusBarPanelBackground (dc, area, panel);
1108 new VisualStyleRenderer (element).DrawBackground (dc, area);
1112 static bool TextBoxBaseShouldPaint (TextBoxBase textBoxBase)
1114 return textBoxBase.BorderStyle == BorderStyle.Fixed3D;
1116 static VisualStyleElement TextBoxBaseGetVisualStyleElement (TextBoxBase textBoxBase)
1118 if (!textBoxBase.Enabled)
1119 return VisualStyleElement.TextBox.TextEdit.Disabled;
1120 if (textBoxBase.ReadOnly)
1121 return VisualStyleElement.TextBox.TextEdit.ReadOnly;
1122 if (textBoxBase.Entered)
1123 return VisualStyleElement.TextBox.TextEdit.Hot;
1124 if (textBoxBase.Focused)
1125 return VisualStyleElement.TextBox.TextEdit.Focused;
1126 return VisualStyleElement.TextBox.TextEdit.Normal;
1128 public override void TextBoxBaseFillBackground (TextBoxBase textBoxBase, Graphics g, Rectangle clippingArea)
1130 if (!TextBoxBaseShouldPaint (textBoxBase)) {
1131 base.TextBoxBaseFillBackground (textBoxBase, g, clippingArea);
1134 VisualStyleElement element = TextBoxBaseGetVisualStyleElement (textBoxBase);
1135 if (!VisualStyleRenderer.IsElementDefined (element)) {
1136 base.TextBoxBaseFillBackground (textBoxBase, g, clippingArea);
1139 Rectangle bounds = new Rectangle(Point.Empty, textBoxBase.Size);
1140 bounds.X -= (bounds.Width - textBoxBase.ClientSize.Width) / 2;
1141 bounds.Y -= (bounds.Height - textBoxBase.ClientSize.Height) / 2;
1142 new VisualStyleRenderer (element).DrawBackground (g, bounds, clippingArea);
1144 public override bool TextBoxBaseHandleWmNcPaint (TextBoxBase textBoxBase, ref Message m)
1146 if (!TextBoxBaseShouldPaint (textBoxBase))
1147 return base.TextBoxBaseHandleWmNcPaint (textBoxBase, ref m);
1148 VisualStyleElement element = TextBoxBaseGetVisualStyleElement (textBoxBase);
1149 if (!VisualStyleRenderer.IsElementDefined (element))
1150 return base.TextBoxBaseHandleWmNcPaint (textBoxBase, ref m);
1151 PaintEventArgs e = XplatUI.PaintEventStart (ref m, textBoxBase.Handle, false);
1152 new VisualStyleRenderer (element).DrawBackgroundExcludingArea (
1154 new Rectangle (Point.Empty, textBoxBase.Size),
1155 new Rectangle (new Point ((textBoxBase.Width - textBoxBase.ClientSize.Width) / 2,
1156 (textBoxBase.Height - textBoxBase.ClientSize.Height) / 2),
1157 textBoxBase.ClientSize));
1158 XplatUI.PaintEventEnd (ref m, textBoxBase.Handle, false);
1161 public override bool TextBoxBaseShouldPaintBackground (TextBoxBase textBoxBase)
1163 if (!TextBoxBaseShouldPaint (textBoxBase))
1164 return base.TextBoxBaseShouldPaintBackground (textBoxBase);
1165 VisualStyleElement element = TextBoxBaseGetVisualStyleElement (textBoxBase);
1166 if (!VisualStyleRenderer.IsElementDefined (element))
1167 return base.TextBoxBaseShouldPaintBackground (textBoxBase);
1168 return new VisualStyleRenderer (element).IsBackgroundPartiallyTransparent ();
1172 protected override Size TrackBarGetThumbSize (TrackBar trackBar)
1174 VisualStyleElement element = TrackBarGetThumbVisualStyleElement (trackBar);
1175 if (!VisualStyleRenderer.IsElementDefined (element))
1176 return base.TrackBarGetThumbSize (trackBar);
1177 Graphics g = trackBar.CreateGraphics ();
1178 Size result = new VisualStyleRenderer (element).GetPartSize (g, ThemeSizeType.True);
1180 return trackBar.Orientation == Orientation.Horizontal ? result : TrackBarRotateVerticalThumbSize (result);
1182 static VisualStyleElement TrackBarGetThumbVisualStyleElement (TrackBar trackBar)
1184 if (trackBar.Orientation == Orientation.Horizontal)
1185 switch (trackBar.TickStyle) {
1186 case TickStyle.BottomRight:
1187 case TickStyle.None:
1188 return TrackBarGetHorizontalThumbBottomVisualStyleElement (trackBar);
1189 case TickStyle.TopLeft:
1190 return TrackBarGetHorizontalThumbTopVisualStyleElement (trackBar);
1192 return TrackBarGetHorizontalThumbVisualStyleElement (trackBar);
1195 switch (trackBar.TickStyle) {
1196 case TickStyle.BottomRight:
1197 case TickStyle.None:
1198 return TrackBarGetVerticalThumbRightVisualStyleElement (trackBar);
1199 case TickStyle.TopLeft:
1200 return TrackBarGetVerticalThumbLeftVisualStyleElement (trackBar);
1202 return TrackBarGetVerticalThumbVisualStyleElement (trackBar);
1205 static Size TrackBarRotateVerticalThumbSize (Size value)
1207 int temporary = value.Width;
1208 value.Width = value.Height;
1209 value.Height = temporary;
1213 protected override void TrackBarDrawHorizontalTrack (Graphics dc, Rectangle thumb_area, Point channel_startpoint, Rectangle clippingArea)
1215 VisualStyleElement element = VisualStyleElement.TrackBar.Track.Normal;
1216 if (!VisualStyleRenderer.IsElementDefined (element)) {
1217 base.TrackBarDrawHorizontalTrack (dc, thumb_area, channel_startpoint, clippingArea);
1220 VisualStyleRenderer renderer = new VisualStyleRenderer (element);
1221 renderer.DrawBackground (dc, new Rectangle (channel_startpoint, new Size (thumb_area.Width, renderer.GetPartSize (dc, ThemeSizeType.True).Height)), clippingArea);
1223 protected override void TrackBarDrawVerticalTrack (Graphics dc, Rectangle thumb_area, Point channel_startpoint, Rectangle clippingArea)
1225 VisualStyleElement element = VisualStyleElement.TrackBar.TrackVertical.Normal;
1226 if (!VisualStyleRenderer.IsElementDefined (element)) {
1227 base.TrackBarDrawVerticalTrack (dc, thumb_area, channel_startpoint, clippingArea);
1230 VisualStyleRenderer renderer = new VisualStyleRenderer (element);
1231 renderer.DrawBackground (dc, new Rectangle (channel_startpoint, new Size (renderer.GetPartSize (dc, ThemeSizeType.True).Width, thumb_area.Height)), clippingArea);
1235 static bool TrackBarIsDisabled (TrackBar trackBar)
1237 return !trackBar.Enabled;
1239 static bool TrackBarIsHot (TrackBar trackBar)
1241 return trackBar.ThumbEntered;
1243 static bool TrackBarIsPressed (TrackBar trackBar)
1245 return trackBar.thumb_pressed;
1247 static bool TrackBarIsFocused (TrackBar trackBar)
1249 return trackBar.Focused;
1252 protected override void TrackBarDrawHorizontalThumbBottom (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
1254 VisualStyleElement element = TrackBarGetHorizontalThumbBottomVisualStyleElement (trackBar);
1255 if (!VisualStyleRenderer.IsElementDefined (element)) {
1256 base.TrackBarDrawHorizontalThumbBottom (dc, thumb_pos, br_thumb, clippingArea, trackBar);
1259 new VisualStyleRenderer (element).DrawBackground (dc, thumb_pos, clippingArea);
1261 static VisualStyleElement TrackBarGetHorizontalThumbBottomVisualStyleElement (TrackBar trackBar)
1263 if (TrackBarIsDisabled (trackBar))
1264 return VisualStyleElement.TrackBar.ThumbBottom.Disabled;
1265 else if (TrackBarIsPressed (trackBar))
1266 return VisualStyleElement.TrackBar.ThumbBottom.Pressed;
1267 else if (TrackBarIsHot (trackBar))
1268 return VisualStyleElement.TrackBar.ThumbBottom.Hot;
1269 else if (TrackBarIsFocused (trackBar))
1270 return VisualStyleElement.TrackBar.ThumbBottom.Focused;
1271 return VisualStyleElement.TrackBar.ThumbBottom.Normal;
1273 protected override void TrackBarDrawHorizontalThumbTop (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
1275 VisualStyleElement element = TrackBarGetHorizontalThumbTopVisualStyleElement (trackBar);
1276 if (!VisualStyleRenderer.IsElementDefined (element)) {
1277 base.TrackBarDrawHorizontalThumbTop (dc, thumb_pos, br_thumb, clippingArea, trackBar);
1280 new VisualStyleRenderer (element).DrawBackground (dc, thumb_pos, clippingArea);
1282 static VisualStyleElement TrackBarGetHorizontalThumbTopVisualStyleElement (TrackBar trackBar)
1284 if (TrackBarIsDisabled (trackBar))
1285 return VisualStyleElement.TrackBar.ThumbTop.Disabled;
1286 else if (TrackBarIsPressed (trackBar))
1287 return VisualStyleElement.TrackBar.ThumbTop.Pressed;
1288 else if (TrackBarIsHot (trackBar))
1289 return VisualStyleElement.TrackBar.ThumbTop.Hot;
1290 else if (TrackBarIsFocused (trackBar))
1291 return VisualStyleElement.TrackBar.ThumbTop.Focused;
1292 return VisualStyleElement.TrackBar.ThumbTop.Normal;
1294 protected override void TrackBarDrawHorizontalThumb (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
1296 VisualStyleElement element = TrackBarGetHorizontalThumbVisualStyleElement (trackBar);
1297 if (!VisualStyleRenderer.IsElementDefined (element)) {
1298 base.TrackBarDrawHorizontalThumb (dc, thumb_pos, br_thumb, clippingArea, trackBar);
1301 new VisualStyleRenderer (element).DrawBackground (dc, thumb_pos, clippingArea);
1303 static VisualStyleElement TrackBarGetHorizontalThumbVisualStyleElement (TrackBar trackBar)
1305 if (TrackBarIsDisabled (trackBar))
1306 return VisualStyleElement.TrackBar.Thumb.Disabled;
1307 else if (TrackBarIsPressed (trackBar))
1308 return VisualStyleElement.TrackBar.Thumb.Pressed;
1309 else if (TrackBarIsHot (trackBar))
1310 return VisualStyleElement.TrackBar.Thumb.Hot;
1311 else if (TrackBarIsFocused (trackBar))
1312 return VisualStyleElement.TrackBar.Thumb.Focused;
1313 return VisualStyleElement.TrackBar.Thumb.Normal;
1317 static Rectangle TrackBarRotateVerticalThumbSize (Rectangle value)
1319 int temporary = value.Width;
1320 value.Width = value.Height;
1321 value.Height = temporary;
1324 protected override void TrackBarDrawVerticalThumbRight (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
1326 VisualStyleElement element = TrackBarGetVerticalThumbRightVisualStyleElement (trackBar);
1327 if (!VisualStyleRenderer.IsElementDefined (element)) {
1328 base.TrackBarDrawVerticalThumbRight (dc, thumb_pos, br_thumb, clippingArea, trackBar);
1331 new VisualStyleRenderer (element).DrawBackground (dc, TrackBarRotateVerticalThumbSize (thumb_pos), clippingArea);
1333 static VisualStyleElement TrackBarGetVerticalThumbRightVisualStyleElement (TrackBar trackBar)
1335 if (TrackBarIsDisabled (trackBar))
1336 return VisualStyleElement.TrackBar.ThumbRight.Disabled;
1337 else if (TrackBarIsPressed (trackBar))
1338 return VisualStyleElement.TrackBar.ThumbRight.Pressed;
1339 else if (TrackBarIsHot (trackBar))
1340 return VisualStyleElement.TrackBar.ThumbRight.Hot;
1341 else if (TrackBarIsFocused (trackBar))
1342 return VisualStyleElement.TrackBar.ThumbRight.Focused;
1343 return VisualStyleElement.TrackBar.ThumbRight.Normal;
1345 protected override void TrackBarDrawVerticalThumbLeft (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
1347 VisualStyleElement element = TrackBarGetVerticalThumbLeftVisualStyleElement (trackBar);
1348 if (!VisualStyleRenderer.IsElementDefined (element)) {
1349 base.TrackBarDrawVerticalThumbLeft (dc, thumb_pos, br_thumb, clippingArea, trackBar);
1352 new VisualStyleRenderer (element).DrawBackground (dc, TrackBarRotateVerticalThumbSize (thumb_pos), clippingArea);
1354 static VisualStyleElement TrackBarGetVerticalThumbLeftVisualStyleElement (TrackBar trackBar)
1356 if (TrackBarIsDisabled (trackBar))
1357 return VisualStyleElement.TrackBar.ThumbLeft.Disabled;
1358 else if (TrackBarIsPressed (trackBar))
1359 return VisualStyleElement.TrackBar.ThumbLeft.Pressed;
1360 else if (TrackBarIsHot (trackBar))
1361 return VisualStyleElement.TrackBar.ThumbLeft.Hot;
1362 else if (TrackBarIsFocused (trackBar))
1363 return VisualStyleElement.TrackBar.ThumbLeft.Focused;
1364 return VisualStyleElement.TrackBar.ThumbLeft.Normal;
1366 protected override void TrackBarDrawVerticalThumb (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
1368 VisualStyleElement element = TrackBarGetVerticalThumbVisualStyleElement (trackBar);
1369 if (!VisualStyleRenderer.IsElementDefined (element)) {
1370 base.TrackBarDrawVerticalThumb (dc, thumb_pos, br_thumb, clippingArea, trackBar);
1373 new VisualStyleRenderer (element).DrawBackground (dc, TrackBarRotateVerticalThumbSize (thumb_pos), clippingArea);
1375 static VisualStyleElement TrackBarGetVerticalThumbVisualStyleElement (TrackBar trackBar)
1377 if (TrackBarIsDisabled (trackBar))
1378 return VisualStyleElement.TrackBar.ThumbVertical.Disabled;
1379 else if (TrackBarIsPressed (trackBar))
1380 return VisualStyleElement.TrackBar.ThumbVertical.Pressed;
1381 else if (TrackBarIsHot (trackBar))
1382 return VisualStyleElement.TrackBar.ThumbVertical.Hot;
1383 else if (TrackBarIsFocused (trackBar))
1384 return VisualStyleElement.TrackBar.ThumbVertical.Focused;
1385 return VisualStyleElement.TrackBar.ThumbVertical.Normal;
1390 const EdgeStyle TrackBarTickEdgeStyle = EdgeStyle.Bump;
1391 const EdgeEffects TrackBarTickEdgeEffects = EdgeEffects.None;
1393 protected override ITrackBarTickPainter TrackBarGetHorizontalTickPainter (Graphics g)
1395 if (!VisualStyleRenderer.IsElementDefined (VisualStyleElement.TrackBar.Ticks.Normal))
1396 return base.TrackBarGetHorizontalTickPainter (g);
1397 return new TrackBarHorizontalTickPainter (g);
1399 class TrackBarHorizontalTickPainter : ITrackBarTickPainter
1401 readonly Graphics g;
1402 readonly VisualStyleRenderer renderer;
1403 public TrackBarHorizontalTickPainter (Graphics g)
1406 renderer = new VisualStyleRenderer (VisualStyleElement.TrackBar.Ticks.Normal);
1408 public void Paint (float x1, float y1, float x2, float y2)
1410 renderer.DrawEdge (g, new Rectangle (
1411 (int)Math.Round (x1),
1412 (int)Math.Round (y1),
1414 (int)Math.Round (y2 - y1) + 1), Edges.Left, TrackBarTickEdgeStyle, TrackBarTickEdgeEffects);
1419 protected override ITrackBarTickPainter TrackBarGetVerticalTickPainter (Graphics g)
1421 if (!VisualStyleRenderer.IsElementDefined (VisualStyleElement.TrackBar.TicksVertical.Normal))
1422 return base.TrackBarGetVerticalTickPainter (g);
1423 return new TrackBarVerticalTickPainter (g);
1425 class TrackBarVerticalTickPainter : ITrackBarTickPainter
1427 readonly Graphics g;
1428 readonly VisualStyleRenderer renderer;
1429 public TrackBarVerticalTickPainter (Graphics g)
1432 renderer = new VisualStyleRenderer (VisualStyleElement.TrackBar.TicksVertical.Normal);
1434 public void Paint (float x1, float y1, float x2, float y2)
1436 renderer.DrawEdge (g, new Rectangle (
1437 (int)Math.Round (x1),
1438 (int)Math.Round (y1),
1439 (int)Math.Round (x2 - x1) + 1,
1440 1), Edges.Top, TrackBarTickEdgeStyle, TrackBarTickEdgeEffects);
1445 public override bool TrackBarHasHotThumbStyle {
1452 static bool ToolBarIsDisabled (ToolBarItem item)
1454 return !item.Button.Enabled;
1456 static bool ToolBarIsPressed (ToolBarItem item)
1458 return item.Pressed;
1460 static bool ToolBarIsChecked (ToolBarItem item)
1462 return item.Button.Pushed;
1464 static bool ToolBarIsHot (ToolBarItem item)
1466 return item.Hilight;
1469 protected override void DrawToolBarButtonBorder (Graphics dc, ToolBarItem item, bool is_flat)
1471 if (item.Button.Style == ToolBarButtonStyle.Separator)
1473 VisualStyleElement element;
1474 if (item.Button.Style == ToolBarButtonStyle.DropDownButton)
1475 element = ToolBarGetDropDownButtonVisualStyleElement (item);
1477 element = ToolBarGetButtonVisualStyleElement (item);
1478 if (!VisualStyleRenderer.IsElementDefined (element)) {
1479 base.DrawToolBarButtonBorder (dc, item, is_flat);
1482 Rectangle rectangle = item.Rectangle;
1483 if (item.Button.Style == ToolBarButtonStyle.DropDownButton && item.Button.Parent.DropDownArrows)
1484 rectangle.Width -= ToolBarDropDownWidth;
1485 new VisualStyleRenderer (element).DrawBackground (dc, rectangle);
1487 private static VisualStyleElement ToolBarGetDropDownButtonVisualStyleElement (ToolBarItem item)
1489 if (item.Button.Parent.DropDownArrows) {
1490 if (ToolBarIsDisabled (item))
1491 return VisualStyleElement.ToolBar.SplitButton.Disabled;
1492 if (ToolBarIsPressed (item))
1493 return VisualStyleElement.ToolBar.SplitButton.Pressed;
1494 if (ToolBarIsChecked (item))
1495 if (ToolBarIsHot (item))
1496 return VisualStyleElement.ToolBar.SplitButton.HotChecked;
1498 return VisualStyleElement.ToolBar.SplitButton.Checked;
1499 if (ToolBarIsHot (item))
1500 return VisualStyleElement.ToolBar.SplitButton.Hot;
1501 return VisualStyleElement.ToolBar.SplitButton.Normal;
1503 if (ToolBarIsDisabled (item))
1504 return VisualStyleElement.ToolBar.DropDownButton.Disabled;
1505 if (ToolBarIsPressed (item))
1506 return VisualStyleElement.ToolBar.DropDownButton.Pressed;
1507 if (ToolBarIsChecked (item))
1508 if (ToolBarIsHot (item))
1509 return VisualStyleElement.ToolBar.DropDownButton.HotChecked;
1511 return VisualStyleElement.ToolBar.DropDownButton.Checked;
1512 if (ToolBarIsHot (item))
1513 return VisualStyleElement.ToolBar.DropDownButton.Hot;
1514 return VisualStyleElement.ToolBar.DropDownButton.Normal;
1517 private static VisualStyleElement ToolBarGetButtonVisualStyleElement (ToolBarItem item)
1519 if (ToolBarIsDisabled (item))
1520 return VisualStyleElement.ToolBar.Button.Disabled;
1521 if (ToolBarIsPressed (item))
1522 return VisualStyleElement.ToolBar.Button.Pressed;
1523 if (ToolBarIsChecked (item))
1524 if (ToolBarIsHot (item))
1525 return VisualStyleElement.ToolBar.Button.HotChecked;
1527 return VisualStyleElement.ToolBar.Button.Checked;
1528 if (ToolBarIsHot (item))
1529 return VisualStyleElement.ToolBar.Button.Hot;
1530 return VisualStyleElement.ToolBar.Button.Normal;
1534 protected override void DrawToolBarSeparator (Graphics dc, ToolBarItem item)
1536 VisualStyleElement element = ToolBarGetSeparatorVisualStyleElement (item);
1537 if (!VisualStyleRenderer.IsElementDefined (element)) {
1538 base.DrawToolBarSeparator (dc, item);
1541 Rectangle area = item.Rectangle;
1542 new VisualStyleRenderer (element).DrawBackground (dc, item.Rectangle);
1544 static VisualStyleElement ToolBarGetSeparatorVisualStyleElement (ToolBarItem toolBarItem)
1546 return toolBarItem.Button.Parent.Vertical ?
1547 VisualStyleElement.ToolBar.SeparatorVertical.Normal :
1548 VisualStyleElement.ToolBar.SeparatorHorizontal.Normal;
1551 #region Toggle button background
1552 protected override void DrawToolBarToggleButtonBackground (Graphics dc, ToolBarItem item)
1554 if (!VisualStyleRenderer.IsElementDefined (ToolBarGetButtonVisualStyleElement (item)))
1555 base.DrawToolBarToggleButtonBackground (dc, item);
1558 #region Drop down arrow
1559 protected override void DrawToolBarDropDownArrow (Graphics dc, ToolBarItem item, bool is_flat)
1561 VisualStyleElement element = ToolBarGetDropDownArrowVisualStyleElement (item);
1562 if (!VisualStyleRenderer.IsElementDefined (element)) {
1563 base.DrawToolBarDropDownArrow (dc, item, is_flat);
1566 Rectangle rect = item.Rectangle;
1567 rect.X = item.Rectangle.Right - ToolBarDropDownWidth;
1568 rect.Width = ToolBarDropDownWidth;
1569 new VisualStyleRenderer (element).DrawBackground (dc, rect);
1571 private static VisualStyleElement ToolBarGetDropDownArrowVisualStyleElement (ToolBarItem item)
1573 if (ToolBarIsDisabled (item))
1574 return VisualStyleElement.ToolBar.SplitButtonDropDown.Disabled;
1575 if (ToolBarIsPressed (item))
1576 return VisualStyleElement.ToolBar.SplitButtonDropDown.Pressed;
1577 if (ToolBarIsChecked (item))
1578 if (ToolBarIsHot (item))
1579 return VisualStyleElement.ToolBar.SplitButtonDropDown.HotChecked;
1581 return VisualStyleElement.ToolBar.SplitButtonDropDown.Checked;
1582 if (ToolBarIsHot (item))
1583 return VisualStyleElement.ToolBar.SplitButtonDropDown.Hot;
1584 return VisualStyleElement.ToolBar.SplitButtonDropDown.Normal;
1587 public override bool ToolBarHasHotElementStyles (ToolBar toolBar)
1591 public override bool ToolBarHasHotCheckedElementStyles {
1598 protected override void ToolTipDrawBackground (Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control)
1600 VisualStyleElement element = VisualStyleElement.ToolTip.Standard.Normal;
1601 if (!VisualStyleRenderer.IsElementDefined (element)) {
1602 base.ToolTipDrawBackground (dc, clip_rectangle, control);
1605 new VisualStyleRenderer (element).DrawBackground (dc, control.Bounds);
1607 public override bool ToolTipTransparentBackground {
1609 VisualStyleElement element = VisualStyleElement.ToolTip.Standard.Normal;
1610 if (!VisualStyleRenderer.IsElementDefined (element))
1611 return base.ToolTipTransparentBackground;
1612 return new VisualStyleRenderer (element).IsBackgroundPartiallyTransparent ();
1617 [MonoTODO("Use the sizing information provided by the VisualStyles API.")]
1618 public override void TreeViewDrawNodePlusMinus (TreeView treeView, TreeNode node, Graphics dc, int x, int middle)
1620 VisualStyleElement element = node.IsExpanded ?
1621 VisualStyleElement.TreeView.Glyph.Opened :
1622 VisualStyleElement.TreeView.Glyph.Closed;
1623 if (!VisualStyleRenderer.IsElementDefined (element)) {
1624 base.TreeViewDrawNodePlusMinus (treeView, node, dc, x, middle);
1627 new VisualStyleRenderer (element).DrawBackground (dc, new Rectangle (x, middle - 4, 9, 9));
1631 public override void UpDownBaseDrawButton (Graphics g, Rectangle bounds, bool top, PushButtonState state)
1633 VisualStyleElement element;
1636 case PushButtonState.Disabled:
1637 element = VisualStyleElement.Spin.Up.Disabled;
1639 case PushButtonState.Pressed:
1640 element = VisualStyleElement.Spin.Up.Pressed;
1642 case PushButtonState.Hot:
1643 element = VisualStyleElement.Spin.Up.Hot;
1646 element = VisualStyleElement.Spin.Up.Normal;
1651 case PushButtonState.Disabled:
1652 element = VisualStyleElement.Spin.Down.Disabled;
1654 case PushButtonState.Pressed:
1655 element = VisualStyleElement.Spin.Down.Pressed;
1657 case PushButtonState.Hot:
1658 element = VisualStyleElement.Spin.Down.Hot;
1661 element = VisualStyleElement.Spin.Down.Normal;
1664 if (!VisualStyleRenderer.IsElementDefined (element)) {
1665 base.UpDownBaseDrawButton (g, bounds, top, state);
1668 new VisualStyleRenderer (element).DrawBackground (g, bounds);
1670 public override bool UpDownBaseHasHotButtonStyle {
1677 static bool AreEqual (VisualStyleElement value1, VisualStyleElement value2)
1680 value1.ClassName == value1.ClassName &&
1681 value1.Part == value2.Part &&
1682 value1.State == value2.State;