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