'wxWidgets 3.1.6, wxAuiNotebook Font Problems
I just upgraded to wxWidgets 3.1.6 and it seems there are loads of fixes and upgrades. However, I ran into the problem of rather small font size for notebook page text.
I am using wxAuiNotebook to host CWorksheet a class derived from wxGrid. The notebook constructs as follows:
CWorksheetNotebook::CWorksheetNotebook(CWorkbook* parent) :
wxAuiNotebook(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_DEFAULT_STYLE), m_Workbook{ parent }
{
SetFont(wxFont(11, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, "Arial"));
....
//SetMeasuringFont, SetNormalFont does not have any effect
}
Then to add a Worksheet to the notebook:
auto panel = new wxPanel(this);
auto sizer = new wxBoxSizer(wxVERTICAL);
auto varGrid = new CWorksheet(panel, m_Workbook, WSLabel, nrows, ncols);
sizer->Add(varGrid, 1, wxALL | wxEXPAND, 5);
panel->SetSizer(sizer);
AddPage(panel, WSLabel, true);
Here, if I manually set the font (as in the constructor) the page text font changes to a larger one but then I have another problem arising from setting the font manually. Setting the font of wxAuiNotebook changes Column and Row labels fonts in CWorksheet.
The worksheet implements the virtual methods from wxGrid:
void DrawColLabel(wxDC& dc, int col) override;
void DrawColLabels(wxDC& dc, const wxArrayInt& cols) override;
//Similarly for Rows
The implementation of DrawColLabel is:
wxPen InitialPen = dc.GetPen();
wxBrush InitialBrush = dc.GetBrush();
wxRect Rect(GetColLeft(col), 0, GetColWidth(col), GetColLabelSize());
wxBrush brush;
brush.SetColour(wxColor(224, 224, 224));
brush.SetStyle(wxBRUSHSTYLE_SOLID);
dc.SetBrush(brush);
dc.DrawRectangle(Rect);
dc.SetTextForeground(wxColor(0, 102, 0));
dc.DrawLabel(GetColLabelValue(col), Rect, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL);
dc.SetPen(wxPen(wxColor(0, 255, 0), 3));
dc.DrawLine(Rect.GetBottomLeft(), Rect.GetBottomRight());
dc.SetPen(InitialPen);
dc.SetBrush(InitialBrush);
I did not have the problem of small fonts when using wxWidgets 3.1.4. I am using Visual Studio 2022 (14.2 for compiler) on Windows 10.
Thanks in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
