Make stretchable spacers work in vertical toolbars too in wxMSW.
Replace the old implementation of stretchable spacers based on changing the size of the separators used as spacers as the toolbar size itself changed with a new one, simply replacing the old separator with the new one of the correct size, as it also works for the vertical toolbars, unlike the old approach. Closes #13673. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76092 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
f2fbc84dcb
commit
74f21995ca
@ -47,6 +47,7 @@ wxMSW:
|
|||||||
- Fix handling of selected images in wxBitmapButton (Artur Wieczorek).
|
- Fix handling of selected images in wxBitmapButton (Artur Wieczorek).
|
||||||
- Fix loading of bitmap with non-pre-multiplied alpha (Artur Wieczorek).
|
- Fix loading of bitmap with non-pre-multiplied alpha (Artur Wieczorek).
|
||||||
- Support multiline strings in wxDC::DrawRotatedText() (Artur Wieczorek).
|
- Support multiline strings in wxDC::DrawRotatedText() (Artur Wieczorek).
|
||||||
|
- Fix stretchable spacers in vertical toolbars (Artur Wieczorek).
|
||||||
|
|
||||||
wxOSX/Cocoa:
|
wxOSX/Cocoa:
|
||||||
|
|
||||||
|
@ -1254,19 +1254,34 @@ bool wxToolBar::Realize()
|
|||||||
InvalidateBestSize();
|
InvalidateBestSize();
|
||||||
UpdateSize();
|
UpdateSize();
|
||||||
|
|
||||||
|
if ( IsVertical() )
|
||||||
|
{
|
||||||
|
// For vertical toolbar heights of buttons are incorrect
|
||||||
|
// unless TB_AUTOSIZE in invoked.
|
||||||
|
// We need to recalculate fixed elements size again.
|
||||||
|
m_totalFixedSize = 0;
|
||||||
|
toolIndex = 0;
|
||||||
|
for ( node = m_tools.GetFirst(); node; node = node->GetNext(), toolIndex++ )
|
||||||
|
{
|
||||||
|
wxToolBarTool * const tool = (wxToolBarTool*)node->GetData();
|
||||||
|
if ( !tool->IsStretchableSpace() )
|
||||||
|
{
|
||||||
|
const RECT r = wxGetTBItemRect(GetHwnd(), toolIndex);
|
||||||
|
if ( !IsVertical() )
|
||||||
|
m_totalFixedSize += r.right - r.left;
|
||||||
|
else if ( !tool->IsControl() )
|
||||||
|
m_totalFixedSize += r.bottom - r.top;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Enforce invoking UpdateStretchableSpacersSize() with correct value of fixed elements size.
|
||||||
|
UpdateSize();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::UpdateStretchableSpacersSize()
|
void wxToolBar::UpdateStretchableSpacersSize()
|
||||||
{
|
{
|
||||||
#ifdef TB_SETBUTTONINFO
|
|
||||||
// we can't resize the spacers if TB_SETBUTTONINFO is not supported (we
|
|
||||||
// could try to do it with multiple separators as for the controls but this
|
|
||||||
// is too painful and it just doesn't seem to be worth doing for the
|
|
||||||
// ancient systems)
|
|
||||||
if ( wxApp::GetComCtl32Version() < 471 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// check if we have any stretchable spacers in the first place
|
// check if we have any stretchable spacers in the first place
|
||||||
unsigned numSpaces = 0;
|
unsigned numSpaces = 0;
|
||||||
wxToolBarToolsList::compatibility_iterator node;
|
wxToolBarToolsList::compatibility_iterator node;
|
||||||
@ -1314,23 +1329,38 @@ void wxToolBar::UpdateStretchableSpacersSize()
|
|||||||
|
|
||||||
const RECT rcOld = wxGetTBItemRect(GetHwnd(), toolIndex);
|
const RECT rcOld = wxGetTBItemRect(GetHwnd(), toolIndex);
|
||||||
|
|
||||||
WinStruct<TBBUTTONINFO> tbbi;
|
const int oldSize = IsVertical()? (rcOld.bottom - rcOld.top): (rcOld.right - rcOld.left);
|
||||||
tbbi.dwMask = TBIF_SIZE;
|
const int newSize = --numSpaces ? sizeSpacer : sizeLastSpacer;
|
||||||
tbbi.cx = --numSpaces ? sizeSpacer : sizeLastSpacer;
|
if ( newSize != oldSize)
|
||||||
|
{
|
||||||
|
if ( !::SendMessage(GetHwnd(), TB_DELETEBUTTON, toolIndex, 0) )
|
||||||
|
{
|
||||||
|
wxLogLastError(wxT("TB_DELETEBUTTON (separator)"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TBBUTTON button;
|
||||||
|
wxZeroMemory(button);
|
||||||
|
|
||||||
if ( !::SendMessage(GetHwnd(), TB_SETBUTTONINFO,
|
button.idCommand = tool->GetId();
|
||||||
tool->GetId(), (LPARAM)&tbbi) )
|
button.iBitmap = newSize; // set separator width/height
|
||||||
{
|
button.fsState = TBSTATE_ENABLED;
|
||||||
wxLogLastError(wxT("TB_SETBUTTONINFO"));
|
button.fsStyle = TBSTYLE_SEP;
|
||||||
}
|
if ( IsVertical() )
|
||||||
else
|
button.fsState |= TBSTATE_WRAP;
|
||||||
{
|
if ( !::SendMessage(GetHwnd(), TB_INSERTBUTTON, toolIndex, (LPARAM)&button) )
|
||||||
// we successfully resized this one, move all the controls after it
|
{
|
||||||
// by the corresponding amount (may be positive or negative)
|
wxLogLastError(wxT("TB_INSERTBUTTON (separator)"));
|
||||||
offset += tbbi.cx - (rcOld.right - rcOld.left);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We successfully replaced this seprator, move all the controls after it
|
||||||
|
// by the corresponding amount (may be positive or negative)
|
||||||
|
offset += newSize - oldSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // TB_SETBUTTONINFO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -1843,6 +1873,11 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam)
|
|||||||
rcItem.bottom = rectTotal.height;
|
rcItem.bottom = rectTotal.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apparently, regions of height < 3 are not taken into account
|
||||||
|
// in clipping so we need to extend them for this purpose.
|
||||||
|
if ( rcItem.bottom - rcItem.top > 0 && rcItem.bottom - rcItem.top < 3 )
|
||||||
|
rcItem.bottom = rcItem.top + 3;
|
||||||
|
|
||||||
rgnDummySeps.Union(wxRectFromRECT(rcItem));
|
rgnDummySeps.Union(wxRectFromRECT(rcItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user