Opened 8 years ago

Closed 6 years ago

#3939 closed defect (fixed)

Can't set font and colours of stock buttons

Reported by: hzd_byte Owned by:
Priority: normal Milestone: 2.8.9
Component: wxGTK Version:
Keywords: wxButton Cc: hzd_byte
Blocked By: Blocking:
Patch: yes

Description

In wxGTK, when I create buttons with wxID_OK and wxID_CANCEL and text "OK" / "Cancel", standard GTK's OK and Cancel buttons created with bitmaps.

But text's color for this buttons doesn't change with SetForegroundColour, and size of this buttons doesn't change with sizers automatically.

When I use my own ID's and/or labels, there is all ok.

Attachments (2)

Bad.png download (24.3 KB) - added by hzd_byte 8 years ago.
button-apply-style.diff download (987 bytes) - added by wojdyr 7 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 8 years ago by vadz

It maybe normal that GTK+ doesn't allow changing the colour of the stock buttons but I don't understand the part about the sizers. Could you please explain better what the problem is?

Changed 8 years ago by hzd_byte

comment:2 Changed 8 years ago by hzd_byte

But background color of these buttons changes!...

Look at attached image. Code for this (dialog's constructor):

SetBackgroundColour(backColor);
wxSizer *sizerUp = new wxBoxSizer(wxVERTICAL);
m_desc = new QSPTextBox(this, ID_DESC);
...
wxTextCtrl *inputStr = new wxTextCtrl(this, wxID_ANY);
inputStr->SetBackgroundColour(backColor);
inputStr->SetForegroundColour(fontColor);
inputStr->SetFont(font);
wxStaticLine* line = new wxStaticLine(this, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL);
sizerUp->Add(m_desc, 1, wxALL | wxGROW, 5);
sizerUp->Add(inputStr, 0, wxALL | wxGROW, 5);
sizerUp->Add(line, 0, wxALL | wxGROW, 5);
----------
wxSizer *sizerBottom = new wxBoxSizer(wxHORIZONTAL);
wxButton *btnOk = new wxButton(this, wxID_OK, _("OK"));
btnOk->SetBackgroundColour(backColor);
btnOk->SetForegroundColour(fontColor);
btnOk->SetFont(font);
wxButton *btnCancel = new wxButton(this, wxID_CANCEL, _("Cancel"));
btnCancel->SetBackgroundColour(backColor);
btnCancel->SetForegroundColour(fontColor);
btnCancel->SetFont(font);
sizerBottom->Add(btnOk, 0, wxALL, 5);
sizerBottom->Add(btnCancel, 0, wxALL, 5);
----------
wxSizer *sizerMain = new wxBoxSizer(wxVERTICAL);
sizerMain->Add(sizerUp, 1, wxGROW, 0);
sizerMain->Add(sizerBottom, 0, wxALIGN_RIGHT, 0);
----------
inputStr->SetValidator(wxGenericValidator(&m_text));
sizerMain->SetMinSize(300, 200);
SetAutoLayout(true);
SetSizer(sizerMain);
sizerMain->Fit(this);
sizerMain->SetSizeHints(this);

File Added: Bad.png

comment:3 Changed 7 years ago by vadz

I guess we should't use the stock buttons if non-default font or colours are used, unless it's somehow possible to apply the fonts/colours to stock buttons too?

comment:4 Changed 7 years ago by wojdyr

  • Keywords wxButton added
  • Patch set
  • Status changed from new to confirmed

I'm attaching patch that fixes the issue with the style of label.
Sizing works fine for me.

Changed 7 years ago by wojdyr

comment:5 Changed 7 years ago by vadz

  • Cc vadz removed
  • Milestone set to 2.8.9
  • Resolution set to port to stable
  • Status changed from confirmed to portneeded

Thanks Marcin, applied to the trunk as r54138. This should be safe to backport to 2.8, shouldn't it?

comment:6 Changed 6 years ago by vadz

  • Resolution changed from port to stable to fixed
  • Status changed from portneeded to closed

Backported into 2.8.9 as r55209.

Note: See TracTickets for help on using tickets.