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:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
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.
20 // Copyright (c) 2004-2005 Novell, Inc.
23 // Alexander Olk, xenomorph2@onlinehome.de
25 // based on ThemeWin32Classic
27 // - You can activate this Theme with export MONO_THEME=nice
31 using System.Drawing.Drawing2D;
32 using System.Drawing.Imaging;
33 using System.Drawing.Text;
35 namespace System.Windows.Forms
37 internal class ThemeNice : ThemeWin32Classic
39 public override Version Version
42 return new Version( 0, 0, 0, 2 );
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 LightColor = Color.LightGray;
51 static readonly Color BorderColor = MouseOverColor;
52 static readonly Color NiceBackColor = Color.FromArgb( System.Convert.ToInt32( "0xffefebe7", 16 ) );
54 static Bitmap size_grip_bmp = CreateSizegripDot();
56 #region Principal Theme Methods
59 ColorControl = NiceBackColor;
60 always_draw_hotkeys = true;
63 public override Color DefaultControlBackColor
65 get { return NiceBackColor; }
68 public override Color DefaultWindowBackColor
70 get { return NiceBackColor; }
73 public override Color ColorControl {
74 get { return NiceBackColor;}
77 static Bitmap CreateSizegripDot()
79 Bitmap bmp = new Bitmap( 4, 4 );
80 using ( Graphics dc = Graphics.FromImage( bmp ) )
82 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
83 dc.SmoothingMode = SmoothingMode.AntiAlias;
85 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 4, 4 ), PressedColor, Color.White ) )
86 dc.FillEllipse( lgbr, new Rectangle( 0, 0, 4, 4 ) );
88 dc.SmoothingMode = old_smoothing_mode;
93 #endregion // Internal Methods
96 protected override void ButtonBase_DrawButton( ButtonBase button, Graphics dc )
98 Rectangle buttonRectangle;
100 int width = button.ClientSize.Width;
101 int height = button.ClientSize.Height;
103 dc.FillRectangle( ResPool.GetSolidBrush( button.BackColor ), button.ClientRectangle );
105 // set up the button rectangle
106 buttonRectangle = button.ClientRectangle;
109 Color first_color = button.has_focus ? Color.LightYellow : Color.White;
111 if ( ( ( button is CheckBox ) && ( ( (CheckBox)button ).check_state == CheckState.Checked ) ) ||
112 ( ( button is RadioButton ) && ( ( (RadioButton)button ).check_state == CheckState.Checked ) ) )
114 use_color = PressedColor;
117 if ( !button.is_enabled )
119 use_color = NormalColor;
120 button.is_entered = false;
123 if ( !button.is_entered )
125 use_color = NormalColor;
129 if ( !button.is_pressed )
130 use_color = MouseOverColor;
132 use_color = PressedColor;
135 // Fill button with a nice linear gradient brush
136 Rectangle lgbRectangle = Rectangle.Inflate( buttonRectangle, -1, -1 );
138 if ( button.flat_style != FlatStyle.Popup || ( ( button.flat_style == FlatStyle.Popup ) && button.is_entered ) )
140 LinearGradientBrush lgbr;
141 if ( button.flat_style == FlatStyle.Flat )
142 lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, height - 1 ), use_color, first_color );
144 lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, height - 1 ), first_color, use_color );
145 dc.FillRectangle( lgbr, lgbRectangle );
148 if ( button.has_focus )
151 Point[] points = new Point[] {
153 new Point( width - 3, 0 ),
154 new Point( width - 1, 2 ),
155 new Point( width - 1, height - 3 ),
156 new Point( width - 3, height - 1 ),
157 new Point( 2, height - 1 ),
158 new Point( 0, height - 3 ),
163 Pen pen = ResPool.GetPen( BorderColor );
164 dc.DrawLines( pen, points );
168 protected override void ButtonBase_DrawFocus( ButtonBase button, Graphics dc )
170 int width = button.ClientSize.Width;
171 int height = button.ClientSize.Height;
173 Point[] points = new Point[] {
175 new Point( width - 3, 0 ),
176 new Point( width - 1, 2 ),
177 new Point( width - 1, height - 3 ),
178 new Point( width - 3, height - 1 ),
179 new Point( 2, height - 1 ),
180 new Point( 0, height - 3 ),
185 Pen pen = ResPool.GetPen( FocusColor );
186 dc.DrawLines( pen, points );
189 protected override void ButtonBase_DrawText( ButtonBase button, Graphics dc )
191 if ( !( button is CheckBox ) && !(button is RadioButton ) )
193 base.ButtonBase_DrawText( button, dc );
196 #endregion // ButtonBase
199 protected override void CheckBox_DrawCheckBox( Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle )
201 dc.FillRectangle( ResPool.GetSolidBrush( checkbox.BackColor ), checkbox.ClientRectangle );
202 // render as per normal button
203 if ( checkbox.appearance == Appearance.Button )
205 DrawButtonBase( dc, checkbox.ClientRectangle, checkbox );
209 // establish if we are rendering a flat style of some sort
210 if ( checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup )
212 DrawFlatStyleCheckBox( dc, checkbox_rectangle, checkbox );
216 ControlPaint.DrawCheckBox( dc, checkbox_rectangle, state );
220 #endregion // CheckBox
226 public override void DrawComboBoxEditDecorations( Graphics dc, ComboBox ctrl, Rectangle cl )
230 dc.DrawLine (ResPool.GetPen (BorderColor), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top
231 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
232 dc.DrawLine (ResPool.GetPen (BorderColor), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
233 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2);
234 dc.DrawLine (ResPool.GetPen (BorderColor), cl.X + cl.Width - 1, cl.Y, cl.X + cl.Width - 1, cl.Y + cl.Height); //right
235 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + cl.Width - 2, cl.Y + 1 , cl.X + cl.Width - 2, cl.Y + cl.Height - 1);
236 dc.DrawLine (ResPool.GetPen (BorderColor), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
237 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
241 dc.DrawLine (ResPool.GetPen (FocusColor), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top
242 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
243 dc.DrawLine (ResPool.GetPen (FocusColor), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
244 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2);
245 dc.DrawLine (ResPool.GetPen (FocusColor), cl.X + cl.Width - 1, cl.Y, cl.X + cl.Width - 1, cl.Y + cl.Height); //right
246 dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + cl.Width - 2, cl.Y + 1 , cl.X + cl.Width - 2, cl.Y + cl.Height - 1);
247 dc.DrawLine (ResPool.GetPen (FocusColor), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
248 dc.DrawLine (ResPool.GetPen (FocusColor), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
252 public override void DrawComboListBoxDecorations( Graphics dc, ComboBox ctrl, Rectangle cl )
254 if ( ctrl.DropDownStyle == ComboBoxStyle.Simple )
256 DrawComboBoxEditDecorations( dc, ctrl, cl );
260 dc.DrawRectangle( ResPool.GetPen( ThemeEngine.Current.ColorWindowFrame ), cl.X, cl.Y, cl.Width - 1, cl.Height - 1 );
266 public override void DrawMenuItem( MenuItem item, DrawItemEventArgs e )
268 StringFormat string_format;
269 Rectangle rect_text = e.Bounds;
271 if ( item.Visible == false )
276 string_format = string_format_menu_menubar_text;
280 string_format = string_format_menu_text;
283 if ( item.Separator )
285 e.Graphics.DrawLine( ThemeEngine.Current.ResPool.GetPen( BorderColor ),
286 e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y );
288 e.Graphics.DrawLine( ThemeEngine.Current.ResPool.GetPen( Color.White ),
289 e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + 1 );
295 rect_text.X += ThemeEngine.Current.MenuCheckSize.Width;
298 { /* Draw vertical break bar*/
299 Rectangle rect = e.Bounds;
302 rect.Height = item.MenuHeight - 6;
304 e.Graphics.DrawLine( ThemeEngine.Current.ResPool.GetPen( LightColor ),
305 rect.X, rect.Y , rect.X, rect.Y + rect.Height );
307 e.Graphics.DrawLine( ThemeEngine.Current.ResPool.GetPen( ThemeEngine.Current.ColorControlLight ),
308 rect.X + 1, rect.Y , rect.X + 1, rect.Y + rect.Height );
311 Color color_text = ThemeEngine.Current.ColorMenuText;
314 /* Draw background */
315 Rectangle rect_back = e.Bounds;
317 rect_back.Width -= 2;
319 if ( ( e.State & DrawItemState.Selected ) == DrawItemState.Selected )
321 color_text = ThemeEngine.Current.ColorMenuText;
322 color_back = NormalColor;
324 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 ) )
326 e.Graphics.FillRectangle( lgbr, rect_back );
330 e.Graphics.DrawRectangle( ResPool.GetPen( BorderColor ), rect_back );
334 color_text = ThemeEngine.Current.ColorMenuText;
335 color_back = NiceBackColor;
337 e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( NiceBackColor ), rect_back );
342 e.Graphics.DrawString( item.Text, e.Font,
343 ThemeEngine.Current.ResPool.GetSolidBrush( color_text ),
344 rect_text, string_format );
346 if ( !item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut )
348 string str = item.GetShortCutText( );
349 Rectangle rect = rect_text;
351 rect.Width -= item.XTab;
353 e.Graphics.DrawString( str, e.Font, ThemeEngine.Current.ResPool.GetSolidBrush( color_text ),
354 rect, string_format_menu_shortcut );
359 ControlPaint.DrawStringDisabled( e.Graphics, item.Text, e.Font,
360 Color.Black, rect_text, string_format );
364 if ( item.MenuBar == false && item.IsPopup )
366 int cx = ThemeEngine.Current.MenuCheckSize.Width;
367 int cy = ThemeEngine.Current.MenuCheckSize.Height;
368 using ( Bitmap bmp = new Bitmap( cx, cy ) )
370 using ( Graphics dc = Graphics.FromImage( bmp ) )
372 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
373 dc.SmoothingMode = SmoothingMode.AntiAlias;
375 Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
376 ControlPaint.DrawMenuGlyph( dc, rect_arrow, MenuGlyph.Arrow );
377 bmp.MakeTransparent( );
381 e.Graphics.DrawImage( bmp, e.Bounds.X + e.Bounds.Width - cx,
382 e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
386 ControlPaint.DrawImageDisabled( e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
387 e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ), color_back );
390 dc.SmoothingMode = old_smoothing_mode;
395 /* Draw checked or radio */
396 if ( item.MenuBar == false && item.Checked )
399 Rectangle area = e.Bounds;
400 int cx = ThemeEngine.Current.MenuCheckSize.Width;
401 int cy = ThemeEngine.Current.MenuCheckSize.Height;
402 using ( Bitmap bmp = new Bitmap( cx, cy ) )
404 using ( Graphics gr = Graphics.FromImage( bmp ) )
406 Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
408 if ( item.RadioCheck )
409 ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Bullet );
411 ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Checkmark );
413 bmp.MakeTransparent( );
414 e.Graphics.DrawImage( bmp, area.X, e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
420 public override void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect)
423 dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
424 (NiceBackColor), cliparea);
426 /* Draw menu borders */
427 dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorHighlightText),
428 rect.X, rect.Y, rect.X + rect.Width, rect.Y);
430 dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorHighlightText),
431 rect.X, rect.Y, rect.X, rect.Y + rect.Height);
433 dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlDark),
434 rect.X + rect.Width - 1 , rect.Y , rect.X + rect.Width - 1, rect.Y + rect.Height);
436 dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlDarkDark),
437 rect.X + rect.Width, rect.Y , rect.X + rect.Width, rect.Y + rect.Height);
439 dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlDark),
440 rect.X , rect.Y + rect.Height - 1 , rect.X + rect.Width - 1, rect.Y + rect.Height -1);
442 dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlDarkDark),
443 rect.X , rect.Y + rect.Height, rect.X + rect.Width - 1, rect.Y + rect.Height);
445 for (int i = 0; i < menu.MenuItems.Count; i++)
446 if (cliparea.IntersectsWith (menu.MenuItems [i].bounds)) {
447 MenuItem item = menu.MenuItems [i];
448 item.MenuHeight = menu.Height;
449 item.PerformDrawItem (new DrawItemEventArgs (dc, ThemeEngine.Current.MenuFont,
450 item.bounds, i, item.Status));
456 public override void DrawProgressBar( Graphics dc, Rectangle clip_rect, ProgressBar ctrl )
458 Rectangle client_area = ctrl.client_area;
460 Rectangle bar = ctrl.client_area;
462 barpos_pixels = ( ( ctrl.Value - ctrl.Minimum ) * client_area.Width ) / ( ctrl.Maximum - ctrl.Minimum );
464 bar.Width = barpos_pixels;
467 // Draw bar background
468 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( client_area.Left, client_area.Top ), new Point( client_area.Left, client_area.Bottom ), LightColor, Color.White ) )
470 dc.FillRectangle( lgbr, client_area );
474 using ( LinearGradientBrush lgbr = new LinearGradientBrush( bar.Location, new Point( bar.X, bar.Bottom ), Color.White, FocusColor ) )
476 dc.FillRectangle( lgbr, bar );
480 dc.DrawRectangle( ResPool.GetPen( BorderColor ), ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.Width - 1, ctrl.ClientRectangle.Height - 1 );
481 dc.DrawRectangle( ResPool.GetPen( LightColor ), ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.Width - 2, ctrl.ClientRectangle.Height - 2 );
483 #endregion // ProgressBar
486 protected override void RadioButton_DrawButton( RadioButton radio_button, Graphics dc, ButtonState state, Rectangle radiobutton_rectangle )
488 SolidBrush sb = new SolidBrush( radio_button.BackColor );
489 dc.FillRectangle( sb, radio_button.ClientRectangle );
492 if (radio_button.appearance==Appearance.Button) {
493 if (radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup) {
494 DrawFlatStyleButton(dc, radio_button.ClientRectangle, radio_button);
496 DrawButtonBase( dc, radio_button.ClientRectangle, radio_button );
499 // establish if we are rendering a flat style of some sort
500 if ( radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup ) {
501 DrawFlatStyleRadioButton (dc, radiobutton_rectangle, radio_button);
503 ControlPaint.DrawRadioButton( dc, radiobutton_rectangle, state );
508 protected override void RadioButton_DrawFocus(RadioButton radio_button, Graphics dc, Rectangle text_rectangle)
510 if (radio_button.Focused && radio_button.appearance != Appearance.Button)
512 if (radio_button.FlatStyle != FlatStyle.Flat && radio_button.FlatStyle != FlatStyle.Popup)
514 DrawInnerFocusRectangle (dc, text_rectangle, radio_button.BackColor);
518 #endregion // RadioButton
521 protected override void ScrollBar_DrawThumb( ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
523 if ( bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith( thumb_pos ) )
524 DrawScrollBarThumb( dc, thumb_pos, bar );
527 protected override void ScrollBar_Vertical_Draw_ThumbMoving_None( int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc )
529 Rectangle r = new Rectangle( 0,
530 scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - ( scrollbutton_height * 2 ) );
531 Rectangle intersect = Rectangle.Intersect( clip, r );
533 if ( intersect != Rectangle.Empty )
535 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
537 dc.FillRectangle( lgbr, intersect );
542 protected override void ScrollBar_Vertical_Draw_ThumbMoving_Forward( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
544 Rectangle r = new Rectangle( 0, scrollbutton_height,
545 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
546 Rectangle intersect = Rectangle.Intersect( clip, r );
548 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
550 if ( intersect != Rectangle.Empty )
551 dc.FillRectangle( lgbr, intersect );
554 r.Y = thumb_pos.Y + thumb_pos.Height;
555 r.Width = bar.ClientRectangle.Width;
556 r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
558 intersect = Rectangle.Intersect( clip, r );
559 if ( intersect != Rectangle.Empty )
560 dc.FillRectangle( lgbr, intersect );
564 protected override void ScrollBar_Vertical_Draw_ThumbMoving_Backwards( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
566 Rectangle r = new Rectangle( 0, scrollbutton_height,
567 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
568 Rectangle intersect = Rectangle.Intersect( clip, r );
570 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
572 if ( intersect != Rectangle.Empty )
573 dc.FillRectangle( lgbr, intersect );
576 r.Y = thumb_pos.Y + thumb_pos.Height;
577 r.Width = bar.ClientRectangle.Width;
578 r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
580 intersect = Rectangle.Intersect( clip, r );
581 if ( intersect != Rectangle.Empty )
582 dc.FillRectangle( lgbr, intersect );
586 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc )
588 Rectangle r = new Rectangle( scrollbutton_width,
589 0, bar.ClientRectangle.Width - ( scrollbutton_width * 2 ), bar.ClientRectangle.Height );
590 Rectangle intersect = Rectangle.Intersect( clip, r );
592 if ( intersect != Rectangle.Empty )
594 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
596 dc.FillRectangle( lgbr, intersect );
601 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
603 Rectangle r = new Rectangle( scrollbutton_width, 0,
604 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
605 Rectangle intersect = Rectangle.Intersect( clip, r );
607 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
609 if ( intersect != Rectangle.Empty )
610 dc.FillRectangle( lgbr, intersect );
612 r.X = thumb_pos.X + thumb_pos.Width;
614 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
615 r.Height = bar.ClientRectangle.Height;
617 intersect = Rectangle.Intersect( clip, r );
618 if ( intersect != Rectangle.Empty )
619 dc.FillRectangle( lgbr, intersect );
623 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
625 Rectangle r = new Rectangle( scrollbutton_width, 0,
626 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
627 Rectangle intersect = Rectangle.Intersect( clip, r );
629 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
631 if ( intersect != Rectangle.Empty )
632 dc.FillRectangle( lgbr, intersect );
634 r.X = thumb_pos.X + thumb_pos.Width;
636 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
637 r.Height = bar.ClientRectangle.Height;
639 intersect = Rectangle.Intersect( clip, r );
640 if ( intersect != Rectangle.Empty )
641 dc.FillRectangle( lgbr, intersect );
644 #endregion // ScrollBar
647 protected override void DrawStatusBarPanel( Graphics dc, Rectangle area, int index,
648 SolidBrush br_forecolor, StatusBarPanel panel )
650 int border_size = 3; // this is actually const, even if the border style is none
652 area.Height -= border_size;
653 if ( panel.BorderStyle != StatusBarPanelBorderStyle.None )
655 DrawNiceRoundedBorder( dc, area, BorderColor );
658 if ( panel.Style == StatusBarPanelStyle.OwnerDraw )
660 StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs(
661 dc, panel.Parent.Font, area, index, DrawItemState.Default,
662 panel, panel.Parent.ForeColor, panel.Parent.BackColor );
663 panel.Parent.OnDrawItemInternal( e );
667 int left = area.Left;
668 if ( panel.Icon != null )
671 dc.DrawIcon( panel.Icon, left, area.Top );
672 left += panel.Icon.Width;
675 if ( panel.Text == String.Empty )
678 string text = panel.Text;
679 StringFormat string_format = new StringFormat( );
680 string_format.Trimming = StringTrimming.Character;
681 string_format.FormatFlags = StringFormatFlags.NoWrap;
683 if ( text[ 0 ] == '\t' )
685 string_format.Alignment = StringAlignment.Center;
686 text = text.Substring( 1 );
687 if ( text[ 0 ] == '\t' )
689 string_format.Alignment = StringAlignment.Far;
690 text = text.Substring( 1 );
694 int x = left + border_size;
695 int y = border_size + 2;
696 Rectangle r = new Rectangle( x, y,
697 area.Right - x - border_size,
698 area.Bottom - y - border_size );
700 dc.DrawString( text, panel.Parent.Font, br_forecolor, r, string_format );
703 private void DrawNiceRoundedBorder( Graphics dc, Rectangle area, Color color )
705 Pen pen = ResPool.GetPen( color );
707 Point[] points = new Point[] {
708 new Point( area.Left + 2, area.Top ),
709 new Point( area.Right - 2, area.Top ),
710 new Point( area.Right, area.Top + 2 ),
711 new Point( area.Right, area.Bottom - 2 ),
712 new Point( area.Right - 2, area.Bottom ),
713 new Point( area.Left + 2, area.Bottom ),
714 new Point( area.Left, area.Bottom - 2 ),
715 new Point( area.Left, area.Top + 2 ),
716 new Point( area.Left + 2, area.Top )
719 dc.DrawLines( pen, points );
721 #endregion // StatusBar
723 public override void DrawTabControl( Graphics dc, Rectangle area, TabControl tab )
725 // Do we need to fill the back color? It can't be changed...
726 dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), area );
727 Rectangle panel_rect = GetTabPanelRectExt( tab );
729 if ( tab.Appearance == TabAppearance.Normal )
731 CPDrawBorder( dc, panel_rect, BorderColor, 1, ButtonBorderStyle.Solid, BorderColor, 1, ButtonBorderStyle.Solid,
732 BorderColor, 1, ButtonBorderStyle.Solid, BorderColor, 1, ButtonBorderStyle.Solid );
735 if ( tab.Alignment == TabAlignment.Top )
737 for ( int r = tab.TabPages.Count; r > 0; r-- )
739 for ( int i = tab.SliderPos; i < tab.TabPages.Count; i++ )
741 if ( i == tab.SelectedIndex )
743 if ( r != tab.TabPages[ i ].Row )
745 Rectangle rect = tab.GetTabRect( i );
746 if ( !rect.IntersectsWith( area ) )
748 DrawTab( dc, tab.TabPages[ i ], tab, rect, false );
754 for ( int r = 0; r < tab.TabPages.Count; r++ )
756 for ( int i = tab.SliderPos; i < tab.TabPages.Count; i++ )
758 if ( i == tab.SelectedIndex )
760 if ( r != tab.TabPages[ i ].Row )
762 Rectangle rect = tab.GetTabRect( i );
763 if ( !rect.IntersectsWith( area ) )
765 DrawTab( dc, tab.TabPages[ i ], tab, rect, false );
770 if ( tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos )
772 Rectangle rect = tab.GetTabRect( tab.SelectedIndex );
773 if ( rect.IntersectsWith( area ) )
774 DrawTab( dc, tab.TabPages[ tab.SelectedIndex ], tab, rect, true );
777 if ( tab.ShowSlider )
779 Rectangle right = GetTabControlRightScrollRect( tab );
780 Rectangle left = GetTabControlLeftScrollRect( tab );
781 CPDrawScrollButton( dc, right, ScrollButton.Right, tab.RightSliderState );
782 CPDrawScrollButton( dc, left, ScrollButton.Left, tab.LeftSliderState );
786 protected override int DrawTab( Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected )
788 int FlatButtonSpacing = 8;
790 int res = bounds.Width;
792 // we can't fill the background right away because the bounds might be adjusted if the tab is selected
794 if ( tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons )
796 dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), bounds );
799 if ( tab.Appearance == TabAppearance.FlatButtons )
801 int width = bounds.Width;
802 bounds.Width += ( FlatButtonSpacing - 2 );
804 CPDrawBorder3D( dc, bounds, Border3DStyle.Etched, Border3DSide.Right );
805 bounds.Width = width;
810 CPDrawBorder3D( dc, bounds, Border3DStyle.Sunken, Border3DSide.All );
812 else if ( tab.Appearance != TabAppearance.FlatButtons )
814 CPDrawBorder3D( dc, bounds, Border3DStyle.Raised, Border3DSide.All );
817 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4 );
820 StringFormat string_format = new StringFormat( );
821 string_format.Alignment = StringAlignment.Center;
822 string_format.LineAlignment = StringAlignment.Center;
823 string_format.FormatFlags = StringFormatFlags.NoWrap;
826 dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
831 Pen border_pen = ResPool.GetPen( BorderColor );
833 dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), bounds );
835 switch ( tab.Alignment )
837 case TabAlignment.Top:
841 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
843 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Left + 2, bounds.Bottom ), Color.White, LightColor ) )
845 dc.FillRectangle( lgbr, interior );
849 dc.DrawLine( border_pen, bounds.Left, bounds.Bottom, bounds.Left, bounds.Top + 3 );
850 dc.DrawLine( border_pen, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top );
851 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Top, bounds.Right - 3, bounds.Top );
852 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3 );
853 dc.DrawLine( border_pen, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom );
857 dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left - 1 , bounds.Top, bounds.Right - 1, bounds.Top );
858 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Top + 1, bounds.Right , bounds.Top + 1 );
859 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Top + 2, bounds.Right , bounds.Top + 2 );
862 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
864 if ( page.Text != String.Empty )
866 StringFormat string_format = new StringFormat( );
867 string_format.Alignment = StringAlignment.Center;
868 string_format.LineAlignment = StringAlignment.Center;
869 string_format.FormatFlags = StringFormatFlags.NoWrap;
871 dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
877 case TabAlignment.Bottom:
881 interior = new Rectangle( bounds.Left + 3, bounds.Top, bounds.Width - 3, bounds.Height );
883 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 3, bounds.Top ), new Point( bounds.Left + 3, bounds.Bottom ), Color.White, LightColor ) )
885 dc.FillRectangle( lgbr, interior );
889 dc.DrawLine( border_pen, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 3 );
890 dc.DrawLine( border_pen, bounds.Left, bounds.Bottom - 3, bounds.Left + 3, bounds.Bottom );
891 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom );
892 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Bottom, bounds.Right, bounds.Bottom - 3 );
893 dc.DrawLine( border_pen, bounds.Right, bounds.Bottom - 3, bounds.Right, bounds.Top );
897 dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left - 1 , bounds.Bottom, bounds.Right - 1, bounds.Bottom );
898 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Bottom - 1, bounds.Right , bounds.Bottom - 1 );
899 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Bottom - 2, bounds.Right , bounds.Bottom - 2 );
902 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
904 if ( page.Text != String.Empty )
906 StringFormat string_format = new StringFormat( );
907 string_format.Alignment = StringAlignment.Center;
908 string_format.LineAlignment = StringAlignment.Center;
909 string_format.FormatFlags = StringFormatFlags.NoWrap;
911 dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
917 case TabAlignment.Left:
921 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
923 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Right, bounds.Top + 2 ), LightColor, Color.White ) )
925 dc.FillRectangle( lgbr, interior );
929 dc.DrawLine( border_pen, bounds.Right, bounds.Top, bounds.Left + 3, bounds.Top );
930 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Top, bounds.Left, bounds.Top + 3 );
931 dc.DrawLine( border_pen, bounds.Left, bounds.Top + 3, bounds.Left, bounds.Bottom - 3 );
932 dc.DrawLine( border_pen, bounds.Left, bounds.Bottom - 3, bounds.Left + 3, bounds.Bottom );
933 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Bottom, bounds.Right, bounds.Bottom );
937 dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left , bounds.Top + 1, bounds.Left , bounds.Bottom - 1 );
938 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left + 1 , bounds.Top, bounds.Left + 1 , bounds.Bottom );
939 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left + 2 , bounds.Top, bounds.Left + 2 , bounds.Bottom );
942 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
944 if ( page.Text != String.Empty )
946 StringFormat string_format = new StringFormat( );
947 // Flip the text around
948 string_format.Alignment = StringAlignment.Center;
949 string_format.LineAlignment = StringAlignment.Center;
950 string_format.FormatFlags = StringFormatFlags.NoWrap;
951 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
952 int wo = interior.Width / 2;
953 int ho = interior.Height / 2;
954 dc.TranslateTransform( interior.X + wo, interior.Y + ho );
955 dc.RotateTransform( 180 );
956 dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), 0, 0, string_format );
957 dc.ResetTransform( );
963 // TabAlignment.Right
967 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
969 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Right, bounds.Top + 2 ), Color.White, LightColor ) )
971 dc.FillRectangle( lgbr, interior );
975 dc.DrawLine( border_pen, bounds.Left, bounds.Top, bounds.Right - 3, bounds.Top );
976 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3 );
977 dc.DrawLine( border_pen, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom - 3 );
978 dc.DrawLine( border_pen, bounds.Right, bounds.Bottom - 3, bounds.Right - 3, bounds.Bottom );
979 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Bottom, bounds.Left, bounds.Bottom );
983 dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Right , bounds.Top + 1, bounds.Right , bounds.Bottom - 1 );
984 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Right - 1 , bounds.Top, bounds.Right - 1 , bounds.Bottom );
985 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Right - 2 , bounds.Top, bounds.Right - 2 , bounds.Bottom );
988 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
990 if ( page.Text != String.Empty )
992 StringFormat string_format = new StringFormat( );
993 string_format.Alignment = StringAlignment.Center;
994 string_format.LineAlignment = StringAlignment.Center;
995 string_format.FormatFlags = StringFormatFlags.NoWrap;
996 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
998 dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
1009 public override void CPDrawComboButton( Graphics dc, Rectangle rectangle, ButtonState state )
1011 Point[] arrow = new Point[ 3 ];
1021 Color first_color = Color.White;
1022 Color second_color = NormalColor;
1024 // rectangle.Width += 1;
1026 if ( ( state & ButtonState.Checked ) != 0 )
1028 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControlLightLight, ColorControlLight ), rectangle );
1031 dc.FillRectangle( ResPool.GetSolidBrush( Color.White ), rectangle );
1033 if ( ( state & ButtonState.Flat ) != 0 )
1035 first_color = NormalColor;
1036 second_color = Color.White;
1040 if ( ( state & ( ButtonState.Pushed | ButtonState.Checked ) ) != 0 )
1042 first_color = Color.White;
1043 second_color = PressedColor;
1047 // CPDrawBorder3D( graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl );
1051 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 ) )
1053 dc.FillRectangle( lgbr, rectangle.X + 2, rectangle.Y + 1, rectangle.Width - 4, rectangle.Height - 3 );
1056 Point[] points = new Point[] {
1057 new Point( rectangle.X + 3, rectangle.Y + 1 ),
1058 new Point( rectangle.Right - 4, rectangle.Y + 1 ),
1059 new Point( rectangle.Right - 2, rectangle.Y + 3 ),
1060 new Point( rectangle.Right - 2, rectangle.Bottom - 4 ),
1061 new Point( rectangle.Right - 4, rectangle.Bottom - 2 ),
1062 new Point( rectangle.X + 3, rectangle.Bottom - 2 ),
1063 new Point( rectangle.X + 1, rectangle.Bottom - 4 ),
1064 new Point( rectangle.X + 1, rectangle.Y + 3 ),
1065 new Point( rectangle.X + 3, rectangle.Y + 1 )
1068 dc.DrawPolygon( ResPool.GetPen( BorderColor ), points );
1070 rect = new Rectangle( rectangle.X + rectangle.Width / 4, rectangle.Y + rectangle.Height / 4, rectangle.Width / 2, rectangle.Height / 2 );
1071 centerX = rect.Left + rect.Width / 2;
1072 centerY = rect.Top + rect.Height / 2;
1073 shiftX = Math.Max( 1, rect.Width / 8 );
1074 shiftY = Math.Max( 1, rect.Height / 8 );
1076 if ( ( state & ButtonState.Pushed ) != 0 )
1085 P1 = new Point( rect.Left, centerY );
1086 P2 = new Point( centerX, rect.Bottom );
1087 P3 = new Point( rect.Right, centerY );
1093 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
1094 dc.SmoothingMode = SmoothingMode.AntiAlias;
1096 /* Draw the arrow */
1097 if ( ( state & ButtonState.Inactive ) != 0 )
1099 using ( Pen pen = new Pen( SystemColors.ControlLightLight, 2 ) )
1101 dc.DrawLines( pen, arrow );
1104 /* Move away from the shadow */
1105 P1.X -= 1; P1.Y -= 1;
1106 P2.X -= 1; P2.Y -= 1;
1107 P3.X -= 1; P3.Y -= 1;
1113 using ( Pen pen = new Pen( SystemColors.ControlDark, 2 ) )
1115 dc.DrawLines( pen, arrow );
1120 using ( Pen pen = new Pen( SystemColors.ControlText, 2 ) )
1122 dc.DrawLines( pen, arrow );
1126 dc.SmoothingMode = old_smoothing_mode;
1129 /* Scroll button: regular button + direction arrow */
1130 public override void CPDrawScrollButton( Graphics dc, Rectangle area, ScrollButton scroll_button_type, ButtonState state )
1132 bool enabled = ( state == ButtonState.Inactive ) ? false: true;
1134 DrawScrollButtonPrimitive( dc, area, state, scroll_button_type );
1136 if ( area.Width < 12 || area.Height < 12 ) /* Cannot see a thing at smaller sizes */
1142 pen = new Pen( arrow_color, 2 );
1144 pen = new Pen( ColorGrayText, 2 );
1148 int centerX = area.Left + area.Width / 2;
1149 int centerY = area.Top + area.Height / 2;
1153 if ( ( state & ButtonState.Pushed ) != 0 )
1156 Point[] arrow = new Point[ 3 ];
1158 switch ( scroll_button_type )
1160 case ScrollButton.Down:
1162 arrow[ 0 ] = new Point( centerX - 3, centerY - 2 );
1163 arrow[ 1 ] = new Point( centerX, centerY + 2 );
1164 arrow[ 2 ] = new Point( centerX + 3, centerY - 2 );
1166 case ScrollButton.Up:
1168 arrow[ 0 ] = new Point( centerX - 3, centerY + 2 );
1169 arrow[ 1 ] = new Point( centerX, centerY - 2 );
1170 arrow[ 2 ] = new Point( centerX + 3, centerY + 2 );
1172 case ScrollButton.Left:
1174 arrow[ 0 ] = new Point( centerX + 2, centerY - 3 );
1175 arrow[ 1 ] = new Point( centerX - 2, centerY );
1176 arrow[ 2 ] = new Point( centerX + 2, centerY + 3 );
1178 case ScrollButton.Right:
1180 arrow[ 0 ] = new Point( centerX - 2, centerY - 3 );
1181 arrow[ 1 ] = new Point( centerX + 2, centerY );
1182 arrow[ 2 ] = new Point( centerX - 2, centerY + 3 );
1188 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
1189 dc.SmoothingMode = SmoothingMode.AntiAlias;
1191 dc.DrawLines( pen, arrow );
1193 dc.SmoothingMode = old_smoothing_mode;
1198 public override void CPDrawSizeGrip( Graphics dc, Color backColor, Rectangle bounds )
1200 Point pt = new Point( bounds.Right - 4, bounds.Bottom - 4 );
1202 dc.DrawImage( size_grip_bmp, pt );
1203 dc.DrawImage( size_grip_bmp, pt.X, pt.Y - 5 );
1204 dc.DrawImage( size_grip_bmp, pt.X, pt.Y - 10 );
1205 dc.DrawImage( size_grip_bmp, pt.X - 5, pt.Y );
1206 dc.DrawImage( size_grip_bmp, pt.X - 10, pt.Y );
1207 dc.DrawImage( size_grip_bmp, pt.X - 5, pt.Y - 5 );
1210 private void DrawScrollBarThumb( Graphics dc, Rectangle area, ScrollBar bar )
1212 LinearGradientBrush lgbr = null;
1215 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right, area.Y ), Color.White, NormalColor );
1217 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom ), Color.White, NormalColor );
1219 Pen pen = ResPool.GetPen( BorderColor );
1221 Point[] points = new Point[] {
1222 new Point( area.X + 2, area.Y ),
1223 new Point( area.Right - 3, area.Y ),
1224 new Point( area.Right - 1, area.Y + 2 ),
1225 new Point( area.Right - 1, area.Bottom - 3 ),
1226 new Point( area.Right - 3, area.Bottom - 1 ),
1227 new Point( area.X + 2, area.Bottom - 1 ),
1228 new Point( area.X, area.Bottom - 3 ),
1229 new Point( area.X, area.Y + 2 ),
1230 new Point( area.X + 2, area.Y )
1235 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1236 dc.DrawPolygon( pen, points );
1238 // draw grip lines only if stere is enough space
1239 if ( area.Height > 20 )
1241 int mid_y = area.Y + ( area.Height / 2 );
1242 int mid_x = area.X + ( area.Width / 2 );
1244 using ( Pen lpen = new Pen( MouseOverColor, 2 ) )
1246 dc.DrawLine( lpen, mid_x - 3, mid_y, mid_x + 3, mid_y );
1247 dc.DrawLine( lpen, mid_x - 3, mid_y - 4, mid_x + 3, mid_y - 4 );
1248 dc.DrawLine( lpen, mid_x - 3, mid_y + 4, mid_x + 3, mid_y + 4 );
1251 Pen spen = ResPool.GetPen( Color.White );
1252 dc.DrawLine( spen, mid_x - 3, mid_y - 1, mid_x + 3, mid_y - 1 );
1253 dc.DrawLine( spen, mid_x - 3, mid_y - 5, mid_x + 3, mid_y - 5 );
1254 dc.DrawLine( spen, mid_x - 3, mid_y + 3, mid_x + 3, mid_y + 3 );
1259 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1260 dc.DrawPolygon( pen, points );
1262 // draw grip lines only if stere is enough space
1263 if ( area.Width > 20 )
1265 int mid_x = area.X + ( area.Width / 2 );
1266 int mid_y = area.Y + ( area.Height / 2 );
1268 using ( Pen lpen = new Pen( MouseOverColor, 2 ) )
1270 dc.DrawLine( lpen, mid_x, mid_y - 3, mid_x, mid_y + 3 );
1271 dc.DrawLine( lpen, mid_x - 4, mid_y - 3, mid_x - 4, mid_y + 3 );
1272 dc.DrawLine( lpen, mid_x + 4, mid_y - 3, mid_x + 4, mid_y + 3 );
1275 Pen spen = ResPool.GetPen( Color.White );
1276 dc.DrawLine( spen, mid_x - 1, mid_y - 3, mid_x - 1, mid_y + 3 );
1277 dc.DrawLine( spen, mid_x - 5, mid_y - 3, mid_x - 5, mid_y + 3 );
1278 dc.DrawLine( spen, mid_x + 3, mid_y - 3, mid_x + 3, mid_y + 3 );
1285 /* Nice scroll button */
1286 public void DrawScrollButtonPrimitive( Graphics dc, Rectangle area, ButtonState state, ScrollButton scroll_button_type )
1288 Pen pen = ResPool.GetPen( BorderColor );
1290 dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), area );
1294 if ( ( state & ButtonState.Pushed ) == ButtonState.Pushed )
1295 use_color = PressedColor;
1297 use_color = NormalColor;
1299 Point[] points = null;
1301 LinearGradientBrush lgbr = null;
1303 switch ( scroll_button_type )
1305 case ScrollButton.Left:
1306 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 2, area.Y ), use_color, Color.White );
1307 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 4, area.Height - 2 );
1309 points = new Point[] {
1310 new Point( area.X + 2, area.Y ),
1311 new Point( area.Right - 1, area.Y ),
1312 new Point( area.Right - 1, area.Bottom - 1 ),
1313 new Point( area.X + 2, area.Bottom - 1 ),
1314 new Point( area.X, area.Bottom - 3 ),
1315 new Point( area.X, area.Y + 2 ),
1316 new Point( area.X + 2, area.Y )
1318 dc.DrawPolygon( pen, points );
1320 case ScrollButton.Right:
1321 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 1, area.Y ), Color.White, use_color );
1322 dc.FillRectangle( lgbr, area.X, area.Y + 1, area.Width - 1, area.Height - 2 );
1324 points = new Point[] {
1325 new Point( area.X, area.Y ),
1326 new Point( area.Right - 3, area.Y ),
1327 new Point( area.Right - 1, area.Y + 2 ),
1328 new Point( area.Right - 1, area.Bottom - 3 ),
1329 new Point( area.Right - 3, area.Bottom - 1 ),
1330 new Point( area.X, area.Bottom - 1 ),
1331 new Point( area.X, area.Y ),
1333 dc.DrawPolygon( pen, points );
1335 case ScrollButton.Up:
1336 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), use_color, Color.White );
1337 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1339 points = new Point[] {
1340 new Point( area.X + 2, area.Y ),
1341 new Point( area.Right - 3, area.Y ),
1342 new Point( area.Right - 1, area.Y + 2 ),
1343 new Point( area.Right - 1, area.Bottom - 1 ),
1344 new Point( area.X, area.Bottom - 1 ),
1345 new Point( area.X, area.Y + 2 ),
1346 new Point( area.X + 2, area.Y )
1348 dc.DrawPolygon( pen, points );
1350 case ScrollButton.Down:
1351 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), Color.White, use_color );
1352 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1354 points = new Point[] {
1355 new Point( area.X, area.Y ),
1356 new Point( area.Right - 1, area.Y ),
1357 new Point( area.Right - 1, area.Bottom - 3 ),
1358 new Point( area.Right - 3, area.Bottom - 1 ),
1359 new Point( area.X + 2, area.Bottom - 1 ),
1360 new Point( area.X, area.Bottom - 3 ),
1361 new Point( area.X, area.Y )
1363 dc.DrawPolygon( pen, points );
1371 public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box)
1373 StringFormat text_format;
1379 rect = box.ClientRectangle;
1381 dc.FillRectangle (ResPool.GetSolidBrush (box.BackColor), rect);
1383 text_format = new StringFormat();
1384 text_format.HotkeyPrefix = HotkeyPrefix.Show;
1386 size = dc.MeasureString (box.Text, box.Font);
1387 width = (int) size.Width;
1389 if (width > box.Width - 16)
1390 width = box.Width - 16;
1392 y = box.Font.Height / 2;
1394 Pen pen = ResPool.GetPen( BorderColor );
1397 Point[] points = new Point[] {
1398 new Point( 8 + width, y ),
1399 new Point( box.Width - 3, y ),
1400 new Point( box.Width - 1, y + 2 ),
1401 new Point( box.Width - 1, box.Height - 3 ),
1402 new Point( box.Width - 3, box.Height - 1 ),
1403 new Point( 2, box.Height - 1 ),
1404 new Point( 0, box.Height - 3 ),
1405 new Point( 0, y + 2 ),
1409 dc.DrawLines( pen, points );
1413 dc.DrawString (box.Text, box.Font, ResPool.GetSolidBrush (box.ForeColor), 10, 0, text_format);
1415 CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor,
1416 new RectangleF (10, 0, width, box.Font.Height), text_format);
1418 text_format.Dispose ();