/* Hardcoded colour values not exposed in the API constants in all configurations */
protected static readonly Color arrow_color = Color.Black;
protected static readonly Color pen_ticks_color = Color.Black;
- protected static readonly Color progressbarblock_color = Color.FromArgb (255, 0, 0, 128);
protected static StringFormat string_format_menu_text;
protected static StringFormat string_format_menu_shortcut;
protected static StringFormat string_format_menu_menubar_text;
ButtonBase_DrawImage(button, dc);
// Draw the focus rectangle
- if ((button.Focused || button.paint_as_acceptbutton) && button.Enabled && button.ShowFocusCues)
+ if (ShouldPaintFocusRectagle (button))
ButtonBase_DrawFocus(button, dc);
// Now the text
ButtonBase_DrawText(button, dc);
}
+ protected static bool ShouldPaintFocusRectagle (ButtonBase button)
+ {
+ return (button.Focused || button.paint_as_acceptbutton) && button.Enabled && button.ShowFocusCues;
+ }
+
protected virtual void ButtonBase_DrawButton (ButtonBase button, Graphics dc)
{
Rectangle borderRectangle;
check_or_radio_checked = ((RadioButton)button).Checked;
}
- if ((button.Focused || button.paint_as_acceptbutton) && button.Enabled && !check_or_radio) {
+ if (button.Focused && button.Enabled && !check_or_radio) {
// shrink the rectangle for the normal button drawing inside the focus rectangle
borderRectangle = Rectangle.Inflate (button.ClientRectangle, -1, -1);
} else {
if (button is CheckBox)
check_size = (button as CheckBox).Appearance == Appearance.Normal ? 13 : 0;
- glyphArea = new Rectangle (0, (button.Height - check_size) / 2, check_size, check_size);
+ glyphArea = new Rectangle (0, 2, check_size, check_size);
+
+ Rectangle content_rect = button.ClientRectangle;
+ ContentAlignment align = ContentAlignment.TopLeft;;
+
+ if (button is CheckBox)
+ align = (button as CheckBox).CheckAlign;
+ else if (button is RadioButton)
+ align = (button as RadioButton).CheckAlign;
+
+ switch (align) {
+ case ContentAlignment.BottomCenter:
+ glyphArea.Y = button.Height - check_size;
+ glyphArea.X = (button.Width - check_size) / 2 - 2;
+ break;
+ case ContentAlignment.BottomLeft:
+ glyphArea.Y = button.Height - check_size - 2;
+ content_rect.Width -= check_size;
+ content_rect.Offset (check_size, 0);
+ break;
+ case ContentAlignment.BottomRight:
+ glyphArea.Y = button.Height - check_size - 2;
+ glyphArea.X = button.Width - check_size;
+ content_rect.Width -= check_size;
+ break;
+ case ContentAlignment.MiddleCenter:
+ glyphArea.Y = (button.Height - check_size) / 2;
+ glyphArea.X = (button.Width - check_size) / 2;
+ break;
+ case ContentAlignment.MiddleLeft:
+ glyphArea.Y = (button.Height - check_size) / 2;
+ content_rect.Width -= check_size;
+ content_rect.Offset (check_size, 0);
+ break;
+ case ContentAlignment.MiddleRight:
+ glyphArea.Y = (button.Height - check_size) / 2;
+ glyphArea.X = button.Width - check_size;
+ content_rect.Width -= check_size;
+ break;
+ case ContentAlignment.TopCenter:
+ glyphArea.X = (button.Width - check_size) / 2;
+ break;
+ case ContentAlignment.TopLeft:
+ content_rect.Width -= check_size;
+ content_rect.Offset (check_size, 0);
+ break;
+ case ContentAlignment.TopRight:
+ glyphArea.X = button.Width - check_size;
+ content_rect.Width -= check_size;
+ break;
+ }
Image image = button.Image;
string text = button.Text;
- Rectangle content_rect = button.ClientRectangle;
- content_rect.Width -= check_size;
- content_rect.Offset (check_size, 0);
Size proposed = Size.Empty;
proposed.Width = button.Width - glyphArea.Width - 2;
Size text_size = TextRenderer.MeasureTextInternal (text, button.Font, proposed, button.TextFormatFlags, button.UseCompatibleTextRendering);
+
+ // Text can't be bigger than the content rectangle
+ text_size.Height = Math.Min (text_size.Height, content_rect.Height);
+ text_size.Width = Math.Min (text_size.Width, content_rect.Width);
+
Size image_size = image == null ? Size.Empty : image.Size;
textRectangle = Rectangle.Empty;
e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
ResPool.GetSolidBrush (fore_color),
- item_rect.X, item_rect.Y, ctrl.StringFormat);
+ item_rect, ctrl.StringFormat);
if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
CPDrawFocusRectangle (e.Graphics, item_rect,
graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding);
}
}
+ public override void ComboBoxDrawNormalDropDownButton (ComboBox comboBox, Graphics g, Rectangle clippingArea, Rectangle area, ButtonState state)
+ {
+ CPDrawComboButton (g, area, state);
+ }
+ public override bool ComboBoxNormalDropDownButtonHasTransparentBackground (ComboBox comboBox, ButtonState state)
+ {
+ return true;
+ }
+ public override bool ComboBoxDropDownButtonHasHotElementStyle (ComboBox comboBox)
+ {
+ return false;
+ }
+ public override void ComboBoxDrawBackground (ComboBox comboBox, Graphics g, Rectangle clippingArea, FlatStyle style)
+ {
+ if (!comboBox.Enabled)
+ g.FillRectangle (ResPool.GetSolidBrush (ColorControl), comboBox.ClientRectangle);
+
+ if (comboBox.DropDownStyle == ComboBoxStyle.Simple)
+ g.FillRectangle (ResPool.GetSolidBrush (comboBox.Parent.BackColor), comboBox.ClientRectangle);
+
+ if (style == FlatStyle.Popup && (comboBox.Entered || comboBox.Focused)) {
+ Rectangle area = comboBox.TextArea;
+ area.Height -= 1;
+ area.Width -= 1;
+ g.DrawRectangle (ResPool.GetPen (SystemColors.ControlDark), area);
+ g.DrawLine (ResPool.GetPen (SystemColors.ControlDark), comboBox.ButtonArea.X - 1, comboBox.ButtonArea.Top, comboBox.ButtonArea.X - 1, comboBox.ButtonArea.Bottom);
+ }
+ bool is_flat = style == FlatStyle.Flat || style == FlatStyle.Popup;
+ if (!is_flat && clippingArea.IntersectsWith (comboBox.TextArea))
+ ControlPaint.DrawBorder3D (g, comboBox.TextArea, Border3DStyle.Sunken);
+ }
+ public override bool CombBoxBackgroundHasHotElementStyle (ComboBox comboBox)
+ {
+ return false;
+ }
#endregion ComboBox
#region Datagrid
public override void DataGridPaintCaption (Graphics g, Rectangle clip, DataGrid grid)
{
- Rectangle modified_area = clip;
- modified_area.Intersect (grid.caption_area);
+ Rectangle bounds = clip;
+ bounds.Intersect (grid.caption_area);
- g.FillRectangle (ResPool.GetSolidBrush (grid.CaptionBackColor),
- modified_area);
+ // Background
+ g.FillRectangle (ResPool.GetSolidBrush (grid.CaptionBackColor), bounds);
- Rectangle text_rect = grid.caption_area;
- text_rect.Y += text_rect.Height / 2 - grid.CaptionFont.Height / 2;
- text_rect.Height = grid.CaptionFont.Height;
-
- g.DrawString (grid.CaptionText, grid.CaptionFont,
- ResPool.GetSolidBrush (grid.CaptionForeColor),
- text_rect);
+ // Bottom line
+ g.DrawLine (ResPool.GetPen (grid.CurrentTableStyle.CurrentHeaderForeColor),
+ bounds.X, bounds.Y + bounds.Height -1,
+ bounds.X + bounds.Width, bounds.Y + bounds.Height -1);
- if (modified_area.IntersectsWith (grid.back_button_rect)) {
+ // Caption text
+ if (grid.CaptionText != String.Empty) {
+ Rectangle text_rect = grid.caption_area;
+ text_rect.Y += text_rect.Height / 2 - grid.CaptionFont.Height / 2;
+ text_rect.Height = grid.CaptionFont.Height;
+
+ g.DrawString (grid.CaptionText, grid.CaptionFont,
+ ResPool.GetSolidBrush (grid.CaptionForeColor),
+ text_rect);
+ }
+
+ // Back button
+ if (bounds.IntersectsWith (grid.back_button_rect)) {
g.DrawImage (grid.back_button_image, grid.back_button_rect);
if (grid.back_button_mouseover) {
CPDrawBorder3D (g, grid.back_button_rect, grid.back_button_active ? Border3DStyle.Sunken : Border3DStyle.Raised, all_sides);
}
}
- if (modified_area.IntersectsWith (grid.parent_rows_button_rect)) {
+
+ // Rows button
+ if (bounds.IntersectsWith (grid.parent_rows_button_rect)) {
g.DrawImage (grid.parent_rows_button_image, grid.parent_rows_button_rect);
if (grid.parent_rows_button_mouseover) {
CPDrawBorder3D (g, grid.parent_rows_button_rect, grid.parent_rows_button_active ? Border3DStyle.Sunken : Border3DStyle.Raised, all_sides);
public override void DataGridPaintColumnHeaders (Graphics g, Rectangle clip, DataGrid grid)
{
+ if (!grid.CurrentTableStyle.ColumnHeadersVisible)
+ return;
+
Rectangle columns_area = grid.column_headers_area;
- if (grid.CurrentTableStyle.CurrentRowHeadersVisible) { // Paint corner shared between row and column header
+ // Paint corner shared between row and column header
+ if (grid.CurrentTableStyle.CurrentRowHeadersVisible) {
Rectangle rect_bloc = grid.column_headers_area;
rect_bloc.Width = grid.RowHeaderWidth;
if (clip.IntersectsWith (rect_bloc)) {
- if (grid.VisibleColumnCount > 0)
+ if (grid.FlatMode)
g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor), rect_bloc);
else
- g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), rect_bloc);
+ CPDrawBorder3D (g, rect_bloc, Border3DStyle.RaisedInner,
+ Border3DSide.Left | Border3DSide.Right |
+ Border3DSide.Top | Border3DSide.Bottom | Border3DSide.Middle,
+ grid.CurrentTableStyle.CurrentHeaderBackColor);
}
columns_area.X += grid.RowHeaderWidth;
columns_area.Width -= grid.RowHeaderWidth;
}
- // Set unused area
- Rectangle column_headers_area_complete = columns_area;
- column_headers_area_complete.Width = grid.column_headers_max_width;
-
- if (grid.CurrentTableStyle.CurrentRowHeadersVisible) {
- column_headers_area_complete.Width -= grid.RowHeaderWidth;
- }
-
// Set column painting
Rectangle rect_columnhdr = new Rectangle ();
int col_pixel;
current_clip.Intersect (prev_clip);
g.Clip = current_clip;
- grid.CurrentTableStyle.GridColumnStyles[column].PaintHeader (g, rect_columnhdr, column);
+ DataGridPaintColumnHeader (g, rect_columnhdr, grid, column);
current_clip.Dispose ();
}
g.Clip = prev_clip;
- Rectangle not_usedarea = column_headers_area_complete;
- not_usedarea.X = rect_columnhdr.X + rect_columnhdr.Width;
- not_usedarea.Width = grid.ClientRectangle.X + grid.ClientRectangle.Width - rect_columnhdr.X - rect_columnhdr.Height;
+ Rectangle not_usedarea = grid.column_headers_area;
+ not_usedarea.X = (column_cnt == 0) ? grid.RowHeaderWidth : rect_columnhdr.X + rect_columnhdr.Width;
+ not_usedarea.Width = grid.ClientRectangle.X + grid.ClientRectangle.Width - not_usedarea.X;
g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
-
+ }
+
+ public override void DataGridPaintColumnHeader (Graphics g, Rectangle bounds, DataGrid grid, int col)
+ {
+ // Background
+ g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.HeaderBackColor), bounds);
+
+ // Paint Borders
+ if (!grid.FlatMode) {
+ g.DrawLine (ResPool.GetPen (ColorControlLightLight),
+ bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
+
+ if (col == 0) {
+ g.DrawLine (ResPool.GetPen (ColorControlLightLight),
+ bounds.X, bounds.Y, bounds.X, bounds.Y + bounds.Height);
+ } else {
+ g.DrawLine (ResPool.GetPen (ColorControlLightLight),
+ bounds.X, bounds.Y + 2, bounds.X, bounds.Y + bounds.Height - 3);
+ }
+
+ if (col == (grid.VisibleColumnCount -1)) {
+ g.DrawLine (ResPool.GetPen (ColorControlDark),
+ bounds.X + bounds.Width - 1, bounds.Y,
+ bounds.X + bounds.Width - 1, bounds.Y + bounds.Height);
+ } else {
+ g.DrawLine (ResPool.GetPen (ColorControlDark),
+ bounds.X + bounds.Width - 1, bounds.Y + 2,
+ bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 3);
+ }
+
+ g.DrawLine (ResPool.GetPen (ColorControlDark),
+ bounds.X, bounds.Y + bounds.Height - 1,
+ bounds.X + bounds.Width, bounds.Y + bounds.Height - 1);
+ }
+
+ bounds.X += 2;
+ bounds.Width -= 2;
+
+ DataGridColumnStyle style = grid.CurrentTableStyle.GridColumnStyles[col];
+
+ if (style.ArrowDrawingMode != DataGridColumnStyle.ArrowDrawing.No)
+ bounds.Width -= 16;
+
+ // Caption
+ StringFormat format = new StringFormat ();
+ format.FormatFlags |= StringFormatFlags.NoWrap;
+ format.LineAlignment = StringAlignment.Center;
+ format.Trimming = StringTrimming.Character;
+
+ g.DrawString (style.HeaderText, grid.CurrentTableStyle.HeaderFont,
+ ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
+ bounds, format);
+
+ // Arrow (6 x 6)
+ if (style.ArrowDrawingMode != DataGridColumnStyle.ArrowDrawing.No) {
+ Point pnt = new Point (bounds.X + bounds.Width + 4, bounds.Y + ((bounds.Height - 6)/2));
+
+ if (style.ArrowDrawingMode == DataGridColumnStyle.ArrowDrawing.Ascending) {
+ g.DrawLine (SystemPens.ControlLightLight, pnt.X + 6, pnt.Y + 6, pnt.X + 3, pnt.Y);
+ g.DrawLine (SystemPens.ControlDark, pnt.X, pnt.Y + 6, pnt.X + 6, pnt.Y + 6);
+ g.DrawLine (SystemPens.ControlDark, pnt.X, pnt.Y + 6, pnt.X + 3, pnt.Y);
+ } else {
+ g.DrawLine (SystemPens.ControlLightLight, pnt.X + 6, pnt.Y, pnt.X + 3, pnt.Y + 6);
+ g.DrawLine (SystemPens.ControlDark, pnt.X, pnt.Y, pnt.X + 6, pnt.Y);
+ g.DrawLine (SystemPens.ControlDark, pnt.X, pnt.Y, pnt.X + 3, pnt.Y + 6);
+ }
+ }
}
public override void DataGridPaintParentRows (Graphics g, Rectangle clip, DataGrid grid)
public override void DataGridPaintParentRow (Graphics g, Rectangle bounds, DataGridDataSource row, DataGrid grid)
{
- //Console.WriteLine ("drawing parent row {0}", row);
-
// Background
g.FillRectangle (ResPool.GetSolidBrush (grid.ParentRowsBackColor),
bounds);
text_size = g.MeasureString (table_name, bold_font).ToSize();
text_rect = new Rectangle(new Point(bounds.X + 3, bounds.Y + bounds.Height - text_size.Height), text_size);
- //Console.WriteLine ("drawing text at {0}", text_rect);
-
g.DrawString (table_name,
bold_font, ResPool.GetSolidBrush (grid.ParentRowsForeColor), text_rect, text_format);
text_rect.Size = g.MeasureString (text, grid.Font).ToSize();
text_rect.Y = bounds.Y + bounds.Height - text_rect.Height; // XXX
- //Console.WriteLine ("drawing text at {0}", text_rect);
-
g.DrawString (text,
grid.Font, ResPool.GetSolidBrush (grid.ParentRowsForeColor), text_rect, text_format);
}
- if (grid.FlatMode == false) {
-
- // Paint Borders
- g.DrawLine (ResPool.GetPen (ColorControlLight),
- bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
-
- g.DrawLine (ResPool.GetPen (ColorControlLight),
- bounds.X, bounds.Y + 1, bounds.X, bounds.Y + bounds.Height - 1);
-
- g.DrawLine (ResPool.GetPen (ColorControlDark),
- bounds.X + bounds.Width - 1, bounds.Y + 1 , bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
-
- g.DrawLine (ResPool.GetPen (ColorControlDark),
- bounds.X, bounds.Y + bounds.Height -1, bounds.X + bounds.Width, bounds.Y + bounds.Height -1);
+ // Paint Borders
+ if (!grid.FlatMode) {
+ CPDrawBorder3D (g, bounds, Border3DStyle.RaisedInner,
+ Border3DSide.Left | Border3DSide.Right |
+ Border3DSide.Top | Border3DSide.Bottom);
}
}
(grid.CurrentTableStyle.CurrentHeaderForeColor), arrow, FillMode.Winding);
}
+ public override void DataGridPaintRowHeaderStar (Graphics g, Rectangle bounds, DataGrid grid)
+ {
+ int x = bounds.X + 4;
+ int y = bounds.Y + 3;
+ Pen pen = ResPool.GetPen (grid.CurrentTableStyle.CurrentHeaderForeColor);
+
+ g.DrawLine (pen, x + 4, y, x + 4, y + 8);
+ g.DrawLine (pen, x, y + 4, x + 8, y + 4);
+ g.DrawLine (pen, x + 1, y + 1, x + 7, y + 7);
+ g.DrawLine (pen, x + 7, y + 1, x + 1, y + 7);
+ }
+
public override void DataGridPaintRowHeader (Graphics g, Rectangle bounds, int row, DataGrid grid)
{
bool is_add_row = grid.ShowEditRow && row == grid.DataGridRows.Length - 1;
bool is_current_row = row == grid.CurrentCell.RowNumber;
// Background
- g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor),
- bounds);
+ g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor), bounds);
// Draw arrow
if (is_current_row) {
}
}
else if (is_add_row) {
- g.DrawString ("*", grid.Font, ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
- bounds);
+ DataGridPaintRowHeaderStar (g, bounds, grid);
}
- if (grid.FlatMode == false && !is_add_row) {
- // Paint Borders
- g.DrawLine (ResPool.GetPen (ColorControlLight),
- bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
-
- g.DrawLine (ResPool.GetPen (ColorControlLight),
- bounds.X, bounds.Y + 1, bounds.X, bounds.Y + bounds.Height - 1);
-
- g.DrawLine (ResPool.GetPen (ColorControlDark),
- bounds.X + bounds.Width - 1, bounds.Y + 1 , bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
-
- g.DrawLine (ResPool.GetPen (ColorControlDark),
- bounds.X, bounds.Y + bounds.Height -1, bounds.X + bounds.Width, bounds.Y + bounds.Height -1);
+ if (!grid.FlatMode && !is_add_row) {
+ CPDrawBorder3D (g, bounds, Border3DStyle.RaisedInner,
+ Border3DSide.Left | Border3DSide.Right |
+ Border3DSide.Top | Border3DSide.Bottom);
}
}
// PaintCells at row, column
int column_cnt = grid.FirstVisibleColumn + grid.VisibleColumnCount;
+ DataGridCell current_cell = grid.CurrentCell;
if (column_cnt > 0) {
Region prev_clip = g.Clip;
current_clip.Intersect (prev_clip);
g.Clip = current_clip;
+ Brush colBackBrush = backBrush;
+ Brush colForeBrush = foreBrush;
+
+ // If we are in the precise cell we are editing, then use the normal colors
+ // even if we are selected.
+ if (grid.is_editing && column == current_cell.ColumnNumber && row == current_cell.RowNumber) {
+ colBackBrush = ResPool.GetSolidBrush (grid.BackColor);
+ colForeBrush = ResPool.GetSolidBrush (grid.ForeColor);
+ }
+
if (is_newrow) {
grid.CurrentTableStyle.GridColumnStyles[column].PaintNewRow (g, rect_cell,
- backBrush,
- foreBrush);
+ colBackBrush,
+ colForeBrush);
} else {
grid.CurrentTableStyle.GridColumnStyles[column].Paint (g, rect_cell, grid.ListManager, row,
- backBrush,
- foreBrush,
+ colBackBrush,
+ colForeBrush,
grid.RightToLeft == RightToLeft.Yes);
}
}
#endregion // Datagrid
-
+
+#if NET_2_0
+ #region DataGridView
+ #region DataGridViewHeaderCell
+ #region DataGridViewRowHeaderCell
+ public override bool DataGridViewRowHeaderCellDrawBackground (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds)
+ {
+ return false;
+ }
+
+ public override bool DataGridViewRowHeaderCellDrawSelectionBackground (DataGridViewRowHeaderCell cell)
+ {
+ return false;
+ }
+
+ public override bool DataGridViewRowHeaderCellDrawBorder (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds)
+ {
+ return false;
+ }
+ #endregion
+
+ #region DataGridViewColumnHeaderCell
+ public override bool DataGridViewColumnHeaderCellDrawBackground (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds)
+ {
+ return false;
+ }
+
+ public override bool DataGridViewColumnHeaderCellDrawBorder (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds)
+ {
+ return false;
+ }
+ #endregion
+
+ public override bool DataGridViewHeaderCellHasPressedStyle (DataGridView dataGridView)
+ {
+ return false;
+ }
+
+ public override bool DataGridViewHeaderCellHasHotStyle (DataGridView dataGridView)
+ {
+ return false;
+ }
+ #endregion
+ #endregion
+#endif
+
#region DateTimePicker
+ protected virtual void DateTimePickerDrawBorder (DateTimePicker dateTimePicker, Graphics g, Rectangle clippingArea)
+ {
+ this.CPDrawBorder3D (g, dateTimePicker.ClientRectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, dateTimePicker.BackColor);
+ }
+
+ protected virtual void DateTimePickerDrawDropDownButton (DateTimePicker dateTimePicker, Graphics g, Rectangle clippingArea)
+ {
+ ButtonState state = dateTimePicker.is_drop_down_visible ? ButtonState.Pushed : ButtonState.Normal;
+ g.FillRectangle (ResPool.GetSolidBrush (ColorControl), dateTimePicker.drop_down_arrow_rect);
+ this.CPDrawComboButton (
+ g,
+ dateTimePicker.drop_down_arrow_rect,
+ state);
+ }
public override void DrawDateTimePicker(Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp)
{
// draw the outer border
Rectangle button_bounds = dtp.ClientRectangle;
- this.CPDrawBorder3D (dc, button_bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, dtp.BackColor);
+ DateTimePickerDrawBorder (dtp, dc, clip_rectangle);
// deflate by the border width
if (clip_rectangle.IntersectsWith (dtp.drop_down_arrow_rect)) {
button_bounds.Inflate (-2,-2);
if (!dtp.ShowUpDown) {
- ButtonState state = dtp.is_drop_down_visible ? ButtonState.Pushed : ButtonState.Normal;
- dc.FillRectangle (ResPool.GetSolidBrush (ColorControl), dtp.drop_down_arrow_rect);
- this.CPDrawComboButton (
- dc,
- dtp.drop_down_arrow_rect,
- state);
+ DateTimePickerDrawDropDownButton (dtp, dc, clip_rectangle);
} else {
ButtonState up_state = dtp.is_up_pressed ? ButtonState.Pushed : ButtonState.Normal;
ButtonState down_state = dtp.is_down_pressed ? ButtonState.Pushed : ButtonState.Normal;
if (!clip_rectangleF.IntersectsWith (fd.drawing_rectangle))
continue;
- text = fd.GetText (dtp.Value);
+ text = dtp.editing_part_index == i ? dtp.editing_text : fd.GetText (dtp.Value);
PointF text_position = new PointF ();
SizeF text_size;
else
text_format.FormatFlags |= StringFormatFlags.NoClip;
- if (fd.is_selected) {
+ if (fd.Selected) {
dc.FillRectangle (SystemBrushes.Highlight, text_rect);
dc.DrawString (text, dtp.Font, SystemBrushes.HighlightText, text_rect, text_format);
}
}
}
-
+
+ public override bool DateTimePickerBorderHasHotElementStyle {
+ get {
+ return false;
+ }
+ }
+
+ public override Rectangle DateTimePickerGetDropDownButtonArea (DateTimePicker dateTimePicker)
+ {
+ Rectangle rect = dateTimePicker.ClientRectangle;
+ rect.X = rect.Right - SystemInformation.VerticalScrollBarWidth - 2;
+ if (rect.Width > (SystemInformation.VerticalScrollBarWidth + 2)) {
+ rect.Width = SystemInformation.VerticalScrollBarWidth;
+ } else {
+ rect.Width = Math.Max (rect.Width - 2, 0);
+ }
+
+ rect.Inflate (0, -2);
+ return rect;
+ }
+
+ public override Rectangle DateTimePickerGetDateArea (DateTimePicker dateTimePicker)
+ {
+ Rectangle rect = dateTimePicker.ClientRectangle;
+ if (dateTimePicker.ShowUpDown) {
+ // set the space to the left of the up/down button
+ if (rect.Width > (DateTimePicker.up_down_width + 4)) {
+ rect.Width -= (DateTimePicker.up_down_width + 4);
+ } else {
+ rect.Width = 0;
+ }
+ } else {
+ // set the space to the left of the up/down button
+ // TODO make this use up down button
+ if (rect.Width > (SystemInformation.VerticalScrollBarWidth + 4)) {
+ rect.Width -= SystemInformation.VerticalScrollBarWidth;
+ } else {
+ rect.Width = 0;
+ }
+ }
+
+ rect.Inflate (-2, -2);
+ return rect;
+ }
+ public override bool DateTimePickerDropDownButtonHasHotElementStyle {
+ get {
+ return false;
+ }
+ }
#endregion // DateTimePicker
#region GroupBox
e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
ResPool.GetSolidBrush (fore_color),
- e.Bounds.X, e.Bounds.Y, ctrl.StringFormat);
+ e.Bounds, ctrl.StringFormat);
if ((e.State & DrawItemState.Focus) == DrawItemState.Focus)
CPDrawFocusRectangle (e.Graphics, e.Bounds, fore_color, back_color);
{
bool details = control.View == View.Details;
int first = control.FirstVisibleIndex;
+ int lastvisibleindex = control.LastVisibleIndex;
- for (int i = first; i <= control.LastVisibleIndex; i ++) {
- if (clip.IntersectsWith (control.Items[i].GetBounds (ItemBoundsPortion.Entire))) {
+#if NET_2_0
+ if (control.VirtualMode)
+ control.OnCacheVirtualItems (new CacheVirtualItemsEventArgs (first, lastvisibleindex));
+#endif
+
+ for (int i = first; i <= lastvisibleindex; i++) {
+ ListViewItem item = control.GetItemAtDisplayIndex (i);
+ if (clip.IntersectsWith (item.Bounds)) {
#if NET_2_0
bool owner_draw = false;
if (control.OwnerDraw)
- owner_draw = DrawListViewItemOwnerDraw (dc, control.Items [i], i);
+ owner_draw = DrawListViewItemOwnerDraw (dc, item, i);
if (!owner_draw)
#endif
- DrawListViewItem (dc, control, control.Items [i]);
+ {
+ DrawListViewItem (dc, control, item);
+ if (control.View == View.Details)
+ DrawListViewSubItems (dc, control, item);
+ }
}
}
#if NET_2_0
- if (control.ShowGroups && control.View != View.List && control.Groups.Count > 0) {
+ if (control.UsingGroups) {
// Use InternalCount instead of Count to take into account Default Group as needed
for (int i = 0; i < control.Groups.InternalCount; i++) {
ListViewGroup group = control.Groups.GetInternalGroup (i);
ListViewInsertionMark insertion_mark = control.InsertionMark;
int insertion_mark_index = insertion_mark.Index;
- if (insertion_mark.Bounds != Rectangle.Empty &&
+ if (Application.VisualStylesEnabled && insertion_mark.Bounds != Rectangle.Empty &&
(control.View != View.Details && control.View != View.List) &&
insertion_mark_index > -1 && insertion_mark_index < control.Items.Count) {
#endif
// draw the gridlines
+#if NET_2_0
+ if (details && control.GridLines && !control.UsingGroups) {
+#else
if (details && control.GridLines) {
+#endif
+ Size control_size = control.ClientSize;
int top = (control.HeaderStyle == ColumnHeaderStyle.None) ?
- 2 : control.Font.Height + 2;
+ 0 : control.header_control.Height;
// draw vertical gridlines
- foreach (ColumnHeader col in control.Columns)
+ foreach (ColumnHeader col in control.Columns) {
+ int column_right = col.Rect.Right - control.h_marker;
dc.DrawLine (SystemPens.Control,
- col.Rect.Right, top,
- col.Rect.Right, control.TotalHeight);
- // draw horizontal gridlines
- ListViewItem last_item = null;
- foreach (ListViewItem item in control.Items) {
- dc.DrawLine (SystemPens.Control,
- item.GetBounds (ItemBoundsPortion.Entire).Left, item.GetBounds (ItemBoundsPortion.Entire).Top,
- control.TotalWidth, item.GetBounds (ItemBoundsPortion.Entire).Top);
- last_item = item;
+ column_right, top,
+ column_right, control_size.Height);
}
- // draw a line after at the bottom of the last item
- if (last_item != null) {
- dc.DrawLine (SystemPens.Control,
- last_item.GetBounds (ItemBoundsPortion.Entire).Left,
- last_item.GetBounds (ItemBoundsPortion.Entire).Bottom,
- control.TotalWidth,
- last_item.GetBounds (ItemBoundsPortion.Entire).Bottom);
+ // draw horizontal gridlines
+ int item_height = control.ItemSize.Height;
+ if (item_height == 0)
+ item_height = control.Font.Height + 2;
+
+ int y = top + item_height - (control.v_marker % item_height); // scroll bar offset
+ while (y < control_size.Height) {
+ dc.DrawLine (SystemPens.Control, 0, y, control_size.Width, y);
+ y += item_height;
}
}
continue;
#endif
- ButtonState state;
- if (control.HeaderStyle == ColumnHeaderStyle.Clickable)
- state = col.Pressed ? ButtonState.Pushed : ButtonState.Normal;
- else
- state = ButtonState.Flat;
- CPDrawButton (dc, rect, state);
+ ListViewDrawColumnHeaderBackground (control, col, dc, rect, clip);
rect.X += 5;
rect.Width -= 10;
if (rect.Width <= 0)
continue;
- dc.DrawString (col.Text, control.Font,
- SystemBrushes.ControlText,
- rect, col.Format);
+#if NET_2_0
+ int image_index;
+ if (control.SmallImageList == null)
+ image_index = -1;
+ else
+ image_index = col.ImageKey == String.Empty ? col.ImageIndex : control.SmallImageList.Images.IndexOfKey (col.ImageKey);
+
+ if (image_index > -1 && image_index < control.SmallImageList.Images.Count) {
+ int image_width = control.SmallImageList.ImageSize.Width + 5;
+ int text_width = (int)dc.MeasureString (col.Text, control.Font).Width;
+ int x_origin = rect.X;
+
+ switch (col.TextAlign) {
+ case HorizontalAlignment.Left:
+ break;
+ case HorizontalAlignment.Right:
+ x_origin = rect.Right - (text_width + image_width);
+ break;
+ case HorizontalAlignment.Center:
+ x_origin = (rect.Width - (text_width + image_width)) / 2 + rect.X;
+ break;
+ }
+
+ if (x_origin < rect.X)
+ x_origin = rect.X;
+
+ control.SmallImageList.Draw (dc, new Point (x_origin, rect.Y), image_index);
+ rect.X += image_width;
+ rect.Width -= image_width;
+ }
+#endif
+
+ dc.DrawString (col.Text, control.Font, SystemBrushes.ControlText, rect, col.Format);
}
int right = control.GetReorderedColumn (control.Columns.Count - 1).Rect.Right - control.h_marker;
if (right < control.Right) {
Rectangle rect = control.Columns [0].Rect;
rect.X = right;
rect.Width = control.Right - right;
- ButtonState state;
- if (control.HeaderStyle == ColumnHeaderStyle.Clickable)
- state = ButtonState.Normal;
- else
- state = ButtonState.Flat;
- CPDrawButton (dc, rect, state);
+ ListViewDrawUnusedHeaderBackground (control, dc, rect, clip);
}
}
}
}
+ protected virtual void ListViewDrawColumnHeaderBackground (ListView listView, ColumnHeader columnHeader, Graphics g, Rectangle area, Rectangle clippingArea)
+ {
+ ButtonState state;
+ if (listView.HeaderStyle == ColumnHeaderStyle.Clickable)
+ state = columnHeader.Pressed ? ButtonState.Pushed : ButtonState.Normal;
+ else
+ state = ButtonState.Flat;
+ CPDrawButton (g, area, state);
+ }
+
+ protected virtual void ListViewDrawUnusedHeaderBackground (ListView listView, Graphics g, Rectangle area, Rectangle clippingArea)
+ {
+ ButtonState state;
+ if (listView.HeaderStyle == ColumnHeaderStyle.Clickable)
+ state = ButtonState.Normal;
+ else
+ state = ButtonState.Flat;
+ CPDrawButton (g, area, state);
+ }
+
public override void DrawListViewHeaderDragDetails (Graphics dc, ListView view, ColumnHeader col, int target_x)
{
Rectangle rect = col.Rect;
if (args.DrawDefault)
return false;
- if (item.ListView.View == View.Details)
- for (int i = 0; i < item.SubItems.Count; i++) {
- int count = Math.Min (item.ListView.Columns.Count, item.SubItems.Count);
-
- // Do system drawing for subitems if no owner draw is done
- for (int j = 0; j < count; j++)
- if (!DrawListViewSubItemOwnerDraw (dc, item, item_state, j))
+ if (item.ListView.View == View.Details) {
+ int count = Math.Min (item.ListView.Columns.Count, item.SubItems.Count);
+
+ // Do system drawing for subitems if no owner draw is done
+ for (int j = 0; j < count; j++) {
+ if (!DrawListViewSubItemOwnerDraw (dc, item, item_state, j)) {
+ if (j == 0) // The first sub item contains the main item semantics
+ DrawListViewItem (dc, item.ListView, item);
+ else
DrawListViewSubItem (dc, item.ListView, item, j);
+ }
}
-
+ }
+
return true;
}
#endif
format.Alignment = StringAlignment.Near;
#if NET_2_0
- if (control.LabelWrap && control.View != View.Tile)
+ if (control.LabelWrap && control.View != View.Details && control.View != View.Tile)
#else
- if (control.LabelWrap)
+ if (control.LabelWrap && control.View != View.Details)
#endif
format.FormatFlags = StringFormatFlags.LineLimit;
else
#if NET_2_0
// Tile view renders its Text in a different fashion
- if (control.View == View.Tile) {
+ if (control.View == View.Tile && Application.VisualStylesEnabled) {
// Item.Text is drawn using its first subitem's bounds
dc.DrawString (item.Text, item.Font, textBrush, item.SubItems [0].Bounds, format);
dc.DrawString (item.Text, font, textBrush, text_rect, format);
}
- if (control.View == View.Details && control.Columns.Count > 0) {
- // draw subitems for details view
- ListViewItem.ListViewSubItemCollection subItems = item.SubItems;
- int count = (control.Columns.Count < subItems.Count ?
- control.Columns.Count : subItems.Count);
-
- if (count > 0) {
- // 0th subitem is the item already drawn
- for (int index = 1; index < count; index++)
- DrawListViewSubItem (dc, control, item, index);
-
- // Fill in selection for remaining columns if Column.Count > SubItems.Count
- ColumnHeader col;
- Rectangle sub_item_rect = text_rect;
- if (item.Selected && (control.Focused || !control.HideSelection) && control.FullRowSelect) {
- for (int index = count; index < control.Columns.Count; index++) {
- col = control.Columns [index];
- sub_item_rect.X = col.Rect.X - control.h_marker;
- sub_item_rect.Width = col.Wd;
- if (control.Focused)
- dc.FillRectangle (SystemBrushes.Highlight, sub_item_rect);
- else
- dc.FillRectangle (SystemBrushes.Control, sub_item_rect);
- }
- }
- }
- }
-
if (item.Focused && control.Focused) {
Rectangle focus_rect = highlight_rect;
if (control.FullRowSelect && control.View == View.Details) {
width += col.Width;
focus_rect = new Rectangle (0, full_rect.Y, width, full_rect.Height);
}
- if (item.Selected)
- CPDrawFocusRectangle (dc, focus_rect, ColorHighlightText, ColorHighlight);
- else
- CPDrawFocusRectangle (dc, focus_rect, control.ForeColor, control.BackColor);
+ if (control.ShowFocusCues) {
+ if (item.Selected)
+ CPDrawFocusRectangle (dc, focus_rect, ColorHighlightText, ColorHighlight);
+ else
+ CPDrawFocusRectangle (dc, focus_rect, control.ForeColor, control.BackColor);
+ }
}
format.Dispose ();
}
+ protected virtual void DrawListViewSubItems (Graphics dc, ListView control, ListViewItem item)
+ {
+ int columns_count = control.Columns.Count;
+ int count = Math.Min (item.SubItems.Count, columns_count);
+ // 0th item already done (in this case)
+ for (int i = 1; i < count; i++)
+ DrawListViewSubItem (dc, control, item, i);
+
+ // Fill in selection for remaining columns if Column.Count > SubItems.Count
+ Rectangle sub_item_rect = item.GetBounds (ItemBoundsPortion.Label);
+ if (item.Selected && (control.Focused || !control.HideSelection) && control.FullRowSelect) {
+ for (int index = count; index < columns_count; index++) {
+ ColumnHeader col = control.Columns [index];
+ sub_item_rect.X = col.Rect.X - control.h_marker;
+ sub_item_rect.Width = col.Wd;
+ dc.FillRectangle (control.Focused ? SystemBrushes.Highlight : SystemBrushes.Control,
+ sub_item_rect);
+ }
+ }
+ }
+
protected virtual void DrawListViewSubItem (Graphics dc, ListView control, ListViewItem item, int index)
{
ListViewItem.ListViewSubItem subItem = item.SubItems [index];
ColumnHeader col = control.Columns [index];
StringFormat format = new StringFormat ();
format.Alignment = col.Format.Alignment;
+ format.LineAlignment = StringAlignment.Center;
format.FormatFlags = StringFormatFlags.NoWrap;
format.Trimming = StringTrimming.EllipsisCharacter;
Rectangle header_bounds = group.HeaderBounds;
text_bounds.Offset (8, 0);
text_bounds.Inflate (-8, 0);
- Size text_size = control.text_size;
+ int text_height = control.Font.Height + 2; // add a tiny padding between the text and the group line
Font font = new Font (control.Font, control.Font.Style | FontStyle.Bold);
Brush brush = new LinearGradientBrush (new Point (header_bounds.Left, 0), new Point (header_bounds.Left + ListViewGroupLineWidth, 0),
sformat.LineAlignment = StringAlignment.Near;
dc.DrawString (group.Header, font, SystemBrushes.ControlText, text_bounds, sformat);
- dc.DrawLine (pen, header_bounds.Left, header_bounds.Top + text_size.Height, header_bounds.Left + ListViewGroupLineWidth,
- header_bounds.Top + text_size.Height);
+ dc.DrawLine (pen, header_bounds.Left, header_bounds.Top + text_height, header_bounds.Left + ListViewGroupLineWidth,
+ header_bounds.Top + text_height);
sformat.Dispose ();
font.Dispose ();
}
#endif
+ public override bool ListViewHasHotHeaderStyle {
+ get {
+ return false;
+ }
+ }
+
// Sizing
+ public override int ListViewGetHeaderHeight (ListView listView, Font font)
+ {
+ return ListViewGetHeaderHeight (font);
+ }
+
+ static int ListViewGetHeaderHeight (Font font)
+ {
+ return font.Height + 5;
+ }
+
+ public static int ListViewGetHeaderHeight ()
+ {
+ return ListViewGetHeaderHeight (ThemeEngine.Current.DefaultFont);
+ }
+
public override Size ListViewCheckBoxSize {
get { return new Size (16, 16); }
}
brush_text,
rect_text, string_format);
- 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, brush_text,
- rect, string_format_menu_shortcut);
- }
-
if (item.MenuBar) {
Border3DStyle border_style = Border3DStyle.Adjust;
if ((item.Status & DrawItemState.HotLight) != 0)
e.Graphics.DrawString (item.Text, e.Font, Brushes.White,
new RectangleF(rect_text.X + 1, rect_text.Y + 1, rect_text.Width, rect_text.Height),
string_format);
+
}
e.Graphics.DrawString (item.Text, e.Font, ResPool.GetSolidBrush(ColorGrayText), rect_text, string_format);
}
+ 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;
+
+ if (item.Enabled) {
+ e.Graphics.DrawString (str, e.Font, brush_text, rect, string_format_menu_shortcut);
+ } else {
+ if ((item.Status & DrawItemState.Selected) != DrawItemState.Selected) {
+ e.Graphics.DrawString (str, e.Font, Brushes.White,
+ new RectangleF(rect.X + 1, rect.Y + 1, rect.Width, rect_text.Height),
+ string_format_menu_shortcut);
+
+ }
+ e.Graphics.DrawString (str, e.Font, ResPool.GetSolidBrush(ColorGrayText), rect, string_format_menu_shortcut);
+ }
+ }
+
/* Draw arrow */
if (item.MenuBar == false && (item.IsPopup || item.MdiList)) {
// draws the pervious or next button
private void DrawMonthCalendarButton (Graphics dc, Rectangle rectangle, MonthCalendar mc, Size title_size, int x_offset, Size button_size, bool is_previous)
{
+ const int arrow_width = 4;
+ const int arrow_height = 7;
+
bool is_clicked = false;
Rectangle button_rect;
- Rectangle arrow_rect = new Rectangle (rectangle.X, rectangle.Y, 4, 7);
- Point[] arrow_path = new Point[3];
+ PointF arrow_center;
+ PointF [] arrow_path = new PointF [3];
+
// prepare the button
if (is_previous)
{
is_clicked = mc.is_previous_clicked;
+
button_rect = new Rectangle (
rectangle.X + 1 + x_offset,
rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
Math.Max(button_size.Width - 1, 0),
Math.Max(button_size.Height - 1, 0));
- arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
- arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
+
+ arrow_center = new PointF (button_rect.X + ((button_rect.Width + arrow_width) / 2.0f),
+ rectangle.Y + ((button_rect.Height + arrow_height) / 2) + 1);
if (is_clicked) {
- arrow_rect.Offset(1,1);
+ arrow_center.X += 1;
+ arrow_center.Y += 1;
}
- arrow_path[0] = new Point (arrow_rect.Right, arrow_rect.Y);
- arrow_path[1] = new Point (arrow_rect.X, arrow_rect.Y + arrow_rect.Height/2);
- arrow_path[2] = new Point (arrow_rect.Right, arrow_rect.Bottom);
+
+ arrow_path [0].X = arrow_center.X;
+ arrow_path [0].Y = arrow_center.Y - arrow_height / 2.0f + 0.5f;
+ arrow_path [1].X = arrow_center.X;
+ arrow_path [1].Y = arrow_center.Y + arrow_height / 2.0f + 0.5f;
+ arrow_path [2].X = arrow_center.X - arrow_width;
+ arrow_path [2].Y = arrow_center.Y + 0.5f;
}
else
{
is_clicked = mc.is_next_clicked;
+
button_rect = new Rectangle (
rectangle.Right - 1 - x_offset - button_size.Width,
rectangle.Y + 1 + ((title_size.Height - button_size.Height)/2),
Math.Max(button_size.Width - 1, 0),
Math.Max(button_size.Height - 1, 0));
- arrow_rect.X = button_rect.X + ((button_rect.Width - arrow_rect.Width)/2);
- arrow_rect.Y = button_rect.Y + ((button_rect.Height - arrow_rect.Height)/2);
+
+ arrow_center = new PointF (button_rect.X + ((button_rect.Width + arrow_width) / 2.0f),
+ rectangle.Y + ((button_rect.Height + arrow_height) / 2) + 1);
if (is_clicked) {
- arrow_rect.Offset(1,1);
+ arrow_center.X += 1;
+ arrow_center.Y += 1;
}
- arrow_path[0] = new Point (arrow_rect.X, arrow_rect.Y);
- arrow_path[1] = new Point (arrow_rect.Right, arrow_rect.Y + arrow_rect.Height/2);
- arrow_path[2] = new Point (arrow_rect.X, arrow_rect.Bottom);
+
+ arrow_path [0].X = arrow_center.X - arrow_width;
+ arrow_path [0].Y = arrow_center.Y - arrow_height / 2.0f + 0.5f;
+ arrow_path [1].X = arrow_center.X - arrow_width;
+ arrow_path [1].Y = arrow_center.Y + arrow_height / 2.0f + 0.5f;
+ arrow_path [2].X = arrow_center.X;
+ arrow_path [2].Y = arrow_center.Y + 0.5f;
}
// fill the background
}
// draw the arrow
dc.FillPolygon (SystemBrushes.ControlText, arrow_path);
+ //dc.FillPolygon (SystemBrushes.ControlText, arrow_path, FillMode.Winding);
}
public override void DrawPictureBox (Graphics dc, Rectangle clip, PictureBox pb) {
Rectangle client = pb.ClientRectangle;
- // FIXME - instead of drawing the whole picturebox every time
+#if NET_2_0
+ client = new Rectangle (client.Left + pb.Padding.Left, client.Top + pb.Padding.Top, client.Width - pb.Padding.Horizontal, client.Height - pb.Padding.Vertical);
+#endif
+
+ // FIXME - instead of drawing the whole picturebox every time
// intersect the clip rectangle with the drawn picture and only draw what's needed,
// Also, we only need a background fill where no image goes
if (pb.Image != null) {
switch (pb.SizeMode) {
case PictureBoxSizeMode.StretchImage:
- dc.DrawImage (pb.Image, 0, 0, client.Width, client.Height);
+ dc.DrawImage (pb.Image, client.Left, client.Top, client.Width, client.Height);
break;
case PictureBoxSizeMode.CenterImage:
#endif
default:
// Normal, AutoSize
- dc.DrawImage(pb.Image, 0, 0, pb.Image.Width, pb.Image.Height);
+ dc.DrawImage (pb.Image, client.Left, client.Top, pb.Image.Width, pb.Image.Height);
break;
}
case 1: { // Continuous
int pixels_to_draw;
pixels_to_draw = (int)(client_area.Width * ((double)(ctrl.Value - ctrl.Minimum) / (double)(Math.Max(ctrl.Maximum - ctrl.Minimum, 1))));
- dc.FillRectangle (ResPool.GetSolidBrush (progressbarblock_color), new Rectangle (client_area.X, client_area.Y, pixels_to_draw, client_area.Height));
+ dc.FillRectangle (ResPool.GetSolidBrush (ctrl.ForeColor), new Rectangle (client_area.X, client_area.Y, pixels_to_draw, client_area.Height));
break;
}
case 2: // Marquee
case 0:
default: // Blocks
Rectangle block_rect;
- int space_betweenblocks = 2;
+ int space_betweenblocks = ProgressBarChunkSpacing;
int block_width;
int increment;
int barpos_pixels;
int block_count = 0;
- block_width = (client_area.Height * 2) / 3;
- barpos_pixels = ((ctrl.Value - ctrl.Minimum) * client_area.Width) / (Math.Max(ctrl.Maximum - ctrl.Minimum, 1));
+ block_width = ProgressBarGetChunkSize (client_area.Height);
+ block_width = Math.Max (block_width, 0); // block_width is used to break out the loop below, it must be >= 0!
+ barpos_pixels = (int)(((double)(ctrl.Value - ctrl.Minimum) * client_area.Width) / (Math.Max (ctrl.Maximum - ctrl.Minimum, 1)));
increment = block_width + space_betweenblocks;
block_rect = new Rectangle (start_pixel, client_area.Y, block_width, client_area.Height);
}
if (clip_rect.IntersectsWith (block_rect) == true) {
- dc.FillRectangle (ResPool.GetSolidBrush (progressbarblock_color), block_rect);
+ dc.FillRectangle (ResPool.GetSolidBrush (ctrl.ForeColor), block_rect);
}
block_rect.X += increment;
}
}
+ public const int ProgressBarChunkSpacing = 2;
+
+ public static int ProgressBarGetChunkSize ()
+ {
+ return ProgressBarGetChunkSize (ProgressBarDefaultHeight);
+ }
+
+ static int ProgressBarGetChunkSize (int progressBarClientAreaHeight)
+ {
+ int size = (progressBarClientAreaHeight * 2) / 3;
+ return size;
+ }
+
+ const int ProgressBarDefaultHeight = 23;
+
public override Size ProgressBarDefaultSize {
get {
- return new Size (100, 23);
+ return new Size (100, ProgressBarDefaultHeight);
}
}
VerticalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63, 63, 63), Color.Black);
else
VerticalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorScrollBar, Color.White);
- Rectangle UpperTrack = new Rectangle (0, 0, bar.ClientRectangle.Width, bar.ThumbPos.Top);
+ Rectangle UpperTrack = new Rectangle (0, 0, bar.ClientRectangle.Width, bar.ThumbPos.Bottom);
if (clip.IntersectsWith (UpperTrack))
dc.FillRectangle (VerticalBrush, UpperTrack);
HorizontalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63, 63, 63), Color.Black);
else
HorizontalBrush = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorScrollBar, Color.White);
- Rectangle LeftTrack = new Rectangle (0, 0, bar.ThumbPos.Left, bar.ClientRectangle.Height);
+ Rectangle LeftTrack = new Rectangle (0, 0, bar.ThumbPos.Right, bar.ClientRectangle.Height);
if (clip.IntersectsWith (LeftTrack))
dc.FillRectangle (HorizontalBrush, LeftTrack);
public override int ScrollBarButtonSize {
get { return 16; }
}
+
+ public override bool ScrollBarHasHotElementStyles {
+ get {
+ return false;
+ }
+ }
+
+ public override bool ScrollBarHasPressedThumbStyle {
+ get {
+ return false;
+ }
+ }
+
+ public override bool ScrollBarHasHoverArrowButtonStyle {
+ get {
+ return false;
+ }
+ }
#endregion // ScrollBar
#region StatusBar
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 ();
-
- Brush brush = is_color_control ? SystemBrushes.Control : ResPool.GetSolidBrush (sb.BackColor);
- dc.FillRectangle (brush, clip);
+ DrawStatusBarBackground (dc, clip, sb);
if (!sb.ShowPanels && sb.Text != String.Empty) {
string text = sb.Text;
}
}
- if (sb.SizingGrip) {
- area = new Rectangle (area.Right - 16 - 2, area.Bottom - 12 - 1, 16, 16);
- CPDrawSizeGrip (dc, ColorControl, area);
- }
+ if (sb.SizingGrip)
+ DrawStatusBarSizingGrip (dc, clip, sb, area);
real_dc.DrawImage (backbuffer, 0, 0);
dc.Dispose ();
}
+ protected virtual void DrawStatusBarBackground (Graphics dc, Rectangle clip, StatusBar sb)
+ {
+ bool is_color_control = sb.BackColor.ToArgb () == ColorControl.ToArgb ();
+
+ Brush brush = is_color_control ? SystemBrushes.Control : ResPool.GetSolidBrush (sb.BackColor);
+ dc.FillRectangle (brush, clip);
+ }
+
+ protected virtual void DrawStatusBarSizingGrip (Graphics dc, Rectangle clip, StatusBar sb, Rectangle area)
+ {
+ area = new Rectangle (area.Right - 16 - 2, area.Bottom - 12 - 1, 16, 16);
+ CPDrawSizeGrip (dc, ColorControl, area);
+ }
protected virtual void DrawStatusBarPanel (Graphics dc, Rectangle area, int index,
Brush br_forecolor, StatusBarPanel panel) {
int icon_width = 16;
area.Height -= border_size;
-
- if (panel.BorderStyle != StatusBarPanelBorderStyle.None) {
- Border3DStyle border_style = Border3DStyle.SunkenOuter;
- if (panel.BorderStyle == StatusBarPanelBorderStyle.Raised)
- border_style = Border3DStyle.RaisedInner;
-
- CPDrawBorder3D(dc, area, border_style, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, panel.Parent.BackColor);
- }
-
+
+ DrawStatusBarPanelBackground (dc, area, panel);
+
if (panel.Style == StatusBarPanelStyle.OwnerDraw) {
StatusBarDrawItemEventArgs e = new StatusBarDrawItemEventArgs (
dc, panel.Parent.Font, area, index, DrawItemState.Default,
return;
}
- if (panel.Text == String.Empty)
- return;
-
string text = panel.Text;
StringFormat string_format = new StringFormat ();
string_format.Trimming = StringTrimming.Character;
string_format.FormatFlags = StringFormatFlags.NoWrap;
- if (text [0] == '\t') {
+ if (text != null && text.Length > 0 && text [0] == '\t') {
string_format.Alignment = StringAlignment.Center;
text = text.Substring (1);
if (text [0] == '\t') {
break;
case HorizontalAlignment.Center:
len = (int) dc.MeasureString (text, panel.Parent.Font).Width;
- x = (panel.Width / 2) + (len / 2);
+ x = area.Left + ((panel.Width - len) / 2);
+
string_rect = new Rectangle (x, y,
area.Right - x - border_size,
area.Bottom - y - border_size);
}
}
+ protected virtual void DrawStatusBarPanelBackground (Graphics dc, Rectangle area, StatusBarPanel panel)
+ {
+ if (panel.BorderStyle != StatusBarPanelBorderStyle.None) {
+ Border3DStyle border_style = Border3DStyle.SunkenOuter;
+ if (panel.BorderStyle == StatusBarPanelBorderStyle.Raised)
+ border_style = Border3DStyle.RaisedInner;
+
+ CPDrawBorder3D(dc, area, border_style, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, panel.Parent.BackColor);
+ }
+ }
+
public override int StatusBarSizeGripWidth {
get { return 15; }
}
ThemeElements.CurrentTheme.TabControlPainter.Draw (dc, area, tab);
}
- public override Rectangle TabControlGetLeftScrollRect (TabControl tab)
+ public override Rectangle TabControlGetDisplayRectangle (TabControl tab)
{
- return ThemeElements.CurrentTheme.TabControlPainter.GetLeftScrollRect (tab);
+ return ThemeElements.CurrentTheme.TabControlPainter.GetDisplayRectangle (tab);
}
- public override Rectangle TabControlGetRightScrollRect (TabControl tab)
+ public override Rectangle TabControlGetPanelRect (TabControl tab)
{
- return ThemeElements.CurrentTheme.TabControlPainter.GetRightScrollRect (tab);
+ return ThemeElements.CurrentTheme.TabControlPainter.GetTabPanelRect (tab);
}
- public override Rectangle TabControlGetDisplayRectangle (TabControl tab)
+ #endregion
+
+ #region TextBox
+ public override void TextBoxBaseFillBackground (TextBoxBase textBoxBase, Graphics g, Rectangle clippingArea)
{
- return ThemeElements.CurrentTheme.TabControlPainter.GetDisplayRectangle (tab);
+ if (textBoxBase.backcolor_set || (textBoxBase.Enabled && !textBoxBase.read_only)) {
+ g.FillRectangle(ResPool.GetSolidBrush(textBoxBase.BackColor), clippingArea);
+ } else {
+ g.FillRectangle(ResPool.GetSolidBrush(ColorControl), clippingArea);
+ }
}
- public override Rectangle TabControlGetPanelRect (TabControl tab)
+ public override bool TextBoxBaseHandleWmNcPaint (TextBoxBase textBoxBase, ref Message m)
{
- return ThemeElements.CurrentTheme.TabControlPainter.GetTabPanelRect (tab);
+ return false;
}
+ public override bool TextBoxBaseShouldPaintBackground (TextBoxBase textBoxBase)
+ {
+ return true;
+ }
#endregion
#region ToolBar
}
}
+ public override bool ToolBarHasHotElementStyles (ToolBar toolBar)
+ {
+ return toolBar.Appearance == ToolBarAppearance.Flat;
+ }
+
+ public override bool ToolBarHasHotCheckedElementStyles {
+ get {
+ return false;
+ }
+ }
#endregion // ToolBar
#region ToolTip
public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control)
{
- Rectangle text_rect = Rectangle.Inflate (control.ClientRectangle, -2, -1);
+ ToolTipDrawBackground (dc, clip_rectangle, control);
+ TextFormatFlags flags = TextFormatFlags.HidePrefix;
#if NET_2_0
- Brush back_brush = ResPool.GetSolidBrush (control.BackColor);;
Color foreground = control.ForeColor;
+ if (control.title.Length > 0) {
+ Font bold_font = new Font (control.Font, control.Font.Style | FontStyle.Bold);
+ TextRenderer.DrawTextInternal (dc, control.title, bold_font, control.title_rect,
+ foreground, flags, false);
+ bold_font.Dispose ();
+ }
+
+ if (control.icon != null)
+ dc.DrawIcon (control.icon, control.icon_rect);
#else
- Brush back_brush = SystemBrushes.Info;
Color foreground = this.ColorInfoText;
#endif
+ TextRenderer.DrawTextInternal (dc, control.Text, control.Font, control.text_rect, foreground, flags, false);
+ }
+
+ protected virtual void ToolTipDrawBackground (Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control)
+ {
+#if NET_2_0
+ Brush back_brush = ResPool.GetSolidBrush (control.BackColor);;
+#else
+ Brush back_brush = SystemBrushes.Info;
+#endif
dc.FillRectangle (back_brush, control.ClientRectangle);
dc.DrawRectangle (SystemPens.WindowFrame, 0, 0, control.Width - 1, control.Height - 1);
-
- TextFormatFlags flags = TextFormatFlags.HidePrefix | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter;
- TextRenderer.DrawTextInternal (dc, control.Text, control.Font, text_rect, foreground, flags, false);
}
public override Size ToolTipSize(ToolTip.ToolTipWindow tt, string text)
{
Size size = TextRenderer.MeasureTextInternal (text, tt.Font, false);
-
size.Width += 4;
size.Height += 3;
-
+ Rectangle text_rect = new Rectangle (Point.Empty, size);
+ text_rect.Inflate (-2, -1);
+ tt.text_rect = text_rect;
+#if NET_2_0
+ tt.icon_rect = tt.title_rect = Rectangle.Empty;
+
+ Size title_size = Size.Empty;
+ if (tt.title.Length > 0) {
+ Font bold_font = new Font (tt.Font, tt.Font.Style | FontStyle.Bold);
+ title_size = TextRenderer.MeasureTextInternal (tt.title, bold_font, false);
+ bold_font.Dispose ();
+ }
+
+ Size icon_size = Size.Empty;
+ if (tt.icon != null)
+ icon_size = new Size (size.Height, size.Height);
+
+ if (icon_size != Size.Empty || title_size != Size.Empty) {
+ int padding = 8;
+ int top_area_width = 0;
+ int top_area_height = icon_size.Height > title_size.Height ? icon_size.Height : title_size.Height;
+ Size text_size = size;
+ Point location = new Point (padding, padding);
+
+ if (icon_size != Size.Empty) {
+ tt.icon_rect = new Rectangle (location, icon_size);
+ top_area_width = icon_size.Width + padding;
+ }
+
+ if (title_size != Size.Empty) {
+ Rectangle title_rect = new Rectangle (location, new Size (title_size.Width, top_area_height));
+ if (icon_size != Size.Empty)
+ title_rect.X += icon_size.Width + padding;
+
+ tt.title_rect = title_rect;
+ top_area_width += title_size.Width;
+ }
+
+ tt.text_rect = new Rectangle (new Point (location.X, location.Y + top_area_height + padding),
+ text_size);
+
+ size.Height += padding + top_area_height;
+ if (top_area_width > size.Width)
+ size.Width = top_area_width;
+
+ // margins
+ size.Width += padding * 2;
+ size.Height += padding * 2;
+ }
+#endif
+
return size;
}
+
+ public override bool ToolTipTransparentBackground {
+ get {
+ return false;
+ }
+ }
#endregion // ToolTip
#region BalloonWindow
balloon_window.Show ();
}
+ public override void HideBalloonWindow (IntPtr handle)
+ {
+ if (balloon_window == null || balloon_window.OwnerHandle != handle)
+ return;
+
+ balloon_window.Close ();
+ balloon_window.Dispose ();
+ balloon_window = null;
+ }
+
private const int balloon_iconsize = 16;
private const int balloon_bordersize = 8;
thumb_area.X = area.X + channel_startpoint.X;
thumb_area.Y = area.Y + channel_startpoint.Y;
thumb_area.Height = area.Height - space_from_right - space_from_left;
- thumb_area.Width = 4;
+ thumb_area.Width = TrackBarVerticalTrackWidth;
pixel_len = thumb_area.Height - 11;
if (tb.Maximum == tb.Minimum) {
}
thumb_pos.Y = thumb_area.Bottom - space_from_bottom - (int)(pixels_betweenticks * (float)(tb.Value - tb.Minimum));
-
- /* Draw thumb fixed 10x22 size */
- thumb_pos.Width = 10;
- thumb_pos.Height = 22;
} else {
toptick_startpoint = new Point ();
bottomtick_startpoint = new Point ();
thumb_area.X = area.X + channel_startpoint.X;
thumb_area.Y = area.Y + channel_startpoint.Y;
thumb_area.Width = area.Width - space_from_right - space_from_left;
- thumb_area.Height = 4;
+ thumb_area.Height = TrackBarHorizontalTrackHeight;
pixel_len = thumb_area.Width - 11;
if (tb.Maximum == tb.Minimum) {
}
thumb_pos.X = channel_startpoint.X + (int)(pixels_betweenticks * (float) (tb.Value - tb.Minimum));
+ }
+
+ thumb_pos.Size = TrackBarGetThumbSize (tb);
+ }
+
+ protected virtual Size TrackBarGetThumbSize (TrackBar trackBar)
+ {
+ return TrackBarGetThumbSize ();
+ }
+
+ public static Size TrackBarGetThumbSize ()
+ {
+ /* Draw thumb fixed 10x22 size */
+ return new Size (10, 22);
+ }
+
+ public const int TrackBarVerticalTrackWidth = 4;
+
+ public const int TrackBarHorizontalTrackHeight = 4;
+
+ #region Ticks
+ protected interface ITrackBarTickPainter
+ {
+ void Paint (float x1, float y1, float x2, float y2);
+ }
- /* Draw thumb fixed 10x22 size */
- thumb_pos.Width = 10;
- thumb_pos.Height = 22;
+ class TrackBarTickPainter : ITrackBarTickPainter
+ {
+ readonly Graphics g;
+ readonly Pen pen;
+ public TrackBarTickPainter (Graphics g, Pen pen)
+ {
+ this.g = g;
+ this.pen = pen;
+ }
+ public void Paint (float x1, float y1, float x2, float y2)
+ {
+ g.DrawLine (pen, x1, y1, x2, y2);
}
}
-
+ protected virtual ITrackBarTickPainter GetTrackBarTickPainter (Graphics g)
+ {
+ return new TrackBarTickPainter (g, ResPool.GetPen (pen_ticks_color));
+ }
+ #endregion
+
+ #region DrawTrackBar_Vertical
private void DrawTrackBar_Vertical (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
float ticks, int value_pos, bool mouse_value) {
GetTrackBarDrawingInfo (tb, out pixels_betweenticks, out thumb_area, out thumb_pos, out channel_startpoint, out bottomtick_startpoint, out toptick_startpoint);
- /* Draw channel */
- dc.FillRectangle (SystemBrushes.ControlDark, channel_startpoint.X, channel_startpoint.Y,
- 1, thumb_area.Height);
-
- dc.FillRectangle (SystemBrushes.ControlDarkDark, channel_startpoint.X + 1, channel_startpoint.Y,
- 1, thumb_area.Height);
-
- dc.FillRectangle (SystemBrushes.ControlLight, channel_startpoint.X + 3, channel_startpoint.Y,
- 1, thumb_area.Height);
+ #region Track
+ TrackBarDrawVerticalTrack (dc, thumb_area, channel_startpoint, clip_rectangle);
+ #endregion
+ #region Thumb
switch (tb.TickStyle) {
case TickStyle.BottomRight:
- case TickStyle.None: {
+ case TickStyle.None:
thumb_pos.X = channel_startpoint.X - 8;
-
- Pen pen = SystemPens.ControlLightLight;
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X , thumb_pos.Y + 10);
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 16, thumb_pos.Y);
- dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y, thumb_pos.X + 16 + 4, thumb_pos.Y + 4);
-
- pen = SystemPens.ControlDark;
- dc.DrawLine (pen, thumb_pos.X +1, thumb_pos.Y + 9, thumb_pos.X +15, thumb_pos.Y +9);
- dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y + 9, thumb_pos.X +16 + 4, thumb_pos.Y +9 - 4);
-
- pen = SystemPens.ControlDarkDark;
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X +16, thumb_pos.Y +10);
- dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y + 10, thumb_pos.X +16 + 5, thumb_pos.Y +10 - 5);
-
- dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 16, 8);
- dc.FillRectangle (br_thumb, thumb_pos.X + 17, thumb_pos.Y + 2, 1, 6);
- dc.FillRectangle (br_thumb, thumb_pos.X + 18, thumb_pos.Y + 3, 1, 4);
- dc.FillRectangle (br_thumb, thumb_pos.X + 19, thumb_pos.Y + 4, 1, 2);
-
+ TrackBarDrawVerticalThumbRight (dc, thumb_pos, br_thumb, clip_rectangle, tb);
break;
- }
- case TickStyle.TopLeft: {
+ case TickStyle.TopLeft:
thumb_pos.X = channel_startpoint.X - 10;
-
- Pen pen = SystemPens.ControlLightLight;
- dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X + 4 + 16, thumb_pos.Y);
- dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 4);
-
- pen = SystemPens.ControlDark;
- dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X + 4 + 16 , thumb_pos.Y+ 9);
- dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X, thumb_pos.Y + 5);
- dc.DrawLine (pen, thumb_pos.X + 19, thumb_pos.Y + 9, thumb_pos.X +19 , thumb_pos.Y+ 1);
-
- pen = SystemPens.ControlDarkDark;
- dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y+ 10, thumb_pos.X + 4 + 16, thumb_pos.Y+ 10);
- dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 10, thumb_pos.X -1, thumb_pos.Y+ 5);
- dc.DrawLine (pen, thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X+ 20, thumb_pos.Y + 10);
-
- dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 15, 8);
- dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 1, 6);
- dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 1, 4);
- dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 1, 2);
-
- break;
- }
-
- case TickStyle.Both: {
- thumb_pos.X = area.X + 10;
-
- Pen pen = SystemPens.ControlLightLight;
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 9);
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 19, thumb_pos.Y);
-
- pen = SystemPens.ControlDark;
- dc.DrawLine (pen, thumb_pos.X + 1, thumb_pos.Y + 9, thumb_pos.X+ 19, thumb_pos.Y + 9);
- dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y+ 1, thumb_pos.X + 19, thumb_pos.Y + 8);
-
- pen = SystemPens.ControlDarkDark;
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X+ 20, thumb_pos.Y +10);
- dc.DrawLine (pen, thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X + 20, thumb_pos.Y+ 9);
-
- dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 18, 8);
-
+ TrackBarDrawVerticalThumbLeft (dc, thumb_pos, br_thumb, clip_rectangle, tb);
break;
- }
-
default:
+ thumb_pos.X = area.X + 10;
+ TrackBarDrawVerticalThumb (dc, thumb_pos, br_thumb, clip_rectangle, tb);
break;
}
+ #endregion
pixel_len = thumb_area.Height - 11;
pixels_betweenticks = pixel_len / ticks;
thumb_area.X = thumb_pos.X;
thumb_area.Y = channel_startpoint.Y;
thumb_area.Width = thumb_pos.Height;
-
- /* Draw ticks*/
+
+ #region Ticks
+ if (pixels_betweenticks <= 0)
+ return;
+ if (tb.TickStyle == TickStyle.None)
+ return;
Region outside = new Region (area);
outside.Exclude (thumb_area);
- if (outside.IsVisible (clip_rectangle)) {
- if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
- ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-
- for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
- if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
- area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc);
- else
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
- area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc);
+ if (outside.IsVisible (clip_rectangle)) {
+ ITrackBarTickPainter tick_painter = TrackBarGetVerticalTickPainter (dc);
+
+ if ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight) {
+ float x = area.X + bottomtick_startpoint.X;
+ for (float inc = 0; inc < pixel_len + 1; inc += pixels_betweenticks) {
+ float y = area.Y + bottomtick_startpoint.Y + inc;
+ tick_painter.Paint (
+ x, y,
+ x + (inc == 0 || inc + pixels_betweenticks >= pixel_len + 1 ? 3 : 2), y);
}
}
-
- if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
- ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-
- pixel_len = thumb_area.Height - 11;
- pixels_betweenticks = pixel_len / ticks;
-
+
+ if ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft) {
+ float x = area.X + toptick_startpoint.X;
for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
- if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
- area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
- else
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
- area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
+ float y = area.Y + toptick_startpoint.Y + inc;
+ tick_painter.Paint (
+ x - (inc == 0 || inc + pixels_betweenticks >= pixel_len + 1 ? 3 : 2), y,
+ x, y);
}
}
}
outside.Dispose ();
-
+ #endregion
+ }
+
+ #region Track
+ protected virtual void TrackBarDrawVerticalTrack (Graphics dc, Rectangle thumb_area, Point channel_startpoint, Rectangle clippingArea)
+ {
+ dc.FillRectangle (SystemBrushes.ControlDark, channel_startpoint.X, channel_startpoint.Y,
+ 1, thumb_area.Height);
+
+ dc.FillRectangle (SystemBrushes.ControlDarkDark, channel_startpoint.X + 1, channel_startpoint.Y,
+ 1, thumb_area.Height);
+
+ dc.FillRectangle (SystemBrushes.ControlLight, channel_startpoint.X + 3, channel_startpoint.Y,
+ 1, thumb_area.Height);
+ }
+ #endregion
+
+ #region Thumb
+ protected virtual void TrackBarDrawVerticalThumbRight (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
+ {
+ Pen pen = SystemPens.ControlLightLight;
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 10);
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 16, thumb_pos.Y);
+ dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y, thumb_pos.X + 16 + 4, thumb_pos.Y + 4);
+
+ pen = SystemPens.ControlDark;
+ dc.DrawLine (pen, thumb_pos.X + 1, thumb_pos.Y + 9, thumb_pos.X + 15, thumb_pos.Y + 9);
+ dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y + 9, thumb_pos.X + 16 + 4, thumb_pos.Y + 9 - 4);
+
+ pen = SystemPens.ControlDarkDark;
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X + 16, thumb_pos.Y + 10);
+ dc.DrawLine (pen, thumb_pos.X + 16, thumb_pos.Y + 10, thumb_pos.X + 16 + 5, thumb_pos.Y + 10 - 5);
+
+ dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 16, 8);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 17, thumb_pos.Y + 2, 1, 6);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 18, thumb_pos.Y + 3, 1, 4);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 19, thumb_pos.Y + 4, 1, 2);
+ }
+
+ protected virtual void TrackBarDrawVerticalThumbLeft (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
+ {
+ Pen pen = SystemPens.ControlLightLight;
+ dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X + 4 + 16, thumb_pos.Y);
+ dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 4);
+
+ pen = SystemPens.ControlDark;
+ dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X + 4 + 16, thumb_pos.Y + 9);
+ dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 9, thumb_pos.X, thumb_pos.Y + 5);
+ dc.DrawLine (pen, thumb_pos.X + 19, thumb_pos.Y + 9, thumb_pos.X + 19, thumb_pos.Y + 1);
+
+ pen = SystemPens.ControlDarkDark;
+ dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 10, thumb_pos.X + 4 + 16, thumb_pos.Y + 10);
+ dc.DrawLine (pen, thumb_pos.X + 4, thumb_pos.Y + 10, thumb_pos.X - 1, thumb_pos.Y + 5);
+ dc.DrawLine (pen, thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X + 20, thumb_pos.Y + 10);
+
+ dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 15, 8);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 1, 6);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 1, 4);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 1, 2);
}
+ protected virtual void TrackBarDrawVerticalThumb (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
+ {
+ Pen pen = SystemPens.ControlLightLight;
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 9);
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 19, thumb_pos.Y);
+
+ pen = SystemPens.ControlDark;
+ dc.DrawLine (pen, thumb_pos.X + 1, thumb_pos.Y + 9, thumb_pos.X + 19, thumb_pos.Y + 9);
+ dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 1, thumb_pos.X + 19, thumb_pos.Y + 8);
+
+ pen = SystemPens.ControlDarkDark;
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 10, thumb_pos.X + 20, thumb_pos.Y + 10);
+ dc.DrawLine (pen, thumb_pos.X + 20, thumb_pos.Y, thumb_pos.X + 20, thumb_pos.Y + 9);
+
+ dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 18, 8);
+ }
+ #endregion
+
+ #region Ticks
+ protected virtual ITrackBarTickPainter TrackBarGetVerticalTickPainter (Graphics g)
+ {
+ return GetTrackBarTickPainter (g);
+ }
+ #endregion
+ #endregion
+
+ #region DrawTrackBar_Horizontal
/*
Horizontal trackbar
Rectangle area = tb.ClientRectangle;
GetTrackBarDrawingInfo (tb , out pixels_betweenticks, out thumb_area, out thumb_pos, out channel_startpoint, out bottomtick_startpoint, out toptick_startpoint);
-
- /* Draw channel */
- dc.FillRectangle (SystemBrushes.ControlDark, channel_startpoint.X, channel_startpoint.Y,
- thumb_area.Width, 1);
-
- dc.FillRectangle (SystemBrushes.ControlDarkDark, channel_startpoint.X, channel_startpoint.Y + 1,
- thumb_area.Width, 1);
- dc.FillRectangle (SystemBrushes.ControlLight, channel_startpoint.X, channel_startpoint.Y +3,
- thumb_area.Width, 1);
+ #region Track
+ TrackBarDrawHorizontalTrack (dc, thumb_area, channel_startpoint, clip_rectangle);
+ #endregion
+ #region Thumb
switch (tb.TickStyle) {
case TickStyle.BottomRight:
- case TickStyle.None: {
+ case TickStyle.None:
thumb_pos.Y = channel_startpoint.Y - 8;
-
- Pen pen = SystemPens.ControlLightLight;
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y);
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 16);
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 16, thumb_pos.X + 4, thumb_pos.Y + 16 + 4);
-
- pen = SystemPens.ControlDark;
- dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X +9, thumb_pos.Y +15);
- dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 16, thumb_pos.X +9 - 4, thumb_pos.Y +16 + 4);
-
- pen = SystemPens.ControlDarkDark;
- dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y +16);
- dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 16, thumb_pos.X +10 - 5, thumb_pos.Y +16 + 5);
-
- dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 16);
- dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 17, 6, 1);
- dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 18, 4, 1);
- dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 19, 2, 1);
+ TrackBarDrawHorizontalThumbBottom (dc, thumb_pos, br_thumb, clip_rectangle, tb);
break;
- }
- case TickStyle.TopLeft: {
+ case TickStyle.TopLeft:
thumb_pos.Y = channel_startpoint.Y - 10;
-
- Pen pen = SystemPens.ControlLightLight;
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X, thumb_pos.Y + 4 + 16);
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X + 4, thumb_pos.Y);
-
- pen = SystemPens.ControlDark;
- dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 9, thumb_pos.Y + 4 + 16);
- dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y);
- dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 19, thumb_pos.X + 1 , thumb_pos.Y +19);
-
- pen = SystemPens.ControlDarkDark;
- dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 10, thumb_pos.Y + 4 + 16);
- dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y -1);
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 10, thumb_pos.Y + 20);
-
- dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 8, 15);
- dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 6, 1);
- dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 4, 1);
- dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 2, 1);
+ TrackBarDrawHorizontalThumbTop (dc, thumb_pos, br_thumb, clip_rectangle, tb);
break;
- }
-
- case TickStyle.Both: {
- thumb_pos.Y = area.Y + 10;
-
- Pen pen = SystemPens.ControlLightLight;
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 9, thumb_pos.Y);
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 19);
-
- pen = SystemPens.ControlDark;
- dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 19);
- dc.DrawLine (pen, thumb_pos.X + 1, thumb_pos.Y + 10, thumb_pos.X + 8, thumb_pos.Y + 19);
-
- pen = SystemPens.ControlDarkDark;
- dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X +10, thumb_pos.Y + 20);
- dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 9, thumb_pos.Y + 20);
-
- dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 18);
-
- break;
- }
-
default:
+ thumb_pos.Y = area.Y + 10;
+ TrackBarDrawHorizontalThumb (dc, thumb_pos, br_thumb, clip_rectangle, tb);
break;
}
+ #endregion
pixel_len = thumb_area.Width - 11;
pixels_betweenticks = pixel_len / ticks;
- /* Draw ticks*/
thumb_area.Y = thumb_pos.Y;
thumb_area.X = channel_startpoint.X;
thumb_area.Height = thumb_pos.Height;
+ #region Ticks
+ if (pixels_betweenticks <= 0)
+ return;
+ if (tb.TickStyle == TickStyle.None)
+ return;
Region outside = new Region (area);
- outside.Exclude (thumb_area);
-
- if (outside.IsVisible (clip_rectangle)) {
- if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
- ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-
- for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
- if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
- area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3);
- else
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
- area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2);
+ outside.Exclude (thumb_area);
+
+ if (outside.IsVisible (clip_rectangle)) {
+ ITrackBarTickPainter tick_painter = TrackBarGetHorizontalTickPainter (dc);
+
+ if ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight) {
+ float y = area.Y + bottomtick_startpoint.Y;
+ for (float inc = 0; inc < pixel_len + 1; inc += pixels_betweenticks) {
+ float x = area.X + bottomtick_startpoint.X + inc;
+ tick_painter.Paint (
+ x, y,
+ x, y + (inc == 0 || inc + pixels_betweenticks >= pixel_len + 1 ? 3 : 2));
}
}
-
- if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
- ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-
- for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
- if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
- area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y);
- else
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
- area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
+
+ if ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft) {
+ float y = area.Y + toptick_startpoint.Y;
+ for (float inc = 0; inc < pixel_len + 1; inc += pixels_betweenticks) {
+ float x = area.X + toptick_startpoint.X + inc;
+ tick_painter.Paint (
+ x, y - (inc == 0 || (inc + pixels_betweenticks) >= pixel_len + 1 ? 3 : 2),
+ x, y);
}
}
}
- outside.Dispose ();
+ outside.Dispose ();
+ #endregion
+ }
+
+ #region Track
+ protected virtual void TrackBarDrawHorizontalTrack (Graphics dc, Rectangle thumb_area, Point channel_startpoint, Rectangle clippingArea)
+ {
+ dc.FillRectangle (SystemBrushes.ControlDark, channel_startpoint.X, channel_startpoint.Y,
+ thumb_area.Width, 1);
+
+ dc.FillRectangle (SystemBrushes.ControlDarkDark, channel_startpoint.X, channel_startpoint.Y + 1,
+ thumb_area.Width, 1);
+
+ dc.FillRectangle (SystemBrushes.ControlLight, channel_startpoint.X, channel_startpoint.Y + 3,
+ thumb_area.Width, 1);
}
+ #endregion
+
+ #region Thumb
+ protected virtual void TrackBarDrawHorizontalThumbBottom (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
+ {
+ Pen pen = SystemPens.ControlLightLight;
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y);
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 16);
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 16, thumb_pos.X + 4, thumb_pos.Y + 16 + 4);
+
+ pen = SystemPens.ControlDark;
+ dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 15);
+ dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 16, thumb_pos.X + 9 - 4, thumb_pos.Y + 16 + 4);
+
+ pen = SystemPens.ControlDarkDark;
+ dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y + 16);
+ dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 16, thumb_pos.X + 10 - 5, thumb_pos.Y + 16 + 5);
+
+ dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 16);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 17, 6, 1);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 18, 4, 1);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 19, 2, 1);
+ }
+
+ protected virtual void TrackBarDrawHorizontalThumbTop (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
+ {
+ Pen pen = SystemPens.ControlLightLight;
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X, thumb_pos.Y + 4 + 16);
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 4, thumb_pos.X + 4, thumb_pos.Y);
+
+ pen = SystemPens.ControlDark;
+ dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 9, thumb_pos.Y + 4 + 16);
+ dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y);
+ dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 19, thumb_pos.X + 1, thumb_pos.Y + 19);
+
+ pen = SystemPens.ControlDarkDark;
+ dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 10, thumb_pos.Y + 4 + 16);
+ dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y + 4, thumb_pos.X + 5, thumb_pos.Y - 1);
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 10, thumb_pos.Y + 20);
+
+ dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 4, 8, 15);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 2, thumb_pos.Y + 3, 6, 1);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 3, thumb_pos.Y + 2, 4, 1);
+ dc.FillRectangle (br_thumb, thumb_pos.X + 4, thumb_pos.Y + 1, 2, 1);
+ }
+
+ protected virtual void TrackBarDrawHorizontalThumb (Graphics dc, Rectangle thumb_pos, Brush br_thumb, Rectangle clippingArea, TrackBar trackBar)
+ {
+ Pen pen = SystemPens.ControlLightLight;
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X + 9, thumb_pos.Y);
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y, thumb_pos.X, thumb_pos.Y + 19);
+
+ pen = SystemPens.ControlDark;
+ dc.DrawLine (pen, thumb_pos.X + 9, thumb_pos.Y + 1, thumb_pos.X + 9, thumb_pos.Y + 19);
+ dc.DrawLine (pen, thumb_pos.X + 1, thumb_pos.Y + 10, thumb_pos.X + 8, thumb_pos.Y + 19);
+
+ pen = SystemPens.ControlDarkDark;
+ dc.DrawLine (pen, thumb_pos.X + 10, thumb_pos.Y, thumb_pos.X + 10, thumb_pos.Y + 20);
+ dc.DrawLine (pen, thumb_pos.X, thumb_pos.Y + 20, thumb_pos.X + 9, thumb_pos.Y + 20);
+
+ dc.FillRectangle (br_thumb, thumb_pos.X + 1, thumb_pos.Y + 1, 8, 18);
+ }
+ #endregion
+
+ #region Ticks
+ protected virtual ITrackBarTickPainter TrackBarGetHorizontalTickPainter (Graphics g)
+ {
+ return GetTrackBarTickPainter (g);
+ }
+ #endregion
+ #endregion
public override void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb)
{
}
}
+ public override bool TrackBarHasHotThumbStyle {
+ get {
+ return false;
+ }
+ }
#endregion // TrackBar
+ #region UpDownBase
+ public override void UpDownBaseDrawButton (Graphics g, Rectangle bounds, bool top, VisualStyles.PushButtonState state)
+ {
+ ControlPaint.DrawScrollButton (g, bounds, top ? ScrollButton.Up : ScrollButton.Down, state == VisualStyles.PushButtonState.Pressed ? ButtonState.Pushed : ButtonState.Normal);
+ }
+
+ public override bool UpDownBaseHasHotButtonStyle {
+ get {
+ return false;
+ }
+ }
+ #endregion
+
#region VScrollBar
public override Size VScrollBarDefaultSize {
get {
}
}
+ public override void TreeViewDrawNodePlusMinus (TreeView treeView, TreeNode node, Graphics dc, int x, int middle)
+ {
+ int height = treeView.ActualItemHeight - 2;
+ dc.FillRectangle (ResPool.GetSolidBrush (treeView.BackColor), (x + 4) - (height / 2), node.GetY() + 1, height, height);
+
+ dc.DrawRectangle (SystemPens.ControlDarkDark, x, middle - 4, 8, 8);
+
+ if (node.IsExpanded) {
+ dc.DrawLine (SystemPens.ControlDarkDark, x + 2, middle, x + 6, middle);
+ } else {
+ dc.DrawLine (SystemPens.ControlDarkDark, x + 2, middle, x + 6, middle);
+ dc.DrawLine (SystemPens.ControlDarkDark, x + 4, middle - 2, x + 4, middle + 2);
+ }
+ }
#endregion
+ #region Managed window
public override int ManagedWindowTitleBarHeight (InternalWindowManager wm)
{
if (wm.IsToolWindow && !wm.IsMinimized)
public override int ManagedWindowBorderWidth (InternalWindowManager wm)
{
- if (wm is ToolWindowManager && wm.form.FormBorderStyle == FormBorderStyle.FixedToolWindow)
+ if ((wm.IsToolWindow && wm.form.FormBorderStyle == FormBorderStyle.FixedToolWindow) ||
+ wm.IsMinimized)
return 3;
else
return 4;
break;
}
+ // Respect MinimizeBox/MaximizeBox
+ if (form.MinimizeBox == false && form.MaximizeBox == false) {
+ buttons.MinimizeButton.Visible = false;
+ buttons.MaximizeButton.Visible = false;
+ } else if (form.MinimizeBox == false)
+ buttons.MinimizeButton.State = ButtonState.Inactive;
+ else if (form.MaximizeBox == false)
+ buttons.MaximizeButton.State = ButtonState.Inactive;
+
int bw = ManagedWindowBorderWidth (wm);
Size btsize = ManagedWindowButtonSize (wm);
int btw = btsize.Width;
int bth = btsize.Height;
int top = bw + 2;
- int left = form.Width - bw - btw - 2;
+ int left = form.Width - bw - btw - ManagedWindowSpacingAfterLastTitleButton;
if ((!wm.IsToolWindow || wm.IsMinimized) && wm.HasBorders) {
buttons.CloseButton.Rectangle = new Rectangle (left, top, btw, bth);
}
}
- public override void DrawManagedWindowDecorations (Graphics dc, Rectangle clip, InternalWindowManager wm)
+ protected virtual Rectangle ManagedWindowDrawTitleBarAndBorders (Graphics dc, Rectangle clip, InternalWindowManager wm)
{
Form form = wm.Form;
int tbheight = ManagedWindowTitleBarHeight (wm);
Color color = ThemeEngine.Current.ColorControlDark;
Color color2 = Color.FromArgb (255, 192, 192, 192);
-#if debug
- Console.WriteLine (DateTime.Now.ToLongTimeString () + " DrawManagedWindowDecorations");
- dc.FillRectangle (Brushes.Black, clip);
-#endif
-
- if (wm.HasBorders) {
- Pen pen = ResPool.GetPen (ColorControl);
- Rectangle borders = new Rectangle (0, 0, form.Width, form.Height);
- ControlPaint.DrawBorder3D (dc, borders, Border3DStyle.Raised);
- // The 3d border is only 2 pixels wide, so we draw the innermost pixels ourselves
- borders = new Rectangle (2, 2, form.Width - 5, form.Height - 5);
- for (int i = 2; i < bdwidth; i++) {
- dc.DrawRectangle (pen, borders);
- borders.Inflate (-1, -1);
- }
- }
+ Pen pen = ResPool.GetPen (ColorControl);
+ Rectangle borders = new Rectangle (0, 0, form.Width, form.Height);
+ ControlPaint.DrawBorder3D (dc, borders, Border3DStyle.Raised);
+ // The 3d border is only 2 pixels wide, so we draw the innermost pixels ourselves
+ borders = new Rectangle (2, 2, form.Width - 5, form.Height - 5);
+ for (int i = 2; i < bdwidth; i++) {
+ dc.DrawRectangle (pen, borders);
+ borders.Inflate (-1, -1);
+ }
bool draw_titlebar_enabled = false;
}
}
- // Draw the line just beneath the title bar
- dc.DrawLine (ResPool.GetPen (SystemColors.Control), bdwidth,
- tbheight + bdwidth - 1, form.Width - bdwidth - 1,
- tbheight + bdwidth - 1);
+ if (!wm.IsMinimized)
+ // Draw the line just beneath the title bar
+ dc.DrawLine (ResPool.GetPen (SystemColors.Control), bdwidth,
+ tbheight + bdwidth - 1, form.Width - bdwidth - 1,
+ tbheight + bdwidth - 1);
+ return tb;
+ }
- if (!wm.IsToolWindow) {
- tb.X += 18; // Room for the icon and the buttons
- tb.Width = (form.Width - 62) - tb.X;
+ public override void DrawManagedWindowDecorations (Graphics dc, Rectangle clip, InternalWindowManager wm)
+ {
+#if debug
+ Console.WriteLine (DateTime.Now.ToLongTimeString () + " DrawManagedWindowDecorations");
+ dc.FillRectangle (Brushes.Black, clip);
+#endif
+ Rectangle tb = ManagedWindowDrawTitleBarAndBorders (dc, clip, wm);
+
+ Form form = wm.Form;
+ if (wm.ShowIcon) {
+ Rectangle icon = ManagedWindowGetTitleBarIconArea (wm);
+ if (icon.IntersectsWith (clip))
+ dc.DrawIcon (form.Icon, icon);
+ const int SpacingBetweenIconAndCaption = 2;
+ tb.Width -= icon.Right + SpacingBetweenIconAndCaption - tb.X ;
+ tb.X = icon.Right + SpacingBetweenIconAndCaption;
}
+
+ foreach (TitleButton button in wm.TitleButtons.AllButtons) {
+ tb.Width -= Math.Max (0, tb.Right - DrawTitleButton (dc, button, clip, form));
+ }
+ const int SpacingBetweenCaptionAndLeftMostButton = 3;
+ tb.Width -= SpacingBetweenCaptionAndLeftMostButton;
string window_caption = form.Text;
window_caption = window_caption.Replace (Environment.NewLine, string.Empty);
ThemeEngine.Current.ResPool.GetSolidBrush (Color.White),
tb, format);
}
-
- if (wm.HasBorders) {
- bool draw_icon = false;
-#if NET_2_0
- draw_icon = !wm.IsToolWindow && form.Icon != null && form.ShowIcon;
-#else
- draw_icon = !wm.IsToolWindow && form.Icon != null;
-#endif
- if (draw_icon) {
- Rectangle icon = new Rectangle (bdwidth + 3,
- bdwidth + 2, wm.IconWidth, wm.IconWidth);
- if (icon.IntersectsWith (clip))
- dc.DrawIcon (form.Icon, icon);
- }
-
- foreach (TitleButton button in wm.TitleButtons.AllButtons) {
- DrawTitleButton (dc, button, clip);
- }
- }
}
public override Size ManagedWindowButtonSize (InternalWindowManager wm)
height - 5);
}
- private void DrawTitleButton (Graphics dc, TitleButton button, Rectangle clip)
+ private int DrawTitleButton (Graphics dc, TitleButton button, Rectangle clip, Form form)
{
if (!button.Visible) {
- return;
+ return int.MaxValue;
}
- if (!button.Rectangle.IntersectsWith (clip))
- return;
+ if (button.Rectangle.IntersectsWith (clip)) {
+ ManagedWindowDrawTitleButton (dc, button, clip, form);
+ }
+ return button.Rectangle.Left;
+ }
+ protected virtual void ManagedWindowDrawTitleButton (Graphics dc, TitleButton button, Rectangle clip, Form form)
+ {
dc.FillRectangle (SystemBrushes.Control, button.Rectangle);
ControlPaint.DrawCaptionButton (dc, button.Rectangle,
button.Caption, button.State);
}
+ public override Rectangle ManagedWindowGetTitleBarIconArea (InternalWindowManager wm)
+ {
+ int bw = ManagedWindowBorderWidth (wm);
+ return new Rectangle (bw + 3, bw + 2, wm.IconWidth, wm.IconWidth);
+ }
+
+ public override Size ManagedWindowGetMenuButtonSize (InternalWindowManager wm)
+ {
+ Size result = SystemInformation.MenuButtonSize;
+ result.Width -= 2;
+ result.Height -= 4;
+ return result;
+ }
+
+ public override bool ManagedWindowTitleButtonHasHotElementStyle (TitleButton button, Form form)
+ {
+ return false;
+ }
+
+ public override void ManagedWindowDrawMenuButton (Graphics dc, TitleButton button, Rectangle clip, InternalWindowManager wm)
+ {
+ dc.FillRectangle (SystemBrushes.Control, button.Rectangle);
+ ControlPaint.DrawCaptionButton (dc, button.Rectangle,
+ button.Caption, button.State);
+ }
+
+ public override void ManagedWindowOnSizeInitializedOrChanged (Form form)
+ {
+ }
+ #endregion
+
#region ControlPaint
public override void CPDrawBorder (Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
}
+ [MonoInternalNote ("Does not respect Mixed")]
+ public override void CPDrawMixedCheckBox (Graphics graphics, Rectangle rectangle, ButtonState state)
+ {
+ CPDrawCheckBox (graphics, rectangle, state);
+ }
+
public override void CPDrawRadioButton (Graphics dc, Rectangle rectangle, ButtonState state)
{
CPColor cpcolor = ResPool.GetCPColor (ColorControl);