Author Topic: patch for [debug windows]  (Read 596 times)

Offline srm2000

  • Single posting newcomer
  • *
  • Posts: 6
patch for [debug windows]
« on: October 11, 2025, 06:32:33 am »
The font size of debug windows might be to small too see it clearly.  Too much complaints from the students。
I make a patch. The debug windows' fonts inherit from the editor. Then you can change the fonts at your will.
In the future, a seperated font setting dialog might be added in the debugger configuration window.

Index: src/src/backtracedlg.cpp
===================================================================
--- src/src/backtracedlg.cpp   (rev 13745)
+++ src/src/backtracedlg.cpp   (patched)
@@ -62,6 +62,14 @@
     SetAutoLayout(true);
     SetSizer(bs);
 
+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
+    wxNativeFontInfo fontInfo;
+    fontInfo.FromString(fontstring);
+    wxFont font(fontInfo);
+
+    m_list->SetFont(font);
+
     m_list->InsertColumn(0, _("Nr"), wxLIST_FORMAT_RIGHT);
     m_list->InsertColumn(1, _("Address"), wxLIST_FORMAT_LEFT);
     m_list->InsertColumn(2, _("Function"), wxLIST_FORMAT_LEFT);
Index: src/src/breakpointsdlg.cpp
===================================================================
--- src/src/breakpointsdlg.cpp   (rev 13745)
+++ src/src/breakpointsdlg.cpp   (patched)
@@ -76,6 +76,14 @@
     SetAutoLayout(TRUE);
     SetSizer(bs);
 
+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
+    wxNativeFontInfo fontInfo;
+    fontInfo.FromString(fontstring);
+    wxFont font(fontInfo);
+
+    m_pList->SetFont(font);
+
     wxWindow* parent = Manager::Get()->GetAppWindow();
     const double scaleFactor = cbGetContentScaleFactor(*parent);
     const int targetHeight = wxRound(12 * scaleFactor);
Index: src/src/cpuregistersdlg.cpp
===================================================================
--- src/src/cpuregistersdlg.cpp   (rev 13745)
+++ src/src/cpuregistersdlg.cpp   (patched)
@@ -27,7 +27,12 @@
     SetSizer(sizer);
     Layout();
 
-    wxFont font(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
+    wxNativeFontInfo fontInfo;
+    fontInfo.FromString(fontstring);
+    wxFont font(fontInfo);
+
     m_pList->SetFont(font);
 
     Clear();
Index: src/src/examinememorydlg.cpp
===================================================================
--- src/src/examinememorydlg.cpp   (rev 13745)
+++ src/src/examinememorydlg.cpp   (patched)
@@ -38,7 +38,12 @@
         return;
     m_pText = XRCCTRL(*this, "txtDump", wxTextCtrl);
 
-    wxFont font(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
+    wxNativeFontInfo fontInfo;
+    fontInfo.FromString(fontstring);
+    wxFont font(fontInfo);
+
     m_pText->SetFont(font);
 
     ConfigManager *c = Manager::Get()->GetConfigManager(wxT("debugger_common"));
Index: src/src/threadsdlg.cpp
===================================================================
--- src/src/threadsdlg.cpp   (rev 13745)
+++ src/src/threadsdlg.cpp   (patched)
@@ -44,8 +44,14 @@
     SetAutoLayout(true);
     SetSizer(bs);
 
-    wxFont font(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
+    wxNativeFontInfo fontInfo;
+    fontInfo.FromString(fontstring);
+    wxFont font(fontInfo);
+
     m_list->SetFont(font);
+
     m_list->InsertColumn(0, _("Active"), wxLIST_FORMAT_LEFT, 64);
     m_list->InsertColumn(1, _("Number"), wxLIST_FORMAT_RIGHT, 64);
     m_list->InsertColumn(2, _("Info"), wxLIST_FORMAT_LEFT);
Index: src/src/watchesdlg.cpp
===================================================================
--- src/src/watchesdlg.cpp   (rev 13745)
+++ src/src/watchesdlg.cpp   (patched)
@@ -403,6 +403,14 @@
     SetAutoLayout(TRUE);
     SetSizer(bs);
 
+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
+    wxNativeFontInfo fontInfo;
+    fontInfo.FromString(fontstring);
+    wxFont font(fontInfo);
+
+    m_grid->SetFont(font);
+
     if (!watchesPropertyEditor)
         watchesPropertyEditor = wxPropertyGrid::RegisterEditorClass(new cbTextCtrlAndButtonTooltipEditor, true);
 
@@ -1337,9 +1345,12 @@
     m_grid->SetExtraStyle(extraStyles);
     m_grid->SetDropTarget(new WatchesDropTarget);
 
+    // use the same font as editor's
+    const wxString fontstring(Manager::Get()->GetConfigManager("editor")->Read("/font", wxEmptyString));
     wxNativeFontInfo fontInfo;
-    fontInfo.FromString(cbDebuggerCommonConfig::GetValueTooltipFont());
+    fontInfo.FromString(fontstring);
     wxFont font(fontInfo);
+
     m_grid->SetFont(font);
 
     m_grid->SetColumnCount(3);

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1781
Re: patch for [debug windows]
« Reply #1 on: October 11, 2025, 10:17:36 am »
Patch (modified to take HiDPI into account) applied in r13747, thank you.

Offline srm2000

  • Single posting newcomer
  • *
  • Posts: 6
Re: suggestion for r13747, patch for [debug windows]
« Reply #2 on: Yesterday at 06:46:34 am »
Patch (modified to take HiDPI into account) applied in r13747, thank you.

The new patch of r13747 makes the fonts of debugging windows especially large. It doesn't match well with the GUI's font at all.

So, my suggestion is,  calling SetFont in the released patch such as,
Code
m_pText->SetFont(font.Scaled(cbGetContentScaleFactor(*this))); 
might be much better like this, just as my original patch.
Code
m_pText->SetFont(font);

The users can change the editor's font to ensure the debugging windows' font size is right.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1781
Re: patch for [debug windows]
« Reply #3 on: Yesterday at 04:13:28 pm »
What scale factor are you using?.

Offline srm2000

  • Single posting newcomer
  • *
  • Posts: 6
Re: patch for [debug windows]
« Reply #4 on: Today at 03:29:30 am »
What scale factor are you using?.
the scale factor is 2.0 .

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1781
Re: patch for [debug windows]
« Reply #5 on: Today at 11:31:03 am »
I have reverted the commit, as the original version only fixed your use case.

Now the dialogs are using the default control font (usually proportional) multiplied by the scale factor; This should fix the issue for all users.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6105
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: patch for [debug windows]
« Reply #6 on: Today at 04:38:40 pm »
One think to mention.

When I try to build the code under wx3.3, I have to add the include file:

Code
#include <wx/fontutil.h>

Otherwise, it will report that the wxNativeFontInfo is not complete. Strange that I haven't see this kinds of build error before.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6105
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: patch for [debug windows]
« Reply #7 on: Today at 04:40:48 pm »
@srm2000

Next time when you post the code, you should use the code format, which is when you click the "#" in your webpage's editor toolbar.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1781
Re: patch for [debug windows]
« Reply #8 on: Today at 06:01:31 pm »
I have removed the FontInfo stuff in a second commit, so the include should not be necessary, if it is feel free to add it (I currently cannot).