Skip to content

Commit

Permalink
Editor: bugfixes for themed ComboBoxCustom
Browse files Browse the repository at this point in the history
Not sure how I missed it, but we have to manually draw the text when using UserPaint so it's painted correctly in all cases.
Also added WM_WINDOWPOSCHANGED to catch the case where the control is being resized.

Fixes #1924
  • Loading branch information
AlanDrake committed Oct 31, 2023
1 parent 1060255 commit 05d434f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Editor/AGS.Editor/ColorThemes/Controls/ComboBoxCustom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace AGS.Editor
public class ComboBoxCustom : ComboBox
{
private const int WM_PAINT = 0x000F;
private const int WM_WINDOWPOSCHANGED = 0x0047;

private readonly ColorTheme _theme;
private readonly string _root;
Expand Down Expand Up @@ -101,6 +102,7 @@ protected override void WndProc(ref Message m)
switch (m.Msg)
{
case WM_PAINT:
case WM_WINDOWPOSCHANGED:
Graphics graphics = Graphics.FromHwnd(Handle);
Rectangle rectBorder = new Rectangle(0, 0, Width, Height);
Rectangle rectButton = new Rectangle(Width - 19, 0, 19, Height);
Expand Down Expand Up @@ -133,6 +135,13 @@ protected override void WndProc(ref Message m)

//Draw button arrow
graphics.FillPath(arrow, path);

// Draw text
Rectangle rectText = new Rectangle(3, 3, Width-19, Height- 3);
if (Text != null)
graphics.DrawString(Text, Font,
new SolidBrush(_theme.GetColor(_root + "/item-selected/foreground")), rectText);

break;
}
}
Expand Down

0 comments on commit 05d434f

Please sign in to comment.