// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Copyright (c) 2004-2005 Novell, Inc.
+// Copyright (c) 2006 Alexander Olk
//
// Authors:
-// Alexander Olk, xenomorph2@onlinehome.de
+// Alexander Olk, alex.olk@googlemail.com
//
// based on ThemeWin32Classic
//
namespace System.Windows.Forms
{
-
internal class ThemeNice : ThemeWin32Classic
{
public override Version Version
{
get {
- return new Version( 0, 0, 0, 1 );
+ return new Version( 0, 0, 0, 3 );
}
}
- /* Default colors for nice theme */
- uint [] theme_colors = { /* AARRGGBB */
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_SCROLLBAR, 0xffc0c0c0,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_BACKGROUND, 0xffefebe7,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_ACTIVECAPTION, 0xff000080,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVECAPTION, 0xff808080,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_MENU, 0xffefebe7,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOW, 0xffffffff,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOWFRAME, 0xff000000,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_MENUTEXT, 0xff000000,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_WINDOWTEXT, 0xff000000,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_CAPTIONTEXT, 0xffffffff,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_ACTIVEBORDER, 0xffc0c0c0,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVEBORDER, 0xffc0c0c0,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_APPWORKSPACE, 0xff808080,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_HIGHLIGHT, 0xff000080,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_HIGHLIGHTTEXT, 0xffffffff,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNFACE, 0xffefebe7,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNSHADOW, 0xff808080,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_GRAYTEXT, 0xff808080,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNTEXT, 0xff000000,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_INACTIVECAPTIONTEXT, 0xffc0c0c0,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_BTNHIGHLIGHT, 0xffffffff,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_3DDKSHADOW, 0xff000000,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_3DLIGHT, 0xffe0e0e0,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_INFOTEXT, 0xff000000,
- (uint) XplatUIWin32.GetSysColorIndex.COLOR_INFOBK, 0xffffffff,
-
- };
-
static readonly Color NormalColor = Color.LightGray;
static readonly Color MouseOverColor = Color.DarkGray;
static readonly Color PressedColor = Color.Gray;
static readonly Color FocusColor = Color.FromArgb( System.Convert.ToInt32( "0xff00c0ff", 16 ) );
-// static uint uifc = 0xff00c0ff;
-// static readonly Color xFocusColor = Color.FromArgb( (int)uifc );
+ static readonly Color FocusColorLight = Color.FromArgb(250, 253, 255);
static readonly Color LightColor = Color.LightGray;
static readonly Color BorderColor = MouseOverColor;
static readonly Color NiceBackColor = Color.FromArgb( System.Convert.ToInt32( "0xffefebe7", 16 ) );
+ static Bitmap size_grip_bmp = CreateSizegripDot();
+
+ static Blend NormalBlend;
+ static Blend FlatBlend;
+
#region Principal Theme Methods
public ThemeNice( )
{
- /* Init Default colour array*/
- syscolors = Array.CreateInstance( typeof (Color), (uint) XplatUIWin32.GetSysColorIndex.COLOR_MAXVALUE + 1 );
+ ColorControl = NiceBackColor;
+
+ FlatBlend = new Blend ();
+ FlatBlend.Factors = new float []{0.0f, 0.992f, 1.0f};
+ FlatBlend.Positions = new float []{0.0f, 0.68f, 1.0f};
- for ( int i = 0; i < theme_colors.Length; i += 2 )
- syscolors.SetValue( Color.FromArgb( (int)theme_colors[ i + 1 ] ), (int) theme_colors[ i ] );
+ NormalBlend = new Blend ();
+ NormalBlend.Factors = new float []{0.0f, 0.008f, 1.0f};
+ NormalBlend.Positions = new float []{0.0f, 0.32f, 1.0f};
}
public override Color DefaultControlBackColor
public override Color DefaultWindowBackColor
{
- get { return NiceBackColor; }
+ get { return NiceBackColor; }
+ }
+
+ public override Color ColorControl {
+ get { return NiceBackColor;}
+ }
+
+ static Bitmap CreateSizegripDot()
+ {
+ Bitmap bmp = new Bitmap( 4, 4 );
+ using ( Graphics dc = Graphics.FromImage( bmp ) )
+ {
+ SmoothingMode old_smoothing_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
+
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 4, 4 ), PressedColor, Color.White ) ) {
+ Blend bl = new Blend ();
+ bl.Factors = new float []{0.0f, 0.992f, 1.0f};
+ bl.Positions = new float []{0.0f, 0.68f, 1.0f};
+ lgbr.Blend = bl;
+ dc.FillEllipse( lgbr, new Rectangle( 0, 0, 4, 4 ) );
+ }
+
+ dc.SmoothingMode = old_smoothing_mode;
+ }
+
+ return bmp;
+ }
+
+ public override Image Images(UIIcon index, int size) {
+ switch (index) {
+ case UIIcon.PlacesRecentDocuments:
+ if (XplatUI.RunningOnUnix)
+ return MimeIconEngine.GetIconForMimeTypeAndSize( "recently/recently", new Size(size, size) );
+ else
+ return base.Images (UIIcon.PlacesRecentDocuments, size);
+ case UIIcon.PlacesDesktop:
+ if (XplatUI.RunningOnUnix)
+ return MimeIconEngine.GetIconForMimeTypeAndSize( "desktop/desktop", new Size(size, size) );
+ else
+ return base.Images (UIIcon.PlacesDesktop, size);
+ case UIIcon.PlacesPersonal:
+ if (XplatUI.RunningOnUnix)
+ return MimeIconEngine.GetIconForMimeTypeAndSize( "directory/home", new Size(size, size) );
+ else
+ return base.Images (UIIcon.PlacesPersonal, size);
+ case UIIcon.PlacesMyComputer:
+ if (XplatUI.RunningOnUnix)
+ return MimeIconEngine.GetIconForMimeTypeAndSize( "workplace/workplace", new Size(size, size) );
+ else
+ return base.Images (UIIcon.PlacesMyComputer, size);
+ case UIIcon.PlacesMyNetwork:
+ if (XplatUI.RunningOnUnix)
+ return MimeIconEngine.GetIconForMimeTypeAndSize( "network/network", new Size(size, size) );
+ else
+ return base.Images (UIIcon.PlacesMyNetwork, size);
+
+ // Icons for message boxes
+ case UIIcon.MessageBoxError: return base.Images (UIIcon.MessageBoxError, size);
+ case UIIcon.MessageBoxInfo: return base.Images (UIIcon.MessageBoxInfo, size);
+ case UIIcon.MessageBoxQuestion: return base.Images (UIIcon.MessageBoxQuestion, size);
+ case UIIcon.MessageBoxWarning: return base.Images (UIIcon.MessageBoxWarning, size);
+
+ // misc Icons
+ case UIIcon.NormalFolder:
+ if (XplatUI.RunningOnUnix)
+ return MimeIconEngine.GetIconForMimeTypeAndSize( "inode/directory", new Size(size, size) );
+ else
+ return base.Images (UIIcon.NormalFolder, size);
+
+ default: {
+ throw new ArgumentException("Invalid Icon type requested", "index");
+ }
+ }
}
#endregion // Internal Methods
#region ButtonBase
- protected override void ButtonBase_DrawButton( ButtonBase button, Graphics dc )
+ protected override void ButtonBase_DrawButton (ButtonBase button, Graphics dc)
{
- int width;
- int height;
- Rectangle buttonRectangle;
-
- width = button.ClientSize.Width;
- height = button.ClientSize.Height;
-
- dc.FillRectangle( ResPool.GetSolidBrush( button.BackColor ), button.ClientRectangle );
+ bool check_or_radio = false;
+ bool check_or_radio_checked = false;
- // set up the button rectangle
- buttonRectangle = button.ClientRectangle;
+ Color use_color = NormalColor;
+ Color first_color = Color.White;
- Color use_color;
+ dc.FillRectangle (ResPool.GetSolidBrush (button.BackColor), button.ClientRectangle);
- if ( ( ( button.GetType( ) == typeof( CheckBox ) ) && ( ( (CheckBox)button ).check_state == CheckState.Checked ) ) ||
- ( ( button.GetType( ) == typeof( RadioButton ) ) && ( ( (RadioButton)button ).check_state == CheckState.Checked ) ) )
- {
- use_color = PressedColor;
+ if (button is CheckBox) {
+ check_or_radio = true;
+ check_or_radio_checked = ((CheckBox)button).Checked;
+ } else if (button is RadioButton) {
+ check_or_radio = true;
+ check_or_radio_checked = ((RadioButton)button).Checked;
}
- else
- if ( !button.is_enabled )
- {
- use_color = NormalColor;
- button.is_entered = false;
- }
- else
- if ( !button.is_entered )
- {
- use_color = NormalColor;
- }
- else
- {
- if ( !button.is_pressed )
- use_color = MouseOverColor;
- else
- use_color = PressedColor;
+
+ if (button.has_focus && !check_or_radio && button.is_enabled)
+ first_color = FocusColorLight;
+
+ if (button.is_enabled) {
+ if (button.FlatStyle == FlatStyle.Popup) {
+ if (!button.is_pressed && button.is_entered && !check_or_radio_checked)
+ use_color = MouseOverColor;
+ } else if (button.FlatStyle == FlatStyle.Flat) {
+ if (button.is_entered && !button.is_pressed && !check_or_radio_checked)
+ use_color = MouseOverColor;
+ } else {
+ if (!button.is_pressed && button.is_entered && !check_or_radio_checked)
+ use_color = MouseOverColor;
+ }
}
+ Rectangle buttonRectangle;
+
+ int height = button.ClientSize.Height;
+
+ // set up the button rectangle
+ buttonRectangle = button.ClientRectangle;
+
// Fill button with a nice linear gradient brush
- Rectangle lgbRectangle = Rectangle.Inflate( buttonRectangle, -2, -1 );
+ Rectangle lgbRectangle = Rectangle.Inflate (buttonRectangle, -1, -1);
- if ( button.flat_style != FlatStyle.Popup || ( ( button.flat_style == FlatStyle.Popup ) && button.is_entered ) )
- {
+ if (button.FlatStyle != FlatStyle.Popup || ((button.FlatStyle == FlatStyle.Popup) && button.is_entered)) {
LinearGradientBrush lgbr;
- if ( button.flat_style == FlatStyle.Flat )
- lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, height - 1 ), use_color, Color.White );
- else
- lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, height - 1 ), Color.White, use_color );
- dc.FillRectangle( lgbr, lgbRectangle );
- lgbr.Dispose( );
+ if (!button.is_pressed && !check_or_radio_checked) {
+ if (button.FlatStyle == FlatStyle.Flat) {
+ lgbr = new LinearGradientBrush (new Point (0, 0), new Point (0, height - 1), use_color, first_color);
+ lgbr.Blend = FlatBlend;
+ } else {
+ lgbr = new LinearGradientBrush (new Point (0, 0), new Point (0, height - 1), first_color, use_color);
+ lgbr.Blend = NormalBlend;
+ }
+ } else {
+ lgbr = new LinearGradientBrush (new Point (0, 0), new Point (0, height - 1), PressedColor, MouseOverColor);
+ }
+ dc.FillRectangle (lgbr, lgbRectangle);
+ lgbr.Dispose ();
- Pen pen = ResPool.GetPen( BorderColor );
- dc.DrawLine( pen, 3, 0, width - 4, 0 );
- dc.DrawLine( pen, width - 1, 3, width - 1, height - 4 );
- dc.DrawLine( pen, 3, height - 1, width - 4, height - 1 );
- dc.DrawLine( pen, 0, 3, 0, height - 4 );
+ if (button.has_focus && !check_or_radio)
+ return;
- dc.DrawCurve( pen, new Point[] { new Point( 0, 4 ), new Point( 4, 0 ) } );
- dc.DrawCurve( pen, new Point[] { new Point( 0, height - 4 ), new Point( 4, height ) } );
- dc.DrawCurve( pen, new Point[] { new Point( width - 4, 0 ), new Point( width, 4 ) } );
- dc.DrawCurve( pen, new Point[] { new Point( width, height - 4 ), new Point( width - 4, height ) } );
+ Internal_DrawButton(dc, buttonRectangle, BorderColor);
}
}
- protected override void ButtonBase_DrawFocus( ButtonBase button, Graphics dc )
+ private void Internal_DrawButton(Graphics dc, Rectangle area, Color border_color)
{
- int width = button.ClientSize.Width;
- int height = button.ClientSize.Height;
+ Point[] points = new Point [] {
+ new Point (area.X + 1, area.Y),
+ new Point (area.Right - 2, area.Y),
+ new Point (area.Right - 2, area.Y + 1),
+ new Point (area.Right - 1, area.Y + 1),
+ new Point (area.Right - 1, area.Bottom - 2),
+ new Point (area.Right - 2, area.Bottom - 2),
+ new Point (area.Right - 2, area.Bottom - 1),
+ new Point (area.X + 1, area.Bottom - 1),
+ new Point (area.X + 1, area.Bottom - 2),
+ new Point (area.X, area.Bottom - 2),
+ new Point (area.X, area.Y + 1),
+ new Point (area.X + 1, area.Y + 1),
+ new Point (area.X + 1, area.Y)
+ };
- Pen pen = ResPool.GetPen( FocusColor );
- dc.DrawLine( pen, 4, 1, width - 5, 1 );
- dc.DrawLine( pen, width - 2, 4, width - 2, height - 5 );
- dc.DrawLine( pen, 4, height - 2, width - 5, height - 2 );
- dc.DrawLine( pen, 1, 4, 1, height - 5 );
+ Pen pen = ResPool.GetPen (border_color);
+ dc.DrawPolygon (pen, points);
+ }
+
+ protected override void ButtonBase_DrawFocus( ButtonBase button, Graphics dc )
+ {
+ if ((button is RadioButton) || (button is CheckBox))
+ return;
- dc.DrawCurve( pen, new Point[] { new Point( 1, 5 ), new Point( 5, 1 ) } );
- dc.DrawCurve( pen, new Point[] { new Point( 1, height - 5 ), new Point( 5, height - 1 ) } );
- dc.DrawCurve( pen, new Point[] { new Point( width - 5, 1 ), new Point( width - 1, 5 ) } );
- dc.DrawCurve( pen, new Point[] { new Point( width - 1, height - 5 ), new Point( width - 5, height - 1 ) } );
+ Internal_DrawButton(dc, button.ClientRectangle, FocusColor);
}
protected override void ButtonBase_DrawText( ButtonBase button, Graphics dc )
{
- if ( button.GetType( ) != typeof( CheckBox ) && button.GetType( ) != typeof( RadioButton ) )
+ if ( !( button is CheckBox ) && !(button is RadioButton ) )
{
base.ButtonBase_DrawText( button, dc );
}
}
#endregion // ButtonBase
- #region CheckBox
- protected override void CheckBox_DrawCheckBox( Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle )
- {
- dc.FillRectangle( ResPool.GetSolidBrush( checkbox.BackColor ), checkbox.ClientRectangle );
- // render as per normal button
- if ( checkbox.appearance == Appearance.Button )
- {
- DrawButtonBase( dc, checkbox.ClientRectangle, checkbox );
- }
- else
- {
- // establish if we are rendering a flat style of some sort
- if ( checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup )
- {
- DrawFlatStyleCheckBox( dc, checkbox_rectangle, checkbox );
- }
- else
- {
- ControlPaint.DrawCheckBox( dc, checkbox_rectangle, state );
- }
- }
- }
- #endregion // CheckBox
-
- #region ComboBox
-
- // Drawing
-
- public override void DrawComboBoxEditDecorations( Graphics dc, ComboBox ctrl, Rectangle cl )
+ #region Menus
+ public override void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect)
{
- dc.DrawRectangle( ResPool.GetPen( BorderColor ) , cl.X + 1, cl.Y + 1, cl.Width - 3, cl.Height - 3 );
+ if (menu.Height == 0)
+ CalcMenuBarSize (dc, menu, rect.Width);
+
+ bool keynav = (menu as MainMenu).tracker.Navigating;
+ HotkeyPrefix hp = MenuAccessKeysUnderlined || keynav ? HotkeyPrefix.Show : HotkeyPrefix.Hide;
+ string_format_menu_menubar_text.HotkeyPrefix = hp;
+ string_format_menu_text.HotkeyPrefix = hp;
+
+ rect.Height = menu.Height;
+ dc.FillRectangle (ResPool.GetSolidBrush (NiceBackColor), rect);
+
+ for (int i = 0; i < menu.MenuItems.Count; i++) {
+ MenuItem item = menu.MenuItems [i];
+ Rectangle item_rect = item.bounds;
+ item_rect.X += rect.X;
+ item_rect.Y += rect.Y;
+ item.MenuHeight = menu.Height;
+ item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont, item_rect, i, item.Status));
+ }
}
- public override void DrawComboListBoxDecorations( Graphics dc, ComboBox ctrl, Rectangle cl )
- {
- if ( ctrl.DropDownStyle == ComboBoxStyle.Simple )
- {
- DrawComboBoxEditDecorations( dc, ctrl, cl );
- }
- else
- {
- dc.DrawRectangle( ResPool.GetPen( ThemeEngine.Current.ColorWindowFrame ), cl.X, cl.Y, cl.Width - 1, cl.Height - 1 );
- }
- }
- #endregion ComboBox
-
- #region Menus
- public override void DrawMenuItem( MenuItem item, DrawItemEventArgs e )
+ public override void DrawMenuItem (MenuItem item, DrawItemEventArgs e)
{
StringFormat string_format;
Rectangle rect_text = e.Bounds;
- if ( item.Visible == false )
+ if (item.Visible == false)
return;
- if ( item.MenuBar )
- {
+ if (item.MenuBar)
string_format = string_format_menu_menubar_text;
- }
else
- {
string_format = string_format_menu_text;
- }
- if ( item.Separator == true )
- {
- e.Graphics.DrawLine( ThemeEngine.Current.ResPool.GetPen( LightColor ),
- e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y );
+ if (item.Separator == true) {
+ e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
+ e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y);
- e.Graphics.DrawLine( ThemeEngine.Current.ResPool.GetPen( ThemeEngine.Current.ColorControlLight ),
- e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + 1 );
+ e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
+ e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + 1);
return;
}
- if ( !item.MenuBar )
- rect_text.X += ThemeEngine.Current.MenuCheckSize.Width;
+ if (!item.MenuBar)
+ rect_text.X += MenuCheckSize.Width;
- if ( item.BarBreak )
- { /* Draw vertical break bar*/
+ if (item.BarBreak) { /* Draw vertical break bar*/
Rectangle rect = e.Bounds;
rect.Y++;
- rect.Width = 3;
- rect.Height = item.MenuHeight - 6;
+ rect.Width = 3;
+ rect.Height = item.MenuHeight - 6;
- e.Graphics.DrawLine( ThemeEngine.Current.ResPool.GetPen( LightColor ),
- rect.X, rect.Y , rect.X, rect.Y + rect.Height );
+ e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
+ rect.X, rect.Y , rect.X, rect.Y + rect.Height);
- e.Graphics.DrawLine( ThemeEngine.Current.ResPool.GetPen( ThemeEngine.Current.ColorControlLight ),
- rect.X + 1, rect.Y , rect.X + 1, rect.Y + rect.Height );
+ e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
+ rect.X + 1, rect.Y , rect.X +1, rect.Y + rect.Height);
}
- Color color_text = ThemeEngine.Current.ColorMenuText;
- Color color_back;
+ Color color_text = ColorMenuText;
+ Color color_back = NiceBackColor;
/* Draw background */
Rectangle rect_back = e.Bounds;
rect_back.X++;
- rect_back.Width -= 2;
+ rect_back.Width -=2;
- if ( ( e.State & DrawItemState.Selected ) == DrawItemState.Selected )
- {
- color_text = ThemeEngine.Current.ColorMenuText;
- color_back = NormalColor;
-
- 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 ) )
- {
- e.Graphics.FillRectangle( lgbr, rect_back );
- }
-
- rect_back.Height--;
- e.Graphics.DrawRectangle( ResPool.GetPen( BorderColor ), rect_back );
- }
- else
- {
- color_text = ThemeEngine.Current.ColorMenuText;
- color_back = NiceBackColor;
-
- e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( NiceBackColor ), rect_back );
+ if (((e.State & DrawItemState.Selected) == DrawItemState.Selected) || ((e.State & DrawItemState.HotLight) == DrawItemState.HotLight)) {
+ 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 ) )
+ e.Graphics.FillRectangle (lgbr, rect_back);
+
+ e.Graphics.DrawRectangle (ResPool.GetPen (BorderColor), rect_back.X, rect_back.Y, rect_back.Width, rect_back.Height - 1);
+ } else {
+ e.Graphics.FillRectangle (ResPool.GetSolidBrush (NiceBackColor), rect_back);
}
- if ( item.Enabled )
- {
- e.Graphics.DrawString( item.Text, e.Font,
- ThemeEngine.Current.ResPool.GetSolidBrush( color_text ),
- rect_text, string_format );
+ if (item.Enabled) {
+ e.Graphics.DrawString (item.Text, e.Font,
+ ResPool.GetSolidBrush (color_text),
+ rect_text, string_format);
- if ( !item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut )
- {
- string str = item.GetShortCutText( );
+ if (!item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut) {
+ string str = item.GetShortCutText ();
Rectangle rect = rect_text;
rect.X = item.XTab;
rect.Width -= item.XTab;
- e.Graphics.DrawString( str, e.Font, ThemeEngine.Current.ResPool.GetSolidBrush( color_text ),
- rect, string_format_menu_shortcut );
+ e.Graphics.DrawString (str, e.Font, ResPool.GetSolidBrush (color_text),
+ rect, string_format_menu_shortcut);
}
- }
- else
- {
- ControlPaint.DrawStringDisabled( e.Graphics, item.Text, e.Font,
- Color.Black, rect_text, string_format );
+
+ } else {
+ ControlPaint.DrawStringDisabled (e.Graphics, item.Text, e.Font,
+ Color.Black, rect_text, string_format);
}
/* Draw arrow */
- if ( item.MenuBar == false && item.IsPopup )
- {
+ if (item.MenuBar == false && item.IsPopup || item.MdiList) {
- int cx = ThemeEngine.Current.MenuCheckSize.Width;
- int cy = ThemeEngine.Current.MenuCheckSize.Height;
- Bitmap bmp = new Bitmap( cx, cy );
- Graphics gr = Graphics.FromImage( bmp );
- Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
- ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Arrow );
- bmp.MakeTransparent( );
+ int cx = MenuCheckSize.Width;
+ int cy = MenuCheckSize.Height;
+ Bitmap bmp = CreateGlyphBitmap (new Size (cx, cy), MenuGlyph.Arrow, color_text);
- if ( item.Enabled )
- {
- e.Graphics.DrawImage( bmp, e.Bounds.X + e.Bounds.Width - cx,
- e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
- }
- else
- {
- ControlPaint.DrawImageDisabled( e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
- e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ), color_back );
+ if (item.Enabled) {
+ e.Graphics.DrawImage (bmp, e.Bounds.X + e.Bounds.Width - cx,
+ e.Bounds.Y + ((e.Bounds.Height - cy) /2));
+ } else {
+ ControlPaint.DrawImageDisabled (e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
+ e.Bounds.Y + ((e.Bounds.Height - cy) /2), color_back);
}
- gr.Dispose( );
- bmp.Dispose( );
+ bmp.Dispose ();
}
/* Draw checked or radio */
- if ( item.MenuBar == false && item.Checked )
- {
+ if (item.MenuBar == false && item.Checked) {
Rectangle area = e.Bounds;
- int cx = ThemeEngine.Current.MenuCheckSize.Width;
- int cy = ThemeEngine.Current.MenuCheckSize.Height;
- Bitmap bmp = new Bitmap( cx, cy );
- Graphics gr = Graphics.FromImage( bmp );
- Rectangle rect_arrow = new Rectangle( 0, 0, cx, cy );
+ int cx = MenuCheckSize.Width;
+ int cy = MenuCheckSize.Height;
+ Bitmap bmp = CreateGlyphBitmap (new Size (cx, cy), item.RadioCheck ? MenuGlyph.Bullet : MenuGlyph.Checkmark, color_text);
- if ( item.RadioCheck )
- ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Bullet );
- else
- ControlPaint.DrawMenuGlyph( gr, rect_arrow, MenuGlyph.Checkmark );
-
- bmp.MakeTransparent( );
- e.Graphics.DrawImage( bmp, area.X, e.Bounds.Y + ( ( e.Bounds.Height - cy ) / 2 ) );
+ e.Graphics.DrawImage (bmp, area.X, e.Bounds.Y + ((e.Bounds.Height - cy) / 2));
- gr.Dispose( );
- bmp.Dispose( );
- }
+ bmp.Dispose ();
+ }
+ }
+
+ public override void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect)
+ {
+
+ dc.FillRectangle (ResPool.GetSolidBrush
+ (NiceBackColor), cliparea);
+
+ /* Draw menu borders */
+ dc.DrawLine (ResPool.GetPen (ColorHighlightText),
+ rect.X, rect.Y, rect.X + rect.Width, rect.Y);
+
+ dc.DrawLine (ResPool.GetPen (ColorHighlightText),
+ rect.X, rect.Y, rect.X, rect.Y + rect.Height);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDark),
+ rect.X + rect.Width - 1 , rect.Y , rect.X + rect.Width - 1, rect.Y + rect.Height);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
+ rect.X + rect.Width, rect.Y , rect.X + rect.Width, rect.Y + rect.Height);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDark),
+ rect.X , rect.Y + rect.Height - 1 , rect.X + rect.Width - 1, rect.Y + rect.Height -1);
+
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
+ rect.X , rect.Y + rect.Height, rect.X + rect.Width - 1, rect.Y + rect.Height);
+
+ for (int i = 0; i < menu.MenuItems.Count; i++)
+ if (cliparea.IntersectsWith (menu.MenuItems [i].bounds)) {
+ MenuItem item = menu.MenuItems [i];
+ item.MenuHeight = menu.Height;
+ item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont,
+ item.bounds, i, item.Status));
+ }
}
#endregion // Menus
barpos_pixels = ( ( ctrl.Value - ctrl.Minimum ) * client_area.Width ) / ( ctrl.Maximum - ctrl.Minimum );
bar.Width = barpos_pixels;
- bar.Height += 1;
+// bar.Height += 1;
// Draw bar background
using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( client_area.Left, client_area.Top ), new Point( client_area.Left, client_area.Bottom ), LightColor, Color.White ) )
{
+ lgbr.Blend = FlatBlend;
dc.FillRectangle( lgbr, client_area );
}
// Draw bar
- using ( LinearGradientBrush lgbr = new LinearGradientBrush( bar.Location, new Point( bar.X, bar.Bottom ), Color.White, FocusColor ) )
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( bar.Location, new Point( bar.X, bar.Bottom ), Color.White, PressedColor ) )
{
+ lgbr.Blend = NormalBlend;
dc.FillRectangle( lgbr, bar );
}
}
#endregion // ProgressBar
- #region RadioButton
- // TODO: fix RadioButton focus
- protected override void RadioButton_DrawButton( RadioButton radio_button, Graphics dc, ButtonState state, Rectangle radiobutton_rectangle )
- {
- SolidBrush sb = new SolidBrush( radio_button.BackColor );
- dc.FillRectangle( sb, radio_button.ClientRectangle );
- sb.Dispose( );
-
- if ( radio_button.appearance == Appearance.Button )
- {
- DrawButtonBase( dc, radio_button.ClientRectangle, radio_button );
- }
- else
- {
- // establish if we are rendering a flat style of some sort
- if ( radio_button.FlatStyle == FlatStyle.Flat || radio_button.FlatStyle == FlatStyle.Popup )
- {
- DrawButtonBase( dc, radio_button.ClientRectangle, radio_button );
- }
- else
- {
- ControlPaint.DrawRadioButton( dc, radiobutton_rectangle, state );
- }
- }
- }
- #endregion // RadioButton
-
#region ScrollBar
protected override void ScrollBar_DrawThumb( ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
{
if ( bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith( thumb_pos ) )
DrawScrollBarThumb( dc, thumb_pos, bar );
}
-
- protected override void ScrollBar_Vertical_Draw_ThumbMoving_None( int scrollbutton_height, ScrollBar bar, Rectangle clip, Graphics dc )
- {
- Rectangle r = new Rectangle( 0,
- scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - ( scrollbutton_height * 2 ) );
- Rectangle intersect = Rectangle.Intersect( clip, r );
-
- if ( intersect != Rectangle.Empty )
- {
- using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
- {
- dc.FillRectangle( lgbr, intersect );
- }
- }
- }
-
- protected override void ScrollBar_Vertical_Draw_ThumbMoving_Forward( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
- {
- Rectangle r = new Rectangle( 0, scrollbutton_height,
- bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
- Rectangle intersect = Rectangle.Intersect( clip, r );
-
- using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
- {
- if ( intersect != Rectangle.Empty )
- dc.FillRectangle( lgbr, intersect );
-
- r.X = 0;
- r.Y = thumb_pos.Y + thumb_pos.Height;
- r.Width = bar.ClientRectangle.Width;
- r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
-
- intersect = Rectangle.Intersect( clip, r );
- if ( intersect != Rectangle.Empty )
- dc.FillRectangle( lgbr, intersect );
- }
- }
-
- protected override void ScrollBar_Vertical_Draw_ThumbMoving_Backwards( int scrollbutton_height, ScrollBar bar, Rectangle thumb_pos, Rectangle clip, Graphics dc )
- {
- Rectangle r = new Rectangle( 0, scrollbutton_height,
- bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height );
- Rectangle intersect = Rectangle.Intersect( clip, r );
-
- using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( r. Width - 1, 0 ), LightColor, Color.White ) )
- {
- if ( intersect != Rectangle.Empty )
- dc.FillRectangle( lgbr, intersect );
-
- r.X = 0;
- r.Y = thumb_pos.Y + thumb_pos.Height;
- r.Width = bar.ClientRectangle.Width;
- r.Height = bar.ClientRectangle.Height - ( thumb_pos.Y + thumb_pos.Height ) - scrollbutton_height;
-
- intersect = Rectangle.Intersect( clip, r );
- if ( intersect != Rectangle.Empty )
- dc.FillRectangle( lgbr, intersect );
- }
- }
-
- protected override void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc )
- {
- Rectangle r = new Rectangle( scrollbutton_width,
- 0, bar.ClientRectangle.Width - ( scrollbutton_width * 2 ), bar.ClientRectangle.Height );
- Rectangle intersect = Rectangle.Intersect( clip, r );
-
- if ( intersect != Rectangle.Empty )
- {
- using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
- {
- dc.FillRectangle( lgbr, intersect );
- }
- }
- }
-
- protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
- {
- Rectangle r = new Rectangle( scrollbutton_width, 0,
- thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
- Rectangle intersect = Rectangle.Intersect( clip, r );
-
- using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
- {
- if ( intersect != Rectangle.Empty )
- dc.FillRectangle( lgbr, intersect );
-
- r.X = thumb_pos.X + thumb_pos.Width;
- r.Y = 0;
- r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
- r.Height = bar.ClientRectangle.Height;
-
- intersect = Rectangle.Intersect( clip, r );
- if ( intersect != Rectangle.Empty )
- dc.FillRectangle( lgbr, intersect );
- }
- }
-
- protected override void ScrollBar_Horizontal_Draw_ThumbMoving_Backwards( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
- {
- Rectangle r = new Rectangle( scrollbutton_width, 0,
- thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height );
- Rectangle intersect = Rectangle.Intersect( clip, r );
-
- using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 0, r.Height - 1 ), LightColor, Color.White ) )
- {
- if ( intersect != Rectangle.Empty )
- dc.FillRectangle( lgbr, intersect );
-
- r.X = thumb_pos.X + thumb_pos.Width;
- r.Y = 0;
- r.Width = bar.ClientRectangle.Width - ( thumb_pos.X + thumb_pos.Width ) - scrollbutton_width;
- r.Height = bar.ClientRectangle.Height;
-
- intersect = Rectangle.Intersect( clip, r );
- if ( intersect != Rectangle.Empty )
- dc.FillRectangle( lgbr, intersect );
- }
- }
#endregion // ScrollBar
#region StatusBar
protected override void DrawStatusBarPanel( Graphics dc, Rectangle area, int index,
- SolidBrush br_forecolor, StatusBarPanel panel )
+ Brush br_forecolor, StatusBarPanel panel )
{
int border_size = 3; // this is actually const, even if the border style is none
area.Height -= border_size;
if ( panel.BorderStyle != StatusBarPanelBorderStyle.None )
{
- DrawNiceRoundedBorder( dc, area, BorderColor );
+ Internal_DrawButton( dc, area, BorderColor );
}
if ( panel.Style == StatusBarPanelStyle.OwnerDraw )
dc.DrawString( text, panel.Parent.Font, br_forecolor, r, string_format );
}
-
- private void DrawNiceRoundedBorder( Graphics dc, Rectangle area, Color color )
- {
- Pen pen = ResPool.GetPen( color );
-
- Point[] points = new Point[] {
- new Point( area.Left + 2, area.Top ),
- new Point( area.Right - 3, area.Top ),
- new Point( area.Right, area.Top + 3 ),
- new Point( area.Right, area.Bottom - 2 ),
- new Point( area.Right - 3, area.Bottom ),
- new Point( area.Left + 2, area.Bottom ),
- new Point( area.Left, area.Bottom - 2 ),
- new Point( area.Left, area.Top + 3 ),
- new Point( area.Left + 2, area.Top )
- };
-
- dc.DrawLines( pen, points );
- }
#endregion // StatusBar
public override void DrawTabControl( Graphics dc, Rectangle area, TabControl tab )
{
// Do we need to fill the back color? It can't be changed...
- dc.FillRectangle( GetControlBackBrush( tab.BackColor ), area );
- Rectangle panel_rect = GetTabPanelRectExt( tab );
+ dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), area );
+ Rectangle panel_rect = TabControlGetPanelRect( tab );
if ( tab.Appearance == TabAppearance.Normal )
{
if ( tab.ShowSlider )
{
- Rectangle right = GetTabControlRightScrollRect( tab );
- Rectangle left = GetTabControlLeftScrollRect( tab );
+ Rectangle right = TabControlGetRightScrollRect( tab );
+ Rectangle left = TabControlGetLeftScrollRect( tab );
CPDrawScrollButton( dc, right, ScrollButton.Right, tab.RightSliderState );
CPDrawScrollButton( dc, left, ScrollButton.Left, tab.LeftSliderState );
}
}
- protected override int DrawTab( Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected )
+ protected virtual int DrawTab( Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected )
{
int FlatButtonSpacing = 8;
Rectangle interior;
if ( tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons )
{
- dc.FillRectangle( GetControlBackBrush( tab.BackColor ), bounds );
+ dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), bounds );
// Separators
if ( tab.Appearance == TabAppearance.FlatButtons )
if ( is_selected )
{
- CPDrawBorder3D( dc, bounds, Border3DStyle.Sunken, Border3DSide.All );
+ CPDrawBorder3D( dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
}
else if ( tab.Appearance != TabAppearance.FlatButtons )
{
- CPDrawBorder3D( dc, bounds, Border3DStyle.Raised, Border3DSide.All );
+ CPDrawBorder3D( dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
}
interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4 );
-
StringFormat string_format = new StringFormat( );
string_format.Alignment = StringAlignment.Center;
string_format.LineAlignment = StringAlignment.Center;
string_format.FormatFlags = StringFormatFlags.NoWrap;
interior.Y++;
- dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
+ dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
interior.Y--;
}
else
{
Pen border_pen = ResPool.GetPen( BorderColor );
+ dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), bounds );
+
switch ( tab.Alignment )
{
case TabAlignment.Top:
- dc.FillRectangle( GetControlBackBrush( tab.BackColor ), bounds );
-
if ( !is_selected )
{
interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Left + 2, bounds.Bottom ), Color.White, LightColor ) )
{
+ lgbr.Blend = NormalBlend;
dc.FillRectangle( lgbr, interior );
}
}
string_format.LineAlignment = StringAlignment.Center;
string_format.FormatFlags = StringFormatFlags.NoWrap;
interior.Y++;
- dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
+ dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
interior.Y--;
}
case TabAlignment.Bottom:
- dc.FillRectangle( GetControlBackBrush( tab.BackColor ), bounds );
-
if ( !is_selected )
{
interior = new Rectangle( bounds.Left + 3, bounds.Top, bounds.Width - 3, bounds.Height );
using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 3, bounds.Top ), new Point( bounds.Left + 3, bounds.Bottom ), Color.White, LightColor ) )
{
+ lgbr.Blend = NormalBlend;
dc.FillRectangle( lgbr, interior );
}
}
string_format.LineAlignment = StringAlignment.Center;
string_format.FormatFlags = StringFormatFlags.NoWrap;
interior.Y++;
- dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
+ dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
interior.Y--;
}
case TabAlignment.Left:
- dc.FillRectangle( GetControlBackBrush( tab.BackColor ), bounds );
-
if ( !is_selected )
{
interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Right, bounds.Top + 2 ), LightColor, Color.White ) )
{
+ lgbr.Blend = FlatBlend;
dc.FillRectangle( lgbr, interior );
}
}
int ho = interior.Height / 2;
dc.TranslateTransform( interior.X + wo, interior.Y + ho );
dc.RotateTransform( 180 );
- dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), 0, 0, string_format );
+ dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), 0, 0, string_format );
dc.ResetTransform( );
}
default:
// TabAlignment.Right
- dc.FillRectangle( GetControlBackBrush( tab.BackColor ), bounds );
-
if ( !is_selected )
{
interior = new Rectangle( bounds.Left + 2, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2 );
using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( bounds.Left + 2, bounds.Top + 2 ), new Point( bounds.Right, bounds.Top + 2 ), Color.White, LightColor ) )
{
+ lgbr.Blend = NormalBlend;
dc.FillRectangle( lgbr, interior );
}
}
string_format.FormatFlags = StringFormatFlags.NoWrap;
string_format.FormatFlags = StringFormatFlags.DirectionVertical;
interior.X++;
- dc.DrawString( page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
+ dc.DrawString( page.Text, page.Font, ResPool.GetSolidBrush( SystemColors.ControlText ), interior, string_format );
interior.X--;
}
}
return res;
- }
+ }
+
+ #region ToolBar
+ public override void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control)
+ {
+ StringFormat format = new StringFormat ();
+ format.Trimming = StringTrimming.EllipsisWord;
+ format.LineAlignment = StringAlignment.Center;
+ if (control.TextAlign == ToolBarTextAlign.Underneath)
+ format.Alignment = StringAlignment.Center;
+ else
+ format.Alignment = StringAlignment.Near;
+
+ dc.FillRectangle (ResPool.GetSolidBrush( NiceBackColor ), clip_rectangle);
+
+ foreach (ToolBarItem item in control.items)
+ if (item.Button.Visible && clip_rectangle.IntersectsWith (item.Rectangle))
+ DrawToolBarButton (dc, control, item, format);
+
+ format.Dispose ();
+ }
+
+ protected override void DrawToolBarButton (Graphics dc, ToolBar control, ToolBarItem item, StringFormat format)
+ {
+ bool is_flat = control.Appearance == ToolBarAppearance.Flat;
+
+ if (item.Button.Style != ToolBarButtonStyle.Separator)
+ DoDrawToolBarButton (dc, item, is_flat);
+
+ switch (item.Button.Style) {
+ case ToolBarButtonStyle.DropDownButton:
+ if (control.DropDownArrows)
+ DrawToolBarDropDownArrow (dc, item, is_flat);
+ DrawToolBarButtonContents (dc, control, item, format);
+ break;
+
+ case ToolBarButtonStyle.Separator:
+ if (is_flat)
+ DrawToolBarSeparator (dc, item);
+ break;
+
+ case ToolBarButtonStyle.ToggleButton:
+ default:
+ DrawToolBarButtonContents (dc, control, item, format);
+ break;
+ }
+ }
+
+ const Border3DSide all_sides = Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom;
+
+ void DoDrawToolBarButton (Graphics dc, ToolBarItem item, bool is_flat)
+ {
+ Color use_color = NormalColor;
+ Color first_color = Color.White;
+
+ if (is_flat) {
+ if (item.Button.Pushed || item.Pressed) {
+ first_color = PressedColor;
+ use_color = MouseOverColor;
+ } else
+ if (item.Hilight)
+ use_color = MouseOverColor;
+ else
+ return;
+ } else {
+ if (item.Button.Pushed || item.Pressed) {
+ first_color = PressedColor;
+ use_color = MouseOverColor;
+ } else
+ if (item.Hilight)
+ use_color = MouseOverColor;
+ }
+
+ Rectangle buttonRectangle = item.Rectangle;
+
+ Rectangle lgbRectangle = Rectangle.Inflate (buttonRectangle, -1, -1);
+
+ using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (buttonRectangle.X, buttonRectangle.Y), new Point (buttonRectangle.X, buttonRectangle.Bottom - 1), first_color, use_color)) {
+ lgbr.Blend = NormalBlend;
+ dc.FillRectangle (lgbr, lgbRectangle);
+ }
+
+ Internal_DrawButton (dc, buttonRectangle, BorderColor);
+ }
+
+ protected override void DrawToolBarSeparator (Graphics dc, ToolBarItem item)
+ {
+ Rectangle area = item.Rectangle;
+ int offset = (int) ResPool.GetPen (ColorControl).Width + 1;
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), area.X + 1, area.Y, area.X + 1, area.Bottom);
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), area.X + offset, area.Y, area.X + offset, area.Bottom);
+ }
+
+ protected override void DrawToolBarDropDownArrow (Graphics dc, ToolBarItem item, bool is_flat)
+ {
+ Rectangle rect = item.Rectangle;
+ rect.X = item.Rectangle.Right - ToolBarDropDownWidth;
+ rect.Width = ToolBarDropDownWidth;
+
+ if (item.DDPressed) {
+ CPDrawBorder3D (dc, rect, Border3DStyle.SunkenOuter, all_sides);
+ CPDrawBorder3D (dc, rect, Border3DStyle.SunkenInner, Border3DSide.Bottom | Border3DSide.Right);
+ } else if (item.Button.Pushed || item.Pressed)
+ CPDrawBorder3D (dc, rect, Border3DStyle.Sunken, all_sides);
+ else if (is_flat) {
+ if (item.Hilight)
+ CPDrawBorder3D (dc, rect, Border3DStyle.RaisedOuter, all_sides);
+ } else
+ CPDrawBorder3D (dc, rect, Border3DStyle.Raised, all_sides);
+
+ PointF [] vertices = new PointF [3];
+ PointF ddCenter = new PointF (rect.X + (rect.Width/2.0f), rect.Y + (rect.Height/2.0f));
+ vertices [0].X = ddCenter.X - ToolBarDropDownArrowWidth / 2.0f + 0.5f;
+ vertices [0].Y = ddCenter.Y;
+ vertices [1].X = ddCenter.X + ToolBarDropDownArrowWidth / 2.0f + 0.5f;
+ vertices [1].Y = ddCenter.Y;
+ vertices [2].X = ddCenter.X + 0.5f; // 0.5 is added for adjustment
+ vertices [2].Y = ddCenter.Y + ToolBarDropDownArrowHeight;
+ dc.FillPolygon (SystemBrushes.ControlText, vertices);
+ }
+
+ protected override void DrawToolBarButtonContents (Graphics dc, ToolBar control, ToolBarItem item, StringFormat format)
+ {
+ if (item.Button.Image != null) {
+ int x = item.ImageRectangle.X + ToolBarImageGripWidth;
+ int y = item.ImageRectangle.Y + ToolBarImageGripWidth;
+ if (item.Button.Enabled)
+ dc.DrawImage (item.Button.Image, x, y);
+ else
+ CPDrawImageDisabled (dc, item.Button.Image, x, y, ColorControl);
+ }
+
+ if (item.Button.Enabled)
+ dc.DrawString (item.Button.Text, control.Font, ResPool.GetSolidBrush (ColorControlText), item.TextRectangle, format);
+ else
+ CPDrawStringDisabled (dc, item.Button.Text, control.Font, ColorControlLight, item.TextRectangle, format);
+ }
+
+ #endregion // ToolBar
+
+// public override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides) {
+// CPDrawBorder3D(graphics, rectangle, style, sides, ColorControl);
+// }
+
+ public override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color)
+ {
+ Pen penTopLeft;
+ Pen penTopLeftInner;
+ Pen penBottomRight;
+ Pen penBottomRightInner;
+ Rectangle rect= new Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
+
+ if ((style & Border3DStyle.Adjust) != 0) {
+ rect.Y -= 2;
+ rect.X -= 2;
+ rect.Width += 4;
+ rect.Height += 4;
+ }
+
+ penTopLeft = penTopLeftInner = penBottomRight = penBottomRightInner = ResPool.GetPen (control_color);
+
+ CPColor cpcolor = ResPool.GetCPColor (control_color);
+
+ switch (style) {
+ case Border3DStyle.Raised:
+ penTopLeftInner = ResPool.GetPen (cpcolor.LightLight);
+ penBottomRight = ResPool.GetPen (cpcolor.Dark);
+ penBottomRightInner = ResPool.GetPen (BorderColor);
+ break;
+ case Border3DStyle.Sunken:
+ penTopLeft = ResPool.GetPen (BorderColor);
+ penTopLeftInner = ResPool.GetPen (cpcolor.Dark);
+ penBottomRight = ResPool.GetPen (cpcolor.LightLight);
+ break;
+ case Border3DStyle.Etched:
+ penTopLeft = penBottomRightInner = ResPool.GetPen (BorderColor);
+ penTopLeftInner = penBottomRight = ResPool.GetPen (cpcolor.LightLight);
+ break;
+ case Border3DStyle.RaisedOuter:
+ penBottomRight = ResPool.GetPen (cpcolor.Dark);
+ break;
+ case Border3DStyle.SunkenOuter:
+ penTopLeft = ResPool.GetPen (BorderColor);
+ penBottomRight = ResPool.GetPen (cpcolor.LightLight);
+ break;
+ case Border3DStyle.RaisedInner:
+ penTopLeft = ResPool.GetPen (cpcolor.LightLight);
+ penBottomRight = ResPool.GetPen (BorderColor);
+ break;
+ case Border3DStyle.SunkenInner:
+ penTopLeft = ResPool.GetPen (cpcolor.Dark);
+ break;
+ case Border3DStyle.Flat:
+ penTopLeft = penBottomRight = ResPool.GetPen (BorderColor);
+ break;
+ case Border3DStyle.Bump:
+ penTopLeftInner = penBottomRight = ResPool.GetPen (cpcolor.Dark);
+ break;
+ default:
+ break;
+ }
+
+ if ((sides & Border3DSide.Middle) != 0) {
+ graphics.FillRectangle (ResPool.GetSolidBrush (control_color), rect);
+ }
+
+ if ((sides & Border3DSide.Left) != 0) {
+ graphics.DrawLine (penTopLeft, rect.Left, rect.Bottom - 2, rect.Left, rect.Top);
+ graphics.DrawLine (penTopLeftInner, rect.Left + 1, rect.Bottom - 2, rect.Left + 1, rect.Top);
+ }
+
+ if ((sides & Border3DSide.Top) != 0) {
+ graphics.DrawLine (penTopLeft, rect.Left, rect.Top, rect.Right - 2, rect.Top);
+ graphics.DrawLine (penTopLeftInner, rect.Left + 1, rect.Top + 1, rect.Right - 3, rect.Top + 1);
+ }
+
+ if ((sides & Border3DSide.Right) != 0) {
+ graphics.DrawLine (penBottomRight, rect.Right - 1, rect.Top, rect.Right - 1, rect.Bottom - 1);
+ graphics.DrawLine (penBottomRightInner, rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 2);
+ }
+
+ if ((sides & Border3DSide.Bottom) != 0) {
+ graphics.DrawLine (penBottomRight, rect.Left, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
+ graphics.DrawLine (penBottomRightInner, rect.Left + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2);
+ }
+ }
+
+ public override void CPDrawButton (Graphics dc, Rectangle rectangle, ButtonState state)
+ {
+ dc.FillRectangle (ResPool.GetSolidBrush (NiceBackColor), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2);
+
+ Color first_color = Color.White;
+ Color second_color = NormalColor;
+
+ if ((state & ButtonState.Flat) == ButtonState.Flat) {
+ first_color = NormalColor;
+ second_color = Color.White;
+ } else
+ if (((state & ButtonState.Flat) == ButtonState.Flat) &&
+ (((state & ButtonState.Checked) == ButtonState.Checked) || ((state & ButtonState.Pushed) == ButtonState.Pushed))) {
+ first_color = PressedColor;
+ second_color = Color.White;
+ } else
+ if (((state & ButtonState.Checked) == ButtonState.Checked) || ((state & ButtonState.Pushed) == ButtonState.Pushed)) {
+ second_color = PressedColor;
+ }
+
+ Rectangle lgbRectangle = Rectangle.Inflate (rectangle, -1, -1);
+
+ using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (rectangle.X, rectangle.Y), new Point (rectangle.X, rectangle.Bottom - 1), first_color, second_color)) {
+ if ((state & ButtonState.Flat) == ButtonState.Flat) {
+ lgbr.Blend = FlatBlend;
+ } else {
+ lgbr.Blend = NormalBlend;
+ }
+ dc.FillRectangle (lgbr, lgbRectangle);
+ }
+
+ Internal_DrawButton(dc, rectangle, BorderColor);
+ }
public override void CPDrawComboButton( Graphics dc, Rectangle rectangle, ButtonState state )
{
Color first_color = Color.White;
Color second_color = NormalColor;
- rectangle.X += 1;
- rectangle.Height += 1;
- rectangle.Width += 1;
+// rectangle.Width += 1;
if ( ( state & ButtonState.Checked ) != 0 )
{
dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorControlLightLight, ColorControlLight ), rectangle );
}
+ else
+ dc.FillRectangle( ResPool.GetSolidBrush( Color.White ), rectangle );
if ( ( state & ButtonState.Flat ) != 0 )
{
first_color = Color.White;
second_color = PressedColor;
}
- else
- {
+// else
+// {
// CPDrawBorder3D( graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl );
- }
+// }
}
- using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( rectangle.X, rectangle.Y ), new Point( rectangle.X, rectangle.Bottom - 1 ), first_color, second_color ) )
+ 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 ) )
{
- dc.FillRectangle( lgbr, rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 3 );
+ lgbr.Blend = NormalBlend;
+ dc.FillRectangle( lgbr, rectangle.X + 2, rectangle.Y + 1, rectangle.Width - 4, rectangle.Height - 3 );
}
- Point[] points = new Point[] {
- new Point( rectangle.X + 2, rectangle.Y ),
- new Point( rectangle.Right - 3, rectangle.Y ),
- new Point( rectangle.Right - 1, rectangle.Y + 2 ),
- new Point( rectangle.Right - 1, rectangle.Bottom - 3 ),
- new Point( rectangle.Right - 3, rectangle.Bottom - 1 ),
- new Point( rectangle.X + 2, rectangle.Bottom - 1 ),
- new Point( rectangle.X, rectangle.Bottom - 3 ),
- new Point( rectangle.X, rectangle.Y + 2 ),
- new Point( rectangle.X + 2, rectangle.Y )
- };
-
- dc.DrawPolygon( ResPool.GetPen( BorderColor ), points );
+ Internal_DrawButton(dc, new Rectangle(rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2), BorderColor);
rect = new Rectangle( rectangle.X + rectangle.Width / 4, rectangle.Y + rectangle.Height / 4, rectangle.Width / 2, rectangle.Height / 2 );
centerX = rect.Left + rect.Width / 2;
arrow[ 1 ] = P2;
arrow[ 2 ] = P3;
+ SmoothingMode old_smoothing_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
+
/* Draw the arrow */
if ( ( state & ButtonState.Inactive ) != 0 )
{
dc.DrawLines( pen, arrow );
}
}
+
+ dc.SmoothingMode = old_smoothing_mode;
}
/* Scroll button: regular button + direction arrow */
DrawScrollButtonPrimitive( dc, area, state, scroll_button_type );
- if ( area.Width < 12 || area.Height < 12 ) /* Cannot see a thing at smaller sizes */
- return;
-
Pen pen = null;
if ( enabled )
- pen = new Pen( arrow_color, 2 );
+ pen = ResPool.GetSizedPen( arrow_color, 2 );
else
- pen = new Pen( ColorGrayText, 2 );
+ pen = ResPool.GetSizedPen( ColorGrayText, 2 );
/* Paint arrows */
if ( ( state & ButtonState.Pushed ) != 0 )
shift = 1;
- Point[] arrow = new Point[ 3 ];
+ int min_3 = 3;
+ int min_2 = 2;
+ if ( area.Width < 12 || area.Height < 12 ) {
+ min_3 = 2;
+ min_2 = 1;
+ }
- switch ( scroll_button_type )
- {
- case ScrollButton.Down:
- centerY += shift;
- arrow[ 0 ] = new Point( centerX - 3, centerY - 2 );
- arrow[ 1 ] = new Point( centerX, centerY + 2 );
- arrow[ 2 ] = new Point( centerX + 3, centerY - 2 );
- break;
- case ScrollButton.Up:
- centerY -= shift;
- arrow[ 0 ] = new Point( centerX - 3, centerY + 2 );
- arrow[ 1 ] = new Point( centerX, centerY - 2 );
- arrow[ 2 ] = new Point( centerX + 3, centerY + 2 );
- break;
- case ScrollButton.Left:
- centerX -= shift;
- arrow[ 0 ] = new Point( centerX + 2, centerY - 3 );
- arrow[ 1 ] = new Point( centerX - 2, centerY );
- arrow[ 2 ] = new Point( centerX + 2, centerY + 3 );
- break;
- case ScrollButton.Right:
- centerX += shift;
- arrow[ 0 ] = new Point( centerX - 2, centerY - 3 );
- arrow[ 1 ] = new Point( centerX + 2, centerY );
- arrow[ 2 ] = new Point( centerX - 2, centerY + 3 );
- break;
- default:
- break;
+ Point[] arrow = new Point [3];
+
+ switch (scroll_button_type) {
+ case ScrollButton.Down:
+ centerY += shift;
+ arrow [0] = new Point (centerX - min_3, centerY - min_2);
+ arrow [1] = new Point (centerX, centerY + min_2);
+ arrow [2] = new Point (centerX + min_3, centerY - min_2);
+ break;
+ case ScrollButton.Up:
+ centerY -= shift;
+ arrow [0] = new Point (centerX - min_3, centerY + min_2);
+ arrow [1] = new Point (centerX, centerY - min_2);
+ arrow [2] = new Point (centerX + min_3, centerY + min_2);
+ break;
+ case ScrollButton.Left:
+ centerX -= shift;
+ arrow [0] = new Point (centerX + min_2, centerY - min_3);
+ arrow [1] = new Point (centerX - min_2, centerY);
+ arrow [2] = new Point (centerX + min_2, centerY + min_3);
+ break;
+ case ScrollButton.Right:
+ centerX += shift;
+ arrow [0] = new Point (centerX - min_2, centerY - min_3);
+ arrow [1] = new Point (centerX + min_2, centerY);
+ arrow [2] = new Point (centerX - min_2, centerY + min_3);
+ break;
+ default:
+ break;
}
+
+ SmoothingMode old_smoothing_mode = dc.SmoothingMode;
+ dc.SmoothingMode = SmoothingMode.AntiAlias;
- dc.DrawLines( pen, arrow );
+ dc.DrawLines (pen, arrow);
- pen.Dispose( );
+ dc.SmoothingMode = old_smoothing_mode;
}
public override void CPDrawSizeGrip( Graphics dc, Color backColor, Rectangle bounds )
{
Point pt = new Point( bounds.Right - 4, bounds.Bottom - 4 );
- using ( Bitmap bmp = new Bitmap( 4, 4 ) )
- {
- using ( Graphics gr = Graphics.FromImage( bmp ) )
- {
- using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 0 ), new Point( 4, 4 ), PressedColor, Color.White ) )
- gr.FillEllipse( lgbr, new Rectangle( 0, 0, 4, 4 ) );
- }
-
- dc.DrawImage( bmp, pt );
- dc.DrawImage( bmp, pt.X, pt.Y - 5 );
- dc.DrawImage( bmp, pt.X, pt.Y - 10 );
- dc.DrawImage( bmp, pt.X - 5, pt.Y );
- dc.DrawImage( bmp, pt.X - 10, pt.Y );
- dc.DrawImage( bmp, pt.X - 5, pt.Y - 5 );
- }
+ dc.DrawImage( size_grip_bmp, pt );
+ dc.DrawImage( size_grip_bmp, pt.X, pt.Y - 5 );
+ dc.DrawImage( size_grip_bmp, pt.X, pt.Y - 10 );
+ dc.DrawImage( size_grip_bmp, pt.X - 5, pt.Y );
+ dc.DrawImage( size_grip_bmp, pt.X - 10, pt.Y );
+ dc.DrawImage( size_grip_bmp, pt.X - 5, pt.Y - 5 );
}
private void DrawScrollBarThumb( Graphics dc, Rectangle area, ScrollBar bar )
LinearGradientBrush lgbr = null;
if ( bar.vert )
- lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 1, area.Y ), Color.White, NormalColor );
+ lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right, area.Y ), Color.White, NormalColor );
else
- lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), Color.White, NormalColor );
+ lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom ), Color.White, NormalColor );
- Pen pen = ResPool.GetPen( BorderColor );
-
- Point[] points = new Point[] {
- new Point( area.X + 2, area.Y ),
- new Point( area.Right - 3, area.Y ),
- new Point( area.Right - 1, area.Y + 2 ),
- new Point( area.Right - 1, area.Bottom - 3 ),
- new Point( area.Right - 3, area.Bottom - 1 ),
- new Point( area.X + 2, area.Bottom - 1 ),
- new Point( area.X, area.Bottom - 3 ),
- new Point( area.X, area.Y + 2 ),
- new Point( area.X + 2, area.Y )
- };
+ lgbr.Blend = NormalBlend;
if ( bar.vert )
{
- dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 3 );
- dc.DrawPolygon( pen, points );
+ dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
+ Internal_DrawButton (dc, area, BorderColor);
// draw grip lines only if stere is enough space
- if ( area.Height > 12 )
+ if ( area.Height > 20 )
{
int mid_y = area.Y + ( area.Height / 2 );
int mid_x = area.X + ( area.Width / 2 );
- using ( Pen lpen = new Pen( MouseOverColor, 2 ) )
- {
- dc.DrawLine( lpen, mid_x - 3, mid_y, mid_x + 3, mid_y );
- dc.DrawLine( lpen, mid_x - 3, mid_y - 4, mid_x + 3, mid_y - 4 );
- dc.DrawLine( lpen, mid_x - 3, mid_y + 4, mid_x + 3, mid_y + 4 );
- }
+ Pen lpen = ResPool.GetSizedPen( MouseOverColor, 2 );
+ dc.DrawLine( lpen, mid_x - 3, mid_y, mid_x + 3, mid_y );
+ dc.DrawLine( lpen, mid_x - 3, mid_y - 4, mid_x + 3, mid_y - 4 );
+ dc.DrawLine( lpen, mid_x - 3, mid_y + 4, mid_x + 3, mid_y + 4 );
Pen spen = ResPool.GetPen( Color.White );
dc.DrawLine( spen, mid_x - 3, mid_y - 1, mid_x + 3, mid_y - 1 );
}
else
{
- dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 3, area.Height - 2 );
- dc.DrawPolygon( pen, points );
+ dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
+ Internal_DrawButton (dc, area, BorderColor);
// draw grip lines only if stere is enough space
- if ( area.Width > 12 )
+ if ( area.Width > 20 )
{
int mid_x = area.X + ( area.Width / 2 );
int mid_y = area.Y + ( area.Height / 2 );
- using ( Pen lpen = new Pen( MouseOverColor, 2 ) )
- {
- dc.DrawLine( lpen, mid_x, mid_y - 3, mid_x, mid_y + 3 );
- dc.DrawLine( lpen, mid_x - 4, mid_y - 3, mid_x - 4, mid_y + 3 );
- dc.DrawLine( lpen, mid_x + 4, mid_y - 3, mid_x + 4, mid_y + 3 );
- }
+ Pen lpen = ResPool.GetSizedPen( MouseOverColor, 2 );
+ dc.DrawLine( lpen, mid_x, mid_y - 3, mid_x, mid_y + 3 );
+ dc.DrawLine( lpen, mid_x - 4, mid_y - 3, mid_x - 4, mid_y + 3 );
+ dc.DrawLine( lpen, mid_x + 4, mid_y - 3, mid_x + 4, mid_y + 3 );
Pen spen = ResPool.GetPen( Color.White );
dc.DrawLine( spen, mid_x - 1, mid_y - 3, mid_x - 1, mid_y + 3 );
{
Pen pen = ResPool.GetPen( BorderColor );
+ dc.FillRectangle( ResPool.GetSolidBrush( NiceBackColor ), area );
+
Color use_color;
if ( ( state & ButtonState.Pushed ) == ButtonState.Pushed )
else
use_color = NormalColor;
- Point[] points = new Point[] {
- new Point( area.X + 2, area.Y ),
- new Point( area.Right - 3, area.Y ),
- new Point( area.Right - 1, area.Y + 2 ),
- new Point( area.Right - 1, area.Bottom - 3 ),
- new Point( area.Right - 3, area.Bottom - 1 ),
- new Point( area.X + 2, area.Bottom - 1 ),
- new Point( area.X, area.Bottom - 3 ),
- new Point( area.X, area.Y + 2 ),
- new Point( area.X + 2, area.Y )
- };
+ Point[] points = null;
LinearGradientBrush lgbr = null;
switch ( scroll_button_type )
{
case ScrollButton.Left:
- lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 2, area.Y ), use_color, Color.White );
- dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 4, area.Height - 2 );
+ lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 1, area.Y ), use_color, Color.White );
+ lgbr.Blend = FlatBlend;
+ dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
+
+ points = new Point[] {
+ new Point( area.X + 2, area.Y ),
+ new Point( area.Right - 1, area.Y ),
+ new Point( area.Right - 1, area.Bottom - 1 ),
+ new Point( area.X + 2, area.Bottom - 1 ),
+ new Point( area.X, area.Bottom - 3 ),
+ new Point( area.X, area.Y + 2 ),
+ new Point( area.X + 2, area.Y )
+ };
dc.DrawPolygon( pen, points );
break;
case ScrollButton.Right:
- lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 2, area.Y ), Color.White, use_color );
- dc.FillRectangle( lgbr, area.X, area.Y + 1, area.Width - 2, area.Height - 2 );
+ lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.Right - 1, area.Y ), Color.White, use_color );
+ lgbr.Blend = NormalBlend;
+ dc.FillRectangle( lgbr, area.X, area.Y + 1, area.Width - 1, area.Height - 2 );
+
+ points = new Point[] {
+ new Point( area.X, area.Y ),
+ new Point( area.Right - 3, area.Y ),
+ new Point( area.Right - 1, area.Y + 2 ),
+ new Point( area.Right - 1, area.Bottom - 3 ),
+ new Point( area.Right - 3, area.Bottom - 1 ),
+ new Point( area.X, area.Bottom - 1 ),
+ new Point( area.X, area.Y ),
+ };
dc.DrawPolygon( pen, points );
break;
case ScrollButton.Up:
lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), use_color, Color.White );
+ lgbr.Blend = FlatBlend;
dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
+
+ points = new Point[] {
+ new Point( area.X + 2, area.Y ),
+ new Point( area.Right - 3, area.Y ),
+ new Point( area.Right - 1, area.Y + 2 ),
+ new Point( area.Right - 1, area.Bottom - 1 ),
+ new Point( area.X, area.Bottom - 1 ),
+ new Point( area.X, area.Y + 2 ),
+ new Point( area.X + 2, area.Y )
+ };
dc.DrawPolygon( pen, points );
break;
case ScrollButton.Down:
lgbr = new LinearGradientBrush( new Point( area.X, area.Y ), new Point( area.X, area.Bottom - 1 ), Color.White, use_color );
- dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 3 );
+ lgbr.Blend = NormalBlend;
+ dc.FillRectangle( lgbr, area.X + 1, area.Y + 1, area.Width - 2, area.Height - 2 );
+
+ points = new Point[] {
+ new Point( area.X, area.Y ),
+ new Point( area.Right - 1, area.Y ),
+ new Point( area.Right - 1, area.Bottom - 3 ),
+ new Point( area.Right - 3, area.Bottom - 1 ),
+ new Point( area.X + 2, area.Bottom - 1 ),
+ new Point( area.X, area.Bottom - 3 ),
+ new Point( area.X, area.Y )
+ };
dc.DrawPolygon( pen, points );
break;
}
lgbr.Dispose( );
}
+
+ #region GroupBox
+ public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box)
+ {
+ StringFormat text_format;
+ SizeF size;
+ int width;
+ int y;
+ Rectangle rect;
+
+ rect = box.ClientRectangle;
+
+ dc.FillRectangle (ResPool.GetSolidBrush (box.BackColor), rect);
+
+ text_format = new StringFormat();
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
+
+ size = dc.MeasureString (box.Text, box.Font);
+ width = (int) size.Width;
+
+ if (width > box.Width - 16)
+ width = box.Width - 16;
+
+ y = box.Font.Height / 2;
+
+ Pen pen = ResPool.GetPen( BorderColor );
+
+ /* Draw group box*/
+ Point[] points = new Point[] {
+ new Point( 8 + width, y ),
+ new Point( box.Width - 3, y ),
+ new Point( box.Width - 1, y + 2 ),
+ new Point( box.Width - 1, box.Height - 3 ),
+ new Point( box.Width - 3, box.Height - 1 ),
+ new Point( 2, box.Height - 1 ),
+ new Point( 0, box.Height - 3 ),
+ new Point( 0, y + 2 ),
+ new Point( 2, y ),
+ new Point( 8, y )
+ };
+ dc.DrawLines( pen, points );
+
+ /* Text */
+ if (box.Enabled) {
+ dc.DrawString (box.Text, box.Font, ResPool.GetSolidBrush (box.ForeColor), 10, 0, text_format);
+ } else {
+ CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor,
+ new RectangleF (10, 0, width, box.Font.Height), text_format);
+ }
+ text_format.Dispose ();
+ }
+ #endregion
} //class
}
-