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