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) 2006 Alexander Olk
23 // Alexander Olk, alex.olk@googlemail.com
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, 3 );
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 static Blend NormalBlend;
58 static Blend FlatBlend;
60 #region Principal Theme Methods
63 ColorControl = NiceBackColor;
65 FlatBlend = new Blend ();
66 FlatBlend.Factors = new float []{0.0f, 0.992f, 1.0f};
67 FlatBlend.Positions = new float []{0.0f, 0.68f, 1.0f};
69 NormalBlend = new Blend ();
70 NormalBlend.Factors = new float []{0.0f, 0.008f, 1.0f};
71 NormalBlend.Positions = new float []{0.0f, 0.32f, 1.0f};
74 public override Color DefaultControlBackColor
76 get { return NiceBackColor; }
79 public override Color DefaultWindowBackColor
81 get { return NiceBackColor; }
84 public override Color ColorControl {
85 get { return NiceBackColor;}
88 static Bitmap CreateSizegripDot()
90 Bitmap bmp = new Bitmap( 4, 4 );
91 using ( Graphics dc = Graphics.FromImage( bmp ) )
93 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
94 dc.SmoothingMode = SmoothingMode.AntiAlias;
96 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 4, 4 ), PressedColor, Color.White ) ) {
97 Blend bl = new Blend ();
98 bl.Factors = new float []{0.0f, 0.992f, 1.0f};
99 bl.Positions = new float []{0.0f, 0.68f, 1.0f};
101 dc.FillEllipse( lgbr, new Rectangle( 0, 0, 4, 4 ) );
104 dc.SmoothingMode = old_smoothing_mode;
110 public override Image Images(UIIcon index, int size) {
112 case UIIcon.PlacesRecentDocuments:
113 if (XplatUI.RunningOnUnix)
114 return MimeIconEngine.GetIconForMimeTypeAndSize( "recently/recently", new Size(size, size) );
116 return base.Images (UIIcon.PlacesRecentDocuments, size);
117 case UIIcon.PlacesDesktop:
118 if (XplatUI.RunningOnUnix)
119 return MimeIconEngine.GetIconForMimeTypeAndSize( "desktop/desktop", new Size(size, size) );
121 return base.Images (UIIcon.PlacesDesktop, size);
122 case UIIcon.PlacesPersonal:
123 if (XplatUI.RunningOnUnix)
124 return MimeIconEngine.GetIconForMimeTypeAndSize( "directory/home", new Size(size, size) );
126 return base.Images (UIIcon.PlacesPersonal, size);
127 case UIIcon.PlacesMyComputer:
128 if (XplatUI.RunningOnUnix)
129 return MimeIconEngine.GetIconForMimeTypeAndSize( "workplace/workplace", new Size(size, size) );
131 return base.Images (UIIcon.PlacesMyComputer, size);
132 case UIIcon.PlacesMyNetwork:
133 if (XplatUI.RunningOnUnix)
134 return MimeIconEngine.GetIconForMimeTypeAndSize( "network/network", new Size(size, size) );
136 return base.Images (UIIcon.PlacesMyNetwork, size);
138 // Icons for message boxes
139 case UIIcon.MessageBoxError: return base.Images (UIIcon.MessageBoxError, size);
140 case UIIcon.MessageBoxInfo: return base.Images (UIIcon.MessageBoxInfo, size);
141 case UIIcon.MessageBoxQuestion: return base.Images (UIIcon.MessageBoxQuestion, size);
142 case UIIcon.MessageBoxWarning: return base.Images (UIIcon.MessageBoxWarning, size);
145 case UIIcon.NormalFolder:
146 if (XplatUI.RunningOnUnix)
147 return MimeIconEngine.GetIconForMimeTypeAndSize( "inode/directory", new Size(size, size) );
149 return base.Images (UIIcon.NormalFolder, size);
152 throw new ArgumentException("Invalid Icon type requested", "index");
156 #endregion // Internal Methods
159 protected override void ButtonBase_DrawButton (ButtonBase button, Graphics dc)
161 bool check_or_radio = false;
162 bool check_or_radio_checked = false;
164 Color use_color = NormalColor;
165 Color first_color = Color.White;
167 dc.FillRectangle (ResPool.GetSolidBrush (button.BackColor), button.ClientRectangle);
169 if (button is CheckBox) {
170 check_or_radio = true;
171 check_or_radio_checked = ((CheckBox)button).Checked;
172 } else if (button is RadioButton) {
173 check_or_radio = true;
174 check_or_radio_checked = ((RadioButton)button).Checked;
177 if (button.has_focus && !check_or_radio && button.is_enabled)
178 first_color = FocusColorLight;
180 if (button.is_enabled) {
181 if (button.FlatStyle == FlatStyle.Popup) {
182 if (!button.is_pressed && button.is_entered && !check_or_radio_checked)
183 use_color = MouseOverColor;
184 } else if (button.FlatStyle == FlatStyle.Flat) {
185 if (button.is_entered && !button.is_pressed && !check_or_radio_checked)
186 use_color = MouseOverColor;
188 if (!button.is_pressed && button.is_entered && !check_or_radio_checked)
189 use_color = MouseOverColor;
193 Rectangle buttonRectangle;
195 int height = button.ClientSize.Height;
197 // set up the button rectangle
198 buttonRectangle = button.ClientRectangle;
200 // Fill button with a nice linear gradient brush
201 Rectangle lgbRectangle = Rectangle.Inflate (buttonRectangle, -1, -1);
203 if (button.FlatStyle != FlatStyle.Popup || ((button.FlatStyle == FlatStyle.Popup) && button.is_entered)) {
204 LinearGradientBrush lgbr;
205 if (!button.is_pressed && !check_or_radio_checked) {
206 if (button.FlatStyle == FlatStyle.Flat) {
207 lgbr = new LinearGradientBrush (new Point (0, 0), new Point (0, height - 1), use_color, first_color);
208 lgbr.Blend = FlatBlend;
210 lgbr = new LinearGradientBrush (new Point (0, 0), new Point (0, height - 1), first_color, use_color);
211 lgbr.Blend = NormalBlend;
214 lgbr = new LinearGradientBrush (new Point (0, 0), new Point (0, height - 1), PressedColor, MouseOverColor);
216 dc.FillRectangle (lgbr, lgbRectangle);
219 if (button.has_focus && !check_or_radio)
222 Internal_DrawButton(dc, buttonRectangle, BorderColor);
226 private void Internal_DrawButton(Graphics dc, Rectangle area, Color border_color)
228 Point[] points = new Point [] {
229 new Point (area.X + 1, area.Y),
230 new Point (area.Right - 2, area.Y),
231 new Point (area.Right - 2, area.Y + 1),
232 new Point (area.Right - 1, area.Y + 1),
233 new Point (area.Right - 1, area.Bottom - 2),
234 new Point (area.Right - 2, area.Bottom - 2),
235 new Point (area.Right - 2, area.Bottom - 1),
236 new Point (area.X + 1, area.Bottom - 1),
237 new Point (area.X + 1, area.Bottom - 2),
238 new Point (area.X, area.Bottom - 2),
239 new Point (area.X, area.Y + 1),
240 new Point (area.X + 1, area.Y + 1),
241 new Point (area.X + 1, area.Y)
244 Pen pen = ResPool.GetPen (border_color);
245 dc.DrawPolygon (pen, points);
248 protected override void ButtonBase_DrawFocus( ButtonBase button, Graphics dc )
250 if ((button is RadioButton) || (button is CheckBox))
253 Internal_DrawButton(dc, button.ClientRectangle, FocusColor);
256 protected override void ButtonBase_DrawText( ButtonBase button, Graphics dc )
258 if ( !( button is CheckBox ) && !(button is RadioButton ) )
260 base.ButtonBase_DrawText( button, dc );
263 #endregion // ButtonBase
266 public override void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect)
268 if (menu.Height == 0)
269 CalcMenuBarSize (dc, menu, rect.Width);
271 bool keynav = (menu as MainMenu).tracker.Navigating;
272 HotkeyPrefix hp = MenuAccessKeysUnderlined || keynav ? HotkeyPrefix.Show : HotkeyPrefix.Hide;
273 string_format_menu_menubar_text.HotkeyPrefix = hp;
274 string_format_menu_text.HotkeyPrefix = hp;
276 rect.Height = menu.Height;
277 dc.FillRectangle (ResPool.GetSolidBrush (NiceBackColor), rect);
279 for (int i = 0; i < menu.MenuItems.Count; i++) {
280 MenuItem item = menu.MenuItems [i];
281 Rectangle item_rect = item.bounds;
282 item_rect.X += rect.X;
283 item_rect.Y += rect.Y;
284 item.MenuHeight = menu.Height;
285 item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont, item_rect, i, item.Status));
289 public override void DrawMenuItem (MenuItem item, DrawItemEventArgs e)
291 StringFormat string_format;
292 Rectangle rect_text = e.Bounds;
294 if (item.Visible == false)
298 string_format = string_format_menu_menubar_text;
300 string_format = string_format_menu_text;
302 if (item.Separator == true) {
303 e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
304 e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y);
306 e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
307 e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + 1);
313 rect_text.X += MenuCheckSize.Width;
315 if (item.BarBreak) { /* Draw vertical break bar*/
316 Rectangle rect = e.Bounds;
319 rect.Height = item.MenuHeight - 6;
321 e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
322 rect.X, rect.Y , rect.X, rect.Y + rect.Height);
324 e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
325 rect.X + 1, rect.Y , rect.X +1, rect.Y + rect.Height);
328 Color color_text = ColorMenuText;
329 Color color_back = NiceBackColor;
331 /* Draw background */
332 Rectangle rect_back = e.Bounds;
336 if (((e.State & DrawItemState.Selected) == DrawItemState.Selected) || ((e.State & DrawItemState.HotLight) == DrawItemState.HotLight)) {
337 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 ) )
338 e.Graphics.FillRectangle (lgbr, rect_back);
340 e.Graphics.DrawRectangle (ResPool.GetPen (BorderColor), rect_back.X, rect_back.Y, rect_back.Width, rect_back.Height - 1);
342 e.Graphics.FillRectangle (ResPool.GetSolidBrush (NiceBackColor), rect_back);
346 e.Graphics.DrawString (item.Text, e.Font,
347 ResPool.GetSolidBrush (color_text),
348 rect_text, string_format);
350 if (!item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut) {
351 string str = item.GetShortCutText ();
352 Rectangle rect = rect_text;
354 rect.Width -= item.XTab;
356 e.Graphics.DrawString (str, e.Font, ResPool.GetSolidBrush (color_text),
357 rect, string_format_menu_shortcut);
361 ControlPaint.DrawStringDisabled (e.Graphics, item.Text, e.Font,
362 Color.Black, rect_text, string_format);
366 if (item.MenuBar == false && item.IsPopup || item.MdiList) {
368 int cx = MenuCheckSize.Width;
369 int cy = MenuCheckSize.Height;
370 Bitmap bmp = CreateGlyphBitmap (new Size (cx, cy), MenuGlyph.Arrow, color_text);
373 e.Graphics.DrawImage (bmp, e.Bounds.X + e.Bounds.Width - cx,
374 e.Bounds.Y + ((e.Bounds.Height - cy) /2));
376 ControlPaint.DrawImageDisabled (e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
377 e.Bounds.Y + ((e.Bounds.Height - cy) /2), color_back);
383 /* Draw checked or radio */
384 if (item.MenuBar == false && item.Checked) {
386 Rectangle area = e.Bounds;
387 int cx = MenuCheckSize.Width;
388 int cy = MenuCheckSize.Height;
389 Bitmap bmp = CreateGlyphBitmap (new Size (cx, cy), item.RadioCheck ? MenuGlyph.Bullet : MenuGlyph.Checkmark, color_text);
391 e.Graphics.DrawImage (bmp, area.X, e.Bounds.Y + ((e.Bounds.Height - cy) / 2));
397 public override void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect)
400 dc.FillRectangle (ResPool.GetSolidBrush
401 (NiceBackColor), cliparea);
403 /* Draw menu borders */
404 dc.DrawLine (ResPool.GetPen (ColorHighlightText),
405 rect.X, rect.Y, rect.X + rect.Width, rect.Y);
407 dc.DrawLine (ResPool.GetPen (ColorHighlightText),
408 rect.X, rect.Y, rect.X, rect.Y + rect.Height);
410 dc.DrawLine (ResPool.GetPen (ColorControlDark),
411 rect.X + rect.Width - 1 , rect.Y , rect.X + rect.Width - 1, rect.Y + rect.Height);
413 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
414 rect.X + rect.Width, rect.Y , rect.X + rect.Width, rect.Y + rect.Height);
416 dc.DrawLine (ResPool.GetPen (ColorControlDark),
417 rect.X , rect.Y + rect.Height - 1 , rect.X + rect.Width - 1, rect.Y + rect.Height -1);
419 dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
420 rect.X , rect.Y + rect.Height, rect.X + rect.Width - 1, rect.Y + rect.Height);
422 for (int i = 0; i < menu.MenuItems.Count; i++)
423 if (cliparea.IntersectsWith (menu.MenuItems [i].bounds)) {
424 MenuItem item = menu.MenuItems [i];
425 item.MenuHeight = menu.Height;
426 item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont,
427 item.bounds, i, item.Status));
433 public override void DrawProgressBar( Graphics dc, Rectangle clip_rect, ProgressBar ctrl )
435 Rectangle client_area = ctrl.client_area;
437 Rectangle bar = ctrl.client_area;
439 barpos_pixels = ( ( ctrl.Value - ctrl.Minimum ) * client_area.Width ) / ( ctrl.Maximum - ctrl.Minimum );
441 bar.Width = barpos_pixels;
444 // Draw bar background
445 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( client_area.Left, client_area.Top ), new Point( client_area.Left, client_area.Bottom ), LightColor, Color.White ) )
447 lgbr.Blend = FlatBlend;
448 dc.FillRectangle( lgbr, client_area );
452 using ( LinearGradientBrush lgbr = new LinearGradientBrush( bar.Location, new Point( bar.X, bar.Bottom ), Color.White, PressedColor ) )
454 lgbr.Blend = NormalBlend;
455 dc.FillRectangle( lgbr, bar );
459 dc.DrawRectangle( ResPool.GetPen( BorderColor ), ctrl.ClientRectangle.X, ctrl.ClientRectangle.Y, ctrl.ClientRectangle.Width - 1, ctrl.ClientRectangle.Height - 1 );
460 dc.DrawRectangle( ResPool.GetPen( LightColor ), ctrl.ClientRectangle.X + 1, ctrl.ClientRectangle.Y + 1, ctrl.ClientRectangle.Width - 2, ctrl.ClientRectangle.Height - 2 );
462 #endregion // ProgressBar
465 protected override void ScrollBar_DrawThumb( ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
467 if ( bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith( thumb_pos ) )
468 DrawScrollBarThumb( dc, thumb_pos, bar );
470 #endregion // ScrollBar
473 protected override void DrawStatusBarPanel( Graphics dc, Rectangle area, int index,
474 Brush br_forecolor, StatusBarPanel panel )
476 int border_size = 3; // this is actually const, even if the border style is none
478 area.Height -= border_size;
479 if ( panel.BorderStyle != StatusBarPanelBorderStyle.None )
481 Internal_DrawButton( dc, area, BorderColor );
484 if ( panel.Style == StatusBarPanelStyle.OwnerDraw )
486 StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs(
487 dc, panel.Parent.Font, area, index, DrawItemState.Default,
488 panel, panel.Parent.ForeColor, panel.Parent.BackColor );
489 panel.Parent.OnDrawItemInternal( e );
493 int left = area.Left;
494 if ( panel.Icon != null )
497 dc.DrawIcon( panel.Icon, left, area.Top );
498 left += panel.Icon.Width;
501 if ( panel.Text == String.Empty )
504 string text = panel.Text;
505 StringFormat string_format = new StringFormat( );
506 string_format.Trimming = StringTrimming.Character;
507 string_format.FormatFlags = StringFormatFlags.NoWrap;
509 if ( text[ 0 ] == '\t' )
511 string_format.Alignment = StringAlignment.Center;
512 text = text.Substring( 1 );
513 if ( text[ 0 ] == '\t' )
515 string_format.Alignment = StringAlignment.Far;
516 text = text.Substring( 1 );
520 int x = left + border_size;
521 int y = border_size + 2;
522 Rectangle r = new Rectangle( x, y,
523 area.Right - x - border_size,
524 area.Bottom - y - border_size );
526 dc.DrawString( text, panel.Parent.Font, br_forecolor, r, string_format );
528 #endregion // StatusBar
530 public override void DrawTabControl( Graphics dc, Rectangle area, TabControl tab )
532 // Do we need to fill the back color? It can't be changed...
533 dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), area );
534 Rectangle panel_rect = TabControlGetPanelRect( tab );
536 if ( tab.Appearance == TabAppearance.Normal )
538 CPDrawBorder( dc, panel_rect, BorderColor, 1, ButtonBorderStyle.Solid, BorderColor, 1, ButtonBorderStyle.Solid,
539 BorderColor, 1, ButtonBorderStyle.Solid, BorderColor, 1, ButtonBorderStyle.Solid );
542 if ( tab.Alignment == TabAlignment.Top )
544 for ( int r = tab.TabPages.Count; r > 0; r-- )
546 for ( int i = tab.SliderPos; i < tab.TabPages.Count; i++ )
548 if ( i == tab.SelectedIndex )
550 if ( r != tab.TabPages[ i ].Row )
552 Rectangle rect = tab.GetTabRect( i );
553 if ( !rect.IntersectsWith( area ) )
555 DrawTab( dc, tab.TabPages[ i ], tab, rect, false );
561 for ( int r = 0; r < tab.TabPages.Count; r++ )
563 for ( int i = tab.SliderPos; i < tab.TabPages.Count; i++ )
565 if ( i == tab.SelectedIndex )
567 if ( r != tab.TabPages[ i ].Row )
569 Rectangle rect = tab.GetTabRect( i );
570 if ( !rect.IntersectsWith( area ) )
572 DrawTab( dc, tab.TabPages[ i ], tab, rect, false );
577 if ( tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos )
579 Rectangle rect = tab.GetTabRect( tab.SelectedIndex );
580 if ( rect.IntersectsWith( area ) )
581 DrawTab( dc, tab.TabPages[ tab.SelectedIndex ], tab, rect, true );
584 if ( tab.ShowSlider )
586 Rectangle right = TabControlGetRightScrollRect( tab );
587 Rectangle left = TabControlGetLeftScrollRect( tab );
588 CPDrawScrollButton( dc, right, ScrollButton.Right, tab.RightSliderState );
589 CPDrawScrollButton( dc, left, ScrollButton.Left, tab.LeftSliderState );
593 protected virtual int DrawTab( Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected )
595 int FlatButtonSpacing = 8;
597 int res = bounds.Width;
599 // we can't fill the background right away because the bounds might be adjusted if the tab is selected
601 if ( tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons )
603 dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), bounds );
606 if ( tab.Appearance == TabAppearance.FlatButtons )
608 int width = bounds.Width;
609 bounds.Width += ( FlatButtonSpacing - 2 );
611 CPDrawBorder3D( dc, bounds, Border3DStyle.Etched, Border3DSide.Right );
612 bounds.Width = width;
617 CPDrawBorder3D( dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
619 else if ( tab.Appearance != TabAppearance.FlatButtons )
621 CPDrawBorder3D( dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
624 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4 );
626 StringFormat string_format = new StringFormat( );
627 string_format.Alignment = StringAlignment.Center;
628 string_format.LineAlignment = StringAlignment.Center;
629 string_format.FormatFlags = StringFormatFlags.NoWrap;
632 dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
637 Pen border_pen = ResPool.GetPen( BorderColor );
639 dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), bounds );
641 switch ( tab.Alignment )
643 case TabAlignment.Top:
647 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
649 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Left + 2, bounds.Bottom ), Color.White, LightColor ) )
651 lgbr.Blend = NormalBlend;
652 dc.FillRectangle( lgbr, interior );
656 dc.DrawLine( border_pen, bounds.Left, bounds.Bottom, bounds.Left, bounds.Top + 3 );
657 dc.DrawLine( border_pen, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top );
658 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Top, bounds.Right - 3, bounds.Top );
659 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3 );
660 dc.DrawLine( border_pen, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom );
664 dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left - 1 , bounds.Top, bounds.Right - 1, bounds.Top );
665 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Top + 1, bounds.Right , bounds.Top + 1 );
666 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Top + 2, bounds.Right , bounds.Top + 2 );
669 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
671 if ( page.Text != String.Empty )
673 StringFormat string_format = new StringFormat( );
674 string_format.Alignment = StringAlignment.Center;
675 string_format.LineAlignment = StringAlignment.Center;
676 string_format.FormatFlags = StringFormatFlags.NoWrap;
678 dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
684 case TabAlignment.Bottom:
688 interior = new Rectangle( bounds.Left + 3, bounds.Top, bounds.Width - 3, bounds.Height );
690 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 3, bounds.Top ), new Point( bounds.Left + 3, bounds.Bottom ), Color.White, LightColor ) )
692 lgbr.Blend = NormalBlend;
693 dc.FillRectangle( lgbr, interior );
697 dc.DrawLine( border_pen, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 3 );
698 dc.DrawLine( border_pen, bounds.Left, bounds.Bottom - 3, bounds.Left + 3, bounds.Bottom );
699 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom );
700 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Bottom, bounds.Right, bounds.Bottom - 3 );
701 dc.DrawLine( border_pen, bounds.Right, bounds.Bottom - 3, bounds.Right, bounds.Top );
705 dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left - 1 , bounds.Bottom, bounds.Right - 1, bounds.Bottom );
706 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Bottom - 1, bounds.Right , bounds.Bottom - 1 );
707 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left , bounds.Bottom - 2, bounds.Right , bounds.Bottom - 2 );
710 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
712 if ( page.Text != String.Empty )
714 StringFormat string_format = new StringFormat( );
715 string_format.Alignment = StringAlignment.Center;
716 string_format.LineAlignment = StringAlignment.Center;
717 string_format.FormatFlags = StringFormatFlags.NoWrap;
719 dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
725 case TabAlignment.Left:
729 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
731 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Right, bounds.Top + 2 ), LightColor, Color.White ) )
733 lgbr.Blend = FlatBlend;
734 dc.FillRectangle( lgbr, interior );
738 dc.DrawLine( border_pen, bounds.Right, bounds.Top, bounds.Left + 3, bounds.Top );
739 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Top, bounds.Left, bounds.Top + 3 );
740 dc.DrawLine( border_pen, bounds.Left, bounds.Top + 3, bounds.Left, bounds.Bottom - 3 );
741 dc.DrawLine( border_pen, bounds.Left, bounds.Bottom - 3, bounds.Left + 3, bounds.Bottom );
742 dc.DrawLine( border_pen, bounds.Left + 3, bounds.Bottom, bounds.Right, bounds.Bottom );
746 dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Left , bounds.Top + 1, bounds.Left , bounds.Bottom - 1 );
747 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left + 1 , bounds.Top, bounds.Left + 1 , bounds.Bottom );
748 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Left + 2 , bounds.Top, bounds.Left + 2 , bounds.Bottom );
751 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
753 if ( page.Text != String.Empty )
755 StringFormat string_format = new StringFormat( );
756 // Flip the text around
757 string_format.Alignment = StringAlignment.Center;
758 string_format.LineAlignment = StringAlignment.Center;
759 string_format.FormatFlags = StringFormatFlags.NoWrap;
760 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
761 int wo = interior.Width / 2;
762 int ho = interior.Height / 2;
763 dc.TranslateTransform( interior.X + wo, interior.Y + ho );
764 dc.RotateTransform( 180 );
765 dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), 0, 0, string_format );
766 dc.ResetTransform( );
772 // TabAlignment.Right
776 interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
778 using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Right, bounds.Top + 2 ), Color.White, LightColor ) )
780 lgbr.Blend = NormalBlend;
781 dc.FillRectangle( lgbr, interior );
785 dc.DrawLine( border_pen, bounds.Left, 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 - 3 );
788 dc.DrawLine( border_pen, bounds.Right, bounds.Bottom - 3, bounds.Right - 3, bounds.Bottom );
789 dc.DrawLine( border_pen, bounds.Right - 3, bounds.Bottom, bounds.Left, bounds.Bottom );
793 dc.DrawLine( ResPool.GetPen( Color.DarkOrange ), bounds.Right , bounds.Top + 1, bounds.Right , bounds.Bottom - 1 );
794 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Right - 1 , bounds.Top, bounds.Right - 1 , bounds.Bottom );
795 dc.DrawLine( ResPool.GetPen( Color.Orange ), bounds.Right - 2 , bounds.Top, bounds.Right - 2 , bounds.Bottom );
798 interior = new Rectangle( bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8 );
800 if ( page.Text != String.Empty )
802 StringFormat string_format = new StringFormat( );
803 string_format.Alignment = StringAlignment.Center;
804 string_format.LineAlignment = StringAlignment.Center;
805 string_format.FormatFlags = StringFormatFlags.NoWrap;
806 string_format.FormatFlags = StringFormatFlags.DirectionVertical;
808 dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
820 public override void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control)
822 StringFormat format = new StringFormat ();
823 format.Trimming = StringTrimming.EllipsisWord;
824 format.LineAlignment = StringAlignment.Center;
825 if (control.TextAlign == ToolBarTextAlign.Underneath)
826 format.Alignment = StringAlignment.Center;
828 format.Alignment = StringAlignment.Near;
830 dc.FillRectangle (ResPool.GetSolidBrush( NiceBackColor ), clip_rectangle);
832 foreach (ToolBarItem item in control.items)
833 if (item.Button.Visible && clip_rectangle.IntersectsWith (item.Rectangle))
834 DrawToolBarButton (dc, control, item, format);
839 protected override void DrawToolBarButton (Graphics dc, ToolBar control, ToolBarItem item, StringFormat format)
841 bool is_flat = control.Appearance == ToolBarAppearance.Flat;
843 if (item.Button.Style != ToolBarButtonStyle.Separator)
844 DoDrawToolBarButton (dc, item, is_flat);
846 switch (item.Button.Style) {
847 case ToolBarButtonStyle.DropDownButton:
848 if (control.DropDownArrows)
849 DrawToolBarDropDownArrow (dc, item, is_flat);
850 DrawToolBarButtonContents (dc, control, item, format);
853 case ToolBarButtonStyle.Separator:
855 DrawToolBarSeparator (dc, item);
858 case ToolBarButtonStyle.ToggleButton:
860 DrawToolBarButtonContents (dc, control, item, format);
865 const Border3DSide all_sides = Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom;
867 void DoDrawToolBarButton (Graphics dc, ToolBarItem item, bool is_flat)
869 Color use_color = NormalColor;
870 Color first_color = Color.White;
873 if (item.Button.Pushed || item.Pressed) {
874 first_color = PressedColor;
875 use_color = MouseOverColor;
878 use_color = MouseOverColor;
882 if (item.Button.Pushed || item.Pressed) {
883 first_color = PressedColor;
884 use_color = MouseOverColor;
887 use_color = MouseOverColor;
890 Rectangle buttonRectangle = item.Rectangle;
892 Rectangle lgbRectangle = Rectangle.Inflate (buttonRectangle, -1, -1);
894 using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (buttonRectangle.X, buttonRectangle.Y), new Point (buttonRectangle.X, buttonRectangle.Bottom - 1), first_color, use_color)) {
895 lgbr.Blend = NormalBlend;
896 dc.FillRectangle (lgbr, lgbRectangle);
899 Internal_DrawButton (dc, buttonRectangle, BorderColor);
902 protected override void DrawToolBarSeparator (Graphics dc, ToolBarItem item)
904 Rectangle area = item.Rectangle;
905 int offset = (int) ResPool.GetPen (ColorControl).Width + 1;
906 dc.DrawLine (ResPool.GetPen (ColorControlDark), area.X + 1, area.Y, area.X + 1, area.Bottom);
907 dc.DrawLine (ResPool.GetPen (ColorControlLight), area.X + offset, area.Y, area.X + offset, area.Bottom);
910 protected override void DrawToolBarDropDownArrow (Graphics dc, ToolBarItem item, bool is_flat)
912 Rectangle rect = item.Rectangle;
913 rect.X = item.Rectangle.Right - ToolBarDropDownWidth;
914 rect.Width = ToolBarDropDownWidth;
916 if (item.DDPressed) {
917 CPDrawBorder3D (dc, rect, Border3DStyle.SunkenOuter, all_sides);
918 CPDrawBorder3D (dc, rect, Border3DStyle.SunkenInner, Border3DSide.Bottom | Border3DSide.Right);
919 } else if (item.Button.Pushed || item.Pressed)
920 CPDrawBorder3D (dc, rect, Border3DStyle.Sunken, all_sides);
923 CPDrawBorder3D (dc, rect, Border3DStyle.RaisedOuter, all_sides);
925 CPDrawBorder3D (dc, rect, Border3DStyle.Raised, all_sides);
927 PointF [] vertices = new PointF [3];
928 PointF ddCenter = new PointF (rect.X + (rect.Width/2.0f), rect.Y + (rect.Height/2.0f));
929 vertices [0].X = ddCenter.X - ToolBarDropDownArrowWidth / 2.0f + 0.5f;
930 vertices [0].Y = ddCenter.Y;
931 vertices [1].X = ddCenter.X + ToolBarDropDownArrowWidth / 2.0f + 0.5f;
932 vertices [1].Y = ddCenter.Y;
933 vertices [2].X = ddCenter.X + 0.5f; // 0.5 is added for adjustment
934 vertices [2].Y = ddCenter.Y + ToolBarDropDownArrowHeight;
935 dc.FillPolygon (SystemBrushes.ControlText, vertices);
938 protected override void DrawToolBarButtonContents (Graphics dc, ToolBar control, ToolBarItem item, StringFormat format)
940 if (item.Button.Image != null) {
941 int x = item.ImageRectangle.X + ToolBarImageGripWidth;
942 int y = item.ImageRectangle.Y + ToolBarImageGripWidth;
943 if (item.Button.Enabled)
944 dc.DrawImage (item.Button.Image, x, y);
946 CPDrawImageDisabled (dc, item.Button.Image, x, y, ColorControl);
949 if (item.Button.Enabled)
950 dc.DrawString (item.Button.Text, control.Font, ResPool.GetSolidBrush (ColorControlText), item.TextRectangle, format);
952 CPDrawStringDisabled (dc, item.Button.Text, control.Font, ColorControlLight, item.TextRectangle, format);
955 #endregion // ToolBar
957 // public override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) {
958 // CPDrawBorder3D(graphics, rectangle, style, sides, ColorControl);
961 public override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color)
966 Pen penBottomRightInner;
967 Rectangle rect= new Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
969 if ((style & Border3DStyle.Adjust) != 0) {
976 penTopLeft = penTopLeftInner = penBottomRight = penBottomRightInner = ResPool.GetPen (control_color);
978 CPColor cpcolor = ResPool.GetCPColor (control_color);
981 case Border3DStyle.Raised:
982 penTopLeftInner = ResPool.GetPen (cpcolor.LightLight);
983 penBottomRight = ResPool.GetPen (cpcolor.Dark);
984 penBottomRightInner = ResPool.GetPen (BorderColor);
986 case Border3DStyle.Sunken:
987 penTopLeft = ResPool.GetPen (BorderColor);
988 penTopLeftInner = ResPool.GetPen (cpcolor.Dark);
989 penBottomRight = ResPool.GetPen (cpcolor.LightLight);
991 case Border3DStyle.Etched:
992 penTopLeft = penBottomRightInner = ResPool.GetPen (BorderColor);
993 penTopLeftInner = penBottomRight = ResPool.GetPen (cpcolor.LightLight);
995 case Border3DStyle.RaisedOuter:
996 penBottomRight = ResPool.GetPen (cpcolor.Dark);
998 case Border3DStyle.SunkenOuter:
999 penTopLeft = ResPool.GetPen (BorderColor);
1000 penBottomRight = ResPool.GetPen (cpcolor.LightLight);
1002 case Border3DStyle.RaisedInner:
1003 penTopLeft = ResPool.GetPen (cpcolor.LightLight);
1004 penBottomRight = ResPool.GetPen (BorderColor);
1006 case Border3DStyle.SunkenInner:
1007 penTopLeft = ResPool.GetPen (cpcolor.Dark);
1009 case Border3DStyle.Flat:
1010 penTopLeft = penBottomRight = ResPool.GetPen (BorderColor);
1012 case Border3DStyle.Bump:
1013 penTopLeftInner = penBottomRight = ResPool.GetPen (cpcolor.Dark);
1019 if ((sides & Border3DSide.Middle) != 0) {
1020 graphics.FillRectangle (ResPool.GetSolidBrush (control_color), rect);
1023 if ((sides & Border3DSide.Left) != 0) {
1024 graphics.DrawLine (penTopLeft, rect.Left, rect.Bottom - 2, rect.Left, rect.Top);
1025 graphics.DrawLine (penTopLeftInner, rect.Left + 1, rect.Bottom - 2, rect.Left + 1, rect.Top);
1028 if ((sides & Border3DSide.Top) != 0) {
1029 graphics.DrawLine (penTopLeft, rect.Left, rect.Top, rect.Right - 2, rect.Top);
1030 graphics.DrawLine (penTopLeftInner, rect.Left + 1, rect.Top + 1, rect.Right - 3, rect.Top + 1);
1033 if ((sides & Border3DSide.Right) != 0) {
1034 graphics.DrawLine (penBottomRight, rect.Right - 1, rect.Top, rect.Right - 1, rect.Bottom - 1);
1035 graphics.DrawLine (penBottomRightInner, rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 2);
1038 if ((sides & Border3DSide.Bottom) != 0) {
1039 graphics.DrawLine (penBottomRight, rect.Left, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
1040 graphics.DrawLine (penBottomRightInner, rect.Left + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2);
1044 public override void CPDrawButton (Graphics dc, Rectangle rectangle, ButtonState state)
1046 dc.FillRectangle (ResPool.GetSolidBrush (NiceBackColor), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2);
1048 Color first_color = Color.White;
1049 Color second_color = NormalColor;
1051 if ((state & ButtonState.Flat) == ButtonState.Flat) {
1052 first_color = NormalColor;
1053 second_color = Color.White;
1055 if (((state & ButtonState.Flat) == ButtonState.Flat) &&
1056 (((state & ButtonState.Checked) == ButtonState.Checked) || ((state & ButtonState.Pushed) == ButtonState.Pushed))) {
1057 first_color = PressedColor;
1058 second_color = Color.White;
1060 if (((state & ButtonState.Checked) == ButtonState.Checked) || ((state & ButtonState.Pushed) == ButtonState.Pushed)) {
1061 second_color = PressedColor;
1064 Rectangle lgbRectangle = Rectangle.Inflate (rectangle, -1, -1);
1066 using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (rectangle.X, rectangle.Y), new Point (rectangle.X, rectangle.Bottom - 1), first_color, second_color)) {
1067 if ((state & ButtonState.Flat) == ButtonState.Flat) {
1068 lgbr.Blend = FlatBlend;
1070 lgbr.Blend = NormalBlend;
1072 dc.FillRectangle (lgbr, lgbRectangle);
1075 Internal_DrawButton(dc, rectangle, BorderColor);
1078 public override void CPDrawComboButton( Graphics dc, Rectangle rectangle, ButtonState state )
1080 Point[] arrow = new Point[ 3 ];
1090 Color first_color = Color.White;
1091 Color second_color = NormalColor;
1093 // rectangle.Width += 1;
1095 if ( ( state & ButtonState.Checked ) != 0 )
1097 dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControlLightLight, ColorControlLight ), rectangle );
1100 dc.FillRectangle( ResPool.GetSolidBrush( Color.White ), rectangle );
1102 if ( ( state & ButtonState.Flat ) != 0 )
1104 first_color = NormalColor;
1105 second_color = Color.White;
1109 if ( ( state & ( ButtonState.Pushed | ButtonState.Checked ) ) != 0 )
1111 first_color = Color.White;
1112 second_color = PressedColor;
1116 // CPDrawBorder3D( graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl );
1120 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 ) )
1122 lgbr.Blend = NormalBlend;
1123 dc.FillRectangle( lgbr, rectangle.X + 2, rectangle.Y + 1, rectangle.Width - 4, rectangle.Height - 3 );
1126 Internal_DrawButton(dc, new Rectangle(rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2), BorderColor);
1128 rect = new Rectangle( rectangle.X + rectangle.Width / 4, rectangle.Y + rectangle.Height / 4, rectangle.Width / 2, rectangle.Height / 2 );
1129 centerX = rect.Left + rect.Width / 2;
1130 centerY = rect.Top + rect.Height / 2;
1131 shiftX = Math.Max( 1, rect.Width / 8 );
1132 shiftY = Math.Max( 1, rect.Height / 8 );
1134 if ( ( state & ButtonState.Pushed ) != 0 )
1143 P1 = new Point( rect.Left, centerY );
1144 P2 = new Point( centerX, rect.Bottom );
1145 P3 = new Point( rect.Right, centerY );
1151 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
1152 dc.SmoothingMode = SmoothingMode.AntiAlias;
1154 /* Draw the arrow */
1155 if ( ( state & ButtonState.Inactive ) != 0 )
1157 using ( Pen pen = new Pen( SystemColors.ControlLightLight, 2 ) )
1159 dc.DrawLines( pen, arrow );
1162 /* Move away from the shadow */
1163 P1.X -= 1; P1.Y -= 1;
1164 P2.X -= 1; P2.Y -= 1;
1165 P3.X -= 1; P3.Y -= 1;
1171 using ( Pen pen = new Pen( SystemColors.ControlDark, 2 ) )
1173 dc.DrawLines( pen, arrow );
1178 using ( Pen pen = new Pen( SystemColors.ControlText, 2 ) )
1180 dc.DrawLines( pen, arrow );
1184 dc.SmoothingMode = old_smoothing_mode;
1187 /* Scroll button: regular button + direction arrow */
1188 public override void CPDrawScrollButton( Graphics dc, Rectangle area, ScrollButton scroll_button_type, ButtonState state )
1190 bool enabled = ( state == ButtonState.Inactive ) ? false: true;
1192 DrawScrollButtonPrimitive( dc, area, state, scroll_button_type );
1197 pen = ResPool.GetSizedPen( arrow_color, 2 );
1199 pen = ResPool.GetSizedPen( ColorGrayText, 2 );
1203 int centerX = area.Left + area.Width / 2;
1204 int centerY = area.Top + area.Height / 2;
1208 if ( ( state & ButtonState.Pushed ) != 0 )
1213 if ( area.Width < 12 || area.Height < 12 ) {
1218 Point[] arrow = new Point [3];
1220 switch (scroll_button_type) {
1221 case ScrollButton.Down:
1223 arrow [0] = new Point (centerX - min_3, centerY - min_2);
1224 arrow [1] = new Point (centerX, centerY + min_2);
1225 arrow [2] = new Point (centerX + min_3, centerY - min_2);
1227 case ScrollButton.Up:
1229 arrow [0] = new Point (centerX - min_3, centerY + min_2);
1230 arrow [1] = new Point (centerX, centerY - min_2);
1231 arrow [2] = new Point (centerX + min_3, centerY + min_2);
1233 case ScrollButton.Left:
1235 arrow [0] = new Point (centerX + min_2, centerY - min_3);
1236 arrow [1] = new Point (centerX - min_2, centerY);
1237 arrow [2] = new Point (centerX + min_2, centerY + min_3);
1239 case ScrollButton.Right:
1241 arrow [0] = new Point (centerX - min_2, centerY - min_3);
1242 arrow [1] = new Point (centerX + min_2, centerY);
1243 arrow [2] = new Point (centerX - min_2, centerY + min_3);
1249 SmoothingMode old_smoothing_mode = dc.SmoothingMode;
1250 dc.SmoothingMode = SmoothingMode.AntiAlias;
1252 dc.DrawLines (pen, arrow);
1254 dc.SmoothingMode = old_smoothing_mode;
1257 public override void CPDrawSizeGrip( Graphics dc, Color backColor, Rectangle bounds )
1259 Point pt = new Point( bounds.Right - 4, bounds.Bottom - 4 );
1261 dc.DrawImage( size_grip_bmp, pt );
1262 dc.DrawImage( size_grip_bmp, pt.X, pt.Y - 5 );
1263 dc.DrawImage( size_grip_bmp, pt.X, pt.Y - 10 );
1264 dc.DrawImage( size_grip_bmp, pt.X - 5, pt.Y );
1265 dc.DrawImage( size_grip_bmp, pt.X - 10, pt.Y );
1266 dc.DrawImage( size_grip_bmp, pt.X - 5, pt.Y - 5 );
1269 private void DrawScrollBarThumb( Graphics dc, Rectangle area, ScrollBar bar )
1271 LinearGradientBrush lgbr = null;
1274 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right, area.Y ), Color.White, NormalColor );
1276 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom ), Color.White, NormalColor );
1278 lgbr.Blend = NormalBlend;
1282 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1283 Internal_DrawButton (dc, area, BorderColor);
1285 // draw grip lines only if stere is enough space
1286 if ( area.Height > 20 )
1288 int mid_y = area.Y + ( area.Height / 2 );
1289 int mid_x = area.X + ( area.Width / 2 );
1291 Pen lpen = ResPool.GetSizedPen( MouseOverColor, 2 );
1292 dc.DrawLine( lpen, mid_x - 3, mid_y, mid_x + 3, mid_y );
1293 dc.DrawLine( lpen, mid_x - 3, mid_y - 4, mid_x + 3, mid_y - 4 );
1294 dc.DrawLine( lpen, mid_x - 3, mid_y + 4, mid_x + 3, mid_y + 4 );
1296 Pen spen = ResPool.GetPen( Color.White );
1297 dc.DrawLine( spen, mid_x - 3, mid_y - 1, mid_x + 3, mid_y - 1 );
1298 dc.DrawLine( spen, mid_x - 3, mid_y - 5, mid_x + 3, mid_y - 5 );
1299 dc.DrawLine( spen, mid_x - 3, mid_y + 3, mid_x + 3, mid_y + 3 );
1304 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1305 Internal_DrawButton (dc, area, BorderColor);
1307 // draw grip lines only if stere is enough space
1308 if ( area.Width > 20 )
1310 int mid_x = area.X + ( area.Width / 2 );
1311 int mid_y = area.Y + ( area.Height / 2 );
1313 Pen lpen = ResPool.GetSizedPen( MouseOverColor, 2 );
1314 dc.DrawLine( lpen, mid_x, mid_y - 3, mid_x, mid_y + 3 );
1315 dc.DrawLine( lpen, mid_x - 4, mid_y - 3, mid_x - 4, mid_y + 3 );
1316 dc.DrawLine( lpen, mid_x + 4, mid_y - 3, mid_x + 4, mid_y + 3 );
1318 Pen spen = ResPool.GetPen( Color.White );
1319 dc.DrawLine( spen, mid_x - 1, mid_y - 3, mid_x - 1, mid_y + 3 );
1320 dc.DrawLine( spen, mid_x - 5, mid_y - 3, mid_x - 5, mid_y + 3 );
1321 dc.DrawLine( spen, mid_x + 3, mid_y - 3, mid_x + 3, mid_y + 3 );
1328 /* Nice scroll button */
1329 public void DrawScrollButtonPrimitive( Graphics dc, Rectangle area, ButtonState state, ScrollButton scroll_button_type )
1331 Pen pen = ResPool.GetPen( BorderColor );
1333 dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), area );
1337 if ( ( state & ButtonState.Pushed ) == ButtonState.Pushed )
1338 use_color = PressedColor;
1340 use_color = NormalColor;
1342 Point[] points = null;
1344 LinearGradientBrush lgbr = null;
1346 switch ( scroll_button_type )
1348 case ScrollButton.Left:
1349 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 1, area.Y ), use_color, Color.White );
1350 lgbr.Blend = FlatBlend;
1351 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1353 points = new Point[] {
1354 new Point( area.X + 2, area.Y ),
1355 new Point( area.Right - 1, area.Y ),
1356 new Point( area.Right - 1, area.Bottom - 1 ),
1357 new Point( area.X + 2, area.Bottom - 1 ),
1358 new Point( area.X, area.Bottom - 3 ),
1359 new Point( area.X, area.Y + 2 ),
1360 new Point( area.X + 2, area.Y )
1362 dc.DrawPolygon( pen, points );
1364 case ScrollButton.Right:
1365 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 1, area.Y ), Color.White, use_color );
1366 lgbr.Blend = NormalBlend;
1367 dc.FillRectangle( lgbr, area.X, area.Y + 1, area.Width - 1, area.Height - 2 );
1369 points = new Point[] {
1370 new Point( area.X, area.Y ),
1371 new Point( area.Right - 3, area.Y ),
1372 new Point( area.Right - 1, area.Y + 2 ),
1373 new Point( area.Right - 1, area.Bottom - 3 ),
1374 new Point( area.Right - 3, area.Bottom - 1 ),
1375 new Point( area.X, area.Bottom - 1 ),
1376 new Point( area.X, area.Y ),
1378 dc.DrawPolygon( pen, points );
1380 case ScrollButton.Up:
1381 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), use_color, Color.White );
1382 lgbr.Blend = FlatBlend;
1383 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1385 points = new Point[] {
1386 new Point( area.X + 2, area.Y ),
1387 new Point( area.Right - 3, area.Y ),
1388 new Point( area.Right - 1, area.Y + 2 ),
1389 new Point( area.Right - 1, area.Bottom - 1 ),
1390 new Point( area.X, area.Bottom - 1 ),
1391 new Point( area.X, area.Y + 2 ),
1392 new Point( area.X + 2, area.Y )
1394 dc.DrawPolygon( pen, points );
1396 case ScrollButton.Down:
1397 lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), Color.White, use_color );
1398 lgbr.Blend = NormalBlend;
1399 dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
1401 points = new Point[] {
1402 new Point( area.X, area.Y ),
1403 new Point( area.Right - 1, area.Y ),
1404 new Point( area.Right - 1, area.Bottom - 3 ),
1405 new Point( area.Right - 3, area.Bottom - 1 ),
1406 new Point( area.X + 2, area.Bottom - 1 ),
1407 new Point( area.X, area.Bottom - 3 ),
1408 new Point( area.X, area.Y )
1410 dc.DrawPolygon( pen, points );
1418 public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box)
1420 StringFormat text_format;
1426 rect = box.ClientRectangle;
1428 dc.FillRectangle (ResPool.GetSolidBrush (box.BackColor), rect);
1430 text_format = new StringFormat();
1431 text_format.HotkeyPrefix = HotkeyPrefix.Show;
1433 size = dc.MeasureString (box.Text, box.Font);
1434 width = (int) size.Width;
1436 if (width > box.Width - 16)
1437 width = box.Width - 16;
1439 y = box.Font.Height / 2;
1441 Pen pen = ResPool.GetPen( BorderColor );
1444 Point[] points = new Point[] {
1445 new Point( 8 + width, y ),
1446 new Point( box.Width - 3, y ),
1447 new Point( box.Width - 1, y + 2 ),
1448 new Point( box.Width - 1, box.Height - 3 ),
1449 new Point( box.Width - 3, box.Height - 1 ),
1450 new Point( 2, box.Height - 1 ),
1451 new Point( 0, box.Height - 3 ),
1452 new Point( 0, y + 2 ),
1456 dc.DrawLines( pen, points );
1460 dc.DrawString (box.Text, box.Font, ResPool.GetSolidBrush (box.ForeColor), 10, 0, text_format);
1462 CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor,
1463 new RectangleF (10, 0, width, box.Font.Height), text_format);
1465 text_format.Dispose ();