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