LibreOffice Module sfx2 (master) 1
templatedefaultview.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
12#include <templateviewitem.hxx>
13#include <sfx2/sfxresid.hxx>
14#include <vcl/event.hxx>
15#include <vcl/svapp.hxx>
16
17#include <sfx2/strings.hrc>
18
19#include <officecfg/Office/Common.hxx>
20
21constexpr int gnItemPadding(5); //TODO:: Change padding to 10. It looks really crowded and occupied.
23
24TemplateDefaultView::TemplateDefaultView(std::unique_ptr<weld::ScrolledWindow> xWindow,
25 std::unique_ptr<weld::Menu> xMenu)
26 : TemplateLocalView(std::move(xWindow), std::move(xMenu))
27{
29 tools::Long nItemMaxSize = std::min(aScreen.GetWidth(),aScreen.GetHeight()) > 800 ? 256 : 192;
30 ThumbnailView::setItemDimensions( nItemMaxSize, nItemMaxSize, gnTextHeight, gnItemPadding );
31 updateThumbnailDimensions(nItemMaxSize);
32
33 // startcenter specific settings
34 maFillColor = Color(ColorTransparency, officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsBackgroundColor::get());
35 maTextColor = Color(ColorTransparency, officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsTextColor::get());
36 maHighlightColor = Color(ColorTransparency, officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsHighlightColor::get());
37 maHighlightTextColor = Color(ColorTransparency, officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsHighlightTextColor::get());
39
41}
42
44{
45 mnCurRegionId = 0;
46
48}
49
51{
52 return ThumbnailView::KeyInput(rKEvt);
53}
54
56{
57 if( rMEvt.IsLeft() && rMEvt.GetClicks() == 1 )
58 {
59 size_t nPos = ImplGetItem(rMEvt.GetPosPixel());
61 TemplateViewItem* pViewItem = dynamic_cast<TemplateViewItem*>(pItem);
62 if(pViewItem)
63 maOpenTemplateHdl.Call(pViewItem);
64 return true;
65 }
66
68}
69
71{
72 mxContextMenu->clear();
73 mxContextMenu->append("open",SfxResId(STR_OPEN));
74 mxContextMenu->append("edit",SfxResId(STR_EDIT_TEMPLATE));
79 Invalidate();
80}
81
82/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static unsigned int GetDisplayBuiltInScreen()
static tools::Rectangle GetScreenPosSizePixel(unsigned int nScreen)
sal_uInt16 GetClicks() const
const Point & GetPosPixel() const
bool IsLeft() const
TemplateDefaultView(std::unique_ptr< weld::ScrolledWindow > xWindow, std::unique_ptr< weld::Menu > xMenu)
virtual bool KeyInput(const KeyEvent &rKEvt) override
virtual void showAllTemplates() override
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
std::vector< TemplateItemProperties > maAllTemplates
void ContextMenuSelectHdl(std::u16string_view rIdent)
void updateThumbnailDimensions(tools::Long itemMaxSize)
void insertItems(const std::vector< TemplateItemProperties > &rTemplates, bool isRegionSelected=true, bool bShowCategoryInTooltip=false)
Link< ThumbnailViewItem *, void > maOpenTemplateHdl
TemplateViewItem * maSelectedItem
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
void setSelection(bool state)
void deselectItems()
deselect all current selected items.
Link< const ThumbnailViewItem *, void > maItemStateHdl
size_t ImplGetItem(const Point &rPoint) const
virtual bool KeyInput(const KeyEvent &rKEvt) override
Color maHighlightColor
Color of the highlight (background) of the hovered item.
std::unique_ptr< weld::Menu > mxContextMenu
double mfHighlightTransparence
Transparence of the highlight.
Color maHighlightTextColor
Color of the text for the highlighted item.
void setItemDimensions(tools::Long ItemWidth, tools::Long ThumbnailHeight, tools::Long DisplayHeight, int itemPadding)
Color maTextColor
Text color.
Color maFillColor
Background color of the thumbnail view widget.
constexpr tools::Long GetWidth() const
constexpr tools::Long GetHeight() const
weld::DrawingArea * GetDrawingArea() const
ColorTransparency
sal_uInt16 nPos
Definition: linksrc.cxx:118
long Long
OUString SfxResId(TranslateId aId)
Definition: sfxresid.cxx:22
constexpr int gnItemPadding(5)
constexpr tools::Long gnTextHeight