/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
for (const CategoryDescriptor& aCategory : aCategories)
{ // E_TABLE is 0, but 0 means void so use id of enum + 1
std::unique_ptr<ThumbnailViewItem> xItem(new ThumbnailViewItem(*this, aCategory.eType + 1));
xItem->mbBorder = false;
xItem->maPreview1 = BitmapEx(aCategory.aImageResId); const Size& rSize = xItem->maPreview1.GetSizePixel();
m_nMaxWidth = std::max(m_nMaxWidth, rSize.Width());
m_nMaxHeight = std::max(m_nMaxHeight, rSize.Height());
xItem->maTitle = DBA_RES(aCategory.pLabelResId);
m_nMaxWidth = std::max<tools::Long>(m_nMaxWidth, GetTextWidth(xItem->maTitle));
AppendItem(std::move(xItem));
}
constint nMargin = 12; constint nWidthRequest = m_nMaxWidth + 2 * nMargin;
set_size_request(nWidthRequest, -1); // we expect a Resize at which point we'll set the item sizes based on our final size
}
ElementType OApplicationIconControl::GetSelectedItem() const
{ for (constauto& rItem : mItemList)
{ if (!rItem->mbSelected) continue; returnstatic_cast<ElementType>(rItem->mnId - 1);
} return E_NONE;
}
void OApplicationIconControl::createIconAutoMnemonics(MnemonicGenerator& rMnemonics)
{ for (constauto& rItem : mItemList)
rMnemonics.RegisterMnemonic(rItem->maTitle);
// exchange texts with generated mnemonics for (auto& rItem : mItemList)
rItem->maTitle = rMnemonics.CreateMnemonic(rItem->maTitle);
}
void OApplicationIconControl::Resize()
{ // fill the full width of the allocated area and give two lines of space to // center the title in
setItemDimensions(GetOutputSizePixel().Width(), m_nMaxHeight, GetTextHeight() * 2, 0);
ThumbnailView::Resize();
}
void OApplicationIconControl::GetFocus()
{
ThumbnailView::GetFocus();
Invalidate(); // redraw focus rect
}
void OApplicationIconControl::LoseFocus()
{
ThumbnailView::LoseFocus();
Invalidate(); // redraw focus rect
}
tools::Rectangle OApplicationIconControl::GetFocusRect()
{ if (HasFocus())
{ // Get the last selected item in the list for (tools::Long i = mFilteredItemList.size() - 1; i >= 0; --i)
{
ThumbnailViewItem* pItem = mFilteredItemList[i]; if (pItem->isSelected())
{
tools::Rectangle aRet(pItem->getDrawArea());
aRet.AdjustLeft(THUMBNAILVIEW_ITEM_CORNER);
aRet.AdjustTop(1);
aRet.AdjustRight(-THUMBNAILVIEW_ITEM_CORNER);
aRet.AdjustBottom(-2); return aRet;
}
}
} return tools::Rectangle();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.