Kaydet (Commit) 2140dea1 authored tarafından Caolán McNamara's avatar Caolán McNamara

split width/height to allow intercept of how width is calculated

in order to possibly get width on demand

Change-Id: I1e6fcb6849705f2b166821516ebe72b179e00ee7
Reviewed-on: https://gerrit.libreoffice.org/72513
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 259d01a3
......@@ -158,7 +158,7 @@ tools::Rectangle OCreationList::GetFocusRect( SvTreeListEntry* _pEntry, long _nL
SvViewDataItem* pItemData = pBitmapItem ? GetViewDataItem( _pEntry, pBitmapItem ) : nullptr;
OSL_ENSURE( pTab && pItemData, "OCreationList::GetFocusRect: could not find the first bitmap item!" );
if ( pTab && pItemData )
aRect.SetLeft( pTab->GetPos() - pItemData->maSize.Width() / 2 );
aRect.SetLeft( pTab->GetPos() - pItemData->mnWidth / 2 );
// inflate the rectangle a little bit - looks better, too
aRect.SetLeft( std::max< long >( 0, aRect.Left() - 2 ) );
......
......@@ -35,7 +35,8 @@ namespace dbaui
vcl::Font aFont( pView->GetFont());
aFont.SetWeight(WEIGHT_BOLD);
pView->Control::SetFont( aFont );
_pViewData->maSize = Size(pView->GetTextWidth(GetText()), pView->GetTextHeight());
_pViewData->mnWidth = pView->GetTextWidth(GetText());
_pViewData->mnHeight = pView->GetTextHeight();
pView->Pop();
}
......
......@@ -140,8 +140,10 @@ public:
SvLBoxItem();
virtual ~SvLBoxItem();
virtual SvLBoxItemType GetType() const = 0;
const Size& GetSize(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const;
static const Size& GetSize(const SvViewDataEntry* pData, sal_uInt16 nItemPos);
int GetWidth(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const;
int GetHeight(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const;
static int GetWidth(const SvViewDataEntry* pData, sal_uInt16 nItemPos);
static int GetHeight(const SvViewDataEntry* pData, sal_uInt16 nItemPos);
void Enable(bool bEnabled) { mbDisabled = !bEnabled; }
virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) = 0;
......
......@@ -28,7 +28,8 @@
struct SvViewDataItem
{
Size maSize;
int mnWidth = 0;
int mnHeight = 0;
};
/**
......
......@@ -730,7 +730,7 @@ void ScContentTree::RequestHelp( const HelpEvent& rHEvt )
aPos = GetEntryPosition( pEntry );
aPos.setX( GetTabPos( pEntry, pTab ) );
aPos = OutputToScreenPixel(aPos);
Size aSize( pItem->GetSize( this, pEntry ) );
Size aSize(pItem->GetWidth(this, pEntry), pItem->GetHeight(this, pEntry));
tools::Rectangle aItemRect( aPos, aSize );
Help::ShowQuickHelp( this, aItemRect, aHelpText );
......
......@@ -270,7 +270,8 @@ void CustomAnimationListEntryItem::InitViewData( SvTreeListBox* pView, SvTreeLis
Size aSize( width, pView->GetTextHeight() );
if( aSize.Height() < nItemMinHeight )
aSize.setHeight( nItemMinHeight );
pViewData->maSize = aSize;
pViewData->mnWidth = aSize.Width();
pViewData->mnHeight = aSize.Height();
}
void CustomAnimationListEntryItem::Paint(const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext,
......@@ -280,7 +281,7 @@ void CustomAnimationListEntryItem::Paint(const Point& rPos, SvTreeListBox& rDev,
const SvViewDataItem* pViewData = mpParent->GetViewDataItem(&rEntry, this);
Point aPos(rPos);
Size aSize(pViewData->maSize);
int nItemHeight = pViewData->mnHeight;
sal_Int16 nNodeType = mpEffect->getNodeType();
if (nNodeType == EffectNodeType::ON_CLICK )
......@@ -336,12 +337,12 @@ void CustomAnimationListEntryItem::Paint(const Point& rPos, SvTreeListBox& rDev,
{
Image aImage(StockImage::Yes, sImage);
Point aImagePos(aPos);
aImagePos.AdjustY((aSize.Height()/2 - aImage.GetSizePixel().Height()) >> 1 );
aImagePos.AdjustY((nItemHeight/2 - aImage.GetSizePixel().Height()) >> 1 );
rRenderContext.DrawImage(aImagePos, aImage);
}
aPos.AdjustX(nIconWidth );
aPos.AdjustY((aSize.Height()/2 - rDev.GetTextHeight()) >> 1 );
aPos.AdjustY((nItemHeight/2 - rDev.GetTextHeight()) >> 1 );
rRenderContext.DrawText(aPos, rRenderContext.GetEllipsisString(msEffectName, rDev.GetOutputSizePixel().Width() - aPos.X()));
}
......@@ -400,7 +401,8 @@ void CustomAnimationTriggerEntryItem::InitViewData( SvTreeListBox* pView, SvTree
Size aSize(pView->GetTextWidth( msDescription ) + 2 * nIconWidth, pView->GetTextHeight() );
if( aSize.Height() < nIconWidth )
aSize.setHeight( nIconWidth );
pViewData->maSize = aSize;
pViewData->mnWidth = aSize.Width();
pViewData->mnHeight = aSize.Height();
}
void CustomAnimationTriggerEntryItem::Paint(const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext,
......
......@@ -143,7 +143,9 @@ void StyleLBoxString::Paint(
{
if (pStylePreviewRenderer->recalculate())
{
mpViewData->maSize = pStylePreviewRenderer->getRenderSize();
Size aSize(pStylePreviewRenderer->getRenderSize());
mpViewData->mnWidth = aSize.Width();
mpViewData->mnHeight = aSize.Height();
}
else
{
......
......@@ -130,7 +130,7 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, long nX, long nY,
continue;
}
Size aSize(SvLBoxItem::GetSize(pViewDataEntry, nCurItem));
auto nItemHeight = SvLBoxItem::GetHeight(pViewDataEntry, nCurItem);
aEntryPos.setX( nX );
aEntryPos.setY( nY );
......@@ -189,7 +189,7 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, long nX, long nY,
}
// center vertically
aEntryPos.AdjustY((nTempEntryHeight - aSize.Height()) / 2 );
aEntryPos.AdjustY((nTempEntryHeight - nItemHeight) / 2 );
// draw item
pViewDataEntry->SetPaintRectangle(aRect);
......@@ -206,15 +206,16 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, long nX, long nY,
// draw icon
if(nIconItem != nItemCount && nIconItem < nItemCount)
{
Size aSize(SvLBoxItem::GetSize(pViewDataEntry, nIconItem));
auto nItemWidth = SvLBoxItem::GetWidth(pViewDataEntry, nIconItem);
auto nItemHeight = SvLBoxItem::GetHeight(pViewDataEntry, nIconItem);
aEntryPos.setX( nX );
aEntryPos.setY( nY );
// center horizontally
aEntryPos.AdjustX((nTempEntryWidth - aSize.Width()) / 2 );
aEntryPos.AdjustX((nTempEntryWidth - nItemWidth) / 2 );
// center vertically
aEntryPos.AdjustY((nTempEntryHeight - aSize.Height()) / 2 );
aEntryPos.AdjustY((nTempEntryHeight - nItemHeight) / 2 );
aEntryPos.AdjustY( -10 );
......
......@@ -1497,7 +1497,7 @@ void UnoTreeListItem::Paint(
const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* /*pView*/, const SvTreeListEntry& rEntry)
{
Point aPos(rPos);
Size aSize(GetSize(&rDev, &rEntry));
Size aSize(GetWidth(&rDev, &rEntry), GetHeight(&rDev, &rEntry));
if (!!maImage)
{
rRenderContext.DrawImage(aPos, maImage, rDev.IsEnabled() ? DrawImageFlags::NONE : DrawImageFlags::Disable);
......@@ -1536,18 +1536,21 @@ void UnoTreeListItem::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry
if( !pViewData )
pViewData = pView->GetViewDataItem( pEntry, this );
pViewData->maSize = maImage.GetSizePixel();
Size aSize(maImage.GetSizePixel());
pViewData->mnWidth = aSize.Width();
pViewData->mnHeight = aSize.Height();
const Size aTextSize(pView->GetTextWidth( maText ), pView->GetTextHeight());
if( pViewData->maSize.Width() )
if( pViewData->mnWidth )
{
pViewData->maSize.AdjustWidth(6 + aTextSize.Width() );
if( pViewData->maSize.Height() < aTextSize.Height() )
pViewData->maSize.setHeight( aTextSize.Height() );
pViewData->mnWidth += (6 + aTextSize.Width());
if( pViewData->mnHeight < aTextSize.Height() )
pViewData->mnHeight = aTextSize.Height();
}
else
{
pViewData->maSize = aTextSize;
pViewData->mnWidth = aTextSize.Width();
pViewData->mnHeight = aTextSize.Height();
}
}
......
......@@ -965,7 +965,8 @@ void FmFilterItemsString::Paint(const Point& rPos, SvTreeListBox& rDev, vcl::Ren
rRenderContext.Push(PushFlags::LINECOLOR);
rRenderContext.SetLineColor(rRenderContext.GetTextColor());
tools::Rectangle aRect(rPos, GetSize(&rDev, &rEntry));
Size aSize(GetWidth(&rDev, &rEntry), GetHeight(&rDev, &rEntry));
tools::Rectangle aRect(rPos, aSize);
Point aFirst(rPos.X(), aRect.Bottom() - 6);
Point aSecond(aFirst .X() + 2, aFirst.Y() + 3);
......@@ -991,7 +992,8 @@ void FmFilterItemsString::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pE
Size aSize(pView->GetTextWidth(GetText()), pView->GetTextHeight());
aSize.AdjustWidth(nxDBmp );
pViewData->maSize = aSize;
pViewData->mnWidth = aSize.Width();
pViewData->mnHeight = aSize.Height();
}
class FmFilterString : public SvLBoxString
......@@ -1013,7 +1015,6 @@ public:
const int nxD = 4;
void FmFilterString::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry, SvViewDataItem* pViewData)
{
if( !pViewData )
......@@ -1027,10 +1028,10 @@ void FmFilterString::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry,
Size aSize(pView->GetTextWidth(m_aName), pView->GetTextHeight());
pView->Control::SetFont( aOldFont );
aSize.AdjustWidth(pView->GetTextWidth(GetText()) + nxD );
pViewData->maSize = aSize;
pViewData->mnWidth = aSize.Width();
pViewData->mnHeight = aSize.Height();
}
void FmFilterString::Paint(const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext,
const SvViewDataEntry* /*pView*/, const SvTreeListEntry& /*rEntry*/)
{
......
......@@ -873,7 +873,7 @@ void SwGlTreeListBox::RequestHelp( const HelpEvent& rHEvt )
if(pItem)
{
aPos = GetEntryPosition( pEntry );
Size aSize(pItem->GetSize( this, pEntry ));
Size aSize(pItem->GetWidth(this, pEntry), pItem->GetHeight(this, pEntry));
aPos.setX( GetTabPos( pEntry, pTab ) );
if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
......
......@@ -3031,7 +3031,7 @@ void SwContentTree::RequestHelp( const HelpEvent& rHEvt )
aPos = GetEntryPosition( pEntry );
aPos.setX( GetTabPos( pEntry, pTab ) );
Size aSize( pItem->GetSize( this, pEntry ) );
Size aSize(pItem->GetWidth(this, pEntry), pItem->GetHeight(this, pEntry));
if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
aSize.setWidth( GetSizePixel().Width() - aPos.X() );
......
......@@ -505,7 +505,7 @@ void SwGlobalTree::RequestHelp( const HelpEvent& rHEvt )
Point aEntryPos = GetEntryPosition( pEntry );
aEntryPos.setX( GetTabPos( pEntry, pTab ) );
Size aSize( pItem->GetSize( this, pEntry ) );
Size aSize(pItem->GetWidth(this, pEntry), pItem->GetHeight(this, pEntry));
if((aEntryPos.X() + aSize.Width()) > GetSizePixel().Width())
aSize.setWidth( GetSizePixel().Width() - aEntryPos.X() );
......
......@@ -785,7 +785,7 @@ bool SvImpLBox::EntryReallyHit(SvTreeListEntry* pEntry, const Point& rPosPixel,
aRect.SetRight( GetOutputSize().Width() - pView->GetMapMode().GetOrigin().X() );
SvLBoxContextBmp* pBmp = static_cast<SvLBoxContextBmp*>(pEntry->GetFirstItem(SvLBoxItemType::ContextBmp));
aRect.AdjustLeft( -(pBmp->GetSize(pView,pEntry).Width()) );
aRect.AdjustLeft( -pBmp->GetWidth(pView,pEntry) );
aRect.AdjustLeft( -4 ); // a little tolerance
Point aPos( rPosPixel );
......@@ -3107,7 +3107,7 @@ bool SvImpLBox::RequestHelp( const HelpEvent& rHEvt )
aPos = GetEntryPosition( pEntry );
aPos.setX( pView->GetTabPos( pEntry, pTab ) ); //pTab->GetPos();
Size aSize( pItem->GetSize( pView, pEntry ) );
Size aSize(pItem->GetWidth(pView, pEntry), pItem->GetHeight(pView, pEntry));
SvLBoxTab* pNextTab = NextTab( pTab );
bool bItemClipped = false;
// is the item cut off by its right neighbor?
......@@ -3199,7 +3199,7 @@ bool SvImpLBox::SetMostRight( SvTreeListEntry* pEntry )
long nNextTab = nTabPos < nMaxRight ? nMaxRight : nMaxRight + 50;
long nTabWidth = nNextTab - nTabPos + 1;
long nItemSize = rItem.GetSize(pView,pEntry).Width();
auto nItemSize = rItem.GetWidth(pView,pEntry);
long nOffset = pTab->CalcOffset( nItemSize, nTabWidth );
long nRight = nTabPos + nOffset + nItemSize;
......
......@@ -196,7 +196,7 @@ void SvLBoxString::Paint(
const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext,
const SvViewDataEntry* /*pView*/, const SvTreeListEntry& rEntry)
{
Size aSize = GetSize(&rDev, &rEntry);
Size aSize;
DrawTextFlags nStyle = (rDev.IsEnabled() && !mbDisabled) ? DrawTextFlags::NONE : DrawTextFlags::Disable;
if (rDev.IsEntryMnemonicsEnabled())
nStyle |= DrawTextFlags::Mnemonic;
......@@ -205,6 +205,9 @@ void SvLBoxString::Paint(
nStyle |= DrawTextFlags::PathEllipsis | DrawTextFlags::Center;
aSize.setWidth( rDev.GetEntryWidth() );
}
else
aSize.setWidth(GetWidth(&rDev, &rEntry));
aSize.setHeight(GetHeight(&rDev, &rEntry));
if (mbEmphasized)
{
......@@ -241,7 +244,8 @@ void SvLBoxString::InitViewData(
pView->Control::SetFont( aFont );
}
pViewData->maSize = Size(pView->GetTextWidth(maText), pView->GetTextHeight());
pViewData->mnWidth = pView->GetTextWidth(maText);
pViewData->mnHeight = pView->GetTextHeight();
if (mbEmphasized)
pView->Pop();
......@@ -379,7 +383,8 @@ void SvLBoxButton::InitViewData(SvTreeListBox* pView,SvTreeListEntry* pEntry, Sv
ControlType eCtrlType = (pData->IsRadio())? ControlType::Radiobutton : ControlType::Checkbox;
if ( eKind != SvLBoxButtonKind::StaticImage && pView )
ImplAdjustBoxSize(aSize, eCtrlType, *pView);
pViewData->maSize = aSize;
pViewData->mnWidth = aSize.Width();
pViewData->mnHeight = aSize.Height();
}
bool SvLBoxButton::CheckModification() const
......@@ -444,7 +449,9 @@ void SvLBoxContextBmp::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntr
{
if( !pViewData )
pViewData = pView->GetViewDataItem( pEntry, this );
pViewData->maSize = m_pImpl->m_aImage1.GetSizePixel();
Size aSize = m_pImpl->m_aImage1.GetSizePixel();
pViewData->mnWidth = aSize.Width();
pViewData->mnHeight = aSize.Height();
}
void SvLBoxContextBmp::Paint(
......
......@@ -303,16 +303,28 @@ SvLBoxItem::~SvLBoxItem()
{
}
const Size& SvLBoxItem::GetSize(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const
int SvLBoxItem::GetWidth(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const
{
const SvViewDataItem* pViewData = pView->GetViewDataItem( pEntry, this );
return pViewData->maSize;
return pViewData->mnWidth;
}
const Size& SvLBoxItem::GetSize(const SvViewDataEntry* pData, sal_uInt16 nItemPos)
int SvLBoxItem::GetHeight(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const
{
const SvViewDataItem* pViewData = pView->GetViewDataItem( pEntry, this );
return pViewData->mnHeight;
}
int SvLBoxItem::GetWidth(const SvViewDataEntry* pData, sal_uInt16 nItemPos)
{
const SvViewDataItem& rIData = pData->GetItem(nItemPos);
return rIData.mnWidth;
}
int SvLBoxItem::GetHeight(const SvViewDataEntry* pData, sal_uInt16 nItemPos)
{
const SvViewDataItem& rIData = pData->GetItem(nItemPos);
return rIData.maSize;
return rIData.mnHeight;
}
struct SvTreeListBoxImpl
......@@ -1679,7 +1691,7 @@ void SvTreeListBox::CheckBoxInserted(SvTreeListEntry* pEntry)
SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetFirstItem(SvLBoxItemType::Button));
if( pItem )
{
long nWidth = pItem->GetSize(this, pEntry).Width();
auto nWidth = pItem->GetWidth(this, pEntry);
if( mnCheckboxItemWidth < nWidth )
{
mnCheckboxItemWidth = nWidth;
......@@ -2028,7 +2040,7 @@ void SvTreeListBox::SetEntryHeight( SvTreeListEntry const * pEntry )
SvViewDataEntry* pViewData = GetViewDataEntry( pEntry );
while( nCur < nCount )
{
short nHeight = static_cast<short>(SvLBoxItem::GetSize( pViewData, nCur ).Height());
auto nHeight = SvLBoxItem::GetHeight(pViewData, nCur);
if( nHeight > nHeightMax )
nHeightMax = nHeight;
nCur++;
......@@ -2396,12 +2408,12 @@ void SvTreeListBox::EditItemText(SvTreeListEntry* pEntry, SvLBoxString* pItem, c
SvLBoxTab* pTab = GetTab( pEntry, pItem );
DBG_ASSERT(pTab,"EditItemText:Tab not found");
Size aItemSize( pItem->GetSize(this, pEntry) );
auto nItemHeight( pItem->GetHeight(this, pEntry) );
Point aPos = GetEntryPosition( pEntry );
aPos.AdjustY(( nEntryHeight - aItemSize.Height() ) / 2 );
aPos.AdjustY(( nEntryHeight - nItemHeight ) / 2 );
aPos.setX( GetTabPos( pEntry, pTab ) );
long nOutputWidth = pImpl->GetOutputSize().Width();
Size aSize( nOutputWidth - aPos.X(), aItemSize.Height() );
Size aSize( nOutputWidth - aPos.X(), nItemHeight );
sal_uInt16 nPos = std::find_if( aTabs.begin(), aTabs.end(),
[pTab](const std::unique_ptr<SvLBoxTab>& p) { return p.get() == pTab; })
- aTabs.begin();
......@@ -2633,7 +2645,8 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render
SvLBoxItem& rItem = rEntry.GetItem(nCurItem);
SvLBoxTabFlags nFlags = pTab->nFlags;
Size aSize(SvLBoxItem::GetSize(pViewDataEntry, nCurItem));
Size aSize(SvLBoxItem::GetWidth(pViewDataEntry, nCurItem),
SvLBoxItem::GetHeight(pViewDataEntry, nCurItem));
long nTabPos = GetTabPos(&rEntry, pTab);
long nNextTabPos;
......@@ -2911,7 +2924,7 @@ tools::Rectangle SvTreeListBox::GetFocusRect( SvTreeListEntry* pEntry, long nLin
if( pTab && nCurTab < pEntry->ItemCount() )
{
SvLBoxItem& rItem = pEntry->GetItem( nCurTab );
aSize.setWidth( rItem.GetSize( this, pEntry ).Width() );
aSize.setWidth(rItem.GetWidth(this, pEntry));
if( !aSize.Width() )
aSize.setWidth( 15 );
long nX = nTabPos; //GetTabPos( pEntry, pTab );
......@@ -3013,9 +3026,9 @@ SvLBoxItem* SvTreeListBox::GetItem_Impl( SvTreeListEntry* pEntry, long nX,
nNextTabPos += 50;
}
Size aItemSize( pItem->GetSize(this, pEntry));
nStart += pTab->CalcOffset( aItemSize.Width(), nNextTabPos - nStart );
long nLen = aItemSize.Width();
auto nItemWidth(pItem->GetWidth(this, pEntry));
nStart += pTab->CalcOffset(nItemWidth, nNextTabPos - nStart);
auto nLen = nItemWidth;
if( pNextTab )
{
long nTabWidth = GetTabPos( pEntry, pNextTab ) - nStart;
......@@ -3055,7 +3068,7 @@ long SvTreeListBox::getPreferredDimensions(std::vector<long> &rWidths) const
while (nCurPos < nCount)
{
SvLBoxItem& rItem = pEntry->GetItem( nCurPos );
long nWidth = rItem.GetSize(this, pEntry).Width();
auto nWidth = rItem.GetWidth(this, pEntry);
if (nWidth)
{
nWidth += SV_TAB_BORDER * 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment