// 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, alex.olk@googlemail.com
static readonly Color scrollbar_gradient_first_color = Color.FromArgb( 248, 247, 245 );
static readonly Color scrollbar_gradient_second_color = Color.FromArgb( 234, 229, 224 );
- static readonly Color arrow_color = Color.FromArgb( 16, 16, 16 );
+ new static readonly Color arrow_color = Color.FromArgb( 16, 16, 16 );
static readonly Color tab_border_color = Color.FromArgb( 166, 151, 138 );
static readonly Color tab_not_selected_gradient_first_color = Color.FromArgb( 227, 223, 220 );
static readonly Color combobox_border_color = Color.FromArgb( 159, 146, 132 );
static readonly Color combobox_focus_border_color = Color.FromArgb( 70, 91, 110 );
- static readonly Color combobox_focus_inner_border_color = Color.FromArgb( 167, 198, 225 );
+ //static readonly Color combobox_focus_inner_border_color = Color.FromArgb( 167, 198, 225 );
static readonly Color combobox_button_second_gradient_color = Color.FromArgb( 226, 220, 213 );
static readonly Color progressbar_edge_dot_color = Color.FromArgb( 219, 212, 205 );
static readonly Color trackbar_inner_second_gradient_color = Color.FromArgb( 223, 215, 208 );
static readonly Color trackbar_inner_pressed_second_gradient_color = Color.FromArgb( 224, 217, 210 );
- static readonly Color disabled_color_foreground = Color.FromArgb( 182, 180, 173 );
+ //static readonly Color disabled_color_foreground = Color.FromArgb( 182, 180, 173 );
static readonly Color active_caption = Color.FromArgb( 85, 152, 215 );
static readonly Color radio_button_dot_color = Color.FromArgb( 94, 160, 221 );
const int SEPARATOR_HEIGHT = 7;
- const int MENU_TAB_SPACE = 8; // Pixels added to the width of an item because of a tab
- const int MENU_BAR_ITEMS_SPACE = 8; // Space between menu bar items
-
- int platform = (int) Environment.OSVersion.Platform;
+ const int MENU_TAB_SPACE = 8; // Pixels added to the width of an item because of a tab
+ const int MENU_BAR_ITEMS_SPACE = 8; // Space between menu bar items
static Color control_parent_backcolor;
#region Principal Theme Methods
public ThemeClearlooks( ) {
ColorControl = theme_back_color;
- always_draw_hotkeys = true;
}
public override Color DefaultControlBackColor {
}
}
+ public override Color ColorInfo {
+ get { return Color.FromArgb (255, 255, 191); }
+ }
+
+ static readonly Color info_border_color = Color.FromArgb (218, 178, 85);
+#if NET_2_0
+ static readonly Color info_second_color = Color.FromArgb (220, 220, 160);
+#endif
public override Image Images(UIIcon index, int size) {
switch (index) {
case UIIcon.PlacesRecentDocuments:
- if ((platform == 4) || (platform == 128))
+ if (XplatUI.RunningOnUnix)
return MimeIconEngine.GetIconForMimeTypeAndSize( "recently/recently", new Size(size, size) );
else
return base.Images (UIIcon.PlacesRecentDocuments, size);
case UIIcon.PlacesDesktop:
- if ((platform == 4) || (platform == 128))
+ if (XplatUI.RunningOnUnix)
return MimeIconEngine.GetIconForMimeTypeAndSize( "desktop/desktop", new Size(size, size) );
else
return base.Images (UIIcon.PlacesDesktop, size);
case UIIcon.PlacesPersonal:
- if ((platform == 4) || (platform == 128))
+ if (XplatUI.RunningOnUnix)
return MimeIconEngine.GetIconForMimeTypeAndSize( "directory/home", new Size(size, size) );
else
return base.Images (UIIcon.PlacesPersonal, size);
case UIIcon.PlacesMyComputer:
- if ((platform == 4) || (platform == 128))
+ if (XplatUI.RunningOnUnix)
return MimeIconEngine.GetIconForMimeTypeAndSize( "workplace/workplace", new Size(size, size) );
else
return base.Images (UIIcon.PlacesMyComputer, size);
case UIIcon.PlacesMyNetwork:
- if ((platform == 4) || (platform == 128))
+ if (XplatUI.RunningOnUnix)
return MimeIconEngine.GetIconForMimeTypeAndSize( "network/network", new Size(size, size) );
else
return base.Images (UIIcon.PlacesMyNetwork, size);
// misc Icons
case UIIcon.NormalFolder:
- if ((platform == 4) || (platform == 128))
+ if (XplatUI.RunningOnUnix)
return MimeIconEngine.GetIconForMimeTypeAndSize( "inode/directory", new Size(size, size) );
else
return base.Images (UIIcon.NormalFolder, size);
if (form != null && (form.AcceptButton == button as IButtonControl))
paint_acceptbutton_black_border = true;
- CL_Draw_Button(dc, button.ClientRectangle, button.flat_style,
+ CL_Draw_Button(dc, button.ClientRectangle, button.FlatStyle,
button.is_entered, button.is_enabled, button.is_pressed,
first_gradient_color, second_gradient_color,
paint_acceptbutton_black_border);
using (LinearGradientBrush lgbr2 = new LinearGradientBrush (new Point (buttonRectangle.X, buttonRectangle.Y + 3),
new Point (buttonRectangle.X, buttonRectangle.Bottom - 3),
top_color, bottom_color)) {
- dc.FillRectangle (lgbr2, buttonRectangle.X + 1, buttonRectangle.Y + 3, 1, buttonRectangle.Height - 6);
- dc.FillRectangle (lgbr2, buttonRectangle.Right - 2, buttonRectangle.Y + 3, 1, buttonRectangle.Height - 6);
+ using (Pen lgbrpen = new Pen (lgbr2)) {
+ dc.DrawLine (lgbrpen, buttonRectangle.X + 1, buttonRectangle.Y + 3, buttonRectangle.X + 1, buttonRectangle.Bottom - 3);
+ dc.DrawLine (lgbrpen, buttonRectangle.Right - 2, buttonRectangle.Y + 3, buttonRectangle.Right - 2, buttonRectangle.Bottom - 3);
+ }
}
} else {
Point[] points_button_complete = {
using (LinearGradientBrush lgbr2 = new LinearGradientBrush (new Point (buttonRectangle.X, buttonRectangle.Y + 2),
new Point (buttonRectangle.X, buttonRectangle.Bottom - 1),
button_outer_border_dark_color, button_outer_border_light_color)) {
- dc.FillRectangle (lgbr2, buttonRectangle.X, buttonRectangle.Y + 2, 1, buttonRectangle.Height - 4);
- dc.FillRectangle (lgbr2, buttonRectangle.Right - 1, buttonRectangle.Y + 2, 1, buttonRectangle.Height - 4);
+ using (Pen lgbrpen = new Pen(lgbr2)) {
+ dc.DrawLine (lgbrpen, buttonRectangle.X, buttonRectangle.Y + 2, buttonRectangle.X, buttonRectangle.Bottom - 3);
+ dc.DrawLine (lgbrpen, buttonRectangle.Right - 1, buttonRectangle.Y + 2, buttonRectangle.Right - 1, buttonRectangle.Bottom - 3);
+ }
}
// inner border
protected override void ButtonBase_DrawFocus( ButtonBase button, Graphics dc ) {
- if ( !button.is_enabled || button.flat_style == FlatStyle.Popup )
+ if ( !button.is_enabled || button.FlatStyle == FlatStyle.Popup )
return;
Pen pen = ResPool.GetPen( button_focus_color );
dc.FillRectangle( ResPool.GetSolidBrush( tab.Parent.BackColor ), area );
else
dc.FillRectangle( ResPool.GetSolidBrush( tab.BackColor ), area );
- Rectangle panel_rect = GetTabPanelRectExt( tab );
+ 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;
dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top, bounds.Right, bounds.Top + 2);
using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Left, bounds.Bottom - 1), border_pressed_dark_color, border_pressed_light_color)) {
- int diff = is_selected ? 4 : 3;
- dc.FillRectangle (lgbr, bounds.Left, bounds.Top + 2, 1, bounds.Height - diff);
- dc.FillRectangle (lgbr, bounds.Right, bounds.Top + 2, 1, bounds.Height - diff);
+ int diff = is_selected ? 3 : 2;
+ using (Pen lgbrpen = new Pen (lgbr)) {
+ dc.DrawLine (lgbrpen, bounds.Left, bounds.Top + 2, bounds.Left, bounds.Bottom - diff);
+ dc.DrawLine (lgbrpen, bounds.Right, bounds.Top + 2, bounds.Right, bounds.Bottom - diff);
+ }
}
if (page.Focused) {
dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Bottom, bounds.Right, bounds.Bottom - 2);
using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Left, bounds.Bottom - 1), border_pressed_light_color, border_pressed_dark_color)) {
- int diff = is_selected ? 4 : 3;
- dc.FillRectangle (lgbr, bounds.Left, bounds.Top + 2, 1, bounds.Height - diff);
- dc.FillRectangle (lgbr, bounds.Right, bounds.Top + 2, 1, bounds.Height - diff);
+ int diff = is_selected ? 3 : 2;
+ using (Pen lgbrpen = new Pen (lgbr)) {
+ dc.DrawLine (lgbrpen, bounds.Left, bounds.Top + 2, bounds.Left, bounds.Bottom - 1 - diff);
+ dc.DrawLine (lgbrpen, bounds.Right, bounds.Top + 2, bounds.Left, bounds.Bottom - 1 - diff);
+ }
}
if (page.Focused) {
dc.DrawLine (tmp_pen, bounds.Left, bounds.Bottom - 2, bounds.Left + 2, bounds.Bottom);
using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Right - 2, bounds.Top + 2), border_pressed_dark_color, border_pressed_light_color)) {
- int diff = is_selected ? 4 : 2;
+ int diff = is_selected ? 3 : 1;
- dc.FillRectangle (lgbr, bounds.Left + 2, bounds.Top, bounds.Width - diff, 1);
- dc.FillRectangle (lgbr, bounds.Left + 2, bounds.Bottom, bounds.Width - diff, 1);
+ using (Pen lgbrpen = new Pen (lgbr)) {
+ dc.DrawLine (lgbrpen, bounds.Left + 2, bounds.Top, bounds.Right - diff, bounds.Left + 2);
+ dc.DrawLine (lgbrpen, bounds.Left + 2, bounds.Bottom, bounds.Right - diff, bounds.Left + 2);
+ }
}
if (page.Focused) {
dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom - 2, bounds.Right - 3, bounds.Bottom);
using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Right - 2, bounds.Top + 2), border_pressed_light_color, border_pressed_dark_color)) {
- int diff = is_selected ? 4 : 2;
+ int diff = is_selected ? 3 : 1;
- dc.FillRectangle (lgbr, bounds.Left + l_diff, bounds.Top, bounds.Width - diff, 1);
- dc.FillRectangle (lgbr, bounds.Left + l_diff, bounds.Bottom, bounds.Width - diff, 1);
+ using (Pen lgbrpen = new Pen (lgbr)) {
+ dc.DrawLine (lgbrpen, bounds.Left + l_diff, bounds.Top, bounds.Right - diff, bounds.Top);
+ dc.DrawLine (lgbrpen, bounds.Left + l_diff, bounds.Bottom, bounds.Right - diff, bounds.Bottom);
+ }
}
if (page.Focused) {
P1 = new Point( rect.Left, centerY );
P2 = new Point( centerX, rect.Bottom );
- P3 = new Point( rect.Right, centerY );
+ P3 = new Point( rect.Right - 1, centerY );
arrow[ 0 ] = P1;
arrow[ 1 ] = P2;
P1 = new Point( rect.Left, centerY );
P2 = new Point( centerX, rect.Bottom );
- P3 = new Point( rect.Right, centerY );
+ P3 = new Point( rect.Right - 1, centerY );
arrow[ 0 ] = P1;
arrow[ 1 ] = P2;
}
#region ToolBar
- public override bool ToolBarInvalidateEntireButton {
- get { return true; }
- }
+
#endregion // ToolBar
#region GroupBox
CPDrawBorder3D( graphics, rectangle, style, sides, ColorControl );
}
- protected override void CPDrawBorder3D( Graphics dc, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color ) {
+ public override void CPDrawBorder3D( Graphics dc, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color ) {
// currently we don't take care of Border3DStyle or Border3DSide
- // FIXME: temporary fix for artefacts, it should use the backcolor of the parent control
- dc.DrawLine( ResPool.GetPen( ColorControl ), rectangle.X, rectangle.Y, rectangle.X, rectangle.Bottom - 1 );
- dc.DrawLine( ResPool.GetPen( ColorControl ), rectangle.Right - 1, rectangle.Y, rectangle.Right - 1, rectangle.Bottom - 1 );
-
Pen tmp_pen = ResPool.GetPen( edge_bottom_inner_color );
dc.DrawLine( tmp_pen, rectangle.X + 1, rectangle.Y + 2, rectangle.X + 2, rectangle.Y + 1 );
dc.DrawLine( tmp_pen, rectangle.Right - 3, rectangle.Y + 1, rectangle.Right - 2, rectangle.Y + 2 );
tmp_pen = ResPool.GetPen( button_outer_border_light_color );
dc.DrawLines( tmp_pen, points_bottom_outer );
- using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( 0, 2 ), new Point( 0, rectangle.Height - 1 ), button_outer_border_dark_color, button_outer_border_light_color ) ) {
- dc.FillRectangle( lgbr, rectangle.X, rectangle.Y + 2, 1, rectangle.Height - 4 );
- dc.FillRectangle( lgbr, rectangle.Right - 1, rectangle.Y + 2, 1, rectangle.Height - 4 );
+ using ( LinearGradientBrush lgbr = new LinearGradientBrush( new Point( rectangle.X, rectangle.Y + 2 ), new Point( rectangle.X, rectangle.Bottom - 3 ), button_outer_border_dark_color, button_outer_border_light_color ) ) {
+ using (Pen lgbrpen = new Pen (lgbr)) {
+ dc.DrawLine (lgbrpen, rectangle.X, rectangle.Y + 2, rectangle.X, rectangle.Bottom - 3 );
+ dc.DrawLine (lgbrpen, rectangle.Right - 1, rectangle.Y + 2, rectangle.Right - 1, rectangle.Bottom - 3 );
+ }
}
tmp_pen = ResPool.GetPen( button_edge_top_outer_color );
dc.FillPie (buttonBrush, rectangle.X + lineWidth + lineWidth / 2, rectangle.Y + lineWidth + lineWidth / 2, (rectangle.Width - lineWidth * 2) / 3, (rectangle.Height - lineWidth * 2) / 3, 0, 359);
}
}
+
+ #region ToolTip
+ public override void DrawToolTip (Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control)
+ {
+ dc.FillRectangle(ResPool.GetSolidBrush (ColorInfo), control.ClientRectangle);
+ dc.DrawRectangle(ResPool.GetPen (info_border_color), 0, 0, control.Width-1, control.Height-1);
+
+ TextFormatFlags flags = TextFormatFlags.HidePrefix | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter;
+ TextRenderer.DrawTextInternal (dc, control.Text, control.Font, control.ClientRectangle, this.ColorInfoText, flags, false);
+ }
+ #endregion // ToolTip
+
+ #region BalloonWindow
+#if NET_2_0
+ NotifyIcon.BalloonWindow balloon_window;
+
+ public override void ShowBalloonWindow (IntPtr handle, int timeout, string title, string text, ToolTipIcon icon)
+ {
+ Control control = Control.FromHandle(handle);
+
+ if (control == null)
+ return;
+
+ if (balloon_window != null) {
+ balloon_window.Close ();
+ balloon_window.Dispose ();
+ }
+
+ balloon_window = new NotifyIcon.BalloonWindow (handle);
+ balloon_window.Title = title;
+ balloon_window.Text = text;
+ balloon_window.Icon = icon;
+ balloon_window.Timeout = timeout;
+ balloon_window.Show ();
+ }
+
+ private const int balloon_iconsize = 48;
+ private const int balloon_bordersize = 8;
+
+ public override void DrawBalloonWindow (Graphics dc, Rectangle clip, NotifyIcon.BalloonWindow control)
+ {
+ Brush solidbrush = ResPool.GetSolidBrush(this.ColorInfoText);
+ Rectangle rect = control.ClientRectangle;
+ int iconsize = (control.Icon == ToolTipIcon.None) ? 0 : balloon_iconsize;
+
+ // Rectangle borders and background.
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorInfo), rect);
+ dc.FillRectangle (ResPool.GetSolidBrush (info_second_color), new Rectangle (rect.X, rect.Y, (balloon_iconsize/2)+balloon_bordersize, rect.Height));
+ dc.DrawRectangle (ResPool.GetPen (info_border_color), 0, 0, rect.Width - 1, rect.Height - 1);
+
+ // Icon
+ Image image;
+ switch (control.Icon) {
+ case ToolTipIcon.Info: {
+ image = ThemeEngine.Current.Images(UIIcon.MessageBoxInfo, balloon_iconsize);
+ break;
+ }
+
+ case ToolTipIcon.Warning: {
+ image = ThemeEngine.Current.Images(UIIcon.MessageBoxError, balloon_iconsize);
+ break;
+ }
+
+ case ToolTipIcon.Error: {
+ image = ThemeEngine.Current.Images(UIIcon.MessageBoxWarning, balloon_iconsize);
+ break;
+ }
+
+ default: {
+ image = null;
+ break;
+ }
+ }
+
+ if (control.Icon != ToolTipIcon.None)
+ dc.DrawImage (image, new Rectangle (balloon_bordersize, (2*balloon_bordersize)+7, iconsize, iconsize));
+
+ // Title
+ Rectangle titlerect = new Rectangle (rect.X + balloon_bordersize + (balloon_iconsize/2) + balloon_bordersize,
+ rect.Y + balloon_bordersize,
+ rect.Width - ((3 * balloon_bordersize) + (balloon_iconsize/2)),
+ rect.Height - (2 * balloon_bordersize));
+
+ Font titlefont = new Font (control.Font.FontFamily, control.Font.Size, control.Font.Style | FontStyle.Bold, control.Font.Unit);
+ dc.DrawString (control.Title, titlefont, solidbrush, titlerect, control.Format);
+
+ // Text
+ Rectangle textrect = new Rectangle (rect.X + (2 * balloon_bordersize) + balloon_iconsize,
+ rect.Y + balloon_bordersize,
+ rect.Width - ((2 * balloon_bordersize) + balloon_iconsize),
+ rect.Height - (2 * balloon_bordersize));
+
+ StringFormat textformat = control.Format;
+ textformat.LineAlignment = StringAlignment.Far;
+ dc.DrawString (control.Text, control.Font, solidbrush, textrect, textformat);
+ }
+
+ public override Rectangle BalloonWindowRect (NotifyIcon.BalloonWindow control)
+ {
+ Rectangle deskrect = Screen.GetWorkingArea (control);
+ SizeF maxsize = new SizeF (250, 200);
+
+ SizeF titlesize = TextRenderer.MeasureString (control.Title, control.Font, maxsize, control.Format);
+ SizeF textsize = TextRenderer.MeasureString (control.Text, control.Font, maxsize, control.Format);
+
+ if (textsize.Height < balloon_iconsize)
+ textsize.Height = balloon_iconsize;
+
+ Rectangle rect = new Rectangle ();
+ rect.Height = (int) (titlesize.Height + textsize.Height + (3 * balloon_bordersize));
+ rect.Width = (int) ((titlesize.Width > textsize.Width) ? titlesize.Width : textsize.Width) + (3 * balloon_bordersize) + balloon_iconsize;
+ rect.X = deskrect.Width - rect.Width - 2;
+ rect.Y = deskrect.Height - rect.Height - 2;
+
+ return rect;
+ }
+#endif
+ #endregion // BalloonWindow
+
} //class
}