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
38 internal class ThemeNice : ThemeWin32Classic
40 public override Version Version
43 return new Version( 0, 0, 0, 1 );
47 /* Default colors for nice theme */
48 uint [] theme_colors = { /* AARRGGBB */
49 (uint) XplatUIWin32.GetSysColorIndex.COLOR_SCROLLBAR, 0xffc0c0c0,
50 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BACKGROUND, 0xffefebe7,
51 (uint) XplatUIWin32.GetSysColorIndex.COLOR_ACTIVECAPTION, 0xff000080,
52 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVECAPTION, 0xff808080,
53 (uint) XplatUIWin32.GetSysColorIndex.COLOR_MENU, 0xffefebe7,
54 (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOW, 0xffffffff,
55 (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOWFRAME, 0xff000000,
56 (uint) XplatUIWin32.GetSysColorIndex.COLOR_MENUTEXT, 0xff000000,
57 (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOWTEXT, 0xff000000,
58 (uint) XplatUIWin32.GetSysColorIndex.COLOR_CAPTIONTEXT, 0xffffffff,
59 (uint) XplatUIWin32.GetSysColorIndex.COLOR_ACTIVEBORDER, 0xffc0c0c0,
60 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVEBORDER, 0xffc0c0c0,
61 (uint) XplatUIWin32.GetSysColorIndex.COLOR_APPWORKSPACE, 0xff808080,
62 (uint) XplatUIWin32.GetSysColorIndex.COLOR_HIGHLIGHT, 0xff000080,
63 (uint) XplatUIWin32.GetSysColorIndex.COLOR_HIGHLIGHTTEXT, 0xffffffff,
64 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNFACE, 0xffefebe7,
65 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNSHADOW, 0xff808080,
66 (uint) XplatUIWin32.GetSysColorIndex.COLOR_GRAYTEXT, 0xff808080,
67 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNTEXT, 0xff000000,
68 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVECAPTIONTEXT, 0xffc0c0c0,
69 (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNHIGHLIGHT, 0xffffffff,
70 (uint) XplatUIWin32.GetSysColorIndex.COLOR_3DDKSHADOW, 0xff000000,
71 (uint) XplatUIWin32.GetSysColorIndex.COLOR_3DLIGHT, 0xffe0e0e0,
72 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INFOTEXT, 0xff000000,
73 (uint) XplatUIWin32.GetSysColorIndex.COLOR_INFOBK, 0xffffffff,
77 static readonly Color NormalColor = Color.LightGray;
78 static readonly Color MouseOverColor = Color.DarkGray;
79 static readonly Color PressedColor = Color.Gray;
80 static readonly Color FocusColor = Color.FromArgb( System.Convert.ToInt32( "0xff00c0ff", 16 ) );
81 // static uint uifc = 0xff00c0ff;
82 // static readonly Color xFocusColor = Color.FromArgb( (int)uifc );
83 static readonly Color LightColor = Color.LightGray;
84 static readonly Color BorderColor = MouseOverColor;
85 static readonly Color NiceBackColor = Color.FromArgb( System.Convert.ToInt32( "0xffefebe7", 16 ) );
87 #region Principal Theme Methods
90 /* Init Default colour array*/
91 syscolors = Array.CreateInstance( typeof (Color), (uint) XplatUIWin32.GetSysColorIndex.COLOR_MAXVALUE + 1 );
93 for ( int i = 0; i < theme_colors.Length; i += 2 )
94 syscolors.SetValue( Color.FromArgb( (int)theme_colors[ i + 1 ] ), (int) theme_colors[ i ] );
97 public override Color DefaultControlBackColor
99 get { return NiceBackColor; }
102 public override Color DefaultWindowBackColor
104 get { return NiceBackColor; }
106 #endregion // Internal Methods
109 protected override void ButtonBase_DrawButton( ButtonBase button, Graphics dc )
113 Rectangle buttonRectangle;
115 width = button.ClientSize.Width;
116 height = button.ClientSize.Height;
118 dc.FillRectangle( ResPool.GetSolidBrush( button.BackColor ), button.ClientRectangle );
120 // set up the button rectangle
121 buttonRectangle = button.ClientRectangle;
125 if ( ( ( button.GetType( ) == typeof( CheckBox ) ) && ( ( (CheckBox)button ).check_state == CheckState.Checked ) ) ||
126 ( ( button.GetType( ) == typeof( RadioButton ) ) && ( ( (RadioButton)button ).check_state == CheckState.Checked ) ) )
128 use_color = PressedColor;
131 if ( !button.is_enabled )
133 use_color = NormalColor;
134 button.is_entered = false;
137 if ( !button.is_entered )
139 use_color = NormalColor;
143 if ( !button.is_pressed )
144 use_color = MouseOverColor;
146 use_color = PressedColor;
149 // Fill button with a nice linear gradient brush
150 Rectangle lgbRectangle = Rectangle.Inflate( buttonRectangle, -2, -1 );
152 if ( button.flat_style != FlatStyle.Popup || ( ( button.flat_style == FlatStyle.Popup ) && button.is_entered ) )
154 LinearGradientBrush lgbr;
155 if ( button.flat_style == FlatStyle.Flat )
156 lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, height - 1 ), use_color, Color.White );
158 lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, height - 1 ), Color.White, use_color );
159 dc.FillRectangle( lgbr, lgbRectangle );
162 Pen pen = ResPool.GetPen( BorderColor );
163 dc.DrawLine( pen, 3, 0, width - 4, 0 );
164 dc.DrawLine( pen, width - 1, 3, width - 1, height - 4 );
165 dc.DrawLine( pen, 3, height - 1, width - 4, height - 1 );
166 dc.DrawLine( pen, 0, 3, 0, height - 4 );
168 dc.DrawCurve( pen, new Point[] { new Point( 0, 4 ), new Point( 4, 0 ) } );
169 dc.DrawCurve( pen, new Point[] { new Point( 0, height - 4 ), new Point( 4, height ) } );
170 dc.DrawCurve( pen, new Point[] { new Point( width - 4, 0 ), new Point( width, 4 ) } );
171 dc.DrawCurve( pen, new Point[] { new Point( width, height - 4 ), new Point( width - 4, height ) } );
175 protected override void ButtonBase_DrawFocus( ButtonBase button, Graphics dc )
177 int width = button.ClientSize.Width;
178 int height = button.ClientSize.Height;
180 Pen pen = ResPool.GetPen( FocusColor );
181 dc.DrawLine( pen, 4, 1, width - 5, 1 );
182 dc.DrawLine( pen, width - 2, 4, width - 2, height - 5 );
183 dc.DrawLine( pen, 4, height - 2, width - 5, height - 2 );
184 dc.DrawLine( pen, 1, 4, 1, height - 5 );
186 dc.DrawCurve( pen, new Point[] { new Point( 1, 5 ), new Point( 5, 1 ) } );
187 dc.DrawCurve( pen, new Point[] { new Point( 1, height - 5 ), new Point( 5, height - 1 ) } );
188 dc.DrawCurve( pen, new Point[] { new Point( width - 5, 1 ), new Point( width - 1, 5 ) } );
189 dc.DrawCurve( pen, new Point[] { new Point( width - 1, height - 5 ), new Point( width - 5, height - 1 ) } );
192 protected override void ButtonBase_DrawText( ButtonBase button, Graphics dc )
194 if ( button.GetType( ) != typeof( CheckBox ) && button.GetType( ) != typeof( RadioButton ) )
196 base.ButtonBase_DrawText( button, dc );
199 #endregion // ButtonBase
202 protected override void CheckBox_DrawCheckBox( Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle )
204 dc.FillRectangle( ResPool.GetSolidBrush( checkbox.BackColor ), checkbox.ClientRectangle );
205 // render as per normal button
206 if ( checkbox.appearance == Appearance.Button )
208 DrawButtonBase( dc, checkbox.ClientRectangle, checkbox );
212 // establish if we are rendering a flat style of some sort
213 if ( checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup )
215 DrawFlatStyleCheckBox( dc, checkbox_rectangle, checkbox );
219 ControlPaint.DrawCheckBox( dc, checkbox_rectangle, state );
223 #endregion // CheckBox
229 public override void DrawComboBoxEditDecorations( Graphics dc, ComboBox ctrl, Rectangle cl )
231 dc.DrawRectangle( ResPool.GetPen( BorderColor ) , cl.X + 1, cl.Y + 1, cl.Width - 3, cl.Height - 3 );
234 public override void DrawComboListBoxDecorations( Graphics dc, ComboBox ctrl, Rectangle cl )
236 if ( ctrl.DropDownStyle == ComboBoxStyle.Simple )
238 DrawComboBoxEditDecorations( dc, ctrl, cl );
242 dc.DrawRectangle( ResPool.GetPen( ThemeEngine.Current.ColorWindowFrame ), cl.X, cl.Y, cl.Width - 1, cl.Height - 1 );
248 public override void DrawMenuItem( MenuItem item, DrawItemEventArgs e )
250 StringFormat string_format;
251 Rectangle rect_text = e.Bounds;
253 if ( item.Visible == false )
258 string_format = string_format_menu_menubar_text;
262 string_format = string_format_menu_text;
265 if ( item.Separator == true )
267 e.Graphics.DrawLine( ThemeEngine.Current.ResPool.GetPen( LightColor ),
268 e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y );
270 e.Graphics.DrawLine( ThemeEngine.Current.ResPool.GetPen( ThemeEngine.Current.ColorControlLight ),
271 e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + 1 );
277 rect_text.X += ThemeEngine.Current.MenuCheckSize.Width;
280 { /* Draw vertical break bar*/
281 Rectangle rect = e.Bounds;
284 rect.Height = item.MenuHeight - 6;
286 e.Graphics.DrawLine( ThemeEngine.Current.ResPool.GetPen( LightColor ),
287 rect.X, rect.Y , rect.X, rect.Y + rect.Height );
289 e.Graphics.DrawLine( ThemeEngine.Current.ResPool.GetPen( ThemeEngine.Current.ColorControlLight ),
290 rect.X + 1, rect.Y , rect.X + 1, rect.Y + rect.Height );
293 Color color_text = ThemeEngine.Current.ColorMenuText;
296 /* Draw background */
297 Rectangle rect_back = e.Bounds;
299 rect_back.Width -= 2;
301 if ( ( e.State & DrawItemState.Selected ) == DrawItemState.Selected )
303 color_text = ThemeEngine.Current.ColorMenuText;
304 color_back = NormalColor;
306 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 ) )
308 e.Graphics.FillRectangle( lgbr, rect_back );
312 e.Graphics.DrawRectangle( ResPool.GetPen( BorderColor ), rect_back );
316 color_text = ThemeEngine.Current.ColorMenuText;
317 color_back = NiceBackColor;
319 e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( NiceBackColor ), rect_back );
324 e.Graphics.DrawString( item.Text, e.Font,
325 ThemeEngine.Current.ResPool.GetSolidBrush( color_text ),
326 rect_text, string_format );
328 if ( !item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut )
330 string str = item.GetShortCutText( );
331 Rectangle rect = rect_text;
333 rect.Width -= item.XTab;
335 e.Graphics.DrawString( str, e.Font, ThemeEngine.Current.ResPool.GetSolidBrush( color_text ),
336 rect, string_format_menu_shortcut );
341 ControlPaint.DrawStringDisabled( e.Graphics, item.Text, e.Font,
342 Color.Black, rect_text, string_format );
346 if ( item.MenuBar == false && item.IsPopup )
349 int cx = ThemeEngine.Current.MenuCheckSize.Width;
350 int cy = ThemeEngine.Current.MenuCheckSize.Height;
351 Bitmap bmp = new Bitmap( cx, cy );
352 Graphics gr = Graphics.FromImage( bmp );
353 Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
354 ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Arrow );
355 bmp.MakeTransparent( );
359 e.Graphics.DrawImage( bmp, e.Bounds.X + e.Bounds.Width - cx,
360 e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
364 ControlPaint.DrawImageDisabled( e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
365 e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ), color_back );
372 /* Draw checked or radio */
373 if ( item.MenuBar == false && item.Checked )
376 Rectangle area = e.Bounds;
377 int cx = ThemeEngine.Current.MenuCheckSize.Width;
378 int cy = ThemeEngine.Current.MenuCheckSize.Height;
379 Bitmap bmp = new Bitmap( cx, cy );
380 Graphics gr = Graphics.FromImage( bmp );
381 Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
383 if ( item.RadioCheck )
384 ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Bullet );
386 ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Checkmark );
388 bmp.MakeTransparent( );
389 e.Graphics.DrawImage( bmp, area.X, e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
398 public override void DrawProgressBar( Graphics dc, Rectangle clip_rect, ProgressBar ctrl )
400 Rectangle client_area = ctrl.client_area;
402 Rectangle bar = ctrl.client_area;
404 barpos_pixels = ( ( ctrl.Value - ctrl.Minimum ) * client_area.Width ) / ( ctrl.Maximum - ctrl.Minimum );
406 bar.Width = barpos_pixels;
409 // Draw bar background
410 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( client_area.Left, client_area.Top ), new Point( client_area.Left, client_area.Bottom ), LightColor, Color.White ) )
412 dc.FillRectangle( lgbr, client_area );
416 using ( LinearGradientBrush lgbr = new LinearGradientBrush( bar.Location, new Point( bar.X, bar.Bottom ), Color.White, FocusColor ) )
418 dc.FillRectangle( lgbr, bar );
422 dc.DrawRectangle( ResPool.GetPen( BorderColor ), ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.Width - 1, ctrl.ClientRectangle.Height - 1 );
423 dc.DrawRectangle( ResPool.GetPen( LightColor ), ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.Width - 2, ctrl.ClientRectangle.Height - 2 );
425 #endregion // ProgressBar
428 // TODO: fix RadioButton focus
429 protected override void RadioButton_DrawButton( RadioButton radio_button, Graphics dc, ButtonState state, Rectangle radiobutton_rectangle )
431 SolidBrush sb = new SolidBrush( radio_button.BackColor );
432 dc.FillRectangle( sb, radio_button.ClientRectangle );
435 if ( radio_button.appearance == Appearance.Button )
437 DrawButtonBase( dc, radio_button.ClientRectangle, radio_button );
441 // establish if we are rendering a flat style of some sort
442 if ( radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup )
444 DrawButtonBase( dc, radio_button.ClientRectangle, radio_button );
448 ControlPaint.DrawRadioButton( dc, radiobutton_rectangle, state );
452 #endregion // RadioButton
455 protected override void ScrollBar_DrawThumb( ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
457 if ( bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith( thumb_pos ) )
458 DrawScrollBarThumb( dc, thumb_pos, bar );
461 protected override void ScrollBar_Vertical_Draw_ThumbMoving_None( int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc )
463 Rectangle r = new Rectangle( 0,
464 scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - ( scrollbutton_height * 2 ) );
465 Rectangle intersect = Rectangle.Intersect( clip, r );
467 if ( intersect != Rectangle.Empty )
469 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
471 dc.FillRectangle( lgbr, intersect );
476 protected override void ScrollBar_Vertical_Draw_ThumbMoving_Forward( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
478 Rectangle r = new Rectangle( 0, scrollbutton_height,
479 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
480 Rectangle intersect = Rectangle.Intersect( clip, r );
482 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
484 if ( intersect != Rectangle.Empty )
485 dc.FillRectangle( lgbr, intersect );
488 r.Y = thumb_pos.Y + thumb_pos.Height;
489 r.Width = bar.ClientRectangle.Width;
490 r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
492 intersect = Rectangle.Intersect( clip, r );
493 if ( intersect != Rectangle.Empty )
494 dc.FillRectangle( lgbr, intersect );
498 protected override void ScrollBar_Vertical_Draw_ThumbMoving_Backwards( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
500 Rectangle r = new Rectangle( 0, scrollbutton_height,
501 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
502 Rectangle intersect = Rectangle.Intersect( clip, r );
504 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
506 if ( intersect != Rectangle.Empty )
507 dc.FillRectangle( lgbr, intersect );
510 r.Y = thumb_pos.Y + thumb_pos.Height;
511 r.Width = bar.ClientRectangle.Width;
512 r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
514 intersect = Rectangle.Intersect( clip, r );
515 if ( intersect != Rectangle.Empty )
516 dc.FillRectangle( lgbr, intersect );
520 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc )
522 Rectangle r = new Rectangle( scrollbutton_width,
523 0, bar.ClientRectangle.Width - ( scrollbutton_width * 2 ), bar.ClientRectangle.Height );
524 Rectangle intersect = Rectangle.Intersect( clip, r );
526 if ( intersect != Rectangle.Empty )
528 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
530 dc.FillRectangle( lgbr, intersect );
535 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
537 Rectangle r = new Rectangle( scrollbutton_width, 0,
538 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
539 Rectangle intersect = Rectangle.Intersect( clip, r );
541 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
543 if ( intersect != Rectangle.Empty )
544 dc.FillRectangle( lgbr, intersect );
546 r.X = thumb_pos.X + thumb_pos.Width;
548 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
549 r.Height = bar.ClientRectangle.Height;
551 intersect = Rectangle.Intersect( clip, r );
552 if ( intersect != Rectangle.Empty )
553 dc.FillRectangle( lgbr, intersect );
557 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
559 Rectangle r = new Rectangle( scrollbutton_width, 0,
560 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
561 Rectangle intersect = Rectangle.Intersect( clip, r );
563 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
565 if ( intersect != Rectangle.Empty )
566 dc.FillRectangle( lgbr, intersect );
568 r.X = thumb_pos.X + thumb_pos.Width;
570 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
571 r.Height = bar.ClientRectangle.Height;
573 intersect = Rectangle.Intersect( clip, r );
574 if ( intersect != Rectangle.Empty )
575 dc.FillRectangle( lgbr, intersect );
578 #endregion // ScrollBar
581 protected override void DrawStatusBarPanel( Graphics dc, Rectangle area, int index,
582 SolidBrush br_forecolor, StatusBarPanel panel )
584 int border_size = 3; // this is actually const, even if the border style is none
586 area.Height -= border_size;
587 if ( panel.BorderStyle != StatusBarPanelBorderStyle.None )
589 DrawNiceRoundedBorder( dc, area, BorderColor );
592 if ( panel.Style == StatusBarPanelStyle.OwnerDraw )
594 StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs(
595 dc, panel.Parent.Font, area, index, DrawItemState.Default,
596 panel, panel.Parent.ForeColor, panel.Parent.BackColor );
597 panel.Parent.OnDrawItemInternal( e );
601 int left = area.Left;
602 if ( panel.Icon != null )
605 dc.DrawIcon( panel.Icon, left, area.Top );
606 left += panel.Icon.Width;
609 if ( panel.Text == String.Empty )
612 string text = panel.Text;
613 StringFormat string_format = new StringFormat( );
614 string_format.Trimming = StringTrimming.Character;
615 string_format.FormatFlags = StringFormatFlags.NoWrap;
617 if ( text[ 0 ] == '\t' )
619 string_format.Alignment = StringAlignment.Center;
620 text = text.Substring( 1 );
621 if ( text[ 0 ] == '\t' )
623 string_format.Alignment = StringAlignment.Far;
624 text = text.Substring( 1 );
628 int x = left + border_size;
629 int y = border_size + 2;
630 Rectangle r = new Rectangle( x, y,
631 area.Right - x - border_size,
632 area.Bottom - y - border_size );
634 dc.DrawString( text, panel.Parent.Font, br_forecolor, r, string_format );
637 private void DrawNiceRoundedBorder( Graphics dc, Rectangle area, Color color )
639 Pen pen = ResPool.GetPen( color );
641 Point[] points = new Point[] {
642 new Point( area.Left + 2, area.Top ),
643 new Point( area.Right - 3, area.Top ),
644 new Point( area.Right, area.Top + 3 ),
645 new Point( area.Right, area.Bottom - 2 ),
646 new Point( area.Right - 3, area.Bottom ),
647 new Point( area.Left + 2, area.Bottom ),
648 new Point( area.Left, area.Bottom - 2 ),
649 new Point( area.Left, area.Top + 3 ),
650 new Point( area.Left + 2, area.Top )
653 dc.DrawLines( pen, points );
655 #endregion // StatusBar
657 public override void DrawTabControl( Graphics dc, Rectangle area, TabControl tab )
659 // Do we need to fill the back color? It can't be changed...
660 dc.FillRectangle( GetControlBackBrush( tab.BackColor ), area );
661 Rectangle panel_rect = GetTabPanelRectExt( tab );
663 if ( tab.Appearance == TabAppearance.Normal )
665 CPDrawBorder( dc, panel_rect, BorderColor, 1, ButtonBorderStyle.Solid, BorderColor, 1, ButtonBorderStyle.Solid,
666 BorderColor, 1, ButtonBorderStyle.Solid, BorderColor, 1, ButtonBorderStyle.Solid );
669 if ( tab.Alignment == TabAlignment.Top )
671 for ( int r = tab.TabPages.Count; r > 0; r-- )
673 for ( int i = tab.SliderPos; i < tab.TabPages.Count; i++ )
675 if ( i == tab.SelectedIndex )
677 if ( r != tab.TabPages[ i ].Row )
679 Rectangle rect = tab.GetTabRect( i );
680 if ( !rect.IntersectsWith( area ) )
682 DrawTab( dc, tab.TabPages[ i ], tab, rect, false );
688 for ( int r = 0; r < tab.TabPages.Count; r++ )
690 for ( int i = tab.SliderPos; i < tab.TabPages.Count; i++ )
692 if ( i == tab.SelectedIndex )
694 if ( r != tab.TabPages[ i ].Row )
696 Rectangle rect = tab.GetTabRect( i );
697 if ( !rect.IntersectsWith( area ) )
699 DrawTab( dc, tab.TabPages[ i ], tab, rect, false );
704 if ( tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos )
706 Rectangle rect = tab.GetTabRect( tab.SelectedIndex );
707 if ( rect.IntersectsWith( area ) )
708 DrawTab( dc, tab.TabPages[ tab.SelectedIndex ], tab, rect, true );
711 if ( tab.ShowSlider )
713 Rectangle right = GetTabControlRightScrollRect( tab );
714 Rectangle left = GetTabControlLeftScrollRect( tab );
715 CPDrawScrollButton( dc, right, ScrollButton.Right, tab.RightSliderState );
716 CPDrawScrollButton( dc, left, ScrollButton.Left, tab.LeftSliderState );
720 protected override int DrawTab( Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected )
722 int FlatButtonSpacing = 8;
724 int res = bounds.Width;
726 // we can't fill the background right away because the bounds might be adjusted if the tab is selected
728 if ( tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons )
730 dc.FillRectangle( GetControlBackBrush( tab.BackColor ), bounds );
733 if ( tab.Appearance == TabAppearance.FlatButtons )
735 int width = bounds.Width;
736 bounds.Width += ( FlatButtonSpacing - 2 );
738 CPDrawBorder3D( dc, bounds, Border3DStyle.Etched, Border3DSide.Right );
739 bounds.Width = width;
744 CPDrawBorder3D( dc, bounds, Border3DStyle.Sunken, Border3DSide.All );
746 else if ( tab.Appearance != TabAppearance.FlatButtons )
748 CPDrawBorder3D( dc, bounds, Border3DStyle.Raised, Border3DSide.All );
751 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4 );
754 StringFormat string_format = new StringFormat( );
755 string_format.Alignment = StringAlignment.Center;
756 string_format.LineAlignment = StringAlignment.Center;
757 string_format.FormatFlags = StringFormatFlags.NoWrap;
760 dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
765 Pen border_pen = ResPool.GetPen( BorderColor );
767 switch ( tab.Alignment )
769 case TabAlignment.Top:
771 dc.FillRectangle( GetControlBackBrush( tab.BackColor ), bounds );
775 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
777 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Left + 2, bounds.Bottom ), Color.White, LightColor ) )
779 dc.FillRectangle( lgbr, interior );
783 dc.DrawLine( border_pen, bounds.Left, bounds.Bottom, bounds.Left, bounds.Top + 3 );
784 dc.DrawLine( border_pen, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top );
785 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Top, bounds.Right - 3, bounds.Top );
786 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3 );
787 dc.DrawLine( border_pen, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom );
791 dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left - 1 , bounds.Top, bounds.Right - 1, bounds.Top );
792 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Top + 1, bounds.Right , bounds.Top + 1 );
793 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Top + 2, bounds.Right , bounds.Top + 2 );
796 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
798 if ( page.Text != String.Empty )
800 StringFormat string_format = new StringFormat( );
801 string_format.Alignment = StringAlignment.Center;
802 string_format.LineAlignment = StringAlignment.Center;
803 string_format.FormatFlags = StringFormatFlags.NoWrap;
805 dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
811 case TabAlignment.Bottom:
813 dc.FillRectangle( GetControlBackBrush( tab.BackColor ), bounds );
817 interior = new Rectangle( bounds.Left + 3, bounds.Top, bounds.Width - 3, bounds.Height );
819 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 3, bounds.Top ), new Point( bounds.Left + 3, bounds.Bottom ), Color.White, LightColor ) )
821 dc.FillRectangle( lgbr, interior );
825 dc.DrawLine( border_pen, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 3 );
826 dc.DrawLine( border_pen, bounds.Left, bounds.Bottom - 3, bounds.Left + 3, bounds.Bottom );
827 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom );
828 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Bottom, bounds.Right, bounds.Bottom - 3 );
829 dc.DrawLine( border_pen, bounds.Right, bounds.Bottom - 3, bounds.Right, bounds.Top );
833 dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left - 1 , bounds.Bottom, bounds.Right - 1, bounds.Bottom );
834 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Bottom - 1, bounds.Right , bounds.Bottom - 1 );
835 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Bottom - 2, bounds.Right , bounds.Bottom - 2 );
838 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
840 if ( page.Text != String.Empty )
842 StringFormat string_format = new StringFormat( );
843 string_format.Alignment = StringAlignment.Center;
844 string_format.LineAlignment = StringAlignment.Center;
845 string_format.FormatFlags = StringFormatFlags.NoWrap;
847 dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
853 case TabAlignment.Left:
855 dc.FillRectangle( GetControlBackBrush( tab.BackColor ), bounds );
859 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
861 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Right, bounds.Top + 2 ), LightColor, Color.White ) )
863 dc.FillRectangle( lgbr, interior );
867 dc.DrawLine( border_pen, bounds.Right, bounds.Top, bounds.Left + 3, bounds.Top );
868 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Top, bounds.Left, bounds.Top + 3 );
869 dc.DrawLine( border_pen, bounds.Left, bounds.Top + 3, bounds.Left, bounds.Bottom - 3 );
870 dc.DrawLine( border_pen, bounds.Left, bounds.Bottom - 3, bounds.Left + 3, bounds.Bottom );
871 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Bottom, bounds.Right, bounds.Bottom );
875 dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left , bounds.Top + 1, bounds.Left , bounds.Bottom - 1 );
876 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left + 1 , bounds.Top, bounds.Left + 1 , bounds.Bottom );
877 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left + 2 , bounds.Top, bounds.Left + 2 , bounds.Bottom );
880 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
882 if ( page.Text != String.Empty )
884 StringFormat string_format = new StringFormat( );
885 // Flip the text around
886 string_format.Alignment = StringAlignment.Center;
887 string_format.LineAlignment = StringAlignment.Center;
888 string_format.FormatFlags = StringFormatFlags.NoWrap;
889 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
890 int wo = interior.Width / 2;
891 int ho = interior.Height / 2;
892 dc.TranslateTransform( interior.X + wo, interior.Y + ho );
893 dc.RotateTransform( 180 );
894 dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), 0, 0, string_format );
895 dc.ResetTransform( );
901 // TabAlignment.Right
903 dc.FillRectangle( GetControlBackBrush( tab.BackColor ), bounds );
907 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
909 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Right, bounds.Top + 2 ), Color.White, LightColor ) )
911 dc.FillRectangle( lgbr, interior );
915 dc.DrawLine( border_pen, bounds.Left, bounds.Top, bounds.Right - 3, bounds.Top );
916 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3 );
917 dc.DrawLine( border_pen, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom - 3 );
918 dc.DrawLine( border_pen, bounds.Right, bounds.Bottom - 3, bounds.Right - 3, bounds.Bottom );
919 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Bottom, bounds.Left, bounds.Bottom );
923 dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Right , bounds.Top + 1, bounds.Right , bounds.Bottom - 1 );
924 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Right - 1 , bounds.Top, bounds.Right - 1 , bounds.Bottom );
925 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Right - 2 , bounds.Top, bounds.Right - 2 , bounds.Bottom );
928 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
930 if ( page.Text != String.Empty )
932 StringFormat string_format = new StringFormat( );
933 string_format.Alignment = StringAlignment.Center;
934 string_format.LineAlignment = StringAlignment.Center;
935 string_format.FormatFlags = StringFormatFlags.NoWrap;
936 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
938 dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
949 public override void CPDrawComboButton( Graphics dc, Rectangle rectangle, ButtonState state )
951 Point[] arrow = new Point[ 3 ];
961 Color first_color = Color.White;
962 Color second_color = NormalColor;
965 rectangle.Height += 1;
966 rectangle.Width += 1;
968 if ( ( state & ButtonState.Checked ) != 0 )
970 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControlLightLight, ColorControlLight ), rectangle );
973 if ( ( state & ButtonState.Flat ) != 0 )
975 first_color = NormalColor;
976 second_color = Color.White;
980 if ( ( state & ( ButtonState.Pushed | ButtonState.Checked ) ) != 0 )
982 first_color = Color.White;
983 second_color = PressedColor;
987 // CPDrawBorder3D( graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl );
991 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( rectangle.X, rectangle.Y ), new Point( rectangle.X, rectangle.Bottom - 1 ), first_color, second_color ) )
993 dc.FillRectangle( lgbr, rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 3 );
996 Point[] points = new Point[] {
997 new Point( rectangle.X + 2, rectangle.Y ),
998 new Point( rectangle.Right - 3, rectangle.Y ),
999 new Point( rectangle.Right - 1, rectangle.Y + 2 ),
1000 new Point( rectangle.Right - 1, rectangle.Bottom - 3 ),
1001 new Point( rectangle.Right - 3, rectangle.Bottom - 1 ),
1002 new Point( rectangle.X + 2, rectangle.Bottom - 1 ),
1003 new Point( rectangle.X, rectangle.Bottom - 3 ),
1004 new Point( rectangle.X, rectangle.Y + 2 ),
1005 new Point( rectangle.X + 2, rectangle.Y )
1008 dc.DrawPolygon( ResPool.GetPen( BorderColor ), points );
1010 rect = new Rectangle( rectangle.X + rectangle.Width / 4, rectangle.Y + rectangle.Height / 4, rectangle.Width / 2, rectangle.Height / 2 );
1011 centerX = rect.Left + rect.Width / 2;
1012 centerY = rect.Top + rect.Height / 2;
1013 shiftX = Math.Max( 1, rect.Width / 8 );
1014 shiftY = Math.Max( 1, rect.Height / 8 );
1016 if ( ( state & ButtonState.Pushed ) != 0 )
1025 P1 = new Point( rect.Left, centerY );
1026 P2 = new Point( centerX, rect.Bottom );
1027 P3 = new Point( rect.Right, centerY );
1033 /* Draw the arrow */
1034 if ( ( state & ButtonState.Inactive ) != 0 )
1036 using ( Pen pen = new Pen( SystemColors.ControlLightLight, 2 ) )
1038 dc.DrawLines( pen, arrow );
1041 /* Move away from the shadow */
1042 P1.X -= 1; P1.Y -= 1;
1043 P2.X -= 1; P2.Y -= 1;
1044 P3.X -= 1; P3.Y -= 1;
1050 using ( Pen pen = new Pen( SystemColors.ControlDark, 2 ) )
1052 dc.DrawLines( pen, arrow );
1057 using ( Pen pen = new Pen( SystemColors.ControlText, 2 ) )
1059 dc.DrawLines( pen, arrow );
1064 /* Scroll button: regular button + direction arrow */
1065 public override void CPDrawScrollButton( Graphics dc, Rectangle area, ScrollButton scroll_button_type, ButtonState state )
1067 bool enabled = ( state == ButtonState.Inactive ) ? false: true;
1069 DrawScrollButtonPrimitive( dc, area, state, scroll_button_type );
1071 if ( area.Width < 12 || area.Height < 12 ) /* Cannot see a thing at smaller sizes */
1077 pen = new Pen( arrow_color, 2 );
1079 pen = new Pen( ColorGrayText, 2 );
1083 int centerX = area.Left + area.Width / 2;
1084 int centerY = area.Top + area.Height / 2;
1088 if ( ( state & ButtonState.Pushed ) != 0 )
1091 Point[] arrow = new Point[ 3 ];
1093 switch ( scroll_button_type )
1095 case ScrollButton.Down:
1097 arrow[ 0 ] = new Point( centerX - 3, centerY - 2 );
1098 arrow[ 1 ] = new Point( centerX, centerY + 2 );
1099 arrow[ 2 ] = new Point( centerX + 3, centerY - 2 );
1101 case ScrollButton.Up:
1103 arrow[ 0 ] = new Point( centerX - 3, centerY + 2 );
1104 arrow[ 1 ] = new Point( centerX, centerY - 2 );
1105 arrow[ 2 ] = new Point( centerX + 3, centerY + 2 );
1107 case ScrollButton.Left:
1109 arrow[ 0 ] = new Point( centerX + 2, centerY - 3 );
1110 arrow[ 1 ] = new Point( centerX - 2, centerY );
1111 arrow[ 2 ] = new Point( centerX + 2, centerY + 3 );
1113 case ScrollButton.Right:
1115 arrow[ 0 ] = new Point( centerX - 2, centerY - 3 );
1116 arrow[ 1 ] = new Point( centerX + 2, centerY );
1117 arrow[ 2 ] = new Point( centerX - 2, centerY + 3 );
1123 dc.DrawLines( pen, arrow );
1128 public override void CPDrawSizeGrip( Graphics dc, Color backColor, Rectangle bounds )
1130 Point pt = new Point( bounds.Right - 4, bounds.Bottom - 4 );
1132 using ( Bitmap bmp = new Bitmap( 4, 4 ) )
1134 using ( Graphics gr = Graphics.FromImage( bmp ) )
1136 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 4, 4 ), PressedColor, Color.White ) )
1137 gr.FillEllipse( lgbr, new Rectangle( 0, 0, 4, 4 ) );
1140 dc.DrawImage( bmp, pt );
1141 dc.DrawImage( bmp, pt.X, pt.Y - 5 );
1142 dc.DrawImage( bmp, pt.X, pt.Y - 10 );
1143 dc.DrawImage( bmp, pt.X - 5, pt.Y );
1144 dc.DrawImage( bmp, pt.X - 10, pt.Y );
1145 dc.DrawImage( bmp, pt.X - 5, pt.Y - 5 );
1149 private void DrawScrollBarThumb( Graphics dc, Rectangle area, ScrollBar bar )
1151 LinearGradientBrush lgbr = null;
1154 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 1, area.Y ), Color.White, NormalColor );
1156 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), Color.White, NormalColor );
1158 Pen pen = ResPool.GetPen( BorderColor );
1160 Point[] points = new Point[] {
1161 new Point( area.X + 2, area.Y ),
1162 new Point( area.Right - 3, area.Y ),
1163 new Point( area.Right - 1, area.Y + 2 ),
1164 new Point( area.Right - 1, area.Bottom - 3 ),
1165 new Point( area.Right - 3, area.Bottom - 1 ),
1166 new Point( area.X + 2, area.Bottom - 1 ),
1167 new Point( area.X, area.Bottom - 3 ),
1168 new Point( area.X, area.Y + 2 ),
1169 new Point( area.X + 2, area.Y )
1174 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 3 );
1175 dc.DrawPolygon( pen, points );
1177 // draw grip lines only if stere is enough space
1178 if ( area.Height > 12 )
1180 int mid_y = area.Y + ( area.Height / 2 );
1181 int mid_x = area.X + ( area.Width / 2 );
1183 using ( Pen lpen = new Pen( MouseOverColor, 2 ) )
1185 dc.DrawLine( lpen, mid_x - 3, mid_y, mid_x + 3, mid_y );
1186 dc.DrawLine( lpen, mid_x - 3, mid_y - 4, mid_x + 3, mid_y - 4 );
1187 dc.DrawLine( lpen, mid_x - 3, mid_y + 4, mid_x + 3, mid_y + 4 );
1190 Pen spen = ResPool.GetPen( Color.White );
1191 dc.DrawLine( spen, mid_x - 3, mid_y - 1, mid_x + 3, mid_y - 1 );
1192 dc.DrawLine( spen, mid_x - 3, mid_y - 5, mid_x + 3, mid_y - 5 );
1193 dc.DrawLine( spen, mid_x - 3, mid_y + 3, mid_x + 3, mid_y + 3 );
1198 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 3, area.Height - 2 );
1199 dc.DrawPolygon( pen, points );
1201 // draw grip lines only if stere is enough space
1202 if ( area.Width > 12 )
1204 int mid_x = area.X + ( area.Width / 2 );
1205 int mid_y = area.Y + ( area.Height / 2 );
1207 using ( Pen lpen = new Pen( MouseOverColor, 2 ) )
1209 dc.DrawLine( lpen, mid_x, mid_y - 3, mid_x, mid_y + 3 );
1210 dc.DrawLine( lpen, mid_x - 4, mid_y - 3, mid_x - 4, mid_y + 3 );
1211 dc.DrawLine( lpen, mid_x + 4, mid_y - 3, mid_x + 4, mid_y + 3 );
1214 Pen spen = ResPool.GetPen( Color.White );
1215 dc.DrawLine( spen, mid_x - 1, mid_y - 3, mid_x - 1, mid_y + 3 );
1216 dc.DrawLine( spen, mid_x - 5, mid_y - 3, mid_x - 5, mid_y + 3 );
1217 dc.DrawLine( spen, mid_x + 3, mid_y - 3, mid_x + 3, mid_y + 3 );
1224 /* Nice scroll button */
1225 public void DrawScrollButtonPrimitive( Graphics dc, Rectangle area, ButtonState state, ScrollButton scroll_button_type )
1227 Pen pen = ResPool.GetPen( BorderColor );
1231 if ( ( state & ButtonState.Pushed ) == ButtonState.Pushed )
1232 use_color = PressedColor;
1234 use_color = NormalColor;
1236 Point[] points = new Point[] {
1237 new Point( area.X + 2, area.Y ),
1238 new Point( area.Right - 3, area.Y ),
1239 new Point( area.Right - 1, area.Y + 2 ),
1240 new Point( area.Right - 1, area.Bottom - 3 ),
1241 new Point( area.Right - 3, area.Bottom - 1 ),
1242 new Point( area.X + 2, area.Bottom - 1 ),
1243 new Point( area.X, area.Bottom - 3 ),
1244 new Point( area.X, area.Y + 2 ),
1245 new Point( area.X + 2, area.Y )
1248 LinearGradientBrush lgbr = null;
1250 switch ( scroll_button_type )
1252 case ScrollButton.Left:
1253 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 2, area.Y ), use_color, Color.White );
1254 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 4, area.Height - 2 );
1255 dc.DrawPolygon( pen, points );
1257 case ScrollButton.Right:
1258 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 2, area.Y ), Color.White, use_color );
1259 dc.FillRectangle( lgbr, area.X, area.Y + 1, area.Width - 2, area.Height - 2 );
1260 dc.DrawPolygon( pen, points );
1262 case ScrollButton.Up:
1263 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), use_color, Color.White );
1264 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1265 dc.DrawPolygon( pen, points );
1267 case ScrollButton.Down:
1268 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), Color.White, use_color );
1269 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 3 );
1270 dc.DrawPolygon( pen, points );