2007-06-06 Jonathan Pobst <monkey@jpobst.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 Size BorderSizableSize {
400                         get {
401                                 return new Size (3, 3);
402                         }
403                 }
404
405                 public virtual Size Border3DSize {
406                         get {
407                                 return XplatUI.Border3DSize;
408                         }
409                 }
410
411                 public virtual Size BorderStaticSize {
412                         get {
413                                 return new Size(1, 1);
414                         }
415                 }
416
417                 public virtual Size BorderSize {
418                         get {
419                                 return XplatUI.BorderSize;
420                         }
421                 }
422
423                 public virtual Size CaptionButtonSize {
424                         get {
425                                 return XplatUI.CaptionButtonSize;
426                         }
427                 }
428
429                 public virtual int CaptionHeight {
430                         get {
431                                 return XplatUI.CaptionHeight;
432                         }
433                 }
434
435                 public virtual Size DoubleClickSize {
436                         get {
437                                 return new Size(4, 4);
438                         }
439                 }
440
441                 public virtual int DoubleClickTime {
442                         get {
443                                 return 500;
444                         }
445                 }
446
447                 public virtual Size FixedFrameBorderSize {
448                         get {
449                                 return XplatUI.FixedFrameBorderSize;
450                         }
451                 }
452
453                 public virtual Size FrameBorderSize {
454                         get {
455                                 return XplatUI.FrameBorderSize;
456                         }
457                 }
458
459                 public virtual int HorizontalScrollBarArrowWidth {
460                         get {
461                                 return 16;
462                         }
463                 }
464
465                 public virtual int HorizontalScrollBarHeight {
466                         get {
467                                 return 16;
468                         }
469                 }
470
471                 public virtual int HorizontalScrollBarThumbWidth {
472                         get {
473                                 return 16;
474                         }
475                 }
476
477                 public virtual Size IconSpacingSize {
478                         get {
479                                 return new Size(75, 75);
480                         }
481                 }
482
483                 public virtual bool MenuAccessKeysUnderlined {
484                         get {
485                                 return XplatUI.MenuAccessKeysUnderlined;
486                         }
487                 }
488                 
489                 public virtual Size MenuButtonSize {
490                         get {
491                                 return new Size(18, 18);
492                         }
493                 }
494
495                 public virtual Size MenuCheckSize {
496                         get {
497                                 return new Size(13, 13);
498                         }
499                 }
500
501                 public virtual Font MenuFont {
502                         get {
503                                 return default_font;
504                         }
505                 }
506
507                 public virtual int MenuHeight {
508                         get {
509                                 return XplatUI.MenuHeight;
510                         }
511                 }
512
513                 public virtual int MouseWheelScrollLines {
514                         get {
515                                 return 3;
516                         }
517                 }
518
519                 public virtual bool RightAlignedMenus {
520                         get {
521                                 return false;
522                         }
523                 }
524
525                 public virtual Size ToolWindowCaptionButtonSize {
526                         get {
527                                 return new Size(15, 15);
528                         }
529                 }
530
531                 public virtual int ToolWindowCaptionHeight {
532                         get {
533                                 return 16;
534                         }
535                 }
536
537                 public virtual int VerticalScrollBarArrowHeight {
538                         get {
539                                 return 16;
540                         }
541                 }
542
543                 public virtual int VerticalScrollBarThumbHeight {
544                         get {
545                                 return 16;
546                         }
547                 }
548
549                 public virtual int VerticalScrollBarWidth {
550                         get {
551                                 return 16;
552                         }
553                 }
554
555                 public virtual Font WindowBorderFont {
556                         get {
557                                 return window_border_font;
558                         }
559                 }
560
561                 public int Clamp (int value, int lower, int upper)
562                 {
563                         if (value < lower) return lower;
564                         else if (value > upper) return upper;
565                         else return value;
566                 }
567
568                 [MonoTODO("Figure out where to point for My Network Places")]
569                 public virtual string Places(UIIcon index) {
570                         switch (index) {
571                                 case UIIcon.PlacesRecentDocuments: {
572                                         // Default = "Recent Documents"
573                                         return Environment.GetFolderPath(Environment.SpecialFolder.Recent);
574                                 }
575
576                                 case UIIcon.PlacesDesktop: {
577                                         // Default = "Desktop"
578                                         return Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
579                                 }
580
581                                 case UIIcon.PlacesPersonal: {
582                                         // Default = "My Documents"
583                                         return Environment.GetFolderPath(Environment.SpecialFolder.Personal);
584                                 }
585
586                                 case UIIcon.PlacesMyComputer: {
587                                         // Default = "My Computer"
588                                         return Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
589                                 }
590
591                                 case UIIcon.PlacesMyNetwork: {
592                                         // Default = "My Network Places"
593                                         return "/tmp";
594                                 }
595
596                                 default: {
597                                         throw new ArgumentOutOfRangeException("index", index, "Unsupported place");
598                                 }
599                         }
600                 }
601
602                 //
603                 // This routine fetches images embedded as assembly resources (not
604                 // resgen resources).  It optionally scales the image to fit the
605                 // specified size x dimension (it adjusts y automatically to fit that).
606                 //
607                 private Image GetSizedResourceImage(string name, int width)
608                 {
609                         Image image = ResPool.GetUIImage (name, width);
610                         if (image != null)
611                                 return image;
612                         
613                         string  fullname;
614
615                         if (width > 0) {
616                                 // Try name_width
617                                 fullname = String.Format("{1}_{0}", name, width);
618                                 image = ResourceImageLoader.Get (fullname);
619                                 if (image != null){
620                                         ResPool.AddUIImage (image, name, width);
621                                         return image;
622                                 }
623                         }
624
625                         // Just try name
626                         image = ResourceImageLoader.Get (name);
627                         if (image == null)
628                                 return null;
629                         
630                         ResPool.AddUIImage (image, name, 0);
631                         if (image.Width != width && width != 0){
632                                 Console.Error.WriteLine ("warning: requesting icon that not been tuned {0}_{1} {2}", width, name, image.Width);
633                                 int height = (image.Height * width)/image.Width;
634                                 Bitmap b = new Bitmap (width, height);
635                                 Graphics g = Graphics.FromImage (b);
636                                 g.DrawImage (image, 0, 0, width, height);
637                                 ResPool.AddUIImage (b, name, width);
638
639                                 return b;
640                         }
641                         return image;
642                 }
643                 
644                 public virtual Image Images(UIIcon index) {
645                         return Images(index, 0);
646                 }
647                         
648                 public virtual Image Images(UIIcon index, int size) {
649                         switch (index) {
650                                 case UIIcon.PlacesRecentDocuments:
651                                         return GetSizedResourceImage ("document-open.png", size);
652                                 case UIIcon.PlacesDesktop:
653                                         return GetSizedResourceImage ("user-desktop.png", size);
654                                 case UIIcon.PlacesPersonal:
655                                         return GetSizedResourceImage ("user-home.png", size);
656                                 case UIIcon.PlacesMyComputer:
657                                         return GetSizedResourceImage ("computer.png", size);
658                                 case UIIcon.PlacesMyNetwork:
659                                         return GetSizedResourceImage ("folder-remote.png", size);
660
661                                 // Icons for message boxes
662                                 case UIIcon.MessageBoxError:
663                                         return GetSizedResourceImage ("dialog-error.png", size);
664                                 case UIIcon.MessageBoxInfo:
665                                         return GetSizedResourceImage ("dialog-information.png", size);
666                                 case UIIcon.MessageBoxQuestion:
667                                         return GetSizedResourceImage ("dialog-question.png", size);
668                                 case UIIcon.MessageBoxWarning:
669                                         return GetSizedResourceImage ("dialog-warning.png", size);
670                                 
671                                 // misc Icons
672                                 case UIIcon.NormalFolder:
673                                         return GetSizedResourceImage ("folder.png", size);
674
675                                 default: {
676                                         throw new ArgumentException("Invalid Icon type requested", "index");
677                                 }
678                         }
679                 }
680
681                 public virtual Image Images(string mimetype, string extension, int size) {
682                         return null;
683                 }
684
685                 #region Principal Theme Methods
686                 // 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)
687                 public abstract void ResetDefaults();
688
689                 // If the theme writes directly to a window instead of a device context
690                 public abstract bool DoubleBufferingSupported {get;}
691                 #endregion      // Principal Theme Methods
692
693                 #region OwnerDraw Support
694                 public abstract void DrawOwnerDrawBackground (DrawItemEventArgs e);
695                 public abstract void DrawOwnerDrawFocusRectangle (DrawItemEventArgs e);
696                 #endregion      // OwnerDraw Support
697
698                 #region Button
699 #if NET_2_0
700                 public abstract Size CalculateButtonAutoSize (Button button);
701 #endif
702                 public abstract void CalculateButtonTextAndImageLayout (ButtonBase b, out Rectangle textRectangle, out Rectangle imageRectangle);
703                 public abstract void DrawButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
704                 public abstract void DrawFlatButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
705                 public abstract void DrawPopupButton (Graphics g, Button b, Rectangle textBounds, Rectangle imageBounds, Rectangle clipRectangle);
706                 #endregion      // Button
707
708                 #region ButtonBase
709                 // Drawing
710                 public abstract void DrawButtonBase(Graphics dc, Rectangle clip_area, ButtonBase button);
711
712                 // Sizing
713                 public abstract Size ButtonBaseDefaultSize{get;}
714                 #endregion      // ButtonBase
715
716                 #region CheckBox
717                 public abstract void DrawCheckBox(Graphics dc, Rectangle clip_area, CheckBox checkbox);
718                 #endregion      // CheckBox
719                 
720                 #region CheckedListBox
721                 // Drawing
722                 public abstract void DrawCheckedListBoxItem (CheckedListBox ctrl, DrawItemEventArgs e);
723                 #endregion // CheckedListBox
724                 
725                 #region ComboBox
726                 // Drawing
727                 public abstract void DrawComboBoxItem (ComboBox ctrl, DrawItemEventArgs e);
728                 public abstract void DrawFlatStyleComboButton (Graphics graphics, Rectangle rectangle, ButtonState state);
729                 #endregion      // ComboBox
730
731                 #region Control
732                 public abstract Font GetLinkFont (Control control);
733                 #endregion      // Control
734                 
735                 #region Datagrid
736                 public abstract int DataGridPreferredColumnWidth { get; }
737                 public abstract int DataGridMinimumColumnCheckBoxHeight { get; }
738                 public abstract int DataGridMinimumColumnCheckBoxWidth { get; }
739                 
740                 // Default colours
741                 public abstract Color DataGridAlternatingBackColor { get; }
742                 public abstract Color DataGridBackColor { get; }
743                 public abstract Color DataGridBackgroundColor { get; }
744                 public abstract Color DataGridCaptionBackColor { get; }
745                 public abstract Color DataGridCaptionForeColor { get; }
746                 public abstract Color DataGridGridLineColor { get; }
747                 public abstract Color DataGridHeaderBackColor { get; }
748                 public abstract Color DataGridHeaderForeColor { get; }
749                 public abstract Color DataGridLinkColor { get; }
750                 public abstract Color DataGridLinkHoverColor { get; }
751                 public abstract Color DataGridParentRowsBackColor { get; }
752                 public abstract Color DataGridParentRowsForeColor { get; }
753                 public abstract Color DataGridSelectionBackColor { get; }
754                 public abstract Color DataGridSelectionForeColor { get; }
755                 // Paint                
756                 public abstract void DataGridPaint (PaintEventArgs pe, DataGrid grid);
757                 public abstract void DataGridPaintCaption (Graphics g, Rectangle clip, DataGrid grid);
758                 public abstract void DataGridPaintColumnHeaders (Graphics g, Rectangle clip, DataGrid grid);
759                 public abstract void DataGridPaintRowContents (Graphics g, int row, Rectangle row_rect, bool is_newrow, Rectangle clip, DataGrid grid);
760                 public abstract void DataGridPaintRowHeader (Graphics g, Rectangle bounds, int row, DataGrid grid);
761                 public abstract void DataGridPaintRowHeaderArrow (Graphics g, Rectangle bounds, DataGrid grid);
762                 public abstract void DataGridPaintParentRows (Graphics g, Rectangle bounds, DataGrid grid);
763                 public abstract void DataGridPaintParentRow (Graphics g, Rectangle bounds, DataGridDataSource row, DataGrid grid);
764                 public abstract void DataGridPaintRows (Graphics g, Rectangle cells, Rectangle clip, DataGrid grid);
765                 public abstract void DataGridPaintRow (Graphics g, int row, Rectangle row_rect, bool is_newrow, Rectangle clip, DataGrid grid);
766                 public abstract void DataGridPaintRelationRow (Graphics g, int row, Rectangle row_rect, bool is_newrow, Rectangle clip, DataGrid grid);
767                 
768                 #endregion // Datagrid
769
770                 #region DateTimePicker
771
772                 public abstract void DrawDateTimePicker(Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp);
773
774                 #endregion      // DateTimePicker
775
776                 #region GroupBox
777                 // Drawing
778                 public abstract void DrawGroupBox (Graphics dc,  Rectangle clip_area, GroupBox box);
779
780                 // Sizing
781                 public abstract Size GroupBoxDefaultSize{get;}
782                 #endregion      // GroupBox
783
784                 #region HScrollBar
785                 public abstract Size HScrollBarDefaultSize{get;}        // Default size of the scrollbar
786                 #endregion      // HScrollBar
787
788                 #region Label
789                 // Drawing
790                 public abstract void DrawLabel (Graphics dc, Rectangle clip_rectangle, Label label);
791
792                 // Sizing
793                 public abstract Size LabelDefaultSize{get;}
794                 #endregion      // Label
795
796                 #region LinkLabel
797                 public abstract void DrawLinkLabel (Graphics dc, Rectangle clip_rectangle, LinkLabel label);
798                 #endregion      // LinkLabel
799                 
800                 #region ListBox
801                 // Drawing
802                 public abstract void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e);
803                 #endregion      // ListBox
804                 
805                 #region ListView
806                 // Drawing
807                 public abstract void DrawListViewItems (Graphics dc, Rectangle clip_rectangle, ListView control);
808                 public abstract void DrawListViewHeader (Graphics dc, Rectangle clip_rectangle, ListView control);
809                 public abstract void DrawListViewHeaderDragDetails (Graphics dc, ListView control, ColumnHeader drag_column, int target_x);
810
811                 // Sizing
812                 public abstract Size ListViewCheckBoxSize { get; }
813                 public abstract int ListViewColumnHeaderHeight { get; }
814                 public abstract int ListViewDefaultColumnWidth { get; }
815                 public abstract int ListViewVerticalSpacing { get; }
816                 public abstract int ListViewEmptyColumnWidth { get; }
817                 public abstract int ListViewHorizontalSpacing { get; }
818                 public abstract Size ListViewDefaultSize { get; }
819                 public abstract int ListViewGroupHeight { get; }
820                 public abstract int ListViewTileWidthFactor { get; }
821                 public abstract int ListViewTileHeightFactor { get; }
822                 #endregion      // ListView
823                 
824                 #region Menus
825                 public abstract void CalcItemSize (Graphics dc, MenuItem item, int y, int x, bool menuBar);
826                 public abstract void CalcPopupMenuSize (Graphics dc, Menu menu);
827                 public abstract int CalcMenuBarSize (Graphics dc, Menu menu, int width);
828                 public abstract void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect);
829                 public abstract void DrawMenuItem (MenuItem item, DrawItemEventArgs e);
830                 public abstract void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect);
831                 #endregion      // Menus
832
833                 #region MonthCalendar
834                 public abstract void DrawMonthCalendar(Graphics dc, Rectangle clip_rectangle, MonthCalendar month_calendar);
835                 #endregion      // MonthCalendar
836
837                 #region Panel
838                 // Sizing
839                 public abstract Size PanelDefaultSize{get;}
840                 #endregion      // Panel
841
842                 #region PictureBox
843                 // Drawing
844                 public abstract void DrawPictureBox (Graphics dc, Rectangle clip, PictureBox pb);
845
846                 // Sizing
847                 public abstract Size PictureBoxDefaultSize{get;}
848                 #endregion      // PictureBox
849
850                 #region PrintPreviewControl
851                 public abstract int PrintPreviewControlPadding{get;}
852                 public abstract Size PrintPreviewControlGetPageSize (PrintPreviewControl preview);
853                 public abstract void PrintPreviewControlPaint (PaintEventArgs pe, PrintPreviewControl preview, Size page_image_size);
854                 #endregion      // PrintPreviewControl
855
856                 #region ProgressBar
857                 // Drawing
858                 public abstract void DrawProgressBar (Graphics dc, Rectangle clip_rectangle, ProgressBar progress_bar);
859
860                 // Sizing
861                 public abstract Size ProgressBarDefaultSize{get;}
862                 #endregion      // ProgressBar
863
864                 #region RadioButton
865                 // Drawing
866                 public abstract void DrawRadioButton (Graphics dc, Rectangle clip_rectangle, RadioButton radio_button);
867
868                 // Sizing
869                 public abstract Size RadioButtonDefaultSize{get;}
870                 #endregion      // RadioButton
871
872                 #region ScrollBar
873                 // Drawing
874                 //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);
875                 public abstract void DrawScrollBar (Graphics dc, Rectangle clip_rectangle, ScrollBar bar);
876
877                 // Sizing
878                 public abstract int ScrollBarButtonSize {get;}          // Size of the scroll button
879                 #endregion      // ScrollBar
880
881                 #region StatusBar
882                 // Drawing
883                 public abstract void DrawStatusBar (Graphics dc, Rectangle clip_rectangle, StatusBar sb);
884
885                 // Sizing
886                 public abstract int StatusBarSizeGripWidth {get;}               // Size of Resize area
887                 public abstract int StatusBarHorzGapWidth {get;}        // Gap between panels
888                 public abstract Size StatusBarDefaultSize{get;}
889                 #endregion      // StatusBar
890
891                 #region TabControl
892                 public abstract Size TabControlDefaultItemSize {get; }
893                 public abstract Point TabControlDefaultPadding {get; }
894                 public abstract int TabControlMinimumTabWidth {get; }
895                 public abstract Rectangle TabControlSelectedDelta { get; }
896                 public abstract int TabControlSelectedSpacing { get; }
897                 public abstract int TabPanelOffsetX { get; }
898                 public abstract int TabPanelOffsetY { get; }
899                 public abstract int TabControlColSpacing { get; }
900                 public abstract Point TabControlImagePadding { get; }
901                 public abstract int TabControlScrollerWidth { get; }
902
903                 public abstract Rectangle TabControlGetLeftScrollRect (TabControl tab);
904                 public abstract Rectangle TabControlGetRightScrollRect (TabControl tab);
905                 public abstract Rectangle TabControlGetDisplayRectangle (TabControl tab);
906                 public abstract Rectangle TabControlGetPanelRect (TabControl tab);
907                 public abstract Size TabControlGetSpacing (TabControl tab);
908                 public abstract void DrawTabControl (Graphics dc, Rectangle area, TabControl tab);
909                 #endregion
910
911                 #region ToolBar
912                 // Drawing
913                 public abstract void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control);
914
915                 // Sizing
916                 public abstract int ToolBarGripWidth {get;}              // Grip width for the ToolBar
917                 public abstract int ToolBarImageGripWidth {get;}         // Grip width for the Image on the ToolBarButton
918                 public abstract int ToolBarSeparatorWidth {get;}         // width of the separator
919                 public abstract int ToolBarDropDownWidth { get; }        // width of the dropdown arrow rect
920                 public abstract int ToolBarDropDownArrowWidth { get; }   // width for the dropdown arrow on the ToolBarButton
921                 public abstract int ToolBarDropDownArrowHeight { get; }  // height for the dropdown arrow on the ToolBarButton
922                 public abstract Size ToolBarDefaultSize{get;}
923                 #endregion      // ToolBar
924
925                 #region ToolTip
926                 public abstract void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control);
927                 public abstract Size ToolTipSize(ToolTip.ToolTipWindow tt, string text);
928                 #endregion      // ToolTip
929                 
930                 #region BalloonWindow
931 #if NET_2_0
932                 public abstract void ShowBalloonWindow (IntPtr handle, int timeout, string title, string text, ToolTipIcon icon);
933                 public abstract void DrawBalloonWindow (Graphics dc, Rectangle clip, NotifyIcon.BalloonWindow control);
934                 public abstract Rectangle BalloonWindowRect (NotifyIcon.BalloonWindow control);
935 #endif
936                 #endregion      // BalloonWindow
937
938                 #region TrackBar
939                 // Drawing
940                 public abstract void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb);
941
942                 // Sizing
943                 public abstract Size TrackBarDefaultSize{get; }         // Default size for the TrackBar control
944                 
945                 public abstract int TrackBarValueFromMousePosition (int x, int y, TrackBar tb);
946                 #endregion      // TrackBar
947
948                 #region VScrollBar
949                 public abstract Size VScrollBarDefaultSize{get;}        // Default size of the scrollbar
950                 #endregion      // VScrollBar
951
952                 #region TreeView
953                 public abstract Size TreeViewDefaultSize { get; }
954                 #endregion
955
956                 public virtual void DrawManagedWindowDecorations (Graphics dc, Rectangle clip, InternalWindowManager wm)
957                 {
958                         // Just making virtual for now so all the themes still build.
959                 }
960
961                 public virtual int ManagedWindowTitleBarHeight (InternalWindowManager wm)
962                 {
963                         // Just making virtual for now so all the themes still build.
964                         return 15;
965                 }
966
967                 public virtual int ManagedWindowBorderWidth (InternalWindowManager wm)
968                 {
969                         // Just making virtual for now so all the themes still build.
970                         return 3;
971                 }
972
973                 public virtual int ManagedWindowIconWidth (InternalWindowManager wm)
974                 {
975                         // Just making virtual for now so all the themes still build.
976                         return ManagedWindowTitleBarHeight (wm) - 5;
977                 }
978
979                 public virtual Size ManagedWindowButtonSize (InternalWindowManager wm)
980                 {
981                         // Just making virtual for now so all the themes still build.
982                         return new Size (10, 10);
983                 }
984
985                 public virtual void ManagedWindowSetButtonLocations (InternalWindowManager wm)
986                 {
987                         // Just making virtual for now so all the themes still build.
988                 }
989
990                 #region ControlPaint Methods
991                 public abstract void CPDrawBorder (Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
992                         ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
993                         Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
994                         int bottomWidth, ButtonBorderStyle bottomStyle);
995
996                 public abstract void CPDrawBorder (Graphics graphics, RectangleF bounds, Color leftColor, int leftWidth,
997                         ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
998                         Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
999                         int bottomWidth, ButtonBorderStyle bottomStyle);
1000
1001                 public abstract void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides);
1002                 public abstract void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color);
1003                 public abstract void CPDrawButton (Graphics graphics, Rectangle rectangle, ButtonState state);
1004                 public abstract void CPDrawCaptionButton (Graphics graphics, Rectangle rectangle, CaptionButton button, ButtonState state);
1005                 public abstract void CPDrawCheckBox (Graphics graphics, Rectangle rectangle, ButtonState state);
1006                 public abstract void CPDrawComboButton (Graphics graphics, Rectangle rectangle, ButtonState state);
1007                 public abstract void CPDrawContainerGrabHandle (Graphics graphics, Rectangle bounds);
1008                 public abstract void CPDrawFocusRectangle (Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor);
1009                 public abstract void CPDrawGrabHandle (Graphics graphics, Rectangle rectangle, bool primary, bool enabled);
1010                 public abstract void CPDrawGrid (Graphics graphics, Rectangle area, Size pixelsBetweenDots, Color backColor);
1011                 public abstract void CPDrawImageDisabled (Graphics graphics, Image image, int x, int y, Color background);
1012                 public abstract void CPDrawLockedFrame (Graphics graphics, Rectangle rectangle, bool primary);
1013                 public abstract void CPDrawMenuGlyph (Graphics graphics, Rectangle rectangle, MenuGlyph glyph, Color color);
1014                 public abstract void CPDrawRadioButton (Graphics graphics, Rectangle rectangle, ButtonState state);
1015                 public abstract void CPDrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style);
1016                 public abstract void CPDrawReversibleLine (Point start, Point end, Color backColor);
1017                 public abstract void CPDrawScrollButton (Graphics graphics, Rectangle rectangle, ScrollButton button, ButtonState state);
1018                 public abstract void CPDrawSelectionFrame (Graphics graphics, bool active, Rectangle outsideRect, Rectangle insideRect,
1019                         Color backColor);
1020                 public abstract void CPDrawSizeGrip (Graphics graphics, Color backColor, Rectangle bounds);
1021                 public abstract void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
1022                         StringFormat format);
1023                 public abstract void CPDrawBorderStyle (Graphics dc, Rectangle area, BorderStyle border_style);
1024                 #endregion      // ControlPaint Methods
1025         }
1026 }