Fix bug #395
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ToolStripProfessionalRenderer.cs
1 //
2 // ToolStripProfessionalRenderer.cs
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
11 // 
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 // 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 //
23 // Copyright (c) 2006 Jonathan Pobst
24 //
25 // Authors:
26 //      Jonathan Pobst (monkey@jpobst.com)
27 //
28
29 using System;
30 using System.Drawing;
31 using System.Drawing.Drawing2D;
32 using System.Drawing.Imaging;
33
34 namespace System.Windows.Forms
35 {
36         public class ToolStripProfessionalRenderer : ToolStripRenderer
37         {
38                 private ProfessionalColorTable color_table;
39                 private bool rounded_edges;
40
41                 #region Public Constructor
42                 public ToolStripProfessionalRenderer () : this (new ProfessionalColorTable ())
43                 {
44                 }
45                 
46                 public ToolStripProfessionalRenderer (ProfessionalColorTable professionalColorTable) : base ()
47                 {
48                         color_table = professionalColorTable;
49                         rounded_edges = true;
50                 }
51                 #endregion
52
53                 #region Public Properties
54                 public ProfessionalColorTable ColorTable {
55                         get { return this.color_table; }
56                 }
57
58                 public bool RoundedEdges {
59                         get { return this.rounded_edges; }
60                         set { this.rounded_edges = value; }
61                 }
62                 #endregion
63
64                 #region Protected Methods
65                 protected override void OnRenderArrow (ToolStripArrowRenderEventArgs e)
66                 {
67                         base.OnRenderArrow (e);
68                 }
69
70                 protected override void OnRenderButtonBackground (ToolStripItemRenderEventArgs e)
71                 {
72                         if (e.Item.Enabled == false)
73                                 return;
74                                 
75                         Rectangle paint_here = new Rectangle (0, 0, e.Item.Width, e.Item.Height);
76
77                         // Paint gradient background
78                         if (e.Item is ToolStripButton && (e.Item as ToolStripButton).Checked && !e.Item.Selected) {
79                                 if (this.ColorTable.UseSystemColors)
80                                         e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.ButtonCheckedHighlight), paint_here);
81                                 else
82                                         using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ButtonCheckedGradientBegin, this.ColorTable.ButtonCheckedGradientEnd, LinearGradientMode.Vertical))
83                                         e.Graphics.FillRectangle (b, paint_here); }
84                         else
85                                 if (e.Item is ToolStripDropDownItem && e.Item.Pressed) // || (e.Item as ToolStripMenuItem).DropDown.Visible == true))
86                                         using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ToolStripGradientBegin, this.ColorTable.ToolStripGradientEnd, LinearGradientMode.Vertical))
87                                                 e.Graphics.FillRectangle (b, paint_here);
88                                 else if (e.Item.Pressed || (e.Item is ToolStripButton && (e.Item as ToolStripButton).Checked))
89                                         using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ButtonPressedGradientBegin, this.ColorTable.ButtonPressedGradientEnd, LinearGradientMode.Vertical))
90                                                 e.Graphics.FillRectangle (b, paint_here);
91                                 else if (e.Item.Selected) // && !e.Item.Pressed)
92                                         using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ButtonSelectedGradientBegin, this.ColorTable.ButtonSelectedGradientEnd, LinearGradientMode.Vertical))
93                                                 e.Graphics.FillRectangle (b, paint_here);
94                                 else if (e.Item.BackColor != Control.DefaultBackColor && e.Item.BackColor != Color.Empty)
95                                         using (Brush b = new SolidBrush (e.Item.BackColor))
96                                                 e.Graphics.FillRectangle (b, paint_here);
97
98                         paint_here.Width -= 1;
99                         paint_here.Height -= 1;
100
101                         // Paint border
102                         if (e.Item.Selected && !e.Item.Pressed)
103                                 using (Pen p = new Pen (this.ColorTable.ButtonSelectedBorder))
104                                         e.Graphics.DrawRectangle (p, paint_here);
105                         else if (e.Item.Pressed)
106                                 using (Pen p = new Pen (this.ColorTable.ButtonPressedBorder))
107                                         e.Graphics.DrawRectangle (p, paint_here);
108                         else if (e.Item is ToolStripButton && (e.Item as ToolStripButton).Checked)
109                                 using (Pen p = new Pen (this.ColorTable.ButtonPressedBorder))
110                                         e.Graphics.DrawRectangle (p, paint_here);
111
112                         base.OnRenderButtonBackground (e);
113                 }
114
115                 protected override void OnRenderDropDownButtonBackground (ToolStripItemRenderEventArgs e)
116                 {
117                         Rectangle paint_here = new Rectangle (0, 0, e.Item.Width, e.Item.Height);
118
119                         // Paint gradient background
120                         if (e.Item.Selected && !e.Item.Pressed)
121                                 using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ButtonSelectedGradientBegin, this.ColorTable.ButtonSelectedGradientEnd, LinearGradientMode.Vertical))
122                                         e.Graphics.FillRectangle (b, paint_here);
123                         else if (e.Item.Pressed)
124                                 using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ImageMarginGradientMiddle, this.ColorTable.ImageMarginGradientEnd, LinearGradientMode.Vertical))
125                                         e.Graphics.FillRectangle (b, paint_here);
126
127                         paint_here.Width -= 1;
128                         paint_here.Height -= 1;
129
130                         // Paint border
131                         if (e.Item.Selected && !e.Item.Pressed)
132                                 using (Pen p = new Pen (this.ColorTable.ButtonSelectedBorder))
133                                         e.Graphics.DrawRectangle (p, paint_here);
134                         else if (e.Item.Pressed)
135                                 using (Pen p = new Pen (this.ColorTable.MenuBorder))
136                                         e.Graphics.DrawRectangle (p, paint_here);
137
138                         base.OnRenderDropDownButtonBackground (e);
139                 }
140
141                 protected override void OnRenderGrip (ToolStripGripRenderEventArgs e)
142                 {
143                         if (e.GripStyle == ToolStripGripStyle.Hidden)
144                                 return;
145
146                         if (e.GripDisplayStyle == ToolStripGripDisplayStyle.Vertical) {
147                                 Rectangle r = new Rectangle (e.GripBounds.Left, e.GripBounds.Top + 5, 2, 2);
148
149                                 for (int i = 0; i < e.GripBounds.Height - 12; i += 4) {
150                                         e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.GripLight), r);
151                                         r.Offset (0, 4);
152                         }
153
154                                 Rectangle r2 = new Rectangle (e.GripBounds.Left - 1, e.GripBounds.Top + 4, 2, 2);
155
156                                 for (int i = 0; i < e.GripBounds.Height - 12; i += 4) {
157                                         e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.GripDark), r2);
158                                         r2.Offset (0, 4);
159                                 }
160                         }
161                         else {
162                                 Rectangle r = new Rectangle (e.GripBounds.Left + 5, e.GripBounds.Top, 2, 2);
163
164                                 for (int i = 0; i < e.GripBounds.Width - 11; i += 4) {
165                                         e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.GripLight), r);
166                                         r.Offset (4, 0);
167                                 }
168
169                                 Rectangle r2 = new Rectangle (e.GripBounds.Left + 4, e.GripBounds.Top - 1, 2, 2);
170
171                                 for (int i = 0; i < e.GripBounds.Width - 11; i += 4) {
172                                         e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.GripDark), r2);
173                                         r2.Offset (4, 0);
174                                 }
175                         }
176
177                         base.OnRenderGrip (e);
178                 }
179
180                 protected override void OnRenderImageMargin (ToolStripRenderEventArgs e)
181                 {
182                         if (!(e.ToolStrip is ToolStripOverflow)) {
183                                 Rectangle side_gradient = new Rectangle (1, 2, 24, e.ToolStrip.Height - 3);
184                                 using (LinearGradientBrush b = new LinearGradientBrush (side_gradient, this.ColorTable.ToolStripGradientBegin, this.ColorTable.ToolStripGradientEnd, LinearGradientMode.Horizontal))
185                                         e.Graphics.FillRectangle (b, side_gradient);
186                         }
187
188                         base.OnRenderImageMargin (e);
189                 }
190
191                 protected override void OnRenderItemCheck (ToolStripItemImageRenderEventArgs e)
192                 {
193                         if (e.Item.Selected)
194                         {
195                                 e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.CheckPressedBackground), e.ImageRectangle);
196                                 e.Graphics.DrawRectangle (ThemeEngine.Current.ResPool.GetPen (this.ColorTable.ButtonPressedBorder), e.ImageRectangle);
197                         }
198                         else if (e.Item.Pressed)
199                         {
200                                 e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.CheckSelectedBackground), e.ImageRectangle);
201                                 e.Graphics.DrawRectangle (ThemeEngine.Current.ResPool.GetPen (this.ColorTable.ButtonSelectedBorder), e.ImageRectangle);
202                         }
203                         else
204                         {
205                                 e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.CheckSelectedBackground), e.ImageRectangle);
206                                 e.Graphics.DrawRectangle (ThemeEngine.Current.ResPool.GetPen (this.ColorTable.ButtonSelectedBorder), e.ImageRectangle);
207                         }
208                         if (e.Item.Image == null)
209                                 ControlPaint.DrawMenuGlyph(e.Graphics, new Rectangle (6,5,7,6), MenuGlyph.Checkmark);
210                         
211                         base.OnRenderItemCheck (e);
212                 }
213                 
214                 protected override void OnRenderItemImage (ToolStripItemImageRenderEventArgs e)
215                 {
216                         base.OnRenderItemImage (e);
217                 }
218
219                 protected override void OnRenderItemText (ToolStripItemTextRenderEventArgs e)
220                 {
221                         base.OnRenderItemText (e);
222                 }
223
224                 protected override void OnRenderLabelBackground (ToolStripItemRenderEventArgs e)
225                 {
226                         base.OnRenderLabelBackground (e);
227                 }
228
229                 protected override void OnRenderMenuItemBackground (ToolStripItemRenderEventArgs e)
230                 {
231                         ToolStripMenuItem tsmi = (ToolStripMenuItem)e.Item;
232                         Rectangle paint_here;
233
234                         if (tsmi.IsOnDropDown) {
235                                 paint_here = new Rectangle (1, 0, e.Item.Bounds.Width - 3, e.Item.Bounds.Height - 1);
236                                 
237                                 if (e.Item.Selected || e.Item.Pressed)
238                                         if (e.Item.Enabled)
239                                                 e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.MenuItemSelectedGradientEnd), paint_here);
240
241                                 if (tsmi.Selected || tsmi.Pressed)
242                                         using (Pen p = new Pen (this.ColorTable.MenuItemBorder))
243                                                 e.Graphics.DrawRectangle (p, paint_here);
244                         }
245                         else {
246                                 paint_here = new Rectangle (0, 0, e.Item.Width, e.Item.Height);
247
248                                 if (e.Item.Pressed)
249                                         using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ToolStripGradientBegin, this.ColorTable.ToolStripGradientEnd, LinearGradientMode.Vertical))
250                                                 e.Graphics.FillRectangle (b, paint_here);
251                                 else if (e.Item.Selected)
252                                         using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ButtonSelectedGradientBegin, this.ColorTable.ButtonSelectedGradientEnd, LinearGradientMode.Vertical))
253                                                 e.Graphics.FillRectangle (b, paint_here);
254                                 else if (e.Item.BackColor != Control.DefaultBackColor && e.Item.BackColor != Color.Empty)
255                                         using (Brush b = new SolidBrush (e.Item.BackColor))
256                                                 e.Graphics.FillRectangle (b, paint_here);
257
258                                 paint_here.Width -= 1;
259                                 paint_here.Height -= 1;
260
261                                 if (tsmi.Selected || tsmi.Pressed) {
262                                         if (tsmi.HasDropDownItems && tsmi.DropDown.Visible)
263                                                 using (Pen p = new Pen (this.ColorTable.MenuBorder))
264                                                         e.Graphics.DrawRectangle (p, paint_here);                               
265                                         else
266                                                 using (Pen p = new Pen (this.ColorTable.MenuItemBorder))
267                                                         e.Graphics.DrawRectangle (p, paint_here);
268                                 }
269                         }
270                         
271                         base.OnRenderMenuItemBackground (e);
272                 }
273
274                 protected override void OnRenderOverflowButtonBackground (ToolStripItemRenderEventArgs e)
275                 {
276                         Rectangle paint_here;
277                         LinearGradientMode gradient_direction = e.ToolStrip.Orientation == Orientation.Vertical ? LinearGradientMode.Horizontal : LinearGradientMode.Vertical;
278                         
279                         if (e.ToolStrip.Orientation == Orientation.Horizontal)
280                                 paint_here = new Rectangle (e.Item.Width - 11, 0, 11, e.Item.Height - 1);
281                         else
282                                 paint_here = new Rectangle (0, e.Item.Height - 11, e.Item.Width - 1, 11);
283                         
284                         // Paint gradient background
285                         if (e.Item.Selected && !e.Item.Pressed)
286                                 using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ButtonSelectedGradientBegin, this.ColorTable.ButtonSelectedGradientEnd, gradient_direction))
287                                         e.Graphics.FillRectangle (b, paint_here);
288                         else if (e.Item.Pressed)
289                                 using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ButtonPressedGradientBegin, this.ColorTable.ButtonPressedGradientEnd, gradient_direction))
290                                         e.Graphics.FillRectangle (b, paint_here);
291                         else
292                                 using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.OverflowButtonGradientBegin, this.ColorTable.OverflowButtonGradientEnd, gradient_direction))
293                                         e.Graphics.FillRectangle (b, paint_here);
294
295                         // Paint the arrow
296                         PaintOverflowArrow (e, paint_here);
297
298                         base.OnRenderOverflowButtonBackground (e);
299                 }
300
301                 protected override void OnRenderSeparator (ToolStripSeparatorRenderEventArgs e)
302                 {
303                         if (e.Vertical) {
304                                 Rectangle r = new Rectangle (4, 6, 1, e.Item.Height - 10);
305                                 e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.SeparatorLight), r);
306
307                                 Rectangle r2 = new Rectangle (3, 5, 1, e.Item.Height - 10);
308                                 e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.SeparatorDark), r2);
309                         }
310                         else {
311                                 if (!e.Item.IsOnDropDown) {
312                                         Rectangle r = new Rectangle (6, 4, e.Item.Width - 10, 1);
313                                         e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.SeparatorLight), r);
314                                 }
315
316                                 Rectangle r3;
317                                 if (e.Item.IsOnDropDown) {
318                                         if (e.Item.UseImageMargin)
319                                                 r3 = new Rectangle (35, 3, e.Item.Width - 36, 1);
320                                         else
321                                                 r3 = new Rectangle (7, 3, e.Item.Width - 7, 1);
322                                 } else
323                                         r3 = new Rectangle (5, 3, e.Item.Width - 10, 1);
324                                         
325                                 e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (this.ColorTable.SeparatorDark), r3);
326                         }
327
328                         base.OnRenderSeparator (e);
329                 }
330
331                 protected override void OnRenderSplitButtonBackground (ToolStripItemRenderEventArgs e)
332                 {
333                         ToolStripSplitButton tssb = (ToolStripSplitButton)e.Item;
334                         Rectangle paint_here = new Rectangle (0, 0, tssb.Width, tssb.Height);
335                         Rectangle button_part = new Rectangle (0, 0, tssb.ButtonBounds.Width, tssb.ButtonBounds.Height);
336
337                         // Paint gradient background
338                         if (tssb.ButtonSelected && !tssb.DropDownButtonPressed)
339                                 using (Brush b = new LinearGradientBrush (paint_here, this.ColorTable.ButtonSelectedGradientBegin, this.ColorTable.ButtonSelectedGradientEnd, LinearGradientMode.Vertical))
340                                         e.Graphics.FillRectangle (b, paint_here);
341                         if (tssb.ButtonPressed)
342                                 using (Brush b = new LinearGradientBrush (button_part, this.ColorTable.ButtonPressedGradientBegin, this.ColorTable.ButtonPressedGradientEnd, LinearGradientMode.Vertical))
343                                         e.Graphics.FillRectangle (b, button_part);
344
345                         paint_here.Width -= 1;
346                         paint_here.Height -= 1;
347
348                         // Paint border
349                         if (e.Item.Selected && !tssb.DropDownButtonPressed)
350                                 using (Pen p = new Pen (this.ColorTable.ButtonSelectedBorder))
351                                 {
352                                         e.Graphics.DrawRectangle (p, paint_here);
353                                         e.Graphics.DrawLine (p, button_part.Right, 0, button_part.Right, button_part.Height);
354                                 }
355                         else if (e.Item.Pressed)
356                                 using (Pen p = new Pen (this.ColorTable.MenuBorder))
357                                         e.Graphics.DrawRectangle (p, paint_here);
358
359                         base.OnRenderSplitButtonBackground (e);
360                 }
361
362                 protected override void OnRenderToolStripBackground (ToolStripRenderEventArgs e)
363                 {
364                         // Don't clear and fill the background if we already painted an image there
365                         if (e.ToolStrip.BackgroundImage != null) {
366                                 if (e.ToolStrip is StatusStrip)
367                                         e.Graphics.DrawLine (Pens.White, e.AffectedBounds.Left, e.AffectedBounds.Top, e.AffectedBounds.Right, e.AffectedBounds.Top);
368                         
369                                 return;
370                         }
371                                 
372                         if (e.ToolStrip is ToolStripDropDown) {
373                                 e.Graphics.Clear (this.ColorTable.ToolStripDropDownBackground);
374                                 return;
375                         }
376                         
377                         if (e.ToolStrip is MenuStrip || e.ToolStrip is StatusStrip) {
378                                 using (LinearGradientBrush b = new LinearGradientBrush (e.AffectedBounds, this.ColorTable.MenuStripGradientBegin, this.ColorTable.MenuStripGradientEnd, e.ToolStrip.Orientation == Orientation.Horizontal ? LinearGradientMode.Horizontal : LinearGradientMode.Vertical))
379                                         e.Graphics.FillRectangle (b, e.AffectedBounds);
380                         }
381                         else
382                                 using (LinearGradientBrush b = new LinearGradientBrush (e.AffectedBounds, this.ColorTable.ToolStripGradientBegin, this.ColorTable.ToolStripGradientEnd, e.ToolStrip.Orientation == Orientation.Vertical ? LinearGradientMode.Horizontal : LinearGradientMode.Vertical))
383                                         e.Graphics.FillRectangle (b, e.AffectedBounds);
384                                         
385                         if (e.ToolStrip is StatusStrip)
386                                 e.Graphics.DrawLine (Pens.White, e.AffectedBounds.Left, e.AffectedBounds.Top, e.AffectedBounds.Right, e.AffectedBounds.Top);
387
388                         base.OnRenderToolStripBackground (e);
389                 }
390
391                 protected override void OnRenderToolStripBorder (ToolStripRenderEventArgs e)
392                 {
393                         if (e.ToolStrip is ToolStripDropDown) {
394                                 if (e.ToolStrip is ToolStripOverflow)
395                                         e.Graphics.DrawLines (ThemeEngine.Current.ResPool.GetPen (this.ColorTable.MenuBorder), new Point[] { e.AffectedBounds.Location, new Point (e.AffectedBounds.Left, e.AffectedBounds.Bottom - 1), new Point (e.AffectedBounds.Right - 1, e.AffectedBounds.Bottom - 1), new Point (e.AffectedBounds.Right - 1, e.AffectedBounds.Top), new Point (e.AffectedBounds.Left, e.AffectedBounds.Top) });
396                                 else
397                                         e.Graphics.DrawLines (ThemeEngine.Current.ResPool.GetPen (this.ColorTable.MenuBorder), new Point[] { new Point (e.AffectedBounds.Left + e.ConnectedArea.Left, e.AffectedBounds.Top), e.AffectedBounds.Location, new Point (e.AffectedBounds.Left, e.AffectedBounds.Bottom - 1), new Point (e.AffectedBounds.Right - 1, e.AffectedBounds.Bottom - 1), new Point (e.AffectedBounds.Right - 1, e.AffectedBounds.Top), new Point (e.AffectedBounds.Left + e.ConnectedArea.Right, e.AffectedBounds.Top) });
398                                 return;
399                         }
400
401                         if (e.ToolStrip is MenuStrip || e.ToolStrip is StatusStrip)
402                                 return;
403                                 
404                         using (Pen p = new Pen (this.ColorTable.ToolStripBorder)) {
405                                 if (this.RoundedEdges == true) {
406                                         e.Graphics.DrawLine (p, new Point (2, e.ToolStrip.Height - 1), new Point (e.ToolStrip.Width - 3, e.ToolStrip.Height - 1));
407                                         e.Graphics.DrawLine (p, new Point (e.ToolStrip.Width - 2, e.ToolStrip.Height - 2), new Point (e.ToolStrip.Width - 1, e.ToolStrip.Height - 2));
408                                         e.Graphics.DrawLine (p, new Point (e.ToolStrip.Width - 1, 2), new Point (e.ToolStrip.Width - 1, e.ToolStrip.Height - 3));
409                                 }
410                                 else
411                                         e.Graphics.DrawLine (p, new Point (e.ToolStrip.Left, e.ToolStrip.Bottom - 1), new Point (e.ToolStrip.Width, e.ToolStrip.Bottom - 1));
412                         }
413
414                         base.OnRenderToolStripBorder (e);
415                 }
416                 
417                 protected override void OnRenderToolStripContentPanelBackground (ToolStripContentPanelRenderEventArgs e)
418                 {
419                         base.OnRenderToolStripContentPanelBackground (e);
420                 }
421                 
422                 protected override void OnRenderToolStripPanelBackground (ToolStripPanelRenderEventArgs e)
423                 {
424                         using (LinearGradientBrush b = new LinearGradientBrush (e.ToolStripPanel.Bounds, this.ColorTable.MenuStripGradientBegin, this.ColorTable.MenuStripGradientEnd, e.ToolStripPanel.Orientation == Orientation.Horizontal ? LinearGradientMode.Horizontal : LinearGradientMode.Vertical))
425                                 e.Graphics.FillRectangle (b, e.ToolStripPanel.Bounds);
426
427                         base.OnRenderToolStripPanelBackground (e);
428                 }
429
430                 protected override void OnRenderToolStripStatusLabelBackground (ToolStripItemRenderEventArgs e)
431                 {
432                         base.OnRenderToolStripStatusLabelBackground (e);
433                 }
434                 #endregion
435
436                 #region Private Methods
437                 private static void PaintOverflowArrow (ToolStripItemRenderEventArgs e, Rectangle paint_here)
438                 {
439                         if (e.ToolStrip.Orientation == Orientation.Horizontal) {
440                                 // Paint down arrow
441                                 Point arrow_loc = new Point (paint_here.X + 2, paint_here.Bottom - 9);
442
443                                 e.Graphics.DrawLine (Pens.White, arrow_loc.X + 1, arrow_loc.Y + 1, arrow_loc.X + 5, arrow_loc.Y + 1);
444                                 e.Graphics.DrawLine (Pens.Black, arrow_loc.X, arrow_loc.Y, arrow_loc.X + 4, arrow_loc.Y);
445
446                                 e.Graphics.DrawLine (Pens.White, arrow_loc.X + 3, arrow_loc.Y + 4, arrow_loc.X + 5, arrow_loc.Y + 4);
447                                 e.Graphics.DrawLine (Pens.White, arrow_loc.X + 3, arrow_loc.Y + 5, arrow_loc.X + 4, arrow_loc.Y + 5);
448                                 e.Graphics.DrawLine (Pens.White, arrow_loc.X + 3, arrow_loc.Y + 4, arrow_loc.X + 3, arrow_loc.Y + 6);
449
450                                 e.Graphics.DrawLine (Pens.Black, arrow_loc.X, arrow_loc.Y + 3, arrow_loc.X + 4, arrow_loc.Y + 3);
451                                 e.Graphics.DrawLine (Pens.Black, arrow_loc.X + 1, arrow_loc.Y + 4, arrow_loc.X + 3, arrow_loc.Y + 4);
452                                 e.Graphics.DrawLine (Pens.Black, arrow_loc.X + 2, arrow_loc.Y + 4, arrow_loc.X + 2, arrow_loc.Y + 5);
453                         } else {
454                                 Point arrow_loc = new Point (paint_here.Right - 9, paint_here.Y + 2);
455
456                                 e.Graphics.DrawLine (Pens.White, arrow_loc.X + 1, arrow_loc.Y + 1, arrow_loc.X + 1, arrow_loc.Y + 5);
457                                 e.Graphics.DrawLine (Pens.Black, arrow_loc.X, arrow_loc.Y, arrow_loc.X, arrow_loc.Y + 4);
458
459                                 e.Graphics.DrawLine (Pens.White, arrow_loc.X + 4, arrow_loc.Y + 3, arrow_loc.X + 4, arrow_loc.Y + 5);
460                                 e.Graphics.DrawLine (Pens.White, arrow_loc.X + 5, arrow_loc.Y + 3, arrow_loc.X + 5, arrow_loc.Y + 4);
461                                 e.Graphics.DrawLine (Pens.White, arrow_loc.X + 4, arrow_loc.Y + 3, arrow_loc.X + 6, arrow_loc.Y + 3);
462
463                                 e.Graphics.DrawLine (Pens.Black, arrow_loc.X + 3, arrow_loc.Y, arrow_loc.X + 3, arrow_loc.Y + 4);
464                                 e.Graphics.DrawLine (Pens.Black, arrow_loc.X + 4, arrow_loc.Y + 1, arrow_loc.X + 4, arrow_loc.Y + 3);
465                                 e.Graphics.DrawLine (Pens.Black, arrow_loc.X + 4, arrow_loc.Y + 2, arrow_loc.X + 5, arrow_loc.Y + 2);
466                         }
467                 }
468                 #endregion
469         }
470 }