// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Copyright (c) 2004-2005 Novell, Inc.
+// Copyright (c) 2004-2006 Novell, Inc.
//
// Authors:
// Jordi Mas i Hernandez, jordi@ximian.com
// Peter Bartok, pbartok@novell.com
// John BouAntoun, jba-mono@optusnet.com.au
-// Marek Safar, marek.safar@seznam.cz
+// Marek Safar, marek.safar@seznam.cz
+// Alexander Olk, alex.olk@googlemail.com
//
#region OwnerDraw Support
public override void DrawOwnerDrawBackground (DrawItemEventArgs e)
{
- if (e.State == DrawItemState.Selected) {
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
e.Graphics.FillRectangle (SystemBrushes.Highlight, e.Bounds);
return;
}
// set up the button rectangle
buttonRectangle = button.ClientRectangle;
- if (button.has_focus) {
+ if (button.has_focus || button.paint_as_acceptbutton) {
// shrink the rectangle for the normal button drawing inside the focus rectangle
borderRectangle = Rectangle.Inflate(buttonRectangle, -1, -1);
} else {
DrawFlatStyleButton (dc, borderRectangle, button);
} else {
CPDrawButton(dc, borderRectangle, button.ButtonState);
- if (button.has_focus) {
+ if (button.has_focus || button.paint_as_acceptbutton) {
dc.DrawRectangle(ResPool.GetPen(button.ForeColor), borderRectangle);
}
}
dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (button.ForeColor), text_rect, button.text_format);
} else {
if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
- dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorControl)), text_rect, button.text_format);
+ dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ColorGrayText), text_rect, button.text_format);
} else {
- CPDrawStringDisabled(dc, button.text, button.Font, ColorControlText, text_rect, button.text_format);
+ Rectangle rect_white = new Rectangle (text_rect.X + 1, text_rect.Y + 1, text_rect.Width, text_rect.Height);
+
+ dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ColorControlLightLight), rect_white, button.text_format);
+ dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ColorGrayText), text_rect, button.text_format);
}
}
}
} else {
// popup has a ButtonColorText forecolor, not a button.ForeCOlor
if (button.FlatStyle == FlatStyle.Popup) {
- rect_fore_color = this.ColorControlText;
+ rect_fore_color = ColorGrayText;
}
// fill then draw outer rect
bool draw_popup_checked = false;
if (button.FlatStyle == FlatStyle.Popup) {
- rect_fore_color = this.ColorControlText;
+ rect_fore_color = ColorGrayText;
// see if we should draw a disabled checked popup button
draw_popup_checked = ((checkbox != null && checkbox.Checked) ||
}
/* Place the text; to be compatible with Windows place it after the checkbox has been drawn */
+
+ // Windows seems to not wrap text in certain situations, this matches as close as I could get it
+ if ((float)(checkbox.Font.Height * 1.5f) > text_rectangle.Height) {
+ text_format.FormatFlags |= StringFormatFlags.NoWrap;
+ }
if (checkbox.Enabled) {
sb = ResPool.GetSolidBrush(checkbox.ForeColor);
dc.DrawString(checkbox.Text, checkbox.Font, sb, text_rectangle, text_format);
ControlPaint.DrawBorder(graphics, checkbox_rectangle, checkbox.ForeColor, ButtonBorderStyle.Solid);
} else {
// draw sunken effect
- CPDrawBorder3D (graphics, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.All, checkbox.BackColor);
+ CPDrawBorder3D (graphics, checkbox_rectangle, Border3DStyle.SunkenInner, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, checkbox.BackColor);
}
} else {
graphics.FillRectangle(ResPool.GetSolidBrush (ControlPaint.LightLight (checkbox.BackColor)), fill_rectangle);
/* Draw text*/
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
- back_color = ThemeEngine.Current.ColorHighlight;
- fore_color = ThemeEngine.Current.ColorHighlightText;
+ back_color = ColorHighlight;
+ fore_color = ColorHighlightText;
}
else {
back_color = e.BackColor;
fore_color = e.ForeColor;
}
- e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
+ e.Graphics.FillRectangle (ResPool.GetSolidBrush
(back_color), item_rect);
e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
- ThemeEngine.Current.ResPool.GetSolidBrush (fore_color),
+ ResPool.GetSolidBrush (fore_color),
item_rect, string_format);
if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
- ThemeEngine.Current.CPDrawFocusRectangle (e.Graphics, item_rect,
+ CPDrawFocusRectangle (e.Graphics, item_rect,
fore_color, back_color);
}
}
#region ComboBox
// Drawing
-
+ // TODO: get rid of that and use BorderStyle Fixed3D
public override void DrawComboBoxEditDecorations (Graphics dc, ComboBox ctrl, Rectangle cl)
{
dc.DrawLine (ResPool.GetPen (ColorControlDark), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top
dc.DrawLine (ResPool.GetPen (ColorControlLight), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
dc.DrawLine (ResPool.GetPen (ColorControlDark), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
dc.DrawLine (ResPool.GetPen (ColorControlDarkDark), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2);
- dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + cl.Width - 2, cl.Y, cl.X + cl.Width - 2, cl.Y + cl.Height); //right
- dc.DrawLine (ResPool.GetPen (ColorControlLight), cl.X + cl.Width - 1, cl.Y + 1 , cl.X + cl.Width - 1, cl.Y + cl.Height - 1);
+ dc.DrawLine (ResPool.GetPen (ColorControl), cl.X + cl.Width - 1, cl.Y, cl.X + cl.Width - 1, cl.Y + cl.Height); //right
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), cl.X + cl.Width - 2, cl.Y + 1 , cl.X + cl.Width - 2, cl.Y + cl.Height - 1);
}
// Sizing
DrawComboBoxEditDecorations (dc, ctrl, cl);
}
else {
- dc.DrawRectangle (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorWindowFrame),
+ dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame),
cl.X, cl.Y, cl.Width - 1, cl.Height - 1);
}
}
string_format.FormatFlags = StringFormatFlags.LineLimit;
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
- back_color = ThemeEngine.Current.ColorHighlight;
- fore_color = ThemeEngine.Current.ColorHighlightText;
+ back_color = ColorHighlight;
+ fore_color = ColorHighlightText;
}
else {
back_color = e.BackColor;
fore_color = e.ForeColor;
}
- e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (back_color), e.Bounds);
+ e.Graphics.FillRectangle (ResPool.GetSolidBrush (back_color), e.Bounds);
if (e.Index != -1) {
e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
- ThemeEngine.Current.ResPool.GetSolidBrush (fore_color),
+ ResPool.GetSolidBrush (fore_color),
text_draw, string_format);
}
if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
- ThemeEngine.Current.CPDrawFocusRectangle (e.Graphics, e.Bounds, fore_color, back_color);
+ CPDrawFocusRectangle (e.Graphics, e.Bounds, fore_color, back_color);
}
string_format.Dispose ();
modified_area);
g.DrawString (grid.CaptionText, grid.CaptionFont,
- ThemeEngine.Current.ResPool.GetSolidBrush (grid.CaptionForeColor),
+ ResPool.GetSolidBrush (grid.CaptionForeColor),
grid.grid_drawing.caption_area);
}
current_clip.Dispose ();
g.ResetClip ();
-
- // This fills with background colour the unused part in the row headers
- if (rect_columnhdr.X + rect_columnhdr.Height < grid.ClientRectangle.X + grid.ClientRectangle.Width) {
- Rectangle not_usedarea = columnshdrs_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 = columnshdrs_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;
+ g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
- g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
- not_usedarea);
- }
}
public override void DataGridPaintRowsHeaders (Graphics g, Rectangle clip, DataGrid grid)
Rectangle rowshdrs_area_complete = grid.grid_drawing.rowshdrs_area;
rowshdrs_area_complete.Height = grid.grid_drawing.rowshdrs_maxheight;
Rectangle rect_row = new Rectangle ();
- rect_row.X = grid.grid_drawing.rowshdrs_area.X;
- int last_y = 0;
+ rect_row.X = grid.grid_drawing.rowshdrs_area.X;
int rowcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
+ Rectangle not_usedarea = rowshdrs_area_complete;
if (rowcnt < grid.RowsCount) { // Paint one row more for partial rows
rowcnt++;
rect_row.Y = grid.grid_drawing.rowshdrs_area.Y + ((row - grid.FirstVisibleRow) * grid.RowHeight);
if (clip.IntersectsWith (rect_row)) {
- DataGridPaintRowHeader (g, rect_row, row, grid);
- last_y = rect_row.Y;
+ DataGridPaintRowHeader (g, rect_row, row, grid);
}
}
g.ResetClip ();
-
- // This fills with background colour the unused part in the row headers
- if (last_y > 0 && rect_row.Y + rect_row.Height < grid.grid_drawing.cells_area.Y + grid.grid_drawing.cells_area.Height) {
- Rectangle not_usedarea = clip;
- not_usedarea.Intersect (rowshdrs_area_complete);
-
- not_usedarea.Y = rect_row.Y + rect_row.Height;
- not_usedarea.Height = rowshdrs_area_complete.Y + rowshdrs_area_complete.Height - rect_row.Height - rect_row.Y;
- g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
- not_usedarea);
- }
-
-
+ not_usedarea.Height = grid.grid_drawing.rowshdrs_maxheight - grid.grid_drawing.rowshdrs_area.Height;
+ not_usedarea.Y = grid.grid_drawing.rowshdrs_area.Y + grid.grid_drawing.rowshdrs_area.Height;
+ g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
}
public override void DataGridPaintRowHeaderArrow (Graphics g, Rectangle bounds, DataGrid grid)
arrow[1] = P2;
arrow[2] = P3;
- g.FillPolygon (ThemeEngine.Current.ResPool.GetSolidBrush
+ g.FillPolygon (ResPool.GetSolidBrush
(grid.CurrentTableStyle.CurrentHeaderForeColor), arrow, FillMode.Winding);
}
public override void DataGridPaintRowHeader (Graphics g, Rectangle bounds, int row, DataGrid grid)
{
// Background
- g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor),
+ g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor),
bounds);
if (grid.FlatMode == false) {
// Paint Borders
- g.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlLight),
+ g.DrawLine (ResPool.GetPen (ColorControlLight),
bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
- g.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlLight),
+ g.DrawLine (ResPool.GetPen (ColorControlLight),
bounds.X, bounds.Y + 1, bounds.X, bounds.Y + bounds.Height - 1);
- g.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlDark),
+ 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 (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlDark),
+ g.DrawLine (ResPool.GetPen (ColorControlDark),
bounds.X, bounds.Y + bounds.Height -1, bounds.X + bounds.Width, bounds.Y + bounds.Height -1);
}
- if (grid.ShowEditRow && row == grid.RowsCount && !(row == grid.CurrentCell.RowNumber && grid.is_changing == true)) {
+ if (grid.ShowEditRow && grid.RowsCount > 0 && row == grid.RowsCount && !(row == grid.CurrentCell.RowNumber && grid.is_changing == true)) {
g.DrawString ("*", grid.grid_drawing.font_newrow, ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
bounds);
if (grid.is_changing == true) {
g.DrawString ("...", grid.Font,
- ThemeEngine.Current.ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
+ ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderForeColor),
bounds);
} else {
int rowcnt = grid.FirstVisibleRow + grid.VisibleRowCount;
- if (grid.ShowEditRow) {
+ if (grid.ShowEditRow && grid.RowsCount > 0) {
rowcnt--;
}
}
}
- if (grid.ShowEditRow && grid.FirstVisibleRow + grid.VisibleRowCount == grid.RowsCount + 1) {
+ if (grid.ShowEditRow && grid.RowsCount > 0 && grid.FirstVisibleRow + grid.VisibleRowCount == grid.RowsCount + 1) {
rect_row.Y = cells.Y + ((rowcnt - grid.FirstVisibleRow) * grid.RowHeight);
if (clip.IntersectsWith (rect_row)) {
DataGridPaintRow (g, rowcnt, rect_row, true, grid);
}
- }
-
+ }
+
not_usedarea.Height = cells.Y + cells.Height - rect_row.Y - rect_row.Height;
not_usedarea.Y = rect_row.Y + rect_row.Height;
not_usedarea.Width = rect_row.Width = cells.Width;
- not_usedarea.X = cells.X;
-
- g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (grid.BackgroundColor),
- not_usedarea);
+ not_usedarea.X = cells.X;
+
+ g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
}
public override void DataGridPaintRow (Graphics g, int row, Rectangle row_rect, bool is_newrow, DataGrid grid)
if (is_newrow) {
grid.CurrentTableStyle.GridColumnStyles[column].PaintNewRow (g, rect_cell,
- ThemeEngine.Current.ResPool.GetSolidBrush (backcolor),
- ThemeEngine.Current.ResPool.GetSolidBrush (forecolor));
+ ResPool.GetSolidBrush (backcolor),
+ ResPool.GetSolidBrush (forecolor));
} else {
grid.CurrentTableStyle.GridColumnStyles[column].Paint (g, rect_cell, grid.ListManager, row,
- ThemeEngine.Current.ResPool.GetSolidBrush (backcolor),
- ThemeEngine.Current.ResPool.GetSolidBrush (forecolor),
+ ResPool.GetSolidBrush (backcolor),
+ ResPool.GetSolidBrush (forecolor),
grid.RightToLeft == RightToLeft.Yes);
}
not_usedarea.Width = row_rect.X + row_rect.Width - rect_cell.X - rect_cell.Width;
not_usedarea.Y = row_rect.Y;
not_usedarea.Height = row_rect.Height;
- g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (grid.BackgroundColor),
+ g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
not_usedarea);
}
}
if (!dtp.ShowUpDown && clip_rectangle.IntersectsWith (dtp.ClientRectangle)) {
// draw the outer border
Rectangle button_bounds = dtp.ClientRectangle;
- this.CPDrawBorder3D (dc, button_bounds, Border3DStyle.Sunken, Border3DSide.All, dtp.BackColor);
+ this.CPDrawBorder3D (dc, button_bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, dtp.BackColor);
// deflate by the border width
if (clip_rectangle.IntersectsWith (dtp.drop_down_arrow_rect)) {
// render the date part
if (clip_rectangle.IntersectsWith (dtp.date_area_rect)) {
// fill the background
- dc.FillRectangle (ResPool.GetSolidBrush (ThemeEngine.Current.ColorWindow), dtp.date_area_rect);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorWindow), dtp.date_area_rect);
// fill the currently highlighted area
if (dtp.hilight_date_area != Rectangle.Empty) {
- dc.FillRectangle (ResPool.GetSolidBrush (ThemeEngine.Current.ColorHighlight), dtp.hilight_date_area);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorHighlight), dtp.hilight_date_area);
}
// draw the text part
text_format.HotkeyPrefix = HotkeyPrefix.Show;
size = dc.MeasureString (box.Text, box.Font);
- width = (int) size.Width;
+ width = ((int) size.Width) + 7;
if (width > box.Width - 16)
width = box.Width - 16;
else
dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (color),
label.pieces[i].rect.X, label.pieces[i].rect.Y);
-
+
if (label.pieces[i].focused) {
CPDrawFocusRectangle (dc, label.pieces[i].rect, label.ForeColor, label.BackColor);
}
StringFormat string_format = ctrl.GetFormatString ();
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
- back_color = ThemeEngine.Current.ColorHighlight;
- fore_color = ThemeEngine.Current.ColorHighlightText;
+ back_color = ColorHighlight;
+ fore_color = ColorHighlightText;
}
else {
back_color = e.BackColor;
fore_color = e.ForeColor;
}
-
- e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
+
+ e.Graphics.FillRectangle (ResPool.GetSolidBrush
(back_color), e.Bounds);
e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
- ThemeEngine.Current.ResPool.GetSolidBrush (fore_color),
+ ResPool.GetSolidBrush (fore_color),
e.Bounds.X, e.Bounds.Y, string_format);
if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
- ThemeEngine.Current.CPDrawFocusRectangle (e.Graphics, e.Bounds,
+ CPDrawFocusRectangle (e.Graphics, e.Bounds,
fore_color, back_color);
}
}
#region ListView
// Drawing
- public override void DrawListView (Graphics dc, Rectangle clip, ListView control)
+ public override void DrawListViewItems (Graphics dc, Rectangle clip, ListView control)
{
- bool details = (control.View == View.Details);
- Rectangle client_area_nohdrs;
- DrawListViewHeader (dc, clip, control);
-
- if (details && control.Columns.Count > 0) {
- client_area_nohdrs = control.client_area;
- client_area_nohdrs.Y += control.Columns[0].Ht;
- client_area_nohdrs.Height -= control.Columns[0].Ht;
- dc.SetClip (client_area_nohdrs);
- } else
- dc.SetClip (control.client_area);
-
+ bool details = control.View == View.Details;
+
dc.FillRectangle (ResPool.GetSolidBrush (control.BackColor), clip);
-
- // In case of details view draw the items only if
- // columns are non-zero
- if (!details || control.Columns.Count > 0) {
- int first = control.FirstVisibleIndex;
-
- for (int i = first; i <= control.LastItemIndex; i ++) {
- if (clip.IntersectsWith (control.Items[i].GetBounds (ItemBoundsPortion.Entire)))
- DrawListViewItem (dc, control, control.Items[i]);
- }
+ int first = control.FirstVisibleIndex;
+
+ for (int i = first; i <= control.LastVisibleIndex; i ++) {
+ if (clip.IntersectsWith (control.Items[i].GetBounds (ItemBoundsPortion.Entire)))
+ DrawListViewItem (dc, control, control.Items [i]);
}
// draw the gridlines
}
- private void DrawListViewHeader (Graphics dc, Rectangle clip, ListView control)
+ public override void DrawListViewHeader (Graphics dc, Rectangle clip, ListView control)
{
bool details = (control.View == View.Details);
dc.FillRectangle (ResPool.GetSolidBrush (control.BackColor),
0, 0, control.TotalWidth, control.Font.Height + 5);
if (control.Columns.Count > 0) {
- if (control.HeaderStyle == ColumnHeaderStyle.Clickable) {
- foreach (ColumnHeader col in control.Columns) {
- Rectangle rect = col.Rect;
- rect.X -= control.h_marker;
- this.CPDrawButton (dc, rect,
- (col.Pressed ?
- ButtonState.Pushed :
- ButtonState.Normal));
- dc.DrawString (col.Text, ThemeEngine.Current.DefaultFont,
- ResPool.GetSolidBrush
- (this.ColorControlText),
- rect.X + 3,
- rect.Y + rect.Height/2 + 1,
- col.Format);
- }
- }
- // Non-clickable columns
- else {
- foreach (ColumnHeader col in control.Columns) {
- Rectangle rect = col.Rect;
- rect.X -= control.h_marker;
- this.CPDrawButton (dc, rect, ButtonState.Flat);
- dc.DrawString (col.Text, ThemeEngine.Current.DefaultFont,
- ResPool.GetSolidBrush
- (this.ColorControlText),
- rect.X + 3,
- rect.Y + rect.Height/2 + 1,
- col.Format);
- }
+ foreach (ColumnHeader col in control.Columns) {
+ Rectangle rect = col.Rect;
+ rect.X -= control.h_marker;
+ ButtonState state;
+ if (control.HeaderStyle == ColumnHeaderStyle.Clickable)
+ state = col.Pressed ? ButtonState.Pushed : ButtonState.Normal;
+ else
+ state = ButtonState.Flat;
+ this.CPDrawButton (dc, rect, state);
+ rect.X += 3;
+ rect.Width -= 8;
+ if (rect.Width <= 0)
+ continue;
+ dc.DrawString (col.Text, DefaultFont,
+ ResPool.GetSolidBrush (ColorControlText),
+ rect, col.Format);
}
}
}
}
- // draws the ListViewItem of the given index
+ public override void DrawListViewHeaderDragDetails (Graphics dc, ListView view, ColumnHeader col, int target_x)
+ {
+ Rectangle rect = col.Rect;
+ rect.X -= view.h_marker;
+ Color color = Color.FromArgb (0x7f, ColorControlDark.R, ColorControlDark.G, ColorControlDark.B);
+ dc.FillRectangle (ResPool.GetSolidBrush (color), rect);
+ rect.X += 3;
+ rect.Width -= 8;
+ if (rect.Width <= 0)
+ return;
+ color = Color.FromArgb (0x7f, ColorControlText.R, ColorControlText.G, ColorControlText.B);
+ dc.DrawString (col.Text, DefaultFont, ResPool.GetSolidBrush (color), rect, col.Format);
+ Pen pen = new Pen (ColorHighlight, 2);
+ dc.DrawLine (pen, target_x, 0, target_x, col.Rect.Height);
+ }
+
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;
- Rectangle rect_iconrect = item.GetBounds (ItemBoundsPortion.Icon);
+ 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 (control.CheckBoxes) {
if (control.StateImageList == null) {
// Make sure we've got at least a line width of 1
}
}
- // Item is drawn as a special case, as it is not just text
if (control.View == View.LargeIcon) {
- if (item.ImageIndex > -1 &&
- control.LargeImageList != null &&
- item.ImageIndex < control.LargeImageList.Images.Count)
- control.LargeImageList.Draw (dc, rect_iconrect.Location,
- item.ImageIndex);
- }
- else {
- if (item.ImageIndex > -1 &&
- control.SmallImageList != null &&
+ if (control.LargeImageList == null) {
+ Pen pen = new Pen (ColorWindowText, 2);
+ dc.DrawLine (pen, icon_rect.Left, icon_rect.Y, icon_rect.Left + 11, icon_rect.Y);
+ } else if (item.ImageIndex > -1 && item.ImageIndex < control.LargeImageList.Images.Count)
+ control.LargeImageList.Draw (dc, icon_rect.Location, item.ImageIndex);
+ } else {
+ if (item.ImageIndex > -1 && control.SmallImageList != null &&
item.ImageIndex < control.SmallImageList.Images.Count)
- control.SmallImageList.Draw (dc, rect_iconrect.Location,
- item.ImageIndex);
+ control.SmallImageList.Draw (dc, icon_rect.Location, item.ImageIndex);
}
// draw the item text
// format for the item text
StringFormat format = new StringFormat ();
- format.LineAlignment = StringAlignment.Center;
+ if (control.View == View.SmallIcon)
+ format.LineAlignment = StringAlignment.Near;
+ else
+ format.LineAlignment = StringAlignment.Center;
if (control.View == View.LargeIcon)
format.Alignment = StringAlignment.Center;
else
if (item.Selected) {
if (control.View == View.Details) {
if (control.FullRowSelect) {
- // fill the entire rect excluding the checkbox
- full_rect.Location = item.LabelRect.Location;
- dc.FillRectangle (this.ResPool.GetSolidBrush
- (this.ColorHighlight), full_rect);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorHighlight), text_rect);
}
else {
Size text_size = Size.Ceiling (dc.MeasureString (item.Text,
// set the format for subitems
format.FormatFlags = StringFormatFlags.NoWrap;
- format.Alignment = StringAlignment.Near;
// 0th subitem is the item already drawn
for (int index = 1; index < count; index++) {
subItem = subItems [index];
col = control.Columns [index];
- sub_item_rect.X = col.Rect.Left;
+ format.Alignment = col.Format.Alignment;
+ sub_item_rect.X = col.Rect.X - control.h_marker;
sub_item_rect.Width = col.Wd;
- sub_item_rect.X -= control.h_marker;
+ Rectangle sub_item_text_rect = sub_item_rect;
+ sub_item_text_rect.X += 3;
+ sub_item_text_rect.Width -= 6;
SolidBrush sub_item_back_br = null;
SolidBrush sub_item_fore_br = null;
Font sub_item_font = null;
if (item.UseItemStyleForSubItems) {
- sub_item_back_br = this.ResPool.GetSolidBrush
- (item.BackColor);
- sub_item_fore_br = this.ResPool.GetSolidBrush
- (item.ForeColor);
+ sub_item_back_br = ResPool.GetSolidBrush (item.BackColor);
+ sub_item_fore_br = ResPool.GetSolidBrush (item.ForeColor);
sub_item_font = item.Font;
- }
- else {
- sub_item_back_br = this.ResPool.GetSolidBrush
- (subItem.BackColor);
- sub_item_fore_br = this.ResPool.GetSolidBrush
- (subItem.ForeColor);
+ } else {
+ sub_item_back_br = ResPool.GetSolidBrush (subItem.BackColor);
+ sub_item_fore_br = ResPool.GetSolidBrush (subItem.ForeColor);
sub_item_font = subItem.Font;
}
- // In case of fullrowselect, background is filled
- // for the entire rect above
if (item.Selected && control.FullRowSelect) {
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorHighlight), sub_item_rect);
if (subItem.Text != null && subItem.Text.Length > 0)
dc.DrawString (subItem.Text, sub_item_font,
this.ResPool.GetSolidBrush
(this.ColorHighlightText),
- sub_item_rect, format);
- }
- else {
+ sub_item_text_rect, format);
+ } else {
dc.FillRectangle (sub_item_back_br, sub_item_rect);
if (subItem.Text != null && subItem.Text.Length > 0)
dc.DrawString (subItem.Text, sub_item_font,
sub_item_fore_br,
- sub_item_rect, format);
+ sub_item_text_rect, format);
}
- sub_item_rect.X += col.Wd;
}
}
}
if (item.Focused) {
+ Rectangle focus_rect = text_rect;
+ if (control.FullRowSelect && control.View == View.Details) {
+ int width = 0;
+ foreach (ColumnHeader col in control.Columns)
+ width += col.Width;
+ focus_rect = new Rectangle (0, full_rect.Y, width, full_rect.Height);
+ }
if (item.Selected)
- CPDrawFocusRectangle (dc, text_rect, ColorHighlightText, ColorHighlight);
+ CPDrawFocusRectangle (dc, focus_rect, ColorHighlightText, ColorHighlight);
else
- CPDrawFocusRectangle (dc, text_rect, control.ForeColor, control.BackColor);
+ CPDrawFocusRectangle (dc, focus_rect, control.ForeColor, control.BackColor);
}
format.Dispose ();
item.X = x;
item.Y = y;
- if (item.Visible == false)
+ if (item.Visible == false) {
+ item.Width = 0;
+ item.Height = 0;
return;
+ }
if (item.Separator == true) {
item.Height = SEPARATOR_HEIGHT / 2;
return;
} else {
SizeF size;
- size = dc.MeasureString (item.Text, ThemeEngine.Current.MenuFont);
+ size = dc.MeasureString (item.Text, MenuFont);
item.Width = (int) size.Width;
item.Height = (int) size.Height;
if (!menuBar) {
if (item.Shortcut != Shortcut.None && item.ShowShortcut) {
- item.XTab = ThemeEngine.Current.MenuCheckSize.Width + MENU_TAB_SPACE + (int) size.Width;
- size = dc.MeasureString (" " + item.GetShortCutText (), ThemeEngine.Current.MenuFont);
+ item.XTab = MenuCheckSize.Width + MENU_TAB_SPACE + (int) size.Width;
+ size = dc.MeasureString (" " + item.GetShortCutText (), MenuFont);
item.Width += MENU_TAB_SPACE + (int) size.Width;
}
- item.Width += 4 + (ThemeEngine.Current.MenuCheckSize.Width * 2);
+ item.Width += 4 + (MenuCheckSize.Width * 2);
} else {
item.Width += MENU_BAR_ITEMS_SPACE;
x += item.Width;
}
- if (item.Height < ThemeEngine.Current.MenuHeight)
- item.Height = ThemeEngine.Current.MenuHeight;
+ if (item.Height < MenuHeight)
+ item.Height = MenuHeight;
}
}
public override void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect)
{
if (menu.Height == 0)
- ThemeEngine.Current.CalcMenuBarSize (dc, menu, rect.Width);
+ CalcMenuBarSize (dc, menu, rect.Width);
bool keynav = (menu as MainMenu).tracker.Navigating;
HotkeyPrefix hp = always_draw_hotkeys || keynav ? HotkeyPrefix.Show : HotkeyPrefix.Hide;
string_format_menu_text.HotkeyPrefix = hp;
rect.Height = menu.Height;
- dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (menu.Wnd.BackColor), rect);
+ dc.FillRectangle (ResPool.GetSolidBrush(ColorMenu), rect);
for (int i = 0; i < menu.MenuItems.Count; i++) {
MenuItem item = menu.MenuItems [i];
item_rect.X += rect.X;
item_rect.Y += rect.Y;
item.MenuHeight = menu.Height;
- item.PerformDrawItem (new DrawItemEventArgs (dc, ThemeEngine.Current.MenuFont, item_rect, i, item.Status));
+ item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont, item_rect, i, item.Status));
}
}
+ Bitmap CreateGlyphBitmap (Size size, MenuGlyph glyph, Color color)
+ {
+ Color bg_color;
+ if (color.R == 0 && color.G == 0 && color.B == 0)
+ bg_color = Color.White;
+ else
+ bg_color = Color.Black;
+ Bitmap bmp = new Bitmap (size.Width, size.Height);
+ Graphics gr = Graphics.FromImage (bmp);
+ Rectangle rect = new Rectangle (Point.Empty, size);
+ gr.FillRectangle (ResPool.GetSolidBrush (bg_color), rect);
+ CPDrawMenuGlyph (gr, rect, glyph, color);
+ bmp.MakeTransparent (bg_color);
+ gr.Dispose ();
+ return bmp;
+ }
+
public override void DrawMenuItem (MenuItem item, DrawItemEventArgs e)
{
StringFormat string_format;
string_format = string_format_menu_text;
if (item.Separator == true) {
- e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlDark),
+ e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y);
- e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlLight),
+ e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
e.Bounds.X, e.Bounds.Y + 1, e.Bounds.X + e.Bounds.Width, e.Bounds.Y + 1);
return;
}
if (!item.MenuBar)
- rect_text.X += ThemeEngine.Current.MenuCheckSize.Width;
+ rect_text.X += MenuCheckSize.Width;
if (item.BarBreak) { /* Draw vertical break bar*/
Rectangle rect = e.Bounds;
rect.Width = 3;
rect.Height = item.MenuHeight - 6;
- e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlDark),
+ e.Graphics.DrawLine (ResPool.GetPen (ColorControlDark),
rect.X, rect.Y , rect.X, rect.Y + rect.Height);
- e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlLight),
+ e.Graphics.DrawLine (ResPool.GetPen (ColorControlLight),
rect.X + 1, rect.Y , rect.X +1, rect.Y + rect.Height);
}
Color color_back;
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
- color_text = ThemeEngine.Current.ColorHighlightText;
- color_back = ThemeEngine.Current.ColorHighlight;
+ color_text = ColorHighlightText;
+ color_back = ColorHighlight;
} else {
- color_text = ThemeEngine.Current.ColorMenuText;
- color_back = ThemeEngine.Current.ColorMenu;
+ color_text = ColorMenuText;
+ color_back = ColorMenu;
}
/* Draw background */
Rectangle rect_back = e.Bounds;
rect_back.X++;
rect_back.Width -=2;
- e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (color_back), rect_back);
+ e.Graphics.FillRectangle (ResPool.GetSolidBrush (color_back), rect_back);
if (item.Enabled) {
e.Graphics.DrawString (item.Text, e.Font,
- ThemeEngine.Current.ResPool.GetSolidBrush (color_text),
+ ResPool.GetSolidBrush (color_text),
rect_text, string_format);
if (!item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut) {
rect.X = item.XTab;
rect.Width -= item.XTab;
- e.Graphics.DrawString (str, e.Font, ThemeEngine.Current.ResPool.GetSolidBrush (color_text),
+ e.Graphics.DrawString (str, e.Font, ResPool.GetSolidBrush (color_text),
rect, string_format_menu_shortcut);
}
} else {
/* Draw arrow */
if (item.MenuBar == false && item.IsPopup || item.MdiList) {
- int cx = ThemeEngine.Current.MenuCheckSize.Width;
- int cy = ThemeEngine.Current.MenuCheckSize.Height;
- Bitmap bmp = new Bitmap (cx, cy);
- Graphics gr = Graphics.FromImage (bmp);
- Rectangle rect_arrow = new Rectangle (0, 0, cx, cy);
- ControlPaint.DrawMenuGlyph (gr, rect_arrow, MenuGlyph.Arrow);
- bmp.MakeTransparent ();
+ int cx = MenuCheckSize.Width;
+ int cy = MenuCheckSize.Height;
+ Bitmap bmp = CreateGlyphBitmap (new Size (cx, cy), MenuGlyph.Arrow, color_text);
if (item.Enabled) {
e.Graphics.DrawImage (bmp, e.Bounds.X + e.Bounds.Width - cx,
e.Bounds.Y + ((e.Bounds.Height - cy) /2), color_back);
}
- gr.Dispose ();
bmp.Dispose ();
}
if (item.MenuBar == false && item.Checked) {
Rectangle area = e.Bounds;
- int cx = ThemeEngine.Current.MenuCheckSize.Width;
- int cy = ThemeEngine.Current.MenuCheckSize.Height;
- Bitmap bmp = new Bitmap (cx, cy);
- Graphics gr = Graphics.FromImage (bmp);
- Rectangle rect_arrow = new Rectangle (0, 0, cx, cy);
-
- if (item.RadioCheck)
- ControlPaint.DrawMenuGlyph (gr, rect_arrow, MenuGlyph.Bullet);
- else
- ControlPaint.DrawMenuGlyph (gr, rect_arrow, MenuGlyph.Checkmark);
+ int cx = MenuCheckSize.Width;
+ int cy = MenuCheckSize.Height;
+ Bitmap bmp = CreateGlyphBitmap (new Size (cx, cy), item.RadioCheck ? MenuGlyph.Bullet : MenuGlyph.Checkmark, color_text);
- bmp.MakeTransparent ();
e.Graphics.DrawImage (bmp, area.X, e.Bounds.Y + ((e.Bounds.Height - cy) / 2));
- gr.Dispose ();
bmp.Dispose ();
}
}
public override void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect)
{
- dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
- (ThemeEngine.Current.ColorMenu), cliparea);
+ dc.FillRectangle (ResPool.GetSolidBrush
+ (ColorMenu), cliparea);
/* Draw menu borders */
- dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorHighlightText),
+ dc.DrawLine (ResPool.GetPen (ColorHighlightText),
rect.X, rect.Y, rect.X + rect.Width, rect.Y);
- dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorHighlightText),
+ dc.DrawLine (ResPool.GetPen (ColorHighlightText),
rect.X, rect.Y, rect.X, rect.Y + rect.Height);
- dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlDark),
+ dc.DrawLine (ResPool.GetPen (ColorControlDark),
rect.X + rect.Width - 1 , rect.Y , rect.X + rect.Width - 1, rect.Y + rect.Height);
- dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlDarkDark),
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
rect.X + rect.Width, rect.Y , rect.X + rect.Width, rect.Y + rect.Height);
- dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlDark),
+ dc.DrawLine (ResPool.GetPen (ColorControlDark),
rect.X , rect.Y + rect.Height - 1 , rect.X + rect.Width - 1, rect.Y + rect.Height -1);
- dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorControlDarkDark),
+ dc.DrawLine (ResPool.GetPen (ColorControlDarkDark),
rect.X , rect.Y + rect.Height, rect.X + rect.Width - 1, rect.Y + rect.Height);
for (int i = 0; i < menu.MenuItems.Count; i++)
if (cliparea.IntersectsWith (menu.MenuItems [i].bounds)) {
MenuItem item = menu.MenuItems [i];
item.MenuHeight = menu.Height;
- item.PerformDrawItem (new DrawItemEventArgs (dc, ThemeEngine.Current.MenuFont,
+ item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont,
item.bounds, i, item.Status));
}
}
dc.DrawRectangle (SystemPens.ControlDark, button_rect);
}
else {
- CPDrawBorder3D (dc, button_rect, Border3DStyle.Raised, Border3DSide.All);
+ CPDrawBorder3D (dc, button_rect, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
}
// draw the arrow
dc.FillPolygon (SystemBrushes.ControlText, arrow_path);
int increment;
int barpos_pixels;
- block_width = ((client_area.Height) * 2 ) / 3;
+ block_width = (client_area.Height * 2 ) / 3;
barpos_pixels = ((ctrl.Value - ctrl.Minimum) * client_area.Width) / (ctrl.Maximum - ctrl.Minimum);
increment = block_width + space_betweenblocks;
/* Draw border */
- CPDrawBorder3D (dc, ctrl.ClientRectangle, Border3DStyle.SunkenInner, Border3DSide.All & ~Border3DSide.Middle, ColorControl);
+ CPDrawBorder3D (dc, ctrl.ClientRectangle, Border3DStyle.SunkenInner, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom & ~Border3DSide.Middle, ColorControl);
/* Draw Blocks */
block_rect = new Rectangle (client_area.X, client_area.Y, block_width, client_area.Height);
protected virtual void RadioButton_DrawText(RadioButton radio_button, Rectangle text_rectangle, Graphics dc, StringFormat text_format)
{
- SolidBrush sb;
-
// offset the text if it's pressed and a button
if (radio_button.Appearance == Appearance.Button) {
if (radio_button.Checked || (radio_button.Capture && radio_button.FlatStyle != FlatStyle.Flat)) {
}
/* Place the text; to be compatible with Windows place it after the radiobutton has been drawn */
- dc.DrawString (radio_button.Text, radio_button.Font, ThemeEngine.Current.ResPool.GetSolidBrush (radio_button.ForeColor), text_rectangle, text_format);
-
+
+ // Windows seems to not wrap text in certain situations, this matches as close as I could get it
+ if ((float)(radio_button.Font.Height * 1.5f) > text_rectangle.Height) {
+ text_format.FormatFlags |= StringFormatFlags.NoWrap;
+ }
+
if (radio_button.Enabled) {
- sb = ResPool.GetSolidBrush(radio_button.ForeColor);
- dc.DrawString(radio_button.Text, radio_button.Font, sb, text_rectangle, text_format);
+ dc.DrawString (radio_button.Text, radio_button.Font, ResPool.GetSolidBrush (radio_button.ForeColor), text_rectangle, text_format);
} else if (radio_button.FlatStyle == FlatStyle.Flat) {
dc.DrawString(radio_button.Text, radio_button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorControl)), text_rectangle, text_format);
} else {
Border3DStyle border_style = Border3DStyle.SunkenInner;
if (panel.BorderStyle == StatusBarPanelBorderStyle.Raised)
border_style = Border3DStyle.RaisedOuter;
- CPDrawBorder3D(dc, area, border_style, Border3DSide.All, panel.Parent.BackColor);
+ CPDrawBorder3D(dc, area, border_style, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, panel.Parent.BackColor);
}
if (panel.Style == StatusBarPanelStyle.OwnerDraw) {
}
if (is_selected) {
- CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.All);
+ CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
} else if (tab.Appearance != TabAppearance.FlatButtons) {
- CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.All);
+ CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
}
interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4);
int ho = interior.Height / 2;
dc.TranslateTransform (interior.X + wo, interior.Y + ho);
dc.RotateTransform (180);
- dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
+ dc.DrawString (page.Text, page.Font, ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
dc.ResetTransform ();
} else {
dc.DrawString (page.Text, page.Font,
- ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText),
+ ResPool.GetSolidBrush (SystemColors.ControlText),
interior, string_format);
}
} else if (page.Text != null) {
return res;
}
- if (page.Focused) {
+ if (page.parent.Focused && is_selected) {
CPDrawFocusRectangle (dc, interior, tab.ForeColor, tab.BackColor);
}
}
#region ToolBar
- public override void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control) {
- StringFormat format = new StringFormat ();
+ public override void DrawToolBar (Graphics dc, Rectangle clip_rectangle, ToolBar control)
+ {
+ StringFormat format = new StringFormat ();
format.Trimming = StringTrimming.EllipsisWord;
- if (control.textAlignment == ToolBarTextAlign.Underneath) {
- format.LineAlignment = StringAlignment.Center;
+ format.LineAlignment = StringAlignment.Center;
+ if (control.TextAlign == ToolBarTextAlign.Underneath)
format.Alignment = StringAlignment.Center;
- } else {
- format.LineAlignment = StringAlignment.Center;
+ else
format.Alignment = StringAlignment.Near;
- }
- // Exclude the area for divider
- Rectangle paint_area = new Rectangle (0, ToolBarGripWidth / 2,
- control.Width, control.Height - ToolBarGripWidth / 2);
- bool flat = (control.Appearance == ToolBarAppearance.Flat);
- dc.FillRectangle (ResPool.GetSolidBrush( DefaultControlBackColor ), paint_area);
- if (control.Divider)
- dc.DrawLine (ResPool.GetPen (ColorControlLight), 0, 0, paint_area.Width, 0);
-
- foreach (ToolBarButton button in control.Buttons) {
-
- Image image = null;
- Rectangle buttonArea = button.Rectangle;
- Rectangle imgRect = Rectangle.Empty; // rect to draw the image
- Rectangle txtRect = buttonArea; // rect to draw the text
- Rectangle ddRect = Rectangle.Empty; // rect for the drop down arrow
-
- // calculate different rects and draw the frame if its not separator button
- if (button.Style != ToolBarButtonStyle.Separator) {
- /* Adjustment for drop down arrow */
- if (button.Style == ToolBarButtonStyle.DropDownButton && control.DropDownArrows) {
- ddRect.X = buttonArea.X + buttonArea.Width - this.ToolBarDropDownWidth;
- ddRect.Y = buttonArea.Y;
- ddRect.Width = this.ToolBarDropDownWidth;
- ddRect.Height = buttonArea.Height;
- }
+ dc.FillRectangle (ResPool.GetSolidBrush( DefaultControlBackColor ), clip_rectangle);
+
+ foreach (ToolBarButton button in control.Buttons)
+ if (button.Visible && clip_rectangle.IntersectsWith (button.Rectangle))
+ DrawToolBarButton (dc, control, button, format);
- // calculate txtRect and imgRect, if imageIndex and imageList are present
- if (button.ImageIndex > -1 && control.ImageList != null) {
- if (button.ImageIndex < control.ImageList.Images.Count)
- image = control.ImageList.Images [button.ImageIndex];
- // draw the image at the centre if textalignment is underneath
- if (control.TextAlign == ToolBarTextAlign.Underneath) {
- imgRect.X = buttonArea.X + ((buttonArea.Width - ddRect.Width
- - control.ImageSize.Width) / 2)
- + this.ToolBarImageGripWidth;
- imgRect.Y = buttonArea.Y + this.ToolBarImageGripWidth;
- imgRect.Width = control.ImageSize.Width;
- imgRect.Height = control.ImageSize.Height;
-
- txtRect.X = buttonArea.X;
- txtRect.Y = buttonArea.Y + imgRect.Height + 2 * this.ToolBarImageGripWidth;
- txtRect.Width = buttonArea.Width - ddRect.Width;
- txtRect.Height = buttonArea.Height - imgRect.Height
- - 2 * this.ToolBarImageGripWidth;
- }
- else {
- imgRect.X = buttonArea.X + this.ToolBarImageGripWidth;
- imgRect.Y = buttonArea.Y + this.ToolBarImageGripWidth;
- imgRect.Width = control.ImageSize.Width;
- imgRect.Height = control.ImageSize.Height;
-
- txtRect.X = buttonArea.X + imgRect.Width + 2 * this.ToolBarImageGripWidth;
- txtRect.Y = buttonArea.Y;
- txtRect.Width = buttonArea.Width - imgRect.Width
- - 2 * this.ToolBarImageGripWidth - ddRect.Width;
- txtRect.Height = buttonArea.Height;
- }
- }
- /* Draw the button frame, only if it is not a separator */
- if (flat) {
- if (button.Pushed || button.Pressed) {
- CPDrawBorder3D (dc, buttonArea, Border3DStyle.SunkenOuter, Border3DSide.All, ColorControl);
- } else if (button.Hilight) {
- dc.DrawRectangle (ResPool.GetPen (ColorControlText), buttonArea);
- if (! ddRect.IsEmpty) {
- dc.DrawLine (ResPool.GetPen (ColorControlText), ddRect.X, ddRect.Y, ddRect.X,
- ddRect.Y + ddRect.Height);
- buttonArea.Width -= this.ToolBarDropDownWidth;
- }
- }
- }
- else { // normal toolbar
- if (button.Pushed || button.Pressed) {
- CPDrawBorder3D (dc, buttonArea, Border3DStyle.SunkenInner,
- Border3DSide.All, ColorControl);
- if (! ddRect.IsEmpty) {
- CPDrawBorder3D (dc, ddRect, Border3DStyle.SunkenInner,
- Border3DSide.Left, ColorControl);
- buttonArea.Width -= this.ToolBarDropDownWidth;
- }
- }
- else {
- CPDrawBorder3D (dc, buttonArea, Border3DStyle.RaisedInner,
- Border3DSide.All, ColorControl);
- if (! ddRect.IsEmpty) {
- CPDrawBorder3D (dc, ddRect, Border3DStyle.RaisedInner,
- Border3DSide.Left, ColorControl);
- buttonArea.Width -= this.ToolBarDropDownWidth;
- }
- }
- }
- }
- DrawToolBarButton (dc, button, control.Font, format, paint_area, buttonArea,
- imgRect, image, txtRect, ddRect, flat);
- }
format.Dispose ();
}
- private void DrawToolBarButton (Graphics dc, ToolBarButton button, Font font, StringFormat format,
- Rectangle controlArea, Rectangle buttonArea, Rectangle imgRect,
- Image image, Rectangle txtRect, Rectangle ddRect, bool flat) {
- if (! button.Visible)
- return;
+ void DrawToolBarButton (Graphics dc, ToolBar control, ToolBarButton button, StringFormat format)
+ {
+ bool is_flat = control.Appearance == ToolBarAppearance.Flat;
+
+ DrawToolBarButtonBorder (dc, button, is_flat);
switch (button.Style) {
+ case ToolBarButtonStyle.DropDownButton:
+ if (control.DropDownArrows)
+ DrawToolBarDropDownArrow (dc, button, is_flat);
+ DrawToolBarButtonContents (dc, control, button, format);
+ break;
case ToolBarButtonStyle.Separator:
- // separator is drawn only in the case of flat appearance
- if (flat) {
- dc.DrawLine (ResPool.GetPen (ColorControlDark), buttonArea.X + 1, buttonArea.Y,
- buttonArea.X + 1, buttonArea.Height);
- dc.DrawLine (ResPool.GetPen (ColorControlLight), buttonArea.X + 1 + (int) ResPool.GetPen (ColorControl).Width,
- buttonArea.Y, buttonArea.X + 1 + (int) ResPool.GetPen (ColorControl).Width, buttonArea.Height);
- /* draw a horizontal separator */
- if (button.Wrapper) {
- int y = buttonArea.Height + this.ToolBarSeparatorWidth / 2;
- dc.DrawLine (ResPool.GetPen (ColorControlDark), 0, y, controlArea.Width, y);
- dc.DrawLine (ResPool.GetPen (ColorControlLight), 0, y + 1 + (int) ResPool.GetPen (ColorControl).Width, controlArea.Width,
- y + 1 + (int) ResPool.GetPen (ColorControl).Width);
- }
- }
+ if (is_flat)
+ DrawToolBarSeparator (dc, button);
break;
case ToolBarButtonStyle.ToggleButton:
- Rectangle toggleArea = Rectangle.Empty;
- toggleArea.X = buttonArea.X + this.ToolBarImageGripWidth;
- toggleArea.Y = buttonArea.Y + this.ToolBarImageGripWidth;
- toggleArea.Width = buttonArea.Width - 2 * this.ToolBarImageGripWidth;
- toggleArea.Height = buttonArea.Height - 2 * this.ToolBarImageGripWidth;
- if (button.PartialPush && button.Pushed) {
- dc.FillRectangle (SystemBrushes.ControlLightLight, toggleArea);
- if (! imgRect.IsEmpty) {
- if (button.Enabled && image != null)
- button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
- imgRect.Height, button.ImageIndex);
- else {
- dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
- ControlPaint.DrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
- Border3DSide.Right | Border3DSide.Bottom);
- }
- }
- if (button.Enabled)
- dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
- else
- CPDrawStringDisabled (dc, button.Text, font, ColorControlLight, txtRect, format);
- }
-
- else if (button.PartialPush) {
- dc.FillRectangle (SystemBrushes.ControlLight, toggleArea);
- if (! imgRect.IsEmpty) {
- if (button.Enabled && image != null)
- button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
- imgRect.Height, button.ImageIndex);
- else {
- dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
- ControlPaint.DrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
- Border3DSide.Right | Border3DSide.Bottom);
- }
- }
- if (button.Enabled)
- dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
- else
- CPDrawStringDisabled (dc, button.Text, font, ColorControlLight,
- txtRect, format);
- }
-
- else if (button.Pushed) {
- dc.FillRectangle (SystemBrushes.ControlLightLight, toggleArea);
- if (! imgRect.IsEmpty) {
- if (button.Enabled && image != null)
- button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
- imgRect.Height, button.ImageIndex);
- else {
- dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
- CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
- Border3DSide.Right | Border3DSide.Bottom, ColorControl);
- }
- }
- if (button.Enabled)
- dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
- else
- CPDrawStringDisabled (dc, button.Text, font, ColorControlLight,
- txtRect, format);
- }
+ DrawToolBarToggleButtonBackground (dc, button);
+ DrawToolBarButtonContents (dc, control, button, format);
+ break;
- else {
- dc.FillRectangle (SystemBrushes.Control, toggleArea);
- if (! imgRect.IsEmpty) {
- if (button.Enabled && image != null)
- button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
- imgRect.Height, button.ImageIndex);
- else {
- dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
- CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
- Border3DSide.Right | Border3DSide.Bottom, ColorControl);
- }
- }
- if (button.Enabled)
- dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
- else
- CPDrawStringDisabled (dc, button.Text, font, ColorControlLight,
- txtRect, format);
- }
+ default:
+ DrawToolBarButtonContents (dc, control, button, format);
break;
+ }
+ }
- case ToolBarButtonStyle.DropDownButton:
- // draw the dropdown arrow
- if (! ddRect.IsEmpty) {
- PointF [] vertices = new PointF [3];
- PointF ddCenter = new PointF (ddRect.X + (ddRect.Width/2.0f), ddRect.Y + (ddRect.Height/2.0f));
- vertices [0].X = ddCenter.X - this.ToolBarDropDownArrowWidth / 2.0f + 0.5f;
- vertices [0].Y = ddCenter.Y;
- vertices [1].X = ddCenter.X + this.ToolBarDropDownArrowWidth / 2.0f + 0.5f;
- vertices [1].Y = ddCenter.Y;
- vertices [2].X = ddCenter.X + 0.5f; // 0.5 is added for adjustment
- vertices [2].Y = ddCenter.Y + this.ToolBarDropDownArrowHeight;
- dc.FillPolygon (SystemBrushes.ControlText, vertices);
- }
- goto case ToolBarButtonStyle.PushButton;
-
- case ToolBarButtonStyle.PushButton:
- if (! imgRect.IsEmpty){
- if (button.Enabled && image != null)
- button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width, imgRect.Height,
- button.ImageIndex);
- else {
- dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
- CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
- Border3DSide.Right | Border3DSide.Bottom, ColorControl);
- }
- }
- if (button.Enabled)
- dc.DrawString (button.Text, font, SystemBrushes.ControlText, txtRect, format);
+ const Border3DSide all_sides = Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom;
+
+ void DrawToolBarButtonBorder (Graphics dc, ToolBarButton button, bool is_flat)
+ {
+ if (button.Style == ToolBarButtonStyle.Separator)
+ return;
+
+ Border3DStyle style;
+
+ if (is_flat) {
+ if (button.Pushed || button.Pressed)
+ style = Border3DStyle.SunkenOuter;
+ else if (button.Hilight)
+ style = Border3DStyle.RaisedOuter;
else
- CPDrawStringDisabled (dc, button.Text, font, ColorControlLight,
- txtRect, format);
- break;
+ return;
+
+ } else {
+ if (button.Pushed || button.Pressed)
+ style = Border3DStyle.Sunken;
+ else
+ style = Border3DStyle.Raised;
}
+
+ CPDrawBorder3D (dc, button.Rectangle, style, all_sides);
+ }
+
+ void DrawToolBarSeparator (Graphics dc, ToolBarButton button)
+ {
+ Rectangle area = button.Rectangle;
+ int offset = (int) ResPool.GetPen (ColorControl).Width + 1;
+ dc.DrawLine (ResPool.GetPen (ColorControlDark), area.X + 1, area.Y, area.X + 1, area.Bottom);
+ dc.DrawLine (ResPool.GetPen (ColorControlLight), area.X + offset, area.Y, area.X + offset, area.Bottom);
+ }
+
+ void DrawToolBarToggleButtonBackground (Graphics dc, ToolBarButton button)
+ {
+ Rectangle area = button.Rectangle;
+ area.X += ToolBarImageGripWidth;
+ area.Y += ToolBarImageGripWidth;
+ area.Width -= 2 * ToolBarImageGripWidth;
+ area.Height -= 2 * ToolBarImageGripWidth;
+
+ if (button.Pushed)
+ dc.FillRectangle (SystemBrushes.ControlLightLight, area);
+ else if (button.PartialPush)
+ dc.FillRectangle (SystemBrushes.ControlLight, area);
+ else
+ dc.FillRectangle (SystemBrushes.Control, area);
+ }
+
+ void DrawToolBarDropDownArrow (Graphics dc, ToolBarButton button, bool is_flat)
+ {
+ Rectangle rect = button.Rectangle;
+ rect.X = button.Rectangle.Right - ToolBarDropDownWidth;
+ rect.Width = ToolBarDropDownWidth;
+
+ if (button.dd_pressed) {
+ CPDrawBorder3D (dc, rect, Border3DStyle.SunkenOuter, all_sides);
+ CPDrawBorder3D (dc, rect, Border3DStyle.SunkenInner, Border3DSide.Bottom | Border3DSide.Right);
+ } else if (button.Pushed || button.Pressed)
+ CPDrawBorder3D (dc, rect, Border3DStyle.Sunken, all_sides);
+ else if (is_flat) {
+ if (button.Hilight)
+ CPDrawBorder3D (dc, rect, Border3DStyle.RaisedOuter, all_sides);
+ } else
+ CPDrawBorder3D (dc, rect, Border3DStyle.Raised, all_sides);
+
+ PointF [] vertices = new PointF [3];
+ PointF ddCenter = new PointF (rect.X + (rect.Width/2.0f), rect.Y + (rect.Height/2.0f));
+ vertices [0].X = ddCenter.X - ToolBarDropDownArrowWidth / 2.0f + 0.5f;
+ vertices [0].Y = ddCenter.Y;
+ vertices [1].X = ddCenter.X + ToolBarDropDownArrowWidth / 2.0f + 0.5f;
+ vertices [1].Y = ddCenter.Y;
+ vertices [2].X = ddCenter.X + 0.5f; // 0.5 is added for adjustment
+ vertices [2].Y = ddCenter.Y + ToolBarDropDownArrowHeight;
+ dc.FillPolygon (SystemBrushes.ControlText, vertices);
+ }
+
+ void DrawToolBarButtonContents (Graphics dc, ToolBar control, ToolBarButton button, StringFormat format)
+ {
+ if (button.Image != null) {
+ int x = button.ImageRectangle.X + ToolBarImageGripWidth;
+ int y = button.ImageRectangle.Y + ToolBarImageGripWidth;
+ if (button.Enabled)
+ dc.DrawImage (button.Image, x, y);
+ else
+ CPDrawImageDisabled (dc, button.Image, x, y, ColorControl);
+ }
+
+ if (button.Enabled)
+ dc.DrawString (button.Text, control.Font, ResPool.GetSolidBrush (ColorControlText), button.TextRectangle, format);
+ else
+ CPDrawStringDisabled (dc, button.Text, control.Font, ColorControlLight, button.TextRectangle, format);
}
// Grip width for the ToolBar
float pixels_betweenticks;
const int space_from_right = 8;
const int space_from_left = 8;
+ const int space_from_bottom = 11;
Rectangle area = tb.ClientRectangle;
switch (tb.TickStyle) {
/* Convert thumb position from mouse position to value*/
if (mouse_value) {
-
- if (value_pos >= channel_startpoint.Y)
- value_pos = (int)(((float) (value_pos - channel_startpoint.Y)) / pixels_betweenticks);
+ if (value_pos < thumb_area.Bottom)
+ value_pos = (int) ((thumb_area.Bottom - value_pos) / pixels_betweenticks);
else
value_pos = 0;
if (value_pos + tb.Minimum > tb.Maximum)
value_pos = tb.Maximum - tb.Minimum;
-
+
tb.Value = value_pos + tb.Minimum;
}
-
- thumb_pos.Y = channel_startpoint.Y + (int) (pixels_betweenticks * (float) value_pos);
+
+ // thumb_pos.Y = channel_startpoint.Y ; // + (int) (pixels_betweenticks * (float) value_pos);
+ thumb_pos.Y = thumb_area.Bottom - space_from_bottom - (int) (pixels_betweenticks * (float) value_pos);
/* Draw thumb fixed 10x22 size */
thumb_pos.Width = 10;
CPDrawBorder3D(graphics, rectangle, style, sides, ColorControl);
}
- private void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color) {
+ private void CPDrawBorder3D (Graphics graphics, Rectangle rectangle, Border3DStyle style, Border3DSide sides, Color control_color)
+ {
Pen penTopLeft;
Pen penTopLeftInner;
Pen penBottomRight;
Pen penBottomRightInner;
- Rectangle rect= new Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
- bool doInner = false;
-
- if ((style & Border3DStyle.Adjust)!=0) {
- rect.Y-=2;
- rect.X-=2;
- rect.Width+=4;
- rect.Height+=4;
- }
-
- /* default to flat */
- penTopLeft=ResPool.GetPen(ControlPaint.Dark(control_color));
- penTopLeftInner=ResPool.GetPen(ControlPaint.Dark(control_color));
- penBottomRight=ResPool.GetPen(ControlPaint.Dark(control_color));
- penBottomRightInner=ResPool.GetPen(ControlPaint.Dark(control_color));
-
- if ((style & Border3DStyle.RaisedOuter)!=0) {
- penTopLeft=ResPool.GetPen(ControlPaint.LightLight(control_color));
- penBottomRight=ResPool.GetPen(ControlPaint.DarkDark(control_color));
- if ((style & (Border3DStyle.RaisedInner | Border3DStyle.SunkenInner))!=0) {
- doInner=true;
- }
- } else if ((style & Border3DStyle.SunkenOuter)!=0) {
- penTopLeft=ResPool.GetPen(ControlPaint.DarkDark(control_color));
- penBottomRight=ResPool.GetPen(ControlPaint.LightLight(control_color));
- if ((style & (Border3DStyle.RaisedInner | Border3DStyle.SunkenInner))!=0) {
- doInner=true;
- }
+ Rectangle rect= new Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
+
+ if ((style & Border3DStyle.Adjust) != 0) {
+ rect.Y -= 2;
+ rect.X -= 2;
+ rect.Width += 4;
+ rect.Height += 4;
}
-
- if ((style & Border3DStyle.RaisedInner)!=0) {
- if (doInner) {
- penTopLeftInner=ResPool.GetPen(control_color);
- penBottomRightInner=ResPool.GetPen(ControlPaint.Dark(control_color));
- } else {
- penTopLeft=ResPool.GetPen(ControlPaint.LightLight(control_color));
- penBottomRight=ResPool.GetPen(ControlPaint.DarkDark(control_color));
- }
- } else if ((style & Border3DStyle.SunkenInner)!=0) {
- if (doInner) {
- penTopLeftInner=ResPool.GetPen(ControlPaint.Dark(control_color));
- penBottomRightInner=ResPool.GetPen(control_color);
- } else {
- penTopLeft=ResPool.GetPen(ControlPaint.DarkDark(control_color));
- penBottomRight=ResPool.GetPen(ControlPaint.LightLight(control_color));
- }
+
+ penTopLeft = penTopLeftInner = penBottomRight = penBottomRightInner = ResPool.GetPen (control_color);
+
+ switch (style) {
+ case Border3DStyle.Raised:
+ penTopLeftInner = ResPool.GetPen (ControlPaint.LightLight (control_color));
+ penBottomRight = ResPool.GetPen (ControlPaint.DarkDark (control_color));
+ penBottomRightInner = ResPool.GetPen (ColorInactiveCaption);
+ break;
+ case Border3DStyle.Sunken:
+ penTopLeft = ResPool.GetPen (ColorInactiveCaption);
+ penTopLeftInner = ResPool.GetPen (ControlPaint.DarkDark (control_color));
+ penBottomRight = ResPool.GetPen (ControlPaint.LightLight (control_color));
+ break;
+ case Border3DStyle.Etched:
+ penTopLeft = penBottomRightInner = ResPool.GetPen (ColorInactiveCaption);
+ penTopLeftInner = penBottomRight = ResPool.GetPen (ControlPaint.LightLight (control_color));
+ break;
+ case Border3DStyle.RaisedOuter:
+ penBottomRight = ResPool.GetPen (ControlPaint.DarkDark (control_color));
+ break;
+ case Border3DStyle.SunkenOuter:
+ penTopLeft = ResPool.GetPen (ColorInactiveCaption);
+ penBottomRight = ResPool.GetPen (ControlPaint.LightLight (control_color));
+ break;
+ case Border3DStyle.RaisedInner:
+ penTopLeft = ResPool.GetPen (ControlPaint.LightLight (control_color));
+ penBottomRight = ResPool.GetPen (ColorInactiveCaption);
+ break;
+ case Border3DStyle.SunkenInner:
+ penTopLeft = ResPool.GetPen (ControlPaint.DarkDark (control_color));
+ break;
+ case Border3DStyle.Flat:
+ penTopLeft = penBottomRight = ResPool.GetPen (ColorInactiveCaption);
+ break;
+ case Border3DStyle.Bump:
+ penTopLeftInner = penBottomRight = ResPool.GetPen (ControlPaint.DarkDark (control_color));
+ break;
+ default:
+ break;
}
-
- if ((sides & Border3DSide.Middle)!=0) {
- graphics.FillRectangle(ResPool.GetSolidBrush(control_color), rect);
+
+ if ((sides & Border3DSide.Middle) != 0) {
+ graphics.FillRectangle (ResPool.GetSolidBrush (control_color), rect);
}
-
- if ((sides & Border3DSide.Left)!=0) {
- graphics.DrawLine(penTopLeft, rect.Left, rect.Bottom-2, rect.Left, rect.Top);
- if (doInner) {
- graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Bottom-2, rect.Left+1, rect.Top);
- }
+
+ if ((sides & Border3DSide.Left) != 0) {
+ graphics.DrawLine (penTopLeft, rect.Left, rect.Bottom - 2, rect.Left, rect.Top);
+ graphics.DrawLine (penTopLeftInner, rect.Left + 1, rect.Bottom - 2, rect.Left + 1, rect.Top);
}
-
- if ((sides & Border3DSide.Top)!=0) {
- graphics.DrawLine(penTopLeft, rect.Left, rect.Top, rect.Right-2, rect.Top);
-
- if (doInner) {
- if ((sides & Border3DSide.Left)!=0) {
- graphics.DrawLine(penTopLeftInner, rect.Left+1, rect.Top+1, rect.Right-3, rect.Top+1);
- } else {
- graphics.DrawLine(penTopLeftInner, rect.Left, rect.Top+1, rect.Right-3, rect.Top+1);
- }
- }
+
+ if ((sides & Border3DSide.Top) != 0) {
+ graphics.DrawLine (penTopLeft, rect.Left, rect.Top, rect.Right - 2, rect.Top);
+ graphics.DrawLine (penTopLeftInner, rect.Left + 1, rect.Top + 1, rect.Right - 3, rect.Top + 1);
}
-
- if ((sides & Border3DSide.Right)!=0) {
- graphics.DrawLine(penBottomRight, rect.Right-1, rect.Top, rect.Right-1, rect.Bottom-1);
-
- if (doInner) {
- if ((sides & Border3DSide.Top)!=0) {
- graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top+1, rect.Right-2, rect.Bottom-2);
- } else {
- graphics.DrawLine(penBottomRightInner, rect.Right-2, rect.Top, rect.Right-2, rect.Bottom-2);
- }
- }
+
+ if ((sides & Border3DSide.Right) != 0) {
+ graphics.DrawLine (penBottomRight, rect.Right - 1, rect.Top, rect.Right - 1, rect.Bottom - 1);
+ graphics.DrawLine (penBottomRightInner, rect.Right - 2, rect.Top + 1, rect.Right - 2, rect.Bottom - 2);
}
-
- if ((sides & Border3DSide.Bottom)!=0) {
- int left=rect.Left;
-
- if ((sides & Border3DSide.Left)!=0) {
- left+=1;
- }
-
- graphics.DrawLine(penBottomRight, rect.Left, rect.Bottom-1, rect.Right-1, rect.Bottom-1);
-
- if (doInner) {
- if ((sides & Border3DSide.Right)!=0) {
- graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-2, rect.Bottom-2);
- } else {
- graphics.DrawLine(penBottomRightInner, left, rect.Bottom-2, rect.Right-2, rect.Bottom-2);
- }
- }
+
+ if ((sides & Border3DSide.Bottom) != 0) {
+ graphics.DrawLine (penBottomRight, rect.Left, rect.Bottom - 1, rect.Right - 1, rect.Bottom - 1);
+ graphics.DrawLine (penBottomRightInner, rect.Left + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2);
}
-
}
-
public override void CPDrawButton (Graphics graphics, Rectangle rectangle, ButtonState state) {
DrawFrameControlStates dfcs=DrawFrameControlStates.ButtonPush;
} else {
pen=new Pen(Color.White, 1);
if (enabled==true) {
- sb=ThemeEngine.Current.ResPool.GetSolidBrush (Color.Black);
+ sb=ResPool.GetSolidBrush (Color.Black);
} else {
sb=ResPool.GetSolidBrush (ColorControl);
}
}
- public override void CPDrawMenuGlyph (Graphics graphics, Rectangle rectangle, MenuGlyph glyph) {
+ public override void CPDrawMenuGlyph (Graphics graphics, Rectangle rectangle, MenuGlyph glyph, Color color) {
Rectangle rect;
int lineWidth;
- // MS draws always the background white
- graphics.FillRectangle(ResPool.GetSolidBrush (Color.White), rectangle);
+ Brush brush = ResPool.GetSolidBrush (color);
switch(glyph) {
case MenuGlyph.Arrow: {
arrow[1]=P2;
arrow[2]=P3;
- graphics.FillPolygon(SystemBrushes.ControlText, arrow, FillMode.Winding);
+ graphics.FillPolygon(brush, arrow, FillMode.Winding);
return;
}
lineWidth=Math.Max(2, rectangle.Width/3);
rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
- graphics.FillEllipse(ResPool.GetSolidBrush (ColorControlText), rect);
+ graphics.FillEllipse(brush, rect);
return;
}
case MenuGlyph.Checkmark: {
int Scale;
+ Pen pen = ResPool.GetPen (color);
lineWidth=Math.Max(2, rectangle.Width/6);
Scale=Math.Max(1, rectangle.Width/12);
rect=new Rectangle(rectangle.X+lineWidth, rectangle.Y+lineWidth, rectangle.Width-lineWidth*2, rectangle.Height-lineWidth*2);
for (int i=0; i<lineWidth; i++) {
- graphics.DrawLine(SystemPens.MenuText, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
- graphics.DrawLine(SystemPens.MenuText, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i, rect.Left+lineWidth/2+6*Scale, rect.Top+lineWidth-2*Scale+i);
+ graphics.DrawLine(pen, rect.Left+lineWidth/2, rect.Top+lineWidth+i, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i);
+ graphics.DrawLine(pen, rect.Left+lineWidth/2+2*Scale, rect.Top+lineWidth+2*Scale+i, rect.Left+lineWidth/2+6*Scale, rect.Top+lineWidth-2*Scale+i);
}
return;
}
/* Scroll button: regular button + direction arrow */
public override void CPDrawScrollButton (Graphics dc, Rectangle area, ScrollButton type, ButtonState state) {
- bool enabled = (state == ButtonState.Inactive) ? false: true;
-
DrawScrollButtonPrimitive (dc, area, state);
+ int arrow_y_pos_diff = 3;
+
+ switch (type) {
+ case ScrollButton.Up:
+ arrow_y_pos_diff = 2;
+ break;
+ case ScrollButton.Down:
+ arrow_y_pos_diff = 4;
+ break;
+ default:
+ break;
+ }
+
// A lot of the following is adapted from the rewind project
- Rectangle rect = new Rectangle (area.X - 3, area.Y - 3,
+ Rectangle rect = new Rectangle (area.X - 3, area.Y - arrow_y_pos_diff,
area.Width + 6, area.Height + 6);
int small_diam = rect.Width > rect.Height ? rect.Height : rect.Width;
if (rect.Width < rect.Height) {
arrow [1].Y = arrow [2].Y + tri;
arrow [0].X = arrow [1].X = arrow [2].X + tri;
break;
+ // Left and Right are not drawn correctly because of libgdiplus problems
+ // once that is solved change it to the code below to match ms
+// case ScrollButton.Left:
+// arrow [2].X = rect.Right - (687 * small_diam / 1000 + 1);
+// arrow [2].Y = (rect.Top + 470 * small_diam / 1000 + 2) - 1;
+// arrow [1].Y = arrow [2].Y + tri;
+// arrow [0].Y = arrow [2].Y - tri + 1;
+// arrow [0].X = arrow [1].X = arrow [2].X + tri;
+// break;
case ScrollButton.Right:
arrow [2].X = rect.Left + 687 * small_diam / 1000 + 1;
arrow [2].Y = rect.Top + 470 * small_diam / 1000 + 2;
public override void CPDrawSizeGrip (Graphics dc, Color backColor, Rectangle bounds) {
+
Point pt = new Point (bounds.Right - 2, bounds.Bottom - 1);
+ Pen pen = ResPool.GetPen (ColorControlDark);
+
+ dc.DrawLine (pen, pt.X - 11, pt.Y, pt.X, pt.Y - 11);
+ dc.DrawLine (pen, pt.X - 10, pt.Y, pt.X, pt.Y - 10);
+
+ dc.DrawLine (pen, pt.X - 7, pt.Y, pt.X, pt.Y - 7);
+ dc.DrawLine (pen, pt.X - 6, pt.Y, pt.X, pt.Y - 6);
+
+ dc.DrawLine (pen, pt.X - 3, pt.Y, pt.X, pt.Y - 3);
+ dc.DrawLine (pen, pt.X - 2, pt.Y, pt.X, pt.Y - 2);
+
+ pen = ResPool.GetPen (ColorControlLight);
+
+ dc.DrawLine (pen, pt.X - 12, pt.Y, pt.X, pt.Y - 12);
+ dc.DrawLine (pen, pt.X - 8, pt.Y, pt.X, pt.Y - 8);
+ dc.DrawLine (pen, pt.X - 4, pt.Y, pt.X, pt.Y - 4);
+
dc.DrawLine (ResPool.GetPen (ColorControl), pt.X - 12, pt.Y, pt.X, pt.Y);
- dc.DrawLine (ResPool.GetPen (ColorControl), pt.X, pt.Y, pt.X, pt.Y - 13);
-
- // diagonals
- for (int i = 0; i < 11; i += 4) {
- dc.DrawLine (ResPool.GetPen (ColorControlDark), pt.X - i, pt.Y, pt.X + 1, pt.Y - i - 2);
- dc.DrawLine (ResPool.GetPen (ColorControlDark), pt.X - i - 1, pt.Y, pt.X + 1, pt.Y - i - 2);
- }
-
- for (int i = 3; i < 13; i += 4)
- dc.DrawLine (ResPool.GetPen (ColorControlLight), pt.X - i, pt.Y, pt.X + 1, pt.Y - i - 1);
}
public override void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
StringFormat format) {
- graphics.DrawString(s, font, ResPool.GetSolidBrush (ThemeEngine.Current.ColorGrayText), layoutRectangle, format);
+ graphics.DrawString(s, font, ResPool.GetSolidBrush (ColorGrayText), layoutRectangle, format);
}
still look like MS's scaled caption buttons. (as opposed to scaling a bitmap)
*/
- private static void DrawCaptionHelper(Graphics graphics, Color color, Pen pen, int lineWidth, int shift, Rectangle captionRect, CaptionButton button) {
+ private void DrawCaptionHelper(Graphics graphics, Color color, Pen pen, int lineWidth, int shift, Rectangle captionRect, CaptionButton button) {
switch(button) {
case CaptionButton.Close: {
pen.StartCap=LineCap.Triangle;
sf.LineAlignment=StringAlignment.Center;
- graphics.DrawString("?", font, ThemeEngine.Current.ResPool.GetSolidBrush (color), captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
+ graphics.DrawString("?", font, ResPool.GetSolidBrush (color), captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
sf.Dispose();
font.Dispose();
graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorControl)), trace_rectangle);
} else if ((State & DrawFrameControlStates.Flat)!=0) {
ControlPaint.DrawBorder(graphics, rectangle, ColorControlDark, ButtonBorderStyle.Solid);
- } else if ((State & DrawFrameControlStates.Inactive)!=0) {
- /* Same as normal, it would seem */
- CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
- } else {
- CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
- }
+ } else
+ CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorControl);
} else if ((State & DrawFrameControlStates.ButtonRadio)!=0) {
Pen penFatDark = new Pen(ColorControlDark, 1);
Pen penFatLight = new Pen(ColorControlLightLight, 1);