Fix bug #395
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / Theme.cs
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:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
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.
19 //
20 // Copyright (c) 2004-2005 Novell, Inc.
21 //
22 // Authors:
23 //      Jordi Mas i Hernandez, jordi@ximian.com
24 //      Peter Dennis Bartok, pbartok@novell.com
25 //
26
27 using System.Collections;
28 using System.Drawing;
29 using System.Drawing.Drawing2D;
30 using System.Reflection;
31
32 namespace System.Windows.Forms
33 {
34         internal enum UIIcon {
35                 PlacesRecentDocuments,
36                 PlacesDesktop,
37                 PlacesPersonal,
38                 PlacesMyComputer,
39                 PlacesMyNetwork,
40                 MessageBoxError,
41                 MessageBoxQuestion,
42                 MessageBoxWarning,
43                 MessageBoxInfo,
44                 
45                 NormalFolder
46         }
47         
48         internal struct CPColor {
49                 internal Color Dark;
50                 internal Color DarkDark;
51                 internal Color Light;
52                 internal Color LightLight;
53                 
54                 internal static CPColor Empty;
55         }
56         
57         // Implements a pool of system resources
58         internal class SystemResPool
59         {
60                 private Hashtable pens = new Hashtable ();
61                 private Hashtable dashpens = new Hashtable ();
62                 private Hashtable sizedpens = new Hashtable ();
63                 private Hashtable solidbrushes = new Hashtable ();
64                 private Hashtable hatchbrushes = new Hashtable ();
65                 private Hashtable uiImages = new Hashtable();
66                 private Hashtable cpcolors = new Hashtable ();
67                 
68                 public SystemResPool () {}
69                 
70                 public Pen GetPen (Color color)
71                 {
72                         int hash = color.ToArgb ();
73
74                         lock (pens) {
75                                 Pen res = pens [hash] as Pen;
76                                 if (res != null)
77                                         return res;
78                         
79                                 Pen pen = new Pen (color);
80                                 pens.Add (hash, pen);
81                                 return pen;
82                         }
83                 }
84                 
85                 public Pen GetDashPen (Color color, DashStyle dashStyle)
86                 {
87                         string hash = color.ToString() + dashStyle;
88
89                         lock (dashpens) {
90                                 Pen res = dashpens [hash] as Pen;
91                                 if (res != null)
92                                         return res;
93                         
94                                 Pen pen = new Pen (color);
95                                 pen.DashStyle = dashStyle;
96                                 dashpens [hash] = pen;
97                                 return pen;
98                         }
99                 }
100                 
101                 public Pen GetSizedPen (Color color, int size)
102                 {
103                         string hash = color.ToString () + size;
104                         
105                         lock (sizedpens) {
106                                 Pen res = sizedpens [hash] as Pen;
107                                 if (res != null)
108                                         return res;
109                         
110                                 Pen pen = new Pen (color, size);
111                                 sizedpens [hash] = pen;
112                                 return pen;
113                         }
114                 }
115                 
116                 public SolidBrush GetSolidBrush (Color color)
117                 {
118                         int hash = color.ToArgb ();
119
120                         lock (solidbrushes) {
121                                 SolidBrush res = solidbrushes [hash] as SolidBrush;
122                                 if (res != null)
123                                         return res;
124                         
125                                 SolidBrush brush = new SolidBrush (color);
126                                 solidbrushes.Add (hash, brush);
127                                 return brush;
128                         }
129                 }               
130                 
131                 public HatchBrush GetHatchBrush (HatchStyle hatchStyle, Color foreColor, Color backColor)
132                 {
133                         string hash = ((int)hatchStyle).ToString () + foreColor.ToString () + backColor.ToString ();
134
135                         lock (hatchbrushes) {
136                                 HatchBrush brush = (HatchBrush) hatchbrushes[hash];
137                                 if (brush == null) {
138                                         brush = new HatchBrush (hatchStyle, foreColor, backColor);
139                                         hatchbrushes.Add (hash, brush);
140                                 }
141                                 return brush;
142                         }
143                 }
144                 
145                 public void AddUIImage (Image image, string name, int size)
146                 {
147                         string hash = name + size.ToString();
148
149                         lock (uiImages) {
150                                 if (uiImages.Contains (hash))
151                                         return;
152                                 uiImages.Add (hash, image);
153                         }
154                 }
155                 
156                 public Image GetUIImage(string name, int size)
157                 {
158                         string hash = name + size.ToString();
159                         
160                         Image image = uiImages [hash] as Image;
161                         
162                         return image;
163                 }
164                 
165                 public CPColor GetCPColor (Color color)
166                 {
167                         lock (cpcolors) {
168                                 object tmp = cpcolors [color];
169                         
170                                 if (tmp == null) {
171                                         CPColor cpcolor = new CPColor ();
172                                         cpcolor.Dark = ControlPaint.Dark (color);
173                                         cpcolor.DarkDark = ControlPaint.DarkDark (color);
174                                         cpcolor.Light = ControlPaint.Light (color);
175                                         cpcolor.LightLight = ControlPaint.LightLight (color);
176                                 
177                                         cpcolors.Add (color, cpcolor);
178
179                                         return cpcolor;
180                                 }
181                         
182                                 return (CPColor)tmp;
183                         }
184                 }
185         }
186
187         internal abstract class Theme
188         {
189                 protected Array syscolors;
190                 private readonly Font default_font;
191                 protected Font window_border_font;
192                 protected Color defaultWindowBackColor;
193                 protected Color defaultWindowForeColor;
194                 internal SystemResPool ResPool = new SystemResPool ();
195                 private MethodInfo update;
196
197                 protected Theme ()
198                 {
199                         default_font = SystemFonts.DefaultFont;
200                         syscolors = null;
201                 }
202
203                 private void SetSystemColors (KnownColor kc, Color value)
204                 {
205                         if (update == null) {
206                                 Type known_colors = Type.GetType ("System.Drawing.KnownColors, " + Consts.AssemblySystem_Drawing);
207                                 if (known_colors != null)
208                                         update = known_colors.GetMethod ("Update", BindingFlags.Static | BindingFlags.Public);
209                         }
210                         if (update != null)
211                                 update.Invoke (null, new object [2] { (int)kc, value.ToArgb () });
212                 }
213
214                 /* OS Feature support */
215                 public abstract Version Version {
216                         get;
217                 }
218
219                 /* Default properties */
220                 public virtual Color ColorScrollBar {
221                         get { return SystemColors.ScrollBar; }
222                         set { SetSystemColors (KnownColor.ScrollBar, value); }
223                 }
224
225                 public virtual Color ColorDesktop {
226                         get { return SystemColors.Desktop;}
227                         set { SetSystemColors (KnownColor.Desktop, value); }
228                 }
229
230                 public virtual Color ColorActiveCaption {
231                         get { return SystemColors.ActiveCaption;}
232                         set { SetSystemColors (KnownColor.ActiveCaption, value); }
233                 }
234
235                 public virtual Color ColorInactiveCaption {
236                         get { return SystemColors.InactiveCaption;}
237                         set { SetSystemColors (KnownColor.InactiveCaption, value); }
238                 }
239
240                 public virtual Color ColorMenu {
241                         get { return SystemColors.Menu;}
242                         set { SetSystemColors (KnownColor.Menu, value); }
243                 }
244
245                 public virtual Color ColorWindow {
246                         get { return SystemColors.Window;}
247                         set { SetSystemColors (KnownColor.Window, value); }
248                 }
249
250                 public virtual Color ColorWindowFrame {
251                         get { return SystemColors.WindowFrame;}
252                         set { SetSystemColors (KnownColor.WindowFrame, value); }
253                 }
254
255                 public virtual Color ColorMenuText {
256                         get { return SystemColors.MenuText;}
257                         set { SetSystemColors (KnownColor.MenuText, value); }
258                 }
259
260                 public virtual Color ColorWindowText {
261                         get { return SystemColors.WindowText;}
262                         set { SetSystemColors (KnownColor.WindowText, value); }
263                 }
264
265                 public virtual Color ColorActiveCaptionText {
266                         get { return SystemColors.ActiveCaptionText;}
267                         set { SetSystemColors (KnownColor.ActiveCaptionText, value); }
268                 }
269
270                 public virtual Color ColorActiveBorder {
271                         get { return SystemColors.ActiveBorder;}
272                         set { SetSystemColors (KnownColor.ActiveBorder, value); }
273                 }
274
275                 public virtual Color ColorInactiveBorder{
276                         get { return SystemColors.InactiveBorder;}
277                         set { SetSystemColors (KnownColor.InactiveBorder, value); }
278                 }
279
280                 public virtual Color ColorAppWorkspace {
281                         get { return SystemColors.AppWorkspace;}
282                         set { SetSystemColors (KnownColor.AppWorkspace, value); }
283                 }
284
285                 public virtual Color ColorHighlight {
286                         get { return SystemColors.Highlight;}
287                         set { SetSystemColors (KnownColor.Highlight, value); }
288                 }
289
290                 public virtual Color ColorHighlightText {
291                         get { return SystemColors.HighlightText;}
292                         set { SetSystemColors (KnownColor.HighlightText, value); }
293                 }
294
295                 public virtual Color ColorControl {
296                         get { return SystemColors.Control;}
297                         set { SetSystemColors (KnownColor.Control, value); }
298                 }
299
300                 public virtual Color ColorControlDark {
301                         get { return SystemColors.ControlDark;}
302                         set { SetSystemColors (KnownColor.ControlDark, value); }
303                 }
304
305                 public virtual Color ColorGrayText {
306                         get { return SystemColors.GrayText;}
307                         set { SetSystemColors (KnownColor.GrayText, value); }
308                 }
309
310                 public virtual Color ColorControlText {
311                         get { return SystemColors.ControlText;}
312                         set { SetSystemColors (KnownColor.ControlText, value); }
313                 }
314
315                 public virtual Color ColorInactiveCaptionText {
316                         get { return SystemColors.InactiveCaptionText;}
317                         set { SetSystemColors (KnownColor.InactiveCaptionText, value); }
318                 }
319
320                 public virtual Color ColorControlLight {
321                         get { return SystemColors.ControlLight;}
322                         set { SetSystemColors (KnownColor.ControlLight, value); }
323                 }
324
325                 public virtual Color ColorControlDarkDark {
326                         get { return SystemColors.ControlDarkDark;}
327                         set { SetSystemColors (KnownColor.ControlDarkDark, value); }
328                 }
329
330                 public virtual Color ColorControlLightLight {
331                         get { return SystemColors.ControlLightLight;}
332                         set { SetSystemColors (KnownColor.ControlLightLight, value); }
333                 }
334
335                 public virtual Color ColorInfoText {
336                         get { return SystemColors.InfoText;}
337                         set { SetSystemColors (KnownColor.InfoText, value); }
338                 }
339
340                 public virtual Color ColorInfo {
341                         get { return SystemColors.Info;}
342                         set { SetSystemColors (KnownColor.Info, value); }
343                 }
344
345                 public virtual Color ColorHotTrack {
346                         get { return SystemColors.HotTrack;}
347                         set { SetSystemColors (KnownColor.HotTrack, value);}
348                 }
349
350                 public virtual Color DefaultControlBackColor {
351                         get { return ColorControl; }
352                         set { ColorControl = value; }
353                 }
354
355                 public virtual Color DefaultControlForeColor {
356                         get { return ColorControlText; }
357                         set { ColorControlText = value; }
358                 }
359
360                 public virtual Font DefaultFont {
361                         get { return default_font; }
362                 }
363
364                 public virtual Color DefaultWindowBackColor {
365                         get { return defaultWindowBackColor; }
366                 }
367
368                 public virtual Color DefaultWindowForeColor {
369                         get { return defaultWindowForeColor; }
370                 }
371
372                 public virtual Color GetColor (XplatUIWin32.GetSysColorIndex idx)
373                 {
374                         return (Color) syscolors.GetValue ((int)idx);
375                 }
376
377                 public virtual void SetColor (XplatUIWin32.GetSysColorIndex idx, Color color)
378                 {
379                         syscolors.SetValue (color, (int) idx);
380                 }
381
382                 // Theme/UI specific defaults
383                 public virtual ArrangeDirection ArrangeDirection  {
384                         get {
385                                 return ArrangeDirection.Down;
386                         }
387                 }
388
389                 public virtual ArrangeStartingPosition ArrangeStartingPosition {
390                         get {
391                                 return ArrangeStartingPosition.BottomLeft;
392                         }
393                 }
394
395                 public virtual int BorderMultiplierFactor { get { return 1; } }
396                 
397                 public virtual Size BorderSizableSize {
398                         get {
399                                 return new Size (3, 3);
400                         }
401                 }
402
403                 public virtual Size Border3DSize {
404                         get {
405                                 return XplatUI.Border3DSize;
406                         }
407                 }
408
409                 public virtual Size BorderStaticSize {
410                         get {
411                                 return new Size(1, 1);
412                         }
413                 }
414
415                 public virtual Size BorderSize {
416                         get {
417                                 return XplatUI.BorderSize;
418                         }
419                 }
420
421                 public virtual Size CaptionButtonSize {
422                         get {
423                                 return XplatUI.CaptionButtonSize;
424                         }
425                 }
426
427                 public virtual int CaptionHeight {
428                         get {
429                                 return XplatUI.CaptionHeight;
430                         }
431                 }
432
433                 public virtual Size DoubleClickSize {
434                         get {
435                                 return new Size(4, 4);
436                         }
437                 }
438
439                 public virtual int DoubleClickTime {
440                         get {
441                                 return XplatUI.DoubleClickTime;
442                         }
443                 }
444
445                 public virtual Size FixedFrameBorderSize {
446                         get {
447                                 return XplatUI.FixedFrameBorderSize;
448                         }
449                 }
450
451                 public virtual Size FrameBorderSize {
452                         get {
453                                 return XplatUI.FrameBorderSize;
454                         }
455                 }
456
457                 public virtual int HorizontalFocusThickness { get { return 1; } }
458                 
459                 public virtual int HorizontalScrollBarArrowWidth {
460                         get {
461                                 return 16;
462                         }
463                 }
464
465                 public virtual int HorizontalScrollBarHeight {
466                         get {
467                                 return 16;
468                         }
469                 }
470
471                 public virtual int HorizontalScrollBarThumbWidth {
472                         get {
473                                 return 16;
474                         }
475                 }
476
477                 public virtual Size IconSpacingSize {
478                         get {
479                                 return new Size(75, 75);
480                         }
481                 }
482
483                 public virtual bool MenuAccessKeysUnderlined {
484                         get {
485                                 return XplatUI.MenuAccessKeysUnderlined;
486                         }
487                 }
488                 
489                 public virtual Size MenuBarButtonSize {
490                         get { return XplatUI.MenuBarButtonSize; }
491                 }
492                 
493                 public virtual Size MenuButtonSize {
494                         get {
495                                 return XplatUI.MenuButtonSize;
496                         }
497                 }
498
499                 public virtual Size MenuCheckSize {
500                         get {
501                                 return new Size(13, 13);
502                         }
503                 }
504
505                 public virtual Font MenuFont {
506                         get {
507                                 return default_font;
508                         }
509                 }
510
511                 public virtual int MenuHeight {
512                         get {
513                                 return XplatUI.MenuHeight;
514                         }
515                 }
516
517                 public virtual int MouseWheelScrollLines {
518                         get {
519                                 return 3;
520                         }
521                 }
522
523                 public virtual bool RightAlignedMenus {
524                         get {
525                                 return false;
526                         }
527                 }
528
529                 public virtual Size ToolWindowCaptionButtonSize {
530                         get {
531                                 return XplatUI.ToolWindowCaptionButtonSize;
532                         }
533                 }
534
535                 public virtual int ToolWindowCaptionHeight {
536                         get {
537                                 return XplatUI.ToolWindowCaptionHeight;
538                         }
539                 }
540
541                 public virtual int VerticalFocusThickness { get { return 1; } }
542
543                 public virtual int VerticalScrollBarArrowHeight {
544                         get {
545                                 return 16;
546                         }
547                 }
548
549                 public virtual int VerticalScrollBarThumbHeight {
550                         get {
551                                 return 16;
552                         }
553                 }
554
555                 public virtual int VerticalScrollBarWidth {
556                         get {
557                                 return 16;
558                         }
559                 }
560
561                 public virtual Font WindowBorderFont {
562                         get {
563                                 return window_border_font;
564                         }
565                 }
566
567                 public int Clamp (int value, int lower, int upper)
568                 {
569                         if (value < lower) return lower;
570                         else if (value > upper) return upper;
571                         else return value;
572                 }
573
574                 [MonoInternalNote ("Figure out where to point for My Network Places")]
575                 public virtual string Places(UIIcon index) {
576                         switch (index) {
577                                 case UIIcon.PlacesRecentDocuments: {
578                                         // Default = "Recent Documents"
579                                         return Environment.GetFolderPath(Environment.SpecialFolder.Recent);
580                                 }
581
582                                 case UIIcon.PlacesDesktop: {
583                                         // Default = "Desktop"
584                                         return Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
585                                 }
586
587                                 case UIIcon.PlacesPersonal: {
588                                         // Default = "My Documents"
589                                         return Environment.GetFolderPath(Environment.SpecialFolder.Personal);
590                                 }
591
592                                 case UIIcon.PlacesMyComputer: {
593                                         // Default = "My Computer"
594                                         return Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
595                                 }
596
597                                 case UIIcon.PlacesMyNetwork: {
598                                         // Default = "My Network Places"
599                                         return "/tmp";
600                                 }
601
602                                 default: {
603                                         throw new ArgumentOutOfRangeException("index", index, "Unsupported place");
604                                 }
605                         }
606                 }
607
608                 //
609                 // This routine fetches images embedded as assembly resources (not
610                 // resgen resources).  It optionally scales the image to fit the
611                 // specified size x dimension (it adjusts y automatically to fit that).
612                 //
613                 private Image GetSizedResourceImage(string name, int width)
614                 {
615                         Image image = ResPool.GetUIImage (name, width);
616                         if (image != null)
617                                 return image;
618                         
619                         string  fullname;
620
621                         if (width > 0) {
622                                 // Try name_width
623                                 fullname = String.Format("{1}_{0}", name, width);
624                                 image = ResourceImageLoader.Get (fullname);
625                                 if (image != null){
626                                         ResPool.AddUIImage (image, name, width);
627                                         return image;
628                                 }
629                         }
630
631                         // Just try name
632                         image = ResourceImageLoader.Get (name);
633                         if (image == null)
634                                 return null;
635                         
636                         ResPool.AddUIImage (image, name, 0);
637                         if (image.Width != width && width != 0){
638                                 Console.Error.WriteLine ("warning: requesting icon that not been tuned {0}_{1} {2}", width, name, image.Width);
639                                 int height = (image.Height * width)/image.Width;
640                                 Bitmap b = new Bitmap (width, height);
641                                 using (Graphics g = Graphics.FromImage (b))
642                                         g.DrawImage (image, 0, 0, width, height);
643                                 ResPool.AddUIImage (b, name, width);
644
645                                 return b;
646                         }
647                         return image;
648                 }
649                 
650                 public virtual Image Images(UIIcon index) {
651                         return Images(index, 0);
652                 }
653                         
654                 public virtual Image Images(UIIcon index, int size) {
655                         switch (index) {
656                                 case UIIcon.PlacesRecentDocuments:
657                                         return GetSizedResourceImage ("document-open.png", size);
658                                 case UIIcon.PlacesDesktop:
659                                         return GetSizedResourceImage ("user-desktop.png", size);
660                                 case UIIcon.PlacesPersonal:
661                                         return GetSizedResourceImage ("user-home.png", size);
662                                 case UIIcon.PlacesMyComputer:
663                                         return GetSizedResourceImage ("computer.png", size);
664                                 case UIIcon.PlacesMyNetwork:
665                                         return GetSizedResourceImage ("folder-remote.png", size);
666
667                                 // Icons for message boxes
668                                 case UIIcon.MessageBoxError:
669                                         return GetSizedResourceImage ("dialog-error.png", size);
670                                 case UIIcon.MessageBoxInfo:
671                                         return GetSizedResourceImage ("dialog-information.png", size);
672                                 case UIIcon.MessageBoxQuestion:
673                                         return GetSizedResourceImage ("dialog-question.png", size);
674                                 case UIIcon.MessageBoxWarning:
675                                         return GetSizedResourceImage ("dialog-warning.png", size);
676                                 
677                                 // misc Icons
678                                 case UIIcon.NormalFolder:
679                                         return GetSizedResourceImage ("folder.png", size);
680
681                                 default: {
682                                         throw new ArgumentException("Invalid Icon type requested", "index");
683                                 }
684                         }
685                 }
686
687                 public virtual Image Images(string mimetype, string extension, int size) {
688                         return null;
689                 }
690
691                 #region Principal Theme Methods
692                 // To let the theme now that a change of defaults (colors, etc) was detected and force a re-read (and possible recreation of cached resources)
693                 public abstract void ResetDefaults();
694
695                 // If the theme writes directly to a window instead of a device context
696                 public abstract bool DoubleBufferingSupported {get;}
697                 #endregion      // Principal Theme Methods
698
699                 #region OwnerDraw Support
700                 public abstract void DrawOwnerDrawBackground (DrawItemEventArgs e);
701                 public abstract void DrawOwnerDrawFocusRectangle (DrawItemEventArgs e);
702                 #endregion      // OwnerDraw Support
703
704                 #region Button
705                 public abstract Size CalculateButtonAutoSize (Button button);
706                 public abstract void CalculateButtonTextAndImageLayout (ButtonBase b, out Rectangle textRectangle, out Rectangle imageRectangle);
707                 public abstract void DrawButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
708                 public abstract void DrawFlatButton (Graphics g, ButtonBase b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
709                 public abstract void DrawPopupButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
710                 #endregion      // Button
711
712                 #region ButtonBase
713                 // Drawing
714                 public abstract void DrawButtonBase(Graphics dc, Rectangle clip_area, ButtonBase button);
715
716                 // Sizing
717                 public abstract Size ButtonBaseDefaultSize{get;}
718                 #endregion      // ButtonBase
719
720                 #region CheckBox
721                 public abstract Size CalculateCheckBoxAutoSize (CheckBox checkBox);
722                 public abstract void CalculateCheckBoxTextAndImageLayout (ButtonBase b, Point offset, out Rectangle glyphArea, out Rectangle textRectangle, out Rectangle imageRectangle);
723                 public abstract void DrawCheckBox (Graphics g, CheckBox cb, Rectangle glyphArea, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
724                 public abstract void DrawCheckBox (Graphics dc, Rectangle clip_area, CheckBox checkbox);
725
726                 #endregion      // CheckBox
727                 
728                 #region CheckedListBox
729                 // Drawing
730                 public abstract void DrawCheckedListBoxItem (CheckedListBox ctrl, DrawItemEventArgs e);
731                 #endregion // CheckedListBox
732                 
733                 #region ComboBox
734                 // Drawing
735                 public abstract void DrawComboBoxItem (ComboBox ctrl, DrawItemEventArgs e);
736                 public abstract void DrawFlatStyleComboButton (Graphics graphics, Rectangle rectangle, ButtonState state);
737                 public abstract void ComboBoxDrawNormalDropDownButton (ComboBox comboBox, Graphics g, Rectangle clippingArea, Rectangle area, ButtonState state);
738                 public abstract bool ComboBoxNormalDropDownButtonHasTransparentBackground (ComboBox comboBox, ButtonState state);
739                 public abstract bool ComboBoxDropDownButtonHasHotElementStyle (ComboBox comboBox);
740                 public abstract void ComboBoxDrawBackground (ComboBox comboBox, Graphics g, Rectangle clippingArea, FlatStyle style);
741                 public abstract bool CombBoxBackgroundHasHotElementStyle (ComboBox comboBox);
742                 #endregion      // ComboBox
743
744                 #region Control
745                 public abstract Font GetLinkFont (Control control);
746                 #endregion      // Control
747                 
748                 #region Datagrid
749                 public abstract int DataGridPreferredColumnWidth { get; }
750                 public abstract int DataGridMinimumColumnCheckBoxHeight { get; }
751                 public abstract int DataGridMinimumColumnCheckBoxWidth { get; }
752                 
753                 // Default colours
754                 public abstract Color DataGridAlternatingBackColor { get; }
755                 public abstract Color DataGridBackColor { get; }
756                 public abstract Color DataGridBackgroundColor { get; }
757                 public abstract Color DataGridCaptionBackColor { get; }
758                 public abstract Color DataGridCaptionForeColor { get; }
759                 public abstract Color DataGridGridLineColor { get; }
760                 public abstract Color DataGridHeaderBackColor { get; }
761                 public abstract Color DataGridHeaderForeColor { get; }
762                 public abstract Color DataGridLinkColor { get; }
763                 public abstract Color DataGridLinkHoverColor { get; }
764                 public abstract Color DataGridParentRowsBackColor { get; }
765                 public abstract Color DataGridParentRowsForeColor { get; }
766                 public abstract Color DataGridSelectionBackColor { get; }
767                 public abstract Color DataGridSelectionForeColor { get; }
768                 // Paint                
769                 public abstract void DataGridPaint (PaintEventArgs pe, DataGrid grid);
770                 public abstract void DataGridPaintCaption (Graphics g, Rectangle clip, DataGrid grid);
771                 public abstract void DataGridPaintColumnHeaders (Graphics g, Rectangle clip, DataGrid grid);
772                 public abstract void DataGridPaintColumnHeader (Graphics g, Rectangle bounds, DataGrid grid, int col);
773                 public abstract void DataGridPaintRowContents (Graphics g, int row, Rectangle row_rect, bool is_newrow, Rectangle clip, DataGrid grid);
774                 public abstract void DataGridPaintRowHeader (Graphics g, Rectangle bounds, int row, DataGrid grid);
775                 public abstract void DataGridPaintRowHeaderArrow (Graphics g, Rectangle bounds, DataGrid grid);
776                 public abstract void DataGridPaintRowHeaderStar (Graphics g, Rectangle bounds, DataGrid grid);
777                 public abstract void DataGridPaintParentRows (Graphics g, Rectangle bounds, DataGrid grid);
778                 public abstract void DataGridPaintParentRow (Graphics g, Rectangle bounds, DataGridDataSource row, DataGrid grid);
779                 public abstract void DataGridPaintRows (Graphics g, Rectangle cells, Rectangle clip, DataGrid grid);
780                 public abstract void DataGridPaintRow (Graphics g, int row, Rectangle row_rect, bool is_newrow, Rectangle clip, DataGrid grid);
781                 public abstract void DataGridPaintRelationRow (Graphics g, int row, Rectangle row_rect, bool is_newrow, Rectangle clip, DataGrid grid);
782                 
783                 #endregion // Datagrid
784
785                 #region DataGridView
786                 #region DataGridViewHeaderCell
787                 #region DataGridViewRowHeaderCell
788                 public abstract bool DataGridViewRowHeaderCellDrawBackground (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds);
789                 public abstract bool DataGridViewRowHeaderCellDrawSelectionBackground (DataGridViewRowHeaderCell cell);
790                 public abstract bool DataGridViewRowHeaderCellDrawBorder (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds);
791                 #endregion
792                 #region DataGridViewColumnHeaderCell
793                 public abstract bool DataGridViewColumnHeaderCellDrawBackground (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds);
794                 public abstract bool DataGridViewColumnHeaderCellDrawBorder (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds);
795                 #endregion
796                 public abstract bool DataGridViewHeaderCellHasPressedStyle (DataGridView dataGridView);
797                 public abstract bool DataGridViewHeaderCellHasHotStyle (DataGridView dataGridView);
798                 #endregion
799                 #endregion
800
801                 #region DateTimePicker
802                 public abstract void DrawDateTimePicker(Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp);
803                 public abstract bool DateTimePickerBorderHasHotElementStyle { get; }
804                 public abstract Rectangle DateTimePickerGetDropDownButtonArea (DateTimePicker dateTimePicker);
805                 public abstract Rectangle DateTimePickerGetDateArea (DateTimePicker dateTimePicker);
806                 public abstract bool DateTimePickerDropDownButtonHasHotElementStyle { get; }
807                 #endregion      // DateTimePicker
808
809                 #region GroupBox
810                 // Drawing
811                 public abstract void DrawGroupBox (Graphics dc,  Rectangle clip_area, GroupBox box);
812
813                 // Sizing
814                 public abstract Size GroupBoxDefaultSize{get;}
815                 #endregion      // GroupBox
816
817                 #region HScrollBar
818                 public abstract Size HScrollBarDefaultSize{get;}        // Default size of the scrollbar
819                 #endregion      // HScrollBar
820
821                 #region ListBox
822                 // Drawing
823                 public abstract void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e);
824                 #endregion      // ListBox
825                 
826                 #region ListView
827                 // Drawing
828                 public abstract void DrawListViewItems (Graphics dc, Rectangle clip_rectangle, ListView control);
829                 public abstract void DrawListViewHeader (Graphics dc, Rectangle clip_rectangle, ListView control);
830                 public abstract void DrawListViewHeaderDragDetails (Graphics dc, ListView control, ColumnHeader drag_column, int target_x);
831                 public abstract bool ListViewHasHotHeaderStyle { get; }
832
833                 // Sizing
834                 public abstract int ListViewGetHeaderHeight (ListView listView, Font font);
835                 public abstract Size ListViewCheckBoxSize { get; }
836                 public abstract int ListViewColumnHeaderHeight { get; }
837                 public abstract int ListViewDefaultColumnWidth { get; }
838                 public abstract int ListViewVerticalSpacing { get; }
839                 public abstract int ListViewEmptyColumnWidth { get; }
840                 public abstract int ListViewHorizontalSpacing { get; }
841                 public abstract Size ListViewDefaultSize { get; }
842                 public abstract int ListViewGroupHeight { get; }
843                 public abstract int ListViewItemPaddingWidth { get; }
844                 public abstract int ListViewTileWidthFactor { get; }
845                 public abstract int ListViewTileHeightFactor { get; }
846                 #endregion      // ListView
847                 
848                 #region Menus
849                 public abstract void CalcItemSize (Graphics dc, MenuItem item, int y, int x, bool menuBar);
850                 public abstract void CalcPopupMenuSize (Graphics dc, Menu menu);
851                 public abstract int CalcMenuBarSize (Graphics dc, Menu menu, int width);
852                 public abstract void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect);
853                 public abstract void DrawMenuItem (MenuItem item, DrawItemEventArgs e);
854                 public abstract void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect);
855                 #endregion      // Menus
856
857                 #region MonthCalendar
858                 public abstract void DrawMonthCalendar(Graphics dc, Rectangle clip_rectangle, MonthCalendar month_calendar);
859                 #endregion      // MonthCalendar
860
861                 #region Panel
862                 // Sizing
863                 public abstract Size PanelDefaultSize{get;}
864                 #endregion      // Panel
865
866                 #region PictureBox
867                 // Drawing
868                 public abstract void DrawPictureBox (Graphics dc, Rectangle clip, PictureBox pb);
869
870                 // Sizing
871                 public abstract Size PictureBoxDefaultSize{get;}
872                 #endregion      // PictureBox
873
874                 #region PrintPreviewControl
875                 public abstract int PrintPreviewControlPadding{get;}
876                 public abstract Size PrintPreviewControlGetPageSize (PrintPreviewControl preview);
877                 public abstract void PrintPreviewControlPaint (PaintEventArgs pe, PrintPreviewControl preview, Size page_image_size);
878                 #endregion      // PrintPreviewControl
879
880                 #region ProgressBar
881                 // Drawing
882                 public abstract void DrawProgressBar (Graphics dc, Rectangle clip_rectangle, ProgressBar progress_bar);
883
884                 // Sizing
885                 public abstract Size ProgressBarDefaultSize{get;}
886                 #endregion      // ProgressBar
887
888                 #region RadioButton
889                 // Drawing
890                 public abstract Size CalculateRadioButtonAutoSize (RadioButton rb);
891                 public abstract void CalculateRadioButtonTextAndImageLayout (ButtonBase b, Point offset, out Rectangle glyphArea, out Rectangle textRectangle, out Rectangle imageRectangle);
892                 public abstract void DrawRadioButton (Graphics g, RadioButton rb, Rectangle glyphArea, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
893                 public abstract void DrawRadioButton (Graphics dc, Rectangle clip_rectangle, RadioButton radio_button);
894
895                 // Sizing
896                 public abstract Size RadioButtonDefaultSize{get;}
897                 #endregion      // RadioButton
898
899                 #region ScrollBar
900                 // Drawing
901                 //public abstract void DrawScrollBar (Graphics dc, Rectangle area, ScrollBar bar, ref Rectangle thumb_pos, ref Rectangle first_arrow_area, ref Rectangle second_arrow_area, ButtonState first_arrow, ButtonState second_arrow, ref int scrollbutton_width, ref int scrollbutton_height, bool vert);
902                 public abstract void DrawScrollBar (Graphics dc, Rectangle clip_rectangle, ScrollBar bar);
903
904                 // Sizing
905                 public abstract int ScrollBarButtonSize {get;}          // Size of the scroll button
906
907                 public abstract bool ScrollBarHasHotElementStyles { get; }
908
909                 public abstract bool ScrollBarHasPressedThumbStyle { get; }
910
911                 public abstract bool ScrollBarHasHoverArrowButtonStyle { get; }
912                 #endregion      // ScrollBar
913
914                 #region StatusBar
915                 // Drawing
916                 public abstract void DrawStatusBar (Graphics dc, Rectangle clip_rectangle, StatusBar sb);
917
918                 // Sizing
919                 public abstract int StatusBarSizeGripWidth {get;}               // Size of Resize area
920                 public abstract int StatusBarHorzGapWidth {get;}        // Gap between panels
921                 public abstract Size StatusBarDefaultSize{get;}
922                 #endregion      // StatusBar
923
924                 #region TabControl
925                 public abstract Size TabControlDefaultItemSize {get; }
926                 public abstract Point TabControlDefaultPadding {get; }
927                 public abstract int TabControlMinimumTabWidth {get; }
928                 public abstract Rectangle TabControlSelectedDelta { get; }
929                 public abstract int TabControlSelectedSpacing { get; }
930                 public abstract int TabPanelOffsetX { get; }
931                 public abstract int TabPanelOffsetY { get; }
932                 public abstract int TabControlColSpacing { get; }
933                 public abstract Point TabControlImagePadding { get; }
934                 public abstract int TabControlScrollerWidth { get; }
935
936                 public abstract Rectangle TabControlGetDisplayRectangle (TabControl tab);
937                 public abstract Rectangle TabControlGetPanelRect (TabControl tab);
938                 public abstract Size TabControlGetSpacing (TabControl tab);
939                 public abstract void DrawTabControl (Graphics dc, Rectangle area, TabControl tab);
940                 #endregion
941
942                 #region TextBoxBase
943                 public abstract void TextBoxBaseFillBackground (TextBoxBase textBoxBase, Graphics g, Rectangle clippingArea);
944                 public abstract bool TextBoxBaseHandleWmNcPaint (TextBoxBase textBoxBase, ref Message m);
945                 public abstract bool TextBoxBaseShouldPaintBackground (TextBoxBase textBoxBase);
946                 #endregion
947
948                 #region ToolBar
949                 // Drawing
950                 public abstract void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control);
951
952                 // Sizing
953                 public abstract int ToolBarGripWidth {get;}              // Grip width for the ToolBar
954                 public abstract int ToolBarImageGripWidth {get;}         // Grip width for the Image on the ToolBarButton
955                 public abstract int ToolBarSeparatorWidth {get;}         // width of the separator
956                 public abstract int ToolBarDropDownWidth { get; }        // width of the dropdown arrow rect
957                 public abstract int ToolBarDropDownArrowWidth { get; }   // width for the dropdown arrow on the ToolBarButton
958                 public abstract int ToolBarDropDownArrowHeight { get; }  // height for the dropdown arrow on the ToolBarButton
959                 public abstract Size ToolBarDefaultSize{get;}
960
961                 public abstract bool ToolBarHasHotElementStyles (ToolBar toolBar);
962                 public abstract bool ToolBarHasHotCheckedElementStyles { get; }
963                 #endregion      // ToolBar
964
965                 #region ToolTip
966                 public abstract void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control);
967                 public abstract Size ToolTipSize(ToolTip.ToolTipWindow tt, string text);
968                 public abstract bool ToolTipTransparentBackground { get; }
969                 #endregion      // ToolTip
970                 
971                 #region BalloonWindow
972                 public abstract void ShowBalloonWindow (IntPtr handle, int timeout, string title, string text, ToolTipIcon icon);
973                 public abstract void HideBalloonWindow (IntPtr handle);
974                 public abstract void DrawBalloonWindow (Graphics dc, Rectangle clip, NotifyIcon.BalloonWindow control);
975                 public abstract Rectangle BalloonWindowRect (NotifyIcon.BalloonWindow control);
976                 #endregion      // BalloonWindow
977
978                 #region TrackBar
979                 // Drawing
980                 public abstract void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb);
981
982                 // Sizing
983                 public abstract Size TrackBarDefaultSize{get; }         // Default size for the TrackBar control
984                 
985                 public abstract int TrackBarValueFromMousePosition (int x, int y, TrackBar tb);
986
987                 public abstract bool TrackBarHasHotThumbStyle { get; }
988                 #endregion      // TrackBar
989
990                 #region UpDownBase
991                 public abstract void UpDownBaseDrawButton (Graphics g, Rectangle bounds, bool top, VisualStyles.PushButtonState state);
992                 public abstract bool UpDownBaseHasHotButtonStyle { get; }
993                 #endregion
994
995                 #region VScrollBar
996                 public abstract Size VScrollBarDefaultSize{get;}        // Default size of the scrollbar
997                 #endregion      // VScrollBar
998
999                 #region TreeView
1000                 public abstract Size TreeViewDefaultSize { get; }
1001                 public abstract void TreeViewDrawNodePlusMinus (TreeView treeView, TreeNode node, Graphics dc, int x, int middle);
1002                 #endregion
1003
1004                 #region Managed window
1005                 public abstract void DrawManagedWindowDecorations (Graphics dc, Rectangle clip, InternalWindowManager wm);
1006                 public abstract int ManagedWindowTitleBarHeight (InternalWindowManager wm);
1007                 public abstract int ManagedWindowBorderWidth (InternalWindowManager wm);
1008                 public abstract int ManagedWindowIconWidth (InternalWindowManager wm);
1009                 public abstract Size ManagedWindowButtonSize (InternalWindowManager wm);
1010                 public abstract void ManagedWindowSetButtonLocations (InternalWindowManager wm);
1011                 public abstract Rectangle ManagedWindowGetTitleBarIconArea (InternalWindowManager wm);
1012                 public abstract Size ManagedWindowGetMenuButtonSize (InternalWindowManager wm);
1013                 public abstract bool ManagedWindowTitleButtonHasHotElementStyle (TitleButton button, Form form);
1014                 public abstract void ManagedWindowDrawMenuButton (Graphics dc, TitleButton button, Rectangle clip, InternalWindowManager wm);
1015                 public abstract void ManagedWindowOnSizeInitializedOrChanged (Form form);
1016                 public const int ManagedWindowSpacingAfterLastTitleButton = 2;
1017                 #endregion
1018
1019                 #region ControlPaint Methods
1020                 public abstract void CPDrawBorder (Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
1021                         ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
1022                         Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
1023                         int bottomWidth, ButtonBorderStyle bottomStyle);
1024
1025                 public abstract void CPDrawBorder (Graphics graphics, RectangleF bounds, Color leftColor, int leftWidth,
1026                         ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
1027                         Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
1028                         int bottomWidth, ButtonBorderStyle bottomStyle);
1029
1030                 public abstract void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides);
1031                 public abstract void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color);
1032                 public abstract void CPDrawButton (Graphics graphics, Rectangle rectangle, ButtonState state);
1033                 public abstract void CPDrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state);
1034                 public abstract void CPDrawCheckBox (Graphics graphics, Rectangle rectangle, ButtonState state);
1035                 public abstract void CPDrawComboButton (Graphics graphics, Rectangle rectangle, ButtonState state);
1036                 public abstract void CPDrawContainerGrabHandle (Graphics graphics, Rectangle bounds);
1037                 public abstract void CPDrawFocusRectangle (Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor);
1038                 public abstract void CPDrawGrabHandle (Graphics graphics, Rectangle rectangle, bool primary, bool enabled);
1039                 public abstract void CPDrawGrid (Graphics graphics, Rectangle area, Size pixelsBetweenDots, Color backColor);
1040                 public abstract void CPDrawImageDisabled (Graphics graphics, Image image, int x, int y, Color background);
1041                 public abstract void CPDrawLockedFrame (Graphics graphics, Rectangle rectangle, bool primary);
1042                 public abstract void CPDrawMenuGlyph (Graphics graphics, Rectangle rectangle, MenuGlyph glyph, Color color, Color backColor);
1043                 public abstract void CPDrawMixedCheckBox (Graphics graphics, Rectangle rectangle, ButtonState state);
1044                 public abstract void CPDrawRadioButton (Graphics graphics, Rectangle rectangle, ButtonState state);
1045                 public abstract void CPDrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style);
1046                 public abstract void CPDrawReversibleLine (Point start, Point end, Color backColor);
1047                 public abstract void CPDrawScrollButton (Graphics graphics, Rectangle rectangle, ScrollButton button, ButtonState state);
1048                 public abstract void CPDrawSelectionFrame (Graphics graphics, bool active, Rectangle outsideRect, Rectangle insideRect,
1049                         Color backColor);
1050                 public abstract void CPDrawSizeGrip (Graphics graphics, Color backColor, Rectangle bounds);
1051                 public abstract void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
1052                         StringFormat format);
1053                 public abstract void CPDrawStringDisabled (IDeviceContext dc, string s, Font font, Color color, Rectangle layoutRectangle, TextFormatFlags format);
1054                 public abstract void CPDrawVisualStyleBorder (Graphics graphics, Rectangle bounds);
1055                 public abstract void CPDrawBorderStyle (Graphics dc, Rectangle area, BorderStyle border_style);
1056                 #endregion      // ControlPaint Methods
1057         }
1058 }