public virtual void DrawButtonText (Graphics g, Button button, Rectangle textBounds)
{
- if (button.Pressed)
- textBounds.Offset (1, 1);
-
if (button.Enabled)
TextRenderer.DrawTextInternal (g, button.Text, button.Font, textBounds, button.ForeColor, button.TextFormatFlags, button.UseCompatibleTextRendering);
else
checkbox_rectangle = new Rectangle(text_rectangle.X, text_rectangle.Y, checkmark_size, checkmark_size);
text_format = new StringFormat();
- text_format.Alignment=StringAlignment.Near;
- text_format.LineAlignment=StringAlignment.Center;
- text_format.HotkeyPrefix = HotkeyPrefix.Show;
+ text_format.Alignment = StringAlignment.Near;
+ text_format.LineAlignment = StringAlignment.Center;
+ if (checkbox.ShowKeyboardCuesInternal)
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
+ else
+ text_format.HotkeyPrefix = HotkeyPrefix.Hide;
/* Calculate the position of text and checkbox rectangle */
if (checkbox.appearance!=Appearance.Button) {
protected virtual void DrawListViewItem (Graphics dc, ListView control, ListViewItem item)
{
- int col_offset;
- if (control.View == View.Details && control.Columns.Count > 0)
- col_offset = control.Columns [0].Rect.X;
- else
- col_offset = 0;
-
Rectangle rect_checkrect = item.CheckRectReal;
- rect_checkrect.X += col_offset;
Rectangle icon_rect = item.GetBounds (ItemBoundsPortion.Icon);
- icon_rect.X += col_offset;
Rectangle full_rect = item.GetBounds (ItemBoundsPortion.Entire);
- full_rect.X += col_offset;
Rectangle text_rect = item.GetBounds (ItemBoundsPortion.Label);
- text_rect.X += col_offset;
#if NET_2_0
// Tile view doesn't support CheckBoxes
// adjustments to get the check-mark at the right place
rect.X ++; rect.Y ++;
// following logic is taken from DrawFrameControl method
+ int x_offset = rect.Width / 5;
+ int y_offset = rect.Height / 3;
for (int i = 0; i < check_wd; i++) {
- dc.DrawLine (check_pen, rect.Left + check_wd / 2,
- rect.Top + check_wd + i,
- rect.Left + check_wd / 2 + 2 * scale,
- rect.Top + check_wd + 2 * scale + i);
+ dc.DrawLine (check_pen, rect.Left + x_offset,
+ rect.Top + y_offset + i,
+ rect.Left + x_offset + 2 * scale,
+ rect.Top + y_offset + 2 * scale + i);
dc.DrawLine (check_pen,
- rect.Left + check_wd / 2 + 2 * scale,
- rect.Top + check_wd + 2 * scale + i,
- rect.Left + check_wd / 2 + 6 * scale,
- rect.Top + check_wd - 2 * scale + i);
+ rect.Left + x_offset + 2 * scale,
+ rect.Top + y_offset + 2 * scale + i,
+ rect.Left + x_offset + 6 * scale,
+ rect.Top + y_offset - 2 * scale + i);
}
}
}
else {
- if (item.Checked && control.StateImageList.Images.Count > 1)
- control.StateImageList.Draw (dc, rect_checkrect.Location, 1);
- else if (control.StateImageList.Images.Count > 0)
- control.StateImageList.Draw (dc, rect_checkrect.Location, 0);
+ int simage_idx;
+ if (item.Checked)
+#if NET_2_0
+ simage_idx = control.StateImageList.Images.Count > 1 ? 1 : -1;
+#else
+ simage_idx = control.StateImageList.Images.Count > 1 ? 1 : 0;
+#endif
+ else
+ simage_idx = control.StateImageList.Images.Count > 0 ? 0 : -1;
+
+ if (simage_idx > -1)
+ control.StateImageList.Draw (dc, rect_checkrect.Location, simage_idx);
}
}
// draw the item text
// format for the item text
StringFormat format = new StringFormat ();
- if (control.View == View.SmallIcon)
+ if (control.View == View.SmallIcon || control.View == View.LargeIcon)
format.LineAlignment = StringAlignment.Near;
else
format.LineAlignment = StringAlignment.Center;
else
format.FormatFlags = StringFormatFlags.NoWrap;
+ if ((control.View == View.LargeIcon && !item.Focused)
+ || control.View == View.Details
+#if NET_2_0
+ || control.View == View.Tile
+#endif
+ )
+ format.Trimming = StringTrimming.EllipsisCharacter;
+
Rectangle highlight_rect = text_rect;
if (control.View == View.Details) { // Adjustments for Details view
Size text_size = Size.Ceiling (dc.MeasureString (item.Text, item.Font));
if (!control.FullRowSelect) // Selection shouldn't be outside the item bounds
highlight_rect.Width = Math.Min (text_size.Width + 4, text_rect.Width);
-
- if (text_size.Width > text_rect.Width)
- format.Trimming = StringTrimming.EllipsisCharacter;
}
if (item.Selected && control.Focused)
#region Menus
- public override bool MenuAccessKeysUnderlined {
- get { return false; }
- }
-
public override void CalcItemSize (Graphics dc, MenuItem item, int y, int x, bool menuBar)
{
item.X = x;
dc.FillRectangle(GetControlBackBrush (pb.BackColor), clip);
dc.DrawImage (pb.Image, (client.Width / 2) - (pb.Image.Width / 2), (client.Height / 2) - (pb.Image.Height / 2));
break;
+#if NET_2_0
+ case PictureBoxSizeMode.Zoom:
+ dc.FillRectangle (GetControlBackBrush (pb.BackColor), clip);
+
+ Size image_size;
+
+ if (((float)pb.Image.Width / (float)pb.Image.Height) >= ((float)client.Width / (float)client.Height))
+ image_size = new Size (client.Width, (pb.Image.Height * client.Width) / pb.Image.Width);
+ else
+ image_size = new Size ((pb.Image.Width * client.Height) / pb.Image.Height, client.Height);
+
+ dc.DrawImage (pb.Image, (client.Width / 2) - (image_size.Width / 2), (client.Height / 2) - (image_size.Height / 2), image_size.Width, image_size.Height);
+ break;
+#endif
default:
dc.FillRectangle(GetControlBackBrush (pb.BackColor), clip);
// Normal, AutoSize
#endregion // ScrollBar
#region StatusBar
- public override void DrawStatusBar (Graphics dc, Rectangle clip, StatusBar sb) {
+ public override void DrawStatusBar (Graphics real_dc, Rectangle clip, StatusBar sb) {
Rectangle area = sb.ClientRectangle;
int horz_border = 2;
int vert_border = 2;
+
+ Image backbuffer = new Bitmap (sb.ClientSize.Width, sb.ClientSize.Height, real_dc);
+ Graphics dc = Graphics.FromImage (backbuffer);
bool is_color_control = sb.BackColor.ToArgb () == ColorControl.ToArgb ();
area = new Rectangle (area.Right - 16 - 2, area.Bottom - 12 - 1, 16, 16);
CPDrawSizeGrip (dc, ColorControl, area);
}
+
+ real_dc.DrawImage (backbuffer, 0, 0);
+ dc.Dispose ();
+ backbuffer.Dispose ();
}
}
#endregion // StatusBar
- public override void DrawTabControl (Graphics dc, Rectangle area, TabControl tab)
- {
- Brush brush = SystemBrushes.Control;
- dc.FillRectangle (brush, area);
- Rectangle panel_rect = GetTabPanelRectExt (tab);
+ #region TabControl
- if (tab.Appearance == TabAppearance.Normal) {
- CPDrawBorder3D (dc, panel_rect, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top, ColorControl);
- CPDrawBorder3D (dc, panel_rect, Border3DStyle.Raised, Border3DSide.Right | Border3DSide.Bottom, ColorControl);
- }
-
- if (tab.Alignment == TabAlignment.Top) {
- for (int r = tab.TabPages.Count; r > 0; r--) {
- for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
- if (i == tab.SelectedIndex)
- continue;
- if (r != tab.TabPages [i].Row)
- continue;
- Rectangle rect = tab.GetTabRect (i);
- if (!rect.IntersectsWith (area))
- continue;
- DrawTab (dc, tab.TabPages [i], tab, rect, false);
- }
- }
- } else {
- for (int r = 0; r < tab.TabPages.Count; r++) {
- for (int i = tab.SliderPos; i < tab.TabPages.Count; i++) {
- if (i == tab.SelectedIndex)
- continue;
- if (r != tab.TabPages [i].Row)
- continue;
- Rectangle rect = tab.GetTabRect (i);
- if (!rect.IntersectsWith (area))
- continue;
- DrawTab (dc, tab.TabPages [i], tab, rect, false);
- }
- }
- }
+ #region TabControl settings
- if (tab.SelectedIndex != -1 && tab.SelectedIndex >= tab.SliderPos) {
- Rectangle rect = tab.GetTabRect (tab.SelectedIndex);
- if (rect.IntersectsWith (area))
- DrawTab (dc, tab.TabPages [tab.SelectedIndex], tab, rect, true);
- }
+ public override Size TabControlDefaultItemSize {
+ get { return ThemeElements.CurrentTheme.TabControlPainter.DefaultItemSize; }
+ }
- if (tab.ShowSlider) {
- Rectangle right = GetTabControlRightScrollRect (tab);
- Rectangle left = GetTabControlLeftScrollRect (tab);
- CPDrawScrollButton (dc, right, ScrollButton.Right, tab.RightSliderState);
- CPDrawScrollButton (dc, left, ScrollButton.Left, tab.LeftSliderState);
- }
+ public override Point TabControlDefaultPadding {
+ get { return ThemeElements.CurrentTheme.TabControlPainter.DefaultPadding; }
}
- public override Rectangle GetTabControlLeftScrollRect (TabControl tab)
- {
- switch (tab.Alignment) {
- case TabAlignment.Top:
- return new Rectangle (tab.ClientRectangle.Right - 34, tab.ClientRectangle.Top + 1, 17, 17);
- default:
- Rectangle panel_rect = GetTabPanelRectExt (tab);
- return new Rectangle (tab.ClientRectangle.Right - 34, panel_rect.Bottom + 2, 17, 17);
- }
+ public override int TabControlMinimumTabWidth {
+ get { return ThemeElements.CurrentTheme.TabControlPainter.MinimumTabWidth; }
}
- public override Rectangle GetTabControlRightScrollRect (TabControl tab)
- {
- switch (tab.Alignment) {
- case TabAlignment.Top:
- return new Rectangle (tab.ClientRectangle.Right - 17, tab.ClientRectangle.Top + 1, 17, 17);
- default:
- Rectangle panel_rect = GetTabPanelRectExt (tab);
- return new Rectangle (tab.ClientRectangle.Right - 17, panel_rect.Bottom + 2, 17, 17);
- }
+ public override Rectangle TabControlSelectedDelta {
+ get { return ThemeElements.CurrentTheme.TabControlPainter.SelectedTabDelta; }
}
- public override Size TabControlDefaultItemSize {
- get { return new Size (42, 21); }
+ public override int TabControlSelectedSpacing {
+ get { return ThemeElements.CurrentTheme.TabControlPainter.SelectedSpacing; }
+ }
+
+ public override int TabPanelOffsetX {
+ get { return ThemeElements.CurrentTheme.TabControlPainter.TabPanelOffset.X; }
+ }
+
+ public override int TabPanelOffsetY {
+ get { return ThemeElements.CurrentTheme.TabControlPainter.TabPanelOffset.Y; }
}
- public override Point TabControlDefaultPadding {
- get { return new Point (6, 3); }
+ public override int TabControlColSpacing {
+ get { return ThemeElements.CurrentTheme.TabControlPainter.ColSpacing; }
}
- public override int TabControlMinimumTabWidth {
- get { return 42; }
+ public override Point TabControlImagePadding {
+ get { return ThemeElements.CurrentTheme.TabControlPainter.ImagePadding; }
}
- public override Rectangle GetTabControlDisplayRectangle (TabControl tab)
- {
- Rectangle ext = GetTabPanelRectExt (tab);
- // Account for border size
- return new Rectangle (ext.Left + 2, ext.Top + 1, ext.Width - 6, ext.Height - 4);
- }
-
- public override Size TabControlGetSpacing (TabControl tab) {
- switch (tab.Appearance) {
- case TabAppearance.Normal:
- return new Size (1, -2);
- case TabAppearance.Buttons:
- return new Size (3, 3);
- case TabAppearance.FlatButtons:
- return new Size (9, 3);
- default:
- throw new Exception ("Invalid Appearance value: " + tab.Appearance);
- }
+ public override int TabControlScrollerWidth {
+ get {return ThemeElements.CurrentTheme.TabControlPainter.ScrollerWidth; }
}
- protected virtual Rectangle GetTabPanelRectExt (TabControl tab)
+
+ public override Size TabControlGetSpacing (TabControl tab)
{
- // Offset the tab from the top corner
- Rectangle res = new Rectangle (tab.ClientRectangle.X + 2,
- tab.ClientRectangle.Y,
- tab.ClientRectangle.Width - 2,
- tab.ClientRectangle.Height - 1);
-
- if (tab.TabCount == 0)
- return res;
-
- int spacing = TabControlGetSpacing (tab).Height;
- int offset = (tab.ItemSize.Height + spacing) * tab.RowCount + 3;
-
- switch (tab.Alignment) {
- case TabAlignment.Left:
- res.X += offset;
- res.Width -= offset;
- break;
- case TabAlignment.Right:
- res.Width -= offset;
- break;
- case TabAlignment.Top:
- res.Y += offset;
- res.Height -= offset;
- break;
- case TabAlignment.Bottom:
- res.Height -= offset;
- break;
+ try {
+ return ThemeElements.CurrentTheme.TabControlPainter.RowSpacing (tab);
+ } catch {
+ throw new Exception ("Invalid Appearance value: " + tab.Appearance);
}
-
- return res;
}
+ #endregion
- protected virtual int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
+ public override void DrawTabControl (Graphics dc, Rectangle area, TabControl tab)
{
- int FlatButtonSpacing = 8;
- Rectangle interior;
- int res = bounds.Width;
-
-
-
- // we can't fill the background right away because the bounds might be adjusted if the tab is selected
-
- StringFormat string_format = new StringFormat ();
- if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) {
- dc.FillRectangle (ResPool.GetSolidBrush (tab.BackColor), bounds);
-
- // Separators
- if (tab.Appearance == TabAppearance.FlatButtons) {
- int width = bounds.Width;
- bounds.Width += (FlatButtonSpacing - 2);
- res = bounds.Width;
- CPDrawBorder3D (dc, bounds, Border3DStyle.Etched, Border3DSide.Right);
- bounds.Width = width;
- }
-
- if (is_selected) {
- 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.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
- }
-
- interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4);
-
-
- string_format.Alignment = StringAlignment.Center;
- string_format.LineAlignment = StringAlignment.Center;
- string_format.FormatFlags = StringFormatFlags.NoWrap;
- } else {
- CPColor cpcolor = ResPool.GetCPColor (tab.BackColor);
-
- Pen light = ResPool.GetPen (cpcolor.LightLight);
-
- switch (tab.Alignment) {
-
- case TabAlignment.Top:
-
- dc.FillRectangle (ResPool.GetSolidBrush (tab.BackColor), bounds);
-
- dc.DrawLine (light, bounds.Left, bounds.Bottom, bounds.Left, bounds.Top + 3);
- dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
- dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right - 3, bounds.Top);
-
- dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom);
- dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 1, bounds.Top + 2, bounds.Right, bounds.Top + 3);
- dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom);
-
- interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
-
- string_format.Alignment = StringAlignment.Center;
- string_format.LineAlignment = StringAlignment.Center;
- string_format.FormatFlags = StringFormatFlags.NoWrap;
-
- break;
-
- case TabAlignment.Bottom:
-
- dc.FillRectangle (ResPool.GetSolidBrush (tab.BackColor), bounds);
-
- dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 3);
- dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left + 2, bounds.Bottom - 1);
-
- dc.DrawLine (SystemPens.ControlDark, bounds.Left + 3, bounds.Bottom - 1, bounds.Right - 3, bounds.Bottom - 1);
- dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Bottom - 3, bounds.Right - 1, bounds.Top);
-
- dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
- dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right - 3, bounds.Bottom, bounds.Right, bounds.Bottom - 3);
- dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom - 3, bounds.Right, bounds.Top);
-
- interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
-
- string_format.Alignment = StringAlignment.Center;
- string_format.LineAlignment = StringAlignment.Center;
- string_format.FormatFlags = StringFormatFlags.NoWrap;
-
- break;
-
- case TabAlignment.Left:
-
- dc.FillRectangle (ResPool.GetSolidBrush (tab.BackColor), bounds);
-
- dc.DrawLine (light, bounds.Left, bounds.Bottom - 3, bounds.Left, bounds.Top + 3);
- dc.DrawLine (light, bounds.Left, bounds.Top + 3, bounds.Left + 3, bounds.Top);
- dc.DrawLine (light, bounds.Left + 3, bounds.Top, bounds.Right, bounds.Top);
-
- dc.DrawLine (SystemPens.ControlDark, bounds.Right, bounds.Bottom - 1, bounds.Left + 2, bounds.Bottom - 1);
-
- dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Bottom, bounds.Left + 2, bounds.Bottom);
- dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left + 2, bounds.Bottom, bounds.Left, bounds.Bottom - 3);
-
- interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
-
- string_format.Alignment = StringAlignment.Center;
- string_format.LineAlignment = StringAlignment.Center;
- string_format.FormatFlags = StringFormatFlags.NoWrap;
- string_format.FormatFlags = StringFormatFlags.DirectionVertical;
-
- break;
-
- default:
- // TabAlignment.Right
-
- dc.FillRectangle (ResPool.GetSolidBrush (tab.BackColor), bounds);
-
- dc.DrawLine (light, bounds.Left, bounds.Top, bounds.Right - 3, bounds.Top);
- dc.DrawLine (light, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3);
-
- dc.DrawLine (SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom - 1);
- dc.DrawLine (SystemPens.ControlDark, bounds.Left, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1);
-
- dc.DrawLine (SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom - 3);
- dc.DrawLine (SystemPens.ControlDarkDark, bounds.Left, bounds.Bottom, bounds.Right - 3, bounds.Bottom);
-
- interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
-
- string_format.Alignment = StringAlignment.Center;
- string_format.LineAlignment = StringAlignment.Center;
- string_format.FormatFlags = StringFormatFlags.NoWrap;
- string_format.FormatFlags = StringFormatFlags.DirectionVertical;
-
- break;
- }
- }
+ ThemeElements.CurrentTheme.TabControlPainter.Draw (dc, area, tab);
+ }
- if (tab.DrawMode == TabDrawMode.Normal && page.Text != null) {
- if (tab.Alignment == TabAlignment.Left) {
- int wo = interior.Width / 2;
- int ho = interior.Height / 2;
- dc.TranslateTransform (interior.X + wo, interior.Y + ho);
- dc.RotateTransform (180);
- dc.DrawString (page.Text, page.Font, SystemBrushes.ControlText, 0, 0, string_format);
- dc.ResetTransform ();
- } else {
- Rectangle str_rect = interior;
+ public override Rectangle TabControlGetLeftScrollRect (TabControl tab)
+ {
+ return ThemeElements.CurrentTheme.TabControlPainter.GetLeftScrollRect (tab);
+ }
- if (tab.ImageList != null && page.ImageIndex >= 0 && page.ImageIndex < tab.ImageList.Images.Count) {
- tab.ImageList.Draw (dc, new Point (interior.X, interior.Y), page.ImageIndex);
- str_rect.X += tab.ImageList.ImageSize.Width + 2;
- str_rect.Width -= tab.ImageList.ImageSize.Width + 2;
- }
- dc.DrawString (page.Text, page.Font,
- SystemBrushes.ControlText,
- str_rect, string_format);
- }
- } else if (page.Text != null) {
- DrawItemState state = DrawItemState.None;
- if (page == tab.SelectedTab)
- state |= DrawItemState.Selected;
- DrawItemEventArgs e = new DrawItemEventArgs (dc,
- tab.Font, bounds, tab.IndexForTabPage (page),
- state, page.ForeColor, page.BackColor);
- tab.OnDrawItemInternal (e);
- return res;
- }
+ public override Rectangle TabControlGetRightScrollRect (TabControl tab)
+ {
+ return ThemeElements.CurrentTheme.TabControlPainter.GetRightScrollRect (tab);
+ }
- if (page.Parent.Focused && is_selected) {
- CPDrawFocusRectangle (dc, interior, tab.ForeColor, tab.BackColor);
- }
+ public override Rectangle TabControlGetDisplayRectangle (TabControl tab)
+ {
+ return ThemeElements.CurrentTheme.TabControlPainter.GetDisplayRectangle (tab);
+ }
- return res;
+ public override Rectangle TabControlGetPanelRect (TabControl tab)
+ {
+ return ThemeElements.CurrentTheme.TabControlPainter.GetTabPanelRect (tab);
}
+ #endregion
+
#region ToolBar
public override void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control)
{
StringFormat format = new StringFormat ();
format.Trimming = StringTrimming.EllipsisCharacter;
format.LineAlignment = StringAlignment.Center;
- format.HotkeyPrefix = MenuAccessKeysUnderlined ? HotkeyPrefix.Show : HotkeyPrefix.Hide;
+ if (control.ShowKeyboardCuesInternal)
+ format.HotkeyPrefix = HotkeyPrefix.Show;
+ else
+ format.HotkeyPrefix = HotkeyPrefix.Hide;
+
if (control.TextAlign == ToolBarTextAlign.Underneath)
format.Alignment = StringAlignment.Center;
else
#endregion // ToolBar
#region ToolTip
- public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control) {
+ public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control)
+ {
+ Rectangle text_rect = Rectangle.Inflate (control.ClientRectangle, -2, -1);
+
dc.FillRectangle(SystemBrushes.Info, control.ClientRectangle);
dc.DrawRectangle(SystemPens.WindowFrame, 0, 0, control.Width-1, control.Height-1);
- dc.DrawString(control.Text, control.Font, ResPool.GetSolidBrush(this.ColorInfoText), control.ClientRectangle, control.string_format);
+ dc.DrawString(control.Text, control.Font, ResPool.GetSolidBrush(this.ColorInfoText), text_rect, control.string_format);
}
- public override Size ToolTipSize(ToolTip.ToolTipWindow tt, string text) {
+ public override Size ToolTipSize(ToolTip.ToolTipWindow tt, string text)
+ {
SizeF sizef;
sizef = tt.DeviceContext.MeasureString(text, tt.Font, SizeF.Empty, tt.string_format);
#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 = 16;
+ private const int balloon_bordersize = 8;
+
public override void DrawBalloonWindow (Graphics dc, Rectangle clip, NotifyIcon.BalloonWindow control)
{
- Brush solidbrush = ResPool.GetSolidBrush(this.ColorInfoText);
+ 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 (SystemBrushes.Info, control.ClientRectangle);
- dc.DrawRectangle (SystemPens.WindowFrame, 0, 0, control.Width-1, control.Height-1);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorInfo), rect);
+ dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame), 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, balloon_bordersize, iconsize, iconsize));
// Title
- Rectangle titlerect = new Rectangle (rect.X + 5, rect.Y + 5, rect.Width - 10, rect.Height - 10);
+ Rectangle titlerect = new Rectangle (rect.X + balloon_bordersize + iconsize + (iconsize > 0 ? balloon_bordersize : 0),
+ rect.Y + balloon_bordersize,
+ rect.Width - ((3 * balloon_bordersize) + iconsize),
+ 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 + 5, rect.Y + 5, rect.Width - 10, rect.Height - 10);
+ Rectangle textrect = new Rectangle (rect.X + balloon_bordersize,
+ rect.Y + balloon_bordersize,
+ rect.Width - (2 * balloon_bordersize),
+ rect.Height - (2 * balloon_bordersize));
+
StringFormat textformat = control.Format;
textformat.LineAlignment = StringAlignment.Far;
dc.DrawString (control.Text, control.Font, solidbrush, textrect, textformat);
SizeF titlesize = control.DeviceContext.MeasureString (control.Title, control.Font, maxsize, control.Format);
SizeF textsize = control.DeviceContext.MeasureString (control.Text, control.Font, maxsize, control.Format);
+ if (titlesize.Height < balloon_iconsize)
+ titlesize.Height = balloon_iconsize;
+
Rectangle rect = new Rectangle ();
- rect.Height = (int) (titlesize.Height + textsize.Height + 15);
- rect.Width = (int) ((titlesize.Width > textsize.Width) ? titlesize.Width : textsize.Width) + 10;
+ rect.Height = (int) (titlesize.Height + textsize.Height + (3 * balloon_bordersize));
+ rect.Width = (int) ((titlesize.Width > textsize.Width) ? titlesize.Width : textsize.Width) + (2 * balloon_bordersize);
rect.X = deskrect.Width - rect.Width - 2;
rect.Y = deskrect.Height - rect.Height - 2;
CPDrawBorder3D(graphics, rectangle, style, sides, ColorControl);
}
- protected virtual void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color)
+ public override void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color)
{
Pen penTopLeft;
Pen penTopLeftInner;
public override void CPDrawCheckBox (Graphics dc, Rectangle rectangle, ButtonState state)
{
- Pen check_pen = SystemPens.ControlDarkDark;
+ Pen check_pen = Pens.Black;
Rectangle cb_rect = new Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);