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