Skip to content

Commit

Permalink
Merge pull request #2203 from AlanDrake/logpanel-styles
Browse files Browse the repository at this point in the history
Theme support for Log Panel
  • Loading branch information
ivan-mogilko authored Oct 31, 2023
2 parents ebe3999 + 0374c75 commit 313066c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Editor/AGS.Editor/GUI/LogPanel.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Editor/AGS.Editor/GUI/LogPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,5 +302,29 @@ private void logTextBox_VScroll(object sender, EventArgs e)
_glue = IsScrollAtBottom();
}
}

private void LoadColorTheme(ColorTheme t)
{

t.SetColor("log-panel/background", c => BackColor = c);
t.SetColor("log-panel/splitter", c => splitContainer.BackColor = c);
t.SetColor("log-panel/background", c => logTextBox.BackColor = c);
t.SetColor("log-panel/foreground", c => logTextBox.ForeColor = c);
t.PropertyGridHelper(propertyGrid, "log-panel/grid");
if (t.Has("tool-bar"))
{
t.SetColor("tool-bar/background", c => toolStrip.BackColor = c);
toolStrip.Renderer = t.GetToolStripRenderer("tool-bar");
}
}

private void LogPanel_Load(object sender, EventArgs e)
{
if (!DesignMode)
{
Hacks.SetRichTextBoxMargins(logTextBox, 12, 12);
Factory.GUIController.ColorThemes.Apply(LoadColorTheme);
}
}
}
}
11 changes: 11 additions & 0 deletions Editor/AGS.Editor/Hacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public static class Hacks
private const int EM_REPLACESEL = 0x00C2;
private const int EM_GETSCROLLPOS = WM_USER + 221;
private const int EM_SETSCROLLPOS = WM_USER + 222;
private const int EM_SETMARGINS = 0xD3;
private const int EC_LEFTMARGIN = 0x1;
private const int EC_RIGHTMARGIN = 0x2;
// TreeView messages
private const int TV_FIRST = 0x1100;
private const int TVM_GETEDITCONTROL = (TV_FIRST + 15);
Expand Down Expand Up @@ -89,6 +92,14 @@ public static void ReplaceSelectedText(this RichTextBox rtb, int at, int length,
Marshal.FreeHGlobal(strPtr);
}

/// <summary>
/// Sets RichTextBox's margins
/// </summary>
public static void SetRichTextBoxMargins(this RichTextBox rtb, int left, int right)
{
SendMessage(rtb.Handle, EM_SETMARGINS, (EC_LEFTMARGIN | EC_RIGHTMARGIN), (IntPtr)(right * 0x10000 + left));
}

// Hack to get around the fact that the BeforeLabelEdit event provides no way to
// let you change the text they're about to edit
public static void SetTreeViewEditText(TreeView tree, string myText)
Expand Down

0 comments on commit 313066c

Please sign in to comment.