// 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 Novell, Inc.
+// Copyright (c) 2004-2005 Novell, Inc.
//
// Authors:
// Jordi Mas i Hernandez, jordi@ximian.com
static readonly Color arrow_color = Color.Black;
static readonly Color pen_ticks_color = Color.Black;
static readonly Color progressbarblock_color = Color.FromArgb (255, 0, 0, 128);
+ static StringFormat string_format_menu_text;
+ static StringFormat string_format_menu_shortcut;
+ static StringFormat string_format_menu_menubar_text;
+ static readonly Rectangle checkbox_rect = new Rectangle (2, 2, 11,11); // Position of the checkbox relative to the item
+ static ImageAttributes imagedisabled_attributes = null;
+ const int SEPARATOR_HEIGHT = 5;
+ const int SM_CXBORDER = 1;
+ const int SM_CYBORDER = 1;
+ const int MENU_TAB_SPACE = 8; // Pixels added to the width of an item because of a tab
+ const int MENU_BAR_ITEMS_SPACE = 8; // Space between menu bar items
#region Principal Theme Methods
public ThemeWin32Classic ()
defaultWindowBackColor = SystemColors.Window;
defaultWindowForeColor = ColorButtonText;
default_font = new Font (FontFamily.GenericSansSerif, 8.25f);
+
+ /* Menu string formats */
+ string_format_menu_text = new StringFormat ();
+ string_format_menu_text.LineAlignment = StringAlignment.Center;
+ string_format_menu_text.Alignment = StringAlignment.Near;
+ string_format_menu_text.HotkeyPrefix = HotkeyPrefix.Show;
+
+ string_format_menu_shortcut = new StringFormat ();
+ string_format_menu_shortcut.LineAlignment = StringAlignment.Center;
+ string_format_menu_shortcut.Alignment = StringAlignment.Far;
+
+ string_format_menu_menubar_text = new StringFormat ();
+ string_format_menu_menubar_text.LineAlignment = StringAlignment.Center;
+ string_format_menu_menubar_text.Alignment = StringAlignment.Center;
+ string_format_menu_menubar_text.HotkeyPrefix = HotkeyPrefix.Show;
}
public override void ResetDefaults() {
// Start drawing
-
- sb=new SolidBrush(checkbox.BackColor);
- dc.FillRectangle(sb, checkbox.ClientRectangle);
- sb.Dispose();
+ dc.FillRectangle (ResPool.GetSolidBrush (checkbox.BackColor), checkbox.ClientRectangle);
// render as per normal button
if (checkbox.appearance==Appearance.Button) {
if (checkbox.FlatStyle == FlatStyle.Flat || checkbox.FlatStyle == FlatStyle.Popup) {
if (checkbox.Focused) {
if (checkbox.FlatStyle != FlatStyle.Flat) {
- DrawInnerFocusRectangle (dc, Rectangle.Inflate (client_rectangle, -4, -4), checkbox.BackColor);
+ DrawInnerFocusRectangle (dc, Rectangle.Inflate (text_rectangle, -1, -1), checkbox.BackColor);
} else {
- dc.DrawRectangle (ResPool.GetPen (checkbox.ForeColor), Rectangle.Inflate (client_rectangle, -4, -4));
+ dc.DrawRectangle (ResPool.GetPen (checkbox.ForeColor), Rectangle.Inflate (text_rectangle, -1, -1));
}
}
}
#endregion // CheckBox
+ #region CheckedListBox
+
+ public override Rectangle CheckedListBoxCheckRectangle ()
+ {
+ return checkbox_rect;
+ }
+
+ public override void DrawCheckedListBoxItem (CheckedListBox ctrl, DrawItemEventArgs e)
+ {
+ Color back_color, fore_color;
+ Rectangle item_rect = e.Bounds;
+ ButtonState state;
+ StringFormat string_format = ctrl.GetFormatString ();
+
+ /* Draw checkbox */
+
+ if ((ctrl.Items.GetListBoxItem (e.Index)).State == CheckState.Checked)
+ state = ButtonState.Checked;
+ else
+ state = ButtonState.Normal;
+
+ if (ctrl.ThreeDCheckBoxes == false)
+ state |= ButtonState.Flat;
+
+ ControlPaint.DrawCheckBox (e.Graphics,
+ item_rect.X + checkbox_rect.X, item_rect.Y + checkbox_rect.Y,
+ checkbox_rect.Width, checkbox_rect.Height,
+ state);
+
+ item_rect.X += checkbox_rect.Width + checkbox_rect.X * 2;
+ item_rect.Width -= checkbox_rect.Width + checkbox_rect.X * 2;
+
+ /* Draw text*/
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ back_color = ThemeEngine.Current.ColorHilight;
+ fore_color = ThemeEngine.Current.ColorHilightText;
+ }
+ else {
+ back_color = e.BackColor;
+ fore_color = e.ForeColor;
+ }
+
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
+ (back_color), item_rect);
+
+ e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
+ ThemeEngine.Current.ResPool.GetSolidBrush (fore_color),
+ item_rect, string_format);
+
+ if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
+ ThemeEngine.Current.CPDrawFocusRectangle (e.Graphics, item_rect,
+ fore_color, back_color);
+ }
+ }
+
+ #endregion // CheckedListBox
+
#region ComboBox
// Drawing
}
}
+ public override void DrawComboBoxItem (ComboBox ctrl, DrawItemEventArgs e)
+ {
+ Color back_color, fore_color;
+ Rectangle text_draw = e.Bounds;
+ StringFormat string_format = new StringFormat ();
+ string_format.FormatFlags = StringFormatFlags.LineLimit;
+
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ back_color = ThemeEngine.Current.ColorHilight;
+ fore_color = ThemeEngine.Current.ColorHilightText;
+ }
+ else {
+ back_color = e.BackColor;
+ fore_color = e.ForeColor;
+ }
+
+ e.Graphics.FillRectangle (ThemeEngine.Current.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),
+ text_draw, string_format);
+ }
+
+ if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
+ ThemeEngine.Current.CPDrawFocusRectangle (e.Graphics, e.Bounds, fore_color, back_color);
+ }
+ }
+
#endregion ComboBox
+ #region Datagrid
+ public override int DataGridPreferredColumnWidth { get { return 75;} }
+ public override int DataGridMinimumColumnCheckBoxHeight { get { return 16;} }
+ public override int DataGridMinimumColumnCheckBoxWidth { get { return 16;} }
+ public override Color DataGridAlternatingBackColor { get { return ColorWindow;} }
+ public override Color DataGridBackgroundColor { get { return ColorWindow;} }
+ public override Color DataGridCaptionBackColor { get { return ColorActiveTitle;} }
+ public override Color DataGridCaptionForeColor { get { return SystemColors.ActiveCaptionText;} }
+ public override Color DataGridGridLineColor { get { return SystemColors.Control;} }
+ public override Color DataGridHeaderBackColor { get { return SystemColors.Control;} }
+ public override Color DataGridHeaderForeColor { get { return SystemColors.ControlText;} }
+ public override Color DataGridLinkColor { get { return SystemColors.HotTrack;} }
+ public override Color DataGridLinkHoverColor { get { return SystemColors.HotTrack;} }
+ public override Color DataGridParentRowsBackColor { get { return SystemColors.Control;} }
+ public override Color DataGridParentRowsForeColor { get { return SystemColors.WindowText;} }
+ public override Color DataGridSelectionBackColor { get { return ColorActiveTitle;} }
+ public override Color DataGridSelectionForeColor { get { return ColorTitleText;} }
+ #endregion // Datagrid
+
#region DateTimePicker
public override void DrawDateTimePicker (Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp) {
#region GroupBox
public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box) {
- SizeF size;
- int width, y;
- Rectangle rect = box.ClientRectangle;
+ StringFormat text_format;
+ SizeF size;
+ int width;
+ int y;
+ Rectangle rect;
+
+ rect = box.ClientRectangle;
+
// Needed once the Dark/Light code below is enabled again
//Color disabled = ColorGrayText;
dc.FillRectangle (ResPool.GetSolidBrush (box.BackColor), rect);
+ text_format = new StringFormat();
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
+
size = dc.MeasureString (box.Text, box.Font);
width = (int) size.Width;
/* Text */
- if (box.Enabled)
- dc.DrawString (box.Text, box.Font, new SolidBrush (box.ForeColor), 10, 0);
- else
+ if (box.Enabled) {
+ dc.DrawString (box.Text, box.Font, new SolidBrush (box.ForeColor), 10, 0, text_format);
+ } else {
CPDrawStringDisabled (dc, box.Text, box.Font, box.ForeColor,
- new RectangleF (10, 0, width, box.Font.Height), new StringFormat ());
+ new RectangleF (10, 0, width, box.Font.Height), text_format);
+ }
}
{
dc.FillRectangle (ResPool.GetSolidBrush (label.BackColor), clip_rectangle);
- CPDrawBorderStyle (dc, clip_rectangle, label.BorderStyle);
+ CPDrawBorderStyle (dc, label.ClientRectangle, label.BorderStyle);
if (label.Enabled) {
dc.DrawString (label.Text, label.Font, ResPool.GetSolidBrush (label.ForeColor), clip_rectangle, label.string_format);
return new Size (100, 23);
}
}
- #endregion // Label
-
+ #endregion // Label\r
+\r
+ #region LinkLabel\r
+ public override void DrawLinkLabel (Graphics dc, Rectangle clip_rectangle, LinkLabel label)\r
+ {\r
+ Color color;\r
+\r
+ dc.FillRectangle (ResPool.GetSolidBrush (label.BackColor), clip_rectangle);\r
+ CPDrawBorderStyle (dc, label.ClientRectangle, label.BorderStyle);
+\r
+ for (int i = 0; i < label.num_pieces; i++) {
+
+ if (clip_rectangle.IntersectsWith (label.pieces[i].rect) == false) {
+ continue;
+ }
+ \r
+ color = label.GetLinkColor (label.pieces[i], i);\r
+\r
+ if (label.pieces[i].link == null)\r
+ dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (Color.Black),\r
+ label.pieces[i].rect.X, label.pieces[i].rect.Y);\r
+ else\r
+ dc.DrawString (label.pieces[i].text, label.GetPieceFont (label.pieces[i]), ResPool.GetSolidBrush (color),\r
+ 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);
+ }\r
+ }
+ \r
+ }\r
+ #endregion // LinkLabel\r
#region ListBox
- // Drawing
-
+ // Drawing
public override void DrawListBoxDecorations (Graphics dc, ListBox ctrl)
{
Rectangle cl = ctrl.LBoxInfo.client_rect;
public override int DrawListBoxDecorationRight (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
public override int DrawListBoxDecorationLeft (BorderStyle border_style) { return DrawListBoxDecorationSize (border_style);}
+ public override void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e)
+ {
+ Color back_color, fore_color;
+ StringFormat string_format = ctrl.GetFormatString ();
+
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ back_color = ThemeEngine.Current.ColorHilight;
+ fore_color = ThemeEngine.Current.ColorHilightText;
+ }
+ else {
+ back_color = e.BackColor;
+ fore_color = e.ForeColor;
+ }
+
+ e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
+ (back_color), e.Bounds);
+
+ e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font,
+ ThemeEngine.Current.ResPool.GetSolidBrush (fore_color),
+ e.Bounds, string_format);
+
+ if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) {
+ ThemeEngine.Current.CPDrawFocusRectangle (e.Graphics, e.Bounds,
+ fore_color, back_color);
+ }
+ }
+
#endregion ListBox
#region ListView
// Drawing
- public override void DrawListView (Graphics dc, Rectangle clip_rectangle, ListView control)
+ public override void DrawListView (Graphics dc, Rectangle clip, ListView control)
{
bool details = (control.View == View.Details);
- // Clear the graphics context
- dc.Clear (control.BackColor);
+ dc.FillRectangle (ResPool.GetSolidBrush (control.BackColor), clip);
// border is drawn directly in the Paint method
if (details && control.HeaderStyle != ColumnHeaderStyle.None) {
dc.FillRectangle (ResPool.GetSolidBrush (SystemColors.Control),
- 0, 0, control.TotalWidth, control.Font.Height);
+ 0, 0, control.TotalWidth, control.Font.Height + 5);
if (control.Columns.Count > 0) {
if (control.HeaderStyle == ColumnHeaderStyle.Clickable) {
foreach (ColumnHeader col in control.Columns) {
(col.Pressed ?
ButtonState.Pushed :
ButtonState.Normal));
- dc.DrawString (col.Text, control.Font,
+ dc.DrawString (col.Text, ThemeEngine.Current.DefaultFont,
ResPool.GetSolidBrush
(this.ColorButtonText),
- col.Rect, col.Format);
+ //col.Rect,
+ col.Rect.X + 3,
+ col.Rect.Y + col.Rect.Height/2 + 1,
+ col.Format);
}
}
// Non-clickable columns
else {
foreach (ColumnHeader col in control.Columns) {
this.CPDrawButton (dc, col.Rect, ButtonState.Flat);
- dc.DrawString (col.Text, control.Font,
+ dc.DrawString (col.Text, ThemeEngine.Current.DefaultFont,
ResPool.GetSolidBrush
(this.ColorButtonText),
- col.Rect, col.Format);
+ //col.Rect,
+ col.Rect.X + 3,
+ col.Rect.Y + col.Rect.Height/2 + 1,
+ col.Format);
}
}
}
// In case of details view draw the items only if
// columns are non-zero
if (!details || control.Columns.Count > 0)
- foreach (ListViewItem item in control.Items)
- this.DrawListViewItem (dc, control, item);
+ foreach (ListViewItem item in control.Items) {
+ if (clip.IntersectsWith (item.EntireRect))
+ DrawListViewItem (dc, control, item);
+ }
// draw the gridlines
if (details && control.GridLines) {
get { return new Size (121, 97); }
}
#endregion // ListView
+
+ #region Menus
+ public override void CalcItemSize (Graphics dc, MenuAPI.MENUITEM item, int y, int x, bool menuBar)
+ {
+ item.rect.Y = y;
+ item.rect.X = x;
+
+ if (item.item.Visible == false)
+ return;
+
+ if (item.item.Separator == true) {
+ item.rect.Height = SEPARATOR_HEIGHT / 2;
+ item.rect.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;
+ 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;
+
+ 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;
+ }
+
+ item.rect.Width += 4 + (ThemeEngine.Current.MenuCheckSize.Width * 2);
+ }
+ else {
+ item.rect.Width += MENU_BAR_ITEMS_SPACE;
+ x += item.rect.Width;
+ }
+
+ if (item.rect.Height < ThemeEngine.Current.MenuHeight)
+ item.rect.Height = ThemeEngine.Current.MenuHeight;
+ }
+ }
+
+ // Updates the menu rect and returns the height
+ public override int CalcMenuBarSize (Graphics dc, IntPtr hMenu, 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) {
+
+ 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;
+ x = 0;
+ }
+
+ x += item.rect.Width;
+ item.item.MenuBar = true;
+
+ if (y + item.rect.Height > menu.Height)
+ menu.Height = item.rect.Height + y;
+ }
+
+ menu.Width = width;
+ return menu.Height;
+ }
+
+
+ public override void CalcPopupMenuSize (Graphics dc, IntPtr hMenu)
+ {
+ 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) {
+ y = 2;
+ max = 0;
+ for (i = start; i < menu.items.Count; i++) {
+ MenuAPI.MENUITEM item = (MenuAPI.MENUITEM) menu.items[i];
+
+ if ((i != start) && (item.item.Break || item.item.BarBreak))
+ break;
+
+ CalcItemSize (dc, item, y, x, false);
+ y += item.rect.Height;
+
+ if (item.rect.Width > max)
+ max = item.rect.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;
+ }
+
+ if (y > menu.Height)
+ menu.Height = y;
+
+ x+= max;
+ }
+
+ menu.Width = x;
+
+ //space for border
+ menu.Width += 2;
+ menu.Height += 2;
+
+ menu.Width += SM_CXBORDER;
+ menu.Height += SM_CYBORDER;
+ }
+
+ // Draws a menu bar in a window
+ public override void DrawMenuBar (Graphics dc, IntPtr hMenu, Rectangle rect)
+ {
+ MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);
+ Rectangle item_rect;
+
+ if (menu.Height == 0)
+ ThemeEngine.Current.CalcMenuBarSize (dc, hMenu, rect.Width);
+
+ rect.Height = menu.Height;
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (menu.Wnd.BackColor), rect);
+
+ for (int i = 0; i < menu.items.Count; i++) {
+ MenuAPI.MENUITEM it = (MenuAPI.MENUITEM) menu.items[i];
+ item_rect = it.rect;
+ 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));
+
+ }
+ }
+
+ public override void DrawMenuItem (MenuItem item, DrawItemEventArgs e)
+ {
+ StringFormat string_format;
+ Rectangle rect_text = e.Bounds;
+
+ if (item.Visible == false)
+ return;
+
+ if (item.MenuBar) {
+ string_format = string_format_menu_menubar_text;
+ }
+ else {
+ string_format = string_format_menu_text;
+ }
+
+ if (item.Separator == true) {
+ e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+ e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y);
+
+ e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonHilight),
+ 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;
+
+ if (item.BarBreak) { /* Draw vertical break bar*/
+ Rectangle rect = e.Bounds;
+ rect.Y++;
+ rect.Width = 3;
+ rect.Height = item.MenuHeight - 6;
+
+ e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+ rect.X, rect.Y , rect.X, rect.Y + rect.Height);
+
+ e.Graphics.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonHilight),
+ rect.X + 1, rect.Y , rect.X +1, rect.Y + rect.Height);
+ }
+
+ Color color_text;
+ Color color_back;
+
+ if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
+ color_text = ThemeEngine.Current.ColorHilightText;
+ color_back = ThemeEngine.Current.ColorHilight;
+ }
+ else {
+ color_text = ThemeEngine.Current.ColorMenuText;
+ color_back = ThemeEngine.Current.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);
+
+ if (item.Enabled) {
+ e.Graphics.DrawString (item.Text, e.Font,
+ ThemeEngine.Current.ResPool.GetSolidBrush (color_text),
+ rect_text, string_format);
+
+ if (!item.MenuBar && item.Shortcut != Shortcut.None && item.ShowShortcut) {
+ string str = item.GetShortCutText ();
+ Rectangle rect = rect_text;
+ rect.X = item.XTab;
+ rect.Width -= item.XTab;
+
+ e.Graphics.DrawString (str, e.Font, ThemeEngine.Current.ResPool.GetSolidBrush (color_text),
+ rect, string_format_menu_shortcut);
+ }
+ }
+ else {
+ ControlPaint.DrawStringDisabled (e.Graphics, item.Text, e.Font,
+ Color.Black, rect_text, string_format);
+ }
+
+ /* Draw arrow */
+ if (item.MenuBar == false && item.IsPopup) {
+
+ 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 ();
+
+ if (item.Enabled) {
+ e.Graphics.DrawImage (bmp, e.Bounds.X + e.Bounds.Width - cx,
+ e.Bounds.Y + ((e.Bounds.Height - cy) /2));
+ } else {
+ ControlPaint.DrawImageDisabled (e.Graphics, bmp, e.Bounds.X + e.Bounds.Width - cx,
+ e.Bounds.Y + ((e.Bounds.Height - cy) /2), color_back);
+ }
+
+ gr.Dispose ();
+ bmp.Dispose ();
+ }
+
+ /* Draw checked or radio */
+ 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);
+
+ 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, IntPtr hMenu, Rectangle cliparea, Rectangle rect)
+ {
+ MenuAPI.MENU menu = MenuAPI.GetMenuFromID (hMenu);
+
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush
+ (ThemeEngine.Current.ColorMenu), cliparea);
+
+ /* Draw menu borders */
+ dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorHilightText),
+ rect.X, rect.Y, rect.X + rect.Width, rect.Y);
+
+ dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorHilightText),
+ rect.X, rect.Y, rect.X, rect.Y + rect.Height);
+
+ dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+ rect.X + rect.Width - 1 , rect.Y , rect.X + rect.Width - 1, rect.Y + rect.Height);
+
+ dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonDkShadow),
+ rect.X + rect.Width, rect.Y , rect.X + rect.Width, rect.Y + rect.Height);
+
+ dc.DrawLine (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorButtonShadow),
+ 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.ColorButtonDkShadow),
+ 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));
+ }
+ }
+
+ #endregion // Menus
#region MonthCalendar
#endregion // Panel
#region PictureBox
- public override void DrawPictureBox (Graphics dc, PictureBox pb) {
+ public override void DrawPictureBox (Graphics dc, Rectangle clip, PictureBox pb) {
Rectangle client = pb.ClientRectangle;
- int x, y, width, height;
-
- dc.FillRectangle (new SolidBrush (pb.BackColor), client);
- x = y = 0;
if (pb.Image != null) {
switch (pb.SizeMode) {
case PictureBoxSizeMode.StretchImage:
- width = client.Width;
- height = client.Height;
+ dc.DrawImage (pb.Image, 0, 0, client.Width, client.Height);
break;
+
case PictureBoxSizeMode.CenterImage:
- width = client.Width;
- height = client.Height;
- x = width / 2;
- y = (height - pb.Image.Height) / 2;
+ dc.DrawImage (pb.Image, (client.Width / 2) - (pb.Image.Width / 2), (client.Height / 2) - (pb.Image.Height / 2));
break;
default:
// Normal, AutoSize
- width = client.Width;
- height = client.Height;
+ dc.DrawImage(pb.Image, 0, 0);
break;
}
- dc.DrawImage (pb.Image, x, y, width, height);
}
CPDrawBorderStyle (dc, client, pb.BorderStyle);
}
#endregion // PictureBox
#region ProgressBar
- public override void DrawProgressBar (Graphics dc, Rectangle clip_rectangle, ProgressBar progress_bar) {
- Rectangle client_area = progress_bar.client_area;
- int space_betweenblocks = 2;
- int x;
+ public override void DrawProgressBar (Graphics dc, Rectangle clip_rect, ProgressBar ctrl)
+ {
+ Rectangle block_rect;
+ Rectangle client_area = ctrl.client_area;
+ int space_betweenblocks = 2;
int block_width;
int increment;
int barpos_pixels;
-
- x = client_area.X;
+
block_width = ((client_area.Height) * 2 ) / 3;
- barpos_pixels = ((progress_bar.Value - progress_bar.Minimum) * client_area.Width) / (progress_bar.Maximum - progress_bar.Minimum);
+ barpos_pixels = ((ctrl.Value - ctrl.Minimum) * client_area.Width) / (ctrl.Maximum - ctrl.Minimum);
increment = block_width + space_betweenblocks;
/* Draw border */
- CPDrawBorder3D (dc, progress_bar.paint_area, Border3DStyle.SunkenInner, Border3DSide.All, ColorButtonFace);
+ CPDrawBorder3D (dc, ctrl.ClientRectangle, Border3DStyle.SunkenInner, Border3DSide.All & ~Border3DSide.Middle, ColorButtonFace);
/* Draw Blocks */
- while ((x - client_area.X) < barpos_pixels) {
- dc.FillRectangle (ResPool.GetSolidBrush (progressbarblock_color), x, client_area.Y, block_width, client_area.Height);
- x = x + increment;
+ block_rect = new Rectangle (client_area.X, client_area.Y, block_width, client_area.Height);
+ while ((block_rect.X - client_area.X) < barpos_pixels) {
+
+ if (clip_rect.IntersectsWith (block_rect) == true) {
+ dc.FillRectangle (ResPool.GetSolidBrush (progressbarblock_color), block_rect);
+ }
+
+ block_rect.X += increment;
}
}
text_rectangle.Inflate(-4,-4);
}
- /* Place the text; to be compatible with Windows place it after the radiobutton has been drawn */
- sb=new SolidBrush(radio_button.ForeColor);
- dc.DrawString (radio_button.Text, radio_button.Font, sb, text_rectangle, text_format);
- sb.Dispose();
+ /* 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);
+
if (radio_button.Enabled) {
sb = ResPool.GetSolidBrush(radio_button.ForeColor);
dc.DrawString(radio_button.Text, radio_button.Font, sb, text_rectangle, text_format);
scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - (scrollbutton_height * 2));
Rectangle intersect = Rectangle.Intersect (clip, r);
- if (intersect != Rectangle.Empty)
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), intersect);
+ if (intersect != Rectangle.Empty) {
+ Brush h = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace);
+ dc.FillRectangle (h, intersect);
+ }
break;
}
case ScrollBar.ThumbMoving.Forward: {
#endregion // ScrollBar
#region StatusBar
- public override void DrawStatusBar (Graphics dc, Rectangle clip_rectangle, StatusBar sb) {
- Rectangle area = sb.paint_area;
- int horz_border = 2;
- int vert_border = 2;
+ public override void DrawStatusBar (Graphics dc, Rectangle clip, StatusBar sb) {
+ Rectangle area = sb.ClientRectangle;
+ int horz_border = 2;
+ int vert_border = 2;
- dc.FillRectangle (GetControlBackBrush (sb.BackColor), area);
+ dc.FillRectangle (GetControlBackBrush (sb.BackColor), clip);
- if (sb.ShowPanels && sb.Panels.Count == 0) {
- // Create a default panel.
- SolidBrush br_forecolor = GetControlForeBrush (sb.ForeColor);
-
- StatusBarPanel panel = new StatusBarPanel ();
- Rectangle new_area = new Rectangle (area.X + horz_border,
- area.Y + horz_border,
- area.Width - StatusBarSizeGripWidth - horz_border,
- area.Height - horz_border);
- DrawStatusBarPanel (dc, new_area, -1, br_forecolor, panel);
+ if (sb.Panels.Count == 0 && sb.Text != String.Empty) {
+ string text = sb.Text;
+ StringFormat string_format = new StringFormat ();
+ string_format.Trimming = StringTrimming.Character;
+ string_format.FormatFlags = StringFormatFlags.NoWrap;
+
+ if (text [0] == '\t') {
+ string_format.Alignment = StringAlignment.Center;
+ text = text.Substring (1);
+ if (text [0] == '\t') {
+ string_format.Alignment = StringAlignment.Far;
+ text = text.Substring (1);
+ }
+ }
+
+ 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);
} else if (sb.ShowPanels) {
SolidBrush br_forecolor = GetControlForeBrush (sb.ForeColor);
int prev_x = area.X + horz_border;
Rectangle pr = new Rectangle (prev_x, y,
sb.Panels [i].Width, area.Height);
prev_x += pr.Width + StatusBarHorzGapWidth;
- DrawStatusBarPanel (dc, pr, i, br_forecolor, sb.Panels [i]);
+ if (pr.IntersectsWith (clip))
+ DrawStatusBarPanel (dc, pr, i, br_forecolor, sb.Panels [i]);
}
}
}
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));
string_format.LineAlignment = StringAlignment.Center;
string_format.FormatFlags = StringFormatFlags.NoWrap;
interior.Y++;
- dc.DrawString (page.Text, page.Font, new SolidBrush (SystemColors.ControlText), interior, string_format);
+ dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
+ interior.Y--;
}
break;
string_format.LineAlignment = StringAlignment.Center;
string_format.FormatFlags = StringFormatFlags.NoWrap;
interior.Y++;
- dc.DrawString (page.Text, page.Font, new SolidBrush (SystemColors.ControlText), interior, string_format);
+ dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
+ interior.Y--;
}
break;
int ho = interior.Height / 2;
dc.TranslateTransform (interior.X + wo, interior.Y + ho);
dc.RotateTransform (180);
- dc.DrawString (page.Text, page.Font, new SolidBrush (SystemColors.ControlText), 0, 0, string_format);
+ dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
dc.ResetTransform ();
}
string_format.FormatFlags = StringFormatFlags.NoWrap;
string_format.FormatFlags = StringFormatFlags.DirectionVertical;
interior.X++;
- dc.DrawString (page.Text, page.Font, new SolidBrush (SystemColors.ControlText), interior, string_format);
+ dc.DrawString (page.Text, page.Font, ThemeEngine.Current.ResPool.GetSolidBrush (SystemColors.ControlText), interior, string_format);
+ interior.X--;
}
break;
}
if (page.Focused) {
- using (Pen pen = new Pen (Color.Black, 1) ) {
- pen.DashStyle = DashStyle.Dot;
- dc.DrawRectangle (pen, interior);
- }
+ CPDrawFocusRectangle (dc, interior, tab.ForeColor, tab.BackColor);
}
return res;
button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
imgRect.Height, button.ImageIndex);
else {
- dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ThemeEngine.Current.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 (new SolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ThemeEngine.Current.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 (new SolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
}
button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width,
imgRect.Height, button.ImageIndex);
else {
- dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
}
button.Parent.ImageList.Draw (dc, imgRect.X, imgRect.Y, imgRect.Width, imgRect.Height,
button.ImageIndex);
else {
- dc.FillRectangle (new SolidBrush (ColorGrayText), imgRect);
+ dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (ColorGrayText), imgRect);
CPDrawBorder3D (dc, imgRect, Border3DStyle.SunkenOuter,
Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
}
#endregion // ToolBar
#region ToolTip
- public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip tt) {
- Control control;
-
- control = tt.tooltip_window;
+ public override void DrawToolTip(Graphics dc, Rectangle clip_rectangle, ToolTip.ToolTipWindow control) {
dc.FillRectangle(ResPool.GetSolidBrush(this.ColorInfoWindow), control.client_rect);
dc.DrawRectangle(ResPool.GetPen(this.ColorWindowFrame), 0, 0, control.Width-1, control.Height-1);
- dc.DrawString(control.text, control.Font, ResPool.GetSolidBrush(this.ColorInfoText), control.client_rect, tt.tooltip_window.string_format);
+ dc.DrawString(control.text, control.Font, ResPool.GetSolidBrush(this.ColorInfoText), control.client_rect, control.string_format);
}
- public override Size ToolTipSize(ToolTip tt, string text) {
+ public override Size ToolTipSize(ToolTip.ToolTipWindow tt, string text) {
SizeF sizef;
- sizef = tt.tooltip_window.DeviceContext.MeasureString(text, tt.tooltip_window.Font);
+ sizef = tt.DeviceContext.MeasureString(text, tt.Font);
return new Size((int)sizef.Width+2, (int)sizef.Height+3); // Need space for the border
}
#endregion // ToolTip
#region TrackBar
- private void DrawTrackBar_Vertical (Graphics dc, Rectangle area, TrackBar tb,
+ private void DrawTrackBar_Vertical (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
float ticks, int value_pos, bool mouse_value) {
float pixel_len;
float pixels_betweenticks;
const int space_from_right = 8;
- const int space_from_left = 8;
+ const int space_from_left = 8;
+ Rectangle area = tb.ClientRectangle;
switch (tb.TickStyle) {
case TickStyle.BottomRight:
}
pixel_len = thumb_area.Height - 11;
- pixels_betweenticks = pixel_len / ticks;
+ pixels_betweenticks = pixel_len / ticks;
+
+ thumb_area.X = thumb_pos.X;
+ thumb_area.Y = channel_startpoint.Y;
+ thumb_area.Width = thumb_pos.Height;
/* Draw ticks*/
- if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
- ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-
- for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
- if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
- area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc);
- else
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
- area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc);
+ Region outside = new Region (area);
+ outside.Exclude (thumb_area);
+
+ if (outside.IsVisible (clip_rectangle)) {
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X , area.Y + bottomtick_startpoint.Y + inc,
+ area.X + bottomtick_startpoint.X + 3, area.Y + bottomtick_startpoint.Y + inc);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X, area.Y + bottomtick_startpoint.Y + inc,
+ area.X + bottomtick_startpoint.X + 2, area.Y + bottomtick_startpoint.Y + inc);
+ }
+ }
+
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ pixel_len = thumb_area.Height - 11;
+ pixels_betweenticks = pixel_len / ticks;
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
+ area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
+ area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
+ }
}
}
-
- if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
- ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-
- pixel_len = thumb_area.Height - 11;
- pixels_betweenticks = pixel_len / ticks;
-
- for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
- if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 3 , area.Y + toptick_startpoint.Y + inc,
- area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
- else
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X - 2, area.Y + toptick_startpoint.Y + inc,
- area.X + toptick_startpoint.X, area.Y + toptick_startpoint.Y + inc);
- }
- }
+
+ outside.Dispose ();
+
}
/*
- Ticks are draw at (channel.Witdh - 10) / (Maximum - Minimum)
*/
- private void DrawTrackBar_Horizontal (Graphics dc, Rectangle area, TrackBar tb,
+ private void DrawTrackBar_Horizontal (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
float ticks, int value_pos, bool mouse_value) {
Point toptick_startpoint = new Point ();
float pixel_len;
float pixels_betweenticks;
const int space_from_right = 8;
- const int space_from_left = 8;
+ const int space_from_left = 8;
+ Rectangle area = tb.ClientRectangle;
switch (tb.TickStyle) {
case TickStyle.BottomRight:
pixels_betweenticks = pixel_len / ticks;
/* Draw ticks*/
- if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
- ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-
- for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
- if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
- area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3);
- else
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
- area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2);
+ thumb_area.Y = thumb_pos.Y;
+ thumb_area.X = channel_startpoint.X;
+ thumb_area.Height = thumb_pos.Height;
+ Region outside = new Region (area);
+ outside.Exclude (thumb_area);
+
+ if (outside.IsVisible (clip_rectangle)) {
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y,
+ area.X + bottomtick_startpoint.X + inc , area.Y + bottomtick_startpoint.Y + 3);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y,
+ area.X + bottomtick_startpoint.X + inc, area.Y + bottomtick_startpoint.Y + 2);
+ }
+ }
+
+ if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
+ ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
+
+ for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
+ if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
+ area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y);
+ else
+ dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
+ area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
+ }
}
}
-
- if (pixels_betweenticks > 0 && ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft ||
- ((tb.TickStyle & TickStyle.Both) == TickStyle.Both))) {
-
- for (float inc = 0; inc < (pixel_len + 1); inc += pixels_betweenticks) {
- if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y - 3,
- area.X + toptick_startpoint.X + inc , area.Y + toptick_startpoint.Y);
- else
- dc.DrawLine (ResPool.GetPen (pen_ticks_color), area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y - 2,
- area.X + toptick_startpoint.X + inc, area.Y + toptick_startpoint.Y );
- }
- }
+
+ outside.Dispose ();
}
- public override void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb) {
-//public override void DrawTrackBar (Graphics dc,
-//Rectangle area,
-//TrackBar tb,
-//ref Rectangle thumb_pos,
-//ref Rectangle thumb_area,
+ public override void DrawTrackBar (Graphics dc, Rectangle clip_rectangle, TrackBar tb)
+ {
Brush br_thumb;
int value_pos;
bool mouse_value;
Rectangle area;
Rectangle thumb_pos = tb.ThumbPos;
Rectangle thumb_area = tb.ThumbArea;
-
+
if (tb.thumb_pressed) {
value_pos = tb.thumb_mouseclick;
mouse_value = true;
mouse_value = false;
}
- area = tb.paint_area;
+ area = tb.ClientRectangle;
if (tb.thumb_pressed == true) {
br_thumb = (Brush) ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace);
/* Control Background */
if (tb.BackColor == DefaultControlBackColor) {
- dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area);
+ dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), clip_rectangle);
} else {
- dc.FillRectangle (ResPool.GetSolidBrush (tb.BackColor), area);
+ dc.FillRectangle (ResPool.GetSolidBrush (tb.BackColor), clip_rectangle);
}
}
if (tb.Orientation == Orientation.Vertical) {
- DrawTrackBar_Vertical (dc, area, tb, ref thumb_pos, ref thumb_area,
+ DrawTrackBar_Vertical (dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
br_thumb, ticks, value_pos, mouse_value);
} else {
- DrawTrackBar_Horizontal (dc, area, tb, ref thumb_pos, ref thumb_area,
+ DrawTrackBar_Horizontal (dc, clip_rectangle, tb, ref thumb_pos, ref thumb_area,
br_thumb, ticks, value_pos, mouse_value);
}
} else {
pen=new Pen(Color.White, 1);
if (enabled==true) {
- sb=new SolidBrush(Color.Black);
+ sb=ThemeEngine.Current.ResPool.GetSolidBrush (Color.Black);
} else {
sb=ResPool.GetSolidBrush (ColorButtonFace);
}
the image grayscale. At least when having > 256 colors on
the display.
*/
-
- ImageAttributes imageAttributes=new ImageAttributes();
- ColorMatrix colorMatrix=new ColorMatrix(new float[][] {
- // This table would create a perfect grayscale image, based on luminance
- // new float[]{0.3f,0.3f,0.3f,0,0},
- // new float[]{0.59f,0.59f,0.59f,0,0},
- // new float[]{0.11f,0.11f,0.11f,0,0},
- // new float[]{0,0,0,1,0,0},
- // new float[]{0,0,0,0,1,0},
- // new float[]{0,0,0,0,0,1}
-
- // This table generates a image that is grayscaled and then
- // brightened up. Seems to match MS close enough.
- new float[]{0.2f,0.2f,0.2f,0,0},
- new float[]{0.41f,0.41f,0.41f,0,0},
- new float[]{0.11f,0.11f,0.11f,0,0},
- new float[]{0.15f,0.15f,0.15f,1,0,0},
- new float[]{0.15f,0.15f,0.15f,0,1,0},
- new float[]{0.15f,0.15f,0.15f,0,0,1}
- });
-
- imageAttributes.SetColorMatrix(colorMatrix);
- graphics.DrawImage(image, new Rectangle(x, y, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
- imageAttributes.Dispose();
+
+ if (imagedisabled_attributes == null) {
+ imagedisabled_attributes = new ImageAttributes ();
+ ColorMatrix colorMatrix=new ColorMatrix(new float[][] {
+ // This table would create a perfect grayscale image, based on luminance
+ // new float[]{0.3f,0.3f,0.3f,0,0},
+ // new float[]{0.59f,0.59f,0.59f,0,0},
+ // new float[]{0.11f,0.11f,0.11f,0,0},
+ // new float[]{0,0,0,1,0,0},
+ // new float[]{0,0,0,0,1,0},
+ // new float[]{0,0,0,0,0,1}
+
+ // This table generates a image that is grayscaled and then
+ // brightened up. Seems to match MS close enough.
+ new float[]{0.2f,0.2f,0.2f,0,0},
+ new float[]{0.41f,0.41f,0.41f,0,0},
+ new float[]{0.11f,0.11f,0.11f,0,0},
+ new float[]{0.15f,0.15f,0.15f,1,0,0},
+ new float[]{0.15f,0.15f,0.15f,0,1,0},
+ new float[]{0.15f,0.15f,0.15f,0,0,1}
+ });
+
+ imagedisabled_attributes.SetColorMatrix (colorMatrix);
+ }
+
+ graphics.DrawImage(image, new Rectangle(x, y, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imagedisabled_attributes);
+
}
public override void CPDrawStringDisabled (Graphics graphics, string s, Font font, Color color, RectangleF layoutRectangle,
- StringFormat format) {
- SolidBrush brush;
-
- brush=new SolidBrush(ControlPaint.Light(color, 95));
+ StringFormat format) {
layoutRectangle.Offset(1.0f, 1.0f);
- graphics.DrawString(s, font, brush, layoutRectangle, format);
-
- brush.Color=ControlPaint.Light(color, 50);
+ graphics.DrawString(s, font, ResPool.GetSolidBrush (ControlPaint.Light(color, 95)), layoutRectangle, format);
layoutRectangle.Offset(-1.0f, -1.0f);
- graphics.DrawString(s, font, brush, layoutRectangle, format);
-
- brush.Dispose();
+ graphics.DrawString(s, font, ResPool.GetSolidBrush (ControlPaint.Light(color, 50)), layoutRectangle, format);
+
}
private static void DrawBorderInternal(Graphics graphics, int startX, int startY, int endX, int endY,
}
case CaptionButton.Help: {
- StringFormat sf = new StringFormat();
- SolidBrush sb = new SolidBrush(color);
+ StringFormat sf = new StringFormat();
Font font = new Font("Microsoft Sans Serif", captionRect.Height, FontStyle.Bold, GraphicsUnit.Pixel);
sf.Alignment=StringAlignment.Center;
sf.LineAlignment=StringAlignment.Center;
- graphics.DrawString("?", font, sb, captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
+ graphics.DrawString("?", font, ThemeEngine.Current.ResPool.GetSolidBrush (color), captionRect.X+captionRect.Width/2+shift, captionRect.Y+captionRect.Height/2+shift+lineWidth/2, sf);
- sf.Dispose();
- sb.Dispose();
+ sf.Dispose();
font.Dispose();
return;
// hatchBrush.Dispose();
// }
+ // Clear the background
+ graphics.FillRectangle (SystemBrushes.Control, rectangle);
+
if ((State & DrawFrameControlStates.Pushed)!=0 || (State & DrawFrameControlStates.Checked)!=0) {
graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorButtonFace)), trace_rectangle);
} else if ((State & DrawFrameControlStates.Flat)!=0) {
return;
}
-
- dc.FillRectangle (new SolidBrush (Color.Blue), area);
-
+
dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X, area.Y, area.Width, 1);
dc.FillRectangle (ResPool.GetSolidBrush (ColorButtonFace), area.X, area.Y, 1, area.Height);