// 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
// John BouAntoun, jba-mono@optusnet.com.au
//
//
-//
-// $Revision: 1.65 $
-// $Modtime: $
-// $Log: ThemeWin32Classic.cs,v $
-// Revision 1.65 2004/11/10 20:10:38 jackson
-// * ThemeWin32Classic.cs: Do not draw the selected tab if its not in
-// the clip area.
-//
-// Revision 1.64 2004/11/10 19:22:26 jackson
-// * ThemeWin32Classic.cs: Don't bother drawing tabs outside of the
-// clip area.
-//
-// Revision 1.63 2004/11/10 01:04:28 jackson
-// * TabControl.cs (CalcXPos): New helper method so we can determine
-// the proper place to start drawing vertical tabs.
-// * ThemeWin32Classic.cs (DrawTab): Draw right aligned tabs.
-//
-// Revision 1.62 2004/11/09 21:44:54 jackson
-// * TabControl.cs: Calculate sizing and rects for left aligned tabs.
-// * ThemeWin32Classic.cs (GetTabControl*ScrollRect): Only handle Top
-// and Bottom, left and right are illegal values for this and
-// multiline is enabled when the alignment is set to left or right.
-// (DrawTab): Each alignment block should draw the text itself now
-// because Left requires special love. Also add rendering for Left
-// aligned tabs.
-//
-// Revision 1.61 2004/11/09 11:06:21 jba
-// - (DrawButtonBase): Fix verticle text rect clipping in windows
-// - (DrawCheckBox): Fix CheckAlign.TopCenter and CheckAlign.BottomCenter
-// rendering and incorrect text rect clipping
-// - (DrawRadioButton): Fix CheckAlign.TopCenter and CheckAlign.BottomCenter
-// rendering and incorrect text rect clipping
-//
-// Revision 1.60 2004/11/09 03:12:00 jackson
-// * ThemeWin32Classic.cs (DrawTabControl): Render tabs from top to
-// bottom when they are bottom aligned so the bottoms of the tabs get
-// displayed.
-// * TabControl.cs (DropRow): Move rows up instead of down when the
-// tab control is bottom aligned.
-//
-// Revision 1.59 2004/11/08 20:40:08 jackson
-// Render the little scrolling jimmi in the correct location with bottom aligned tabs
-//
-// Revision 1.58 2004/11/08 14:15:00 jordi
-// fixes vertical scrollbar and removes dead code
-//
-// Revision 1.57 2004/11/05 05:47:34 jba
-// - Fix Button rendering for FlatStyle = Flat or Popup
-// - Fix RadioButton and CheckBox rendering when Appearance = Button (normal and
-// flatstyle).
-// - Correct outer rectangle color when drawing focus rectangle
-// - Adjust button bounds to be 1 px smaller when focused
-// - Make button not draw sunken 3d border when pushed (windows compat)
-// - Fix CPDrawBorder3D to not make bottom right hand corner rounded
-// - Offset the text in RadioButton and Checkbox when being rendered as a button.
-// - Hover and Click behaviour for Colored FlatStyle.Flat and Popup radiobuttons
-// - Fixed disabled rendering for colored flatstyle radiobuttons (both)
-// - Fixed disabled text rendering for normally rendered radiobuttons
-//
-// Revision 1.56 2004/11/04 11:26:09 ravindra
-// - Changed default ListView values signatures (prefixed all with ListView).
-// - Fixed default size values for VScrollBar and HScrollBar.
-// - Fixed DrawListViewItem method.
-//
-// Revision 1.55 2004/11/03 18:52:14 jackson
-// Initial implementation of the scrolly widgerywoo
-//
-// Revision 1.54 2004/11/02 20:40:54 jackson
-// Move the row with the selected tab to the bottom
-//
-// Revision 1.53 2004/11/02 02:47:55 jackson
-// New rendering and sizing code for tab controls
-//
-// Revision 1.52 2004/10/30 10:23:02 ravindra
-// Drawing ListView and some default values.
-//
-// Revision 1.51 2004/10/26 09:55:48 ravindra
-// Some formatting for my last checkins.
-//
-// Revision 1.50 2004/10/26 09:36:32 ravindra
-// Implemented DetailView drawing for ListView control and default values.
-//
-// Revision 1.49 2004/10/18 04:49:25 pbartok
-// - Added ToolTip drawing code
-//
-// Revision 1.48 2004/10/15 15:08:49 ravindra
-// Added ColumnHeaderHeight property in Theme for ListView.
-//
-// Revision 1.47 2004/10/13 15:06:37 pbartok
-// - Path from John BouAntoun:
-// * Fix check rendering (centre correctly for normal style, offset
-// correctly for FlatStyle).
-// * Fix border color usage (use backcolor) for FlatStyle.Popup
-// * Use checkbox.Capture instead of checkbox.is_pressed when rendering
-// flatstyle states.
-//
-// Revision 1.46 2004/10/13 03:48:15 pbartok
-// - Removed all occurences of SystemColors and replaced them with the
-// matching theme color
-//
-// Revision 1.45 2004/10/13 03:41:45 pbartok
-// - From John BouAntoun: Added an overload to CPDrawBorder3D to allow him
-// using the function for flatstyle drawing
-// - Changed functions to use the new version of CPDrawBorder3D
-//
-// Revision 1.44 2004/10/13 02:45:21 pbartok
-// - Fixes from John BouAntoun: now handles forecolors and backcolors for
-// flatstyle rendered controls much better; It also fixes normal checkbox
-// rendering when pushed or disabled.
-//
-// Revision 1.43 2004/10/07 14:56:51 jordi
-// Removes deletion of cached brushes
-//
-// Revision 1.42 2004/10/06 09:59:05 jordi
-// removes warnings from compilation
-//
-// Revision 1.41 2004/10/05 16:15:30 jackson
-// Improve rendering of the radio button patch by John BouAntoun
-//
-// Revision 1.40 2004/10/05 09:04:31 ravindra
-// - Added DrawListView method and ListViewDefaultSize property.
-// - Changed ControlPaint method calls to CPDrawXXX wherever possible.
-// - Changed DOS style CRLF to Unix format (dos2unix).
-//
-// Revision 1.39 2004/10/04 07:09:37 jordi
-// fixes right button position causing right button not showing on horizontal scrollbars
-//
-// Revision 1.38 2004/09/28 18:44:25 pbartok
-// - Streamlined Theme interfaces:
-// * Each DrawXXX method for a control now is passed the object for the
-// control to be drawn in order to allow accessing any state the theme
-// might require
-//
-// * ControlPaint methods for the theme now have a CP prefix to avoid
-// name clashes with the Draw methods for controls
-//
-// * Every control now retrieves it's DefaultSize from the current theme
-//
-// Revision 1.37 2004/09/09 08:28:11 pbartok
-// - Improve disabled string look
-//
-// Revision 1.36 2004/09/09 03:03:49 ravindra
-// PictureBox would not draw a null image to avoid crash.
-//
-// Revision 1.35 2004/09/07 17:12:26 jordi
-// GroupBox control
-//
-// Revision 1.34 2004/09/07 09:40:15 jordi
-// LinkLabel fixes, methods, multiple links
-//
-// Revision 1.33 2004/09/05 08:03:51 jordi
-// fixes bugs, adds flashing on certain situations
-//
-// Revision 1.32 2004/09/02 16:32:54 jordi
-// implements resource pool for pens, brushes, and hatchbruses
-//
-// Revision 1.31 2004/08/25 20:04:40 ravindra
-// Added the missing divider code and grip for ToolBar Control.
-//
-// Revision 1.30 2004/08/25 18:29:14 jordi
-// new methods, properties, and fixes for progressbar
-//
-// Revision 1.29 2004/08/25 00:43:13 ravindra
-// Fixed wrapping related issues in ToolBar control.
-//
-// Revision 1.28 2004/08/24 18:37:02 jordi
-// fixes formmating, methods signature, and adds missing events
-//
-// Revision 1.27 2004/08/24 16:16:46 jackson
-// Handle drawing picture boxes in the theme now. Draw picture box borders and obey sizing modes
-//
-// Revision 1.26 2004/08/21 01:52:08 ravindra
-// Improvments in mouse event handling in the ToolBar control.
-//
-// Revision 1.25 2004/08/20 00:12:51 jordi
-// fixes methods signature
-//
-// Revision 1.24 2004/08/19 22:25:31 jordi
-// theme enhancaments
-//
-// Revision 1.23 2004/08/18 19:16:53 jordi
-// Move colors to a table
-//
-// Revision 1.22 2004/08/17 19:29:11 jackson
-// Don't use KnownColor to create colours. It has a large startup time.
-//
-// Revision 1.21 2004/08/15 23:20:54 ravindra
-// Changes to Theme for ToolBar control and also dos2unix format.
-//
-// Revision 1.20 2004/08/13 21:22:18 jordi
-// removes redundant code and fixes issues with tickposition
-//
-// Revision 1.19 2004/08/12 20:29:01 jordi
-// Trackbar enhancement, fix mouse problems, highli thumb, etc
-//
-// Revision 1.18 2004/08/12 18:54:37 jackson
-// Handle owner draw status bars
-//
-// Revision 1.17 2004/08/11 01:31:35 jackson
-// Create Brushes as little as possible
-//
-// Revision 1.16 2004/08/10 19:21:27 jordi
-// scrollbar enhancements and standarize on win colors defaults
-//
-// Revision 1.15 2004/08/10 18:52:30 jackson
-// Implement DrawItem functionality
-//
-// Revision 1.14 2004/08/09 21:34:54 jackson
-// Add support for drawing status bar and get status bar item sizes
-//
-// Revision 1.13 2004/08/09 21:21:49 jackson
-// Use known colors for default control colours
-//
-// Revision 1.12 2004/08/09 21:12:15 jackson
-// Make the default font static, it is static in control so this doesn't change functionality and creating fonts is sloooooow.
-//
-// Revision 1.11 2004/08/09 17:31:13 jackson
-// New names for control properties
-//
-// Revision 1.10 2004/08/09 17:00:00 jackson
-// Add default window color properties
-//
-// Revision 1.9 2004/08/09 16:17:19 jackson
-// Use correct default back color
-//
-// Revision 1.8 2004/08/09 15:53:12 jackson
-// Themes now handle default control properties so coloring will be consistent
-//
-// Revision 1.7 2004/08/08 22:54:21 jordi
-// Label BorderStyles
-//
-// Revision 1.6 2004/08/08 18:09:53 jackson
-// Add pen_buttonface
-//
-// Revision 1.5 2004/08/08 17:34:28 jordi
-// Use Windows Standard Colours
-//
-// Revision 1.4 2004/08/07 23:31:15 jordi
-// fixes label bug and draw method name
-//
-// Revision 1.3 2004/08/07 19:05:44 jordi
-// Theme colour support and GetSysColor defines
-//
-// Revision 1.2 2004/08/07 00:01:39 pbartok
-// - Fixed some rounding issues with float/int
-//
-// Revision 1.1 2004/07/26 17:42:03 jordi
-// Theme support
-//
-//
+
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
+using System.Drawing.Text;
namespace System.Windows.Forms
{
internal class ThemeWin32Classic : Theme
{
+ public override Version Version {\r
+ get {\r
+ return new Version(0, 1, 0, 0);\r
+ }\r
+ }\r
+
/* Default colors for Win32 classic theme */
uint [] theme_colors = { /* AARRGGBB */
(uint) XplatUIWin32.GetSysColorIndex.COLOR_INFOBK, 0xffffffff,
};
-
- static protected Pen pen_ticks;
- static protected SolidBrush br_arrow;
- static protected SolidBrush br_progressbarblock;
- static protected Pen pen_arrow;
-
- /* Cache */
- protected SolidBrush label_br_fore_color;
- protected SolidBrush label_br_back_color;
+ /* Hardcoded colour values not exposed in the API constants in all configurations */
+ 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 ()
- {
- label_br_fore_color = null;
- label_br_back_color = null;
-
+ {
/* Init Default colour array*/
syscolors = Array.CreateInstance (typeof (Color), (uint) XplatUIWin32.GetSysColorIndex.COLOR_MAXVALUE+1);
for (int i = 0; i < theme_colors.Length; i +=2)
- syscolors.SetValue (Color.FromArgb ((int)theme_colors[i+1]), (int) theme_colors[i]);
-
- pen_ticks = new Pen (Color.Black);
- br_arrow = new SolidBrush (Color.Black);
- pen_arrow = new Pen (Color.Black);
- br_progressbarblock = new SolidBrush (Color.FromArgb (255, 0, 0, 128));
+ syscolors.SetValue (Color.FromArgb ((int)theme_colors[i+1]), (int) theme_colors[i]);
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() {
+ throw new NotImplementedException("Need to implement ResetDefaults() for Win32 theme");
+ }
+
public override bool DoubleBufferingSupported {
get {return true; }
}
width = button.ClientSize.Width;
height = button.ClientSize.Height;
-
- SolidBrush sb = new SolidBrush(button.BackColor);
- dc.FillRectangle(sb, button.ClientRectangle);
- sb.Dispose();
+
+ dc.FillRectangle(ResPool.GetSolidBrush (button.BackColor), button.ClientRectangle);
// set up the button rectangle
buttonRectangle = button.ClientRectangle;
text_rect.Y++;
}
- if (button.is_enabled) {
- SolidBrush b = new SolidBrush(button.ForeColor);
- dc.DrawString(button.text, button.Font, b, text_rect, button.text_format);
- b.Dispose();
+ if (button.is_enabled) {
+ dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (button.ForeColor), text_rect, button.text_format);
+
} else {
if (button.FlatStyle == FlatStyle.Flat || button.FlatStyle == FlatStyle.Popup) {
dc.DrawString(button.text, button.Font, ResPool.GetSolidBrush (ControlPaint.DarkDark (this.ColorButtonFace)), text_rect, button.text_format);
text_format = new StringFormat();
text_format.Alignment=StringAlignment.Near;
text_format.LineAlignment=StringAlignment.Center;
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
/* Calculate the position of text and checkbox rectangle */
if (checkbox.appearance!=Appearance.Button) {
// 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 DrawComboBoxEditDecorations (Graphics dc, ComboBox ctrl, Rectangle cl)
+ {
+ dc.DrawLine (ResPool.GetPen (ColorButtonShadow), cl.X, cl.Y, cl.X + cl.Width, cl.Y); //top
+ dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), cl.X + 1, cl.Y + 1, cl.X + cl.Width - 2, cl.Y + 1);
+ dc.DrawLine (ResPool.GetPen (ColorButtonFace), cl.X, cl.Y + cl.Height - 2, cl.X + cl.Width, cl.Y + cl.Height - 2); //down
+ dc.DrawLine (ResPool.GetPen (ColorButtonHilight), cl.X, cl.Y + cl.Height - 1, cl.X + cl.Width, cl.Y + cl.Height - 1);
+ dc.DrawLine (ResPool.GetPen (ColorButtonShadow), cl.X, cl.Y, cl.X, cl.Y + cl.Height); //left
+ dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), cl.X + 1, cl.Y + 1, cl.X + 1, cl.Y + cl.Height - 2);
+ dc.DrawLine (ResPool.GetPen (ColorButtonFace), cl.X + cl.Width - 2, cl.Y, cl.X + cl.Width - 2, cl.Y + cl.Height); //right
+ dc.DrawLine (ResPool.GetPen (ColorButtonHilight), cl.X + cl.Width - 1, cl.Y + 1 , cl.X + cl.Width - 1, cl.Y + cl.Height - 1);
+ }
+
+ // Sizing
+ public override int DrawComboBoxEditDecorationTop () { return 2;}
+ public override int DrawComboBoxEditDecorationBottom () { return 2;}
+ public override int DrawComboBoxEditDecorationRight () { return 2;}
+ public override int DrawComboBoxEditDecorationLeft () { return 2;}
+
+ private int DrawComboListBoxDecoration (ComboBoxStyle style)
+ {
+ if (style == ComboBoxStyle.Simple)
+ return 2;
+ else
+ return 1;
+ }
+
+ public override int DrawComboListBoxDecorationTop (ComboBoxStyle style)
+ {
+ return DrawComboListBoxDecoration (style);
+ }
+
+ public override int DrawComboListBoxDecorationBottom (ComboBoxStyle style)
+ {
+ return DrawComboListBoxDecoration (style);
+ }
+
+ public override int DrawComboListBoxDecorationRight (ComboBoxStyle style)
+ {
+ return DrawComboListBoxDecoration (style);
+ }
+
+ public override int DrawComboListBoxDecorationLeft (ComboBoxStyle style)
+ {
+ return DrawComboListBoxDecoration (style);
+ }
+
+ public override void DrawComboListBoxDecorations (Graphics dc, ComboBox ctrl, Rectangle cl)
+ {
+ if (ctrl.DropDownStyle == ComboBoxStyle.Simple) {
+ DrawComboBoxEditDecorations (dc, ctrl, cl);
+ }
+ else {
+ dc.DrawRectangle (ThemeEngine.Current.ResPool.GetPen (ThemeEngine.Current.ColorWindowFrame),
+ cl.X, cl.Y, cl.Width - 1, cl.Height - 1);
+ }
+ }
+
+ 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) {
+ // if not showing the numeric updown control then render border
+ 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);
+
+ // deflate by the border width
+ if (clip_rectangle.IntersectsWith (dtp.drop_down_arrow_rect)) {
+ button_bounds.Inflate (-2,-2);
+ ButtonState state = dtp.is_drop_down_visible ? ButtonState.Pushed : ButtonState.Normal;
+ this.CPDrawComboButton (
+ dc,
+ dtp.drop_down_arrow_rect,
+ state);
+ }
+ }
+
+ // 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);
+
+ // fill the currently highlighted area
+ if (dtp.hilight_date_area != Rectangle.Empty) {
+ dc.FillRectangle (ResPool.GetSolidBrush (ThemeEngine.Current.ColorHilight), dtp.hilight_date_area);
+ }
+
+ // draw the text part
+ // TODO: if date format is CUstom then we need to draw the dates as separate parts
+ StringFormat text_format = new StringFormat();
+ 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);
+ }
+ }
+
+ #endregion // DateTimePicker
#region GroupBox
public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box) {
- SizeF size;
- int width, y;
- Rectangle rect = box.ClientRectangle;
- Color disabled = ColorGrayText;
+ 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;
Pen pen_light = ResPool.GetPen (Color.FromArgb (255,255,255,255));
Pen pen_dark = ResPool.GetPen (Color.FromArgb (255, 128, 128,128));
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);
+ }
}
#endregion // HScrollBar
#region Label
- public override void DrawLabel (Graphics dc, Rectangle clip_rectangle, Label label) {
- if (label_br_fore_color == null || label_br_fore_color.Color != label.ForeColor) {
- label_br_fore_color = GetControlForeBrush (label.ForeColor);
- }
-
- if (label_br_back_color == null || label_br_back_color.Color != label.BackColor) {
- label_br_back_color = GetControlBackBrush (label.BackColor);
- }
-
- dc.FillRectangle (label_br_back_color, clip_rectangle);
+ public override void DrawLabel (Graphics dc, Rectangle clip_rectangle, Label label)
+ {
+ 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, label_br_fore_color, clip_rectangle, label.string_format);
+ dc.DrawString (label.Text, label.Font, ResPool.GetSolidBrush (label.ForeColor), clip_rectangle, label.string_format);
} else {
ControlPaint.DrawStringDisabled (dc, label.Text, label.Font, 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) {
ColumnHeader col;
ListViewItem.ListViewSubItem subItem;
Rectangle sub_item_rect = item.LabelRect;
- sub_item_rect.X = item.LabelRect.Right;
// set the format for subitems
format.FormatFlags = StringFormatFlags.NoWrap;
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;
SolidBrush sub_item_back_br = null;
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
// cache local copies of Marshal-by-ref internal members (gets around error CS0197)
Size calendar_spacing = (Size)((object)mc.calendar_spacing);
Size date_cell_size = (Size)((object)mc.date_cell_size);
- // fill the background of the calendar
- dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), client_rectangle);
-
+
// draw the singlecalendars
int x_offset = 1;
int y_offset = 1;
x_offset = 1;
}
- DrawSingleMonth (
- dc,
- new Rectangle (x_offset, y_offset, month_size.Width, month_size.Height),
- mc,
- i,
- j);
-
- // draw the today date if it's set
- if (mc.ShowToday &&
- (i == mc.CalendarDimensions.Height-1 && j == 0)) \r
+ Rectangle month_rect = new Rectangle (x_offset, y_offset, month_size.Width, month_size.Height);
+ if (month_rect.IntersectsWith (clip_rectangle)) {
+ DrawSingleMonth (
+ dc,
+ clip_rectangle,
+ month_rect,
+ mc,
+ i,
+ j);
+ }
+ }
+ }
+
+ Rectangle bottom_rect = new Rectangle (
+ client_rectangle.X,
+ Math.Max(client_rectangle.Bottom - date_cell_size.Height - 3, 0),
+ client_rectangle.Width,
+ date_cell_size.Height + 2);
+ // draw the today date if it's set
+ if (mc.ShowToday && bottom_rect.IntersectsWith (clip_rectangle)) \r
+ {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), bottom_rect);
+ if (mc.ShowToday) {
+ int today_offset = 5;
+ if (mc.ShowTodayCircle) \r
{
- int today_offset = 0;
- if (mc.ShowTodayCircle) \r
- {
- Rectangle today_circle_rect = new Rectangle (
- client_rectangle.X + 5,
- Math.Max(client_rectangle.Bottom - date_cell_size.Height - 2, 0),
- date_cell_size.Width,
- date_cell_size.Height);
+ Rectangle today_circle_rect = new Rectangle (
+ client_rectangle.X + 5,
+ Math.Max(client_rectangle.Bottom - date_cell_size.Height - 2, 0),
+ date_cell_size.Width,
+ date_cell_size.Height);
DrawTodayCircle (dc, today_circle_rect);
- today_offset = date_cell_size.Width + 5;
- }
- // draw today's date
- StringFormat text_format = new StringFormat();
- text_format.LineAlignment = StringAlignment.Center;
- text_format.Alignment = StringAlignment.Near;
- Font bold_font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
- Rectangle today_rect = new Rectangle (
- today_offset + client_rectangle.X,
- Math.Max(client_rectangle.Bottom - date_cell_size.Height, 0),
- 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);
+ today_offset += date_cell_size.Width + 5;
+ }
+ // draw today's date
+ StringFormat text_format = new StringFormat();
+ text_format.LineAlignment = StringAlignment.Center;
+ text_format.Alignment = StringAlignment.Near;
+ Font bold_font = new Font (mc.Font.FontFamily, mc.Font.Size, mc.Font.Style | FontStyle.Bold);
+ Rectangle today_rect = new Rectangle (
+ today_offset + client_rectangle.X,
+ Math.Max(client_rectangle.Bottom - date_cell_size.Height, 0),
+ 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);
+ }
+ }
+
+ // finally paint the borders of the calendars as required
+ for (int i = 0; i <= mc.CalendarDimensions.Width; i++) {
+ if (i == 0 && clip_rectangle.X == client_rectangle.X) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, 1, client_rectangle.Height));
+ } else if (i == mc.CalendarDimensions.Width && clip_rectangle.Right == client_rectangle.Right) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.Right-1, client_rectangle.Y, 1, client_rectangle.Height));
+ } else {
+ Rectangle rect = new Rectangle (
+ client_rectangle.X + (month_size.Width*i) + (calendar_spacing.Width * (i-1)) + 1,
+ client_rectangle.Y,
+ calendar_spacing.Width,
+ client_rectangle.Height);
+ if (i < mc.CalendarDimensions.Width && i > 0 && clip_rectangle.IntersectsWith (rect)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
+ }
+ }
+ }
+ for (int i = 0; i <= mc.CalendarDimensions.Height; i++) {
+ if (i == 0 && clip_rectangle.Y == client_rectangle.Y) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Y, client_rectangle.Width, 1));
+ } else if (i == mc.CalendarDimensions.Height && clip_rectangle.Bottom == client_rectangle.Bottom) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), new Rectangle (client_rectangle.X, client_rectangle.Bottom-1, client_rectangle.Width, 1));
+ } else {
+ Rectangle rect = new Rectangle (
+ client_rectangle.X,
+ client_rectangle.Y + (month_size.Height*i) + (calendar_spacing.Height*(i-1)) + 1,
+ client_rectangle.Width,
+ calendar_spacing.Height);
+ if (i < mc.CalendarDimensions.Height && i > 0 && clip_rectangle.IntersectsWith (rect)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), rect);
+ }
+ }
+ }
+
+ // draw the drop down border if need
+ if (mc.owner != null) {
+ Rectangle bounds = mc.ClientRectangle;
+ if (clip_rectangle.Contains (mc.Location)) {
+ // find out if top or left line to draw
+ if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
+
+ dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.X, bounds.Bottom-1);
+ }
+ if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
+ dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Y, bounds.Right-1, bounds.Y);
+ }
+ }
+ if (clip_rectangle.Contains (new Point(bounds.Right, bounds.Bottom))) {
+ // find out if bottom or right line to draw
+ if(clip_rectangle.Contains (new Point (bounds.Left, bounds.Bottom))) {
+ dc.DrawLine (SystemPens.ControlText, bounds.X, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1);
+ }
+ if(clip_rectangle.Contains (new Point (bounds.Right, bounds.Y))) {
+ dc.DrawLine (SystemPens.ControlText, bounds.Right-1, bounds.Y, bounds.Right-1, bounds.Bottom-1);
}
}
}
}
// darws a single part of the month calendar (with one month)
- private void DrawSingleMonth(Graphics dc, Rectangle rectangle, MonthCalendar mc, int row, int col) \r
+ private void DrawSingleMonth(Graphics dc, Rectangle clip_rectangle, Rectangle rectangle, MonthCalendar mc, int row, int col) \r
{
// cache local copies of Marshal-by-ref internal members (gets around error CS0197)
Size title_size = (Size)((object)mc.title_size);
// draw the title back ground
- Rectangle title_rect = new Rectangle(rectangle.X, rectangle.Y, title_size.Width, title_size.Height);
- dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), title_rect);
- // draw the title
DateTime this_month = current_month.AddMonths (row*mc.CalendarDimensions.Width+col);
- string title_text = this_month.ToString ("MMMM yyyy");
- dc.DrawString (title_text, mc.Font, ResPool.GetSolidBrush (mc.TitleForeColor), title_rect, text_format);
-
- // draw previous and next buttons if it's time
- if (row == 0 && col == 0) \r
- {
- // draw previous button
- DrawMonthCalendarButton (
- dc,
- rectangle,
- mc,
- title_size,
- mc.button_x_offset,
- (System.Drawing.Size)((object)mc.button_size),
- true);
- }
- if (row == 0 && col == mc.CalendarDimensions.Width-1) \r
- {
- // draw next button
- DrawMonthCalendarButton (
- dc,
- rectangle,
- mc,
- title_size,
- mc.button_x_offset,
- (System.Drawing.Size)((object)mc.button_size),
- false);
+ Rectangle title_rect = new Rectangle(rectangle.X, rectangle.Y, title_size.Width, title_size.Height);
+ if (title_rect.IntersectsWith (clip_rectangle)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), title_rect);
+ // draw the title
+ string title_text = this_month.ToString ("MMMM yyyy");
+ dc.DrawString (title_text, mc.Font, ResPool.GetSolidBrush (mc.TitleForeColor), title_rect, text_format);
+
+ // draw previous and next buttons if it's time
+ if (row == 0 && col == 0) \r
+ {
+ // draw previous button
+ DrawMonthCalendarButton (
+ dc,
+ rectangle,
+ mc,
+ title_size,
+ mc.button_x_offset,
+ (System.Drawing.Size)((object)mc.button_size),
+ true);
+ }
+ if (row == 0 && col == mc.CalendarDimensions.Width-1) \r
+ {
+ // draw next button
+ DrawMonthCalendarButton (
+ dc,
+ rectangle,
+ mc,
+ title_size,
+ mc.button_x_offset,
+ (System.Drawing.Size)((object)mc.button_size),
+ false);
+ }
}
// set the week offset and draw week nums if needed
int col_offset = (mc.ShowWeekNumbers) ? 1 : 0;
- // draw the day names
- DayOfWeek first_day_of_week = mc.GetDayOfWeek(mc.FirstDayOfWeek);
- for (int i=0; i < 7; i++) \r
- {
- int position = i - (int) first_day_of_week;
- if (position < 0) \r
+ Rectangle day_name_rect = new Rectangle(
+ rectangle.X,
+ rectangle.Y + title_size.Height,
+ (7 + col_offset) * date_cell_size.Width,
+ date_cell_size.Height);
+ if (day_name_rect.IntersectsWith (clip_rectangle)) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), day_name_rect);
+ // draw the day names
+ DayOfWeek first_day_of_week = mc.GetDayOfWeek(mc.FirstDayOfWeek);
+ for (int i=0; i < 7; i++) \r
{
- position = 7 + position;
+ int position = i - (int) first_day_of_week;
+ if (position < 0) \r
+ {
+ position = 7 + position;
+ }
+ // draw it
+ Rectangle day_rect = new Rectangle(
+ day_name_rect.X + ((i + col_offset)* date_cell_size.Width),
+ day_name_rect.Y,
+ date_cell_size.Width,
+ date_cell_size.Height);
+ dc.DrawString (((DayOfWeek)i).ToString().Substring(0, 3), mc.Font, ResPool.GetSolidBrush (mc.TitleBackColor), day_rect, text_format);
}
- // draw it
- Rectangle day_rect = new Rectangle(
- rectangle.X + ((position + col_offset) * date_cell_size.Width),
- rectangle.Y + title_size.Height,
- date_cell_size.Width,
- date_cell_size.Height);
- dc.DrawString (((DayOfWeek)i).ToString().Substring(0, 3), mc.Font, ResPool.GetSolidBrush (mc.TitleBackColor), day_rect, text_format);
+
+ // draw the vertical divider
+ int vert_divider_y = Math.Max(title_size.Height+ date_cell_size.Height-1, 0);
+ dc.DrawLine (
+ ResPool.GetPen (mc.ForeColor),
+ rectangle.X + (col_offset * date_cell_size.Width) + mc.divider_line_offset,
+ rectangle.Y + vert_divider_y,
+ rectangle.Right - mc.divider_line_offset,
+ rectangle.Y + vert_divider_y);
}
- // draw the vertical divider
- int vert_divider_y = Math.Max(title_size.Height+ date_cell_size.Height-1, 0);
- dc.DrawLine (
- ResPool.GetPen (mc.ForeColor),
- rectangle.X + (col_offset * date_cell_size.Width) + mc.divider_line_offset,
- rectangle.Y + vert_divider_y,
- rectangle.Right - mc.divider_line_offset,
- rectangle.Y + vert_divider_y);
- // draw the actual date items in the grid (including the week
- Rectangle date_rect = new Rectangle(
+ // draw the actual date items in the grid (including the week numbers)
+ Rectangle date_rect = new Rectangle (
rectangle.X,
rectangle.Y + title_size.Height + date_cell_size.Height,
date_cell_size.Width,
date_cell_size.Height);
int month_row_count = 0;
+ bool draw_week_num_divider = false;
DateTime current_date = mc.GetFirstDateInMonthGrid ( new DateTime (this_month.Year, this_month.Month, 1));
for (int i=0; i < 6; i++) \r
{
+ // establish if this row is in our clip_area
+ Rectangle row_rect = new Rectangle (
+ rectangle.X,
+ rectangle.Y + title_size.Height + (date_cell_size.Height * (i+1)),
+ date_cell_size.Width * 7,
+ date_cell_size.Height);
+ if (mc.ShowWeekNumbers) {
+ row_rect.Width += date_cell_size.Width;
+ }
+
+ bool draw_row = row_rect.IntersectsWith (clip_rectangle);
+ if (draw_row) {
+ dc.FillRectangle (ResPool.GetSolidBrush (mc.BackColor), row_rect);
+ }
+ // establish if this is a valid week to draw
+ if (mc.IsValidWeekToDraw (this_month, current_date, row, col)) {
+ month_row_count = i;
+ }
+
// draw the week number if required
- if (mc.ShowWeekNumbers) \r
- {
+ if (mc.ShowWeekNumbers && month_row_count == i) {
+ if (!draw_week_num_divider) {
+ draw_week_num_divider = draw_row;
+ }
// get the week for this row
int week = mc.GetWeekOfYear (current_date);
- // determine if we are drawing this week number
- bool draw_week_num = mc.IsValidWeekToDraw (this_month, current_date, row, col);
- if (draw_week_num) {
+ if (draw_row) {
dc.DrawString (
week.ToString(),
mc.Font,
ResPool.GetSolidBrush (mc.TitleBackColor),
date_rect,
text_format);
- date_rect.Offset(date_cell_size.Width, 0);
- month_row_count = i;
-
- } else {
- // leave the loop
- break;
- }
- } else {
- if (mc.IsValidWeekToDraw (this_month, current_date, row, col)) {
- month_row_count = i;
}
+ date_rect.Offset(date_cell_size.Width, 0);
}
-
+
// only draw the days if we have to
if(month_row_count == i) {
for (int j=0; j < 7; j++) \r
{
- DrawMonthCalendarDate (
- dc,
- date_rect,
- mc,
- current_date,
- this_month,
- row,
- col);
+ if (draw_row) {
+ DrawMonthCalendarDate (
+ dc,
+ date_rect,
+ mc,
+ current_date,
+ this_month,
+ row,
+ col);
+ }
// move the day on
current_date = current_date.AddDays(1);
month_row_count++;
// draw week numbers if required
- if (mc.ShowWeekNumbers) {
+ if (draw_week_num_divider) {
col_offset = 1;
dc.DrawLine (
ResPool.GetPen (mc.ForeColor),
rectangle.X + date_cell_size.Width - 1,
rectangle.Y + title_size.Height + date_cell_size.Height + mc.divider_line_offset,
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);
+ rectangle.Y + title_size.Height + date_cell_size.Height + (month_row_count * date_cell_size.Height) - mc.divider_line_offset);
}
}
if (date < mc.SelectionEnd) \r
{
// use rectangle instead of rectangle to go all the way to edge of rect
- selection_rect.X = (int) Math.Floor(rectangle.X + rectangle.Width / 2);
+ selection_rect.X = (int) Math.Floor((double)(rectangle.X + rectangle.Width / 2));
selection_rect.Width = Math.Max(rectangle.Right - selection_rect.X, 0);
dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
}
#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;
- Rectangle paint_area = progress_bar.paint_area;
- int steps = (progress_bar.Maximum - progress_bar.Minimum) / progress_bar.step;
- 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 (br_progressbarblock, 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_format = new StringFormat();
text_format.Alignment = StringAlignment.Near;
text_format.LineAlignment = StringAlignment.Center;
+ text_format.HotkeyPrefix = HotkeyPrefix.Show;
/* Calculate the position of text and checkbox rectangle */
if (radio_button.appearance!=Appearance.Button) {
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);
#endregion // RadioButton
#region ScrollBar
- public override void DrawScrollBar(Graphics dc, Rectangle clip_rectangle, ScrollBar bar) {
+ public override void DrawScrollBar (Graphics dc, Rectangle clip, ScrollBar bar)
+ {
int scrollbutton_width = bar.scrollbutton_width;
int scrollbutton_height = bar.scrollbutton_height;
Rectangle first_arrow_area;
bar.ThumbPos = thumb_pos;
/* Buttons */
- CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state);
- CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state);
+ if (clip.IntersectsWith (first_arrow_area))
+ CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Up, bar.firstbutton_state);
+ if (clip.IntersectsWith (second_arrow_area))
+ CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Down, bar.secondbutton_state);
/* Background */
switch (bar.thumb_moving) {
case ScrollBar.ThumbMoving.None: {
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), 0,
- scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - (scrollbutton_height * 2));
-
+ Rectangle r = new Rectangle (0,
+ scrollbutton_height, bar.ClientRectangle.Width, bar.ClientRectangle.Height - (scrollbutton_height * 2));
+ Rectangle intersect = Rectangle.Intersect (clip, r);
+
+ if (intersect != Rectangle.Empty) {
+ Brush h = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace);
+ dc.FillRectangle (h, intersect);
+ }
break;
}
case ScrollBar.ThumbMoving.Forward: {
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
- 0, scrollbutton_height,
- bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height);
-
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
- 0, thumb_pos.Y + thumb_pos.Height,
- bar.ClientRectangle.Width, bar.ClientRectangle.Height - (thumb_pos.Y + thumb_pos.Height) - scrollbutton_height);
-
+ Rectangle r = new Rectangle (0, scrollbutton_height,
+ bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height);
+ Rectangle intersect = Rectangle.Intersect (clip, r);
+
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), intersect);
+
+ r.X = 0;
+ r.Y = thumb_pos.Y + thumb_pos.Height;
+ r.Width = bar.ClientRectangle.Width;
+ r.Height = bar.ClientRectangle.Height - (thumb_pos.Y + thumb_pos.Height) - scrollbutton_height;
+
+ intersect = Rectangle.Intersect (clip, r);
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black), intersect);
break;
}
case ScrollBar.ThumbMoving.Backwards: {
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
- 0, scrollbutton_height,
- bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height);
-
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
- 0, thumb_pos.Y + thumb_pos.Height,
- bar.ClientRectangle.Width, bar.ClientRectangle.Height - (thumb_pos.Y + thumb_pos.Height) - scrollbutton_height);
-
+ Rectangle r = new Rectangle (0, scrollbutton_height,
+ bar.ClientRectangle.Width, thumb_pos.Y - scrollbutton_height);
+ Rectangle intersect = Rectangle.Intersect (clip, r);
+
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black), intersect);
+
+ r.X = 0;
+ r.Y = thumb_pos.Y + thumb_pos.Height;
+ r.Width = bar.ClientRectangle.Width;
+ r.Height = bar.ClientRectangle.Height - (thumb_pos.Y + thumb_pos.Height) - scrollbutton_height;
+
+ intersect = Rectangle.Intersect (clip, r);
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), intersect);
break;
}
default:
break;
}
-
- }
- else {
+ } else {
first_arrow_area = new Rectangle(0, 0, scrollbutton_width, bar.Height);
bar.FirstArrowArea = first_arrow_area;
bar.ThumbPos = thumb_pos;
/* Buttons */
- CPDrawScrollButton (dc, bar.FirstArrowArea, ScrollButton.Left, bar.firstbutton_state);
- CPDrawScrollButton (dc, bar.SecondArrowArea, ScrollButton.Right, bar.secondbutton_state);
+ if (clip.IntersectsWith (first_arrow_area))
+ CPDrawScrollButton (dc, first_arrow_area, ScrollButton.Left, bar.firstbutton_state);
+ if (clip.IntersectsWith (second_arrow_area))
+ CPDrawScrollButton (dc, second_arrow_area, ScrollButton.Right, bar.secondbutton_state);
- /* Background */
- //dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), scrollbutton_width,
- // 0, area.Width - (scrollbutton_width * 2), area.Height);
-
+ /* Background */
switch (bar.thumb_moving) {
case ScrollBar.ThumbMoving.None: {
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), scrollbutton_width,
- 0, bar.ClientRectangle.Width - (scrollbutton_width * 2), bar.ClientRectangle.Height);
-
+ Rectangle r = new Rectangle (scrollbutton_width,
+ 0, bar.ClientRectangle.Width - (scrollbutton_width * 2), bar.ClientRectangle.Height);
+ Rectangle intersect = Rectangle.Intersect (clip, r);
+
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), intersect);
break;
}
case ScrollBar.ThumbMoving.Forward: {
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
- scrollbutton_width, 0,
- thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height);
-
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
- thumb_pos.X + thumb_pos.Width, 0,
- bar.ClientRectangle.Width - (thumb_pos.X + thumb_pos.Width) - scrollbutton_width, bar.ClientRectangle.Height);
-
+ Rectangle r = new Rectangle (scrollbutton_width, 0,
+ thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height);
+ Rectangle intersect = Rectangle.Intersect (clip, r);
+
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), intersect);
+
+ r.X = thumb_pos.X + thumb_pos.Width;
+ r.Y = 0;
+ r.Width = bar.ClientRectangle.Width - (thumb_pos.X + thumb_pos.Width) - scrollbutton_width;
+ r.Height = bar.ClientRectangle.Height;
+
+ intersect = Rectangle.Intersect (clip, r);
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black), intersect);
break;
}
case ScrollBar.ThumbMoving.Backwards: {
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black),
- scrollbutton_width, 0,
- thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height);
-
- dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace),
- thumb_pos.X + thumb_pos.Width, 0,
- bar.ClientRectangle.Width - (thumb_pos.X + thumb_pos.Width) - scrollbutton_width, bar.ClientRectangle.Height);
+ Rectangle r = new Rectangle (scrollbutton_width, 0,
+ thumb_pos.X - scrollbutton_width, bar.ClientRectangle.Height);
+ Rectangle intersect = Rectangle.Intersect (clip, r);
-
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, Color.FromArgb (255, 63,63,63), Color.Black), intersect);
+
+ r.X = thumb_pos.X + thumb_pos.Width;
+ r.Y = 0;
+ r.Width = bar.ClientRectangle.Width - (thumb_pos.X + thumb_pos.Width) - scrollbutton_width;
+ r.Height = bar.ClientRectangle.Height;
+
+ intersect = Rectangle.Intersect (clip, r);
+ if (intersect != Rectangle.Empty)
+ dc.FillRectangle (ResPool.GetHatchBrush (HatchStyle.Percent50, ColorButtonHilight, ColorButtonFace), intersect);
break;
}
-
- default:
- break;
}
}
/* Thumb */
- if (bar.Enabled)
- DrawScrollButtonPrimitive (dc, thumb_pos, ButtonState.Normal);
+ if (bar.Enabled && thumb_pos.Width > 0 && thumb_pos.Height > 0 && clip.IntersectsWith (thumb_pos))
+ DrawScrollButtonPrimitive (dc, thumb_pos, ButtonState.Normal);
}
public override int ScrollBarButtonSize {
#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]);
}
}
int left = area.Left;
if (panel.Icon != null) {
left += 2;
- int size = area.Height - border_size;
- Rectangle ia = new Rectangle (left, border_size, size, size);
dc.DrawIcon (panel.Icon, left, area.Top);
left += panel.Icon.Width;
}
string text = panel.Text;
StringFormat string_format = new StringFormat ();
- string_format.LineAlignment = StringAlignment.Center;
- string_format.Alignment = StringAlignment.Near;
+ string_format.Trimming = StringTrimming.Character;
string_format.FormatFlags = StringFormatFlags.NoWrap;
if (text [0] == '\t') {
}
}
- float x = left + border_size;
- float y = ((area.Bottom - area.Top) / 2.0F) + border_size;
-
- dc.DrawString (text, panel.Parent.Font, br_forecolor, x, y, string_format);
+ int x = left + border_size;
+ int y = border_size + 2;
+ Rectangle r = new Rectangle (x, y,
+ area.Right - x - border_size,
+ area.Bottom - y - border_size);
+
+ dc.DrawString (text, panel.Parent.Font, br_forecolor, r, string_format);
}
public override int StatusBarSizeGripWidth {
private int DrawTab (Graphics dc, TabPage page, TabControl tab, Rectangle bounds, bool is_selected)
{
- int FlatButtonSpacing = 8;
- int RoundCornerSize = 5;
+ int FlatButtonSpacing = 8;
Rectangle interior;
int res = bounds.Width;
}
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 (pen_ticks, 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 (pen_ticks, 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) {
- //Console.WriteLine ("{0} {1} {2}", pixel_len, inc, pixels_betweenticks );
- if (inc == 0 || (inc + pixels_betweenticks) >= pixel_len +1)
- dc.DrawLine (pen_ticks, 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 (pen_ticks, 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 (pen_ticks, 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 (pen_ticks, 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 (pen_ticks, 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 (pen_ticks, 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);
}
ControlPaint.DrawBorder(graphics, rectangle, ColorButtonShadow, ButtonBorderStyle.Solid);
} else {
if ((state & (ButtonState.Pushed | ButtonState.Checked))!=0) {
- CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+ // this needs to render like a pushed button - jba
+ // CPDrawBorder3D(graphics, rectangle, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
+ Rectangle trace_rectangle = new Rectangle(rectangle.X, rectangle.Y, Math.Max (rectangle.Width-1, 0), Math.Max (rectangle.Height-1, 0));
+ graphics.DrawRectangle (ResPool.GetPen (ControlPaint.Dark (ColorButtonFace)), trace_rectangle);
} else {
CPDrawBorder3D(graphics, rectangle, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Top | Border3DSide.Right | Border3DSide.Bottom, ColorButtonFace);
}
}
- public override void CPDrawFocusRectangle (Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor) {
- // 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));
-
- //Color colorForeInverted;
- Pen pen;
-
- //colorForeInverted=Color.FromArgb(Math.Abs(foreColor.R-255), Math.Abs(foreColor.G-255), Math.Abs(foreColor.B-255));
- //pen=new Pen(colorForeInverted, 1);
- // MS seems to always use black
- pen = ResPool.GetPen (Color.Black);
- graphics.DrawRectangle(pen, trace_rectangle);
+ public override void CPDrawFocusRectangle (Graphics graphics, Rectangle rectangle, Color foreColor, Color backColor)
+ {
+ Rectangle rect = rectangle;
+ Pen pen;
+ HatchBrush brush;
+
+ if (backColor.GetBrightness () >= 0.5) {
+ foreColor = Color.Transparent;
+ backColor = Color.Black;
+
+ } else {
+ backColor = Color.FromArgb (Math.Abs (backColor.R-255), Math.Abs (backColor.G-255), Math.Abs (backColor.B-255));
+ foreColor = Color.Black;
+ }
+
+ brush = ResPool.GetHatchBrush (HatchStyle.Percent50, backColor, foreColor);
+ pen = new Pen (brush, 1);
+
+ rect.Width--;
+ rect.Height--;
- DrawInnerFocusRectangle (graphics, Rectangle.Inflate (rectangle, -4, -4), backColor);
+ graphics.DrawRectangle (pen, rect);
+ pen.Dispose ();
}
public override void CPDrawGrabHandle (Graphics graphics, Rectangle rectangle, bool primary, bool enabled) {
} 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);
+
}
int centerX;
int centerY;
int shiftX;
- int shiftY;
rect=new Rectangle(rectangle.X+rectangle.Width/4, rectangle.Y+rectangle.Height/4, rectangle.Width/2, rectangle.Height/2);
centerX=rect.Left+rect.Width/2;
centerY=rect.Top+rect.Height/2;
shiftX=Math.Max(1, rect.Width/8);
- shiftY=Math.Max(1, rect.Height/8);
rect.X-=shiftX;
centerX-=shiftX;
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) {
for (int i = 0; i < 3; i++)
if (enabled)
- dc.DrawLine (pen_arrow, x + i, y - i, x + i + 6 - 2*i, y - i);
+ 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 (br_arrow, x + 3, area.Y + 6, 1, 1);
+ dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
+ x + 3, area.Y + 6, 1, 1);
+
break;
}
case ScrollButton.Down: {
- int x = area.X + (area.Width / 2) - 4;
+ int x = area.X + (area.Width / 2) - 5;
int y = area.Y + 5;
for (int i = 4; i != 0; i--)
if (enabled)
- dc.DrawLine (pen_arrow, x + i, y + i, x + i + 8 - 2*i, y + i);
+ 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);
- dc.FillRectangle (br_arrow, x + 4, y + 4, 1, 1);
+ dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
+ x + 4, y + 4, 1, 1);
break;
}
for (int i = 0; i < 3; i++)
if (enabled)
- dc.DrawLine (pen_arrow, x - i, y + i, x - i, y + i + 6 - 2*i);
+ 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);
- dc.FillRectangle (br_arrow, x - 3, y + 3, 1, 1);
+ dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
+ x - 3, y + 3, 1, 1);
break;
}
case ScrollButton.Right: {
- int y = area.Y + (area.Height / 2) - 4;
+ int y = area.Y + (area.Height / 2) - 5;
int x = area.X + 5;
for (int i = 4; i != 0; i--)
if (enabled)
- dc.DrawLine (pen_arrow, x + i, y + i, x + i, y + i + 8 - 2*i);
+ 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);
- dc.FillRectangle (br_arrow, x + 4, y + 4, 1, 1);
+ dc.FillRectangle (enabled ? ResPool.GetSolidBrush (arrow_color) : ResPool.GetSolidBrush (ColorGrayText),
+ x + 4, y + 4, 1, 1);
break;
}
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);