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 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 ) );
55 static Bitmap size_grip_bmp = CreateSizegripDot();
57 #region Principal Theme Methods
60 ColorControl = NiceBackColor;
61 always_draw_hotkeys = true;
64 public override Color DefaultControlBackColor
66 get { return NiceBackColor; }
69 public override Color DefaultWindowBackColor
71 get { return NiceBackColor; }
74 public override Color ColorControl {
75 get { return NiceBackColor;}
78 static Bitmap CreateSizegripDot()
80 Bitmap bmp = new Bitmap( 4, 4 );
81 using ( Graphics dc = Graphics.FromImage( bmp ) )
83 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
84 dc.SmoothingMode = SmoothingMode.AntiAlias;
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 ) );
89 dc.SmoothingMode = old_smoothing_mode;
94 #endregion // Internal Methods
97 protected override void ButtonBase_DrawButton (ButtonBase button, Graphics dc)
99 bool check_or_radio = false;
100 bool check_or_radio_checked = false;
102 Color use_color = NormalColor;
103 Color first_color = Color.White;
105 dc.FillRectangle (ResPool.GetSolidBrush (button.BackColor), button.ClientRectangle);
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;
115 if (button.has_focus && !check_or_radio && button.is_enabled)
116 first_color = FocusColorLight;
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;
131 if (!button.is_pressed && button.is_entered && !check_or_radio_checked)
132 use_color = MouseOverColor;
134 if (button.is_pressed || check_or_radio_checked)
135 use_color = PressedColor;
139 Rectangle buttonRectangle;
141 int width = button.ClientSize.Width;
142 int height = button.ClientSize.Height;
144 // set up the button rectangle
145 buttonRectangle = button.ClientRectangle;
147 // Fill button with a nice linear gradient brush
148 Rectangle lgbRectangle = Rectangle.Inflate (buttonRectangle, -1, -1);
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);
155 lgbr = new LinearGradientBrush (new Point (0, 0), new Point (0, height - 1), first_color, use_color);
156 dc.FillRectangle (lgbr, lgbRectangle);
159 if (button.has_focus && !check_or_radio)
162 Point[] points = new Point [] {
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),
174 Pen pen = ResPool.GetPen (BorderColor);
175 dc.DrawLines (pen, points);
179 protected override void ButtonBase_DrawFocus( ButtonBase button, Graphics dc )
181 if ((button is RadioButton) || (button is CheckBox))
184 int width = button.ClientSize.Width;
185 int height = button.ClientSize.Height;
187 Point[] points = new Point[] {
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 ),
199 Pen pen = ResPool.GetPen( FocusColor );
200 dc.DrawLines( pen, points );
203 protected override void ButtonBase_DrawText( ButtonBase button, Graphics dc )
205 if ( !( button is CheckBox ) && !(button is RadioButton ) )
207 base.ButtonBase_DrawText( button, dc );
210 #endregion // ButtonBase
216 public override void DrawComboBoxEditDecorations( Graphics dc, ComboBox ctrl, Rectangle cl )
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);
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);
242 public override void DrawComboListBoxDecorations( Graphics dc, ComboBox ctrl, Rectangle cl )
244 if ( ctrl.DropDownStyle == ComboBoxStyle.Simple )
246 DrawComboBoxEditDecorations( dc, ctrl, cl );
250 dc.DrawRectangle( ResPool.GetPen( ColorWindowFrame ), cl.X, cl.Y, cl.Width - 1, cl.Height - 1 );
256 public override void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect)
258 if (menu.Height == 0)
259 CalcMenuBarSize (dc, menu, rect.Width);
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;
266 rect.Height = menu.Height;
267 dc.FillRectangle (ResPool.GetSolidBrush (NiceBackColor), rect);
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));
279 public override void DrawMenuItem (MenuItem item, DrawItemEventArgs e)
281 StringFormat string_format;
282 Rectangle rect_text = e.Bounds;
284 if (item.Visible == false)
288 string_format = string_format_menu_menubar_text;
290 string_format = string_format_menu_text;
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);
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);
303 rect_text.X += MenuCheckSize.Width;
305 if (item.BarBreak) { /* Draw vertical break bar*/
306 Rectangle rect = e.Bounds;
309 rect.Height = item.MenuHeight - 6;
311 e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
312 rect.X, rect.Y , rect.X, rect.Y + rect.Height);
314 e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
315 rect.X + 1, rect.Y , rect.X +1, rect.Y + rect.Height);
318 Color color_text = ColorMenuText;
319 Color color_back = NiceBackColor;
321 /* Draw background */
322 Rectangle rect_back = e.Bounds;
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);
330 e.Graphics.DrawRectangle (ResPool.GetPen (BorderColor), rect_back.X, rect_back.Y, rect_back.Width, rect_back.Height - 1);
332 e.Graphics.FillRectangle (ResPool.GetSolidBrush (NiceBackColor), rect_back);
336 e.Graphics.DrawString (item.Text, e.Font,
337 ResPool.GetSolidBrush (color_text),
338 rect_text, string_format);
340 if (!item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut) {
341 string str = item.GetShortCutText ();
342 Rectangle rect = rect_text;
344 rect.Width -= item.XTab;
346 e.Graphics.DrawString (str, e.Font, ResPool.GetSolidBrush (color_text),
347 rect, string_format_menu_shortcut);
351 ControlPaint.DrawStringDisabled (e.Graphics, item.Text, e.Font,
352 Color.Black, rect_text, string_format);
356 if (item.MenuBar == false && item.IsPopup || item.MdiList) {
358 int cx = MenuCheckSize.Width;
359 int cy = MenuCheckSize.Height;
360 Bitmap bmp = CreateGlyphBitmap (new Size (cx, cy), MenuGlyph.Arrow, color_text);
363 e.Graphics.DrawImage (bmp, e.Bounds.X + e.Bounds.Width - cx,
364 e.Bounds.Y + ((e.Bounds.Height - cy) /2));
366 ControlPaint.DrawImageDisabled (e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
367 e.Bounds.Y + ((e.Bounds.Height - cy) /2), color_back);
373 /* Draw checked or radio */
374 if (item.MenuBar == false && item.Checked) {
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);
381 e.Graphics.DrawImage (bmp, area.X, e.Bounds.Y + ((e.Bounds.Height - cy) / 2));
387 public override void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect)
390 dc.FillRectangle (ResPool.GetSolidBrush
391 (NiceBackColor), cliparea);
393 /* Draw menu borders */
394 dc.DrawLine (ResPool.GetPen (ColorHighlightText),
395 rect.X, rect.Y, rect.X + rect.Width, rect.Y);
397 dc.DrawLine (ResPool.GetPen (ColorHighlightText),
398 rect.X, rect.Y, rect.X, rect.Y + rect.Height);
400 dc.DrawLine (ResPool.GetPen (ColorControlDark),
401 rect.X + rect.Width - 1 , rect.Y , rect.X + rect.Width - 1, rect.Y + rect.Height);
403 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
404 rect.X + rect.Width, rect.Y , rect.X + rect.Width, rect.Y + rect.Height);
406 dc.DrawLine (ResPool.GetPen (ColorControlDark),
407 rect.X , rect.Y + rect.Height - 1 , rect.X + rect.Width - 1, rect.Y + rect.Height -1);
409 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
410 rect.X , rect.Y + rect.Height, rect.X + rect.Width - 1, rect.Y + rect.Height);
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));
423 public override void DrawProgressBar( Graphics dc, Rectangle clip_rect, ProgressBar ctrl )
425 Rectangle client_area = ctrl.client_area;
427 Rectangle bar = ctrl.client_area;
429 barpos_pixels = ( ( ctrl.Value - ctrl.Minimum ) * client_area.Width ) / ( ctrl.Maximum - ctrl.Minimum );
431 bar.Width = barpos_pixels;
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 ) )
437 dc.FillRectangle( lgbr, client_area );
441 using ( LinearGradientBrush lgbr = new LinearGradientBrush( bar.Location, new Point( bar.X, bar.Bottom ), Color.White, PressedColor ) )
443 dc.FillRectangle( lgbr, bar );
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 );
450 #endregion // ProgressBar
453 protected override void RadioButton_DrawFocus(RadioButton radio_button, Graphics dc, Rectangle text_rectangle)
455 if (radio_button.Focused && radio_button.appearance != Appearance.Button)
457 if (radio_button.FlatStyle != FlatStyle.Flat && radio_button.FlatStyle != FlatStyle.Popup)
459 DrawInnerFocusRectangle (dc, text_rectangle, radio_button.BackColor);
463 #endregion // RadioButton
466 protected override void ScrollBar_DrawThumb( ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
468 if ( bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith( thumb_pos ) )
469 DrawScrollBarThumb( dc, thumb_pos, bar );
472 protected override void ScrollBar_Vertical_Draw_ThumbMoving_None( int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc )
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 );
478 if ( intersect != Rectangle.Empty )
480 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
482 dc.FillRectangle( lgbr, intersect );
487 protected override void ScrollBar_Vertical_Draw_ThumbMoving_Forward( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
489 Rectangle r = new Rectangle( 0, scrollbutton_height,
490 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
491 Rectangle intersect = Rectangle.Intersect( clip, r );
493 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
495 if ( intersect != Rectangle.Empty )
496 dc.FillRectangle( lgbr, intersect );
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;
503 intersect = Rectangle.Intersect( clip, r );
504 if ( intersect != Rectangle.Empty )
505 dc.FillRectangle( lgbr, intersect );
509 protected override void ScrollBar_Vertical_Draw_ThumbMoving_Backwards( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
511 Rectangle r = new Rectangle( 0, scrollbutton_height,
512 bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
513 Rectangle intersect = Rectangle.Intersect( clip, r );
515 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
517 if ( intersect != Rectangle.Empty )
518 dc.FillRectangle( lgbr, intersect );
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;
525 intersect = Rectangle.Intersect( clip, r );
526 if ( intersect != Rectangle.Empty )
527 dc.FillRectangle( lgbr, intersect );
531 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc )
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 );
537 if ( intersect != Rectangle.Empty )
539 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
541 dc.FillRectangle( lgbr, intersect );
546 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
548 Rectangle r = new Rectangle( scrollbutton_width, 0,
549 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
550 Rectangle intersect = Rectangle.Intersect( clip, r );
552 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
554 if ( intersect != Rectangle.Empty )
555 dc.FillRectangle( lgbr, intersect );
557 r.X = thumb_pos.X + thumb_pos.Width;
559 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
560 r.Height = bar.ClientRectangle.Height;
562 intersect = Rectangle.Intersect( clip, r );
563 if ( intersect != Rectangle.Empty )
564 dc.FillRectangle( lgbr, intersect );
568 protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
570 Rectangle r = new Rectangle( scrollbutton_width, 0,
571 thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
572 Rectangle intersect = Rectangle.Intersect( clip, r );
574 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
576 if ( intersect != Rectangle.Empty )
577 dc.FillRectangle( lgbr, intersect );
579 r.X = thumb_pos.X + thumb_pos.Width;
581 r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
582 r.Height = bar.ClientRectangle.Height;
584 intersect = Rectangle.Intersect( clip, r );
585 if ( intersect != Rectangle.Empty )
586 dc.FillRectangle( lgbr, intersect );
589 #endregion // ScrollBar
592 protected override void DrawStatusBarPanel( Graphics dc, Rectangle area, int index,
593 SolidBrush br_forecolor, StatusBarPanel panel )
595 int border_size = 3; // this is actually const, even if the border style is none
597 area.Height -= border_size;
598 if ( panel.BorderStyle != StatusBarPanelBorderStyle.None )
600 DrawNiceRoundedBorder( dc, area, BorderColor );
603 if ( panel.Style == StatusBarPanelStyle.OwnerDraw )
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 );
612 int left = area.Left;
613 if ( panel.Icon != null )
616 dc.DrawIcon( panel.Icon, left, area.Top );
617 left += panel.Icon.Width;
620 if ( panel.Text == String.Empty )
623 string text = panel.Text;
624 StringFormat string_format = new StringFormat( );
625 string_format.Trimming = StringTrimming.Character;
626 string_format.FormatFlags = StringFormatFlags.NoWrap;
628 if ( text[ 0 ] == '\t' )
630 string_format.Alignment = StringAlignment.Center;
631 text = text.Substring( 1 );
632 if ( text[ 0 ] == '\t' )
634 string_format.Alignment = StringAlignment.Far;
635 text = text.Substring( 1 );
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 );
645 dc.DrawString( text, panel.Parent.Font, br_forecolor, r, string_format );
648 private void DrawNiceRoundedBorder( Graphics dc, Rectangle area, Color color )
650 Pen pen = ResPool.GetPen( color );
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 )
664 dc.DrawLines( pen, points );
666 #endregion // StatusBar
668 public override void DrawTabControl( Graphics dc, Rectangle area, TabControl tab )
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 );
674 if ( tab.Appearance == TabAppearance.Normal )
676 CPDrawBorder( dc, panel_rect, BorderColor, 1, ButtonBorderStyle.Solid, BorderColor, 1, ButtonBorderStyle.Solid,
677 BorderColor, 1, ButtonBorderStyle.Solid, BorderColor, 1, ButtonBorderStyle.Solid );
680 if ( tab.Alignment == TabAlignment.Top )
682 for ( int r = tab.TabPages.Count; r > 0; r-- )
684 for ( int i = tab.SliderPos; i < tab.TabPages.Count; i++ )
686 if ( i == tab.SelectedIndex )
688 if ( r != tab.TabPages[ i ].Row )
690 Rectangle rect = tab.GetTabRect( i );
691 if ( !rect.IntersectsWith( area ) )
693 DrawTab( dc, tab.TabPages[ i ], tab, rect, false );
699 for ( int r = 0; r < tab.TabPages.Count; r++ )
701 for ( int i = tab.SliderPos; i < tab.TabPages.Count; i++ )
703 if ( i == tab.SelectedIndex )
705 if ( r != tab.TabPages[ i ].Row )
707 Rectangle rect = tab.GetTabRect( i );
708 if ( !rect.IntersectsWith( area ) )
710 DrawTab( dc, tab.TabPages[ i ], tab, rect, false );
715 if ( tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos )
717 Rectangle rect = tab.GetTabRect( tab.SelectedIndex );
718 if ( rect.IntersectsWith( area ) )
719 DrawTab( dc, tab.TabPages[ tab.SelectedIndex ], tab, rect, true );
722 if ( tab.ShowSlider )
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 );
731 protected override int DrawTab( Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected )
733 int FlatButtonSpacing = 8;
735 int res = bounds.Width;
737 // we can't fill the background right away because the bounds might be adjusted if the tab is selected
739 if ( tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons )
741 dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), bounds );
744 if ( tab.Appearance == TabAppearance.FlatButtons )
746 int width = bounds.Width;
747 bounds.Width += ( FlatButtonSpacing - 2 );
749 CPDrawBorder3D( dc, bounds, Border3DStyle.Etched, Border3DSide.Right );
750 bounds.Width = width;
755 CPDrawBorder3D( dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
757 else if ( tab.Appearance != TabAppearance.FlatButtons )
759 CPDrawBorder3D( dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
762 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4 );
765 StringFormat string_format = new StringFormat( );
766 string_format.Alignment = StringAlignment.Center;
767 string_format.LineAlignment = StringAlignment.Center;
768 string_format.FormatFlags = StringFormatFlags.NoWrap;
771 dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
776 Pen border_pen = ResPool.GetPen( BorderColor );
778 dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), bounds );
780 switch ( tab.Alignment )
782 case TabAlignment.Top:
786 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
788 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Left + 2, bounds.Bottom ), Color.White, LightColor ) )
790 dc.FillRectangle( lgbr, interior );
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 );
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 );
807 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
809 if ( page.Text != String.Empty )
811 StringFormat string_format = new StringFormat( );
812 string_format.Alignment = StringAlignment.Center;
813 string_format.LineAlignment = StringAlignment.Center;
814 string_format.FormatFlags = StringFormatFlags.NoWrap;
816 dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
822 case TabAlignment.Bottom:
826 interior = new Rectangle( bounds.Left + 3, bounds.Top, bounds.Width - 3, bounds.Height );
828 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 3, bounds.Top ), new Point( bounds.Left + 3, bounds.Bottom ), Color.White, LightColor ) )
830 dc.FillRectangle( lgbr, interior );
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 );
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 );
847 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
849 if ( page.Text != String.Empty )
851 StringFormat string_format = new StringFormat( );
852 string_format.Alignment = StringAlignment.Center;
853 string_format.LineAlignment = StringAlignment.Center;
854 string_format.FormatFlags = StringFormatFlags.NoWrap;
856 dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
862 case TabAlignment.Left:
866 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
868 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Right, bounds.Top + 2 ), LightColor, Color.White ) )
870 dc.FillRectangle( lgbr, interior );
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 );
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 );
887 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
889 if ( page.Text != String.Empty )
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( );
908 // TabAlignment.Right
912 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
914 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Right, bounds.Top + 2 ), Color.White, LightColor ) )
916 dc.FillRectangle( lgbr, interior );
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 );
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 );
933 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
935 if ( page.Text != String.Empty )
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;
943 dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
954 // public override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) {
955 // CPDrawBorder3D(graphics, rectangle, style, sides, ColorControl);
958 protected override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color)
963 Pen penBottomRightInner;
964 Rectangle rect= new Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
966 if ((style & Border3DStyle.Adjust) != 0) {
973 penTopLeft = penTopLeftInner = penBottomRight = penBottomRightInner = ResPool.GetPen (control_color);
975 CPColor cpcolor = ResPool.GetCPColor (control_color);
978 case Border3DStyle.Raised:
979 penTopLeftInner = ResPool.GetPen (cpcolor.LightLight);
980 penBottomRight = ResPool.GetPen (cpcolor.Dark);
981 penBottomRightInner = ResPool.GetPen (BorderColor);
983 case Border3DStyle.Sunken:
984 penTopLeft = ResPool.GetPen (BorderColor);
985 penTopLeftInner = ResPool.GetPen (cpcolor.Dark);
986 penBottomRight = ResPool.GetPen (cpcolor.LightLight);
988 case Border3DStyle.Etched:
989 penTopLeft = penBottomRightInner = ResPool.GetPen (BorderColor);
990 penTopLeftInner = penBottomRight = ResPool.GetPen (cpcolor.LightLight);
992 case Border3DStyle.RaisedOuter:
993 penBottomRight = ResPool.GetPen (cpcolor.Dark);
995 case Border3DStyle.SunkenOuter:
996 penTopLeft = ResPool.GetPen (BorderColor);
997 penBottomRight = ResPool.GetPen (cpcolor.LightLight);
999 case Border3DStyle.RaisedInner:
1000 penTopLeft = ResPool.GetPen (cpcolor.LightLight);
1001 penBottomRight = ResPool.GetPen (BorderColor);
1003 case Border3DStyle.SunkenInner:
1004 penTopLeft = ResPool.GetPen (cpcolor.Dark);
1006 case Border3DStyle.Flat:
1007 penTopLeft = penBottomRight = ResPool.GetPen (BorderColor);
1009 case Border3DStyle.Bump:
1010 penTopLeftInner = penBottomRight = ResPool.GetPen (cpcolor.Dark);
1016 if ((sides & Border3DSide.Middle) != 0) {
1017 graphics.FillRectangle (ResPool.GetSolidBrush (control_color), rect);
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);
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);
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);
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);
1041 public override void CPDrawComboButton( Graphics dc, Rectangle rectangle, ButtonState state )
1043 Point[] arrow = new Point[ 3 ];
1053 Color first_color = Color.White;
1054 Color second_color = NormalColor;
1056 // rectangle.Width += 1;
1058 if ( ( state & ButtonState.Checked ) != 0 )
1060 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControlLightLight, ColorControlLight ), rectangle );
1063 dc.FillRectangle( ResPool.GetSolidBrush( Color.White ), rectangle );
1065 if ( ( state & ButtonState.Flat ) != 0 )
1067 first_color = NormalColor;
1068 second_color = Color.White;
1072 if ( ( state & ( ButtonState.Pushed | ButtonState.Checked ) ) != 0 )
1074 first_color = Color.White;
1075 second_color = PressedColor;
1079 // CPDrawBorder3D( graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl );
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 ) )
1085 dc.FillRectangle( lgbr, rectangle.X + 2, rectangle.Y + 1, rectangle.Width - 4, rectangle.Height - 3 );
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 )
1100 dc.DrawPolygon( ResPool.GetPen( BorderColor ), points );
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 );
1108 if ( ( state & ButtonState.Pushed ) != 0 )
1117 P1 = new Point( rect.Left, centerY );
1118 P2 = new Point( centerX, rect.Bottom );
1119 P3 = new Point( rect.Right, centerY );
1125 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
1126 dc.SmoothingMode = SmoothingMode.AntiAlias;
1128 /* Draw the arrow */
1129 if ( ( state & ButtonState.Inactive ) != 0 )
1131 using ( Pen pen = new Pen( SystemColors.ControlLightLight, 2 ) )
1133 dc.DrawLines( pen, arrow );
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;
1145 using ( Pen pen = new Pen( SystemColors.ControlDark, 2 ) )
1147 dc.DrawLines( pen, arrow );
1152 using ( Pen pen = new Pen( SystemColors.ControlText, 2 ) )
1154 dc.DrawLines( pen, arrow );
1158 dc.SmoothingMode = old_smoothing_mode;
1161 /* Scroll button: regular button + direction arrow */
1162 public override void CPDrawScrollButton( Graphics dc, Rectangle area, ScrollButton scroll_button_type, ButtonState state )
1164 bool enabled = ( state == ButtonState.Inactive ) ? false: true;
1166 DrawScrollButtonPrimitive( dc, area, state, scroll_button_type );
1171 pen = new Pen( arrow_color, 2 );
1173 pen = new Pen( ColorGrayText, 2 );
1177 int centerX = area.Left + area.Width / 2;
1178 int centerY = area.Top + area.Height / 2;
1182 if ( ( state & ButtonState.Pushed ) != 0 )
1187 if ( area.Width < 12 || area.Height < 12 ) {
1192 Point[] arrow = new Point [3];
1194 switch (scroll_button_type) {
1195 case ScrollButton.Down:
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);
1201 case ScrollButton.Up:
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);
1207 case ScrollButton.Left:
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);
1213 case ScrollButton.Right:
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);
1223 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
1224 dc.SmoothingMode = SmoothingMode.AntiAlias;
1226 dc.DrawLines (pen, arrow);
1228 dc.SmoothingMode = old_smoothing_mode;
1233 public override void CPDrawSizeGrip( Graphics dc, Color backColor, Rectangle bounds )
1235 Point pt = new Point( bounds.Right - 4, bounds.Bottom - 4 );
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 );
1245 private void DrawScrollBarThumb( Graphics dc, Rectangle area, ScrollBar bar )
1247 LinearGradientBrush lgbr = null;
1250 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right, area.Y ), Color.White, NormalColor );
1252 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom ), Color.White, NormalColor );
1254 Pen pen = ResPool.GetPen( BorderColor );
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 )
1270 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1271 dc.DrawPolygon( pen, points );
1273 // draw grip lines only if stere is enough space
1274 if ( area.Height > 20 )
1276 int mid_y = area.Y + ( area.Height / 2 );
1277 int mid_x = area.X + ( area.Width / 2 );
1279 using ( Pen lpen = new Pen( MouseOverColor, 2 ) )
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 );
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 );
1294 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1295 dc.DrawPolygon( pen, points );
1297 // draw grip lines only if stere is enough space
1298 if ( area.Width > 20 )
1300 int mid_x = area.X + ( area.Width / 2 );
1301 int mid_y = area.Y + ( area.Height / 2 );
1303 using ( Pen lpen = new Pen( MouseOverColor, 2 ) )
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 );
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 );
1320 /* Nice scroll button */
1321 public void DrawScrollButtonPrimitive( Graphics dc, Rectangle area, ButtonState state, ScrollButton scroll_button_type )
1323 Pen pen = ResPool.GetPen( BorderColor );
1325 dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), area );
1329 if ( ( state & ButtonState.Pushed ) == ButtonState.Pushed )
1330 use_color = PressedColor;
1332 use_color = NormalColor;
1334 Point[] points = null;
1336 LinearGradientBrush lgbr = null;
1338 switch ( scroll_button_type )
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 );
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 )
1353 dc.DrawPolygon( pen, points );
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 );
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 ),
1368 dc.DrawPolygon( pen, points );
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 );
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 )
1383 dc.DrawPolygon( pen, points );
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 );
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 )
1398 dc.DrawPolygon( pen, points );
1406 public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box)
1408 StringFormat text_format;
1414 rect = box.ClientRectangle;
1416 dc.FillRectangle (ResPool.GetSolidBrush (box.BackColor), rect);
1418 text_format = new StringFormat();
1419 text_format.HotkeyPrefix = HotkeyPrefix.Show;
1421 size = dc.MeasureString (box.Text, box.Font);
1422 width = (int) size.Width;
1424 if (width > box.Width - 16)
1425 width = box.Width - 16;
1427 y = box.Font.Height / 2;
1429 Pen pen = ResPool.GetPen( BorderColor );
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 ),
1444 dc.DrawLines( pen, points );
1448 dc.DrawString (box.Text, box.Font, ResPool.GetSolidBrush (box.ForeColor), 10, 0, text_format);
1450 CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor,
1451 new RectangleF (10, 0, width, box.Font.Height), text_format);
1453 text_format.Dispose ();