So basically I found out that you can only set font before the widget creation or font won't change, but I need to change the font after element creation so how can I do it?
void MyMain::makeBtnPanel()
{
btnPanel = new wxPanel(this, wxID_ANY);
wxGridSizer* grid = new wxGridSizer(5, 4, 2, 2);
// here is hidden code that is adding widgets to grid
btnPanel->SetSizer(grid);
sizer->Add(btnPanel, 5, wxEXPAND);
}
void MyMain::styleBtns()
{
wxFont mainBtnFont(
16,
wxFONTFAMILY_DEFAULT,
wxFONTSTYLE_NORMAL,
wxFONTWEIGHT_EXTRALIGHT
);
btnPanel->SetFont(mainBtnFont);
}
styleBtns
function is not working but if I set font immediately after btnPanel
creation (on 2nd line of makeBtnPanel
function) font will be set.
class constructor:
MyMain::MyMain()
: wxFrame(
NULL,
wxID_ANY,
"Calculator",
wxDefaultPosition,
wxSize(322, 392)
)
{
sizer = new wxBoxSizer(wxVERTICAL);
SetSizer(sizer);
makeDisplayPanel();
makeBtnPanel();
styleBtns();
setupMainFrame();
}
Omg, I'm so dumb. I couldn't change font because I was setting font to empty variables. I wrote else if
instead of if
and code didn't execute, it didn't set these variables.