* ThemeNice.cs: Changed the color for focused buttons and activated
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ThemeNice.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 //      Alexander Olk, xenomorph2@onlinehome.de
24 //
25 //      based on ThemeWin32Classic
26 //
27 //              - You can activate this Theme with export MONO_THEME=nice
28
29
30 using System.Drawing;
31 using System.Drawing.Drawing2D;
32 using System.Drawing.Imaging;
33 using System.Drawing.Text;
34
35 namespace System.Windows.Forms
36 {
37         internal class ThemeNice : ThemeWin32Classic
38         {
39                 public override Version Version
40                 {
41                         get {
42                                 return new Version( 0, 0, 0, 2 );
43                         }
44                 }
45                 
46                 static readonly Color NormalColor = Color.LightGray;
47                 static readonly Color MouseOverColor = Color.DarkGray;
48                 static readonly Color PressedColor = Color.Gray;
49                 static readonly Color FocusColor = Color.FromArgb( System.Convert.ToInt32( "0xff00c0ff", 16 ) );
50                 static readonly Color FocusColorLight = Color.FromArgb(250, 253, 255);
51                 static readonly Color LightColor = Color.LightGray;
52                 static readonly Color BorderColor = MouseOverColor;
53                 static readonly Color NiceBackColor  = Color.FromArgb( System.Convert.ToInt32( "0xffefebe7", 16 ) );
54                 
55                 static Bitmap size_grip_bmp = CreateSizegripDot();
56                 
57                 #region Principal Theme Methods
58                 public ThemeNice( )
59                 {
60                         ColorControl = NiceBackColor;
61                         always_draw_hotkeys = true;
62                 }
63                 
64                 public override Color DefaultControlBackColor
65                 {
66                         get { return NiceBackColor; }
67                 }
68                 
69                 public override Color DefaultWindowBackColor
70                 {
71                         get { return NiceBackColor; }                   
72                 }
73                 
74                 public override Color ColorControl {
75                         get { return NiceBackColor;}
76                 }
77                 
78                 static Bitmap CreateSizegripDot()
79                 {
80                         Bitmap bmp = new Bitmap( 4, 4 );
81                         using ( Graphics dc = Graphics.FromImage( bmp ) )
82                         {
83                                 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
84                                 dc.SmoothingMode = SmoothingMode.AntiAlias;
85                                 
86                                 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 4, 4 ), PressedColor, Color.White ) )
87                                                 dc.FillEllipse( lgbr, new Rectangle( 0, 0, 4, 4 ) );
88                                 
89                                 dc.SmoothingMode = old_smoothing_mode;
90                         }
91                         
92                         return bmp;
93                 }
94                 #endregion      // Internal Methods
95                 
96                 #region ButtonBase
97                 protected override void ButtonBase_DrawButton (ButtonBase button, Graphics dc)
98                 {
99                         bool check_or_radio = false;
100                         bool check_or_radio_checked = false;
101                         
102                         Color use_color = NormalColor;
103                         Color first_color = Color.White;
104                         
105                         dc.FillRectangle (ResPool.GetSolidBrush (button.BackColor), button.ClientRectangle);
106                         
107                         if (button is CheckBox) {
108                                 check_or_radio = true;
109                                 check_or_radio_checked = ((CheckBox)button).Checked;
110                         } else if (button is RadioButton) {
111                                 check_or_radio = true;
112                                 check_or_radio_checked = ((RadioButton)button).Checked;
113                         }
114                         
115                         if (button.has_focus && !check_or_radio && button.is_enabled)
116                                 first_color = FocusColorLight;
117                         
118                         if (button.is_enabled) {
119                                 if (button.FlatStyle == FlatStyle.Popup) {
120                                         if (!button.is_pressed && button.is_entered && !check_or_radio_checked)
121                                                 use_color = MouseOverColor;
122                                         else if (button.is_pressed || check_or_radio_checked)
123                                                 use_color = PressedColor;
124                                 } else if (button.FlatStyle == FlatStyle.Flat) {
125                                         if (button.is_entered && !button.is_pressed && !check_or_radio_checked)
126                                                 use_color = MouseOverColor;
127                                         else if (button.is_pressed || check_or_radio_checked) {
128                                                 use_color = PressedColor;
129                                         }
130                                 } else {
131                                         if (!button.is_pressed && button.is_entered && !check_or_radio_checked)
132                                                 use_color = MouseOverColor;
133                                         else
134                                         if (button.is_pressed || check_or_radio_checked)
135                                                 use_color = PressedColor;
136                                 }
137                         }
138                         
139                         Rectangle buttonRectangle;
140                         
141                         int width = button.ClientSize.Width;
142                         int height = button.ClientSize.Height;
143                         
144                         // set up the button rectangle
145                         buttonRectangle = button.ClientRectangle;
146                         
147                         // Fill button with a nice linear gradient brush
148                         Rectangle lgbRectangle = Rectangle.Inflate (buttonRectangle, -1, -1);
149                         
150                         if (button.flat_style != FlatStyle.Popup || ((button.flat_style == FlatStyle.Popup) && button.is_entered)) {
151                                 LinearGradientBrush lgbr;
152                                 if (button.flat_style == FlatStyle.Flat)
153                                         lgbr = new LinearGradientBrush (new Point (0, 0), new Point (0, height - 1), use_color, first_color);
154                                 else
155                                         lgbr = new LinearGradientBrush (new Point (0, 0), new Point (0, height - 1), first_color, use_color);
156                                 dc.FillRectangle (lgbr, lgbRectangle);
157                                 lgbr.Dispose ();
158                                 
159                                 if (button.has_focus && !check_or_radio)
160                                         return; 
161                                 
162                                 Point[] points = new Point [] {
163                                         new Point (2, 0),
164                                         new Point (width - 3, 0),
165                                         new Point (width - 1, 2),
166                                         new Point (width - 1, height - 3),
167                                         new Point (width - 3, height - 1),
168                                         new Point (2, height - 1),
169                                         new Point (0, height - 3),
170                                         new Point (0, 2),
171                                         new Point (2, 0)
172                                 };
173                                 
174                                 Pen pen = ResPool.GetPen (BorderColor);
175                                 dc.DrawLines (pen, points);
176                         }
177                 }
178                 
179                 protected override void ButtonBase_DrawFocus( ButtonBase button, Graphics dc )
180                 {
181                         if ((button is RadioButton) || (button is CheckBox))
182                                 return; 
183                         
184                         int width = button.ClientSize.Width;
185                         int height = button.ClientSize.Height;
186                         
187                         Point[] points = new Point[] {
188                                 new Point( 2, 0 ),
189                                 new Point( width - 3, 0 ),
190                                 new Point( width - 1, 2 ),
191                                 new Point( width - 1, height - 3 ),
192                                 new Point( width - 3, height - 1 ),
193                                 new Point( 2, height - 1 ),
194                                 new Point( 0, height - 3 ),
195                                 new Point( 0, 2 ),
196                                 new Point( 2, 0 )
197                         };
198                         
199                         Pen pen = ResPool.GetPen( FocusColor );
200                         dc.DrawLines( pen, points );
201                 }
202                 
203                 protected override void ButtonBase_DrawText( ButtonBase button, Graphics dc )
204                 {
205                         if ( !( button is CheckBox ) && !(button is RadioButton ) )
206                         {
207                                 base.ButtonBase_DrawText( button, dc );
208                         }
209                 }
210                 #endregion      // ButtonBase
211                 
212                 #region ComboBox
213                 
214                 // Drawing
215                 
216                 public override void DrawComboBoxEditDecorations( Graphics dc, ComboBox ctrl, Rectangle cl )
217                 {
218                         if ( !ctrl.Focused )
219                         {
220                                 dc.DrawLine (ResPool.GetPen (BorderColor), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top 
221                                 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
222                                 dc.DrawLine (ResPool.GetPen (BorderColor), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
223                                 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2); 
224                                 dc.DrawLine (ResPool.GetPen (BorderColor), cl.X + cl.Width - 1, cl.Y, cl.X + cl.Width - 1, cl.Y + cl.Height); //right
225                                 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + cl.Width - 2, cl.Y + 1 , cl.X + cl.Width - 2, cl.Y + cl.Height - 1);
226                                 dc.DrawLine (ResPool.GetPen (BorderColor), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
227                                 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
228                         }
229                         else
230                         {
231                                 dc.DrawLine (ResPool.GetPen (FocusColor), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top 
232                                 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
233                                 dc.DrawLine (ResPool.GetPen (FocusColor), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
234                                 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2); 
235                                 dc.DrawLine (ResPool.GetPen (FocusColor), cl.X + cl.Width - 1, cl.Y, cl.X + cl.Width - 1, cl.Y + cl.Height); //right
236                                 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + cl.Width - 2, cl.Y + 1 , cl.X + cl.Width - 2, cl.Y + cl.Height - 1);
237                                 dc.DrawLine (ResPool.GetPen (FocusColor), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
238                                 dc.DrawLine (ResPool.GetPen (FocusColor), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
239                         }
240                 }
241                 
242                 public override void DrawComboListBoxDecorations( Graphics dc, ComboBox ctrl, Rectangle cl )
243                 {
244                         if ( ctrl.DropDownStyle == ComboBoxStyle.Simple )
245                         {
246                                 DrawComboBoxEditDecorations( dc, ctrl, cl );
247                         }
248                         else
249                         {
250                                 dc.DrawRectangle( ResPool.GetPen( ColorWindowFrame ), cl.X, cl.Y, cl.Width - 1, cl.Height - 1 );
251                         }
252                 }               
253                 #endregion ComboBox
254                 
255                 #region Menus
256                 public override void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect)
257                 {
258                         if (menu.Height == 0)
259                                 CalcMenuBarSize (dc, menu, rect.Width);
260                         
261                         bool keynav = (menu as MainMenu).tracker.Navigating;
262                         HotkeyPrefix hp = always_draw_hotkeys || keynav ? HotkeyPrefix.Show : HotkeyPrefix.Hide;
263                         string_format_menu_menubar_text.HotkeyPrefix = hp;
264                         string_format_menu_text.HotkeyPrefix = hp;
265                         
266                         rect.Height = menu.Height;
267                         dc.FillRectangle (ResPool.GetSolidBrush (NiceBackColor), rect);
268                         
269                         for (int i = 0; i < menu.MenuItems.Count; i++) {
270                                 MenuItem item = menu.MenuItems [i];
271                                 Rectangle item_rect = item.bounds;
272                                 item_rect.X += rect.X;
273                                 item_rect.Y += rect.Y;
274                                 item.MenuHeight = menu.Height;
275                                 item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont, item_rect, i, item.Status)); 
276                         }       
277                 }
278                 
279                 public override void DrawMenuItem (MenuItem item, DrawItemEventArgs e)
280                 {
281                         StringFormat string_format;
282                         Rectangle rect_text = e.Bounds;
283                         
284                         if (item.Visible == false)
285                                 return;
286                         
287                         if (item.MenuBar)
288                                 string_format = string_format_menu_menubar_text;
289                         else
290                                 string_format = string_format_menu_text;
291                         
292                         if (item.Separator == true) {
293                                 e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
294                                                      e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y);
295                                 
296                                 e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
297                                                      e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + 1);
298                                 
299                                 return;
300                         }
301                         
302                         if (!item.MenuBar)
303                                 rect_text.X += MenuCheckSize.Width;
304                         
305                         if (item.BarBreak) { /* Draw vertical break bar*/
306                                 Rectangle rect = e.Bounds;
307                                 rect.Y++;
308                                 rect.Width = 3;
309                                 rect.Height = item.MenuHeight - 6;
310                                 
311                                 e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
312                                                      rect.X, rect.Y , rect.X, rect.Y + rect.Height);
313                                 
314                                 e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
315                                                      rect.X + 1, rect.Y , rect.X +1, rect.Y + rect.Height);
316                         }                       
317                         
318                         Color color_text = ColorMenuText;
319                         Color color_back = NiceBackColor;
320                         
321                         /* Draw background */
322                         Rectangle rect_back = e.Bounds;
323                         rect_back.X++;
324                         rect_back.Width -=2;
325                         
326                         if (((e.State & DrawItemState.Selected) == DrawItemState.Selected) || ((e.State & DrawItemState.HotLight) == DrawItemState.HotLight)) {
327                                         using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (rect_back.X, rect_back.Y), new Point (rect_back.Right, rect_back.Y), Color.White, NormalColor))//NormalColor, Color.White ) )
328                                                 e.Graphics.FillRectangle (lgbr, rect_back);
329                                         
330                                         e.Graphics.DrawRectangle (ResPool.GetPen (BorderColor), rect_back.X, rect_back.Y, rect_back.Width, rect_back.Height - 1);
331                         } else {
332                                 e.Graphics.FillRectangle (ResPool.GetSolidBrush (NiceBackColor), rect_back);
333                         }
334                         
335                         if (item.Enabled) {
336                                 e.Graphics.DrawString (item.Text, e.Font,
337                                                        ResPool.GetSolidBrush (color_text),
338                                                        rect_text, string_format);
339                                 
340                                 if (!item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut) {
341                                         string str = item.GetShortCutText ();
342                                         Rectangle rect = rect_text;
343                                         rect.X = item.XTab;
344                                         rect.Width -= item.XTab;
345                                         
346                                         e.Graphics.DrawString (str, e.Font, ResPool.GetSolidBrush (color_text),
347                                                                rect, string_format_menu_shortcut);
348                                 }
349                                 
350                         } else {
351                                 ControlPaint.DrawStringDisabled (e.Graphics, item.Text, e.Font, 
352                                                                  Color.Black, rect_text, string_format);
353                         }
354                         
355                         /* Draw arrow */
356                         if (item.MenuBar == false && item.IsPopup || item.MdiList) {
357                                 
358                                 int cx = MenuCheckSize.Width;
359                                 int cy = MenuCheckSize.Height;
360                                 Bitmap  bmp = CreateGlyphBitmap (new Size (cx, cy), MenuGlyph.Arrow, color_text);
361                                 
362                                 if (item.Enabled) {
363                                         e.Graphics.DrawImage (bmp, e.Bounds.X + e.Bounds.Width - cx,
364                                                               e.Bounds.Y + ((e.Bounds.Height - cy) /2));
365                                 } else {
366                                         ControlPaint.DrawImageDisabled (e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
367                                                                         e.Bounds.Y + ((e.Bounds.Height - cy) /2),  color_back);
368                                 }
369                                 
370                                 bmp.Dispose ();
371                         }
372                         
373                         /* Draw checked or radio */
374                         if (item.MenuBar == false && item.Checked) {
375                                 
376                                 Rectangle area = e.Bounds;
377                                 int cx = MenuCheckSize.Width;
378                                 int cy = MenuCheckSize.Height;
379                                 Bitmap  bmp = CreateGlyphBitmap (new Size (cx, cy), item.RadioCheck ? MenuGlyph.Bullet : MenuGlyph.Checkmark, color_text);
380                                 
381                                 e.Graphics.DrawImage (bmp, area.X, e.Bounds.Y + ((e.Bounds.Height - cy) / 2));
382                                 
383                                 bmp.Dispose ();
384                         }                       
385                 }                       
386                 
387                 public override void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect)
388                 {
389                         
390                         dc.FillRectangle (ResPool.GetSolidBrush
391                                           (NiceBackColor), cliparea);
392                         
393                         /* Draw menu borders */
394                         dc.DrawLine (ResPool.GetPen (ColorHighlightText),
395                                      rect.X, rect.Y, rect.X + rect.Width, rect.Y);
396                         
397                         dc.DrawLine (ResPool.GetPen (ColorHighlightText),
398                                      rect.X, rect.Y, rect.X, rect.Y + rect.Height);
399                         
400                         dc.DrawLine (ResPool.GetPen (ColorControlDark),
401                                      rect.X + rect.Width - 1 , rect.Y , rect.X + rect.Width - 1, rect.Y + rect.Height);
402                         
403                         dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
404                                      rect.X + rect.Width, rect.Y , rect.X + rect.Width, rect.Y + rect.Height);
405                         
406                         dc.DrawLine (ResPool.GetPen (ColorControlDark),
407                                      rect.X , rect.Y + rect.Height - 1 , rect.X + rect.Width - 1, rect.Y + rect.Height -1);
408                         
409                         dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
410                                      rect.X , rect.Y + rect.Height, rect.X + rect.Width - 1, rect.Y + rect.Height);
411                         
412                         for (int i = 0; i < menu.MenuItems.Count; i++)
413                                 if (cliparea.IntersectsWith (menu.MenuItems [i].bounds)) {
414                                         MenuItem item = menu.MenuItems [i];
415                                         item.MenuHeight = menu.Height;
416                                         item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont,
417                                                                                      item.bounds, i, item.Status));
418                                 }
419                 }
420                 #endregion // Menus
421                 
422                 #region ProgressBar
423                 public override void DrawProgressBar( Graphics dc, Rectangle clip_rect, ProgressBar ctrl )
424                 {
425                         Rectangle       client_area = ctrl.client_area;
426                         int             barpos_pixels;
427                         Rectangle bar = ctrl.client_area;
428                         
429                         barpos_pixels = ( ( ctrl.Value - ctrl.Minimum ) * client_area.Width ) / ( ctrl.Maximum - ctrl.Minimum );
430                         
431                         bar.Width = barpos_pixels;
432 //                      bar.Height += 1;
433                         
434                         // Draw bar background
435                         using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( client_area.Left, client_area.Top ), new Point( client_area.Left, client_area.Bottom ), LightColor, Color.White ) )
436                         {
437                                 dc.FillRectangle( lgbr, client_area );
438                         }
439                         
440                         // Draw bar
441                         using ( LinearGradientBrush lgbr = new LinearGradientBrush( bar.Location, new Point( bar.X, bar.Bottom ), Color.White, PressedColor ) )
442                         {
443                                 dc.FillRectangle( lgbr, bar );
444                         }
445                         
446                         /* Draw border */
447                         dc.DrawRectangle( ResPool.GetPen( BorderColor ), ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.Width - 1, ctrl.ClientRectangle.Height - 1 );
448                         dc.DrawRectangle( ResPool.GetPen( LightColor ), ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.Width - 2, ctrl.ClientRectangle.Height - 2 );
449                 }
450                 #endregion      // ProgressBar
451                 
452                 #region RadioButton
453                 protected override void RadioButton_DrawFocus(RadioButton radio_button, Graphics dc, Rectangle text_rectangle)
454                 {
455                         if (radio_button.Focused && radio_button.appearance != Appearance.Button) 
456                         {
457                                 if (radio_button.FlatStyle != FlatStyle.Flat && radio_button.FlatStyle != FlatStyle.Popup) 
458                                 {
459                                         DrawInnerFocusRectangle (dc, text_rectangle, radio_button.BackColor);
460                                 } 
461                         }
462                 }
463                 #endregion      // RadioButton
464                 
465                 #region ScrollBar
466                 protected override void ScrollBar_DrawThumb( ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
467                 {
468                         if ( bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith( thumb_pos ) )
469                                 DrawScrollBarThumb( dc, thumb_pos, bar );
470                 }
471                 
472                 protected override void ScrollBar_Vertical_Draw_ThumbMoving_None( int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc )
473                 {
474                         Rectangle r = new Rectangle( 0,
475                                                     scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - ( scrollbutton_height * 2 ) );
476                         Rectangle intersect = Rectangle.Intersect( clip, r );
477                         
478                         if ( intersect != Rectangle.Empty  )
479                         {
480                                 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
481                                 {
482                                         dc.FillRectangle( lgbr, intersect );
483                                 }
484                         }
485                 }
486                 
487                 protected override void ScrollBar_Vertical_Draw_ThumbMoving_Forward( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
488                 {
489                         Rectangle r = new Rectangle( 0,  scrollbutton_height,
490                                                     bar.ClientRectangle.Width, thumb_pos.Y  - scrollbutton_height );
491                         Rectangle intersect = Rectangle.Intersect( clip, r );
492                         
493                         using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
494                         {
495                                 if ( intersect != Rectangle.Empty )
496                                         dc.FillRectangle( lgbr, intersect );
497                                 
498                                 r.X = 0;
499                                 r.Y = thumb_pos.Y + thumb_pos.Height;
500                                 r.Width = bar.ClientRectangle.Width;
501                                 r.Height = bar.ClientRectangle.Height -  ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
502                                 
503                                 intersect = Rectangle.Intersect( clip, r );
504                                 if ( intersect != Rectangle.Empty )
505                                         dc.FillRectangle( lgbr, intersect );
506                         }
507                 }
508                 
509                 protected override void ScrollBar_Vertical_Draw_ThumbMoving_Backwards( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
510                 {
511                         Rectangle r = new Rectangle( 0,  scrollbutton_height,
512                                                     bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
513                         Rectangle intersect = Rectangle.Intersect( clip, r );
514                         
515                         using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
516                         {
517                                 if ( intersect != Rectangle.Empty )
518                                         dc.FillRectangle( lgbr, intersect );
519                                 
520                                 r.X = 0;
521                                 r.Y = thumb_pos.Y + thumb_pos.Height;
522                                 r.Width = bar.ClientRectangle.Width;
523                                 r.Height = bar.ClientRectangle.Height -  ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
524                                 
525                                 intersect = Rectangle.Intersect( clip, r );
526                                 if ( intersect != Rectangle.Empty )
527                                         dc.FillRectangle( lgbr, intersect );
528                         }
529                 }
530                 
531                 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc )
532                 {
533                         Rectangle r = new Rectangle( scrollbutton_width,
534                                                     0, bar.ClientRectangle.Width - ( scrollbutton_width * 2 ), bar.ClientRectangle.Height );
535                         Rectangle intersect = Rectangle.Intersect( clip, r );
536                         
537                         if ( intersect != Rectangle.Empty )
538                         {
539                                 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
540                                 {
541                                         dc.FillRectangle( lgbr, intersect );
542                                 }
543                         }
544                 }
545                 
546                 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
547                 {
548                         Rectangle r = new Rectangle( scrollbutton_width,  0,
549                                                     thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
550                         Rectangle intersect = Rectangle.Intersect( clip, r );
551                         
552                         using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
553                         {
554                                 if ( intersect != Rectangle.Empty )
555                                         dc.FillRectangle( lgbr, intersect );
556                                 
557                                 r.X = thumb_pos.X + thumb_pos.Width;
558                                 r.Y = 0;
559                                 r.Width = bar.ClientRectangle.Width -  ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
560                                 r.Height = bar.ClientRectangle.Height;
561                                 
562                                 intersect = Rectangle.Intersect( clip, r );
563                                 if ( intersect != Rectangle.Empty )
564                                         dc.FillRectangle( lgbr, intersect );
565                         }
566                 }
567                 
568                 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
569                 {
570                         Rectangle r = new Rectangle( scrollbutton_width,  0,
571                                                     thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
572                         Rectangle intersect = Rectangle.Intersect( clip, r );
573                         
574                         using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
575                         {
576                                 if ( intersect != Rectangle.Empty )
577                                         dc.FillRectangle( lgbr, intersect );
578                                 
579                                 r.X = thumb_pos.X + thumb_pos.Width;
580                                 r.Y = 0;
581                                 r.Width = bar.ClientRectangle.Width -  ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
582                                 r.Height = bar.ClientRectangle.Height;
583                                 
584                                 intersect = Rectangle.Intersect( clip, r );
585                                 if ( intersect != Rectangle.Empty )
586                                         dc.FillRectangle( lgbr, intersect );
587                         }
588                 }
589                 #endregion      // ScrollBar
590                 
591                 #region StatusBar
592                 protected override void DrawStatusBarPanel( Graphics dc, Rectangle area, int index,
593                                                            SolidBrush br_forecolor, StatusBarPanel panel )
594                 {
595                         int border_size = 3; // this is actually const, even if the border style is none
596                         
597                         area.Height -= border_size;
598                         if ( panel.BorderStyle != StatusBarPanelBorderStyle.None )
599                         {
600                                 DrawNiceRoundedBorder( dc, area, BorderColor );
601                         }
602                         
603                         if ( panel.Style == StatusBarPanelStyle.OwnerDraw )
604                         {
605                                 StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs(
606                                         dc, panel.Parent.Font, area, index, DrawItemState.Default,
607                                         panel, panel.Parent.ForeColor, panel.Parent.BackColor );
608                                 panel.Parent.OnDrawItemInternal( e );
609                                 return;
610                         }
611                         
612                         int left = area.Left;
613                         if ( panel.Icon != null )
614                         {
615                                 left += 2;
616                                 dc.DrawIcon( panel.Icon, left, area.Top );
617                                 left += panel.Icon.Width;
618                         }
619                         
620                         if ( panel.Text == String.Empty )
621                                 return;
622                         
623                         string text = panel.Text;
624                         StringFormat string_format = new StringFormat( );
625                         string_format.Trimming = StringTrimming.Character;
626                         string_format.FormatFlags = StringFormatFlags.NoWrap;
627                         
628                         if ( text[ 0 ] == '\t' )
629                         {
630                                 string_format.Alignment = StringAlignment.Center;
631                                 text = text.Substring( 1 );
632                                 if ( text[ 0 ] == '\t' )
633                                 {
634                                         string_format.Alignment = StringAlignment.Far;
635                                         text = text.Substring( 1 );
636                                 }
637                         }
638                         
639                         int x = left + border_size;
640                         int y = border_size + 2;
641                         Rectangle r = new Rectangle( x, y,
642                                                     area.Right - x - border_size,
643                                                     area.Bottom - y - border_size );
644                         
645                         dc.DrawString( text, panel.Parent.Font, br_forecolor, r, string_format );
646                 }
647                 
648                 private void DrawNiceRoundedBorder( Graphics dc, Rectangle area, Color color )
649                 {
650                         Pen pen = ResPool.GetPen( color ); 
651                         
652                         Point[] points = new Point[] {
653                                 new Point( area.Left + 2, area.Top ),
654                                 new Point( area.Right - 2, area.Top ),
655                                 new Point( area.Right, area.Top + 2 ),
656                                 new Point( area.Right, area.Bottom - 2 ),
657                                 new Point( area.Right - 2, area.Bottom ),
658                                 new Point( area.Left + 2, area.Bottom ),
659                                 new Point( area.Left, area.Bottom - 2 ),
660                                 new Point( area.Left, area.Top + 2 ),
661                                 new Point( area.Left + 2, area.Top )
662                         };
663                         
664                         dc.DrawLines( pen, points );
665                 }
666                 #endregion      // StatusBar
667                 
668                 public override void DrawTabControl( Graphics dc, Rectangle area, TabControl tab )
669                 {
670                         // Do we need to fill the back color? It can't be changed...
671                         dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), area );
672                         Rectangle panel_rect = GetTabPanelRectExt( tab );
673                         
674                         if ( tab.Appearance == TabAppearance.Normal )
675                         {
676                                 CPDrawBorder( dc, panel_rect, BorderColor, 1, ButtonBorderStyle.Solid, BorderColor, 1, ButtonBorderStyle.Solid,
677                                              BorderColor, 1, ButtonBorderStyle.Solid, BorderColor, 1, ButtonBorderStyle.Solid );
678                         }
679                         
680                         if ( tab.Alignment == TabAlignment.Top )
681                         {
682                                 for ( int r = tab.TabPages.Count; r > 0; r-- )
683                                 {
684                                         for ( int i = tab.SliderPos; i < tab.TabPages.Count; i++ )
685                                         {
686                                                 if ( i == tab.SelectedIndex )
687                                                         continue;
688                                                 if ( r != tab.TabPages[ i ].Row )
689                                                         continue;
690                                                 Rectangle rect = tab.GetTabRect( i );
691                                                 if ( !rect.IntersectsWith( area ) )
692                                                         continue;
693                                                 DrawTab( dc, tab.TabPages[ i ], tab, rect, false );
694                                         }
695                                 }
696                         }
697                         else
698                         {
699                                 for ( int r = 0; r < tab.TabPages.Count; r++ )
700                                 {
701                                         for ( int i = tab.SliderPos; i < tab.TabPages.Count; i++ )
702                                         {
703                                                 if ( i == tab.SelectedIndex )
704                                                         continue;
705                                                 if ( r != tab.TabPages[ i ].Row )
706                                                         continue;
707                                                 Rectangle rect = tab.GetTabRect( i );
708                                                 if ( !rect.IntersectsWith( area ) )
709                                                         continue;
710                                                 DrawTab( dc, tab.TabPages[ i ], tab, rect, false );
711                                         }
712                                 }
713                         }
714                         
715                         if ( tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos )
716                         {
717                                 Rectangle rect = tab.GetTabRect( tab.SelectedIndex );
718                                 if ( rect.IntersectsWith( area ) )
719                                         DrawTab( dc, tab.TabPages[ tab.SelectedIndex ], tab, rect, true );
720                         }
721                         
722                         if ( tab.ShowSlider )
723                         {
724                                 Rectangle right = GetTabControlRightScrollRect( tab );
725                                 Rectangle left = GetTabControlLeftScrollRect( tab );
726                                 CPDrawScrollButton( dc, right, ScrollButton.Right, tab.RightSliderState );
727                                 CPDrawScrollButton( dc, left, ScrollButton.Left, tab.LeftSliderState );
728                         }
729                 }
730                 
731                 protected override int DrawTab( Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected )
732                 {
733                         int FlatButtonSpacing = 8;
734                         Rectangle interior;
735                         int res = bounds.Width;
736                         
737                         // we can't fill the background right away because the bounds might be adjusted if the tab is selected
738                         
739                         if ( tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons )
740                         {
741                                 dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), bounds );
742                                 
743                                 // Separators
744                                 if ( tab.Appearance == TabAppearance.FlatButtons )
745                                 {
746                                         int width = bounds.Width;
747                                         bounds.Width += ( FlatButtonSpacing - 2 );
748                                         res = bounds.Width;
749                                         CPDrawBorder3D( dc, bounds, Border3DStyle.Etched, Border3DSide.Right );
750                                         bounds.Width = width;
751                                 }
752                                 
753                                 if ( is_selected )
754                                 {
755                                         CPDrawBorder3D( dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
756                                 }
757                                 else if ( tab.Appearance != TabAppearance.FlatButtons )
758                                 {
759                                         CPDrawBorder3D( dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
760                                 }
761                                 
762                                 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4 );
763                                 
764                                 
765                                 StringFormat string_format = new StringFormat( );
766                                 string_format.Alignment = StringAlignment.Center;
767                                 string_format.LineAlignment = StringAlignment.Center;
768                                 string_format.FormatFlags = StringFormatFlags.NoWrap;
769                                 
770                                 interior.Y++;
771                                 dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
772                                 interior.Y--;
773                         }
774                         else
775                         {
776                                 Pen border_pen = ResPool.GetPen( BorderColor );
777                                 
778                                 dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), bounds );
779                                 
780                                 switch ( tab.Alignment )
781                                 {
782                                         case TabAlignment.Top:
783                                                 
784                                                 if ( !is_selected )
785                                                 {
786                                                         interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
787                                                         
788                                                         using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2  ), new Point( bounds.Left + 2, bounds.Bottom ), Color.White, LightColor ) )
789                                                         {
790                                                                 dc.FillRectangle( lgbr, interior );
791                                                         }
792                                                 }
793                                                 
794                                                 dc.DrawLine( border_pen, bounds.Left, bounds.Bottom, bounds.Left, bounds.Top + 3 );
795                                                 dc.DrawLine( border_pen, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top );
796                                                 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Top, bounds.Right - 3, bounds.Top );
797                                                 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3 );
798                                                 dc.DrawLine( border_pen, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom );
799                                                 
800                                                 if ( page.Focused )
801                                                 {
802                                                         dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left - 1 , bounds.Top, bounds.Right - 1, bounds.Top );
803                                                         dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Top + 1, bounds.Right , bounds.Top + 1 );
804                                                         dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Top + 2, bounds.Right , bounds.Top + 2 );
805                                                 }
806                                                 
807                                                 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
808                                                 
809                                                 if ( page.Text != String.Empty )
810                                                 {
811                                                         StringFormat string_format = new StringFormat( );
812                                                         string_format.Alignment = StringAlignment.Center;
813                                                         string_format.LineAlignment = StringAlignment.Center;
814                                                         string_format.FormatFlags = StringFormatFlags.NoWrap;
815                                                         interior.Y++;
816                                                         dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
817                                                         interior.Y--;
818                                                 }
819                                                 
820                                                 break;
821                                                 
822                                         case TabAlignment.Bottom:
823                                                 
824                                                 if ( !is_selected )
825                                                 {
826                                                         interior = new Rectangle( bounds.Left + 3, bounds.Top, bounds.Width - 3, bounds.Height );
827                                                         
828                                                         using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 3, bounds.Top  ), new Point( bounds.Left + 3, bounds.Bottom  ), Color.White, LightColor ) )
829                                                         {
830                                                                 dc.FillRectangle( lgbr, interior );
831                                                         }
832                                                 }
833                                                 
834                                                 dc.DrawLine( border_pen, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 3 );
835                                                 dc.DrawLine( border_pen, bounds.Left, bounds.Bottom - 3, bounds.Left + 3, bounds.Bottom );
836                                                 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom );
837                                                 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Bottom, bounds.Right, bounds.Bottom - 3 );
838                                                 dc.DrawLine( border_pen, bounds.Right, bounds.Bottom - 3, bounds.Right, bounds.Top );
839                                                 
840                                                 if ( page.Focused )
841                                                 {
842                                                         dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left - 1 , bounds.Bottom, bounds.Right - 1, bounds.Bottom );
843                                                         dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Bottom - 1, bounds.Right , bounds.Bottom - 1 );
844                                                         dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Bottom - 2, bounds.Right , bounds.Bottom - 2 );
845                                                 }
846                                                 
847                                                 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
848                                                 
849                                                 if ( page.Text != String.Empty )
850                                                 {
851                                                         StringFormat string_format = new StringFormat( );
852                                                         string_format.Alignment = StringAlignment.Center;
853                                                         string_format.LineAlignment = StringAlignment.Center;
854                                                         string_format.FormatFlags = StringFormatFlags.NoWrap;
855                                                         interior.Y++;
856                                                         dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
857                                                         interior.Y--;
858                                                 }
859                                                 
860                                                 break;
861                                                 
862                                         case TabAlignment.Left:
863                                                 
864                                                 if ( !is_selected )
865                                                 {
866                                                         interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
867                                                         
868                                                         using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2  ), new Point( bounds.Right, bounds.Top + 2 ), LightColor, Color.White ) )
869                                                         {
870                                                                 dc.FillRectangle( lgbr, interior );
871                                                         }
872                                                 }
873                                                 
874                                                 dc.DrawLine( border_pen, bounds.Right, bounds.Top, bounds.Left + 3, bounds.Top );
875                                                 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Top, bounds.Left, bounds.Top + 3 );
876                                                 dc.DrawLine( border_pen, bounds.Left, bounds.Top + 3, bounds.Left, bounds.Bottom - 3 );
877                                                 dc.DrawLine( border_pen, bounds.Left, bounds.Bottom - 3, bounds.Left + 3, bounds.Bottom );
878                                                 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Bottom, bounds.Right, bounds.Bottom );
879                                                 
880                                                 if ( page.Focused )
881                                                 {
882                                                         dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left , bounds.Top + 1, bounds.Left , bounds.Bottom - 1 );
883                                                         dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left + 1 , bounds.Top, bounds.Left + 1 , bounds.Bottom );
884                                                         dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left + 2 , bounds.Top, bounds.Left + 2 , bounds.Bottom );
885                                                 }
886                                                 
887                                                 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
888                                                 
889                                                 if ( page.Text != String.Empty )
890                                                 {
891                                                         StringFormat string_format = new StringFormat( );
892                                                         // Flip the text around
893                                                         string_format.Alignment = StringAlignment.Center;
894                                                         string_format.LineAlignment = StringAlignment.Center;
895                                                         string_format.FormatFlags = StringFormatFlags.NoWrap;
896                                                         string_format.FormatFlags = StringFormatFlags.DirectionVertical;
897                                                         int wo = interior.Width / 2;
898                                                         int ho = interior.Height / 2;
899                                                         dc.TranslateTransform( interior.X + wo, interior.Y + ho );
900                                                         dc.RotateTransform( 180 );
901                                                         dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), 0, 0, string_format );
902                                                         dc.ResetTransform( );
903                                                 }
904                                                 
905                                                 break;
906                                                 
907                                         default:
908                                                 // TabAlignment.Right
909                                                 
910                                                 if ( !is_selected )
911                                                 {
912                                                         interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
913                                                         
914                                                         using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2  ), new Point( bounds.Right, bounds.Top + 2 ), Color.White, LightColor ) )
915                                                         {
916                                                                 dc.FillRectangle( lgbr, interior );
917                                                         }
918                                                 }
919                                                 
920                                                 dc.DrawLine( border_pen, bounds.Left, bounds.Top, bounds.Right - 3, bounds.Top );
921                                                 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3 );
922                                                 dc.DrawLine( border_pen, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom - 3 );
923                                                 dc.DrawLine( border_pen, bounds.Right, bounds.Bottom - 3, bounds.Right - 3, bounds.Bottom );
924                                                 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Bottom, bounds.Left, bounds.Bottom );
925                                                 
926                                                 if ( page.Focused )
927                                                 {
928                                                         dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Right , bounds.Top + 1, bounds.Right , bounds.Bottom - 1 );
929                                                         dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Right - 1 , bounds.Top, bounds.Right - 1 , bounds.Bottom );
930                                                         dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Right - 2 , bounds.Top, bounds.Right - 2 , bounds.Bottom );
931                                                 }
932                                                 
933                                                 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
934                                                 
935                                                 if ( page.Text != String.Empty )
936                                                 {
937                                                         StringFormat string_format = new StringFormat( );
938                                                         string_format.Alignment = StringAlignment.Center;
939                                                         string_format.LineAlignment = StringAlignment.Center;
940                                                         string_format.FormatFlags = StringFormatFlags.NoWrap;
941                                                         string_format.FormatFlags = StringFormatFlags.DirectionVertical;
942                                                         interior.X++;
943                                                         dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
944                                                         interior.X--;
945                                                 }
946                                                 
947                                                 break;
948                                 }
949                         }
950                         
951                         return res;
952                 }
953                 
954 //              public override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) {
955 //                      CPDrawBorder3D(graphics, rectangle, style, sides, ColorControl);
956 //              }
957                 
958                 protected override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color)
959                 {
960                         Pen             penTopLeft;
961                         Pen             penTopLeftInner;
962                         Pen             penBottomRight;
963                         Pen             penBottomRightInner;
964                         Rectangle       rect= new Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
965                         
966                         if ((style & Border3DStyle.Adjust) != 0) {
967                                 rect.Y -= 2;
968                                 rect.X -= 2;
969                                 rect.Width += 4;
970                                 rect.Height += 4;
971                         }
972                         
973                         penTopLeft = penTopLeftInner = penBottomRight = penBottomRightInner = ResPool.GetPen (control_color);
974                         
975                         CPColor cpcolor = ResPool.GetCPColor (control_color);
976                         
977                         switch (style) {
978                         case Border3DStyle.Raised:
979                                 penTopLeftInner = ResPool.GetPen (cpcolor.LightLight);
980                                 penBottomRight = ResPool.GetPen (cpcolor.Dark);
981                                 penBottomRightInner = ResPool.GetPen (BorderColor);
982                                 break;
983                         case Border3DStyle.Sunken:
984                                 penTopLeft = ResPool.GetPen (BorderColor);
985                                 penTopLeftInner = ResPool.GetPen (cpcolor.Dark);
986                                 penBottomRight = ResPool.GetPen (cpcolor.LightLight);
987                                 break;
988                         case Border3DStyle.Etched:
989                                 penTopLeft = penBottomRightInner = ResPool.GetPen (BorderColor);
990                                 penTopLeftInner = penBottomRight = ResPool.GetPen (cpcolor.LightLight);
991                                 break;
992                         case Border3DStyle.RaisedOuter:
993                                 penBottomRight = ResPool.GetPen (cpcolor.Dark);
994                                 break;
995                         case Border3DStyle.SunkenOuter:
996                                 penTopLeft = ResPool.GetPen (BorderColor);
997                                 penBottomRight = ResPool.GetPen (cpcolor.LightLight);
998                                 break;
999                         case Border3DStyle.RaisedInner:
1000                                 penTopLeft = ResPool.GetPen (cpcolor.LightLight);
1001                                 penBottomRight = ResPool.GetPen (BorderColor);
1002                                 break;
1003                         case Border3DStyle.SunkenInner:
1004                                 penTopLeft = ResPool.GetPen (cpcolor.Dark);
1005                                 break;
1006                         case Border3DStyle.Flat:
1007                                 penTopLeft = penBottomRight = ResPool.GetPen (BorderColor);
1008                                 break;
1009                         case Border3DStyle.Bump:
1010                                 penTopLeftInner = penBottomRight = ResPool.GetPen (cpcolor.Dark);
1011                                 break;
1012                         default:
1013                                 break;
1014                         }
1015                         
1016                         if ((sides & Border3DSide.Middle) != 0) {
1017                                 graphics.FillRectangle (ResPool.GetSolidBrush (control_color), rect);
1018                         }
1019                         
1020                         if ((sides & Border3DSide.Left) != 0) {
1021                                 graphics.DrawLine (penTopLeft, rect.Left, rect.Bottom - 2, rect.Left, rect.Top);
1022                                 graphics.DrawLine (penTopLeftInner, rect.Left + 1, rect.Bottom - 2, rect.Left + 1, rect.Top);
1023                         }
1024                         
1025                         if ((sides & Border3DSide.Top) != 0) {
1026                                 graphics.DrawLine (penTopLeft, rect.Left, rect.Top, rect.Right - 2, rect.Top);
1027                                 graphics.DrawLine (penTopLeftInner, rect.Left + 1, rect.Top + 1, rect.Right - 3, rect.Top + 1);
1028                         }
1029                         
1030                         if ((sides & Border3DSide.Right) != 0) {
1031                                 graphics.DrawLine (penBottomRight, rect.Right - 1, rect.Top, rect.Right - 1, rect.Bottom - 1);
1032                                 graphics.DrawLine (penBottomRightInner, rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 2);
1033                         }
1034                         
1035                         if ((sides & Border3DSide.Bottom) != 0) {
1036                                 graphics.DrawLine (penBottomRight, rect.Left, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
1037                                 graphics.DrawLine (penBottomRightInner, rect.Left + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2);
1038                         }
1039                 }
1040                 
1041                 public override void CPDrawComboButton( Graphics dc, Rectangle rectangle, ButtonState state )
1042                 {
1043                         Point[]                 arrow = new Point[ 3 ];
1044                         Point                           P1;
1045                         Point                           P2;
1046                         Point                           P3;
1047                         int                             centerX;
1048                         int                             centerY;
1049                         int                             shiftX;
1050                         int                             shiftY;
1051                         Rectangle               rect;
1052                         
1053                         Color first_color = Color.White;
1054                         Color second_color = NormalColor;
1055                         
1056 //                      rectangle.Width += 1;
1057                         
1058                         if ( ( state & ButtonState.Checked ) != 0 )
1059                         {
1060                                 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControlLightLight, ColorControlLight ), rectangle );
1061                         }
1062                         else
1063                                 dc.FillRectangle( ResPool.GetSolidBrush( Color.White ), rectangle );
1064                         
1065                         if ( ( state & ButtonState.Flat ) != 0 )
1066                         {
1067                                 first_color = NormalColor;
1068                                 second_color = Color.White;
1069                         }
1070                         else
1071                         {
1072                                 if ( ( state & ( ButtonState.Pushed | ButtonState.Checked ) ) != 0 )
1073                                 {
1074                                         first_color = Color.White;
1075                                         second_color = PressedColor;
1076                                 }
1077 //                              else
1078 //                              {
1079 //                                      CPDrawBorder3D( graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl );
1080 //                              }
1081                         }
1082                         
1083                         using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( rectangle.X + 1, rectangle.Y + 1 ), new Point( rectangle.X + 1, rectangle.Bottom - 2 ), first_color, second_color ) )
1084                         {
1085                                 dc.FillRectangle( lgbr, rectangle.X + 2, rectangle.Y + 1, rectangle.Width - 4, rectangle.Height - 3 );
1086                         }
1087                         
1088                         Point[] points = new Point[] {
1089                                 new Point( rectangle.X + 3, rectangle.Y + 1 ),
1090                                 new Point( rectangle.Right - 4, rectangle.Y + 1 ),
1091                                 new Point( rectangle.Right - 2, rectangle.Y + 3 ),
1092                                 new Point( rectangle.Right - 2, rectangle.Bottom - 4 ),
1093                                 new Point( rectangle.Right - 4, rectangle.Bottom - 2 ),
1094                                 new Point( rectangle.X + 3, rectangle.Bottom - 2 ),
1095                                 new Point( rectangle.X + 1, rectangle.Bottom - 4 ),
1096                                 new Point( rectangle.X + 1, rectangle.Y + 3 ),
1097                                 new Point( rectangle.X + 3, rectangle.Y + 1 )
1098                         };
1099                         
1100                         dc.DrawPolygon( ResPool.GetPen( BorderColor ), points );
1101                         
1102                         rect = new Rectangle( rectangle.X + rectangle.Width / 4, rectangle.Y + rectangle.Height / 4, rectangle.Width / 2, rectangle.Height / 2 );
1103                         centerX = rect.Left + rect.Width / 2;
1104                         centerY = rect.Top + rect.Height / 2;
1105                         shiftX = Math.Max( 1, rect.Width / 8 );
1106                         shiftY = Math.Max( 1, rect.Height / 8 );
1107                         
1108                         if ( ( state & ButtonState.Pushed ) != 0 )
1109                         {
1110                                 shiftX--;
1111                                 shiftY--;
1112                         }
1113                         
1114                         rect.Y -= shiftY;
1115                         centerY -= shiftY;
1116                         
1117                         P1 = new Point( rect.Left, centerY );
1118                         P2 = new Point( centerX, rect.Bottom );
1119                         P3 = new Point( rect.Right, centerY );
1120                         
1121                         arrow[ 0 ] = P1;
1122                         arrow[ 1 ] = P2;
1123                         arrow[ 2 ] = P3;
1124                         
1125                         SmoothingMode old_smoothing_mode = dc.SmoothingMode;
1126                         dc.SmoothingMode = SmoothingMode.AntiAlias;
1127                         
1128                         /* Draw the arrow */
1129                         if ( ( state & ButtonState.Inactive ) != 0 )
1130                         {
1131                                 using ( Pen pen = new Pen( SystemColors.ControlLightLight, 2 ) )
1132                                 {
1133                                         dc.DrawLines( pen, arrow );
1134                                 }
1135                                 
1136                                 /* Move away from the shadow */
1137                                 P1.X -= 1;              P1.Y -= 1;
1138                                 P2.X -= 1;              P2.Y -= 1;
1139                                 P3.X -= 1;              P3.Y -= 1;
1140                                 
1141                                 arrow[ 0 ] = P1;
1142                                 arrow[ 1 ] = P2;
1143                                 arrow[ 2 ] = P3;
1144                                 
1145                                 using ( Pen pen = new Pen( SystemColors.ControlDark, 2 ) )
1146                                 {
1147                                         dc.DrawLines( pen, arrow );
1148                                 }
1149                         }
1150                         else
1151                         {
1152                                 using ( Pen pen = new Pen( SystemColors.ControlText, 2 ) )
1153                                 {
1154                                         dc.DrawLines( pen, arrow );
1155                                 }
1156                         }
1157                         
1158                         dc.SmoothingMode = old_smoothing_mode;
1159                 }
1160                 
1161                 /* Scroll button: regular button + direction arrow */
1162                 public override void CPDrawScrollButton( Graphics dc, Rectangle area, ScrollButton scroll_button_type, ButtonState state )
1163                 {
1164                         bool enabled = ( state == ButtonState.Inactive ) ? false: true;
1165                         
1166                         DrawScrollButtonPrimitive( dc, area, state, scroll_button_type );
1167                         
1168                         Pen pen = null;
1169                         
1170                         if ( enabled )
1171                                 pen = new Pen( arrow_color, 2 );
1172                         else
1173                                 pen = new Pen( ColorGrayText, 2 );
1174                         
1175                         /* Paint arrows */
1176                         
1177                         int centerX = area.Left + area.Width / 2;
1178                         int centerY = area.Top + area.Height / 2;
1179                         
1180                         int shift = 0;
1181                         
1182                         if ( ( state & ButtonState.Pushed ) != 0 )
1183                                 shift = 1;
1184                         
1185                         int min_3 = 3;
1186                         int min_2 = 2;
1187                         if ( area.Width < 12 || area.Height < 12 ) {
1188                                 min_3 = 2;
1189                                 min_2 = 1;
1190                         }
1191                         
1192                         Point[] arrow = new Point [3];
1193                         
1194                         switch (scroll_button_type) {
1195                         case ScrollButton.Down:
1196                                 centerY += shift;
1197                                 arrow [0] = new Point (centerX - min_3, centerY - min_2);
1198                                 arrow [1] = new Point (centerX, centerY + min_2);
1199                                 arrow [2] = new Point (centerX + min_3, centerY - min_2);
1200                                 break;
1201                         case ScrollButton.Up:
1202                                 centerY -= shift;
1203                                 arrow [0] = new Point (centerX - min_3, centerY + min_2);
1204                                 arrow [1] = new Point (centerX, centerY - min_2);
1205                                 arrow [2] = new Point (centerX + min_3, centerY + min_2);
1206                                 break;
1207                         case ScrollButton.Left:
1208                                 centerX -= shift;
1209                                 arrow [0] = new Point (centerX + min_2, centerY - min_3);
1210                                 arrow [1] = new Point (centerX - min_2, centerY);
1211                                 arrow [2] = new Point (centerX + min_2, centerY + min_3);
1212                                 break;
1213                         case ScrollButton.Right:
1214                                 centerX += shift;
1215                                 arrow [0] = new Point (centerX - min_2, centerY - min_3);
1216                                 arrow [1] = new Point (centerX + min_2, centerY);
1217                                 arrow [2] = new Point (centerX - min_2, centerY + min_3);
1218                                 break;
1219                         default:
1220                                 break;
1221                         }
1222
1223                         SmoothingMode old_smoothing_mode = dc.SmoothingMode;
1224                         dc.SmoothingMode = SmoothingMode.AntiAlias;
1225                         
1226                         dc.DrawLines (pen, arrow);
1227                         
1228                         dc.SmoothingMode = old_smoothing_mode;
1229                         
1230                         pen.Dispose ();
1231                 }
1232                 
1233                 public override void CPDrawSizeGrip( Graphics dc, Color backColor, Rectangle bounds )
1234                 {
1235                         Point pt = new Point( bounds.Right - 4, bounds.Bottom - 4 );
1236                         
1237                         dc.DrawImage( size_grip_bmp, pt );
1238                         dc.DrawImage( size_grip_bmp, pt.X, pt.Y - 5 );
1239                         dc.DrawImage( size_grip_bmp, pt.X, pt.Y - 10 );
1240                         dc.DrawImage( size_grip_bmp, pt.X - 5, pt.Y );
1241                         dc.DrawImage( size_grip_bmp, pt.X - 10, pt.Y );
1242                         dc.DrawImage( size_grip_bmp, pt.X - 5, pt.Y - 5 );
1243                 }
1244                 
1245                 private void DrawScrollBarThumb( Graphics dc, Rectangle area, ScrollBar bar )
1246                 {
1247                         LinearGradientBrush lgbr = null;
1248                         
1249                         if ( bar.vert )
1250                                 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right, area.Y ), Color.White, NormalColor );
1251                         else
1252                                 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom ), Color.White, NormalColor );
1253                         
1254                         Pen pen = ResPool.GetPen( BorderColor );
1255                         
1256                         Point[] points = new Point[] {
1257                                 new Point( area.X + 2, area.Y ),
1258                                 new Point( area.Right - 3, area.Y ),
1259                                 new Point( area.Right - 1, area.Y + 2 ),
1260                                 new Point( area.Right - 1, area.Bottom - 3 ),
1261                                 new Point( area.Right - 3, area.Bottom - 1 ),
1262                                 new Point( area.X + 2, area.Bottom - 1 ),
1263                                 new Point( area.X, area.Bottom - 3 ),
1264                                 new Point( area.X, area.Y + 2 ),
1265                                 new Point( area.X + 2, area.Y )
1266                         };
1267                         
1268                         if ( bar.vert )
1269                         {
1270                                 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1271                                 dc.DrawPolygon( pen, points );
1272                                 
1273                                 // draw grip lines only if stere is enough space
1274                                 if ( area.Height > 20 )
1275                                 {
1276                                         int mid_y = area.Y + ( area.Height / 2 );
1277                                         int mid_x = area.X + ( area.Width / 2 );
1278                                         
1279                                         using ( Pen lpen = new Pen( MouseOverColor, 2 ) )
1280                                         {
1281                                                 dc.DrawLine( lpen, mid_x - 3, mid_y, mid_x + 3, mid_y );
1282                                                 dc.DrawLine( lpen, mid_x - 3, mid_y - 4, mid_x + 3, mid_y - 4 );
1283                                                 dc.DrawLine( lpen, mid_x - 3, mid_y + 4, mid_x + 3, mid_y + 4 );
1284                                         }
1285                                         
1286                                         Pen spen = ResPool.GetPen( Color.White );
1287                                         dc.DrawLine( spen, mid_x - 3, mid_y - 1, mid_x + 3, mid_y - 1 );
1288                                         dc.DrawLine( spen, mid_x - 3, mid_y - 5, mid_x + 3, mid_y - 5 );
1289                                         dc.DrawLine( spen, mid_x - 3, mid_y + 3, mid_x + 3, mid_y + 3 );
1290                                 }
1291                         }
1292                         else
1293                         {
1294                                 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1295                                 dc.DrawPolygon( pen, points );
1296                                 
1297                                 // draw grip lines only if stere is enough space
1298                                 if ( area.Width > 20 )
1299                                 {
1300                                         int mid_x = area.X +  ( area.Width / 2 );
1301                                         int mid_y = area.Y +  ( area.Height / 2 );
1302                                         
1303                                         using ( Pen lpen = new Pen( MouseOverColor, 2 ) )
1304                                         {
1305                                                 dc.DrawLine( lpen, mid_x, mid_y - 3, mid_x, mid_y + 3 );
1306                                                 dc.DrawLine( lpen, mid_x - 4, mid_y - 3, mid_x - 4, mid_y + 3 );
1307                                                 dc.DrawLine( lpen, mid_x + 4, mid_y - 3, mid_x + 4, mid_y + 3 );
1308                                         }
1309                                         
1310                                         Pen spen = ResPool.GetPen( Color.White );
1311                                         dc.DrawLine( spen, mid_x - 1, mid_y - 3, mid_x - 1, mid_y + 3 );
1312                                         dc.DrawLine( spen, mid_x - 5, mid_y - 3, mid_x - 5, mid_y + 3 );
1313                                         dc.DrawLine( spen, mid_x + 3, mid_y - 3, mid_x + 3, mid_y + 3 );
1314                                 }
1315                         }
1316                         
1317                         lgbr.Dispose( );
1318                 }
1319                 
1320                 /* Nice scroll button */
1321                 public void DrawScrollButtonPrimitive( Graphics dc, Rectangle area, ButtonState state, ScrollButton scroll_button_type )
1322                 {
1323                         Pen pen = ResPool.GetPen( BorderColor );
1324                         
1325                         dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), area );
1326                         
1327                         Color use_color;
1328                         
1329                         if ( ( state & ButtonState.Pushed ) == ButtonState.Pushed )
1330                                 use_color = PressedColor;
1331                         else
1332                                 use_color = NormalColor;
1333                         
1334                         Point[] points = null;
1335                         
1336                         LinearGradientBrush lgbr = null;
1337                         
1338                         switch ( scroll_button_type )
1339                         {
1340                                 case ScrollButton.Left:
1341                                         lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 2, area.Y ), use_color, Color.White );
1342                                         dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 4, area.Height - 2 );
1343                                         
1344                                         points = new Point[] {
1345                                                 new Point( area.X + 2, area.Y ),
1346                                                 new Point( area.Right - 1, area.Y ),
1347                                                 new Point( area.Right - 1, area.Bottom - 1 ),
1348                                                 new Point( area.X + 2, area.Bottom - 1 ),
1349                                                 new Point( area.X, area.Bottom - 3 ),
1350                                                 new Point( area.X, area.Y + 2 ),
1351                                                 new Point( area.X + 2, area.Y )
1352                                         };
1353                                         dc.DrawPolygon( pen, points );
1354                                         break;
1355                                 case ScrollButton.Right:
1356                                         lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 1, area.Y ), Color.White, use_color );
1357                                         dc.FillRectangle( lgbr, area.X, area.Y + 1, area.Width - 1, area.Height - 2 );
1358                                         
1359                                         points = new Point[] {
1360                                                 new Point( area.X, area.Y ),
1361                                                 new Point( area.Right - 3, area.Y ),
1362                                                 new Point( area.Right - 1, area.Y + 2 ),
1363                                                 new Point( area.Right - 1, area.Bottom - 3 ),
1364                                                 new Point( area.Right - 3, area.Bottom - 1 ),
1365                                                 new Point( area.X, area.Bottom - 1 ),
1366                                                 new Point( area.X, area.Y ),
1367                                         };
1368                                         dc.DrawPolygon( pen, points );
1369                                         break;
1370                                 case ScrollButton.Up:
1371                                         lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), use_color, Color.White );
1372                                         dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1373                                         
1374                                         points = new Point[] {
1375                                                 new Point( area.X + 2, area.Y ),
1376                                                 new Point( area.Right - 3, area.Y ),
1377                                                 new Point( area.Right - 1, area.Y + 2 ),
1378                                                 new Point( area.Right - 1, area.Bottom - 1 ),
1379                                                 new Point( area.X, area.Bottom - 1 ),
1380                                                 new Point( area.X, area.Y + 2 ),
1381                                                 new Point( area.X + 2, area.Y )
1382                                         };
1383                                         dc.DrawPolygon( pen, points );
1384                                         break;
1385                                 case ScrollButton.Down:
1386                                         lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), Color.White, use_color );
1387                                         dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1388                                         
1389                                         points = new Point[] {
1390                                                 new Point( area.X, area.Y ),
1391                                                 new Point( area.Right - 1, area.Y ),
1392                                                 new Point( area.Right - 1, area.Bottom - 3 ),
1393                                                 new Point( area.Right - 3, area.Bottom - 1 ),
1394                                                 new Point( area.X + 2, area.Bottom - 1 ),
1395                                                 new Point( area.X, area.Bottom - 3 ),
1396                                                 new Point( area.X, area.Y )
1397                                         };
1398                                         dc.DrawPolygon( pen, points );
1399                                         break;
1400                         }
1401                         
1402                         lgbr.Dispose( );
1403                 }
1404                 
1405                 #region GroupBox
1406                 public override void DrawGroupBox (Graphics dc,  Rectangle area, GroupBox box) 
1407                 {
1408                         StringFormat    text_format;
1409                         SizeF           size;
1410                         int             width;
1411                         int             y;
1412                         Rectangle       rect;
1413                         
1414                         rect = box.ClientRectangle;
1415                         
1416                         dc.FillRectangle (ResPool.GetSolidBrush (box.BackColor), rect);
1417                         
1418                         text_format = new StringFormat();
1419                         text_format.HotkeyPrefix = HotkeyPrefix.Show;
1420                         
1421                         size = dc.MeasureString (box.Text, box.Font);
1422                         width = (int) size.Width;
1423                         
1424                         if (width > box.Width - 16)
1425                                 width = box.Width - 16;
1426                         
1427                         y = box.Font.Height / 2;
1428                         
1429                         Pen pen = ResPool.GetPen( BorderColor );
1430                         
1431                         /* Draw group box*/
1432                         Point[] points = new Point[] {
1433                                 new Point( 8 + width, y ),
1434                                 new Point( box.Width - 3, y ),
1435                                 new Point( box.Width - 1, y + 2 ),
1436                                 new Point( box.Width - 1, box.Height - 3 ),
1437                                 new Point( box.Width - 3, box.Height - 1 ),
1438                                 new Point( 2, box.Height - 1 ),
1439                                 new Point( 0, box.Height - 3 ),
1440                                 new Point( 0, y + 2 ),
1441                                 new Point( 2, y ),
1442                                 new Point( 8, y )
1443                         };
1444                         dc.DrawLines( pen, points );
1445                         
1446                         /* Text */
1447                         if (box.Enabled) {
1448                                 dc.DrawString (box.Text, box.Font, ResPool.GetSolidBrush (box.ForeColor), 10, 0, text_format);
1449                         } else {
1450                                 CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor, 
1451                                                       new RectangleF (10, 0, width,  box.Font.Height), text_format);
1452                         }
1453                         text_format.Dispose (); 
1454                 }
1455                 #endregion
1456         } //class
1457 }
1458