summaryrefslogtreecommitdiffstats
path: root/sfx2/source/control/templatedefaultview.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /sfx2/source/control/templatedefaultview.cxx
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sfx2/source/control/templatedefaultview.cxx')
-rw-r--r--sfx2/source/control/templatedefaultview.cxx92
1 files changed, 92 insertions, 0 deletions
diff --git a/sfx2/source/control/templatedefaultview.cxx b/sfx2/source/control/templatedefaultview.cxx
new file mode 100644
index 000000000..65415520b
--- /dev/null
+++ b/sfx2/source/control/templatedefaultview.cxx
@@ -0,0 +1,92 @@
+/* -*- 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/.
+ */
+
+#include <templatedefaultview.hxx>
+#include <sfx2/thumbnailview.hxx>
+#include <templateviewitem.hxx>
+#include <sfx2/sfxresid.hxx>
+#include <vcl/builderfactory.hxx>
+#include <vcl/event.hxx>
+#include <vcl/svapp.hxx>
+
+#include <sfx2/strings.hrc>
+
+#define MNI_OPEN 1
+#define MNI_EDIT 2
+
+#include <officecfg/Office/Common.hxx>
+
+VCL_BUILDER_FACTORY(TemplateDefaultView)
+
+static constexpr int gnItemPadding(5); //TODO:: Change padding to 10. It looks really crowded and occupied.
+static constexpr long gnTextHeight = 30;
+
+TemplateDefaultView::TemplateDefaultView( Window* pParent)
+ : TemplateLocalView(pParent)
+{
+ tools::Rectangle aScreen = Application::GetScreenPosSizePixel(Application::GetDisplayBuiltInScreen());
+ mnItemMaxSize = std::min(aScreen.GetWidth(),aScreen.GetHeight()) > 800 ? 256 : 192;
+ ThumbnailView::setItemDimensions( mnItemMaxSize, mnItemMaxSize, gnTextHeight, gnItemPadding );
+ updateThumbnailDimensions(mnItemMaxSize);
+
+ // startcenter specific settings
+ maFillColor = Color(officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsBackgroundColor::get());
+ maTextColor = Color(officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsTextColor::get());
+ maHighlightColor = Color(officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsHighlightColor::get());
+ maHighlightTextColor = Color(officecfg::Office::Common::Help::StartCenter::StartCenterThumbnailsHighlightTextColor::get());
+ mfHighlightTransparence = 0.25;
+}
+
+void TemplateDefaultView::reload()
+{
+ TemplateLocalView::reload();
+ // Set preferred width
+ set_width_request(gnTextHeight + mnItemMaxSize + 2*gnItemPadding);
+}
+
+void TemplateDefaultView::showAllTemplates()
+{
+ mnCurRegionId = 0;
+
+ insertItems(maAllTemplates, false);
+}
+
+void TemplateDefaultView::KeyInput( const KeyEvent& rKEvt )
+{
+ ThumbnailView::KeyInput(rKEvt);
+}
+
+void TemplateDefaultView::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if( rMEvt.IsLeft() && rMEvt.GetClicks() == 1 )
+ {
+ size_t nPos = ImplGetItem(rMEvt.GetPosPixel());
+ ThumbnailViewItem* pItem = ImplGetItem(nPos);
+ TemplateViewItem* pViewItem = dynamic_cast<TemplateViewItem*>(pItem);
+ if(pViewItem)
+ maOpenTemplateHdl.Call(pViewItem);
+ return;
+ }
+
+ TemplateLocalView::MouseButtonDown(rMEvt);
+}
+
+void TemplateDefaultView::createContextMenu()
+{
+ ScopedVclPtrInstance<PopupMenu> pItemMenu;
+ pItemMenu->InsertItem(MNI_OPEN,SfxResId(STR_OPEN));
+ pItemMenu->InsertItem(MNI_EDIT,SfxResId(STR_EDIT_TEMPLATE));
+ deselectItems();
+ maSelectedItem->setSelection(true);
+ pItemMenu->SetSelectHdl(LINK(this, TemplateLocalView, ContextMenuSelectHdl));
+ pItemMenu->Execute(this, tools::Rectangle(maPosition,Size(1,1)), PopupMenuFlags::ExecuteDown);
+ Invalidate();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */