Skip to content

Commit

Permalink
Merge branch 'alpha' into alpha-fr#728
Browse files Browse the repository at this point in the history
  • Loading branch information
PWagner1 authored Jun 10, 2022
2 parents 6f5d0e3 + 7922065 commit 7d8ce13
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 116 deletions.
4 changes: 4 additions & 0 deletions Documents/Help/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* Made enumeration `SchemeOfficeColors` public, so they can be used to make external themes
* Resolved [#722](https://github.com/Krypton-Suite/Standard-Toolkit/issues/722), KryptonRichTextBox disabled colour cannot be set
* Resolved [#662](https://github.com/Krypton-Suite/Standard-Toolkit/issues/662), Can not "Control / Set Disabled" Background Colour Of Comboboxes, in DropDown mode
* Resolved [#578](https://github.com/Krypton-Suite/Standard-Toolkit/issues/578), ComboBox Center no longer draws text centered
* Resolved [#20](https://github.com/Krypton-Suite/Standard-Toolkit/issues/20), Selected text in ComboBox is drawn in a different font
* Resolved [#308](https://github.com/Krypton-Suite/Standard-Toolkit/issues/308), Panel AntiAlias Border Problem
* Resolved [#734](https://github.com/Krypton-Suite/Standard-Toolkit/issues/734), Disabled Text in NumericUpDown Not visible
* Resolved [#715](https://github.com/Krypton-Suite/Standard-Toolkit/issues/715), v65.22.4.94 - PaletteSparkleBlueBase.GetContentPadding: Specified argument was out of the range of valid values. Parameter name: style
* Implemented the `PlacementModeConverter` for `PlacementMode` enum type
* Implemented [#551](https://github.com/Krypton-Suite/Standard-Toolkit/issues/551), `DropShadow` should now be off and deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ public InternalComboBox(KryptonComboBox kryptonComboBox)
// Remove from view until size for the first time by the Krypton control
ItemHeight = 15;
DropDownHeight = 200;
DrawMode = DrawMode.OwnerDrawFixed; // DrawMode = DrawMode.OwnerDrawVariable;
SetStyle(/*ControlStyles.UserPaint| */ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer, true);
//DrawMode = DrawMode.OwnerDrawFixed; // #20 fix, but this causes other problems; see #578
DrawMode = DrawMode.OwnerDrawVariable;
SetStyle(/*ControlStyles.UserPaint | */ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer, true);
}
#endregion

Expand Down Expand Up @@ -171,10 +172,7 @@ public bool MouseOver
/// <summary>
/// Reset the app themed setting so it is retested when next required.
/// </summary>
public void ClearAppThemed()
{
_appThemed = null;
}
public void ClearAppThemed() => _appThemed = null;

/// <summary>
/// Gets the content short text.
Expand Down Expand Up @@ -388,56 +386,53 @@ protected override void WndProc(ref Message m)
_kryptonComboBox.CueHint.PerformPaint(_kryptonComboBox, g, rect, backBrush);
}
else
//////////////////////////////////////////////////////
// Following commented out, to allow the Draw to always happen even tho the edit box will draw over afterwards
// Draw Over is tracked here
// https://github.com/Krypton-Suite/Standard-Toolkit/issues/179
// If not enabled or not the dropDown Style then we can draw over the text area
//if (!_kryptonComboBox.Enabled || _kryptonComboBox.DropDownStyle != ComboBoxStyle.DropDown)
////////////////////////////////////////////////////////
//// Following commented out, to allow the Draw to always happen even tho the edit box will draw over afterwards
//// Draw Over is tracked here
//// https://github.com/Krypton-Suite/Standard-Toolkit/issues/179
//// If not enabled or not the dropDown Style then we can draw over the text area
////if (!_kryptonComboBox.Enabled || _kryptonComboBox.DropDownStyle != ComboBoxStyle.DropDown)
{
// Set the correct text rendering hint for the text drawing. We only draw if the edit text is disabled so we
// just always grab the disable state value. Without this line the wrong hint can occur because it inherits
// it from the device context. Resulting in blurred text.
g.TextRenderingHint = CommonHelper.PaletteTextHintToRenderingHint(states.Content.GetContentShortTextHint(state));

// Define the string formatting requirements
StringFormat stringFormat = new()
{
LineAlignment = StringAlignment.Near,
FormatFlags = StringFormatFlags.NoWrap,
Trimming = StringTrimming.None,
// Use the correct prefix setting
HotkeyPrefix = HotkeyPrefix.None
};

stringFormat.Alignment = states.Content.GetContentShortTextH(state) switch
{
PaletteRelativeAlign.Near => RightToLeft == RightToLeft.Yes
? StringAlignment.Far
: StringAlignment.Near,
PaletteRelativeAlign.Far => RightToLeft == RightToLeft.Yes
? StringAlignment.Near
: StringAlignment.Far,
PaletteRelativeAlign.Center => StringAlignment.Center,
_ => stringFormat.Alignment
};

// Draw using a solid brush
Rectangle rectangle = new(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
rectangle = CommonHelper.ApplyPadding(VisualOrientation.Top, rectangle,
states.Content.GetContentPadding(state));
TextFormatFlags flags = TextFormatFlags.TextBoxControl | TextFormatFlags.NoPadding | TextFormatFlags.VerticalCenter;

// Use the correct prefix setting
flags |= TextFormatFlags.NoPrefix;

try
// Do we need to switch drawing direction?
if (RightToLeft == RightToLeft.Yes)
{
//string label = this.Items[e.Index].ToString();
using SolidBrush foreBrush = new(states.Content.GetContentShortTextColor1(state));
g.DrawString(displayText, states.Content.GetContentShortTextFont(state), foreBrush, rectangle, stringFormat);
flags |= TextFormatFlags.RightToLeft;
}
catch (ArgumentException)

switch (states.Content.GetContentShortTextH(state))
{
using SolidBrush foreBrush = new(ForeColor);
g.DrawString(displayText, Font, foreBrush, rectangle, stringFormat);
case PaletteRelativeAlign.Near:
flags |= TextFormatFlags.Left;
break;
case PaletteRelativeAlign.Center:
flags |= TextFormatFlags.HorizontalCenter;
break;
case PaletteRelativeAlign.Far:
flags |= TextFormatFlags.Right;
break;
}

// Draw text using font defined by the control
Rectangle rectangle = new(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
rectangle = CommonHelper.ApplyPadding(VisualOrientation.Top, rectangle, states.Content.GetContentPadding(state));
// Find correct text color
Color textColor = states.Content.GetContentShortTextColor1(state);
Font contentShortTextFont = states.Content.GetContentShortTextFont(state);
// Find correct background color
Color backColor = states.PaletteBack.GetBackColor1(state);

TextRenderer.DrawText(g,
Text, contentShortTextFont,
rectangle,
textColor, backColor,
flags);
}

// Remove clipping settings
Expand Down Expand Up @@ -672,8 +667,8 @@ public bool Visible
IntPtr.Zero,
0, 0, 0, 0,
PI.SWP_.NOMOVE | PI.SWP_.NOSIZE |
(value ? PI.SWP_.SHOWWINDOW : PI.SWP_.HIDEWINDOW)
);
(value ? PI.SWP_.SHOWWINDOW : PI.SWP_.HIDEWINDOW)
);
}

#endregion
Expand Down Expand Up @@ -1277,6 +1272,8 @@ public bool IsInitializing
/// <summary>Gets or sets the draw mode of the combobox.</summary>
/// <value>The draw mode of the combobox.</value>
[Description(@"Gets or sets the draw mode of the combobox.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[EditorBrowsable(EditorBrowsableState.Never)]
public DrawMode DrawMode
{
get => _comboBox.DrawMode;
Expand Down Expand Up @@ -2666,7 +2663,15 @@ private void AttachEditControl()
// If we found a child then it is the edit class
if (childPtr != IntPtr.Zero)
{
if (this.DropDownStyle == ComboBoxStyle.Simple)
{
//this.childListBox = new ComboBox.ComboBoxChildNativeWindow(this, ComboBox.ChildWindowType.ListBox);
//this.childListBox.AssignHandle(window);
childPtr = PI.GetWindow(childPtr, PI.GetWindowType.GW_HWNDNEXT);
}
_subclassEdit = new SubclassEdit(childPtr, this);
// Following will have been done by Framework
//PI.SendMessage(childPtr, PI.WM_.EM_SETMARGINS, new IntPtr(3), IntPtr.Zero);
_subclassEdit.TrackMouseEnter += OnComboBoxMouseChange;
_subclassEdit.TrackMouseLeave += OnComboBoxMouseChange;
}
Expand Down Expand Up @@ -2723,6 +2728,7 @@ private void OnComboBoxDrawItem(object sender, DrawItemEventArgs e)
// Do we need to draw the edit area
if ((e.State & DrawItemState.ComboBoxEdit) == DrawItemState.ComboBoxEdit)
{
// TODO: Check if this is covered by the WM_PAINT in the internal Combo
// Always get base implementation to draw the background
e.DrawBackground();

Expand Down Expand Up @@ -2926,7 +2932,13 @@ private void OnComboBoxGotFocus(object sender, EventArgs e)
{
if (DropDownStyle == ComboBoxStyle.DropDown)
{
//_subclassEdit.Visible = true;
_subclassEdit.Visible = true;
PaletteState state = Enabled
? IsActive
? PaletteState.Tracking
: PaletteState.Normal
: PaletteState.Disabled;
_comboBox.Font = GetComboBoxTripleState().Content.GetContentShortTextFont(state);
}

base.OnGotFocus(e);
Expand All @@ -2938,7 +2950,8 @@ private void OnComboBoxLostFocus(object sender, EventArgs e)
{
if (DropDownStyle == ComboBoxStyle.DropDown)
{
//_subclassEdit.Visible = false;
_subclassEdit.Visible = false;
_comboBox.Font = GetComboBoxTripleState().Content.GetContentShortTextFont(PaletteState.Normal);
}

// ReSharper disable RedundantBaseQualifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,48 +375,45 @@ protected override void WndProc(ref Message m)

//////////////////////////////////////////////////////
// Following removed to allow the Draw to always happen, to allow centering etc
_internalNumericUpDown.TextAlign = states.Content.GetContentShortTextH(state) switch
{
PaletteRelativeAlign.Center =>
HorizontalAlignment.Center,
PaletteRelativeAlign.Far => HorizontalAlignment
.Right,
_ => HorizontalAlignment.Left
};
if (NumericUpDown.Enabled)
{
if (!NumericUpDown.TrailingZeroes && NumericUpDown.AllowDecimals)
_internalNumericUpDown.TextAlign =
states.Content.GetContentShortTextH(state) switch
{
// Got ot deal with culture formatting, and also the override to include `ThousandsSeparator`
var textInvariantAsRequested =
_internalNumericUpDown.Value.ToString(
'F' + _internalNumericUpDown.DecimalPlaces.ToString(CultureInfo
.InvariantCulture), CultureInfo.CurrentCulture);
var textInvariantAsTrimmed =
_internalNumericUpDown.Value.ToString(@"0.#########################",
CultureInfo.InvariantCulture);
var lengthToRemove = textInvariantAsRequested.Length -
textInvariantAsTrimmed.Length;
if (lengthToRemove > 0)
{
_internalNumericUpDown.SetChangingText(true);
_internalNumericUpDown.Text = textInvariantAsRequested.Substring(0,
textInvariantAsRequested.Length - lengthToRemove);
}
}
PaletteRelativeAlign.Center => HorizontalAlignment.Center,
PaletteRelativeAlign.Far => HorizontalAlignment.Right,
_ => HorizontalAlignment.Left
};

// Let base implementation draw the actual text area
if (m.WParam == IntPtr.Zero)
{
m.WParam = hdc;
DefWndProc(ref m);
m.WParam = IntPtr.Zero;
}
else
if (!NumericUpDown.TrailingZeroes && NumericUpDown.AllowDecimals)
{
// Got ot deal with culture formatting, and also the override to include `ThousandsSeparator`
var textInvariantAsRequested =
_internalNumericUpDown.Value.ToString(
'F' + _internalNumericUpDown.DecimalPlaces.ToString(CultureInfo
.InvariantCulture), CultureInfo.CurrentCulture);
var textInvariantAsTrimmed =
_internalNumericUpDown.Value.ToString(@"0.#########################",
CultureInfo.InvariantCulture);
var lengthToRemove = textInvariantAsRequested.Length -
textInvariantAsTrimmed.Length;
if (lengthToRemove > 0)
{
DefWndProc(ref m);
_internalNumericUpDown.SetChangingText(true);
_internalNumericUpDown.Text = textInvariantAsRequested.Substring(0,
textInvariantAsRequested.Length - lengthToRemove);
}
}

// Let base implementation draw the actual text area
if (m.WParam == IntPtr.Zero)
{
m.WParam = hdc;
DefWndProc(ref m);
m.WParam = IntPtr.Zero;
}
else
{
DefWndProc(ref m);
}
}

// Do we need to match the original BeginPaint?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ public void UnattachGlobalEvents()
/// <summary>
/// Gets and sets the ViewManager instance.
/// </summary>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager
{
[DebuggerStepThrough]
Expand Down
10 changes: 10 additions & 0 deletions Source/Krypton Components/Krypton.Toolkit/General/GraphicsHint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ public GraphicsHint(Graphics graphics, PaletteGraphicsHint hint)
case PaletteGraphicsHint.AntiAlias:
_graphics.SmoothingMode = SmoothingMode.AntiAlias;
break;
case PaletteGraphicsHint.HighSpeed:
_graphics.SmoothingMode = SmoothingMode.HighSpeed;
break;
case PaletteGraphicsHint.HighQuality:
_graphics.SmoothingMode = SmoothingMode.HighQuality;
break;
case PaletteGraphicsHint.Inherit:
// Change nothing!
break;

default:
// Should never happen!
Debug.Assert(false);
Expand Down
Loading

0 comments on commit 7d8ce13

Please sign in to comment.