// 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
//
string_format_menu_menubar_text.LineAlignment = StringAlignment.Center;
string_format_menu_menubar_text.Alignment = StringAlignment.Center;
string_format_menu_menubar_text.HotkeyPrefix = HotkeyPrefix.Show;
+ always_draw_hotkeys = false;
}
public override void ResetDefaults() {
protected SolidBrush GetControlBackBrush (Color c) {
if (c == DefaultControlBackColor)
return ResPool.GetSolidBrush (ColorControl);
- return new SolidBrush (c);
+ return ResPool.GetSolidBrush (c);
}
protected SolidBrush GetControlForeBrush (Color c) {
if (c == DefaultControlForeColor)
return ResPool.GetSolidBrush (ColorControlText);
- return new SolidBrush (c);
+ return ResPool.GetSolidBrush (c);
}
#endregion // Internal Methods
// 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 {
borderRectangle = buttonRectangle;
}
-
+
if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
DrawFlatStyleButton (dc, borderRectangle, button);
} else {
CPDrawButton(dc, borderRectangle, button.ButtonState);
+ if (button.has_focus || button.paint_as_acceptbutton) {
+ dc.DrawRectangle(ResPool.GetPen(button.ForeColor), borderRectangle);
+ }
}
}
CheckBox_DrawText(checkbox, text_rectangle, dc, text_format);
CheckBox_DrawFocus(checkbox, dc, text_rectangle);
+
+ text_format.Dispose ();
}
protected virtual void CheckBox_DrawCheckBox( Graphics dc, CheckBox checkbox, ButtonState state, Rectangle checkbox_rectangle )
}
/* 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);
}
}
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 ();
}
#endregion ComboBox
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.LineAlignment = StringAlignment.Center;
text_format.Alignment = StringAlignment.Near;
dc.DrawString (dtp.Text, dtp.Font, ResPool.GetSolidBrush (dtp.ForeColor), Rectangle.Inflate(dtp.date_area_rect, -1, -1), text_format);
+ text_format.Dispose ();
}
}
CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor,
new RectangleF (10, 0, width, box.Font.Height), text_format);
}
-
+ text_format.Dispose ();
}
public override Size GroupBoxDefaultSize {
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);
}
}
}
}
+ 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);
+ }
+
// draws the ListViewItem of the given index
- private void DrawListViewItem (Graphics dc, ListView control, ListViewItem item)
+ protected virtual void DrawListViewItem (Graphics dc, ListView control, ListViewItem item)
{
+ int col_offset;
+ if (control.View == View.Details && control.Columns.Count > 0)
+ col_offset = control.Columns [0].Rect.X;
+ else
+ col_offset = 0;
+
Rectangle rect_checkrect = item.CheckRectReal;
+ rect_checkrect.X += col_offset;
Rectangle rect_iconrect = item.GetBounds (ItemBoundsPortion.Icon);
+ rect_iconrect.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
// 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 (control.View == View.Details) {
if (control.FullRowSelect) {
// fill the entire rect excluding the checkbox
- full_rect.Location = item.LabelRect.Location;
+ full_rect.Location = item.GetBounds (ItemBoundsPortion.Label).Location;
dc.FillRectangle (this.ResPool.GetSolidBrush
(this.ColorHighlight), full_rect);
}
// 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;
- sub_item_rect.Width = col.Wd;
+ format.Alignment = col.Format.Alignment;
+ sub_item_rect.X = col.Rect.Left + 3;
+ sub_item_rect.Width = col.Wd - 6;
sub_item_rect.X -= control.h_marker;
SolidBrush sub_item_back_br = null;
else
CPDrawFocusRectangle (dc, text_rect, control.ForeColor, control.BackColor);
}
+
+ format.Dispose ();
}
// Sizing
#endregion // ListView
#region Menus
- public override void CalcItemSize (Graphics dc, MenuAPI.MENUITEM item, int y, int x, bool menuBar)
+ public override void CalcItemSize (Graphics dc, MenuItem item, int y, int x, bool menuBar)
{
- item.rect.Y = y;
- item.rect.X = x;
+ item.X = x;
+ item.Y = y;
- if (item.item.Visible == false)
+ if (item.Visible == false) {
+ item.Width = 0;
+ item.Height = 0;
return;
+ }
- if (item.item.Separator == true) {
- item.rect.Height = SEPARATOR_HEIGHT / 2;
- item.rect.Width = -1;
+ if (item.Separator == true) {
+ item.Height = SEPARATOR_HEIGHT / 2;
+ item.Width = -1;
return;
}
- if (item.item.MeasureEventDefined) {
- MeasureItemEventArgs mi = new MeasureItemEventArgs (dc, item.pos);
- item.item.PerformMeasureItem (mi);
- item.rect.Height = mi.ItemHeight;
- item.rect.Width = mi.ItemWidth;
+ if (item.MeasureEventDefined) {
+ MeasureItemEventArgs mi = new MeasureItemEventArgs (dc, item.Index);
+ item.PerformMeasureItem (mi);
+ item.Height = mi.ItemHeight;
+ item.Width = mi.ItemWidth;
return;
} else {
-
SizeF size;
- size = dc.MeasureString (item.item.Text, ThemeEngine.Current.MenuFont);
- item.rect.Width = (int) size.Width;
- item.rect.Height = (int) size.Height;
+ size = dc.MeasureString (item.Text, MenuFont);
+ item.Width = (int) size.Width;
+ item.Height = (int) size.Height;
if (!menuBar) {
-
- if (item.item.Shortcut != Shortcut.None && item.item.ShowShortcut) {
- item.item.XTab = ThemeEngine.Current.MenuCheckSize.Width + MENU_TAB_SPACE + (int) size.Width;
- size = dc.MeasureString (" " + item.item.GetShortCutText (), ThemeEngine.Current.MenuFont);
- item.rect.Width += MENU_TAB_SPACE + (int) size.Width;
+ if (item.Shortcut != Shortcut.None && item.ShowShortcut) {
+ 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.rect.Width += 4 + (ThemeEngine.Current.MenuCheckSize.Width * 2);
- }
- else {
- item.rect.Width += MENU_BAR_ITEMS_SPACE;
- x += item.rect.Width;
+ item.Width += 4 + (MenuCheckSize.Width * 2);
+ } else {
+ item.Width += MENU_BAR_ITEMS_SPACE;
+ x += item.Width;
}
- if (item.rect.Height < ThemeEngine.Current.MenuHeight)
- item.rect.Height = ThemeEngine.Current.MenuHeight;
- }
+ if (item.Height < MenuHeight)
+ item.Height = MenuHeight;
+ }
}
// Updates the menu rect and returns the height
- public override int CalcMenuBarSize (Graphics dc, IntPtr hMenu, int width)
+ public override int CalcMenuBarSize (Graphics dc, Menu menu, int width)
{
int x = 0;
- int i = 0;
int y = 0;
- MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);
menu.Height = 0;
- MenuAPI.MENUITEM item;
- while (i < menu.items.Count) {
+ foreach (MenuItem item in menu.MenuItems) {
- item = (MenuAPI.MENUITEM) menu.items[i];
CalcItemSize (dc, item, y, x, true);
- i = i + 1;
- if (x + item.rect.Width > width) {
- item.rect.X = 0;
- y += item.rect.Height;
- item.rect.Y = y;
+ if (x + item.Width > width) {
+ item.X = 0;
+ y += item.Height;
+ item.Y = y;
x = 0;
}
- x += item.rect.Width;
- item.item.MenuBar = true;
+ x += item.Width;
+ item.MenuBar = true;
- if (y + item.rect.Height > menu.Height)
- menu.Height = item.rect.Height + y;
+ if (y + item.Height > menu.Height)
+ menu.Height = item.Height + y;
}
menu.Width = width;
return menu.Height;
}
-
- public override void CalcPopupMenuSize (Graphics dc, IntPtr hMenu)
+ public override void CalcPopupMenuSize (Graphics dc, Menu menu)
{
int x = 3;
int start = 0;
int i, n, y, max;
- MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);
menu.Height = 0;
- while (start < menu.items.Count) {
+ while (start < menu.MenuItems.Count) {
y = 2;
max = 0;
- for (i = start; i < menu.items.Count; i++) {
- MenuAPI.MENUITEM item = (MenuAPI.MENUITEM) menu.items[i];
+ for (i = start; i < menu.MenuItems.Count; i++) {
+ MenuItem item = menu.MenuItems [i];
- if ((i != start) && (item.item.Break || item.item.BarBreak))
+ if ((i != start) && (item.Break || item.BarBreak))
break;
CalcItemSize (dc, item, y, x, false);
- y += item.rect.Height;
+ y += item.Height;
- if (item.rect.Width > max)
- max = item.rect.Width;
+ if (item.Width > max)
+ max = item.Width;
}
- // Reemplace the -1 by the menu width (separators)
- for (n = start; n < i; n++, start++) {
- MenuAPI.MENUITEM item = (MenuAPI.MENUITEM) menu.items[n];
- item.rect.Width = max;
- }
+ // Replace the -1 by the menu width (separators)
+ for (n = start; n < i; n++, start++)
+ menu.MenuItems [n].Width = max;
if (y > menu.Height)
menu.Height = y;
}
// Draws a menu bar in a window
- public override void DrawMenuBar (Graphics dc, IntPtr hMenu, Rectangle rect)
+ public override void DrawMenuBar (Graphics dc, Menu menu, Rectangle rect)
{
- MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);
- Rectangle item_rect;
-
if (menu.Height == 0)
- ThemeEngine.Current.CalcMenuBarSize (dc, hMenu, 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_menubar_text.HotkeyPrefix = hp;
+ 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.items.Count; i++) {
- MenuAPI.MENUITEM it = (MenuAPI.MENUITEM) menu.items[i];
- item_rect = it.rect;
+ for (int i = 0; i < menu.MenuItems.Count; i++) {
+ MenuItem item = menu.MenuItems [i];
+ Rectangle item_rect = item.bounds;
item_rect.X += rect.X;
item_rect.Y += rect.Y;
- it.item.MenuHeight = menu.Height;
- it.item.PerformDrawItem (new DrawItemEventArgs (dc, ThemeEngine.Current.MenuFont,
- item_rect, i, it.item.Status));
-
+ item.MenuHeight = menu.Height;
+ item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont, item_rect, i, item.Status));
}
}
if (item.Visible == false)
return;
- if (item.MenuBar) {
+ if (item.MenuBar)
string_format = string_format_menu_menubar_text;
- }
- else {
+ else
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;
- }
- else {
- color_text = ThemeEngine.Current.ColorMenuText;
- color_back = ThemeEngine.Current.ColorMenu;
+ color_text = ColorHighlightText;
+ color_back = ColorHighlight;
+ } else {
+ 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 {
+ } else {
ControlPaint.DrawStringDisabled (e.Graphics, item.Text, e.Font,
Color.Black, rect_text, string_format);
}
/* Draw arrow */
- if (item.MenuBar == false && item.IsPopup) {
+ if (item.MenuBar == false && item.IsPopup || item.MdiList) {
- int cx = ThemeEngine.Current.MenuCheckSize.Width;
- int cy = ThemeEngine.Current.MenuCheckSize.Height;
+ int cx = MenuCheckSize.Width;
+ int cy = MenuCheckSize.Height;
Bitmap bmp = new Bitmap (cx, cy);
Graphics gr = Graphics.FromImage (bmp);
Rectangle rect_arrow = new Rectangle (0, 0, cx, cy);
if (item.MenuBar == false && item.Checked) {
Rectangle area = e.Bounds;
- int cx = ThemeEngine.Current.MenuCheckSize.Width;
- int cy = ThemeEngine.Current.MenuCheckSize.Height;
+ int cx = MenuCheckSize.Width;
+ int cy = MenuCheckSize.Height;
Bitmap bmp = new Bitmap (cx, cy);
Graphics gr = Graphics.FromImage (bmp);
Rectangle rect_arrow = new Rectangle (0, 0, cx, cy);
}
}
- public override void DrawPopupMenu (Graphics dc, IntPtr hMenu, Rectangle cliparea, Rectangle rect)
+ public override void DrawPopupMenu (Graphics dc, Menu menu, Rectangle cliparea, Rectangle rect)
{
- MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);
- 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.items.Count; i++)
- if (cliparea.IntersectsWith (((MenuAPI.MENUITEM) menu.items[i]).rect)) {
- MenuAPI.MENUITEM it = (MenuAPI.MENUITEM) menu.items[i];
- it.item.MenuHeight = menu.Height;
- it.item.PerformDrawItem (new DrawItemEventArgs (dc, ThemeEngine.Current.MenuFont,
- it.rect, i, it.item.Status));
+ for (int i = 0; i < menu.MenuItems.Count; i++)
+ if (cliparea.IntersectsWith (menu.MenuItems [i].bounds)) {
+ MenuItem item = menu.MenuItems [i];
+ item.MenuHeight = menu.Height;
+ item.PerformDrawItem (new DrawItemEventArgs (dc, MenuFont,
+ item.bounds, i, item.Status));
}
}
Math.Max(client_rectangle.Width - today_offset, 0),
date_cell_size.Height);
dc.DrawString ("Today: " + DateTime.Now.ToShortDateString(), bold_font, ResPool.GetSolidBrush (mc.ForeColor), today_rect, text_format);
+ text_format.Dispose ();
+ bold_font.Dispose ();
}
}
rectangle.X + date_cell_size.Width - 1,
rectangle.Y + title_size.Height + date_cell_size.Height + (month_row_count * date_cell_size.Height) - mc.divider_line_offset);
}
+ text_format.Dispose ();
}
// draws the pervious or next button
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);
dc.DrawRectangle (pen, interior);
}
}
+ text_format.Dispose ();
}
private void DrawTodayCircle (Graphics dc, Rectangle rectangle) {
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);
RadioButton_DrawText(radio_button, text_rectangle, dc, text_format);
RadioButton_DrawFocus(radio_button, dc, text_rectangle);
+ text_format.Dispose ();
}
protected virtual void RadioButton_DrawButton(RadioButton radio_button, Graphics dc, ButtonState state, Rectangle radiobutton_rectangle)
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 {
}
// renders a radio button with the Flat and Popup FlatStyle
- private void DrawFlatStyleRadioButton (Graphics graphics, Rectangle rectangle, RadioButton radio_button)
+ protected void DrawFlatStyleRadioButton (Graphics graphics, Rectangle rectangle, RadioButton radio_button)
{
int lineWidth;
if ( intersect != Rectangle.Empty )
{
- Brush h = ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, ColorWindow);
+ Brush h = ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White);
dc.FillRectangle( h, intersect );
}
}
Rectangle intersect = Rectangle.Intersect( clip, r );
if ( intersect != Rectangle.Empty )
- dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, ColorWindow ), intersect );
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White ), intersect );
r.X = 0;
r.Y = thumb_pos.Y + thumb_pos.Height;
intersect = Rectangle.Intersect( clip, r );
if ( intersect != Rectangle.Empty )
- dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, ColorWindow), intersect );
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
}
protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_None( int scrollbutton_width, ScrollBar bar, Rectangle clip, Graphics dc )
Rectangle intersect = Rectangle.Intersect( clip, r );
if ( intersect != Rectangle.Empty )
- dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, ColorWindow), intersect );
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
}
protected virtual void ScrollBar_Horizontal_Draw_ThumbMoving_Forward( int scrollbutton_width, Rectangle thumb_pos, ScrollBar bar, Rectangle clip, Graphics dc )
Rectangle intersect = Rectangle.Intersect( clip, r );
if ( intersect != Rectangle.Empty )
- dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, ColorWindow ), intersect );
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
r.X = thumb_pos.X + thumb_pos.Width;
r.Y = 0;
intersect = Rectangle.Intersect( clip, r );
if ( intersect != Rectangle.Empty )
- dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, ColorWindow), intersect );
+ dc.FillRectangle( ResPool.GetHatchBrush( HatchStyle.Percent50, ColorScrollBar, Color.White), intersect );
}
public override int ScrollBarButtonSize {
dc.DrawString (text, sb.Font, ResPool.GetSolidBrush (sb.ForeColor),
new Rectangle(area.X + 2, area.Y + 2, area.Width - 4, area.Height - 4), string_format);
+ string_format.Dispose ();
} else if (sb.ShowPanels) {
SolidBrush br_forecolor = GetControlForeBrush (sb.ForeColor);
int prev_x = area.X + horz_border;
Border3DStyle border_style = Border3DStyle.SunkenInner;
if (panel.BorderStyle == StatusBarPanelBorderStyle.Raised)
border_style = Border3DStyle.RaisedOuter;
- CPDrawBorder3D(dc, area, border_style, Border3DSide.All, ColorControl);
+ CPDrawBorder3D(dc, area, border_style, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, panel.Parent.BackColor);
}
if (panel.Style == StatusBarPanelStyle.OwnerDraw) {
area.Bottom - y - border_size);
dc.DrawString (text, panel.Parent.Font, br_forecolor, r, string_format);
+ string_format.Dispose ();
}
public override int StatusBarSizeGripWidth {
protected virtual int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
{
- int FlatButtonSpacing = 8;
+ int FlatButtonSpacing = 8;
Rectangle interior;
int res = bounds.Width;
+
+
// we can't fill the background right away because the bounds might be adjusted if the tab is selected
+ StringFormat string_format = new StringFormat ();
if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) {
-
dc.FillRectangle (GetControlBackBrush (tab.BackColor), bounds);
// Separators
}
if (is_selected) {
- CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.All);
+ CPDrawBorder3D (dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
} else if (tab.Appearance != TabAppearance.FlatButtons) {
- CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.All);
+ CPDrawBorder3D (dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom);
}
interior = new Rectangle (bounds.Left + 2, bounds.Top + 2, bounds.Width - 4, bounds.Height - 4);
- StringFormat string_format = new StringFormat ();
string_format.Alignment = StringAlignment.Center;
string_format.LineAlignment = StringAlignment.Center;
string_format.FormatFlags = StringFormatFlags.NoWrap;
-
- interior.Y++;
- dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
- interior.Y--;
} else {
Pen light = ResPool.GetPen (ControlPaint.LightLight (tab.BackColor));
interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
- if (page.Text != String.Empty) {
- StringFormat string_format = new StringFormat ();
- string_format.Alignment = StringAlignment.Center;
- string_format.LineAlignment = StringAlignment.Center;
- string_format.FormatFlags = StringFormatFlags.NoWrap;
- interior.Y++;
- dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
- interior.Y--;
- }
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
break;
interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
- if (page.Text != String.Empty) {
- StringFormat string_format = new StringFormat ();
- string_format.Alignment = StringAlignment.Center;
- string_format.LineAlignment = StringAlignment.Center;
- string_format.FormatFlags = StringFormatFlags.NoWrap;
- interior.Y++;
- dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
- interior.Y--;
- }
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
break;
interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
- if (page.Text != String.Empty) {
- StringFormat string_format = new StringFormat ();
- // Flip the text around
- string_format.Alignment = StringAlignment.Center;
- string_format.LineAlignment = StringAlignment.Center;
- string_format.FormatFlags = StringFormatFlags.NoWrap;
- string_format.FormatFlags = StringFormatFlags.DirectionVertical;
- int wo = interior.Width / 2;
- int ho = interior.Height / 2;
- dc.TranslateTransform (interior.X + wo, interior.Y + ho);
- dc.RotateTransform (180);
- dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
- dc.ResetTransform ();
- }
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ string_format.FormatFlags = StringFormatFlags.DirectionVertical;
break;
interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
- if (page.Text != String.Empty) {
- StringFormat string_format = new StringFormat ();
- string_format.Alignment = StringAlignment.Center;
- string_format.LineAlignment = StringAlignment.Center;
- string_format.FormatFlags = StringFormatFlags.NoWrap;
- string_format.FormatFlags = StringFormatFlags.DirectionVertical;
- interior.X++;
- dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
- interior.X--;
- }
+ string_format.Alignment = StringAlignment.Center;
+ string_format.LineAlignment = StringAlignment.Center;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+ string_format.FormatFlags = StringFormatFlags.DirectionVertical;
break;
}
}
- if (page.Focused) {
+ if (tab.DrawMode == TabDrawMode.Normal && page.Text != null) {
+ if (tab.Alignment == TabAlignment.Left) {
+ int wo = interior.Width / 2;
+ int ho = interior.Height / 2;
+ dc.TranslateTransform (interior.X + wo, interior.Y + ho);
+ dc.RotateTransform (180);
+ dc.DrawString (page.Text, page.Font, ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
+ dc.ResetTransform ();
+ } else {
+ dc.DrawString (page.Text, page.Font,
+ ResPool.GetSolidBrush (SystemColors.ControlText),
+ interior, string_format);
+ }
+ } else if (page.Text != null) {
+ DrawItemState state = DrawItemState.None;
+ if (page == tab.SelectedTab)
+ state |= DrawItemState.Selected;
+ DrawItemEventArgs e = new DrawItemEventArgs (dc,
+ tab.Font, bounds, tab.IndexForTabPage (page),
+ state, page.ForeColor, page.BackColor);
+ tab.OnDrawItemInternal (e);
+ return res;
+ }
+
+ if (page.parent.Focused && is_selected) {
CPDrawFocusRectangle (dc, interior, tab.ForeColor, tab.BackColor);
}
/* 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);
+ CPDrawBorder3D (dc, buttonArea, Border3DStyle.SunkenOuter, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, ColorControl);
} else if (button.Hilight) {
dc.DrawRectangle (ResPool.GetPen (ColorControlText), buttonArea);
if (! ddRect.IsEmpty) {
else { // normal toolbar
if (button.Pushed || button.Pressed) {
CPDrawBorder3D (dc, buttonArea, Border3DStyle.SunkenInner,
- Border3DSide.All, ColorControl);
+ Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, ColorControl);
if (! ddRect.IsEmpty) {
CPDrawBorder3D (dc, ddRect, Border3DStyle.SunkenInner,
Border3DSide.Left, ColorControl);
}
else {
CPDrawBorder3D (dc, buttonArea, Border3DStyle.RaisedInner,
- Border3DSide.All, ColorControl);
+ Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom, ColorControl);
if (! ddRect.IsEmpty) {
CPDrawBorder3D (dc, ddRect, Border3DStyle.RaisedInner,
Border3DSide.Left, ColorControl);
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,
button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
imgRect.Height, button.ImageIndex);
else {
- dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorGrayText), imgRect);
ControlPaint.DrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
Border3DSide.Right | Border3DSide.Bottom);
}
button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
imgRect.Height, button.ImageIndex);
else {
- dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorGrayText), imgRect);
ControlPaint.DrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
Border3DSide.Right | Border3DSide.Bottom);
}
button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
imgRect.Height, button.ImageIndex);
else {
- dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorGrayText), imgRect);
CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
Border3DSide.Right | Border3DSide.Bottom, ColorControl);
}
button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
imgRect.Height, button.ImageIndex);
else {
- dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorGrayText), imgRect);
CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
Border3DSide.Right | Border3DSide.Bottom, ColorControl);
}
button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width, imgRect.Height,
button.ImageIndex);
else {
- dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorGrayText), imgRect);
CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
Border3DSide.Right | Border3DSide.Bottom, ColorControl);
}
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;
/* Draw 'arrows' for horizontal lines */
graphics.DrawLine(pen, rect.X+3, Y-1, rect.X+3, Y+1);
graphics.DrawLine(pen, rect.Right-3, Y-1, rect.Right-3, Y+1);
+ pen.Dispose ();
}
// make a rectange to trace around border of the button
Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
+#if NotUntilCairoIsFixed
Color colorBackInverted = Color.FromArgb (Math.Abs (backColor.R-255), Math.Abs (backColor.G-255), Math.Abs (backColor.B-255));
DashStyle oldStyle; // used for caching old penstyle
Pen pen = ResPool.GetPen (colorBackInverted);
-
+
oldStyle = pen.DashStyle;
pen.DashStyle = DashStyle.Dot;
+
graphics.DrawRectangle (pen, trace_rectangle);
pen.DashStyle = oldStyle;
+#else
+ CPDrawFocusRectangle(graphics, trace_rectangle, Color.Wheat, backColor);
+#endif
}
} 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);
}
/* 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);
-
- if (area.Width < 12 || area.Height < 12) /* Cannot see a thing at smaller sizes */
- return;
- /* Paint arrows */
- switch (type) {
- case ScrollButton.Up: {
- int x = area.X + (area.Width / 2) - 4;
- int y = area.Y + 9;
-
- for (int i = 0; i < 3; i++)
- if (enabled)
- dc.DrawLine (ResPool.GetPen (arrow_color), x + i, y - i, x + i + 6 - 2*i, y - i);
- else
- dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y - i, x + i + 6 - 2*i, y - i);
-
-
- dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
- x + 3, area.Y + 6, 1, 1);
-
- break;
+ // A lot of the following is adapted from the rewind project
+ Rectangle rect = new Rectangle (area.X - 3, area.Y - 3,
+ area.Width + 6, area.Height + 6);
+ int small_diam = rect.Width > rect.Height ? rect.Height : rect.Width;
+ if (rect.Width < rect.Height) {
+ rect.Y += (rect.Height - rect.Width) / 2;
+ rect.Height = small_diam;
+ } else if (rect.Width > rect.Height) {
+ rect.X += (rect.Width - rect.Height) / 2;
+ rect.Width = small_diam;
}
- case ScrollButton.Down: {
- int x = area.X + (area.Width / 2) - 5;
- int y = area.Y + 5;
- for (int i = 4; i != 0; i--)
- if (enabled)
- dc.DrawLine (ResPool.GetPen (arrow_color), x + i, y + i, x + i + 8 - 2*i, y + i);
- else
- dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y + i, x + i + 8 - 2*i, y + i);
+ small_diam -= 2;
-
- dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
- x + 4, y + 4, 1, 1);
- break;
- }
-
- case ScrollButton.Left: {
- int y = area.Y + (area.Height / 2) - 4;
- int x = area.X + 9;
+ int tri = 290 * small_diam / 1000 - 1;
+ if (tri == 0)
+ tri = 1;
- for (int i = 0; i < 3; i++)
- if (enabled)
- dc.DrawLine (ResPool.GetPen (arrow_color), x - i, y + i, x - i, y + i + 6 - 2*i);
- else
- dc.DrawLine (ResPool.GetPen (ColorGrayText), x - i, y + i, x - i, y + i + 6 - 2*i);
+ Point [] arrow = new Point [3];
+ for (int i = 0; i < 3; i++)
+ arrow [i] = new Point ();
- dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
- x - 3, y + 3, 1, 1);
+ switch(type) {
+ default:
+ case ScrollButton.Down:
+ arrow [2].X = rect.Left + 470 * small_diam / 1000 + 2;
+ arrow [2].Y = rect.Top + 687 * small_diam / 1000 + 1;
+ arrow [0].X = arrow [2].X - tri;
+ arrow [1].X = arrow [2].X + tri;
+ arrow [0].Y = arrow [1].Y = arrow [2].Y - tri;
break;
- }
- case ScrollButton.Right: {
- int y = area.Y + (area.Height / 2) - 5;
- int x = area.X + 5;
-
- for (int i = 4; i != 0; i--)
- if (enabled)
- dc.DrawLine (ResPool.GetPen (arrow_color), x + i, y + i, x + i, y + i + 8 - 2*i);
- else
- dc.DrawLine (ResPool.GetPen (ColorGrayText), x + i, y + i, x + i, y + i + 8 - 2*i);
+ case ScrollButton.Up:
+ arrow [2].X = rect.Left + 470 * small_diam / 1000 + 2;
+ arrow [2].Y = rect.Bottom - (687 * small_diam / 1000 + 1);
+ arrow [0].X = arrow [2].X - tri;
+ arrow [1].X = arrow [2].X + tri;
+ arrow [0].Y = arrow [1].Y = arrow [2].Y + tri;
+ break;
- dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
- x + 4, y + 4, 1, 1);
+ case ScrollButton.Left:
+ arrow [2].X = rect.Right - (687 * small_diam / 1000 + 1);
+ arrow [2].Y = rect.Top + 470 * small_diam / 1000 + 2;
+ arrow [0].Y = arrow [2].Y - tri;
+ arrow [1].Y = arrow [2].Y + tri;
+ 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;
+ arrow [0].Y = arrow [2].Y - tri;
+ arrow [1].Y = arrow [2].Y + tri;
+ arrow [0].X = arrow [1].X = arrow [2].X - tri;
break;
}
- default:
- break;
+ /* Draw the arrow */
+ if ((state & ButtonState.Inactive)!=0) {
+ dc.FillPolygon (SystemBrushes.ControlLightLight, arrow, FillMode.Winding);
+ for (int i = 0; i < 3; i++) {
+ arrow [i].X--;
+ arrow [i].Y--;
+ }
+
+ dc.FillPolygon (SystemBrushes.ControlDark, arrow, FillMode.Winding);
+ } else {
+ dc.FillPolygon (SystemBrushes.ControlText, arrow, FillMode.Winding);
}
}
-
public override void CPDrawSelectionFrame (Graphics graphics, bool active, Rectangle outsideRect, Rectangle insideRect,
Color backColor) {
public override void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
StringFormat format) {
- layoutRectangle.Offset(1.0f, 1.0f);
- graphics.DrawString(s, font, ResPool.GetSolidBrush (ControlPaint.Light(color, 95)), layoutRectangle, format);
- layoutRectangle.Offset(-1.0f, -1.0f);
- graphics.DrawString(s, font, ResPool.GetSolidBrush (ControlPaint.Light(color, 50)), 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();