Do not limit label width in wxToolBar by control width
This removes irregular behaviour in setting the label of a control. Creating a control with label now behaves the same as setting or changing the label later on. And behaves the same as for other tools in the wxToolBar. Closes https://github.com/wxWidgets/wxWidgets/pull/1289
This commit is contained in:
committed by
Vadim Zeitlin
parent
20c7421a67
commit
94907d3893
@@ -333,10 +333,6 @@ public:
|
|||||||
@param label
|
@param label
|
||||||
Text to be displayed near the control.
|
Text to be displayed near the control.
|
||||||
|
|
||||||
@remarks
|
|
||||||
wxMSW: the label is only displayed if there is enough space
|
|
||||||
available below the embedded control.
|
|
||||||
|
|
||||||
@remarks
|
@remarks
|
||||||
wxMac: labels are only displayed if wxWidgets is built with @c
|
wxMac: labels are only displayed if wxWidgets is built with @c
|
||||||
wxMAC_USE_NATIVE_TOOLBAR set to 1
|
wxMAC_USE_NATIVE_TOOLBAR set to 1
|
||||||
|
@@ -194,39 +194,32 @@ public:
|
|||||||
{
|
{
|
||||||
if ( m_staticText )
|
if ( m_staticText )
|
||||||
{
|
{
|
||||||
if ( !label.empty() )
|
if ( !label.empty() )
|
||||||
{
|
{
|
||||||
m_staticText->SetLabel(label);
|
m_staticText->SetLabel(label);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete m_staticText;
|
delete m_staticText;
|
||||||
m_staticText = NULL;
|
m_staticText = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( !label.empty() )
|
if ( !label.empty() )
|
||||||
{
|
{
|
||||||
// Create a control to render the control's label.
|
m_staticText = new wxStaticText(m_tbar, wxID_ANY, label);
|
||||||
// It has the same witdh as the control.
|
}
|
||||||
wxSize size(m_control->GetSize().GetWidth(), wxDefaultCoord);
|
|
||||||
m_staticText = new wxStaticText(m_tbar, wxID_ANY, label,
|
|
||||||
wxDefaultPosition, size,
|
|
||||||
wxALIGN_CENTRE | wxST_NO_AUTORESIZE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( IsButton() )
|
|
||||||
{
|
// Because new label can have different length than the old one
|
||||||
// Because new label can have different length than the old one
|
// so updating button's label with TB_SETBUTTONINFO would require
|
||||||
// so updating button's label with TB_SETBUTTONINFO would require
|
// also manual re-positionining items in the control tools located
|
||||||
// also manual re-positionining items in the control tools located
|
// to the right in the toolbar and recalculation of stretchable
|
||||||
// to the right in the toolbar and recalculation of stretchable
|
// spacers so it is easier just to recreate the toolbar with
|
||||||
// spacers so it is easier just to recreate the toolbar with
|
// Realize(). Performance penalty should be negligible.
|
||||||
// Realize(). Performance penalty should be negligible.
|
m_tbar->Realize();
|
||||||
m_tbar->Realize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxStaticText* GetStaticText()
|
wxStaticText* GetStaticText()
|
||||||
|
Reference in New Issue
Block a user