+2008-06-10 George Giolfan <georgegiolfan@yahoo.com>
+
+ * VisualStyleElement.cs: Added ComboBox border part and state constants.
+
2008-06-10 George Giolfan <georgegiolfan@yahoo.com>
* GtkPlus.cs, IVisualStyles.cs, VisualStylesEngine.cs,
#region Class name/part/state constants
private const string BUTTON = "BUTTON";
private const string CLOCK = "CLOCK";
+ #region COMBOXBOX
private const string COMBOBOX = "COMBOBOX";
+ enum COMBOBOXPARTS
+ {
+ CP_BORDER = 4
+ }
+ enum BORDERSTATES
+ {
+ CBB_NORMAL = 1,
+ CBB_HOT,
+ CBB_FOCUSED,
+ CBB_DISABLED
+ }
+ #endregion
private const string EDIT = "EDIT";
private const string EXPLORERBAR = "EXPLORERBAR";
private const string HEADER = "HEADER";
public static VisualStyleElement Normal { get { return VisualStyleElement.CreateElement (VisualStyleElement.COMBOBOX, 1, 1); } }
public static VisualStyleElement Pressed { get { return VisualStyleElement.CreateElement (VisualStyleElement.COMBOBOX, 1, 3); } }
}
+ internal static class Border
+ {
+ public static VisualStyleElement Normal {
+ get {
+ return new VisualStyleElement (
+ COMBOBOX,
+ (int)COMBOBOXPARTS.CP_BORDER,
+ (int)BORDERSTATES.CBB_NORMAL);
+ }
+ }
+ public static VisualStyleElement Hot {
+ get {
+ return new VisualStyleElement (
+ COMBOBOX,
+ (int)COMBOBOXPARTS.CP_BORDER,
+ (int)BORDERSTATES.CBB_HOT);
+ }
+ }
+ public static VisualStyleElement Focused {
+ get {
+ return new VisualStyleElement (
+ COMBOBOX,
+ (int)COMBOBOXPARTS.CP_BORDER,
+ (int)BORDERSTATES.CBB_FOCUSED);
+ }
+ }
+ public static VisualStyleElement Disabled {
+ get {
+ return new VisualStyleElement (
+ COMBOBOX,
+ (int)COMBOBOXPARTS.CP_BORDER,
+ (int)BORDERSTATES.CBB_DISABLED);
+ }
+ }
+ }
}
#endregion
#region ExplorerBar
+2008-06-10 George Giolfan <georgegiolfan@yahoo.com>
+
+ * ComboBox.cs, Theme.cs, ThemeVisualStyles.cs, ThemeWin32Classic.cs: Added
+ support for rendering the border with VisualStyles.
+
2008-06-10 George Giolfan <georgegiolfan@yahoo.com>
* InternalWindowManager.cs: Added ShowIcon. Fixed IconRectangleContains when
MouseUp += new MouseEventHandler (OnMouseUpCB);
MouseMove += new MouseEventHandler (OnMouseMoveCB);
MouseWheel += new MouseEventHandler (OnMouseWheelCB);
+ MouseEnter += new EventHandler (OnMouseEnter);
MouseLeave += new EventHandler (OnMouseLeave);
KeyDown +=new KeyEventHandler(OnKeyDownCB);
}
#endregion Public Properties
+ #region Internal Properties
+ internal Rectangle ButtonArea {
+ get { return button_area; }
+ }
+
+ internal Rectangle TextArea {
+ get { return text_area; }
+ }
+ #endregion
+
#region Public Methods
#if NET_2_0
[Obsolete ("This method has been deprecated")]
is_flat = style == FlatStyle.Flat || style == FlatStyle.Popup;
#endif
- if (!Enabled)
- dc.FillRectangle (theme.ResPool.GetSolidBrush (theme.ColorControl), bounds);
-
- if (DropDownStyle == ComboBoxStyle.Simple)
- dc.FillRectangle (theme.ResPool.GetSolidBrush (Parent.BackColor), ClientRectangle);
-
- if (style == FlatStyle.Popup && (is_entered || Focused)) {
- Rectangle area = text_area;
- area.Height -= 1;
- area.Width -= 1;
- dc.DrawRectangle (theme.ResPool.GetPen (SystemColors.ControlDark), area);
- dc.DrawLine (theme.ResPool.GetPen (SystemColors.ControlDark), button_area.X - 1, button_area.Top, button_area.X - 1, button_area.Bottom);
- }
- if (!is_flat && clip.IntersectsWith (text_area))
- ControlPaint.DrawBorder3D (dc, text_area, Border3DStyle.Sunken);
+ theme.ComboBoxDrawBackground (this, dc, clip, style);
int border = theme.Border3DSize.Width;
Capture = true;
}
+ void OnMouseEnter (object sender, EventArgs e)
+ {
+ if (ThemeEngine.Current.CombBoxBackgroundHasHotElementStyle (this))
+ Invalidate ();
+ }
+
void OnMouseLeave (object sender, EventArgs e)
{
- if (show_dropdown_button)
- DropDownButtonEntered = false;
+ if (ThemeEngine.Current.CombBoxBackgroundHasHotElementStyle (this)) {
+ drop_down_button_entered = false;
+ Invalidate ();
+ } else {
+ if (show_dropdown_button)
+ DropDownButtonEntered = false;
+ }
}
void OnMouseMoveCB (object sender, MouseEventArgs e)
public abstract void ComboBoxDrawNormalDropDownButton (ComboBox comboBox, Graphics g, Rectangle clippingArea, Rectangle area, ButtonState state);
public abstract bool ComboBoxNormalDropDownButtonHasTransparentBackground (ComboBox comboBox, ButtonState state);
public abstract bool ComboBoxDropDownButtonHasHotElementStyle (ComboBox comboBox);
+ public abstract void ComboBoxDrawBackground (ComboBox comboBox, Graphics g, Rectangle clippingArea, FlatStyle style);
+ public abstract bool CombBoxBackgroundHasHotElementStyle (ComboBox comboBox);
#endregion // ComboBox
#region Control
#endif
return true;
}
+ static bool ComboBoxShouldPaintBackground (ComboBox comboBox)
+ {
+ if (comboBox.DropDownStyle == ComboBoxStyle.Simple)
+ return false;
+#if NET_2_0
+ switch (comboBox.FlatStyle) {
+ case FlatStyle.Flat:
+ case FlatStyle.Popup:
+ return false;
+ }
+#endif
+ return true;
+ }
+ public override void ComboBoxDrawBackground (ComboBox comboBox, Graphics g, Rectangle clippingArea, FlatStyle style)
+ {
+ if (!ComboBoxShouldPaintBackground (comboBox)) {
+ base.ComboBoxDrawBackground (comboBox, g, clippingArea, style);
+ return;
+ }
+ VisualStyleElement element;
+ if (!comboBox.Enabled)
+ element = VisualStyleElement.ComboBox.Border.Disabled;
+ else if (comboBox.Entered)
+ element = VisualStyleElement.ComboBox.Border.Hot;
+ else if (comboBox.Focused)
+ element = VisualStyleElement.ComboBox.Border.Focused;
+ else
+ element = VisualStyleElement.ComboBox.Border.Normal;
+ if (!VisualStyleRenderer.IsElementDefined (element)) {
+ base.ComboBoxDrawBackground (comboBox, g, clippingArea, style);
+ return;
+ }
+ new VisualStyleRenderer (element).DrawBackground (g, new Rectangle (Point.Empty, comboBox.Size), clippingArea);
+ }
+ public override bool CombBoxBackgroundHasHotElementStyle (ComboBox comboBox)
+ {
+ if (ComboBoxShouldPaintBackground (comboBox) &&
+ comboBox.Enabled &&
+ VisualStyleRenderer.IsElementDefined (VisualStyleElement.ComboBox.Border.Hot))
+ return true;
+ return base.CombBoxBackgroundHasHotElementStyle (comboBox);
+ }
#endregion
#region ControlPaint
#region DrawButton
{
return false;
}
+ public override void ComboBoxDrawBackground (ComboBox comboBox, Graphics g, Rectangle clippingArea, FlatStyle style)
+ {
+ if (!comboBox.Enabled)
+ g.FillRectangle (ResPool.GetSolidBrush (ColorControl), comboBox.Bounds);
+
+ if (comboBox.DropDownStyle == ComboBoxStyle.Simple)
+ g.FillRectangle (ResPool.GetSolidBrush (comboBox.Parent.BackColor), comboBox.ClientRectangle);
+
+ if (style == FlatStyle.Popup && (comboBox.Entered || comboBox.Focused)) {
+ Rectangle area = comboBox.TextArea;
+ area.Height -= 1;
+ area.Width -= 1;
+ g.DrawRectangle (ResPool.GetPen (SystemColors.ControlDark), area);
+ g.DrawLine (ResPool.GetPen (SystemColors.ControlDark), comboBox.ButtonArea.X - 1, comboBox.ButtonArea.Top, comboBox.ButtonArea.X - 1, comboBox.ButtonArea.Bottom);
+ }
+ bool is_flat = style == FlatStyle.Flat || style == FlatStyle.Popup;
+ if (!is_flat && clippingArea.IntersectsWith (comboBox.TextArea))
+ ControlPaint.DrawBorder3D (g, comboBox.TextArea, Border3DStyle.Sunken);
+ }
+ public override bool CombBoxBackgroundHasHotElementStyle (ComboBox comboBox)
+ {
+ return false;
+ }
#endregion ComboBox
#region Datagrid