Fix displaying labels in small wxPropertyGrid editor buttons
We need to create wxButtons without internal border (with wxBU_EXACTFIT flag) to display button labels properly even if buttons are small. See #18715.
This commit is contained in:
parent
e8be37da3d
commit
c7aeba7ed5
@ -1980,42 +1980,24 @@ wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize
|
|||||||
wxASSERT(selected);
|
wxASSERT(selected);
|
||||||
|
|
||||||
const wxString label = wxString::FromUTF8("\xe2\x80\xa6"); // "Horizontal ellipsis" character
|
const wxString label = wxString::FromUTF8("\xe2\x80\xa6"); // "Horizontal ellipsis" character
|
||||||
#ifdef __WXMAC__
|
|
||||||
// Decorations are chunky on Mac, and we can't make the button square, so
|
|
||||||
// do things a bit differently on this platform.
|
|
||||||
|
|
||||||
wxPoint p(pos.x+sz.x, pos.y- wxPG_BUTTON_BORDER_WIDTH);
|
int dim = sz.y + 2*wxPG_BUTTON_BORDER_WIDTH;
|
||||||
wxSize s(25, wxDefaultCoord);
|
|
||||||
|
|
||||||
wxButton* but = new wxButton();
|
wxPoint p(pos.x + sz.x, pos.y - wxPG_BUTTON_BORDER_WIDTH);
|
||||||
but->Create(GetPanel(),wxID_ANY,label,p,s,wxWANTS_CHARS);
|
wxSize s(wxDefaultCoord, dim);
|
||||||
|
|
||||||
// Now that we know the size, move to the correct position
|
|
||||||
p.x = pos.x + sz.x - but->GetSize().x - 2;
|
|
||||||
but->Move(p);
|
|
||||||
|
|
||||||
#else
|
|
||||||
wxSize s(sz.y + 2*wxPG_BUTTON_BORDER_WIDTH, sz.y + 2*wxPG_BUTTON_BORDER_WIDTH);
|
|
||||||
|
|
||||||
// Reduce button width to line height
|
|
||||||
if ( s.x > m_lineHeight )
|
|
||||||
s.x = m_lineHeight;
|
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
|
||||||
// On wxGTK, take fixed button margins into account
|
|
||||||
if ( s.x < 25 )
|
|
||||||
s.x = 25;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxPoint p(pos.x+sz.x-s.x, pos.y-wxPG_BUTTON_BORDER_WIDTH);
|
|
||||||
|
|
||||||
wxButton* but = new wxButton();
|
wxButton* but = new wxButton();
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
but->Hide();
|
but->Hide();
|
||||||
#endif
|
#endif
|
||||||
but->Create(GetPanel(),wxID_ANY,label,p,s,wxWANTS_CHARS);
|
but->Create(GetPanel(),wxID_ANY,label,p,s,wxWANTS_CHARS|wxBU_EXACTFIT);
|
||||||
but->SetFont(GetFont());
|
but->SetFont(GetFont().GetBaseFont().Smaller());
|
||||||
#endif
|
// If button is narrow make it a square and move it to the correct position
|
||||||
|
s = but->GetSize();
|
||||||
|
if ( s.x < s.y )
|
||||||
|
but->SetSize(wxSize(s.y, s.y));
|
||||||
|
p.x = pos.x + sz.x - s.y;
|
||||||
|
but->Move(p);
|
||||||
|
|
||||||
if ( selected->HasFlag(wxPG_PROP_READONLY) && !selected->HasFlag(wxPG_PROP_ACTIVE_BTN) )
|
if ( selected->HasFlag(wxPG_PROP_READONLY) && !selected->HasFlag(wxPG_PROP_ACTIVE_BTN) )
|
||||||
but->Disable();
|
but->Disable();
|
||||||
@ -2137,6 +2119,7 @@ wxPGMultiButton::wxPGMultiButton( wxPropertyGrid* pg, const wxSize& sz )
|
|||||||
m_fullEditorSize(sz), m_buttonsWidth(0)
|
m_fullEditorSize(sz), m_buttonsWidth(0)
|
||||||
{
|
{
|
||||||
SetBackgroundColour(pg->GetCellBackgroundColour());
|
SetBackgroundColour(pg->GetCellBackgroundColour());
|
||||||
|
SetFont(pg->GetFont().GetBaseFont().Smaller());
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPGMultiButton::Finalize( wxPropertyGrid* WXUNUSED(propGrid),
|
void wxPGMultiButton::Finalize( wxPropertyGrid* WXUNUSED(propGrid),
|
||||||
@ -2166,8 +2149,13 @@ void wxPGMultiButton::Add( const wxString& label, int itemid )
|
|||||||
{
|
{
|
||||||
itemid = GenId(itemid);
|
itemid = GenId(itemid);
|
||||||
wxSize sz = GetSize();
|
wxSize sz = GetSize();
|
||||||
wxButton* button = new wxButton( this, itemid, label, wxPoint(sz.x, 0),
|
wxButton* button = new wxButton(this, itemid, label,
|
||||||
wxSize(sz.y, sz.y) );
|
wxPoint(sz.x, 0), wxSize(wxDefaultCoord, sz.y), wxBU_EXACTFIT);
|
||||||
|
// If button is narrow make it a square
|
||||||
|
wxSize szBtn = button->GetSize();
|
||||||
|
if ( szBtn.x < szBtn.y )
|
||||||
|
button->SetSize(wxSize(szBtn.y, szBtn.y));
|
||||||
|
|
||||||
DoAddButton( button, sz );
|
DoAddButton( button, sz );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user